<link href="wstyle.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryValidationSelect.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" />
<div align="center">
<? if ($_GET['stat'] == '' ) { ?>
  <form name="form1" method="post" action="index.php?page=24&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"> <input type="text" name="Search" id="Search"></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">Status</div></td>
      <td class="td1">Change status</td>
    </tr>
		<?
            $result = mysql_query("SELECT *  FROM p1_order_info where ".$_POST['search_by']." = '".$_POST['Search']."'"); 
            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"><? 
	  						$_SESSION['24_status'] = $row['status'];
	  						$status_24 = -1;
						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 'Fixed'; }
								
									}else{
										echo 'Delivery';
									}
							
							
						}
						 ?></div></td>
      <td class="td2"><a href="index.php?page=24&stat=cs&id=<? echo $row['oid'];?>&status=<? echo $row['status']?>&status_24=<? echo $status_24?>" class="link">change status</a></td>
    </tr>
    
		<?
			}
		?>    
  </table>
 <? } if ( $_GET['stat'] == 'cs' ) { ?>
            <form id="form2" name="form2" method="post" action="index.php?page=24&stat=update">
              <label><br />
              </label>
              <table width="80%" border="0">
                <tr>
                  <td height="30" class="td1"><div align="center">New Status</div></td>
                  <td class="td2"><div align="center"><span id="spryselect1">
                    <select name="new_status" id="new_status">
                      <option value="">Select --></option>
                      <option value="1">Factory</option>
                      <? if ($_GET['status'] >=1 ) {
                        		?>
                      <option value="2">Printed</option>
                      <? 
							}
                        ?>
                      <? if ($_GET['status'] ==2  ) {
                        		?>
                      <option value="3">Delivery</option>
                      <? 
							}
                        ?>
                      <? if ($_GET['status'] ==2 && $_GET['status_24'] >= 0 ) {
                        		?>
                      <option value="4">Requested</option>
                      <? 
							}
                        ?>
                      <? if ($_GET['status'] ==2 && $_GET['status_24'] >= 1 ) {
                        		?>
                      <option value="5">delivered</option>
                      <? 
							}
                        ?>
                      <? if ($_GET['status'] ==2 && $_GET['status_24'] >= 2 ) {
                        		?>
                      <option value="6">Under fixing</option>
                      <? 
							}
                        ?>
                      <? if ($_GET['status'] ==2 && $_GET['status_24'] >= 3 ) {
                        		?>
                      <option value="7">Fixed</option>
                      <? 
							}
                        ?>
                    </select>
                  <span class="selectRequiredMsg">Please select an item.</span></span></div></td>
                </tr>
              </table>
              <label><br />
              <input name="status" type="hidden" id="status" value="<? echo $_GET['status'];?>" />
              <input name="status_24" type="hidden" id="status_24" value="<? echo $_GET['status_24'];?>" />
              <input name="oid" type="hidden" id="oid" value="<? echo $_GET['id'];?>" />
              <br />
              <input name="Submit" type="submit" class="Submit" id="Submit" value="   Update   " />
              </label>
                                                                        </form>
            <p>&nbsp;</p>
<script type="text/javascript">
<!--
var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1");
//-->
</script>

<? } ?>
</div>

