<link href="wstyle.css" rel="stylesheet" type="text/css" />
<? if ($_GET['stat'] == '' ) { ?>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<p align="center" class="link">Delivered Onsite</p>
<form action="index.php?page=54&stat=print" method="post" name="form1" target="_blank" id="form1">
  <table width="80%" border="0" align="center">
    <tr>
      <td class="td1">Date</td>
      <td class="td2"><span id="sprytextfield1">
      <label>
      <input type="text" name="from_date" id="from_date" />
      </label>
      <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">*</span></span>  YYYY-MM-DD</td>
    </tr>
  </table>
  <p align="center">
    <input name="Submit" type="submit" class="Submit" id="Submit" value="   Show   " />
  </p>
</form>
<? } if ($_GET['stat'] == 'print' ) { 
							
    		?>
						<p align="center" class="link">Delivered Onsite</p>
						<p align="center" class="link">( <? echo $_POST['from_date'] ?> )</p>
<table width="80%" border="0" align="center">
<tr>
      <td class="td1"><div align="center">Time</div></td>
      <td class="td1"><div align="center">Total Delivered</div></td>
    </tr>
    <tr>
      <td class="td2">Befor</td>
      <td class="td2"><?
      			$query = mysql_query("select count(*) total from p1_out_order where stop1=1 and status3_dt between '".$_POST['from_date']." 00:00:00' and '".$_POST['from_date']." 07:59:59'"); 
	  			echo  mysql_result($query,0,"total");
				$total =  mysql_result($query,0,"total");
	  ?></td>
    </tr>
    <?	
                        $result = mysql_query('select * from p1_default_time'); 
                        while($row = mysql_fetch_array($result)){ 
                ?>
    <tr>
      <td class="td2"><div align="center"><? echo $row['time_name']?></div></td>
      <td class="td2"><div align="center"><?
	  
	  $next_time = str_replace("00:00","59:59",$row['time_name']);

	  
	  
      			$query = mysql_query("select count(*) total from p1_out_order where stop1=1 and status3_dt between '".$_POST['from_date']." ".$row['time_name']."' and '".$_POST['from_date']." ".$next_time."'"); 
	  			echo  mysql_result($query,0,"total");
				$total =$total + mysql_result($query,0,"total");
				
	  ?></div></td>
    </tr>
    <?
          }
    ?>
    <tr>
      <td class="td2">After</td>
      <td class="td2"><?
      			$query = mysql_query("select count(*) total from p1_out_order where stop1=1 and status3_dt between '".$_POST['from_date']." 21:00:00' and '".$_POST['from_date']." 23:59:59'"); 
	  			echo  mysql_result($query,0,"total");
				$total =$total +  mysql_result($query,0,"total");
	  ?></td>
    </tr>
    <tr>
      <td class="td1">Total</td>
      <td class="td1"><? echo $total ?></td>
    </tr>
  </table>


<? } ?>
<p>&nbsp;</p>
<div align="center">



</div>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "date", {format:"yyyy-mm-dd", useCharacterMasking:true});
//-->
</script>
