<link href="wstyle.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
<div align="center">
<? if ($_GET['stat'] == '' ) { ?>
  <form name="form1" method="post" action="index.php?page=5&stat=search">
    <table width="50%" border="0">
        <tr>
          <td class="td1">Search By</td>
          <td class="td2"><label>
<select name="search_by" id="search_by">
              <option value="Plate">Plate No</option>
              <option value="traf_recpt">Traf .Rcpt No.</option>
              <option value="cpr">CPR</option>
            <option value="mobile">Mobile</option>
            	
            </select>
          </label></td>
        </tr>
        <tr>
          <td class="td1">Search</td>
          <td class="td2"><span id="sprytextfield1">
            <label>
            <input type="text" name="Search" id="Search">
            </label>
          <span class="textfieldRequiredMsg">A value is required.</span></span></td>
        </tr>
      </table>
  </form>
 <? } if ( $_GET['stat'] == 'search' ) { ?>
  <table width="100%" border="0" align="center">
    <tr>
      <td class="td1"><div align="center">Date</div></td>
      <td class="td1"><div align="center">Time</div></td>
      <td class="td1"><div align="center">Plate No.</div></td>
      <td class="td1"><div align="center">Type</div></td>
      <td class="td1"><div align="center">Number <br>
      of <br>
      Plate</div></td>
      <td class="td1"><div align="center">CPR</div></td>
      <td class="td1"><div align="center">Name</div></td>
      <td class="td1"><div align="center">Mobile</div></td>
      <td class="td1"><div align="center">Status</div></td>
      <td class="td1">Rack</td>
      <td class="td1">User</td>
    </tr>
		<?
            $result = mysql_query("SELECT *  FROM p1_order_info where ".$_POST['search_by']." = '".$_POST['Search']."' and stop1 = 0"); 
            while($row = mysql_fetch_array($result)){ 
        
        ?>
    <tr>
      <td class="td2"><div align="center"><? echo $row['Date_a']; ?></div></td>
      <td class="td2"><div align="center"><? echo $row['Time_a']; ?></div></td>
      <td class="td2"><div align="center"><? echo $row['Plate']; ?></div></td>
      <td class="td2"><div align="center"><?	
                        $result1 = mysql_query('select * from p1_plate_type where tyid = '.$row['Type1']); 
                        while($row1 = mysql_fetch_array($result1)){ 
                				echo $row1['plate_type'] ;
								
            
					}
				?></div></td>
      <td class="td2"><div align="center"><? echo $row['number_of_plate']; ?> </div></td>
      <td class="td2"><div align="center"><? echo $row['cpr']; ?> </div></td>
      <td class="td2"><div align="center"><? echo $row['Name']; ?> </div></td>
      <td class="td2"><div align="center"><? echo $row['mobile']; ?> </div></td>
      <td class="td2"><div align="center"><? 
	  					
						if ($row['status']=='0' ) {
							echo 'Factory';
						}	
						if ($row['status']=='1' ) {
							echo 'Printed';
						}	
						if ($row['status'] =='2' ) {
							$oid = $row['oid'];
							$query1 = mysql_query("SELECT * FROM p1_out_order where oid = ".$oid." order by outid desc"); 		
								if (mysql_num_rows($query1) <> "0")	{
								
										$status_24 = mysql_result($query1,0,"status");
										
										if ( $status_24 == 0 ){ echo 'Requested'; } 
										if ( $status_24 == 1 ){ echo 'delivered'; }
										if ( $status_24 == 2 ){ echo 'Under fixing'; }
										if ( $status_24 == 3 ){ echo 'fixing'; }
								
									}else{
										echo 'Delivery';
									}
							
							
						}
						 ?></div></td>
      <td class="td2"><div align="center"><? echo $row['Rack'];	 ?></div>      </td>
      <td class="td2"><div align="center"><? 
	  			$uid = $row['uid'];
	  			$query1 = mysql_query("select * from p1_powers where uid = $uid");
				echo mysql_result($query1,0,"fullname");
	  
	  
	   ?></div></td>
    </tr>
		<?
			}
		?>    
  </table>
  <p>&nbsp;</p>
  <? } ?>
</div>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
//-->
</script>
