<link href="wstyle.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationSelect.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" />

<? if ($_GET['stat'] == '' ) { ?>
<style type="text/css">
<!--
.style1 {color: #EFB410}
.style2 {color: #004684}
-->
</style>
<p align="center" class="td4">Sale Log</p>
<table width="95%" border="0" align="center">
  <tr>
    <td rowspan="2" class="td1">Reciept No.</td>
    <td rowspan="2" class="td1">Date</td>
    <td rowspan="2" class="td1">Remote Addr</td>
    <td colspan="2" class="td1">Black frame</td>
    <td colspan="2" class="td1">Silver frame</td>
    <td colspan="2" class="td1">White frame</td>
    <td rowspan="2" class="td1">Fiber</td>
    <td rowspan="2" class="td1">Screws</td>
    <td rowspan="2" class="td1">offside<br />
      fixing</td>
    <td rowspan="2" class="td1">Total</td>
    <td rowspan="2" class="td1">User Name</td>
  </tr>
  <tr>
    <td class="td1">Short</td>
    <td class="td1">Long</td>
    <td class="td1">Short</td>
    <td class="td1">Long</td>
    <td class="td1">Short</td>
    <td class="td1">Long</td>
  </tr>
  <?
		 $i = 0;
		$result_lest = mysql_query("SELECT * FROM p1_sale_log order by slid desc"); 
		while($row = mysql_fetch_array($result_lest)){ 
		
		$i = $i + 1;
		
		
						$month			   = substr($row['create_date'],5,2);
						$year			   = substr($row['create_date'],0,4);
						// Create invoice
						//Invoice No.
							$Inv_year  = $year -2000;
							if ($month < 10 ) {
								$Inv_month = '0'.($month/1);
							}else{
								$Inv_month = $month;
							}
							if ($row['sid'] < 10 ) {
								$Inv_serial = '0000'.$row['sid'];
							}elseif ($serial < 100 ) {
								$Inv_serial = '000'.$row['sid'];
							}elseif ($serial < 1000 ) {
								$Inv_serial = '00'.$row['sid'];
							}elseif ($serial < 10000 ) {
								$Inv_serial = '0'.$row['sid'];
							}elseif ($serial < 100000 ) {
								$Inv_serial = $row['sid'];
							}
							
	
		
	?>
  <tr>
    <td rowspan="2" class="td2"><? echo $Inv_year.$Inv_month.'SR'.$Inv_serial;  ?></td>
    <td rowspan="2" class="td2"><? echo $row['create_date'] ?></td>
    <td rowspan="2" class="td2"><? echo $row['Remote_Addr'] ?></td>
    <td class="td2"><? echo $row['befor_bs'] ?></td>
    <td class="td2"><? echo $row['befor_bl'] ?></td>
    <td class="td2"><? echo $row['befor_ss'] ?></td>
    <td class="td2"><? echo $row['befor_sl'] ?></td>
    <td class="td2"><? echo $row['befor_ws'] ?></td>
    <td class="td2"><? echo $row['befor_wl'] ?></td>
    <td class="td2"><? echo $row['befor_fiber'] ?></td>
    <td class="td2"><? echo $row['befor_screws'] ?></td>
    <td class="td2"><? echo $row['befor_outsidefixing'] ?></td>
    <td class="td2"><? 
		if ($row['befor_outsidefixing'] > 1 ) {		
				echo $row['befor_bs']*5+$row['befor_bl']*5+$row['befor_ss']*5+$row['befor_sl']*5+$row['befor_ws']*5+$row['befor_wl']*5+$row['befor_fiber']+$row['befor_screws']+$row['befor_outsidefixing']*5 ;
			}else{
				echo $row['befor_bs']*5+$row['befor_bl']*5+$row['befor_ss']*5+$row['befor_sl']*5+$row['befor_ws']*5+$row['befor_wl']*5+$row['befor_fiber']+$row['befor_screws']+$row['befor_outsidefixing']*10; 
			}
			
			?>
      BD</td>
    <td rowspan="2" class="td2"><?
       		 $uid = $row['uid'];
			$query1 = mysql_query("SELECT * FROM p1_powers where uid = $uid");
			echo  mysql_result($query1,0,"fullname");
		
		?></td>
  </tr>
  <tr>
    <td class="td2"><? echo $row['after_bs'] ?></td>
    <td class="td2"><? echo $row['after_bl'] ?></td>
    <td class="td2"><? echo $row['after_ss'] ?></td>
    <td class="td2"><? echo $row['after_sl'] ?></td>
    <td class="td2"><? echo $row['after_ws'] ?></td>
    <td class="td2"><? echo $row['after_wl'] ?></td>
    <td class="td2"><? echo $row['after_fiber'] ?></td>
    <td class="td2"><? echo $row['after_screws'] ?></td>
    <td class="td2"><? echo $row['after_outsidefixing'] ?></td>
    <td class="td2"><? 
		if ($row['after_outsidefixing'] > 1 ) {		
				echo $row['after_bs']*5+$row['after_bl']*5+$row['after_ss']*5+$row['after_sl']*5+$row['after_ws']*5+$row['after_wl']*5+$row['after_fiber']+$row['after_screws']+$row['after_outsidefixing']*5 ;
			}else{
				echo $row['after_bs']*5+$row['after_bl']*5+$row['after_ss']*5+$row['after_sl']*5+$row['after_ws']*5+$row['after_wl']*5+$row['after_fiber']+$row['after_screws']+$row['after_outsidefixing']*10; 
			}
			
			?>
      BD</td>
  </tr>
  <? } ?>
</table>
<?  } ?>
