<?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();
?>

<? 

											


				
			$query2c = "select * from main_job_details where main_id='".$_REQUEST['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'];
													 $customer_id=$row['customer_id'];
													  $customer_name=$row['customer_name'];
													  $inv_type=$row['inv_type'];
													  $account_of=$row['account_of'];
												}


$trans_inv_no = $_REQUEST['trans_inv_no']; 
$account_of = $_POST['an_ac_of'];

$trans_inv_date = $_REQUEST['trans_inv_date'];
$customer_id = $_REQUEST['customer_id'];

$totalcharge='0';
$max_contact2 = $_POST['count2'];
if($max_contact2!=''){
for ($z = 1; $z < $max_contact2; $z++) {	 
$particular= mysql_real_escape_string($_POST['particular'.$z]);
$vehicle_no = $_POST['vehicle_no'.$z];
$chargable_amount = $_POST['chargable_amount'.$z];
$challan_id = $_POST['challan_id'.$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,challan_id,main_id,main_job_no) values ('$customer_id','$trans_inv_no','$trans_inv_date','Challan','$particular','$vehicle_no','$chargable_amount','$job_service_no','$account_of','$challan_id','$main_id','$main_job_no')";
$r=mysql_query($query,$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'.$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'];

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

//echo $query1fa;;
//echo $query;

//exit();
?> 

<script>
javascript:window.location.href="print_transinv.php?main_id=<? echo $main_id;?>&&Job_No=<?php echo $_REQUEST['Job_No'];?>&&trans_inv_date=<? echo $trans_inv_date?>&&customer_id=<?php echo $_REQUEST['customer_id']?>&&trans_inv_no=<?php echo $_REQUEST['trans_inv_no']; ?>&&our_company_name=<?php echo $_REQUEST['an_ac_of']?>";
</script>
