<? session_start();
 include("../opendb.php");
 include("../test.php");
?>
<style>
input,select,td{font-family:'arial narrow';letter-spacing:1;font-size:12}
.mnu{margin-left:5}
th{color:white;font-family:'arial narrow';font-size:12}
a{color:white; text-decoration:underline}
h3{font-family:'arial narrow';}
a{text-decoration:none}
</style>
<CENTER>
<?
print "<h3>Pre-sale report ";
if($vd)
{
 mysqli_query($db,"update presale set chkd='y' where code='$code' and brcode='$brcode'");
}

if($ord)
$sql="select * from presale where  brcode='$brcode' and chkd='n' order by $ord";
else if($exec=='All')
$sql="select * from presale where  brcode='$brcode' and chkd='n' order by no";
else 
$sql="select * from presale where brcode='$brcode' and chkd='n' and (exec='$exec' or phead='$exec' or disthea='$exec') order by no";
 $re=mysqli_query($db,$sql);
print "<table cellspacing=1 cellpadding=2 bgcolor='steelblue'>";
print "<th>No<th>Date<th>Name <th>Address<th>Phone<th>Segment <th>Profile<th>Status <th>Financer <th>Area <th bgcolor='lightsteelblue'><a href='$PHP_SELF?ord=11&dfrom=$dfrom&dto=$dto'>Executive</a>";
print "<th bgcolor='lightsteelblue'><a href='$PHP_SELF?ord=16&dfrom=$dfrom&dto=$dto'>Prod Head ";
print "<th bgcolor='lightsteelblue'><a href='$PHP_SELF?ord=15&dfrom=$dfrom&dto=$dto'>Dist Head<th>Discussion<th>Acc by <th>Viewed";
$i=1;
 while($row=mysqli_fetch_array($re))
 {
   print "\n<tr bgcolor=white><form action='$PHP_SELF'>";
   print "<input type=hidden name='code' value='$row[code]'>";
   print "<input type=hidden name='dfrom' value='$dfrom'>";
   print "<input type=hidden name='dto' value='$dto'>";
   print "<input type=hidden name='ord' value='$ord'>";

   $code=substr($row[na],0,3).rand(100,999); 
   print "\n<td>$i</td><td>".datetohtml($row[1])."</td><td>$row[2]</td><td>$row[3]</td>";
   print "<td>$row[4]</td><td>$row[5]</td><td>$row[6]</td><td>$row[7]</td><td>$row[8]</td>";
   print "<td>$row[9]</td><td>$row[10]</a></td><td>$row[phead]</td><td>$row[disthea]</td><td>$row[discuss]</td><td>$row[12]</td><td><input type=submit value='Viewed' name='vd'></td></form></tr>";
 $i++;
 }
print "<tr bgcolor='steelblue'><td></td>";
return;

?>
<!--
<form action='<?print $PHP_SELF?>' name='f1' target='x'>
<table BGCOLOR=STEELBLUE>
<tH colspan=2><center><b><font color=white>PRESALE REPORT</tH>
<tr bgcolor=white><td>Date From </td><td>dd<input type=text name='d' size=2 value='<?print date("d");?>'>
			mm<input type=text name='m' size=2 value='<?print date("m");?>'>
			yy<input type=text name='y' size=4 value='<?print date("Y");?>'>
</td></tr>
<tr bgcolor=white><td>Date To </td><td>dd<input type=text name='d1' size=2 value='<?print date("d");?>'>
			mm<input type=text name='m1' size=2 value='<?print date("m");?>'>
			yy<input type=text name='y1' size=4 value='<?print date("Y");?>'>
</td></tr>
<tr  bgcolor=white><td>Executive</td><td>
<select name='exec'>
<option>All</option>
<?
$exeres=mysqli_query($db,"select distinct exec from presale where exec!=' 'order by exec");
while($exerow=mysqli_fetch_array($exeres))
{
 print "<option>$exerow[0]</option>";
}
$exeres1=mysqli_query($db,"select distinct disthea from presale  where disthea!=' 'order by disthea");
while($exerow=mysqli_fetch_array($exeres1))
{
 print "<option>$exerow[0]</option>";
}
$exeres2=mysqli_query($db,"select distinct phead from presale  where phead!=' 'order by phead");
while($exerow=mysqli_fetch_array($exeres2))
{
 print "<option>$exerow[0]</option>";
}
?>
</select>
</td></tr>
<th colspan=2><INPUT TYPE=SUBMIT VALUE='SHOW / PRINT' name='show'></td></tr>
</table>
</form>
-->
