<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">POS Summary</p>
<form action="index.php?page=57&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' ) { 

    		?>
						<p align="center" class="link">B1  W.L.L.<br />
						Summary of POS Transactions<br />
						For the Period: <? echo $_POST['from_date'];?> to <? echo $_POST['to_date'];?></p>
                        <div align="center">
                          <table width="60%" border="1">
                            <tr>
                              <td rowspan="2" class="td_print1">Plates</td>
                              <td colspan="2" class="td_print1">Quantity</td>
                              <td rowspan="2" class="td_print1">Value</td>
                            </tr>
                            <tr>
                              <td class="td_print1">Long</td>
                              <td class="td_print1">Short</td>
                            </tr>
								<?
                                    $result = mysql_query("SELECT *  FROM p1_plate_type"); 
                                    while($row = mysql_fetch_array($result)){ 
									
										$query1 = mysql_query("SELECT sum(Size1)  Size1  , sum(Size2)  Size2  FROM p1_order_info where Date_a between  '".$_POST['from_date']."' AND '".$_POST['to_date']."' and type1 = ".$row['tyid']." and stop1 = 0"); 		
                                ?>
                            <tr>
                              <td><div align="center"><b><? echo $row['plate_type'];?></b></div></td>
                              <td><div align="center"><span class="td_print2"> <? if (mysql_result($query1,0,"Size1") *1 > 0 )
												{								
													echo mysql_result($query1,0,"Size1");	
													$Size1 = mysql_result($query1,0,"Size1");
												}else{
													echo 0;
													$Size1 = 0;
												}
												
												$Size1_total = $Size1_total +$Size1;
							?>
                              </span></div></td>
                              <td><div align="center"><span class="td_print2"> <? if (mysql_result($query1,0,"Size2") *1 > 0 ) {	
															  	echo mysql_result($query1,0,"Size2");
																$Size2 = mysql_result($query1,0,"Size2");											
														}else{
																echo 0;
																$Size2 = 0;
												}
												$Size2_total = $Size2_total +$Size2;
												
												?></span></div></td>
                              <td><div align="center"><span class="td_print2"><? echo ($Size1+$Size2)*$row['plate_price'] ;
												$Size12_total = $Size12_total + ($Size1+$Size2)*$row['plate_price'];
							  
							  ?></span></div></td>
                            </tr>

                            <? } ?>
                            <tr>
                              <td class="td_print1">Total</td>
                              <td class="td_print1"><? echo $Size1_total?></td>
                              <td class="td_print1"><? echo $Size2_total?></td>
                              <td class="td_print1"><? echo $Size12_total?></td>
                            </tr>
                          </table>
                          <br />
                         
                        </div>
                       
                       
                        <?
						
						
						$query = mysql_query("select sum(bs),sum(bl),sum(ss),sum(sl),sum(ws),sum(wl),sum(fiber),sum(screws) from p1_sale where create_date between '".$_POST['from_date']."' AND '".$_POST['to_date']."'");
						
								if (mysql_result($query,0,"sum(bs)") <> "" ) 
									{
										$bs = mysql_result($query,0,"sum(bs)");
									}else{
										$bs = 0;
									}
								if (mysql_result($query,0,"sum(bl)") <> "" ) 
									{
										$bl = mysql_result($query,0,"sum(bl)");
									}else{	
										$bl = 0;
									}
								if (mysql_result($query,0,"sum(ss)") <> "" ) 
									{
										$ss = mysql_result($query,0,"sum(ss)");
									}else{	
										$ss = 0;
									}
								if (mysql_result($query,0,"sum(sl)") <> "" ) 
									{
										$sl = mysql_result($query,0,"sum(sl)");
									}else{	
										$sl = 0;
									}
								if (mysql_result($query,0,"sum(ws)") <> "" ) 
									{
										$ws = mysql_result($query,0,"sum(ws)");
									}else{	
										$ws = 0;
									}
								if (mysql_result($query,0,"sum(wl)") <> "" ) 
									{
										$wl = mysql_result($query,0,"sum(wl)");
									}else{	
										$wl = 0;
									}
								if (mysql_result($query,0,"sum(fiber)") <> "" ) 
									{
										$fiber = mysql_result($query,0,"sum(fiber)");
									}else{	
										$fiber = 0;
									}
								if (mysql_result($query,0,"sum(screws)") <> "" ) 
									{
										$screws = mysql_result($query,0,"sum(screws)");
									}else{	
										$screws = 0;
									}
								
							$outsidefixing = 0;
							$outsidefixing_count = 0;
							$query_out = mysql_query("select outsidefixing from p1_sale where create_date between '".$_POST['from_date']."' AND '".$_POST['to_date']."'");
							 while($row = mysql_fetch_array($query_out)){ 
							
									if ($row['outsidefixing'] == 1 ) {
										$outsidefixing = $outsidefixing + 10;
									}else{
										$outsidefixing = $outsidefixing + $row['outsidefixing']*5;
									}
									if ($row['outsidefixing'] <> 0 ) {
										$outsidefixing_count = $outsidefixing_count+$row['outsidefixing'];
									}
								
								}
							
							$TotalBD1 =0;
							
							$query1 = mysql_query("SELECT sum(BD1)  number_of_plate  FROM p1_order_info where Date_a between  '".$_POST['from_date']."' AND '".$_POST['to_date']."' and stop1 = 0"); 		
											if (mysql_result($query1,0,"number_of_plate") *1 > 0 )
												{								
													$TotalBD1 =mysql_result($query1,0,"number_of_plate");
												}
							
								


						 ?>
                        <table width="60%" border="1" align="center">
                          <tr>
                            <td width="342" class="td_print1">Frames</td>
                            <td class="td_print1">Quantity</td>
                            <td class="td_print1">Value</td>
                          </tr>

                          <tr>
                            <td align="left" class="td_print2"><div align="left">Frame Black - Long</div></td>
                            <td class="td_print2"><? echo $bl?></td>
                            <td class="td_print2"><? echo $bl*5?></td>
                          </tr>
                          <tr>
                            <td align="left" class="td_print2"><div align="left">Frame Black - Short</div></td>
                            <td class="td_print2"><? echo $bs?></td>
                            <td class="td_print2"><? echo $bs*5?></td>
                          </tr>
                          <tr>
                            <td align="left" class="td_print2"><div align="left">Frame Chrome - Long</div></td>
                            <td class="td_print2"><? echo $sl?></td>
                            <td class="td_print2"><? echo $sl*5?></td>
                          </tr>
                          <tr>
                            <td align="left" class="td_print2"><div align="left">Frame Chrome - Short</div></td>
                            <td class="td_print2"><? echo $ss?></td>
                            <td class="td_print2"><? echo $ss*5?></td>
                          </tr>
                          <tr>
                            <td align="left" class="td_print2"><div align="left">Frame White - Long</div></td>
                            <td class="td_print2"><? echo $wl?></td>
                            <td class="td_print2"><? echo $wl*5?></td>
                          </tr>
                          <tr>
                            <td align="left" class="td_print2"><div align="left">Frame White - Short</div></td>
                            <td class="td_print2"><? echo $ws?></td>
                            <td class="td_print2"><? echo $ws*5?></td>
                          </tr>
                          <tr>
                            <td align="left" class="td_print1">Total</td>
                            <td class="td_print1"><span class="td_print2"><? echo $bl+$bs+$sl+$ss+ $wl+$ws?></span></td>
                            <td class="td_print1"><span class="td_print2"><? echo ($bl+$bs+$sl+$ss+ $wl+$ws)*5?></span></td>
                          </tr>
                        </table>
                        <br />
                        <table width="60%" border="1" align="center">
                          <tr>
                            <td width="342" class="td_print1">Other</td>
                            <td class="td_print1">Quantity</td>
                            <td class="td_print1">Value</td>
                          </tr>
                          <tr>
                            <td align="left" class="td_print2"><div align="left">Fixing New Plate/ Screws</div></td>
                            <td class="td_print2"><? echo $screws+$TotalBD1;?></td>
                            <td class="td_print2"><? echo $screws+$TotalBD1;?></td>
                          </tr>
                          <tr>
                            <td align="left" class="td_print2"><div align="left">Plate Fixing - CUSTOMER SITE</div></td>
                            <td class="td_print2"><? echo $outsidefixing_count?></td>
                            <td class="td_print2"><? echo $outsidefixing?></td>
                          </tr>
                          <tr>
                            <td align="left" class="td_print2"><div align="left">Plate Support - Fiber</div></td>
                            <td class="td_print2"><? echo $fiber?></td>
                            <td class="td_print2"><? echo $fiber?></td>
                          </tr>

                          <tr>
                            <td align="left" class="td_print1">Total</td>
                            <td class="td_print1"><span class="td_print2"><? echo $screws+$TotalBD1+ $outsidefixing_count+ $fiber?></span></td>
                            <td class="td_print1"><span class="td_print2"><? echo $screws+$TotalBD1+ $outsidefixing+ $fiber?></span></td>
                          </tr>
                        </table>
                        <p align="center">
                          <? } ?>
</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>
