<?php 
session_start();
ob_start(); ?>
<?php include "header.php"?>
<!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 type="text/css">
<!--
input{ border:#CCCCCC solid 1px; border-radius:5px; height:22px; width:200px; padding-left:5px;}
select{ border:#CCCCCC solid 1px; border-radius:5px; height:27px; width:200px;}
.table_bg{ border:#CCCCCC solid 1px; border-radius:5px; height:auto; width:auto; padding:20px; margin-bottom:10px;}
.text_style{ font-family:Arial, Helvetica, sans-serif; font-size:12px;}
.text_style1{ font-family:Arial, Helvetica, sans-serif; font-weight:bold; font-size:12px;}
.style14 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 18px;
	font-weight: bold;
}
.style141 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 16px;
	font-weight: bold;
.style15 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 14px;
}
.style16 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 24px;
	font-weight: bold;
}

-->
</style>
</head>

<?php
if(isset($_GET["uid"]))
{
$uid=$_GET["uid"];
$whr="md5(id)='$uid'";
$getPatientInfo=$objIms->getRows('tbl_account',$whr);

			$invoice_no=$getPatientInfo["invoice_no"];
			$trans_date=$objIms->IntToDate($getPatientInfo["trans_date"]);
			$actual_amt=$getPatientInfo["actual_amt"];
			$salesmas_id=$getPatientInfo["mas_id"];
			$discount=$getPatientInfo["discount"];
			
			$Paid_Amount=$objIms->getSumValue('tbl_account','Dr_Amt','mas_id="'.$salesmas_id.'"');
			
			$whr1="id='$salesmas_id'";
$get=$objIms->getRows('view_sales_master',$whr1);
$client_name=$get["client_name"];
$client_address=$get["client_address"];
$client_tin=$get["tin_no"];
	}
?>

<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="panel" style="width:95%; margin:10px auto">
<br />

<div align="center" class="style16"></div>
<br />
<div id="printableArea">
<div style="width:210mm; height:auto; margin:auto; text-align:center">
  <table width="100%" border="1">
    <tr>
      <td  colspan="6"><table width="100%" border="1">
          <tr>
            <td height="102" colspan="2" align="center" ><span class="style14" style="background:#666666; color:#FFFFFF">SWASTIK SALES </span><br />
                <span class="style141">Gola Chowk,Badam Bazaar</span><br />
                <span class="style141">Dist-Hazaribhag (Jharkhand)</span></td>
            <td width="19%" align="left" valign="top"><span class="text_style1" style="float:right; margin-right:15px;">Contact No</span><br />
                <span class="text_style1" style="float:right;margin-right:10px;">Ph. No.: 06546-227422</span><br />
                <span class="text_style1" style="float:right;margin-right:10px;">Mobile: 9430322212</span><br />
                <span class="text_style1" style="float:right;margin-right:10px;">8877030008</span><br />            </td>
          </tr>
          <tr>
            <td width="14%"  align="left" valign="top"><span class="text_style1">No: </span></td>
            <td width="67%" align="left"><span class="text_style1">
              <?=$invoice_no?>
            </span></td>
            <td width="19%" align="left" valign="top"><span class="text_style1"> Date : </span>
                <?=$trans_date?></td>
          </tr>
          <tr>
            <td align="left"><span class="text_style1">Client Name  : </span> </td>
            <td align="left"><?=$client_name?></td>
            <td align="left">Tin No:
              <?=$client_tin?></td>
          </tr>
          <tr>
            <td align="left"><span class="text_style1">Client Address :  &nbsp;</span> </td>
            <td align="left"><?=$client_address?></td>
            <td>&nbsp;</td>
          </tr>
      </table></td>
    </tr>
    <?php
  $sql_viewtmp="select *  from view_sales_detail where salesmas_id=$salesmas_id";
				$res_viewtmp=mysql_query($sql_viewtmp);
				if(mysql_num_rows($res_viewtmp)>0)
				{ 
					$i=1;
					$sum=0;
  ?>
    <tr>
      <td width="6%" height="28"><span class="text_style1">Si No</span></td>
      <td width="29%"><span class="text_style1">Item Name</span></td>
      <td width="18%"><span class="text_style1">Unit Name</span></td>
      <td width="13%"><span class="text_style1">Order Qty</span></td>
      <td width="17%"><span class="text_style1">Price(Pc)</span></td>
      <td width="17%"><span class="text_style1">Total Price</span></td>
    </tr>
    <?php
  while($rows=mysql_fetch_assoc($res_viewtmp))
					{
  ?>
    <tr>
      <td height="27"><span class="text_style">
        <?=$i++?>
      </span></td>
      <td><span class="text_style">
        <?=$rows["item_name"]?>
      </span></td>
      <td><span class="text_style">
        <?=$rows["unit_name"]?>
      </span></td>
      <td><span class="text_style">
        <?=$rows["qty"]?>
      </span></td>
      <td><span class="text_style">
        <?=$rows["unit_price"]?>
      </span></td>
      <td class="text_style1"><?php echo ($rows["unit_price"]*$rows["qty"]);$sum=$sum+($rows["unit_price"]*$rows["qty"])?></td>
    </tr>
    <?php }}?>
    <tr>
      <td height="27" colspan="5" align="right" class="text_style1"> Sum Total : </td>
      <td class="text_style1"><?php echo number_format($sum,2);?></td>
    </tr>
    <tr>
      <td height="27" colspan="5" align="right" class="text_style1">Discount:</td>
      <td class="text_style1"><?php $discount=$sum*$discount/100; echo number_format($discount,2);?></td>
    </tr>
    <?php  
  $sums=$sum-$discount;
  $sqltax="select * from tbl_sales_tax where salesmas_id=$salesmas_id order by id asc";
	$exetax=mysql_query($sqltax);
	$sumtax=0;
	if(mysql_num_rows($exetax)>0){while($rstax=mysql_fetch_array($exetax)){
	
	$sqltax1="select * from tbl_tax_mstr where id=".$rstax["taxmas_id"];
	$exetax1=mysql_query($sqltax1);	
	$rstax1=mysql_fetch_array($exetax1);
	?>
    <tr>
      <td height="27" colspan="5" align="right" class="text_style1"><?=$rstax1["tax_name"]?></td>
      <td class="text_style1"><?php $tax=($rstax1["tax_percent"]/100)*$sums; echo $tax;?></td>
    </tr>
    <?php $sumtax=$sumtax+$tax;}}?>
    <tr>
      <td height="27" colspan="5" align="right" class="text_style1"> Total : </td>
      <td class="text_style1"><?php echo $tot=$sums+$sumtax;?></td>
    </tr>
    <tr>
      <td height="27" colspan="5" align="right" class="text_style1">Grand Total: </td>
      <td class="text_style1"><?php  $gtol=$tot; echo number_format($gtol,2);?></td>
    </tr>
    <tr>
      <td height="27" colspan="5" align="right" class="text_style1">Round Off:</td>
      <td class="text_style1"><?php  echo $gtol=round($gtol);?></td>
    </tr>
    <tr>
      <td height="27" colspan="5" align="right" class="text_style1">Paid Amt: </td>
      <td class="text_style1"><?=$Paid_Amount?></td>
    </tr>
    <tr>
      <td height="27" colspan="5" align="right" class="text_style1">Due:</td>
      <td class="text_style1"><?php $pt=$gtol-$Paid_Amount; echo number_format($pt,2);?></td>
    </tr>
    <tr>
      <td colspan="6" align="left"><table width="100%" border="0">
          <tr>
            <td width="58%" class="text_style">&nbsp;</td>
            <td width="21%">&nbsp;</td>
            <td width="21%" align="left" valign="top"><br />
                <br />
                <br />
                <br />
                <span style="font-size:12px;"> For: <strong>SWASTIK SALES</strong></span></td>
          </tr>
      </table></td>
    </tr>
  </table>
</div>
</div>
<br />

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

</body>
</html>
