<?php 
session_start();
ob_start(); 
include "header.php";
//$objIms->Semifinisheditem_alter();
?>



<?php

if(isset($_GET["uid"]))
{
$uid=$_GET["uid"];
$rs=$objIms->getRows("view_purchase_supplier","md5(id)='$uid'");
$pur_id=$rs["id"];
$order_no=$rs["order_no"];
$purchase_date=$objIms->IntToDate($rs["purchase_date"]);
$supplier_name=$rs["supplier_name"];

}


	
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

		
	
		 <style>
			select.error { background-color:#ffa8a8; border: 1px dotted red;  }
			input.error{ background-color:#ffa8a8;   }
			textarea.error{ background-color:#ffa8a8; border: 1px dotted red;  }
         </style>
		 
        


<style type="text/css">
<!--
.table_bg{ border:#CCCCCC solid 1px; border-radius:5px; height:auto; width:auto; padding:20px; margin-bottom:10px;}
.style2 {
	color: #00CC00;
	font-style: italic;
}
.style3 {color: #00CC00}


-->
</style>
</head>
<script type="text/javascript">
 
function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}

</script>
<body>

<div class="span11" style=" width:83%;">



<div class="12" style=" margin-left:0px; ">



<br />
<br />
<br />

<div class="12" style=" margin-left:0px;">
<div id="printableArea">
<div class="panel" style="border:<?php echo THEMECOLOR?> solid 1px; border-radius:0px;">
<div class="entry-head" >
<h4>View Purchase Report
</div>
<p>&nbsp;</p>

<br />


     
            
		
            <?php 
				  $sql_viewtmp="SELECT * FROM `tbl_sales`";
				$res_viewtmp=mysql_query($sql_viewtmp);
				if(mysql_num_rows($res_viewtmp)>0)
				{ 
					$i=1;
					$sums=0;
					?>
					<div class="panel">
					
					<p>&nbsp;</p>
                     <table width="100%" class="table table-bordered">
                     <tr height="32" align="left">
            <th nowrap="nowrap" width="6%">Si No</th>
            <th nowrap="nowrap" width="24%">Sale Date </th>
            <th nowrap="nowrap" width="35%">Client Name</th>
           
            <th nowrap="nowrap" width="17%">Sale No </th>
			<th nowrap="nowrap" width="17%"> Amount </th>
			
            <th nowrap="nowrap" width="18%">View</th>
            </tr>
            <?php
			$tot_amount=0;
				while($rows=mysql_fetch_assoc($res_viewtmp))
					{
						
						
						
						
							
							
			?>
           
            <tr height="32">
            <td nowrap="nowrap" width="6%"><?php echo $i++;?></td>
           
		    <td nowrap="nowrap" width="24%"><?php echo $objIms->IntToDate($rows["stampdate"]);?></td>
		    <td nowrap="nowrap" width="35%"><?php $sql_viewtmp22="select * from tbl_client where id = '".$rows["client_id"]."'";
			$res_viewtmp22=mysql_query($sql_viewtmp22);
			$rows22=mysql_fetch_assoc($res_viewtmp22);
			
			 echo $rows22['client_name'];?></td>
            
            <td nowrap="nowrap" width="17%"><?php echo $rows["sale_no"];?></td>
			<td nowrap="nowrap" width="17%"><?php  $sql_viewtmp2="select sum((qty*unit_price)-(qty*unit_price*discount/100)) as taxable_value from tbl_sales_detail where salesmas_id = '".$rows["id"]."'";
			$res_viewtmp2=mysql_query($sql_viewtmp2);
			$rows2=mysql_fetch_assoc($res_viewtmp2);
			
			 echo $tot_amt = round($rows2['taxable_value'],2);
			 $tot_amount+=$tot_amt;
			 ?></td>
			
            <td nowrap="nowrap" width="18%"><a onclick="PopupCenter('Salespopup_view.php?uid=<?php echo md5($rows["id"]);?>','xtf','1000','700');" style="cursor:pointer; text-decoration:none">View</a></td>
            </tr>   <?php }?>
			<tr>

			<td colspan="4" align="right"><b>Total Amount</b></td><td><?php echo $tot_amount;?></td>
			<td></td>
			</tr>
           </table>
		   </div>
    <?php }
	?>
	
		

   
<p></p>
		<br />
        

</div>
</div>
<br />

<div align="center"><span class="btn btn-info" onClick="printDiv('printableArea')">Print</span></div>
</body>
</html>
