<?php
require_once ("../config.inc.php");
require_once ("../includes/adminlogincheck.inc.php");
require_once ("../includes/mysql.inc.php");
require_once ("../includes/arrays.inc.php");
require_once ("../classes/miscellaneous.class.php");
require_once "../includes/fckeditor/fckeditor.php";

$page		= isset($_REQUEST['page'])	?	trim($_REQUEST['page'])	:	"1";
$id			= isset($_REQUEST['id'])	?	trim($_REQUEST['id'])	:	"0";
$active     = isset($_REQUEST['chkActive'])	?	trim($_REQUEST['chkActive'])	:	"0";
$uid2       = isset($_REQUEST['uid'])	?	trim($_REQUEST['uid'])	:	"0";

$message	= "";
if (!$objDB) {
	$message	= "Unable to Locate Database Server.";
} else {
	$objM		= new miscellaneous($objDB);
	$objM->set_testimonial($_POST);
	if (isset($_POST['SaveNow'])) {
		$message	= $objM->save_testimonial($id,$uid2,$active);
		if ($message == "") {
			header("Location: testimonials.php?page=$page&act=1");
			exit;
		}
	} elseif (isset($_POST['BackNow'])) {
		if ($message == "") {
			header("Location: testimonials.php?page=$page");
			exit;
		}
	} else {
		$array	= $objM->get_testimonial($id);
		$objM->set_testimonial($array);
	}
}

include_once('title.inc.php');
?>
<script language="javascript" type="text/javascript">
function validate()
{
	var frm	= document.frmUser;
	
	if (frm.vTitle.value == "") {
		alert("Please enter title of the event.");
		frm.vTitle.focus();
		return false;
	}
	if (frm.vCity.value == "") {
		alert("Please enter city of the event.");
		frm.vCity.focus();
		return false;
	}
	if (frm.vVenue.value == "") {
		alert("Please enter venue of the event.");
		frm.vVenue.focus();
		return false;
	}
	if (frm.dDate_Event.value == "") {
		alert("Please enter date of the event.");
		frm.dDate_Event.focus();
		return false;
	}
	if (frm.vDescription.value == "") {
		alert("Please enter description of the event.");
		frm.vDescription.focus();
		return false;
	}
	return true;
}
</script>
<?php include_once('tophtml.php');?>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top" class="white"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="72%" valign="top">
			<table width="100%"  border="0" cellspacing="0" cellpadding="5">
          <tr>
            <td><table width="100%"  border="0" cellspacing="0" cellpadding="5">
              <tr>
                <td width="41%" class="headings1" colspan="2">Manage Testimonial</td>
              </tr>
            </table>
			<div class="bordernew padding2">
				<form name="frmUser" method="post" action="" >
          <table width="100%"  border="0" cellspacing="0" cellpadding="5">
            <tr>
              <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
				<?php if ($objDB) 
					  { 
				?>
					<?php 	if(isset($message) && $message!='')
							{
					?>
                <tr align="left">
                  <td align="center" class="maintext2">&nbsp;</td>
                  <td colspan="2" class="maintext2 warning"><?php echo $message;?></td>
                  </tr>
					<?php  	}//end if?>
  				<tr align="left">
                  <td width="3%" class="maintext2">&nbsp;</td>
                  <td width="20%" valign="top" class="maintext2">Testimonial Description</td>
                  <td width="70%" valign="top" class="maintext2"><textarea name="tContent" cols="80" rows="12" class="textbox_textarea"><?php echo stripslashes($objM->tContent)?></textarea></td>
  				</tr>
                 <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td valign="top" class="maintext2">Active</td>
                  <td valign="top" class="maintext2"><input type="radio" name="chkActive" value="1" <?php if($objM->vActive=='1'){echo 'checked';}if($objM->vActive==''){echo 'checked';}?>>Yes
									<input type="radio" name="chkActive" value="0" <?php if($objM->vActive=='0'){echo 'checked';}?>>No</td>
                 </tr>
				<?php 			
						}//end first if
				?>
              </table>
                <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td align="right"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td>&nbsp;</td>
                      </tr>
                    </table>
                      <?php if ($objDB) 
					  { 
					?>
                      <table width="100%"  border="0" cellspacing="0" cellpadding="5">
                      <tr>
                        <td align="left"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td width="25%">&nbsp;</td>
                              <td width="7%">

<input name="BackNow" type="submit" class="back-btn" value="Back"></td>
							  <?php //if ($id > 0) { ?>
                              <td ><input name="SaveNow" type="submit" class="loginbutton" value="Save" onclick="return validate();"><input type="hidden" name="page" value="<?php echo $page?>">
                                      <input type="hidden" name="id" value="<?php echo $id?>"><input type="hidden" name="uid" value="<?php echo $array['nUser_Id']?>"></td>
							  <?php //}//end if?>
                              </tr>
                        </table></td>
                      </tr>
                    </table>
					<?php 		
						}//end first if
				?></td>
                  </tr>
                </table></td>
            </tr>
          </table></form>
			</div>
			</td>
          </tr>
        </table>
		</td>
        </tr>
    </table>      
    </td>
  </tr>
</table>
<?php include_once('bottomhtml.php');?>