<?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;
}
.style16 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 24px;
	font-weight: bold;
}

-->
</style>
</head>

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

			
			$whr1="md5(id)='$uid'";
$get=$objIms->getRows('view_purchasereturn_supplier',$whr1);
$purret_id=$get["id"];
$return_no=$get["return_no"];
$client_name=$get["supplier_name"];
$order_no=$get["order_no"];
$purchase_date=$objIms->IntToDate($get["purchase_date"]);
$client_address=$get["address"];
$client_tin=$get["gstin"];
$ret_date=$objIms->IntToDate($get["ret_date"]);

/*$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"');*/
	}
?>

<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>
<body>

<div class="panel" style="width:95%; margin:10px auto">
<br />

<div align="center" class="style16"></div>
<br />
<div id="tableWrap">
<div id="printableArea">
<div style="width:210mm; height:297mm; margin:auto; text-align:center">
<table width="100%" border="0">
  <tr>
  <td align="center"><p><span class="style14" style="background:#666666; color:#FFFFFF; ">BHATIYA TEXTILES </span><br />
        <span >123,T.T.SHARDHANAND ROAD,UPPER BAZAR</span><br /> 
	<span >DIST: RANCHI-834001(Jharkhand)</span><br />   
		<span>Ph.No.:0651-6565999         </span><br />
		<span>Mobile No.:9693119999        </span><br /> 
		<span>Email: mukulbhatia9999@gmail.com        </span><br />    
        
        <span>GSTIN:20ACGPB704Q1ZO         </span>
        
    </p>
      <table width="100%" border="1">
        <tr>
          <td colspan="16"><div align="center">DEBIT NOTE </div></td>
          </tr>
        <tr>
          <td colspan="8">Document No&nbsp;&nbsp; :
            <?=$return_no?>
            <br />
Date Of Date&nbsp;:-<?=$ret_date?><br />
State&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :-Jharkhand <span style="float:right">State Code:-20</span></td>
          <td colspan="8">Against Invoice / Bill of Supply No :  <?=$order_no?><br />
          Date of Invoice / 
          Bill of Supply : <?=$purchase_date?><br /></td>
          </tr>
        <tr>
          <td colspan="16">&nbsp;</td>
          </tr>
        <tr>
          <td colspan="8"><div align="center">Deatils Of Receiver | Billed to: </div></td>
          <td colspan="8"><div align="center">Details of Consignee | Shipped to: </div></td>
          </tr>
        <tr>
          <td colspan="8">Name :<?=$client_name?><br />
Address : <?=$client_address?><br />
GSTIN :<?=$client_tin?><br />
State :-Jharkhand <span style="float:right">State Code:-20</span></td>
          <td colspan="8">Name :
              <?=$client_name?>
            <br />
            Address :
  <?=$client_address?>
  <br />
            GSTIN :
  <?=$client_tin?>
  <br />
            State :-Jharkhand <span style="float:right">State Code:-20</span> </td>
        </tr>
        <tr>
          <td colspan="16">&nbsp;</td>
          </tr>
		    <?php
  $sql_viewtmp="select *  from view_purchasereturn_det where purretmas_id=$purret_id";
				$res_viewtmp=mysql_query($sql_viewtmp);
				if(mysql_num_rows($res_viewtmp)>0)
				{ 
					$i=1;
					
  ?>
        <tr>
          <td rowspan="2"><strong>Sr. No </strong></td>
          <td rowspan="2"><strong>Name of Product/Service </strong></td>
          <td rowspan="2"><strong>HSN ASC </strong></td>
          <td rowspan="2"><strong>UOM</strong></td>
          <td rowspan="2"><strong>Qty</strong></td>
          <td rowspan="2"><strong>Rate</strong></td>
          <td rowspan="2"><strong>Amount</strong></td>
          <td rowspan="2"><strong>Less:Discount</strong></td>
          <td rowspan="2"><strong>Taxable Value </strong></td>
          <td colspan="2"><div align="center"><strong>CGST</strong></div></td>
          <td colspan="2"><div align="center"><strong>SGST</strong></div></td>
          <td colspan="2"><div align="center"><strong>IGST</strong></div></td>
          <td rowspan="2"><strong>Total</strong></td>
        </tr>
		
        <tr>
          <td><strong>Rate</strong></td>
          <td><strong>Amount</strong></td>
          <td><strong>Rate</strong></td>
          <td><strong>Amount</strong></td>
          <td><strong>Rate</strong></td>
          <td><strong>Amount</strong></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><?=$i++?></td>
          <td><?=$rows["item_name"]?></td>
          <td><?=$rows["hsn_code"]?></td>
          <td><?=$rows["unit_name"]?></td>
          <td><?php echo $rows["ret_qty"]; $totqty+=$rows["ret_qty"];?></td>
          <td><?=$rows["pur_price"]?></td>
          <td><?php $totsum=($rows["pur_price"]*$rows["ret_qty"]);echo number_format($totsum,2);$sumam+=$totsum;?></td>
          <td><?php  $discount=$totsum*($rows["discount"]/100); echo number_format($discount,2);?></td>
          <td><?php  $totprice=($totsum-$discount); echo number_format($totprice,2);$sumtav+=$totprice;?></td>
          <td><?php echo $rows["cgst"];?></td>
          <td><?php  $cgst=$totprice*($rows["cgst"]/100); echo number_format($cgst,2);$sumtcg+=$cgst;?></td>
          <td><?php echo $rows["sgst"];?></td>
          <td><?php  $sgst=$totprice*($rows["sgst"]/100); echo number_format($sgst,2);$sumtsg+=$sgst;?></td>
          <td><?php echo $rows["igst"];?></td>
          <td><?php  $igst=$totprice*($rows["igst"]/100); echo number_format($igst,2);$sumtig+=$igst;?></td>
          <td><?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><?php echo $s;?></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
		<?php }?>
        <tr>
          <td colspan="4"><div align="right">Total :  </div></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>&nbsp;</td>
          <td><?=number_format($sumtcg,2);?></td>
          <td>&nbsp;</td>
          <td><?=number_format($sumtsg,2);?></td>
          <td>&nbsp;</td
          ><td><?=number_format($sumtig,2);?></td>
          <td><?=number_format($sums,2);?></td>
        </tr>
        <tr>
          <td colspan="16">&nbsp;</td>
          </tr>
        <tr>
          <td colspan="8">Total Invoice Amount In Words:<br />
<h5><?php echo $objIms->Inwords($sums).' Only';?></h5> </td>
          <td colspan="8"><table width="100%" border="1">
            <tr>
              <td><strong>Total Amount Before Tax: </strong></td>
              <td><strong>
                <?=number_format($sumtav,2);?>
              </strong></td>
            </tr>
            <tr>
              <td>Add : CGST </td>
              <td><?=number_format($sumtcg,2);?></td>
            </tr>
            <tr>
              <td>Add : SGST </td>
              <td><?=number_format($sumtsg,2);?>              </td>
            </tr>
            <tr>
              <td>Add : IGST </td>
              <td><?=number_format($sumtig,2);?></td>
            </tr>
            <tr>
              <td><strong>Tax Amount : GST </strong></td>
              <td><strong>
                <?php $totgst=$sumtcg+$sumtsg+$sumtig; echo number_format($totgst,2);?>
              </strong></td>
            </tr>
          </table></td>
          </tr>
        <tr>
          <td colspan="5"><div align="center">Bank Deatils: </div></td>
          <td colspan="3" rowspan="2">&nbsp;</td>
          <td colspan="8"><table width="100%" border="1">
            <tr>
              <td width="81%"><strong>Total Amount After Tax : </strong></td>
              <td width="19%"><strong>
                <?=number_format($sums,2);?>
              </strong></td>
            </tr>
            <tr>
              <td><strong>Round Off Amount :</strong> </td>
              <td><strong>
              <?=number_format(round($sums),2);?>
              </strong></td>
            </tr>
            <tr>
              <td colspan="2">&nbsp;</td>
              </tr>
            <tr>
              <td>GST Payable on Reverse Charge : </td>
              <td>NA</td>
            </tr>
          </table></td>
          </tr>
        <tr>
          <td colspan="5">&nbsp;</td>
          <td colspan="8"><span style="vertical-align:text-top; text-align:center">Certified that the particulars given above are true and correct.</span> <br />
<span style="vertical-align:text-top; text-align:center"><strong>For BHATIYA TEXTILES</strong></span><br /><br />
<br />
<br />

<span style="vertical-align:text-bottom; text-align:center">Authorised Signatory</span></td>
          </tr>
      </table>      
      <p>&nbsp; </p></td>
  </tr>
</table>

</div>
</div>
</div>
<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>
  

</body>
</html>
