<?php 
session_start();
ob_start(); ?><!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">

<?php include "header.php";
if(isset($_GET["uid"]))
{
$uid=$_GET["uid"];

			
			$whr1="md5(id)='$uid'";
$get=$objIms->getRows('view_sales_master',$whr1);
$salesmas_id=$get["id"];
$sale_no=$get["sale_no"];
$sales_type=$get["sales_type"];
$client_name=$get["client_name"];
$client_address=$get["client_address"];
$client_tin=$get["tin_no"];
$saledt=$objIms->IntToDate($get["stampdate"]);

/*$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"];			
			
			$discount=$getPatientInfo["discount"];
$Paid_Amount=$objIms->getSumValue('tbl_account','Dr_Amt','mas_id="'.$salesmas_id.'" and sales_type="Sales"');*/
	}?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
function original()
{
document.getElementById("original").style.display="block";
document.getElementById("duplicate").style.display="none";
document.getElementById("triplicate").style.display="none";
}

function duplicate()
{
document.getElementById("original").style.display="none";
document.getElementById("duplicate").style.display="block";
document.getElementById("triplicate").style.display="none";
}


function triplicate()
{
document.getElementById("original").style.display="none";
document.getElementById("duplicate").style.display="none";
document.getElementById("triplicate").style.display="block";
}

</script>

<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>
<script type="text/javascript">
$(function(){
    $('button').click(function(){
        var url='data:application/vnd.ms-excel,' + encodeURIComponent($('#tableWrap').html()) 
        location.href=url
        return false
    })
})
</script>
</head>

<body>

    <div class="col-sm-10">
    <div class="row">
  <div class="col-md-12 col-sm-12 col-xs-12">
  <div class="panel">
  <div class="panel-heading"><strong>BILL VIEW </strong><span style="float:right"> <a href="sales_list.php" style="color:#333333; text-decoration:none">Go Back</a> </span> </div>
  
   
  
  <style media="print">

  [background-color] {
        z-index: 0; background:#FFFFFF;
        position: relative;
        -webkit-print-color-adjust: exact !important;
    }

  </style>
  <style>
  h1,h2{ margin:0px;}

table{ border-collapse:collapse; }

.table-bdr tr td{  border-bottom:hidden; border-right:1px #000000 solid }
#table-bdr-in{ border:#333333 solid 1px;}
.st-code{border:#000000 solid 1px; padding:3px; width:120px; float:right; margin-right:5px; border-bottom:none}
#btr-hdn{border:hidden}
@page {
  margin: 10%;

  @top-center {
    font-family: sans-serif;
    font-weight: bold;
    font-size: 2em;
    content: counter(page);
  }
}
  </style>
<div id="printableArea">
<div style="width:205mm; height:297mm;  font-family:Calibri;">
<table width="100%" border="0">
  <tr>
   <?php for($ia=0;$ia<2;$ia++){?><td >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td> <div id="tableWrap"><table width="100%" border="0">
  <tr>
    <td height="81" align="center" valign="top" >
	<!--<h1 style="color:#000000">AT.PVT. LTD. </h1>-->
	<h2><span class="style14" style="background:#666666; color:#FFFFFF; ">PUSTAKAYAN </span></h2>
    
	<span>MALVIYA MARG</span><br /> 
	<span >DIST: HAZARIBAG(Jharkhand)</span><br />   
		
		<span>Mobile No.:9263832235        </span><br /> 
		    
        <?php if($sales_type=="Tax Invoice"){?>
        <span>GSTIN:        </span>
        <?php }?>
</td>
  </tr>
  </table>
<table width="100%" border="1" style="font-size:12px;" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">
	
	<h1>TAX INVOICE</h1>
	
  <span id="original"><?php if($ia==1){echo "Receipient Copy";}else{echo "Supplier Copy";}?></span> 
  
  	</td>
  </tr>
  <tr>
    <td><table width="100%" border="1" class="table-bdr" cellpadding="0" cellspacing="0" style="border:hidden"> 
      <tr>
        <td width="12%">&nbsp;</td>
        <td width="2%" align="center" id="btr-hdn">&nbsp;</td>
        <td width="36%">&nbsp;</td>
        <td width="16%">Transportation Mode </td>
        <td width="2%" align="center" id="btr-hdn">:</td>
        <td width="32%">&nbsp;</td>
      </tr>
      
      <tr>
        <td>Invoice No </td>
        <td align="center" id="btr-hdn">:</td>
        <td><?=$sale_no?></td>
        <td>Vehicle Number </td>
        <td align="center" id="btr-hdn">:</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>Invoice Date </td>
        <td align="center" id="btr-hdn">:</td>
        <td><?=$saledt?></td>
        <td>Date of Supply </td>
        <td align="center" id="btr-hdn">:</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td valign="top"  id="table-bdr-in" style="border-right:hidden">State</td>
        <td align="center" valign="top"  id="table-bdr-in">:</td>
        <td  id="table-bdr-in" style="border-left:hidden"><strong> Jharkhand</strong>
  <div class="st-code"> State Code : 20</div></td><td  id="table-bdr-in">Place of Supply</td>
        <td align="center"  id="table-bdr-in" style="border-left:hidden">:</td>
        <td  id="table-bdr-in" style="border-left:hidden"><strong> Jharkhand</strong>
            <div class="st-code"> State Code : 20</div></td>
      </tr>
      <tr>
        <td colspan="6"  id="table-bdr-in">&nbsp;</td>
        </tr>
      <tr>
        <td colspan="3" align="center" id="table-bdr-in">Details of Receiver | Billed to : </td>
        <td colspan="3" align="center" id="table-bdr-in">Details of Consignee | Shipped to : </td>
        </tr>
      <tr>
        <td>Name</td>
        <td align="center" id="btr-hdn" style="border-top:#000000 solid 1px;">:</td>
        <td><?=$client_name?></td>
        <td>Name</td>
        <td align="center" id="btr-hdn" style="border-top:#000000 solid 1px;">:</td>
        <td><strong>
          <?=$client_name?>
        </strong></td>
      </tr>
      <tr>
        <td>Address</td>
        <td align="center" id="btr-hdn">:</td>
        <td><?=$client_address?></td>
        <td>Address</td>
        <td align="center" id="btr-hdn">:</td>
        <td><strong>
          <?=$client_address?>
        </strong></td>
      </tr>
      <tr>
        <td>GSTIN</td>
        <td align="center" id="btr-hdn">:</td>
        <td><?=$client_tin?></td>
        <td>GSTIN</td>
        <td align="center" id="btr-hdn">:</td>
        <td><?=$client_tin?></td>
      </tr>
      <tr>
        <td valign="top">State</td>
        <td align="center" valign="top" style="border-left:hidden">:</td>
        <td  id="table-bdr-in" style="border-left:hidden"><strong> Jharkhand</strong>
            <div class="st-code"> State Code : 20</div></td>
        <td valign="top">State</td>
        <td align="center" valign="top" style="border-left:hidden">:</td>
        <td  id="table-bdr-in" style="border-left:hidden"><strong> Jharkhand</strong>
            <div class="st-code"> State Code : 20</div></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>
	  <?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;
					
  ?>
	<table width="100%" border="1" class="table-bdr" style="border:hidden">
      <tr>
        <td rowspan="2" id="table-bdr-in">Sr No. </td>
        <td rowspan="2" id="table-bdr-in">Name of Product / Service </td>
        <td rowspan="2" id="table-bdr-in">HSN ACS </td>
        <td rowspan="2" id="table-bdr-in">UOM</td>
        <td rowspan="2" id="table-bdr-in">Qty</td>
        <td rowspan="2" id="table-bdr-in"> Rate</td>
        <td rowspan="2" id="table-bdr-in">Amount</td>
        <td rowspan="2" id="table-bdr-in">Less: Discount </td>
        <td rowspan="2" id="table-bdr-in">Taxable Value </td>
        <td colspan="2" align="center" id="table-bdr-in">CGST</td>
        <td colspan="2" align="center" id="table-bdr-in">SGST</td>
        <td colspan="2" align="center" id="table-bdr-in">IGST</td>
        <td rowspan="2" align="right" id="table-bdr-in">Total</td>
      </tr>
      <tr>
        <td id="table-bdr-in">Rate(%) </td>
        <td id="table-bdr-in">Amount</td>
        <td id="table-bdr-in">Rate(%)</td>
        <td id="table-bdr-in">Amount</td>
        <td id="table-bdr-in">Rate(%)</td>
        <td id="table-bdr-in"> Amount</td>
        </tr>
	<?php
		   $totqty=0;
		   $sumam=0;
		   $sumtav=0;
		   $sumtcg=0;
		   $sumtsg=0;
		   $sumtig=0;
		   $sums=0;
  while($rows=mysql_fetch_assoc($res_viewtmp))
					{
  ?>
        
        
      <tr>
        <td align="center" id="table-bdr-in"><?=$i++?></td>
        <td id="table-bdr-in"><?=$rows["item_name"]?></td>
        <td id="table-bdr-in"><?=$rows["hsn_code"]?></td>
        <td id="table-bdr-in"><?=$rows["unit_name"]?></td>
        <td id="table-bdr-in"><?php echo $rows["qty"]; $totqty+=$rows["qty"];?></td>
        <td id="table-bdr-in"><?=$rows["unit_price"]?></td>
        <td id="table-bdr-in"><?php $totsum=($rows["unit_price"]*$rows["qty"]);echo number_format($totsum,2);$sumam+=$totsum;?></td>
        <td id="table-bdr-in"><?php  $discount=$totsum*($rows["discount"]/100); echo number_format($discount,2);?></td>
        <?php 
		if($row_details["dis_per_status"]<>'')
		{
			
		 $t_total=($t_total+$dis_amount);
		}
		else
		{
		 $t_total=($t_total+$total);	
		}
		?>
        <td id="table-bdr-in"><?php  $totprice=($totsum-$discount); echo number_format($totprice,2);$sumtav+=$totprice;?></td>
        <td id="table-bdr-in"><?php echo $rows["cgst"];?></td>
        <td id="table-bdr-in"><?php  $cgst=$totprice*($rows["cgst"]/100); echo number_format($cgst,2);$sumtcg+=$cgst;?></td>
        <td id="table-bdr-in"><?php echo $rows["sgst"];?></td>
        <td id="table-bdr-in"><?php  $sgst=$totprice*($rows["sgst"]/100); echo number_format($sgst,2);$sumtsg+=$sgst;?></td>
        <td id="table-bdr-in"><?php echo $rows["igst"];?></td>
        <td id="table-bdr-in"><?php  $igst=$totprice*($rows["igst"]/100); echo number_format($igst,2);$sumtig+=$igst;?></td>
        <?php 
		$item_total=$dis_amount+($cgst_amt*2)+$igst_amt;
		$grand_total=$grand_total+$item_total;
		?>
        <td align="right" id="table-bdr-in"><?php   $totamt=$totprice+$cgst+$sgst+$igst; echo number_format($totamt,2);$sums+=$totamt;?></td>
      </tr>
     
	  
	  
      <?php }?>
	  <?php for($s=$i;$s<=10;$s++){?>
     <tr>
        <td align="center" id="table-bdr-in"><?php echo $s;?></td>
        <td id="table-bdr-in">&nbsp;</td>
        <td id="table-bdr-in">&nbsp;</td>
        <td id="table-bdr-in">&nbsp;</td>
        <td id="table-bdr-in">&nbsp;</td>
        <td id="table-bdr-in">&nbsp;</td>
        <td id="table-bdr-in">&nbsp;</td>
        <td id="table-bdr-in">&nbsp;</td>
        <td id="table-bdr-in">&nbsp;</td>
        <td id="table-bdr-in">&nbsp;</td>
        <td id="table-bdr-in">&nbsp;</td>
        <td id="table-bdr-in">&nbsp;</td>
        <td id="table-bdr-in">&nbsp;</td>
        <td id="table-bdr-in">&nbsp;</td>
        <td id="table-bdr-in">&nbsp;</td>
        <td align="right" id="table-bdr-in">&nbsp;</td>
      </tr>
	  <?php }?>
      <tr style="font-weight:bold">
        <td height="25" colspan="4" align="right"  ><strong>Total : </strong></td>
        <td><?=number_format($totqty,2);?></td>
        <td>&nbsp;</td>
        <td><?=number_format($sumam,2);?></td>
        <td>&nbsp;</td>
        <td><?=number_format($sumtav,2);?></td>
        
        <td colspan="2" align="center"><?=number_format($sumtcg,2);?></td>
        <td colspan="2" align="center"><?=number_format($sumtsg,2);?></td>
        <td colspan="2" align="center"><?=number_format($sumtig,2);?></td>
        <td align="right"><?=number_format($sums,2);?></td>
      </tr>
    
	<?php }?></table></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><table width="100%" border="1" style="border:hidden; border-color:#000000">
      <tr>
        <td colspan="2" rowspan="5" align="center" valign="top"><strong>Total Invoice Amount in Words : </br></strong>
		  <?php echo $objIms->Inwords(round($sums)).' Only';?> Rupees Only.&nbsp;&nbsp;</td>
        <td width="21%">Total Amount Before Tax </td>
        <td width="2%" align="center">:</td>
        <td width="16%"><strong>
        <?=number_format($sumtav,2);?>
        </strong></td>
      </tr>
      <tr>
        <td>Add : CGST </td>
        <td align="center">:</td>
        <td><?=number_format($sumtcg,2);?></td>
      </tr>
      <tr>
        <td>Add : SGST </td>
        <td align="center">:</td>
        <td><?=number_format($sumtsg,2);?></td>
      </tr>
      <tr>
        <td>Add : IGST </td>
        <td align="center">:</td>
        <td><?=number_format($sumtig,2);?></td>
      </tr>
      <tr>
        <td>Tax Amount : GST </td>
        <td align="center">:</td>
        <td><strong>
        <?php $totgst=$sumtcg+$sumtsg+$sumtig; echo number_format($totgst,2);?>
        </strong></td>
      </tr>
      <tr>
        <td width="46%" rowspan="4"><table width="100%" height="71" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td colspan="3" align="center"><strong>: Bank Details : </strong></td>
            </tr>
          <tr>
            <td width="36%" height="25">Bank Account Number </td>
            <td width="4%">:</td>
            <td width="60%">&nbsp;</td>
          </tr>
          <tr>
            <td>Bank Branch IFSC </td>
            <td>:</td>
            <td>&nbsp;</td>
          </tr>
        </table></td>
        <td width="15%" rowspan="5" align="center" valign="bottom">(Common Seal)</td>
        <td>Total Amount After Tax </td>
        <td align="center">:</td>
        <td><strong>
        <?=number_format($sums,2);?>
        </strong></td>
      </tr>
      <tr>
        <td>Round Off Amount </td>
        <td align="center">:</td>
        <td><strong>
        <?=number_format(round($sums),2);?>
        </strong></td>
        </tr>
      <tr>
        <td colspan="3">&nbsp;</td>
        </tr>
      <tr>
        <td><strong>GST Payable on Reverse Charge </strong></td>
        <td align="center">:</td>
        <td>&nbsp;</td>
      </tr>
      
      <tr>
             
        <td align="center" valign="top">&nbsp;</td>
		
		
		

  
        <td colspan="3" nowrap="nowrap" align="center">Certified that the perticulars given above are true and correct. 
		<br />

<strong>  For, PUSTAKAYAN</strong>
<br />
<br />
<br />
<br />
Authorised Signatory		</td>
        </tr>
    </table></td>
  </tr>
</table></div></td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><?php }?>
  </tr>
</table>


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

<div align="center"><span class="btn btn-info" onClick="printDiv('printableArea')">Print</span> &nbsp;&nbsp;<button class="btn btn-success">Export to Excel</button></div>

</div></div></div></div>
</body>
</html>
