<?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;?>
<?  $short_year=$curr_short_year .'-'. $future; ?>

<?php
$currentmonth = date("m");

if($currentmonth>$check_month) { 
$cuyear = date("y");
$cuyear1 = date("y")+1;

} else { 
$cuyear = date("y")-1;
$cuyear1 =  date("y");
 } 
$fy_short_year = "$cuyear"."-"."$cuyear1";
?>



<?php 

$transport_name = $_POST['transport_name'];

$query2tm = "select * from transport_master where transport_id = '$transport_name'";
$result2tm = mysql_query($query2tm,$conn);	
while($row = mysql_fetch_array($result2tm))
{
$short_form = $row['short_form'];
}


?>


<?php
$queryls1 = "select * from transport_master where trans_auto_no!='' and short_form='$short_form'";
$resultls1 = mysql_query($queryls1,$conn);	
$num_rows3t = mysql_num_rows($resultls1);
if($num_rows3t =='0') { 
$trans_auto_no1 = 0;
$trans_auto_no_new=$trans_auto_no1+1;
$cont_seriesa= sprintf("%04d", $trans_auto_no_new);
} 
else 
{
while($row=mysql_fetch_array($resultls1))
{
$trans_auto_no = $row['trans_auto_no'];
}
$trans_auto_no_new=$trans_auto_no+1;
$cont_seriesa= sprintf("%04d", $trans_auto_no_new);
}
if($short_form=='DGK' or $short_form=='SPM'){
$trans_inv_no=$short_form.'/'.$cont_seriesa.'/'. $fy_short_year;
}
if($short_form=='HSC' or $short_form=='SE'){
$trans_inv_no=$cont_seriesa.'/'. $fy_short_year;
}
if($short_form=='SMCL' or $short_form=='PSGR' or $short_form=='TCS'){
$trans_inv_no=$short_form.'/'.$inv_type.'/'.$cont_seriesa.'/'. $fy_short_year;
}

$query2b2 = "select * from transport_master where trans_auto_no = '$trans_auto_no_new' and f_year ='$curr_fy' and short_form='$short_form'";

$result2b2 = mysql_query($query2b2,$conn);	
$num_rowsb2 = mysql_num_rows($result2b2); 
if($num_rowsb2=='0') { 
$query14T = "update transport_master set trans_auto_no='$trans_auto_no_new',trans_inv_no='$trans_inv_no',f_year='$curr_fy' where short_form='$short_form'";
$r14T=mysql_query($query14T,$conn);
}
?>

<?php


$querytu = "update tax_transtax set trans_inv_no='$trans_inv_no' where  trans_inv_no='".$_REQUEST['trans_inv_no']."' and final_job_no = '".$_REQUEST['Job_No']."'  and customer_id = '".$_REQUEST['customer_id']."'";
$resulttu=mysql_query($querytu,$conn);

$querytrans01="update import_inv_make set trans_inv_no='$trans_inv_no' where trans_inv_no='".$_REQUEST['trans_inv_no']."' and final_job_no = '".$_REQUEST['Job_No']."'  and customer_id = '".$_REQUEST['customer_id']."'";
$restrans01=mysql_query($querytrans01,$conn);



?>


<?php

$queryls1s = "select * from transport_master where trans_auto_no='".$_REQUEST['trans_auto_noold']."' and short_form='".$_REQUEST['short_formold']."'";
$resultls1s = mysql_query($queryls1s,$conn);
$num_rowsb2s = mysql_num_rows($resultls1s); 
if($num_rowsb2s=='1')	
{
while($row=mysql_fetch_array($resultls1s))
{
$trans_auto_no = $row['trans_auto_no'];
}
$trans_auto_no_old=$trans_auto_no-1;

$query14T = "update transport_master set trans_auto_no='$trans_auto_no_old' where short_form='$short_form'";
$r14T=mysql_query($query14T,$conn);
}
?>