<?php include 'connection.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>Invoice</title>

													
<?php												
$query2 = "select * from company_info where name = '".$_REQUEST['our_company_name']."'";
$result2 = mysql_query($query2,$conn);	
while($row = mysql_fetch_array($result2))
{
$full_name_com = $row['full_name_com'];
}
?>
<?php												
$query2 = "select * from customer_master where customer_id = '".$_REQUEST['customer_id']."'";
$result2 = mysql_query($query2,$conn);	
while($row = mysql_fetch_array($result2))
{
$billing_address = $row['billing_address'];
$bgst_no = $row['bgst_no'];
$customer_name = $row['customer_name'];
$bstate_code = $row['bstate_code'];

}
?>
<?php
$str = $_REQUEST['trans_inv_no'];
				$resultset = explode("/",$str);
				
			$transport_name = current($resultset);
				
				?>
				
				<?php 
$query2tm = "select * from transport_master where short_form = '$transport_name'";
$result2tm = mysql_query($query2tm,$conn);	
while($row = mysql_fetch_array($result2tm))
{
$full_name = $row['transport_name'];
}
?>
<style type="text/css">
#printable { display: ; }
#footer {
    position : absolute;
    bottom : 0;
    
  }
    @media print
    {
    	#non-printable { display: none; }
    	#printable { display: block; }
    }
</style>
<style type="text/css">
<!--
.style1 {
	font-family: arial;
	font-size: 14px;
}
.style3 {font-size: 18px; font-weight: bold; }
.style4 {font-size: 14px; padding:3px; font:Arial, Helvetica, sans-serif;}
.style6 {font-size: 13px; padding: 3px; font: Arial, Helvetica, sans-serif; font-weight: bold; }
.style8 {font-size: 12px; line-height:150%;}
-->
</style>
</head>

<body>
 
<table width="100%" style="border-collapse:collapse">
<tr  class="non-printable"><td width="89%"><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" class="style10" >
        <input type="hidden" id="inv_no" name="inv_no" value="<? echo $_REQUEST['inv_no'] ?>" >
		<input type="hidden" id="Job_No" name="Job_No" value="<? echo $_REQUEST['Job_No'] ?>" >
			 			  <input type="hidden" id="trans_inv_date" name="trans_inv_date" value="<? echo $_REQUEST['trans_inv_date'] ?>" >
						   <input type="hidden" id="customer_id" name="customer_id" value="<? echo $_REQUEST['customer_id'] ?>" >
						   <input type="hidden" id="trans_inv_no" name="trans_inv_no" value="<? echo $_REQUEST['trans_inv_no'] ?>" >
						    <input type="hidden" id="our_company_name" name="our_company_name" value="<? echo $_REQUEST['our_company_name'] ?>" >
							    
        <div class="login-fields" id="non-printable" style="padding-left:5px;">
         <div class="field">
        			 <select name="space_01" id="space_01" class="login username-field input-small" required >
			<option>Select</option>
			<option value="<?php echo $_REQUEST['space_01']?>" selected="selected"><?php echo $_REQUEST['space_01']?></option>
			<option value="Null">Null</option>
			<option value="1">1</option>
			<option value="2">2</option>
    		<option value="3">3</option>
			<option value="4">4</option>
			</select>
			
			<input type="submit" value="Submit"></div></div></form></td>
	<td width="11%">
			
			 <div class="non-printable" id="non-printable" style="padding-left:10px;"><a href="index.php">Back to Dashbaord </a></div>
			
			</td></tr>
  <tr>
    <td colspan="2"><div align="center">
	<img src="scl_header.jpg"/>
	
	
    </div>
      <table width="100%" border="1"  style="border-collapse:collapse">
      
      <tr>
        <td width="204%" height="30" colspan="4" class="style1"><div align="center" class="style3">INVOICE</div></td>
      </tr>
      <tr>
        <td colspan="4" class="style1"><table width="100%"  style="border-collapse:collapse">
          
          <tr valign="top">
            <td width="48%"><table width="100%"   style="border-collapse:collapse">
              <tr>
                <td><div align="left" style="padding:3px;">
                    <p>BILL TO</p>
                </div></td>
                <td><div align="left" style="padding:3px;"><?php echo $customer_name?></div></td>
              </tr>
              <tr>
                <td><div align="left" style="padding:3px;"></div></td>
              </tr>
              <tr>
                <td><div align="left" style="padding:3px;">A/C OF : </div></td>
                <td><div align="left" style="padding:3px;"><?php echo $bgst_no?></div></td>
              </tr>
            </table></td>
            <td width="52%"><table width="100%"   style="border-collapse:collapse">
              <tr>
                <td width="28%"><div align="left" style="padding:3px;">INV NO  : </div></td>
                <td width="36%"><div align="left" style="padding:3px;"><?php echo $_REQUEST['trans_inv_no']; ?> </div></td>
              </tr>
              <tr>
                <td><div align="left" style="padding:3px;">INV DATE : </div></td>
                <td><div align="left" style="padding:3px;"><?php echo $_REQUEST['trans_inv_date']?></div></td>
              </tr>
              <tr>
                <td><div align="left" style="padding:3px;">REF NO  : </div></td>
                <td><div align="left" style="padding:3px;"><?php echo $_REQUEST['Job_No'];?></div></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
      

      <tr>
        <td colspan="4" class="style1"><table width="100%" border="1" bordercolor="#D1D1D1" style="border-collapse:collapse">
          <tr>
            <td width="4%"><div align="left" class="style4">Sr No. </div></td>
            <td width="43%"><div align="center" class="style4">Particular</div></td>
            <td width="13%"><div align="center" class="style4">Rate Rs. </div></td>
            <td width="10%"><div align="center" class="style4">Amount</div></td>
            </tr>
          
		<?php 
	  $i =1; 
	 
													
													?> 
											

          <tr>
            <td valign="top"><div align="center" style="padding:2px;"><?php echo $i?></div></td>
            <td><table width="100%" style="border-collapse:collapse">
              <tr>
                <td height="36" valign="top"><div align="left" style="padding:2px;">
				
<?php 
$querytax = "select * from  transporter_details_expenses where trans_inv_no='".$_REQUEST['trans_inv_no']."' and inv_no = '".$_REQUEST['inv_no']."' and customer_id='".$_REQUEST['customer_id']."'";
//echo $querytax;
		                 $resulttax = mysql_query($querytax,$conn);	
						  while($row=mysql_fetch_array($resulttax))
	                                              	{
													
													$against_job_service_no = $row['against_job_service_no'];
													}
	$query21 = "select * from job_services where job_service_no ='$against_job_service_no'";
$result21 = mysql_query($query21,$conn);
while($row=mysql_fetch_array($result21))
{
echo $services_name = $row['services_name'];
}?>	</div>	</td>
              </tr>
			  <?php
			  
$querytax = "select * from  transporter_details_expenses where trans_inv_no='".$_REQUEST['trans_inv_no']."' and inv_no = '".$_REQUEST['inv_no']."' and customer_id='".$_REQUEST['customer_id']."'";
		//echo $querytax;
		                 $resulttax = mysql_query($querytax,$conn);	
						  while($row=mysql_fetch_array($resulttax))
	                                              	{
													$particular= $row['particular'];
													?>
              <tr>
                <td><div align="left" style="padding:2px; line-height:160%;"><?php echo $particular?></div>				</td>
              </tr>          <?php $i++;} ?>

            </table>
			  <?php if($_REQUEST['space_01'] == 1) {?>
              <div style="height:200px;"></div>
			  <?php }?>
			  <?php if($_REQUEST['space_01'] == 2) {?>
              <div style="height:300px;"></div>
			  <?php }?>
			  <?php if($_REQUEST['space_01'] == 3) {?>
              <div style="height:400px;"></div>
			  <?php }?>
			  <?php if($_REQUEST['space_01'] == 4) {?>
              <div style="height:450px;"></div>
			  <?php }?>			  </td>
            <td valign="top"><table width="100%" style="border-collapse:collapse">
              <?php
			  
$querytax = "select * from  transporter_details_expenses where trans_inv_no='".$_REQUEST['trans_inv_no']."' and inv_no = '".$_REQUEST['inv_no']."' and customer_id='".$_REQUEST['customer_id']."'";
		//echo $querytax;
		                 $resulttax = mysql_query($querytax,$conn);	
						  while($row=mysql_fetch_array($resulttax))
	                                              	{
													
													$vehicle_no = $row['vehicle_no']; ?>
              <tr>
                <td height="36" valign="top"><div align="left" style="padding:2px;"> </div></td>
              </tr>
              <tr>
                <td valign="top"><div align="right" style="padding:2px; line-height:160%;"><?php echo $vehicle_no; ?></div></td>
              </tr>
              <?php } ?>
            </table></td>
            <td valign="top"><table width="100%" style="border-collapse:collapse">
             
              <?php
			  
$querytax = "select * from  transporter_details_expenses where trans_inv_no='".$_REQUEST['trans_inv_no']."' and inv_no = '".$_REQUEST['inv_no']."' and customer_id='".$_REQUEST['customer_id']."'";
		//echo $querytax;
		                 $resulttax = mysql_query($querytax,$conn);	
						  while($row=mysql_fetch_array($resulttax))
	                                              	{
													$chargable_amount = $row['chargable_amount'];
													$vehicle_no = $row['vehicle_no'];
													
													$totalamt+=$chargable_amount;?>
													 <tr>
                <td height="36" valign="top"><div align="left" style="padding:2px;">
                   </div></td>
              </tr>
              <tr>
                <td valign="top"><div align="right" style="padding:2px; line-height:160%;"><?php echo number_format($chargable_amount,2)?></div></td>
              </tr>
              <?php } ?>
            </table></td>
          </tr>
			
           <tr>
            <td colspan="2"><div align="left" class="style6" style="padding:2px;"> Amount Chargeable (in words) Rupeess:
		      <? 
   $no = round($totalamt);
      $point = round($totalamt - $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;
     $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</div></td>
            <td><div align="right" style="padding:5px;">Total Amount </div></td>
            <td><div align="right" style="padding:5px;"><?php echo $totalamt?></td>
          </tr>
        </table></td>
      </tr>
	  
	  
     
	
      <tr>
        <td colspan="4" class="style1"><table width="100%" style="border-collapse:collapse">
          <tr>
            <td width="70%" valign="top"><p>&nbsp;</p>              </td>
            <td width="30%" valign="top"><div align="right" style="padding:2px; text-transform:uppercase">For <?php echo $full_name?> <BR /><BR /><BR /></div><div align="right" style="padding:2px;"> Authorised Signatory </div></td>
          </tr>
        </table></td>
      </tr>
    </table></td></tr>
</table>

<?php 

$query2fa="update job_services set taxable ='$totalamt' where inv_no = '".$_REQUEST['inv_no']."' and Job_No='".$_REQUEST['Job_No']."' and services_name='$services_name'";
$r2fa=mysql_query($query2fa,$conn);


$query4fa="update  tax_transtax set gross_amt ='$totalamt' where trans_inv_no = '".$_REQUEST['trans_inv_no']."' and Job_No='".$_REQUEST['Job_No']."'";
$r4fa=mysql_query($query4fa,$conn);


$query1fa="update import_inv_make set trans_inv_noEdit ='DONE' where trans_inv_no = '".$_REQUEST['trans_inv_no']."' AND customer_id = '".$_REQUEST['customer_id']."'";
$r1fa=mysql_query($query1fa,$conn);


//$query3fa="update export_job_main_01 set trans_inv_noEdit ='DONE' where trans_inv_no = '".$_REQUEST['trans_inv_no']."' AND customer_id = '".$_REQUEST['customer_id']."'";
//$r3fa=mysql_query($query3fa,$conn);

//echo $query2fa;
?>
<div align="center" style="font-size:12px;">This is a Computer generated invoice, Signature is not required.</div>
</body>
</html>
