<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">Total Payment</p>
<form action="index.php?page=51&stat=print" method="post" name="form1" target="_blank" id="form1">
  <table width="80%" border="0" align="center">
    <tr>
      <td class="td1">From 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>
    <tr>
      <td class="td1">To Date</td>
      <td class="td2"><span id="sprytextfield2">
      <label>
      <input type="text" name="to_date" id="to_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' ) { 
			$plate_count = 0;
            $result = mysql_query('SELECT *  FROM p1_plate_type',$db); 
            while($row = mysql_fetch_array($result)){ 
				$plate_count = $plate_count + 1;
				$plate_name[$plate_count] = $row['plate_type'];
				
			
			}
    		?>
						<p align="center" class="link">Total Payment</p>
<table width="100%" border="1" align="center" bordercolor="#000000">
                          <tr>
                            <td rowspan="2" class="td_print1">Date</td>
                            <td colspan="<? echo $plate_count?>" class="td_print1">Plate Color code</td>
                            <td rowspan="2" class="td_print1">Total</td>
                          </tr>
                          <tr>
                          <? for ($loop=1;$loop<=$plate_count;$loop++)
						  	{	
							?>
                            <td class="td_print1"><? echo $plate_name[$loop];?></td>
   
                            <? } ?>
                          </tr>
                        <?

							$result = mysql_query("select sum(number_of_plate),Date_a from p1_order_info where Date_a between  '".$_POST['from_date']."' AND '".$_POST['to_date']."' and stop1=0 group by Date_a"); 
							$sum_nop = 0;
							while($row = mysql_fetch_array($result)){ 
						?>
                          <tr>
                            <td class="td_print2"><? echo $row['Date_a'];?></td>
                         <? 
						 $total = 0;
						 for ($loop=1;$loop<=$plate_count;$loop++) 	{	?>
                            <td class="td2"><? 
							
							$query1 = mysql_query("SELECT sum(number_of_plate)  number_of_plate  FROM p1_order_info where Date_a = '".$row['Date_a']."' and type1 = ".$loop." and stop1 = 0"); 		
											if (mysql_result($query1,0,"number_of_plate") *1 > 0 )
												{								
													echo mysql_result($query1,0,"number_of_plate")*3.5;	
													$total = $total+mysql_result($query1,0,"number_of_plate")*3.5;
												}else{
													echo 0;
												}
							?></td>
                           <? } ?>
                            <td class="td2"><? echo $total;?></td>
                          </tr>
						<? 
						
								
						
							}
						?>
                        </table>
<p align="center">&nbsp;</p>


<? } ?>
<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});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "date", {useCharacterMasking:true, format:"yyyy-mm-dd"});
//-->
</script>
