<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts Multicart                     |
// +----------------------------------------------------------------------+
// | Authors: Programmer<programmer@armia.com>        		              |
// +----------------------------------------------------------------------+
// | Copyrights Armia Systems, Inc and iScripts.com � 2005                |
// | All rights reserved                                                  |
// +----------------------------------------------------------------------+
// | This script may not be distributed, sold, given away for free to     |
// | third party, or used as a part of any internet services such as      |
// | webdesign etc.                                                       |
// +----------------------------------------------------------------------+
include "../includes/config.php";
include "../includes/session.php";
include "../includes/functions.php";

if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}

if(isset( $_SESSION["sess_adminname"]) and $_SESSION["sess_adminname"]!= ""){
	$adminname = $_SESSION["sess_adminname"];
}else{
	header("Location:login.php");
	exit;
}

$rid=($_GET['rid']!='')?$_GET['rid']:$_POST['rid'];
$txtDes = $_POST["txtDes"];
$radActive = $_POST["radActive"];


if (isset($_POST["btnSaveChanges"])) 
{
    $message = "" ;
	
    if (!$txtDes) 
	{
        $message .= REVIEW_EMPTY." <br>";
    }else{
	$sql = mysql_query("UPDATE  ".$tableprefix."Review SET
			vDes = '".addslashes($txtDes)."',
			vActive = '".addslashes($radActive)."' WHERE nRId='".addslashes($rid)."'") or die (mysql_error());
	
	header("Location:product_reviews.php?msg=e");
	exit();
	}
			

}//end if
else if (isset($_POST["btnDelete"])) 
{
	$sql = mysql_query("DELETE FROM  ".$tableprefix."Review	WHERE nRId='".addslashes($rid)."'") or die (mysql_error());
	header("Location:product_reviews.php?msg=d");
	exit();
}

$sql = "SELECT * FROM ".$tableprefix."Review WHERE nRId='".addslashes($rid)."'";
$result = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($result)>0)
{
	$row = mysql_fetch_array($result);
	$txtDes =$row["vDes"];
	$radActive =$row["vActive"];
}//end if

include "../includes/htmltop.php";
?>
<body>
<center>
		
		<div align="left" id="layout">
		
		
				
				
				<!--header area start -->
<?php

	include_once("../includes/topheader_admin.php")

?>
				
				<!--header area end -->
				
				
				
				
				<div align="left" class="main_body">
				<!--main body start -->
				
				
				
<?php
		include_once("../includes/admintopmenu.php")
?>		
																					
								
					<div align="left" class="content_area">
					
					<!--content area start -->
							
					<div align="left" class="page_title"><?php echo EDIT_PRODUCT_REVIEW;?></div>
					<div align="left">
					
					<form name="frmReview" action="" method="POST">
					<input type="hidden" name="rid" value="<?php echo $rid;?>" >
					<div style="text-align:center; padding:5px; color:#FF0000"><?php echo $message; ?></div>
					
					<table cellpadding="0" cellspacing="0" width="100%" class="manage_table">
						
						<tr><td colspan="3">&nbsp;</td></tr>
						<tr><td width="26%" align="right" valign="top"><?php echo DESCRIPTION;?>&nbsp;<span class="required">*</span></td>
						  <td width="4%" align="center" valign="top" >:</td><td width="70%" align="left" valign="top"><textarea name="txtDes" cols="45" rows="8" class="textarea2"><?php echo stripslashes($txtDes);?></textarea></td></tr>
						<tr>
						  <td align="center" ><?php echo ACTIVE;?>&nbsp;<span class="required">*</span></td>
							<td align="center" >:</td>
							<td align="left"><input type="radio" name="radActive" value="1" <?php if($radActive=='1'){ echo 'checked="checked"';}?>><?php echo YES;?>
							<input type="radio" name="radActive" value="0" <?php if($radActive=='0'){ echo 'checked="checked"';}?>><?php echo NO;?></td>
						</tr>
						<tr><td colspan="3">&nbsp;</td></tr>
						<tr><td colspan="3" align="center">
								
								<input type="submit" class="button" value=<?php echo DELETE;?> name="btnDelete" onClick="return confirmDelete();" >&nbsp;&nbsp;
                                                                <input type="submit" value=<?php echo BTN_SAVE_CHANGES;?> name="btnSaveChanges" class="button">&nbsp;&nbsp;&nbsp;&nbsp;</td>
						</tr>
					</table>
					  </form>											

					  </div>
						
						
				<!--content area end-->
								
				</div>
				
								
					<div align="left" class="clear_float"><img src="<?php echo $imagefolder;?>/clear.gif" alt="" width="1" height="1" /></div>
				<!--main body end -->
				</div>
				
				
<?php
	include "../includes/footer.php";
?>
<script type="text/javascript">
function confirmDelete()
{
	return confirm("<?php echo ARE_U_SURE;?>");
}
</script>