<?php include("include/system_connect.php");?>

<? include("include/session.php"); ?>

<title><? echo $page_title;?></title>



<style>

		td

		{

		font-family:Verdana, Arial, Helvetica, sans-serif;

		font-size:11px;

		}

	

	</style>

<style>































#print_this_page {































	 BACKGROUND: url(images/print_this_page.gif) #fff no-repeat 0px 0px; HEIGHT: 23px; WIDTH: 130px































}































































#close_this_page {































	 BACKGROUND: url(images/close_this_page.gif) #fff no-repeat 0px 0px; HEIGHT: 23px; WIDTH: 130px































}































</style>

<?

$bill_no=$_REQUEST['bill_no'];







$qry2 = $mysqli->prepare("select member_id,stock_id,bill_type,id,date,transp_no,eway_bill,lr_no,box_no,transp_chrg from report_stock where bill_no=?");

$qry2->bind_param('s', $bill_no);

$qry2->execute();

$qry2->bind_result($member_id,$stock_id,$bill_type,$id,$date,$transp_no,$eway_bill,$lr_no,$box_no,$transp_chrg);

while ($qry2->fetch())

{

$member_id=$member_id;

$stock_id=$stock_id;

$bill_type=$bill_type;

$id=$id;

$date=$date;	
$transp_chrg=$transp_chrg;
$transp_no=$transp_no;
$eway_bill=$eway_bill;
$lr_no=$lr_no;
$box_no=$box_no;												

}

$qry_st = $mysqli->prepare("select name,cont_no,state,address,gst_no,district from admin_account_login where id=?");

$qry_st->bind_param('s', $stock_id);

$qry_st->execute();

$qry_st->bind_result($stock_name,$cont_no,$state,$address,$gst_no,$district);

while ($qry_st->fetch())

{

$stock_name=$stock_name;
$gst_no=$gst_no;
$cont_no=$cont_no;

$state=$state;

$address=$address;
$district=$district;													

}



$qry_st = $mysqli->prepare("select short_code from branch where id=?");

$qry_st->bind_param('s', $branch_id);

$qry_st->execute();

$qry_st->bind_result($short_code);

while ($qry_st->fetch())

{

$short_code=$short_code;

													

}





			if($stock_id==0){$stk_code="KOL";}else{$stk_code=$short_code;}

			











?>







					

					

					<table cellpadding="0" cellspacing="0" width="933" align="center" height="200">

<tr>

<td width="931">

<table cellpadding="0" cellspacing="0" border="0" width="100%">

<tr>

<td width="22%"><img src="images/logo.png" height="120" width="120" /></td>

	  <td width="78%" align="center"><p><font face="Arial, Helvetica, sans-serif" size="+2"><B>GST INVOICE</B></font><br />

	        
<!--
	    Regd. Office : 6, Adarsh Nagar, Konnagar,Hooghly - 712246 (W.B.)<BR />

		Corp. Office : Mehar Par, Nr. Pani Tanki,Sogra College (Bihar Sharif) 803101<BR />

	      E-mail: info@napthapetro.in<BR />

		 Contact No. : +91 87896 59903-->

		  

		  </p>

	    </td>

</tr></table>

<center><b>GST INVOICE</b></center>

<?

$inv_id=$id;	



					 $dgt=str_pad($inv_id,8,"0",STR_PAD_LEFT);

?>

<HR width="100%" />

					<table border="0"  cellpadding="0" cellspacing="0" width="95%" >

					<tr>

					  <td width="45%" align="left">

					&nbsp;

					<b>GST No. :</b>&nbsp;18AAJCG4262C1ZQ

					</td>

					

					  <td width="8%" align="center">&nbsp;					</td>

					<td width="47%" align="left"><b>Transportation Mode:</b> Apply for zsupply of Goods Only				</td>

					</tr>

					

					<tr>

					  <td width="45%" align="left">

					&nbsp;

					<b>Tax is payable on Reverse Charge :</b> Yes/No

					</td>

					

					  <td width="8%" align="center">&nbsp;					</td>

					<td width="47%" align="left"><b>Transport No :</b> &nbsp;<? echo $transp_no;?></td>

					</tr>

					<tr>

					  <td width="45%" align="left">

					&nbsp;

					<b>GST Invoice No. :</b><?php echo $dgt;?>

					</td>

					

					  <td width="8%" align="center">&nbsp;					</td>

					<td width="47%" align="left"><b>E-Way Bill No :</b>&nbsp;<? echo $eway_bill;?>	</td>


					</tr>

					<tr>

					  <td width="45%" align="left">

					&nbsp;

					<b>Date. :</b><?php echo $date;?>

					</td>

					

					  <td width="8%" align="center">&nbsp;					</td>

					<td width="47%" align="left"><b>L.R No : </b>&nbsp;<? echo $lr_no;?>				</td>

					</tr>

					

					<tr>

					  <td width="45%" align="left">&nbsp;

					


					</td>

					

					  <td width="8%" align="center">&nbsp;					</td>

					<td width="47%" align="left"><b>No Of Box/Case : </b>&nbsp;<? echo $box_no;?></td>

					</tr>

					<tr>

					<td colspan="3" align="left">

					<!--&nbsp;

					<b>Distributor ID :</b>&nbsp;-->

					<? 

					//echo $member_id;

					?>

					

					</td>

					</tr>	
<tr>

					  <td width="45%" align="left">

					&nbsp;

					<b>Details Of Receiver(Billed To)</b>

					</td>

					  <td width="8%" align="center">&nbsp;</td>

					<td width="47%" align="left"><b>Details Of Sender(Ship To) </b></td>

					</tr>
					<tr>

					<td align="left">

					&nbsp;

					<b> Name :</b>&nbsp;

					<? 

					 echo $stock_name;

					?>

					(<? 

					 echo $cont_no;

					?>)

					</td>
<td width="8%" align="center">&nbsp;</td>
<td width="47%" align="left"><b>Name :</b>&nbsp;GINSENG MARKETING PVT LTD .</td>

					</tr>

					

					<tr>

					<td align="left">

					&nbsp;

					<b> Address :</b>&nbsp;

					<?php echo $address;?> <?php echo $district;?>

					

					</td>

<td width="8%" align="center">&nbsp;</td>
<td width="47%" align="left"><b>Address :</b>&nbsp;Ward no 2 Barpeta Road<br />
  Barpeta Assam, India 781315<br />
</td>
					</tr>

					<tr>

					<td align="left">

					&nbsp;

					<b>State  :</b>&nbsp;

					<? 

					 echo $state;

					?>

					

					</td>
					<td width="8%" align="center">&nbsp;</td>
<td width="47%" align="left"><b>Contact No :</b>&nbsp;+91 95312 04342 </td>


					</tr>

					<tr>

					<td align="left">

					&nbsp;

					<b>State Code  :</b>&nbsp;

					

					

					</td>
					<td width="8%" align="center">&nbsp;</td>
<td width="47%" align="left"><b>State :</b>&nbsp;Assam - 18 </td>


					</tr>

					<tr>

					<td colspan="3" align="left">

					&nbsp;

					<b>GSTIN NO  :</b>&nbsp;<? echo $gst_no;?>

					

					

					</td>

					</tr>

					</table>

					

					

					

					<HR width="100%" />

					<table border="0"  cellpadding="0" cellspacing="0" width="100%" height="125">

					<tr>

						<td colspan="2">

					<table border="1"  cellpadding="4" cellspacing="0" width="100%" height="125">

					 <tr>

					 <td width="22"><b>Sl No.</b></td>

	<td width="149"><b>Description Of Goods</b></td>

	<td width="32"><b>HSN Code</b></td>

	<td width="25"><b>QTY</b></td>
	<td width="25"><b>Batch No</b></td>

	<td width="28"><b>UOM</b></td>

	<td width="29"><b>Rate</b></td>
	<td width="29"><b>MRP</b></td>

	<td width="41"><b>Gross Value</b></td>


	<td width="56"><b>Discount</b></td>

	<td width="56"><b>Taxable Value</b></td>

	<td width="102"><table border="1" cellpadding="0" cellspacing="1"><tr><td colspan="2"><b>CGST</b></td></tr><tr><td><b>Rate</b></td><td><b>Amount</b></td></tr></table></td>

	<td width="102"><table border="1"  cellpadding="0" cellspacing="1"><tr><td colspan="2"><b>SGST</b></td></tr><tr><td><b>Rate</b></td><td><b>Amount</b></td></tr></table></td>

	<td width="102"><table border="1"  cellpadding="0" cellspacing="1"><tr><td colspan="2"><b>IGST</b></td></tr><tr><td><b>Rate</b></td><td><b>Amount</b></td></tr></table></td>

	</tr>

					<?

					

$qtyy=$mysqli->prepare("select item_code,qty,dis,del from bill_stock where bill_no=?");

$qtyy->bind_param("s", $bill_no);

$qtyy->execute();

$qtyy->bind_result($item_code,$qty,$dis,$del);

$z=0;

while($qtyy->fetch())

{

$z++;

$itmcd[$z]=$item_code;

$qtty[$z]=$qty;

$disss[$z]=$dis;

$dell[$z]=$del;

}	



				  for($kk=1;$kk<=$z;$kk++)

				   {

				  

				  $item_code=$itmcd[$kk];

				  

				  

							  $qry22 = $mysqli->prepare("select  name, code, rate, pv, uom, cgst,sgst,igst,tax,batch_no,mrp from product_resale where id=?");

							  $qry22->bind_param("s", $item_code);

                             $qry22->execute();

                    $qry22->bind_result($name, $code, $rate, $pv, $uom, $cgst,$sgst,$igst,$tax,$batch_no,$mrp);

					while($qry22->fetch())

                  {

				  $name=$name;

				  $code=$code;

				  $rate=$rate;

				  $pv=$pv;

				  $uom=$uom;

				  $cgst=$cgst;

				  $sgst=$sgst;

				  $igst=$igst;

				  $tax=$tax;
				  $batch_no=$batch_no;
$mrp=$mrp;

				  }

				

$qty=$qtty[$kk];

$vat=$rate*$tax/100;

$dp=$rate+$vat;

$total=$rate*$qty;

$diss=$rate*$disss[$kk];

$taxable_val=$total+$dell[$kk]-$diss;



$cgst_val=$taxable_val*$cgst/100;

$igst_val=$taxable_val*$igst/100;

$sgst_val=$taxable_val*$sgst/100;

?>

				    <tr>

					<td height="20" valign="middle" align="left">&nbsp;<? echo $kk;?></td>

					 <td height="20" valign="middle" align="left">&nbsp;<? echo $name;?></td>

					 <td height="20" valign="middle" align="left">&nbsp;<? echo $code;?></td>

					 <td height="20" valign="middle" align="left">&nbsp;<? echo $qty;?></td>
   <td height="20" valign="middle" align="left">&nbsp;<? echo $batch_no;?></td>
					 <td height="20" valign="middle" align="left">&nbsp;<? echo $uom;?></td>

					 

					 <td height="20" valign="middle" align="left">&nbsp;<? echo $rate;?></td>
  <td height="20" valign="middle" align="left">&nbsp;<? echo $mrp;?></td>
					 <td height="20" valign="middle" align="left">&nbsp;<? echo $total=$rate*$qty;?></td>

					 
					   <td height="20" valign="middle" align="left">&nbsp;<? echo $diss;?></td>

					 <td height="20" valign="middle" align="left">&nbsp;<? echo sprintf("%01.2f",$taxable_val);?></td>

					<td><table width="102" border="1"  cellpadding="0" cellspacing="1">

  <tr><td width="35"><? if($bill_type=="state"){echo $cgst;  } ?></td>

  <td width="50"><? if($bill_type=="state"){echo sprintf("%01.2f",$cgst_val); } ?></td>

  </tr></table></td>

					 <td><table width="102" border="1"  cellpadding="0" cellspacing="1">

  <tr><td width="35"><? if($bill_type=="state"){echo $sgst;  } ?></td>

  <td width="50"><? if($bill_type=="state"){echo sprintf("%01.2f",$sgst_val); } ?></td>

  </tr></table></td>

					  <td><table width="102" border="1"  cellpadding="0" cellspacing="1">

  <tr><td width="35"><? if($bill_type=="central"){echo $igst;  } ?></td>

  <td width="50"><? if($bill_type=="central"){echo sprintf("%01.2f",$igst_val); } ?></td>

  </tr></table></td>

					

					

					</tr>

				<?

				$dis_pv=$disss[$kk]*$pv;

				$ind_pvv=$pv*$qty;

				$ind_pv=$ind_pvv-$dis_pv;

				$total_pv= $total_pv+$ind_pv;

				$total_qty=$total_qty+$qty;

				} ?>   

					

				

<?

$qry2 = $mysqli->prepare("select gross_bill,cgst,sgst,igst,total,discount from report_stock where bill_no=?");

$qry2->bind_param('s', $bill_no);

$qry2->execute();

$qry2->bind_result($gross_bill,$cgst,$sgst,$igst,$total,$discount);

while ($qry2->fetch())

{

$gross_bill=$gross_bill;

$cgst=$cgst;

$sgst=$sgst;

$igst=$igst;

$total=$total;	

$discount=$discount;												

}

?>				

<tr>

<td height="20" valign="middle" align="right" colspan="2">&nbsp;</td>

<td colspan="9" align="right"><b>Gross Total</b></td>



<td colspan="3"><?  echo sprintf("%01.2f",$gross_bill);?></td>



</tr>

<tr>

<td colspan="11" align="right"><b>CGST</b></td>



<td colspan="3"><?  echo sprintf("%01.2f",$cgst);?></td>



</tr>

<tr>

<td colspan="11" align="right"><b>SGST</b></td>



<td colspan="3"><?  echo sprintf("%01.2f",$sgst);?></td>



</tr>

<tr>

<td colspan="11" align="right"><b>IGST</b></td>



<td colspan="3"><?  echo sprintf("%01.2f",$igst);?></td>



</tr>



<tr>

<td colspan="11" align="right"><b>Net Amount</b></td>

<td colspan="3"><?  echo sprintf("%01.2f",$total);?></td>

</tr>

<?

$payable=$total+$transp_chrg-$discount;

?>

<tr>

<td colspan="11" align="right"><b>Discount</b></td>

<td colspan="3"><?  echo sprintf("%01.2f",$discount);?></td>

</tr>
<tr>

<td colspan="11" align="right"><b>Transport Charge</b></td>

<td colspan="3"><?  echo sprintf("%01.2f",$transp_chrg);?></td>

</tr>

<tr>

<td colspan="11" align="right"><b>Payable</b></td>

<td colspan="3"><?  echo round($payable);?></td>

</tr>





					

					

					

					</table>

					</td>

					</tr>

					

					<tr>

					

					  

					<td width="52%" align="right">

					

					<table border="0"  cellpadding="4" cellspacing="4" width="100%">

					<tr>

					<td align="right" colspan="2"><b>Authorised Signature</b><br /></td>

					</tr>

					<tr>

					<td align="right" colspan="2"><b>For</b>&nbsp;&nbsp;<font size="2"><? echo $company_name;?></font></td>

					</tr>
					<tr>



					<td align="right"><a href="javascript:;" onClick="window.print();"><DIV id=print_this_page></DIV></a></td><td><a href="javascript:;" onClick="window.close();"><DIV id=close_this_page></DIV></a></td>



					</tr>

					</table>

					

	</td></tr>

				</table>

	</td>

</tr>	

</table>

			

		

							

					

					

					