<?php 
include "config.php";
error_reporting(0);
?>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>Bill</title></head>
<script>
  function enterkeypressed()
{
	//alert(event.keyCode);
	if(event.keyCode=='13'){ window.print(); }
}
</script>
<body onkeydown="enterkeypressed()" ontouchstart="window.print()"><div style="margin-bottom:80px">
<div id="p1">
<center>
  <table border="3" width="760"  cellpadding="5" style="border-collapse:collapse;">
       <tr style="border-bottom:2pt solid black;">
       <td style="border-right:2pt solid black;" colspan="11"  >
     
       
  <table width="100%" >
  <tr style="border:2px solid red">

<td width="100%" align="left" style="border:2px solid black;border-radius:10px;padding-left:40px;padding-top:10px;padding-bottom:10px"> <span >
     <strong><font size="5dp"><span style="margin-left:60px;">Sri Murugan Crushers</span></font></strong>
     <br>
     <font style="font-size: 16px;">S.F No.301/1 & C NARANAMANGALAM VILLAGE<br> <span style="margin-left:40px;">AALATHUR(TK)

     PERAMBALUR-621 109</span> <span style="margin-left:190px;font-size:24px;font-weight:bold">INVOICE</span> <br>
     <span style="margin-left:120px;margin-top:100px;"> Cell:7373055273</span><br>
     <span style="margin-left:80px;margin-bottom:20px;"><b>GSTIN &nbsp;&nbsp;:33ABGPU1543H1ZQ</b></span>
   </font>
</span>
 <br>


</td>
<!-- <td width="16%" align="center" >
  </td> -->

</tr>
</table>
<!-- <table border="0" width="100%">
<tr>
<td align="left"><b>E-mail : feenix@gmail.com</b></td>
<td align="left"  valign="center" width="255"><B><b>GSTIN &nbsp;&nbsp;: 33BMRPS7277P1ZT</b></B></td>
</tr>
</table> -->




</td>
</tr>

     <tr >
      <td colspan="5" rowspan="3" style="border-right:2pt solid black; border-bottom:2pt solid black;" valign="top" >
        <div align="left"><U><B><font size="3">Customer</font><font size="3"> Name & Address</font></B></U>
        <?php 

  $customer= $_GET['customer'];
  $sales = $_GET['sales'];
  $vehicle=$_GET['vehicle'];
  $delivery=$_GET['delivery'];
  
$cus=mysqli_query($connect,"select * from customerdetails where status !='deleted' && code = '$customer'");
while($cusshow = mysqli_fetch_array($cus))
{
?><br>
 <?php echo $cusshow['name'] ?><br>
 <?php echo $cusshow['address'] ?><br>
 <?php echo $cusshow['district'] ?><br>
           <?php echo $cusshow['state'] ?>- <?php echo $cusshow['pincode'] ?><br><br>
           
          <b>Mobile No:<?php  echo $cusshow['mobile']?></b><b style="margin-left:150px;">GST.No:<?php  echo $cusshow['gst']?> </b>
        </div></td>
      <td colspan="4" style="border-right:2pt solid black;"><center>
        <b> ORIGINAL INVOICE</b>
      </center></td></tr>
         <td colspan="2">Invoice No.</td>:<td colspan="2" style="border-right:2pt solid black;"><?php echo $sales ?><br>  </td> 
         </tr>
         <!--<td colspan="2"><b>Bill Amount</b></td><td colspan="2" style="border-right:2pt solid black;">: <b  id="amd"></b> </td> </tr>-->    
        <tr><td colspan="2">Date.</td>:<td colspan="2"  style="border-right:2pt solid black;"><?php  echo $_GET['date'] ?><br> </td> 
      </tr>
        <?php 
  }
        ?>
       
    <tr style="border-bottom:2pt solid black; border-top:2pt solid black;">
    <td width="5%" style="border-right:2pt solid black;" ><center><b>Sno.</b></center></td>
    <td width="50%" style="border-right:2pt solid black;" colspan="2"><center><b>Description of Goods</b></center></td>
    <td width="10%" style="border-right:2pt solid black;"><center><b>HSN</b></center></td>
   
    
    <td  width="17%" style="border-right:2pt solid black;"><center>
      <strong>Rate</strong>
    </center>
    </td>
    
    <td width="12%" style="border-right:2pt solid black;"><center>
      <strong>      Qty      </strong>
    </center>    </td>
    <td width="17%"   style="border-right:2pt solid black;"><center>
      <strong>Unit</strong>
    </center>
    
    </td>
    <td width="10%" style="border-right:2pt solid black;"><center>
      <b>Tax%</b>
    </center></td>
    <td width="12%"  style="border-right:2pt solid black;"><center>
      <b>Total</b>
    </center></td>
   
    
     
     <tr style="border-bottom:0pt solid white;">
      
     <?php 

 
    $product = $_GET['product'];
$cus=mysqli_query($connect,"select * from productdetail where status !='deleted' && productcode='$product'");
while($cusshow = mysqli_fetch_array($cus))
{
  $price = $_GET['price'];
  $qty = $_GET['quantity'];
  $gst = $cusshow['tax'];
  $inclu = $price * 100 /( 100 + $gst);
  $sub = $inclu * $qty;
  $tax = (0.01*$gst*$sub);
    $count +=1;
 ?>
      <td  align="center" ><?php echo $count ?></td>
      <td colspan="2"><?php echo $cusshow['productname'] ?></td>
    
      <td  align="center"><?php echo $cusshow['hsn'] ?>
        </td>
      
      
      <td align="right"><?php echo number_format($inclu,"2",".","") ?></td>
      <td width="6%" align="right">
      <?php echo $_GET['quantity'] ?>        </td>
      <td width="12%" align="right">
      <?php echo($cusshow['unit'])?>
        </td>
      
      <td  width="6%" align="right"><?php echo $gst ?>
        </td>
      
      <td style="border-right:2pt solid black;" align="right"><?php echo number_format(($sub),"2",".","") ?></td>
     </tr>
       <tr style="border-bottom:0pt solid white;"> 
       <?php 
  }
    ?>
      <td  align="center" ></td>
      <td colspan="2"></td>
    
      <td  align="center">
        </td>
      
      
      <td align="right"></td>
      <td width="6%" align="right">
      
      <td width="12%" align="right">
     
        </td>
      
      <td  width="6%" align="right">      </td>
      
      <td style="border-right:2pt solid black;" align="right"></td>
     </tr>
        <tr style="border-bottom:0pt solid white;"> 

        <td  align="center" ></td>
      <td colspan="2"></td>
    
      <td  align="center">
        </td>
      
      
      <td align="right"></td>
      <td width="6%" align="right">
      
      <td width="12%" align="right">
     
        </td>
      
      <td  width="6%" align="right">      </td>
      
      <td style="border-right:2pt solid black;" align="right"></td>
     </tr>
    <tr style="border-bottom:0pt solid white;"> 

    <td  align="center" ></td>
      <td colspan="2"></td>
    
      <td  align="center">
        </td>
      
      
      <td align="right"></td>
      <td width="6%" align="right">
      
      <td width="12%" align="right">
     
        </td>
      
      <td  width="6%" align="right">      </td>
      
      <td style="border-right:2pt solid black;" align="right"></td>
     </tr>
  <tr style="border-bottom:0pt solid white;"> 

  <td  align="center" ></td>
      <td colspan="2"></td>
    
      <td  align="center">
        </td>
      
      
      <td align="right"></td>
      <td width="6%" align="right">
      
      <td width="12%" align="right">
     
        </td>
      
      <td  width="6%" align="right">      </td>
      
      <td style="border-right:2pt solid black;" align="right"></td>
     </tr>
     <tr style="border-bottom:0pt solid white;"> 

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

  <td  align="center">
    </td>
  
  
  <td align="right"></td>
  <td width="6%" align="right">
  
  <td width="12%" align="right">
 
    </td>
  
  <td  width="6%" align="right">      </td>
  
  <td style="border-right:2pt solid black;" align="right"></td>
 </tr>
<tr style="border-bottom:0pt solid white;"> 

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

  <td  align="center">
    </td>
  
  
  <td align="right"></td>
  <td width="6%" align="right">
  
  <td width="12%" align="right">
 
    </td>
  
  <td  width="6%" align="right">      </td>
  
  <td style="border-right:2pt solid black;" align="right"></td>
 </tr>
 <tr style="border-bottom:0pt solid white;"> 

    <td  align="center" ></td>
      <td colspan="2"></td>
    
      <td  align="center">
        </td>
      
      
      <td align="right"></td>
      <td width="6%" align="right">
      
      <td width="12%" align="right">
     
        </td>
      
      <td  width="6%" align="right">      </td>
      
      <td style="border-right:2pt solid black;" align="right"></td>
     </tr>
  <tr style="border-bottom:0pt solid white;"> 

  <td  align="center" ></td>
      <td colspan="2"></td>
    
      <td  align="center">
        </td>
      
      
      <td align="right"></td>
      <td width="6%" align="right">
      
      <td width="12%" align="right">
     
        </td>
      
      <td  width="6%" align="right">      </td>
      
      <td style="border-right:2pt solid black;" align="right"></td>
     </tr>
     <tr style="border-bottom:0pt solid white;"> 

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

  <td  align="center">
    </td>
  
  
  <td align="right"></td>
  <td width="6%" align="right">
  
  <td width="12%" align="right">
 
    </td>
  
  <td  width="6%" align="right">      </td>
  
  <td style="border-right:2pt solid black;" align="right"></td>
 </tr>
<tr style="border-bottom:0pt solid white;"> 

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

  <td  align="center">
    </td>
  
  
  <td align="right"></td>
  <td width="6%" align="right">
  
  <td width="12%" align="right">
 
    </td>
  
  <td  width="6%" align="right">      </td>
  
  <td style="border-right:2pt solid black;" align="right"></td>
 </tr>

    <?php
        function convertNumberToWord($number = false)
{
  
   $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;
	    $plural =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] : '';
  //echo $result . "Rupees  " . $points . " Paise";
    return  $result;
}
?>
<?php 

 
    $product = $_GET['product'];
$cus=mysqli_query($connect,"select * from productdetail where status !='deleted' && productcode='$product'");
while($cusshow = mysqli_fetch_array($cus))
{
  $price = $_GET['price'];
  $qty = $_GET['quantity'];
  $gst = $cusshow['tax'];
  $inclu = $price * 100 /( 100 + $gst);
  $sub = $inclu * $qty;
  $tax = (0.01*$gst*$sub);
    //$count +=1;
    $total=$price*$qty;
 ?>
  
    <tr style="border-top:2pt solid black;border-bottom:2pt solid black;">
    <!-- <td colspan="6" rowspan="4" align="left" valign="top" style="border-top:2pt solid black; font-size:18px;"><br> -->
        <!-- <strong>opening balance:  + Current Bill Amount:  = Total Pending:         </strong></p>--></td>
    <td colspan="8" align="right"style="border-right:2pt solid black"><b>Total Amount Before Tax</b></td><td style="border-right:2pt solid black;" colspan="" align="right">&nbsp;<?php echo number_format( ($sub),"2",".","")?></td>
    </tr>
    <br>
    <tr> 
    </tr>
    
    <tr style="border-top:1pt solid black;"> 
    <td colspan="5" rowspan="4" align="left" valign="top" style="border-top:1pt solid black;border-right:1pt solid black;"><strong>Account Details: </strong>    </td>
    <td colspan="3" align="right" >&nbsp;<b>Total Tax Amount</b></td><td><?php echo number_format( ($tax),"2",".","")?></td></tr>
    <tr> <td colspan="3" align="right"><b>CGST <?php echo ($cusshow['tax']/2)."%" ?></b></td><td style="border-right:2pt solid black;" colspan="" align="right">&nbsp;<?php echo number_format( ($tax/2),"2",".","")?></td>
    </tr>
    <tr> <td colspan="3" align="right"><b>SGST <?php echo ($cusshow['tax']/2)."%" ?></b></td><td style="border-right:2pt solid black;" colspan="" align="right">&nbsp;<?php echo number_format( ($tax/2),"2",".","")?></td>
    </tr>
    <tr> <td colspan="3" align="right"><b>Total Amount After Tax</b></td><td style="border-right:2pt solid black;" colspan="" align="right">&nbsp;<?php echo round((number_format( ($price * $qty),"2",".","")))?></td>
    </tr>
    <tr>
      <td colspan="9"><strong>Amount Chargeable (in words)Rupees</strong><strong>:&nbsp;&nbsp;<u><?php echo ucfirst(convertNumberToWord($total)).'rupees only'; ?></u></strong>
      </td>
    </tr>
    <?php 
  }
    ?>
     <tr style="border-bottom:2pt solid black;border-top:2pt solid black; ">
   <td colspan="4">
<b>Vehicle No:<?php echo $vehicle?></b><br>
<b>Delivery:<?php echo $delivery?></b>

   </td>
     <td style="border-right:2pt solid black;" colspan="8" align="right"  valign="top"><b><font size="4">For Feenix Infotech</font> </b><br />
 
<br />
<br>Authorized signatory</td> 
   </table>
   <table width="760" style="border:2px solid black">
    <tr><th><center>For Emergeny Queries Contact - 9842466273 Between 10am to 4pm</center></th></tr>
    </table>
    <table width="700">
    <tr><td><center> This is Computer Generated Invoice</center></td></tr>
    </table>
   
</div>
</div>
</body>
</html>