<?php include 'connection.php';
session_start();
if (!isset($_SESSION['is_logged_in'])) {
    header("Location:login.php");
    die();
    }
    date_default_timezone_set('Asia/Calcutta');
$today = date("d/m/Y");
$today1 = date("d/m");
$currentmonth = date(m);
    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();

?>







<?php
$challan_no01=$_REQUEST['challan_no01'];
if($_REQUEST['auto_challan_no']!=''){
$query1kn = "select * from challan_no where auto_challan_no = '".$_REQUEST['auto_challan_no']."' and f_year ='".$_REQUEST['f_year']."'";
$result1kn = mysql_query($query1kn,$conn);
$num_rowskn = mysql_num_rows($result1kn);
if($num_rowskn =='0') {
$auto_challan_no = $_REQUEST['auto_challan_no'];
$f_year = $_REQUEST['f_year']; 
$qryautopi = "insert into challan_no(auto_challan_no,f_year,challan_no) values ('$auto_challan_no','$f_year','$challan_no01')";
$rautopi=mysql_query($qryautopi,$conn);
}

}
$challan_id = $_POST['challan_id'];
$customer_id=$_REQUEST['customer_id'];
$main_id=$_REQUEST['main_id'];
$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'];
												}

$consignor = $_POST['consignor'];
$consignee = $_POST['consignee'];
$consignee_gst_no = $_POST['consignee_gst_no'];
$from_consignor = $_POST['from_consignor'];
$to_consignor = $_POST['to_consignor'];
$vehicle_no = $_POST['vehicle_no'];
$articles_no = $_POST['articles_no'];
$weight = $_POST['weight'];
$freight = $_POST['freight'];
$transportations_service = $_POST['transportations_service'];
$description = $_POST['description'];
$loaded_export_import = $_POST['loaded_export_import'];
$container_no = $_POST['container_no'];
$seal_no = $_POST['seal_no'];

$destinations = $_POST['destinations'];
$shipping_agent = $_POST['shipping_agent'];
$booking_no = $_POST['booking_no'];
$type_pkgs=$_POST['type_pkgs'];
$in_time = $_POST['in_time'];
$out_time = $_POST['out_time'];
$receiver_signature_with_seal = $_POST['receiver_signature_with_seal'];

$delivery_at = $_POST['delivery_at'];
$consignor_address = $_POST['consignor_address'];
$consignee_addess = $_POST['consignee_addess'];
$date = $today;
$no_of_pkgs=$_POST['no_of_pkgs'];
$actual_weight=$_POST['actual_weight'];
$charged_weight=$_POST['charged_weight'];
$topay_freight=$_POST['topay_freight'];
$paid_freight=$_POST['paid_freight'];
$total_container_no=$_POST['total_container_no'];
$container_type=$_POST['container_type'];
$b_e_no=$_POST['b_e_no'];
$b_e_date=$_POST['b_e_date'];
$sb_no=$_POST['sb_no'];
$sb_date=$_POST['sb_date'];
$challan_no_book=$_POST['challan_no_book'];
$delivery_date=$_POST['delivery_date'];

$query14 = "insert into challan_master (customer_id,consignor,consignee,consignee_gst_no,articles_no,weight,freight,transportations_service,description,loaded_export_import,container_no,seal_no,destinations,shipping_agent,booking_no,in_time,out_time,receiver_signature_with_seal,delivery_at,vehicle_no,from_consignor,to_consignor,date,consignor_address,consignee_addess,paid_freight,topay_freight,actual_weight,charged_weight,challan_no,no_of_pkgs,total_container_no,container_type,b_e_no,b_e_date,sb_no,sb_date,main_id,main_job_no,type_pkgs,challan_no_book,delivery_date) values ('$customer_id','$consignor','$consignee','$consignee_gst_no','$articles_no','$weight','$freight','$transportations_service','$description','$loaded_export_import','$container_no','$seal_no','$destinations','$shipping_agent','$booking_no','$in_time','$out_time','$receiver_signature_with_seal','$delivery_at','$vehicle_no','$from_consignor','$to_consignor','$date','$consignor_address','$consignee_addess','$paid_freight','$topay_freight','$actual_weight','$charged_weight','$challan_no01','$no_of_pkgs','$total_container_no','$container_type','$b_e_no','$b_e_date','$sb_no','$sb_date','$main_id','$main_job_no','$type_pkgs','$challan_no_book','$delivery_date')";
$r14=mysql_query($query14,$conn);
//echo $query14;
 //exit();
?> 

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