<?php
session_start();
error_reporting(0);
require 'include/configurations.php'; // ITECHBIDS Configuration File
require 'include/header.php';
function select_tag_string($name, $array,$key)
{
$tag="<select name=\"$name\">";
foreach($array as $field)
{
if($key==$field)
$tag=$tag . "<option value=\"$field\" selected>$field</option>";
else
$tag=$tag . "<option value=\"$field\">$field</option>";
}
$tag=$tag . "</select>";
return $tag;
}



?>
<?
$status=0;
if(isset($_REQUEST['alter']))
{
   if($status==0)
  {
  //echo "y hao";
  
   $feedback_id=$_REQUEST['feedback_id'];
   $feedback=$_REQUEST['feedback'];
   $feedback_type=$_REQUEST['type'];
   $query ="update feedback set ";
   $query .=" feedback='$feedback' , feedback_type ='$feedback_type'  where f_id= $feedback_id";
   //echo $query;
      if( mysql_query($query))
      {
	   echo "<meta http-equiv='refresh' content='0;url=feedback.php'>";
      }
      else
      {
      }
  }
  else
  {
   echo "<h4><center>Please fill in the fields marked in red</center></h4>";
  }
  
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
$fid=$_REQUEST['fid'];
$query="select * from feedback where f_id=\"$fid\"";
$table=mysql_query($query);
$row=mysql_fetch_array($table);
if($row[seller_id])
{
$fromid=$row[seller_id];
}
else
{
$fromid=$row[buyer_id];
}

$from="select * from member_details where user_id=$fromid";
$from_res=mysql_query($from);
$from_row=mysql_fetch_array($from_res);
$fromid=$from_row[user_name];

$to="select * from member_details where user_id=$row[feedback_to]";
$to_res=mysql_query($to);
$to_row=mysql_fetch_array($to_res);
$toid=$to_row[user_name];



?>
<font color="#0000FF"><center><h4>Edit Feedback</h4></center></font>
<form action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
<table class="ft" width="69%">
<tr  class="ct" height="25"><td colspan="2" align="center"> Edit Feedback</td></tr>
 <tr ><td><font color="<? if($e_productid=="true") echo"#ff0000"; ?>"> Item Id</td>
  <td> <? echo $row['productid']; ?> </td></tr>
  
<tr ><td><font color="<? if($e_user_id=="true") echo"#ff0000"; ?>"> To User </td>
<td><? echo $toid ?> </td></tr>

<tr ><td><font color="<? if($e_user_id=="true") echo"#ff0000"; ?>"> From User </td>
<td><? echo $fromid  ?> </td></tr>
  
<tr ><td><font color="<? if($e_feedback=="true") echo"#ff0000"; ?>"> Feedback</td> 
<td> <textarea name="feedback" cols=30 rows=15><?  if(isset($_REQUEST['alter'])) echo $_REQUEST['feedback']; else echo $row['feedback']; ?></textarea></td></tr>
<tr ><td><font color="<? if($e_type=="true") echo"#ff0000"; ?>">Feedabck Type</td> 
<?
$array=array("Positive","Negative","Neutral");
 if(isset($_REQUEST['alter'])) 
$name = $_REQUEST['type']; 
else 
$name=$row['feedback_type'];  ?>
 <td><?= select_tag_string("type", $array ,$name); ?> </td></tr>


  
<input type="hidden" name=feedback_id value="<?= $row['f_id']; ?>">

<tr ><td align="center" colspan="2"><input type="submit" class="button"   name="alter" value=" Alter " > </td></tr>
</table>
</form>
<?
require 'include/footer.php';
?>
</body>
</html>
