<?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.                                                       |
// +----------------------------------------------------------------------+
?>
<?php
include "../includes/config.php";
include "../includes/session.php";
include "../includes/functions.php";

if (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;
}
if(isset( $_GET["feedbackid"]) and $_GET["feedbackid"]!= ""){
	$feedbackid = $_GET["feedbackid"];
}else if(isset( $_POST["feedbackid"]) and $_POST["feedbackid"]!= ""){
	$feedbackid = $_POST["feedbackid"];
}else{
	header("Location:feedbacks.php");
	exit;
}


$chkPublished = $_POST["chkPublished"];
if($chkPublished == "on"){
	$chkPublished = "Y";
}else{
	$chkPublished = "N";
}

if(isset($_POST["btnSaveChanges"])){
	$sql ="UPDATE  ".$tableprefix."feedbacks SET 
		published = '".addslashes($chkPublished)."'
		WHERE 	feedback_id = '".addslashes($feedbackid)."'
		";
	$res = mysql_query($sql);

	$message = CHANGES_SAVED_SUCCESSFULLY;
}else if(isset($_POST["btnDelete"])){ 
	$sql ="DELETE FROM  ".$tableprefix."feedbacks 
		WHERE 	feedback_id = '".addslashes($feedbackid)."'
		";
	$res = mysql_query($sql);
	header("Location:feedbacks.php?msg=deleted");
	exit;
}

if(isset($_GET["msg"]) and $_GET["msg"]!=""){
	$msg = $_GET["msg"];
	switch($msg){
		case "deleted": $message = MSG_USER_DELETED;break;
		default:
			;
	} // switch
	
}

$sql = "SELECT * FROM ".$tableprefix."feedbacks  WHERE feedback_id = '".addslashes($feedbackid)."' ";
$result = mysql_query($sql);
if(mysql_num_rows($result) != 0){
	$row = mysql_fetch_array($result);
	$txtFirstName = $row["first_name"];
	$txtLastName = $row["last_name"];
	$txtEmail = $row["email"];
	$txtFeedbackContent = $row["feedback_content"];
	$txtDateAdded = $row["date_added"];
	$txtDateAdded = dateFormat($txtDateAdded,"Y-m-d","m/d/Y");
	$userid = $row["user_id"];
	$chkPublished = $row["published"];
}

include "../includes/htmltop.php";
?>

<SCRIPT>
function confirmDelete(){
	if(confirm("<?php echo ARE_YOU_SURE_DELETE_RECORD;?>") ){
		return true;
	}
	return false;
}
</SCRIPT>
<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 VIEW_FB;?></div>
					<div align="center" class="text_information grey_tr"><?php echo $message?></div>
            		<br>
											
					<div align="left">			
					
					<form name="frmFeedback" action="<?php echo $_SERVER["PHP_SELF"]?>" method="POST">
					<input type="hidden" name="feedbackid" value="<?php echo htmlentities($feedbackid);?>">
					<table cellpadding="0" cellspacing="0" width="100%" class="manage_table">
						
						<tr><td colspan="3">&nbsp;</td></tr>
						<tr><td colspan="3" align="right"><span class="required">*</span>&nbsp;<?php echo FIELDS_ARE_MANDATORY;?></td></tr>
						<tr><td width="16%" align="left" ><?php echo FNAME;?>&nbsp;<span class="required">*</span></td><td width="2%" >&nbsp;</td><td width="82%" align="left"><input class="textbox" type="text" value="<?php echo ($txtFirstName);?>" name="txtFirstName" size="30" maxlength="100" readonly></td></tr>
						<tr><td align="left" ><?php echo LNAME;?> &nbsp;</td><td >&nbsp;</td><td align="left"><input type="text" class="textbox" value="<?php echo ($txtLastName);?>" name="txtLastName" size="30" maxlength="100" readonly></td></tr>
						<tr><td align="left" ><?php echo EMAIL;?>&nbsp;<span class="required">*</span></td><td >&nbsp;</td><td align="left"><input class="textbox" type="text" value="<?php echo htmlentities($txtEmail);?>" name="txtEmail" size="30" maxlength="100" readonly></td></tr>
						<tr><td align="left" valign="top"><?php echo USER_FB;?>&nbsp;<span class="required">*</span></td><td >&nbsp;</td><td align="left"><TEXTAREA class="textbox" name="txtFeedback" rows="8" cols="45" readonly><?php echo (stripslashes($txtFeedbackContent));?></TEXTAREA></td></tr>
						<tr><td align="left" ><?php echo PUBLISHED1;?>&nbsp;</td><td >&nbsp;</td><td align="left"><input class="checkbox" type="checkbox" name="chkPublished" <?php if($chkPublished == "Y"){ echo "CHECKED";} ?> ></td></tr>
						<tr><td colspan="3">&nbsp;</td></tr>
						<tr><td colspan="3" align="center">
                                                        <input type="button" class="button" value="<?php echo BACK_TO_FB;?>" name="btnBackToFeedbacks" onClick="window.location.href='feedbacks.php'" >&nbsp;&nbsp;<input type="submit" class="button" value="<?php echo DELETE;?>" name="btnDelete" onClick="return confirmDelete();">
                                                        &nbsp;&nbsp;<input type="submit" class="button" value="<?php echo BTN_SAVE_CHANGES;?>" name="btnSaveChanges">
                                                        </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";
?>