<?php
session_start();
error_reporting(0);
require 'include/configurations.php'; // ITECHBIDS Configuration File
require 'include/header.php';

$val=$_REQUEST['val'];
$del=$_REQUEST['del'];
$del_id=$_REQUEST['chkSub'];
$delete_allx=$_REQUEST['delete_allx'];
$mode=$_REQUEST['mode'];

if(($del==1)&&(count($del_id)!=0))
{
$w=0;
foreach($del_id as $del_id1)
{
$w++;
$del="delete from feedback where f_id=$del_id1";
mysql_query($del);
}
echo "<font color=#ff0000 ><strong> $w Rows Deleted On successfully ! </strong></font>";
}
if($delete_allx==1)
{
$del="delete from feedback";
if($res=mysql_query($del)) 
echo "<font color=#ff0000 ><strong> All Rows Deleted On successfully ! </strong></font>";
} 

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form method="get" action="feedback.php" >
 <table align="center" width="80%" class="ft">
<tr class="ct" height="25"><td colspan="2"> Search</td></tr>
<tr >
<td>User Name: <input type=text name="user" ></td>
<td> Item Id: <input type=text name="item" ></td>
</tr>
<tr><td align="center" colspan="2"><input type="submit" class="button"   value="Search" ></td></tr>
</table> 
</form>
<br>
</from>
<table width="75%" ><tr>
<td><a href="feedback.php?type=positive" style="text-decoration:none"  id="link1">Positive</a></td>
<td><a href="feedback.php?type=negative" style="text-decoration:none"  id="link1">Negative</a></td>
<td><a href="feedback.php?type=neutral" style="text-decoration:none"  id="link1">Neutral</a></td>
<td><a href="feedback.php" style="text-decoration:none"  id="link1">All</a></td>
</tr></table>
<br>
<?
$type=$_REQUEST['type'];
$item=$_REQUEST['item'];
$user=$_REQUEST['user'];

$query="select * from feedback";
if( ($type!="") || ($item!="") || ($user!="") )
$query.=" where ";
if($type!="")
$query.="feedback_type= \"$type\"";
else if($item!="")
$query .=" productid=\"$item\"";
else if($user!="")
{

$myquery="select * from member_details where user_name=\"$user\" ";

$tab=mysql_query($myquery);
$row=mysql_fetch_array($tab);
$id=$row['user_id'];
if($id=="")$id=-1;
$query.="feedback_to= $id";
//echo $query;

} 
//echo $query;
$table=mysql_query($query);
if(mysql_num_rows($table)==0)
{
echo "<b> No Feedback Found </b>";
}
else
{
?>
<form name="myform" method="get" action="<? $_SERVER['PHP_SELF'] ?>" name="frm1">

<table width="75%">
<?
$total=mysql_num_rows($table);
$totalx=($total/5);

$reminder=($total%5);
settype($totalx,'int');

if(($reminder==0)&&($total!=0))
$totalx=$totalx-1;

$set=$_REQUEST['set'];
if($set=="")$set=0;
$href ="feedback.php?";
$href .="user=" .$_REQUEST['user'] . "&item=" . $_REQUEST['item'] . "&del=" .$_REQUEST['del'] . "&del_id=". $_REQUEST['del_id'];
$href .="&type=" .$_REQUEST['type'];
//$href .="csz=" . $csz . "&price_start=" . $price_start . "&price_end=" . $price_end;
//$href .="&bed=" . $bed . "&bath=" . $bath . "&set=";

$href.="&set=";
?>
<tr><td colspan="8" align="center" >
<b>There are <?= $total; ?> properties Selected.</b>
</td>
<td>
<? if($set!=0){ ?>  <a href="<?=$href.($set-1) ?>  style="text-decoration:none"  id="link1"">  <? }?>    Prev <? if($set!=0) {?> </a>  <? }?>
</td><td>
<? if($set!=$totalx){ ?>  <a href="<?=$href.($set+1) ?>  style="text-decoration:none"  id="link1"">  <? }?>     Next  <? if($set!=$totalx) {?> </a> <? }?>

</td></tr>
</table>







<table align="center" width="97%" class="ft">
<tr class="ct" height="25">
<td width="5%">	</td>
<!-- <td width="15%" align="center">FeedBack Id</td> -->
<td width="11%" align="center">Date</td>
<td width="15%" align="center">Type</td>
<td width="13%" align="center">Item Id</td>
<td width="13%" align="center">User Id</td>
<td width="33%" align="center">FeedBack</td>
<td width="10%">Edit</td>
</tr>





<?
$start= $set*5 +1;
$end=$set*5 +5;
$i=0;

while($row=mysql_fetch_array($table))
{
$i++;
if(($i<$start)||($i>$end))
continue;
?>

<tr  >
<td><input name="chkSub[]" id="chkSub" type="checkbox" class="check" value="<?php echo $row['f_id'];  ?>"></td>
<!-- <td><?= $row['f_id']?></td> -->
<td><?= $row['date']?></td>
<td><?= $row['feedback_type']?></td>
<td><?= $row['productid']?></td>
<?
$queryx="select * from member_details where user_id=$row[feedback_to]";
$tablex=mysql_query($queryx);
$rowx=mysql_fetch_array($tablex);
?>
<td><?= $rowx['user_name']?></td>
<td><?= $row['feedback']?></td>
<td><a href="feedback_edit.php?fid=<?= $row['f_id'] ?>"  style="text-decoration:none"  id="link1"> Edit </a></td>
</tr>
<?
}

?>

<tr>
    <td colspan="8"  align="center">
      	<input type="hidden" name="del" value="1">
        <input type="hidden" name="del_id" value="<?php echo $row['f_id']; ?>">
        <input type="hidden" name="user" value="<?= $_REQUEST['user'] ?>">
        <input type="hidden" name="item" value="<?= $_REQUEST['item'] ?>">
        <input type="hidden" name="type" value="<?= $_REQUEST['type'] ?>">				
		<input type="hidden" name="set" value="">
		<input type="hidden" name="delete_allx" value="0">
	    <input type="submit" class="button"   name="delete" value="Delete" >
		
	   <input type="button" name="delete_all" value="Delete All"  onclick="mydelall()">
    </td>
  </tr>
</table>
</form>
<?
}
?>
<?
require 'include/footer.php';
?>
</body>
</html>
<script language="javascript">
function mydel()
{
  var where_to= confirm("Are U Sure U Want to delete the items?");
  if (where_to== true)
  {
    document.myform.delete1.value=1;
    document.myform.submit();
  }
  else
  {
    window.location="feedback.php";
    document.myform.submit();
  } 
}

function mydelall()
{
  var where_to= confirm("Are U Sure U Want to delete the items?");
  if (where_to== true)
  {
    document.myform.delete_allx.value=1;
    document.myform.submit();
  }
  else
  {
    window.location="feedback.php";
    document.myform.submit();
  } 
}

</script>