<?php
include 'connection.php';

date_default_timezone_set('Asia/Calcutta');
$today = date("Y-m-d");
$time = date("h:i A"); 
$currentyear = date("Y");
$query2job = "select * from check_month";
$resultjob = mysql_query($query2job,$conn);
while($rowmonth=mysql_fetch_array($resultjob))
{
$check_month = $rowmonth['check_month'];
}

?>
<? 										   
													   							  
$month1=date("m");
if($month1>$check_month)
  {
  $currentyear = date("Y");
 $curr_full_year=date("Y");
$curr_short_year=date("y");
$future=$curr_short_year+1;
} else {
$currentyear1 = date("Y");
$currentyear = $currentyear1-1;
$curr_full_year1=date("Y");
 $curr_full_year=$curr_full_year1-1;
 $curr_short_year1=date("y");

$curr_short_year=$curr_short_year1-1;
$future=$curr_short_year+1;
}
?>


<?   $curr_fy=$currentyear .'-'. $future;?>

<?php
function randomPassword() {
    $alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    $pass = array(); //remember to declare $pass as an array
    $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
    for ($i = 0; $i < 5; $i++) {
        $n = rand(0, $alphaLength);
        $pass[] = $alphabet[$n];
    }
    return implode($pass); //turn the array into a string
}
$unique_id = randomPassword();
?>

<? 
$queryac = "select * from  tax_transtax where trans_inv_no='".$_REQUEST['trans_inv_no']."' and customer_id='".$_REQUEST['customer_id']."'";
$resultac = mysql_query($queryac,$conn);	
while($row = mysql_fetch_array($resultac))
{
$an_ac_of = $row['an_ac_of'];
$challan_id = $row['challan_id'];
$main_id = $row['main_id'];
$bstate_code=$row['bstate_code'];
$gst_inv_type=$row['gst_inv_type'];
$advance=$row['advance'];


}$query2c = "select * from main_job_details where main_id='$main_id'";
		                 				$result2c = mysql_query($query2c,$conn);	
										while($row = mysql_fetch_array($result2c)){
													 $main_job_no = $row['main_job_no'];
													 $main_id = $row['main_id'];
													 $ref_no=$row['ref_no'];
													 $account_of=$row['account_of'];
												}
												
$trans_inv_no = $_REQUEST['trans_inv_no']; 
$account_of = $_REQUEST['our_company_name'];
$inv_no = $_POST['inv_no'];
$inv_date = $_POST['inv_date'];
$trans_inv_date = $_POST['trans_inv_date'];
$customer_id = $_REQUEST['customer_id'];
$an_ac_of = $_POST['an_ac_of'];


$query2tm = "select * from 	transporter_details_expenses where trans_inv_no = '".$_REQUEST['trans_inv_no']."' and customer_id='".$_REQUEST['customer_id']."'";
							$result2tm = mysql_query($query2tm,$conn);	
while($row = mysql_fetch_array($result2tm))
{
$detail_id = $row['detail_id'];
$particular= $_POST['particular'.$detail_id];
$vehicle_no = $_POST['vehicle_no'.$detail_id];
$chargable_amount = $_POST['chargable_amount'.$detail_id];
$totalcharge+=$chargable_amount;

$query1fatt="update transporter_details_expenses set particular ='$particular',vehicle_no ='$vehicle_no',chargable_amount ='$chargable_amount' where detail_id='$detail_id'";
//echo $query1fatt;
$r1fatt=mysql_query($query1fatt,$conn);




}
$max_contact2 = $_POST['cntcount2'];
if($max_contact2!=''){
for ($z = 1; $z <= $max_contact2; $z++) {	 
$particular= mysql_real_escape_string($_POST['particular_a'.$z]);
$vehicle_no = $_POST['vehicle_no_a'.$z];
$chargable_amount = $_POST['chargable_amount_a'.$z];
$totalcharge+=$chargable_amount;


$query = "insert transporter_details_expenses(customer_id,trans_inv_no,trans_inv_date,inv_no,particular,vehicle_no,chargable_amount,against_job_service_no,account_of,main_id,main_job_no) values ('$customer_id','$trans_inv_no','$trans_inv_date','DIRECT','$particular','$vehicle_no','$chargable_amount','$job_service_no','$account_of','$main_id','$main_job_no')";
$r=mysql_query($query,$conn);


}}

$challan_no_book=$_POST['challan_no_book'];
$delivery_date=$_POST['delivery_date'];
$trans_inv_date=$_POST['trans_inv_date'];
$query4fa="update  tax_transtax set challan_no_book ='$challan_no_book',delivery_date='$delivery_date',trans_inv_date='$trans_inv_date' where trans_inv_no = '$trans_inv_no' and customer_id='$customer_id'";
$r4fa=mysql_query($query4fa,$conn);



/*?>if($taxable!=''){
$totalamt = $totalcharge;

$query1fa="update job_services set taxable ='$totalamt' where customer_id = '".$_REQUEST['customer_id']."' and Job_No='".$_REQUEST['Job_No']."' and services_name='Transportation Charges'";
//$r1fa=mysql_query($query1fa,$conn);

}

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

$address_direct=$_POST['address_direct'];
if($address_direct!='') {

$query1fatt="update transporter_details_expenses set address ='$address_direct' where trans_inv_no = '".$_REQUEST['trans_inv_no']."' and inv_no='".$_REQUEST['inv_no']."'";
//echo $query1fatt;
$r1fatt=mysql_query($query1fatt,$conn);
 } 

<?php *///echo $query1fa;;
//echo $query;

//exit();
?> 

<script>
javascript:window.location.href="view_all_dircttransinv.php";
</script>
