<?php include 'connection.php';

$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))
{
$department_name = $row['department_name'];
$designation = $row['designation'];
$active_login = $row['active_login'];
$multi_login = $row['multi_login'];

}
?>



<? function cha_billgst($inv_no,$customer_id,$statecode) { 




error_reporting(0);
 global $conn;
global $grandtotal;
global $taxamt;
global $sumnon_taxable;
global $sumtaxable;
global $sumpaid_by_party;

global $sumCGST;
global $sumSGST;
global $sumIGST;




$grandtotal='0';
$total_amt='0';
$sumCGST ='0';
$sumSGST='0';
$sumIGST='0';
$sumnon_taxable='';
$sumtaxable='';
$sumpaid_by_party='';
$querytax = "select * from  job_services where inv_no='$inv_no' and customer_id= '$customer_id'and cha_bill='YES'";
$resulttax = mysql_query($querytax,$conn);	
while($row=mysql_fetch_array($resulttax))
{
$cha_amt = $row['cha_amt'];

$paid_by_party = $row['paid_by_party'];
$non_taxable = $row['non_taxable'];
$taxable = $row['taxable'];
$CGST = $row['CGST_rate'];
$SGST = $row['SGST_rate'];
$IGST = $row['IGST_rate'];
if($CGST=='') {
$CGST=$IGST/2;									
}
if($SGST=='') {
$SGST=$IGST/2;
}
$HSN_code = $row['HSN_code'];
$sumnon_taxable +=$non_taxable;
$sumtaxable += $taxable;
$sumpaid_by_party += $cha_amt;
$total_amt = $sumpaid_by_party;
?>
<?php if($statecode =='27' and $taxable!='' and $taxable!=' ') { $taxcgstval = $cha_amt*$CGST/100; $sumCGST+=$taxcgstval;}?>
<?php if($statecode =='27' and $taxable!='' and $taxable!=' ') { $taxsgstval = $cha_amt*$SGST/100; $sumSGST+=$taxsgstval; }?>
<?php if($statecode !='27' and $taxable!='' and $taxable!=' ') { $taxigstval = $cha_amt*$IGST/100; $sumIGST+=$taxigstval;}?>

<?php }?>


<?php 
			  $taxamt = $sumCGST+$sumSGST+$sumIGST;

$grandtotal = $total_amt+$sumCGST+$sumSGST+$sumIGST;?>
<?   $grandtotal;?>

<?   


}?>

<? 

function cha_our_billgst($inv_no,$customer_id,$statecode) { 




error_reporting(0);
 global $conn;
global $grandtotal;
global $taxamt;
global $sumnon_taxable;
global $sumtaxable;
global $sumpaid_by_party;

global $sumCGST;
global $sumSGST;
global $sumIGST;




$grandtotal='0';
$total_amt='0';
$sumCGST ='0';
$sumSGST='0';
$sumIGST='0';
$sumnon_taxable='';
$sumtaxable='';
$sumpaid_by_party='';
$querytax = "select * from  job_services where inv_no='$inv_no' and customer_id= '$customer_id'";
$resulttax = mysql_query($querytax,$conn);	
while($row=mysql_fetch_array($resulttax))
{
$cha_amt = $row['cha_amt'];

$paid_by_party = $row['paid_by_party'];
$non_taxable = $row['non_taxable'];
$taxable = $row['taxable'];
$CGST = $row['CGST_rate'];
$SGST = $row['SGST_rate'];
$IGST = $row['IGST_rate'];
if($CGST=='') {
$CGST=$IGST/2;									
}
if($SGST=='') {
$SGST=$IGST/2;
}
$HSN_code = $row['HSN_code'];
$sumnon_taxable +=$non_taxable;
$sumtaxable += $taxable;
$sumpaid_by_party += $paid_by_party;
$total_amt = $sumnon_taxable+$sumtaxable+$sumpaid_by_party;
?>
<?php if($statecode =='27' and $taxable!='' and $taxable!=' ') { $taxcgstval = $taxable*$CGST/100; $sumCGST+=$taxcgstval;}?>
<?php if($statecode =='27' and $taxable!='' and $taxable!=' ') { $taxsgstval = $taxable*$SGST/100; $sumSGST+=$taxsgstval; }?>
<?php if($statecode !='27' and $taxable!='' and $taxable!=' ') { $taxigstval = $taxable*$IGST/100; $sumIGST+=$taxigstval;}?>

<?php }?>


<?php 
			  $taxamt = $sumCGST+$sumSGST+$sumIGST;

$grandtotal = $total_amt+$sumCGST+$sumSGST+$sumIGST;?>
<?   $grandtotal;?>

<?   


}?>







<? function bill_calculation_gst($inv_no,$customer_id) { 




error_reporting(0);
 global $conn;
global $gross_amt;
global $total_gst_amt;
global $sumnon_taxable;
global $sumtaxable;
global $sumpaid_by_party;

global $sumCGST;
global $sumSGST;
global $sumIGST;

$query2 = "select * from  tax_servicetax where inv_no='$inv_no' and customer_id= '$customer_id'";
//echo $query2;
$result2 = mysql_query($query2,$conn);	
while($row=mysql_fetch_array($result2))
{
$state_code = $row['state_code'];
}
?>
<?php												
$query2a = "select * from customer_master where customer_id = '$customer_id' ";
//echo $query2a;
$result2a = mysql_query($query2a,$conn);	
while($row = mysql_fetch_array($result2a))
{
$bstate_code = $row['bstate_code'];
}
?>
<? if($state_code!='') {
$bstate_code=$state_code;}
?>


<?php
$grandtotal='0';
$total_amt='0';
$sumCGST ='0';
$sumSGST='0';
$sumIGST='0';
$sumnon_taxable='';
$sumtaxable='';
$sumpaid_by_party='';
$querytax = "select * from  job_services where inv_no='$inv_no' and customer_id= '$customer_id'";
$resulttax = mysql_query($querytax,$conn);	
while($row=mysql_fetch_array($resulttax))
{
$paid_by_party = $row['paid_by_party'];
$non_taxable = $row['non_taxable'];
$taxable = $row['taxable'];
$CGST = $row['CGST_rate'];
$SGST = $row['SGST_rate'];
$IGST = $row['IGST_rate'];
$HSN_code = $row['HSN_code'];
$sumnon_taxable +=$non_taxable;
$sumtaxable += $taxable;
$sumpaid_by_party += $paid_by_party;

?>
<?php if($bstate_code =='27' and $taxable!='' and $taxable!=' ') { $taxcgstval = $taxable*$CGST/100; $sumCGST+=$taxcgstval;}?>
<?php if($bstate_code =='27' and $taxable!='' and $taxable!=' ') { $taxsgstval = $taxable*$SGST/100; $sumSGST+=$taxsgstval; }?>
<?php if($bstate_code !='27' and $taxable!='' and $taxable!=' ') { $taxigstval = $taxable*$IGST/100; $sumIGST+=$taxigstval;}?>

<?php }?>
<?php 


 $total_amt = $sumnon_taxable+$sumtaxable+$sumpaid_by_party;

$gross_amt = $total_amt+$sumCGST+$sumSGST+$sumIGST;
$total_gst_amt= $sumCGST+$sumSGST+$sumIGST?>
<?   


}?>





<? function directbill_calculation_gst($dir_inv_id,$customer_id) { 




error_reporting(0);
 global $conn;
global $gross_amt;
global $total_gst_amt;
global $sumnon_taxable;
global $sumtaxable;
global $sumpaid_by_party;

global $sumCGST;
global $sumSGST;
global $sumIGST;

$query2 = "select * from  direct_invoice_ai where dir_inv_id='$dir_inv_id' and customer_id= '$customer_id'";
//echo $query2;
$result2 = mysql_query($query2,$conn);	
while($row=mysql_fetch_array($result2))
{
$bstate_code = $row['state_code'];
$dir_inv_id=$row['dir_inv_id'];
}?>



<?php
$grandtotal='0';
$total_amt='0';
$sumCGST ='0';
$sumSGST='0';
$sumIGST='0';
$sumnon_taxable='';
$sumtaxable='';
$sumpaid_by_party='';
$querytax = "select * from  direct_job_services_ai where dir_inv_id='$dir_inv_id' and dir_inv_id= '$dir_inv_id'";
$resulttax = mysql_query($querytax,$conn);	
while($row=mysql_fetch_array($resulttax))
{
$paid_by_party = $row['paid_by_party'];
$non_taxable = $row['non_taxable'];
$taxable = $row['taxable'];
$CGST = $row['CGST_rate'];
$SGST = $row['SGST_rate'];
$IGST = $row['IGST_rate'];
$HSN_code = $row['HSN_code'];
$sumnon_taxable +=$non_taxable;
$sumtaxable += $taxable;
$sumpaid_by_party += $paid_by_party;

?>
<?php if($bstate_code =='27' and $taxable!='' and $taxable!=' ') { $taxcgstval = $taxable*$CGST/100; $sumCGST+=$taxcgstval;}?>
<?php if($bstate_code =='27' and $taxable!='' and $taxable!=' ') { $taxsgstval = $taxable*$SGST/100; $sumSGST+=$taxsgstval; }?>
<?php if($bstate_code !='27' and $taxable!='' and $taxable!=' ') { $taxigstval = $taxable*$IGST/100; $sumIGST+=$taxigstval;}?>

<?php }?>
<?php 


 $total_amt = $sumnon_taxable+$sumtaxable+$sumpaid_by_party;

$gross_amt = $total_amt+$sumCGST+$sumSGST+$sumIGST;
$total_gst_amt= $sumCGST+$sumSGST+$sumIGST;
}?>



<? function directbill_calculation_gst1($dir_inv_id,$customer_id) { 




error_reporting(0);
 global $conn;
global $gross_amt;
global $total_gst_amt;
global $sumnon_taxable;
global $sumtaxable;
global $sumpaid_by_party;

global $sumCGST;
global $sumSGST;
global $sumIGST;

$query2 = "select * from  direct_invoice_ai where dir_inv_id='$dir_inv_id' and customer_id= '$customer_id'";
//echo $query2;
$result2 = mysql_query($query2,$conn);	
while($row=mysql_fetch_array($result2))
{
$bstate_code = $row['state_code'];
$dir_inv_id=$row['dir_inv_id'];
}?>



<?php
$grandtotal='0';
$total_amt='0';
$sumCGST09 ='0';
$sumSGST09='0';
$sumIGST09='0';
$sumtnote_amt='';
$querytax1 = "select * from  direct_job_services_ai where dir_inv_id='$dir_inv_id' and dir_inv_id= '$dir_inv_id'";
$resulttax1 = mysql_query($querytax1,$conn);	
while($row=mysql_fetch_array($resulttax1))
{
$paid_by_party = $row['paid_by_party'];
$non_taxable = $row['non_taxable'];
$note_amt = $row['note_amt'];
$CGST = $row['CGST_rate'];
$SGST = $row['SGST_rate'];
$IGST = $row['IGST_rate'];
$HSN_code = $row['HSN_code'];
$sumnon_taxable +=$non_taxable;
$sumtnote_amt += $note_amt;
$sumpaid_by_party += $paid_by_party;

?>
<?php if($bstate_code =='27' and $note_amt!='' and $note_amt!=' ') { $taxcgstval09 = $note_amt*$CGST/100; $sumCGST09+=$taxcgstval09;}?>
<?php if($bstate_code =='27' and $note_amt!='' and $note_amt!=' ') { $taxsgstval09 = $note_amt*$SGST/100; $sumSGST09+=$taxsgstval09; }?>
<?php if($bstate_code !='27' and $note_amt!='' and $note_amt!=' ') { $taxigstval09 = $note_amt*$IGST/100; $sumIGST09+=$taxigstval09;}?>

<?php }?>
<?php 


 $total_amt09  = $sumtnote_amt;

$gross_amt09 = $total_amt09+$sumCGST09+$sumSGST09+$sumIGST09;
$total_gst_amt09 = $sumCGST09+$sumSGST09+$sumIGST09;
}?>


<? function bill_calculation($inv_no,$customer_id,$job_no) { 




error_reporting(0);
 global $conn;
global $sumtaxable;
global $grandtotal;

$query2 = "select * from  tax_servicetax where inv_no='$inv_no' and job_no= '$job_no'";
//echo $query2;
$result2 = mysql_query($query2,$conn);	
while($row=mysql_fetch_array($result2))
{
$state_code = $row['state_code'];
}
?>
<?php												
$query2a = "select * from customer_master where customer_id = '$customer_id' ";
//echo $query2a;
$result2a = mysql_query($query2a,$conn);	
while($row = mysql_fetch_array($result2a))
{
$bstate_code = $row['bstate_code'];
}
?>
<? if($state_code!='') {
$bstate_code=$state_code;}
?>


<?php
$grandtotal='0';
$total_amt='0';
$sumCGST ='0';
$sumSGST='0';
$sumIGST='0';
$sumnon_taxable='';
$sumtaxable='';
$sumpaid_by_party='';
$querytax = "select * from  job_services where inv_no='$inv_no' and job_no= '$job_no'";
$resulttax = mysql_query($querytax,$conn);	
while($row=mysql_fetch_array($resulttax))
{
$paid_by_party = $row['paid_by_party'];
$non_taxable = $row['non_taxable'];
$taxable = $row['taxable'];
$CGST = $row['CGST_rate'];
$SGST = $row['SGST_rate'];
$IGST = $row['IGST_rate'];
$HSN_code = $row['HSN_code'];
$sumnon_taxable +=$non_taxable;
$sumtaxable += $taxable;
$sumpaid_by_party += $paid_by_party;

?>
<?php if($bstate_code =='27' and $taxable!='' and $taxable!=' ') { $taxcgstval = $taxable*$CGST/100; $sumCGST+=$taxcgstval;}?>
<?php if($bstate_code =='27' and $taxable!='' and $taxable!=' ') { $taxsgstval = $taxable*$SGST/100; $sumSGST+=$taxsgstval; }?>
<?php if($bstate_code !='27' and $taxable!='' and $taxable!=' ') { $taxigstval = $taxable*$IGST/100; $sumIGST+=$taxigstval;}?>

<?php }?>
<?php 
 $total_amt = $sumnon_taxable+$sumtaxable+$sumpaid_by_party;

$grandtotal = $total_amt+$sumCGST+$sumSGST+$sumIGST;?>
<? echo  $grandtotal;


}?>

<? function back_toindex($department_name,$designation) { ?>
<? error_reporting(0);
 global $conn;
?>

<? $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))
{
$department_name = $row['department_name'];
$designation = $row['designation'];
$active_login = $row['active_login'];
$multi_login = $row['multi_login'];

}
?>
<?php if($department_name =='Billing') { ?> <a href="index.php" class="btn btn-box-tool">Back to Dashbaord </a><? } ?>
 
<?php if($department_name =='Sales' and $active_login !='Sales Back Office'and ($designation =='Sales Person' OR $designation =='Sales Head' OR $designation =='Field Application Engineer')) {  ?> <a href="index_sales.php" class="btn btn-box-tool">Back to Dashbaord </a><? } ?>
 <?php if($department_name =='Sales' and $active_login !='Sales Back Office'and $designation =='Sales Coordinator') { ?> <a href="index_sales_co.php" class="btn btn-box-tool">Back to Dashbaord </a><? } ?>

<?php if($department_name =='Admin') { ?> <a href="index.php" class="btn btn-box-tool">Back to Dashbaord </a><? } ?>
 
<?php if($department_name =='Procurement') { ?> <a href="index_procurement.php" class="btn btn-box-tool">Back to Dashbaord </a><? } ?>

<?php if($department_name =='Logistic') { ?> <a href="index_dept.php" class="btn btn-box-tool">Back to Dashbaord </a><? } ?>
<?php if($department_name =='Salary') { ?> <a href="view_all_employee.php" class="btn btn-box-tool">Back to Dashbaord </a><? } ?>


<?php if($department_name =='AR Team') { ?> <a href="index_AR.php" class="btn btn-box-tool">Back to Dashbaord </a><? } ?>
<?php if($department_name =='Sales'and $active_login =='Sales Back Office') { ?> <a href="index_sales_office.php" class="btn btn-box-tool">Back to Dashbaord </a><? } ?>
<?php if($department_name =='HR and admin') { ?> <a href="index_hr_and_admin.php" class="btn btn-box-tool">Back to Dashbaord </a><? } ?>

	<? } ?>	


<? function depat_check($department_name,$designation) {?>
<? error_reporting(0);
 global $conn;
?><? $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))
{
$department_name = $row['department_name'];
$designation = $row['designation'];
$active_login = $row['active_login'];
$multi_login = $row['multi_login'];

}
?>

 
<?php if($department_name =='Import') {  include 'header.php'; } ?>
 
<?php if($department_name =='Accounts') { include 'header.php'; } ?>

<?php if($department_name =='Export') { include 'header.php'; } ?>

<?php if($department_name =='Billing') { include 'header.php'; } ?>

<?php if($department_name =='Admin') { include 'header.php'; } ?>
<?php if($department_name =='Logistics') { include 'header.php'; } ?>


<?php if($department_name =='Salary') { include 'header1.php'; } ?>



<? } ?>



<? function depat_check1($department_name,$designation) {?>
<? error_reporting(0);
 global $conn;
?><? $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))
{
$department_name = $row['department_name'];
$designation = $row['designation'];
$active_login = $row['active_login'];
$multi_login = $row['multi_login'];

}
?>

 
<?php if($department_name =='Import') {  include 'header.php'; } ?>
 
<?php if($department_name =='Accounts') { include 'link_header.php'; } ?>

<?php if($department_name =='Export') { include 'header.php'; } ?>

<?php if($department_name =='Billing') { include 'link_header.php'; } ?>

<?php if($department_name =='Admin') { include 'link_header.php'; } ?>
<?php if($department_name =='Logistics') { include 'header.php'; } ?>


<?php if($department_name =='Salary') { include 'header1.php'; } ?>



<? } ?>




				<? function country() {
				?>
				<option value=""></option>
													<option value="United States">United States</option>
													<option value="Canada">Canada</option>
													<option value="Afghanistan">Afghanistan</option>
													<option value="Albania">Albania</option>
													<option value="Algeria">Algeria</option>
													<option value="Andorra">Andorra</option>
													<option value="Angola">Angola</option>
													<option value="Argentina">Argentina</option>
													<option value="Armenia">Armenia</option>
													<option value="Australia">Australia</option>
													<option value="Austria">Austria</option>
													<option value="Azerbaijan">Azerbaijan</option>
													<option value="Bahamas">Bahamas</option>
													<option value="Bahrain">Bahrain</option>
													<option value="Bangladesh">Bangladesh</option>
													<option value="Barbados">Barbados</option>
													<option value="Belarus">Belarus</option>
													<option value="Belgium">Belgium</option>
													<option value="Belize">Belize</option>
													<option value="Benin">Benin</option>
													<option value="Bhutan">Bhutan</option>
													<option value="Bolivia">Bolivia</option>
													<option value="Botswana">Botswana</option>
													<option value="Brazil">Brazil</option>
													<option value="Brunei">Brunei</option>
													<option value="Bulgaria">Bulgaria</option>
													<option value="Burundi">Burundi</option>
													<option value="Cambodia">Cambodia</option>
													<option value="Cameroon">Cameroon</option>
													<option value="Canada">Canada</option>
													<option value="Chad">Chad</option>
													<option value="Chile">Chile</option>
													<option value="China">China</option>
													<option value="Colombia">Colombia</option>
													<option value="Comoros">Comoros</option>
													<option value="Costa Rica">Costa Rica</option>
													<option value="Croatia">Croatia</option>
													<option value="Cuba">Cuba</option>
													<option value="Cyprus">Cyprus</option>
													<option value="Denmark">Denmark</option>
													<option value="Djibouti">Djibouti</option>
													<option value="Dominica">Dominica</option>
													<option value="Ecuador">Ecuador</option>
													<option value="Egypt">Egypt</option>
													<option value="El Salvador">El Salvador</option>
													<option value="Eritrea">Eritrea</option>
													<option value="Estonia">Estonia</option>
													<option value="Ethiopia">Ethiopia</option>
													<option value="Fiji">Fiji</option>
													<option value="Finland">Finland</option>
													<option value="France">France</option>
													<option value="Gabon">Gabon</option>
													<option value="Gambia">Gambia</option>
													<option value="Georgia">Georgia</option>
													<option value="Germany">Germany</option>
													
													<option value="Ghana">Ghana</option>
													
													<option value="Greece">Greece</option>
													
													<option value="Grenada">Grenada</option>
													
													<option value="Guatemala">Guatemala</option>
													
													<option value="Guinea">Guinea</option>
													
													<option value="Guinea-Bissau">Guinea-Bissau</option>
													
													<option value="Guyana">Guyana</option>
													
													<option value="Haiti">Haiti</option>
													
													<option value="Honduras">Honduras</option>
													
													<option value="Hungary">Hungary</option>
													
													<option value="Iceland">Iceland</option>
													
													<option value="India" selected="selected">India</option>
													
													<option value="Indonesia">Indonesia</option>
													
													<option value="Iran">Iran</option>
													
													<option value="Iraq">Iraq</option>
													
													<option value="Ireland">Ireland</option>
													
													<option value="Israel">Israel</option>
													
													<option value="Italy">Italy</option>
													
													<option value="Jamaica">Jamaica</option>
													
													<option value="Japan">Japan</option>
													
													<option value="Jordan">Jordan</option>
													
													<option value="Kazakhstan">Kazakhstan</option>
													
													<option value="Kenya">Kenya</option>
													
													<option value="Kiribati">Kiribati</option>
													
													<option value="Korea">Korea</option>
													
													<option value="Kuwait">Kuwait</option>
													
													<option value="Kyrgyzstan">Kyrgyzstan</option>
													
													<option value="Laos">Laos</option>
													
													<option value="Latvia">Latvia</option>
													
													<option value="Lebanon">Lebanon</option>
													
													<option value="Lesotho">Lesotho</option>
													
													<option value="Liberia">Liberia</option>
													
													<option value="Libya">Libya</option>
													
													<option value="Liechtenstein">Liechtenstein</option>
													
													<option value="Lithuania">Lithuania</option>
													
													<option value="Luxembourg">Luxembourg</option>
													
													<option value="Madagascar">Madagascar</option>
													
													<option value="Malawi">Malawi</option>
													
													<option value="Malaysia">Malaysia</option>
													
													<option value="Maldives">Maldives</option>
													
													<option value="Mali">Mali</option>
													
													<option value="Malta">Malta</option>
													
													<option value="Mauritania">Mauritania</option>
													
													<option value="Mauritius">Mauritius</option>
													
													<option value="Mexico">Mexico</option>
													
													<option value="Moldova">Moldova</option>
													
													<option value="Monaco">Monaco</option>
													
													<option value="Mongolia">Mongolia</option>
													
													<option value="Morocco">Morocco</option>
													
													<option value="Mozambique">Mozambique</option>
													
													<option value="Myanmar">Myanmar</option>
													
													<option value="Namibia">Namibia</option>
													
													<option value="Nauru">Nauru</option>
													
													<option value="Nepal">Nepal</option>
													
													<option value="New Zealand">New Zealand</option>
													
													<option value="Nicaragua">Nicaragua</option>
													
													<option value="Niger">Niger</option>
													
													<option value="Nigeria">Nigeria</option>
													
													<option value="Norway">Norway</option>
													
													<option value="Oman">Oman</option>
													
													<option value="Pakistan">Pakistan</option>
													
													<option value="Palau">Palau</option>
													
													<option value="Palestine">Palestine</option>
													
													<option value="Panama">Panama</option>
													
													<option value="Papua New Guinea">Papua New Guinea</option>
													
													<option value="Paraguay">Paraguay</option>
													
													<option value="Peru">Peru</option>
													
													<option value="Philippines">Philippines</option>
													
													<option value="Poland">Poland</option>
													
													<option value="Portugal">Portugal</option>
													
													<option value="Qatar">Qatar</option>
													
													<option value="Romania">Romania</option>
													
													<option value="Russia">Russia</option>
													
													<option value="Rwanda">Rwanda</option>
													
													<option value="Saint Lucia">Saint Lucia</option>
													
													<option value="Samoa">Samoa</option>
													
													<option value="Saudi Arabia">Saudi Arabia</option>
													
													<option value="Senegal">Senegal</option>
													
													<option value="Seychelles">Seychelles</option>
													
													<option value="Sierra Leone">Sierra Leone</option>
													
													<option value="Singapore">Singapore</option>
													
													<option value="Slovakia">Slovakia</option>
													
													<option value="Slovenia">Slovenia</option>
													
													<option value="Somalia">Somalia</option>
													
													<option value="South Africa">South Africa</option>
													
													<option value="Spain">Spain</option>
													
													<option value="Sri Lanka">Sri Lanka</option>
													
													<option value="Sudan">Sudan</option>
													
													<option value="Suriname">Suriname</option>
													
													<option value="Swaziland">Swaziland</option>
													
													<option value="Sweden">Sweden</option>
													
													<option value="Switzerland">Switzerland</option>
													
													<option value="Syria">Syria</option>
													
													<option value="Taiwan">Taiwan</option>
													
													<option value="Tajikistan">Tajikistan</option>
													
													<option value="Tanzania">Tanzania</option>
													
													<option value="Thailand">Thailand</option>
													
													<option value="Netherlands">Netherlands</option>
													
													<option value="Togo">Togo</option>
													
													<option value="Tonga">Tonga</option>
													
													<option value="Trinidad and Tobago">Trinidad and Tobago</option>
													
													<option value="Tunisia">Tunisia</option>
													
													<option value="Turkey">Turkey</option>
													
													<option value="Turkmenistan">Turkmenistan</option>
													
													<option value="Tuvalu">Tuvalu</option>
													
													<option value="Uganda">Uganda</option>
													
													<option value="Ukraine">Ukraine</option>
													
													<option value="UAE">UAE</option>
													
													<option value="UK">UK</option>
													
													<option value="Uruguay">Uruguay</option>
													
													<option value="Uzbekistan">Uzbekistan</option>
													
													<option value="Venezuela">Venezuela</option>
													
													<option value="Vietnam">Vietnam</option>
													
													<option value="Western Sahara">Western Sahara</option>
													
													<option value="Yemen">Yemen</option>
													
													<option value="Yugoslavia Montenegro">Yugoslavia Montenegro</option>
													
													<option value="Zambia">Zambia</option>
													
													<option value="Zimbabwe">Zimbabwe</option>
													
													<option value="Hong Kong">Hong Kong</option>
													
													<option value="CZECH REPUBLIC">CZECH REPUBLIC</option>
													
													<? } ?>
													
													
													
<? function state() {
				?>
				
				<option value="Andaman &amp; Nicobar (UT)">Andaman &amp; Nicobar (UT)</option>
															
															<option value="Andhra Pradesh">Andhra Pradesh</option>
															
															<option value="Arunachal Pradesh">Arunachal Pradesh</option>
															
															<option value="Assam">Assam</option>
															
															<option value="Bihar">Bihar</option>
															
															<option value="Chandigarh (UT)">Chandigarh (UT)</option>
															
															<option value="Chhattisgarh">Chhattisgarh</option>
															
															<option value="Dadra and Nagar Haveli (UT)">Dadra and Nagar Haveli (UT)</option>
															
															<option value="Daman and Diu (UT)">Daman and Diu (UT)</option>
															
															<option value="Delhi (UT)">Delhi (UT)</option>
															
															<option  value="Goa">Goa</option>
															
															<option value="Gujarat">Gujarat</option>
															
															<option value="Haryana">Haryana</option>
															
															<option value="Himachal Pradesh">Himachal Pradesh</option>
															
															<option value="Jammu and Kashmir">Jammu and Kashmir</option>
															
															<option value="Jharkhand">Jharkhand</option>
															
															<option value="Karnataka">Karnataka</option>
															
															<option value="Kerala">Kerala</option>
															
															<option value="Lakshadweep (UT)">Lakshadweep (UT)</option>
															
															<option value="Madhya Pradesh">Madhya Pradesh</option>
															
															<option value="Maharashtra">Maharashtra</option>
															
															<option value="Manipur">Manipur</option>
															
															<option value="Meghalaya">Meghalaya</option>
															
															<option value="Mizoram">Mizoram</option>
															
															<option value="Nagaland">Nagaland</option>
															
															<option value="Orissa">Orissa</option>
															
															<option value="Puducherry (UT)">Puducherry (UT)</option>
															
															<option value="Punjab">Punjab</option>
															
															<option value="Rajasthan">Rajasthan</option>
															
															<option value="Sikkim">Sikkim</option>
															
															<option value="Tamil Nadu">Tamil Nadu</option>
															
															<option value="Tripura">Tripura</option>
															
															<option value="Uttar Pradesh">Uttar Pradesh</option>
															
															<option value="Uttarakhand">Uttarakhand</option>
															
															<option value="West Bengal">West Bengal</option>
															
															<option value="Other">Other</option>
															
															<option value="Telangana">Telangana</option>
															<? } ?>
															
															
<? function industry(){  ?>


<option title="None" value="None">None</option><option value="Automobile Company">Automobile Company</option>
													
													<option value="Cable/Wire/Filament Manufacturer">Cable/Wire/Filament Manufacturer</option>
													
													<option value="Cement Plant">Cement Plant</option>
													
													<option value="Chemical Industry">Chemical Industry</option>
													
													<option value="Consultant">Consultant</option>
													
													<option value="Dealer">Dealer</option>
													
													<option value="Food Products">Food Products</option>
													
													<option value="Machine Tool ">Machine Tool </option>
													
													<option value="Machinery Manufacturer">Machinery Manufacturer</option>
													
													<option value="Metal Manufacturing plant">Metal Manufacturing plant</option>
													
													<option value="Mine">Mine</option>
													
													<option value="OEM - Hopper/Silo Fabricator/builders">OEM - Hopper/Silo Fabricator/builders</option>
													
													<option value="OEM - Machine Builder">OEM - Machine Builder</option>
													
													<option value="Ordnance Factory">Ordnance Factory</option>
													
													<option value="Pharma">Pharma</option>
													
													<option value="Pharma Machinery Manufacturer">Pharma Machinery Manufacturer</option>
													
													<option value="Pipe Manufacturing plant">Pipe Manufacturing plant</option>
													
													<option value="Plastic Machinery Manufacturer">Plastic Machinery Manufacturer</option>
													
													<option value="Power Plant">Power Plant</option>
													
													<option value="Rubber products">Rubber products</option>
													
													<option value="Steel Plant">Steel Plant</option>
													
													<option value="Trader">Trader</option>
													
													<option value="Vendor">Vendor</option>
													
													
											 <? } ?>
											 
											 
<? function  enquiry(){ ?>

	<option title="None" value="None">None</option>
											<option title="Cold Call" value="Cold Call">Cold Call</option>
											<option title="Conference" value="Conference">Conference</option>
											<option title="Email" value="Email">Email</option>
											<option title="Employee" value="Employee">Employee</option>
											<option title="Email Campaign" value="Email Campaign">Email Campaign</option>
											<option title="Existing Customer" value="Existing Customer">Existing Customer</option>
											<option title="InboundCall" value="InboundCall">InboundCall</option>
											<option title="Magazine Advt" value="Magazine Advt">Magazine Advt</option>
											<option title="Recommended from within company of buyer" value="Recommended from within company of buyer">Recommended from within company of buyer</option>
											<option title="Self Generated" value="Self Generated">Self Generated</option>
											<option title="Trade Show" value="Trade Show">Trade Show</option>
											<option title="Web Site" value="Web Site">Web Site</option>
											<option title="Word Of Mouth" value="Word Of Mouth">Word Of Mouth</option>
											<option title="Other" value="Other">Other</option>
											<option title="IndiaMart" value="IndiaMart">IndiaMart</option>
											<option title="TradeIndia" value="TradeIndia">TradeIndia</option>
											<option title="Jimtrade" value="Jimtrade">Jimtrade</option>
											<option title="PBSI 2013" value="PBSI 2013">PBSI 2013</option>
											
											<? } ?>
											
									<? function companytype() { ?>		
											<option value="Partnership">Partnership</option>
									        <option value="Pvt Ltd">Pvt Ltd</option>
									        <option value="Public Ltd">Public Ltd</option>
									        <option value="LLP">LLP</option>
									        <option value="Corporation">Corporation</option>
									        <option value="Branch Office">Branch Office</option>
									        <option value="Inc">Inc</option>
									        <option value="HUF">HUF</option>
									        <option value="Govt.">Govt.</option>
									        <option value="Individual">Individual</option>
									        <option value="Sole Proprietor">Sole Proprietor</option>
									        <option value="Trust">Trust</option>
											
											<? } ?>
											<? function bill_calculation_chagst($inv_no,$customer_id) { 




error_reporting(0);
 global $conn;
global $gross_amt;
global $total_gst_amt;
global $sumnon_taxable;
global $sumtaxable;
global $sumpaid_by_party;

global $sumCGST;
global $sumSGST;
global $sumIGST;

$query2 = "select * from  tax_servicetax where inv_no='$inv_no' and customer_id= '$customer_id'";
//echo $query2;
$result2 = mysql_query($query2,$conn);	
while($row=mysql_fetch_array($result2))
{
$state_code = $row['state_code'];
}
?>
<?php												
$query2a = "select * from customer_master where customer_id = '$customer_id' ";
//echo $query2a;
$result2a = mysql_query($query2a,$conn);	
while($row = mysql_fetch_array($result2a))
{
$bstate_code = $row['bstate_code'];
}
?>
<? if($state_code!='') {
$bstate_code=$state_code;}
?>


<?php
$grandtotal='0';
$total_amt='0';
$sumCGST ='0';
$sumSGST='0';
$sumIGST='0';
$sumnon_taxable='';
$sumtaxable='';
$sumpaid_by_party='';
$querytax = "select * from  job_services where inv_no='$inv_no' and customer_id= '$customer_id' and cha_bill='YES'";
$resulttax = mysql_query($querytax,$conn);	
while($row=mysql_fetch_array($resulttax))
{
$taxable_check='';
$cha_amt = $row['cha_amt'];
$paid_by_party = $row['paid_by_party'];
$non_taxable = $row['non_taxable'];
													$taxable_check = $row['taxable'];
													if($taxable_check!='') {
													$taxable = $row['cha_amt'];

													}
													$sumnon_taxable +=$non_taxable;
													$sumtaxable += $taxable;
													$rcpt_no = $row['rcpt_no'];
													$rcpt_date = $row['rcpt_date'];
													$cha_amt = $row['cha_amt'];
													//$sumpaid_by_party += $cha_amt;
													$services_name = $row['services_name'];
													$job_service_no = $row['job_service_no'];
													$CGST = $row['CGST_rate_cha'];
													$SGST = $row['SGST_rate_cha'];
													$IGST = $row['IGST_rate_cha'];
													
													if($CGST=='') {
													$CGST=$IGST/2;
													
													}
													if($SGST=='') {
													$SGST=$IGST/2;
													
													}$HSN_code = $row['HSN_code_cha'];
												//	$total_amt = $sumpaid_by_party;
?>
<?php if($bstate_code =='27' and $taxable!='' and $taxable!=' ') { $taxcgstval = $taxable*$CGST/100; $sumCGST+=$taxcgstval;}?>
<?php if($bstate_code =='27' and $taxable!='' and $taxable!=' ') { $taxsgstval = $taxable*$SGST/100; $sumSGST+=$taxsgstval; }?>
<?php if($bstate_code !='27' and $taxable!='' and $taxable!=' ') { $taxigstval = $taxable*$IGST/100; $sumIGST+=$taxigstval;}?>

<?php }?>
<?php 


 $total_amt = $sumnon_taxable+$sumtaxable+$sumpaid_by_party;

$gross_amt = $total_amt+$sumCGST+$sumSGST+$sumIGST;
$total_gst_amt= $sumCGST+$sumSGST+$sumIGST?>
<?   


}?>

