
<? session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}
include("../opendb.php");
include("../test.php");
?>
<style>
body,td{font-family:'arial narrow';letter-spacing:1;font-size:13}
th{background-color:green;color:white}
.mnu{margin-left:5}
</style>
<body bgcolor='ivory'>
<form action='<?print $PHP_SELF?>'>
<table border=1 >
<tr><td align=center>Year <input type=text name='seafno' size=5></td><td> customer Name <input type=text name='seaname'></td><td>Rep.
<select name='exe'><option></option>
<?
 $r=mysqli_query($db,"select distinct exec,exec from compcustnew order by exec")or die(mysqli_error());
 while($reprow=mysqli_fetch_row($r))
 {
 print "<option value='$reprow[0]'>$reprow[1]</option>";
 }
?>
</select></td><td>Make.
<select name='mexe'><option></option>
<?
 $r1=mysqli_query($db,"select distinct make,make from compcustnew order by make")or die(mysqli_error());
 while($reprow1=mysqli_fetch_row($r1))
 {
 print "<option value='$reprow1[0]'>$reprow1[1]</option>";
 }
?>
</select></td><td>District
<select name='dexe'><option></option>
<?
 $r1=mysqli_query($db,"select distinct dist,dist from compcustnew order by make")or die(mysqli_error());
 while($reprow1=mysqli_fetch_row($r1))
 {
 print "<option value='$reprow1[0]'>$reprow1[1]</option>";
 }
?>
</select></td><td>Config.
<select name='cexe'><option></option>
<?
 $r1=mysqli_query($db,"select distinct config,config from compcustnew order by make")or die(mysqli_error());
 while($reprow1=mysqli_fetch_row($r1))
 {
 print "<option value='$reprow1[0]'>$reprow1[1]</option>";
 }
?>
</select></td><td>
<input type=submit value='Search' name='sea'>
</td></tr>
</table>
</form>
<br>
<?
$sql="select * from compcustnew where brcode='$brcode'";

if($sea)
{ print '<font color=blue> Search Result: </font>';
 if(strlen($seafno)>0)
  $sql="select * from compcustnew where brcode='$brcode' and model='$seafno' order by model";
 else if(strlen($seaname)>0)
  $sql="select * from compcustnew where brcode='$brcode' and name like '%$seaname%' order by name";
 else if(strlen($exe)>0)
  $sql="select * from compcustnew where brcode='$brcode' and exec= '$exe'";
 else if(strlen($mexe)>0)
  $sql="select * from compcustnew where brcode='$brcode' and make= '$mexe'";
 else if(strlen($dexe)>0)
  $sql="select * from compcustnew where brcode='$brcode' and dist= '$dexe'";
 else if(strlen($cexe)>0)
  $sql="select * from compcustnew where brcode='$brcode' and config='$cexe'";


}
else
 print "<font color=blue>Printing last 100 order forms</font>";

$re=mysqli_query($db,$sql) or die(mysqli_error());
if(mysqli_num_rows($re)<=0)
{
 print "<font color=red>Record does not exist</font>";
 return;
}


print "<table border=1> <th>No <th>Name<th>Add1 <th>Add2 <th>Add3 <th>District <th>Mobile <th>Landline<th>Make <th>Configure <th>Year<th>Executive";

while($row=mysqli_fetch_array($re))
{
$sql="select * from rep_master where branch='$brcode' and code= '$row[rname]'";
$re1=mysqli_query($db,$sql) or die(mysqli_error());
$rep=mysqli_fetch_row($re1);

 print "\n<tr><td align=center>";
if($row[stat]=='In-Active')
 print "<font color=red size=3><b> * </b></font>";
print "$row[0]</td><td>$row[1]</td><td>".strtoupper($row[2])."</td><td>$row[3]</td><td>$row[4]</td><td>$row[5]</td><td align=right>$row[6]</td><td>$row[7]</td><td>$row[8]</td><td>$row[9]</td><td>$row[10]</td><td>$row[11]</td><td>";
if($level>=4) 
 print "<a href='0.php?code=$row[formno]'>[Edit]</a>";
else
 print "&nbsp;</td>";
print "</tr>";
}
?>
</table>

