<?php
include('db_connection.php');
$Mainclass=new DB_Controller();
$Mainclass->Check_Login();
$Dealer=$_COOKIE['O_Code'];

function AmountConvervrtToWord($amount)
{
  $number = $amount;
   $no = round($number);
   $point = round($number - $no, 2) * 100;
   $hundred = null;
   $digits_1 = strlen($no);
   $i = 0;
   $str = array();
   $words = array('0' => '', '1' => 'one', '2' => 'two',
    '3' => 'three', '4' => 'four', '5' => 'five', '6' => 'six',
    '7' => 'seven', '8' => 'eight', '9' => 'nine',
    '10' => 'ten', '11' => 'eleven', '12' => 'twelve',
    '13' => 'thirteen', '14' => 'fourteen',
    '15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen',
    '18' => 'eighteen', '19' =>'nineteen', '20' => 'twenty',
    '30' => 'thirty', '40' => 'forty', '50' => 'fifty',
    '60' => 'sixty', '70' => 'seventy',
    '80' => 'eighty', '90' => 'ninety');
   $digits = array('', 'hundred', 'thousand', 'lakh', 'crore');
   while ($i < $digits_1) {
     $divider = ($i == 2) ? 10 : 100;
     $number = floor($no % $divider);
     $no = floor($no / $divider);
     $i += ($divider == 10) ? 1 : 2;
     if ($number) {
        $plural = (($counter = count($str)) && $number > 9) ? 's' : null;
        $hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
        $str [] = ($number < 21) ? $words[$number] .
            " " . $digits[$counter] . $plural . " " . $hundred
            :
            $words[floor($number / 10) * 10]
            . " " . $words[$number % 10] . " "
            . $digits[$counter] . $plural . " " . $hundred;
     } else $str[] = null;
  }
  $str = array_reverse($str);
  $result = implode('', $str);
  $points = ($point) ?
    "." . $words[$point / 10] . " " .
          $words[$point = $point % 10] : '';
  return ucwords($result)." Only";
}


$SqCheckIndent="select * from gold_indent_master where Order_No='".$_REQUEST['Order_No']."'";
$RsCheckIndent=mysqli_query($Mainclass->dbh,$SqCheckIndent);
$FchIndent=mysqli_fetch_array($RsCheckIndent);

$FetchDealerCon=" Order_Code= '".$FchIndent['Dealer_Code']."'";
$Field_Needed="State,Dealer_Name,Dealership,Dealer_Address_Line1,Dealer_Address_Line2,Dealer_City,Dealer_Pin,Dealer_GST,Dealer_Phone,Dealer_Type";
//$DeaerDtl=$Mainclass->Fetch_needed_data_condition('dealer_master',$Field_Needed,$FetchDealerCon);
$DeaerDtl=$Mainclass->Fetch_individual_data('dealer_master',$Field_Needed,$FetchDealerCon);

$SqlState="select * from state_master where State='".$DeaerDtl['State']."'";
$RsState=mysqli_query($Mainclass->dbh,$SqlState);
$FchState=mysqli_fetch_array($RsState);
?>
<!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">

<script>
 function Print() 
	  { 
	  
	  
	  
	  
	  document.getElementById("print_gatepass_btn").style.visibility = "hidden"; 
	  
	 
	 
	  var divToPrint = document.getElementById('printdiv');              
	  
	  var popupWin = window.open('', '_blank');      
	  
	  popupWin.document.open();
	  
	  popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
	  
	  popupWin.document.close();
	  }  
</script>


<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body style="margin:0px; padding:0px;">

<div id="printdiv">

<table width="800" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td><table width="800" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td style="font-family:Arial, Helvetica, sans-serif; text-align:center; font-size:16px; font-weight:600; color:#000000; padding-bottom:10px;">
	<?php
	 if(strtoupper($DeaerDtl['Dealer_Type'])=="OWNED")
	{
	  echo "Stock Transfer Note";
	
	}
	else
	{
	   echo "Credit Bill (Tax Invoice)";
	   
	 }
	?>
	</td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="50%" style="font-family:Arial, Helvetica, sans-serif; text-align:left; font-size:12px; line-height:20px; font-weight:500; color:#000000; padding-right:20px; text-transform:uppercase;">From :<br />
CHANDRANI PEARLS PVT LTD (HO)<br />
2016, RAJDANGA Main Road<br />
Block GA-88, Chandrani house<br />
Kolkata - 700107<br />
West Bengal (19)<br />
Phone : (033) 4031 4444<br />
GST : 19AAECC9607L1Z7<br />
CIN : U74999WB2011PTC165200</td>
    <td width="50%" style="font-family:Arial, Helvetica, sans-serif; text-align:left; font-size:12px; line-height:20px; font-weight:500; color:#000000; text-transform:uppercase;">To : <br />
    <?php echo $DeaerDtl['Dealership']; ?> (<?php echo $FchIndent['Dealer_Code']; ?>)<br />
<?php echo $DeaerDtl['Dealer_Address_Line1']; ?><br />
<?php echo $DeaerDtl['Dealer_Address_Line2']; ?><br />
<?php echo $DeaerDtl['Dealer_City']; ?> - <?php echo $DeaerDtl['Dealer_Pin']; ?>
&nbsp;<?php echo $DeaerDtl['State']; ?>(<?php echo $FchState['GST_Code']; ?>) <br />
Phone : <?php echo $DeaerDtl['Dealer_Phone']; ?><br />
<?php echo $DeaerDtl['Dealer_GST']; ?>
</td>
  </tr>
</table>
</td>
  </tr>
  <tr>
    <td><table width="400" border="0" cellspacing="0" cellpadding="0">
	<?php
	if($FchIndent['Bill_No']!='')
	{
	?>
  <tr>
    <td width="100" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; color:#000000; padding:5px 0px; letter-spacing:1px;">Bill No</td>
    <td width="300" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; color:#000000; padding:5px 0px; letter-spacing:2px;">:&nbsp; <?php echo $FchIndent['Bill_No']; ?></td>
  </tr>
  <?php
   }
  ?>
  <tr>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; color:#000000; padding:5px 0px; letter-spacing:1px;">Date</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; color:#000000; padding:5px 0px; letter-spacing:2px;">:&nbsp; <?php echo date('d/m/Y',strtotime($FchIndent['Dispatched_Date'])); ?></td>
  </tr>
  <tr>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; color:#000000; padding:5px 0px; letter-spacing:1px;">Ref No.</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; color:#000000; padding:5px 0px; letter-spacing:2px;">:&nbsp; <?php echo $FchIndent['STN_NO']; ?> <?php if($FchIndent['Consignment_Stn']==1){ echo "(Consignment Stn)"; } ?></td>
  </tr>
<tr>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; color:#000000; padding:5px 0px; letter-spacing:1px;">Date</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; color:#000000; padding:5px 0px; letter-spacing:2px;">:&nbsp; <?php echo date('d/m/Y',strtotime($FchIndent['Dispatched_Date'])); ?></td>
  </tr>
  
  
</table>
</td>
  </tr>
  
    <tr>
  <td style="padding-top:15px; padding-bottom:15px; border-bottom:1px dashed #000000;">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
	<td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:3px 0px; letter-spacing:1px;">Gold Rate as on <?php echo date('d/m/Y',strtotime($FchIndent['Dispatched_Date'])); ?> </td>
	</tr>
	
	
  
   <tr>
     <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:3px 0px; letter-spacing:1px;">
	 <?php
	  $i=1;
	  $SqlGoldRate="Select gold_purity, gold_rate from  gold_indent_details where Order_No='".$_REQUEST['Order_No']."' group by gold_purity";
      $RsGoldRt=mysqli_query($Mainclass->dbh,$SqlGoldRate);
	  $CountGoldRt=mysqli_num_rows($RsGoldRt);
      while($FetchGoldRt=mysqli_fetch_array($RsGoldRt))
     {
	?>
	 <?php echo $FetchGoldRt['gold_purity']; ?>  : Rs. <?php echo $FetchGoldRt['gold_rate']; ?> 
	 
	  <?php
	  
	  if(($CountGoldRt!=$i) && $CountGoldRt>1)
	  {
		  echo "|";
	  }
	  
	  $i++;
	   }
     ?>
	 </td>
   </tr>
  </table>
  </td>
  </tr>

  
  <tr>
    <td ><table width="100%" border="0" cellspacing="0" cellpadding="0">
	
	<?php
	$TotalPQ=0;
	$TotalPAmt=0;
	$TotalItem=0;
	$TotalItemAmt=0;
	$SqlItem="select Product_Category, sum(Order_Quantity) as STNQty ,sum(Order_Total) as STNTotal from gold_indent_details where Order_No='".$_REQUEST['Order_No']."' group by Product_Category order by Product_Category";
	$RsItem=mysqli_query($Mainclass->dbh,$SqlItem);
	while($FchItem=mysqli_fetch_array($RsItem))
	{
	 $FetchCatCon=" SLN= '".$FchItem['Product_Category']."'";
     $Field_Needed="Category";
     $CategoryDtl=$Mainclass->Fetch_individual_data('gold_product_category_master',$Field_Needed,$FetchCatCon);
	 
	 
	 $PecentageQty=($FchItem['STNQty']/$FchIndent['Total_Quantity'])*100;
	 
	 $PecentageQty=round($PecentageQty,2);
	 
	 $PecentageAmt=($FchItem['STNTotal']/$FchIndent['Net_Total'])*100;
	 $PecentageAmt=round($PecentageAmt,2);
	 
	 $TotalPQ=$TotalPQ+$PecentageQty;
	 $TotalPAmt=$TotalPAmt+$PecentageAmt;
	?>
	
	
  <tr>
    <td width="25%" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; color:#000000; padding:3px 0px; letter-spacing:1px; text-transform:uppercase;"><?php echo $CategoryDtl['Category']; ?></td>
    <td width="5%" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:3px 0px; ">:</td>
    <td width="10%" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px; text-transform:uppercase;"><?php echo $FchItem['STNQty']; ?></td>
	<td width="10%" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px; text-transform:uppercase;"><?php echo $PecentageQty; ?> %</td>
    <td width="40%" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px; text-transform:uppercase;"><?php echo $FchItem['STNTotal']; ?></td>
	<td width="10%" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px; text-transform:uppercase;"><?php echo $PecentageAmt; ?>%</td>
  </tr>
  
  <?php
  $TotalItem=$TotalItem+$FchItem['STNQty'];
  $TotalItemAmt=$TotalItemAmt+$FchItem['STNTotal'];
  }
  
  $CustomerTotal=intval(round($TotalItemAmt));
  
  $RoundOff=$CustomerTotal-$TotalItemAmt;
  
  $RoundOff=round($RoundOff, 2);
  ?>

 <tr>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:uppercase; border-top:1px dashed #000000; border-bottom:1px dashed #000000; font-weight:600;">TOTAL</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:6px 0px; border-top:1px dashed #000000; border-bottom:1px dashed #000000; font-weight:600;">:</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:uppercase; border-top:1px dashed #000000; border-bottom:1px dashed #000000; font-weight:600;"><?php echo  $TotalItem; ?></td>
	<td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:uppercase; border-top:1px dashed #000000; border-bottom:1px dashed #000000; font-weight:600;"><?php echo$TotalPQ; ?> %</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:uppercase; border-top:1px dashed #000000; border-bottom:1px dashed #000000; font-weight:600;"><?php echo $TotalItemAmt; ?></td>
		<td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:uppercase; border-top:1px dashed #000000; border-bottom:1px dashed #000000; font-weight:600;"><?php echo $TotalPAmt; ?> %</td>
  </tr>
  
    <tr>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; color:#000000; padding:3px 0px; letter-spacing:1px;">Round off</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:3px 0px;">&nbsp;</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px; text-transform:uppercase;">&nbsp;</td>
	<td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px; text-transform:uppercase;">&nbsp;</td>
	
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px; text-transform:uppercase;"><?php  if($RoundOff>0){ echo "+".$RoundOff; }else{ echo $RoundOff;} ?></td>
	<td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px; text-transform:uppercase;">&nbsp;</td>
  </tr>
 
<tr>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:uppercase; border-bottom:1px dashed #000000; font-weight:600;">BILL AMOUNT</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:6px 0px; border-bottom:1px dashed #000000; font-weight:600;">&nbsp;</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:uppercase; border-bottom:1px dashed #000000; font-weight:600;">&nbsp;</td>
	   <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:uppercase; border-bottom:1px dashed #000000; font-weight:600;">&nbsp;</td>
	     
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:uppercase; border-bottom:1px dashed #000000; font-weight:600;"><?php echo number_format($CustomerTotal,2);?></td>
	 <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:uppercase; border-bottom:1px dashed #000000; font-weight:600;">&nbsp;</td>
  </tr>  
  
  
  <tr>
    <td colspan="6" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; color:#000000; padding:5px 0px; letter-spacing:1px;">Rs. <?php echo AmountConvervrtToWord($TotalItemAmt); ?> <span style="text-align:right; float:right;">E & o.E.</span></td>
    </tr>
</table>
</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  
  <tr>
   <td>
	<table width="200" border="0" cellspacing="0" cellpadding="0">
	
	<tr>
	<td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:3px 0px; text-transform:capitalize; border-top:1px dashed #000000; border-bottom:1px dashed #000000; font-weight:600; border-left:1px dashed #000000; ">Comp. </td>
	<td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:3px 0px; border-top:1px dashed #000000; border-bottom:1px dashed #000000; font-weight:600; border-left:1px dashed #000000;">Wt </td>
	<td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000;padding:3px 3px 3px 0px; border-top:1px dashed #000000; border-bottom:1px dashed #000000; font-weight:600; border-left:1px dashed #000000;  border-right:1px dashed #000000;">Value </td>
	
	</tr>
	
	 <?php
  $SqlTotalGold="Select gold_purity,sum(gold_wt) as total_gold_wt, sum(total_gold_value) as total_gold_value from  gold_indent_details where Order_No='".$_REQUEST['Order_No']."' group by gold_purity";
  $RsTotalGold=mysqli_query($Mainclass->dbh,$SqlTotalGold);
  while($FetchTotalGold=mysqli_fetch_array($RsTotalGold))
  {
  ?>
  <tr>
  <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:3px 0px;border-left:1px dashed #000000;"><?php echo $FetchTotalGold['gold_purity']; ?> Gold</td>
  <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:3px 0px;border-left:1px dashed #000000;"><?php echo $FetchTotalGold['total_gold_wt']; ?> g</td>
  <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000;  padding:3px 3px 3px 0px;border-left:1px dashed #000000; border-right:1px dashed #000000;"><?php echo $FetchTotalGold['total_gold_value']; ?></td>
  </tr>
  <?php
  }
  //$SqlTotalDia="Select diamond_carat, sum(total_diamond_value) as total_diamond_value from  gold_indent_details where Order_No='".$_REQUEST['Order_No']."' and total_diamond_value>0 group by diamond_carat";
   $SqlTotalDia="Select diamond_carat, sum(total_diamond_value) as total_diamond_value from  gold_indent_details where Order_No='".$_REQUEST['Order_No']."' and total_diamond_value>0";
  $RsTotalDia=mysqli_query($Mainclass->dbh,$SqlTotalDia);
  while($FetchTotalDia=mysqli_fetch_array($RsTotalDia))
  {
	?>  
	 <tr>
  <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:3px 0px;border-left:1px dashed #000000;">Diamond</td>
  <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:3px 0px;border-left:1px dashed #000000;">-</td>
  <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000;  padding:3px 3px 3px 0px;border-left:1px dashed #000000; border-right:1px dashed #000000;"><?php echo $FetchTotalDia['total_diamond_value']; ?></td>
  </tr>

<?php	
  } 
  $SqlTotalDia="Select sum(stone_value) as total_stone_value from  gold_indent_details where Order_No='".$_REQUEST['Order_No']."' and stone_value>0";
  $RsTotalDia=mysqli_query($Mainclass->dbh,$SqlTotalDia);
  while($FetchTotalDia=mysqli_fetch_array($RsTotalDia))
  {
?>
	 <tr>
  <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:3px 0px;border-left:1px dashed #000000;">Stone</td>
  <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:3px 0px;border-left:1px dashed #000000;">-</td>
  <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000;  padding:3px 3px 3px 0px;border-left:1px dashed #000000; border-right:1px dashed #000000;"><?php echo $FetchTotalDia['total_stone_value']; ?></td>
  </tr>

<?php
  }	  
  $SqlTotalDia="Select sum(Solitaire_Value) as total_solitaire_value from  gold_indent_details where Order_No='".$_REQUEST['Order_No']."' and Solitaire_Value>0";
  $RsTotalDia=mysqli_query($Mainclass->dbh,$SqlTotalDia);
  while($FetchTotalDia=mysqli_fetch_array($RsTotalDia))
  {
?>
	 <tr>
  <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:3px 0px;border-left:1px dashed #000000;">Solitaire</td>
  <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:3px 0px;border-left:1px dashed #000000;">-</td>
  <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000;  padding:3px 3px 3px 0px;border-left:1px dashed #000000; border-right:1px dashed #000000;"><?php echo $FetchTotalDia['total_solitaire_value']; ?></td>
  </tr>

<?php
  }
?>  
	<tr><td colspan="3" style="border-top:1px dashed #000000;"></td></tr>
	</table>
	</td>
  </tr>
    <tr>
    <td>&nbsp;</td>
  </tr>
  
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:capitalize; border-top:1px dashed #000000; border-bottom:1px dashed #000000; font-weight:600;">HSN</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:capitalize; border-top:1px dashed #000000; border-bottom:1px dashed #000000; font-weight:600;">Taxable Val</td>
   <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:capitalize; border-top:1px dashed #000000; border-bottom:1px dashed #000000; font-weight:600;">SGST%</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:capitalize; border-top:1px dashed #000000; border-bottom:1px dashed #000000; font-weight:600;">SGST</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:capitalize; border-top:1px dashed #000000; border-bottom:1px dashed #000000; font-weight:600;">CGST%</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:capitalize; border-top:1px dashed #000000; border-bottom:1px dashed #000000; font-weight:600;">CGST</td>
	<td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:capitalize; border-top:1px dashed #000000; border-bottom:1px dashed #000000; font-weight:600;">IGST%</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:capitalize; border-top:1px dashed #000000; border-bottom:1px dashed #000000; font-weight:600;">IGST</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:capitalize; border-top:1px dashed #000000; border-bottom:1px dashed #000000; font-weight:600;">Amount</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:6px 0px; letter-spacing:1px; text-transform:capitalize; border-top:1px dashed #000000; border-bottom:1px dashed #000000; font-weight:600;">QTY</td>
  </tr>
  
  
    <?php
	$TotalTaxable=0;
	$Total_SGST=0;
	$Total_CGST=0;
	$Total_IGST=0;
	$TotalHSNQty=0;
	$FinalTotalAmt=0;
 $SqlHsn="select distinct HSN_Code from  gold_indent_details  WHERE `Order_No`='".trim($_REQUEST['Order_No'])."'";
 $RsHsn=mysqli_query($Mainclass->dbh,$SqlHsn);
 while($RowHsn=mysqli_fetch_array($RsHsn))
  {
   // $Hsn=substr($RowHsn['HSN_Code'], 0, 4);  
    $Sql="select sum(GST) as HsnVat,sum(CGST) as CGST,sum(SGST) as SGST,sum(IGST) as IGST , sum(Total) as HsnTotal,sum(Order_Total) as FinalTotal,sum(Order_Quantity) as Order_Quantity from gold_indent_details where Order_No='".trim($_REQUEST['Order_No'])."' and HSN_Code='".$RowHsn['HSN_Code']."'";
    $Rs=mysqli_query($Mainclass->dbh,$Sql);
    $Row=mysqli_fetch_array($Rs);
   
   
     $TotalTaxable=$TotalTaxable+$Row['HsnTotal'];
    $Total_SGST=$Total_SGST+$Row['SGST'];
	$Total_CGST=$Total_CGST+$Row['CGST'];
	$Total_IGST=$Total_IGST+$Row['IGST'];
	$TotalHSNQty=$TotalHSNQty+$Row['Order_Quantity'];
    $FinalTotalAmt=$FinalTotalAmt+$Row['FinalTotal'];
	
	if($Row['CGST']>0)
	{
	  $CGST_Rate=1.50;
	  $SGST_Rate=1.50;
	}
	else{
	   $CGST_Rate=0;
	   $SGST_Rate=0;
	}
   
   if($Row['IGST']>0)
   {
      $IGST_Rate=3.00;
   }
   else{
       $IGST_Rate=0;
   }

  ?>
  <tr>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:3px 0px; letter-spacing:1px;"><?php echo $RowHsn['HSN_Code'];?></td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px;"><?php echo $Row['HsnTotal'];?></td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px;"><?php echo $CGST_Rate; ?></td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px;"><?php echo $Row['CGST'];?></td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px;"><?php echo $SGST_Rate; ?></td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px;"><?php echo $Row['SGST'];?></td>
	   <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px;"><?php echo $IGST_Rate; ?></td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px;"><?php echo $Row['IGST'];?></td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px;"><?php echo $Row['FinalTotal'];?></td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px;"><?php echo $Row['Order_Quantity'];?></td>
  </tr>
  
  
  <?php
  }
  ?>
  <!-- <tr>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:3px 0px; letter-spacing:1px;">7116</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px;">177365.88</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px;">1.50</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px;">2660.58</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px;">1.50</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px;">2660.58</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px;">182687.04</td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:3px 0px; letter-spacing:1px;">126</td>
  </tr>-->
  <tr>
    <td colspan="3" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:5px 0px; letter-spacing:1px; border-bottom:1px dashed #000000; border-top:1px dashed #000000; font-weight:600;"><?php echo $TotalTaxable; ?></td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:5px 0px; letter-spacing:1px; border-bottom:1px dashed #000000; border-top:1px dashed #000000; font-weight:600;"><?php echo $Total_SGST; ?></td>
    <td colspan="2" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:5px 0px; letter-spacing:1px; border-bottom:1px dashed #000000; border-top:1px dashed #000000; font-weight:600;"><?php echo $Total_CGST; ?></td>
	    <td colspan="2" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:5px 0px; letter-spacing:1px; border-bottom:1px dashed #000000; border-top:1px dashed #000000; font-weight:600;"><?php echo $Total_IGST; ?></td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:5px 0px; letter-spacing:1px; border-bottom:1px dashed #000000; border-top:1px dashed #000000; font-weight:600;"><?php echo $FinalTotalAmt;?></td>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:right; color:#000000; padding:5px 0px; letter-spacing:1px; border-bottom:1px dashed #000000; border-top:1px dashed #000000; font-weight:600;"><?php echo $TotalHSNQty;?></td>
  </tr>
</table>
</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>

  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="60%" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; color:#000000; padding:20px 0px 0px; letter-spacing:1px; bfont-weight:600;">Receive Signature with Stamp</td>
    <td width="40%" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:20px 0px 0px; letter-spacing:1px; bfont-weight:600;">Signature</td>
  </tr>
</table>
</td>
  </tr>
  <tr>
    <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; color:#000000; padding:10px 0px; letter-spacing:1px; bfont-weight:500;"><!--(No-E-way bill is required to be generated as the goods covered under this invoice<br />
are expected as per serial No.4/5 to the Annexture to rule 138(4)of the CGST Rules.--></td>
  </tr>
  <tr>
    <td style="padding:15px 0px;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="45%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td style="background-color:#000000; height:1px;"></td>
  </tr>
</table>
</td>
    <td width="10%" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; color:#000000; padding:3px 0px; letter-spacing:1px;">Cut Mark</td>
    <td width="45%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td style="background-color:#000000; height:1px;"></td>
  </tr>
</table></td>
  </tr>
</table>
</td>
  </tr>
  <tr>
    <td style="font-family:Arial, Helvetica, sans-serif; text-align:center; font-size:16px; font-weight:600; color:#000000; padding-bottom:10px;">GATE PASS</td>
  </tr>
   <tr>
    <td style="font-family:Arial, Helvetica, sans-serif; text-align:right; font-size:12px; line-height:20px; font-weight:500; color:#000000;">Chandrani Pearls Pvt. Ltd <br />
216, Rajdanga Main Road, Kolkata - 700107
</td>
  </tr>
  
   <tr>
    <td style="font-family:Arial, Helvetica, sans-serif; text-align:left; font-size:12px; line-height:20px; font-weight:500; color:#000000;">No. <?php echo $FchIndent['Gate_Pass_No']; ?><br />
Sending <?php echo $FchIndent['No_of_Boxes']; ?> no, box vide REF No. <?php echo $FchIndent['STN_NO']; ?><br />
Dated <?php echo date('d/m/Y',strtotime($FchIndent['Dispatched_Date'])); ?> through <?php echo $FchIndent['Courier_Name']; ?>

<?php
if($FchIndent['Shipment_No']!='')
{
  echo "(".$FchIndent['Shipment_No'].")";

}

?>

<br />
c_<?php echo $FchIndent['Toal_Product_Weight']; ?>(<?php echo $FchIndent['Total_Weight']; ?>)
</td>
  </tr>
   <tr>
    <td style="padding-top:20px;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="50%" style="font-family:Arial, Helvetica, sans-serif; text-align:left; font-size:12px; line-height:20px; font-weight:500; color:#000000; ">Date : <br />
<br />
Issued By : </td>
    <td width="50%" style="font-family:Arial, Helvetica, sans-serif; text-align:left; font-size:12px; line-height:20px; font-weight:500; color:#000000;">Time : <br />
<br />
Signature :</td>
  </tr>
</table>
</td>
  </tr>
</table></td>
  </tr>
  <tr>
    <td style="padding-top:20px;"><table width="50" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td><input name="" type="button" value="PRINT" onClick="Print()" id="print_gatepass_btn" /></td>
  </tr>
</table>
</td>
  </tr>
</table>

</div>







</body>
</html>
