<?php include 'connection.php';

session_start();

if (!isset($_SESSION['is_logged_in'])) {

    header("Location:login.php");

    die();

    }

$querylogin = "select * from users where username = '". $_SESSION["LOGIN_NAME"]."' AND password = '".$_SESSION["EMPLOYEE_PASSWORD"]."'";

$resultlogin = mysql_query($querylogin,$conn);

while($row=mysql_fetch_array($resultlogin))

{

$user_id = $row['id'];

$staff_name = $row['full_name'];

$avatar = $row['avatar'];

$tech_id = $row['teacher_id'];





}







?><!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 charset="utf-8" />

   <title>Billing Software</title>

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

    <meta content="Admin Dashboard" name="description" />

    <meta content="ThemeDesign" name="author" />

    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <link rel="shortcut icon" href="assets/images/favicon.png">

    <link href="assets/plugins/datatables/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />

    <link href="assets/plugins/datatables/responsive.bootstrap.min.css" rel="stylesheet" type="text/css" />

    <link href="assets/plugins/datatables/dataTables.bootstrap.min.css" rel="stylesheet" type="text/css" />

  <link href="assets/plugins/timepicker/bootstrap-timepicker.min.css" rel="stylesheet">

    <link href="assets/plugins/bootstrap-colorpicker/css/bootstrap-colorpicker.min.css" rel="stylesheet">

    <link href="assets/plugins/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet">

    <link href="assets/plugins/bootstrap-touchspin/css/jquery.bootstrap-touchspin.min.css" rel="stylesheet" />

    <link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">

    <link href="assets/css/icons.css" rel="stylesheet" type="text/css">

    <link href="assets/css/style.css" rel="stylesheet" type="text/css">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><style type="text/css">

<!--

body {

  background-color: #FFFFFF;

}

-->

</style>

<style type="text/css">

#printable { display: ; }

    @media print

    {

    	#non-printable { display: none; }

    	#printable { display: block; }

    }

	 #footer {

    position:relative;

    bottom : 0;

	}

     #header {

    position:fixed;

    top : 0;

	}

</style>
</head>



<body>



<? 

$queryls = "select * from credit_main where credit_main_id='".$_REQUEST['credit_main_id']."'";

$resultls = mysql_query($queryls,$conn); 

while($row=mysql_fetch_array($resultls))

{
$item_code = $row['item_code'];
$credit_no = $row['credit_no'];
$credit_date = $row['credit_date'];
$customer_id = $row['customer_id'];
$year = $row['f_year'];
$customer_name = $row['customer_name'];
$GST_Btype = $row['GST_Btype'];
$amount = $row['amount'];
$reference_no=$row['reference_no'];
$refer_date=$row['refer_date'];

} 



$queryls1 = "select * from customer_master where customer_id='".$_REQUEST['customer_id']."' ";

$resultls1 = mysql_query($queryls1,$conn); 

while($row=mysql_fetch_array($resultls1))

{

$billing_address = $row['billing_address'];

$customer_name = $row['customer_name'];

$bill_address  = $row['bill_address'];

$bstate = $row['bstate'];

$bstate_code = $row['bstate_code'];

$billtoGSTN  = $row['billtoGSTN'];

$bill_cin  = $row['bill_cin'];

$bill_panno = $row['bill_panno'];



$ship_address = $row['ship_address'];

$sstate  = $row['sstate'];

$sstate_code  = $row['sstate_code'];

$shiptoGSTN = $row['shiptoGSTN'];

$ship_cin = $row['ship_cin'];

$ship_panno  = $row['ship_panno'];



$TCS_applicable = $row['TCS_applicable'];

$TCS_percentage = $row['TCS_percentage'];


}



$queryc = "select * from  transporter_master where transporter_id='$carrier01'";

$resultlc = mysql_query($queryc,$conn); 

while($row=mysql_fetch_array($resultlc))

{

$carrier= $row['transporter_name']; 

}





?>

<div class="container">

	<img src="header_bar_shigmoda.jpg"/>
<div style="height:20px;"></div>
<div class="non-printable" id="non-printable" style="padding-left:10px;"><a href="index.php">Back to Dashbaord </a><button onClick="myFunction()">Print this page</button>



<script>

function myFunction() {

    window.print();

}

</script></div>

<div align="center"></div>

<table width="100%" border="1" style="border-collapse:collapse; font-size:13px;">

  

  

  <tr>

    <td colspan="14"><div align="center"><strong>credit NOTES</strong></div></td>
  </tr>

  
  <tr>

    <td colspan="14"><div>
      <table width="100%" border="1">
        <tr>
          <td width="25%"><div align="left" style="padding:2px;">credit Note No.: </div></td>
          <td width="32%"><div align="left" style="padding:2px;"><?php echo $credit_no?></div></td>
          <td width="18%"><div align="left" style="padding:2px;">Reference No.: </div></td>
          <td width="25%"><?php echo $reference_no;?></td>
          </tr>
        <tr>
          <td><div align="left" style="padding:2px;">Date:&nbsp;</div></td>
          <td><div align="left" style="padding:2px;"><?php echo $credit_date?></div></td>
          <td><div align="left" style="padding:2px;">Date:&nbsp;<?php echo $refer_date;?></div></td>
          <td>&nbsp;</td>
          </tr>
      </table>
    </div></td>
  </tr>

<tr>

  <td colspan="12" ><div align="left" style="padding:2px;"><strong>Details Of Receiver (BIlled To):</strong>



</div></td>
  </tr>
<tr>
  <td colspan="12" ><table width="100%">
    <tr>
      <td><div align="left" style="padding:2px;">Consignee Name: </div></td>
      <td colspan="3"><div align="left" style="padding:2px;"><?php echo $customer_name?></div></td>
    </tr>
    <tr>
      <td><div align="left" style="padding:2px;">Address: </div></td>
      <td colspan="3"><div align="left" style="padding:2px;"><?php echo $bill_address?></div></td>
    </tr>
    <tr>
      <td width="25%">
          <div align="left" style="padding:2px;">State :</div>      </td>
      <td width="23%"><div align="left" style="padding:2px;"><?php echo $bstate?></div></td>
      <td width="7%">Code :</td>
      <td width="45%"><div align="left" style="padding:2px;"><?php echo $bstate_code?></div></td>
    </tr>
    <tr>
      <td>
          <div align="left" style="padding:2px;">GSTIN :</div>      </td>
      <td colspan="3"><div align="left" style="padding:2px;"><?php echo $billtoGSTN?></div></td>
    </tr>
  </table></td>
  </tr>
<tr>
  <td colspan="12" ><div align="left" style="padding:2px;"><strong>Details Of Consignee (Shipped To):</strong> </div></td>
  </tr>



<tr>

  <td colspan="13" ><div align="left" style="padding:2px;">
    <table width="100%">
      <tr>
        <td><div align="left" style="padding:2px;">Receiver Name: </div></td>
        <td colspan="3">
            <div align="left" style="padding:2px;"><?php echo $customer_name?></div>        </td>
      </tr>
      <tr>
        <td><div align="left" style="padding:2px;">Address: </div></td>
        <td colspan="3">
            <div align="left" style="padding:2px;"><?php echo $ship_address?></div>        </td>
      </tr>
      <tr>
        <td width="25%" height="30">
            <div align="left" style="padding:2px;">State :</div>       </td>
        <td width="23%"><div align="left" style="padding:2px;"><?php echo $sstate?></div></td>
        <td width="7%">Code :</td>
        <td width="45%"><div align="left" style="padding:2px;"><?php echo $sstate_code?></div></td>
      </tr>
      <tr>
        <td>
            <div align="left" style="padding:2px;">GSTIN :</div>        </td>
        <td colspan="3"><div align="left" style="padding:2px;"><?php echo $shiptoGSTN?></div></td>
      </tr>
    </table>
  </div></td>
  </tr>

  

  <tr>

    <td width="2%" rowspan="2" ><div align="center">S.N.</div></td>

    <td width="17%" rowspan="2"><div align="center">Description of Goods</div></td>

      <td width="5%"><div align="center">QTY</div></td>



    <td width="8%"><div align="center">Rate</div></td>

    <td width="9%"><div align="center">Taxable Amt</div></td>

    <td colspan="2"><div align="center">SGST</div></td>

    <td width="12%" colspan="2"><div align="center">CGST</div></td>

    <td width="8%" colspan="2"><div align="center">IGST</div></td>
    <td width="11%"><div align="center">Total Value</div></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div align="center">&#8377;</div></td>
    <td><div align="center">&#8377;</div></td>
    <td width="6%"><div align="center">%</div></td>
    <td width="6%"><div align="center">&#8377;</div></td>
    <td><div align="center">%</div></td>
    <td><div align="center">&#8377;</div></td>
    <td><div align="center">%</div></td>
    <td><div align="center">&#8377;</div></td>
    <td><div align="center">&#8377;</div></td>
  </tr>



  <?

   $i=1;

$query2 = "select * from credit_details_more where credit_no = '".$_REQUEST['credit_no']."' AND customer_id = '".$_REQUEST['customer_id']."'  ORDER BY credit_more_id desc";

$result=mysql_query($query2,$conn);

$num_rows = mysql_num_rows($result);

$i=1;

while($row=mysql_fetch_array($result))

{  
$details = $row['details'];
$product_id = $row['product_id'];

$currency = $row['currency'];

$credit_more_id = $row['credit_more_id'];

$qty=$row['qty'];

$HSN_code = $row['HSN_code'];

$rate = $row['rate'];

$pro_value = $qty*$rate;

$total+=$pro_value;



$CGST = $row['CGST_rate'];

$SGST = $row['SGST_rate'];

$IGST = $row['IGST_rate'];





?>

<?php if($GST_Btype =='Local') { $cgstvalue = $pro_value*$CGST/100; $cgstvalue;  $sumcgst+=$cgstvalue;} ?>

<?php if($GST_Btype =='Local') { $sgstvalue = $pro_value*$SGST/100;  $sgstvalue;  $sumsgst+=$sgstvalue;} ?>

<?php if($GST_Btype =='OMS') { $igstvalue = $pro_value*$IGST/100;  $igstvalue;  $sumigst+=$igstvalue;} ?>

<?php  $totagst = $sumcgst+$sumsgst+$sumigst;  ?>

<?php

$query2hsn="SELECT * FROM  credit_details_more WHERE  credit_no ='".$_REQUEST['credit_no']."' AND customer_id = '".$_REQUEST['customer_id']."' and credit_more_id='$credit_more_id' ORDER BY credit_more_id desc";

//echo $query2hsn;

$result1hsn = mysql_query($query2hsn,$conn);

while($query3hsn=mysql_fetch_array($result1hsn))

{

$CGST = $query3hsn['CGST_rate'];

$SGST = $query3hsn['SGST_rate'];

$IGST = $query3hsn['IGST_rate'];

$UGST = $query3hsn['UGST'];

 max($IGST);

}

$items_max[] = $IGST;



$maxtax =  max($items_max);

	 ?>

  <tr>

    <td><div align="center"><span style="padding:2px;"><? echo $i;?></span></div></td>

    <td><div align="left" style="padding-left:3px;"><?php echo $details?></div></td>

    <td><div align="center" style="padding:2px;"><? echo $qty;?></div></td>

    <td><div align="center" style="padding:2px;"><? echo $rate;?></div></td>

    <td><div align="center" style="padding:2px;"><? echo $pro_value;?></div></td>

    <td><div align="center" style="padding:2px;"><? if($GST_Btype =='Local') { echo $SGST;}?></div></td>

    <td><div align="center" style="padding:2px;"><? if($GST_Btype =='Local') {echo round($sgstvalue,0);}?></div></td>

    <td><div align="center" style="padding:2px;"><? if($GST_Btype =='Local') {echo $CGST;}?></div></td>

    <td><div align="center" style="padding:2px;">
      <? if($GST_Btype =='Local') {echo round($cgstvalue,0);}?>
    </div></td>
    <td><div align="center" style="padding:2px;">
      <? if($GST_Btype =='OMS') {  echo $IGST; }?>
    </div></td>
    <td><div align="center" style="padding:2px;">
      <? if($GST_Btype =='OMS') {  echo round($igstvalue,0);}?>
    </div></td>
    <td><div align="center" style="padding:2px;"><? echo round($pro_value+$sgstvalue+$cgstvalue+$igstvalue);?></div></td>
  </tr> <?php $i++;}?>


  <tr>

    <td colspan="5" rowspan="5" valign="top"><div align="left" style="padding:3px;"><strong>State:</strong> Maharashtra<br>
<strong>Code:</strong> 27 <br>
<strong>TAN :</strong> PNEA13258A<br>
<strong>GST:</strong> 27AAICA3372L1ZE<br>
<strong>PAN:</strong> AAICA3372L<br>
<strong>CIN:</strong> U21020MH2010PTC201231</div></td>

	<td colspan="6"><div align="right" style="padding:2px;"> Total Bef. Tax</div></td>

    <td><div align="center"><?php echo $sub_total = $total?></div></td>
  </tr>

   

  <tr>

    <td colspan="6"><div align="right" style="padding:2px;"> Total CGST</div></td>

    <td><div align="center"><?php echo round($sumcgst,0)?></div></td>
  </tr>

  <tr>

    <td colspan="6"><div align="right" style="padding:2px;"> Total SGST</div></td>

    <td><div align="center"><?php  echo round($sumsgst,0);?></div></td>
  </tr>
  <tr>
    <td colspan="6"><div align="right" style="padding:2px;"> Total IGST</div></td>
    <td><div align="center">
      <?php  echo round($sumigst,0);?>
    </div></td>
  </tr>

  

 

   <tr>

     <td colspan="6"><div align="right" style="padding:2px;">Grand Total</div></td>

     <td><div align="center"><?php $grandtotal= $total+$sumcgst+$sumsgst+$sumigst; echo round($grandtotal,0)?></div></td>
   </tr>

  

   <tr>

     <td colspan="21" valign="top"><div align="left" style="padding:2px;">Amount Chargeable (in words) :<strong><br />

             <?php  

   $no = round($grandtotal);

   $point = round($grandtotal - $no, 0) * 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;

     $finaltotal = floor($no % $divider);

     $no = floor($no / $divider);

     $i += ($divider == 10) ? 1 : 2;

     if ($finaltotal) {

        $plural = (($counter = count($str)) && $finaltotal > 9) ? '' : null;

        $hundred = ($counter == 1 && $str[0]) ? ' and ' : null;

        $str [] = ($finaltotal < 21) ? $words[$finaltotal] .

            " " . $digits[$counter] . $plural . " " . $hundred

            :

            $words[floor($finaltotal / 10) * 10]

            . " " . $words[$finaltotal % 10] . " "

            . $digits[$counter] . $plural . " " . $hundred;

     } else $str[] = null;

  }

  $str = array_reverse($str);

  $result = implode('', $str);

  $points = ($point) ?

    "." . $words[$point / 10] . " " . 

          $words[$point = $point % 10] : '';

 echo $result=ucwords(strtolower($result)); "  "; ?>

     only</strong></div></td>
   </tr>


<tr>

    <td colspan="14" ><div align="right" style="padding:2px;">
      
      For SHIGMODA CARRIERS & LIFTERS PRIVATE LIMITED<br><br><br><br>
      
    Authorised Signatory</div></td>
  </tr>
</table>
</body>
</html>

