<?php 
include 'connection.php';
session_start();
if (!isset($_SESSION['is_logged_in'])) {
    header("Location:login.php");
    die();
    }
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
}

	date_default_timezone_set('Asia/Calcutta');
$today = date("d/m/y");
$today1 = date("d-m-Y");
$today2 = date("Y-m-d");
$received_time = date("Y-m-d H:i:s");

$currentyear = date("Y");
$currentmonth = date("m");

if($currentmonth>03) { 
$cuyear = date("Y");
$cuyear1 = date("y")+1;
} 
else { 
$cuyear = date("Y")-1;
$cuyear1 =  date("y");
} 
$f_year = "$cuyear"."-"."$cuyear1";


$unique_id = randomPassword();	

$querylogin = "select * from  mst_users where user_name = '". $_SESSION["LOGIN_NAME"]."' AND password = '".$_SESSION["EMPLOYEE_PASSWORD"]."'";
$resultlogin = mysqli_query($conn,$querylogin);
while($row=mysqli_fetch_array($resultlogin))
{
$user_name = $row['user_name'];
$user_id09 = $row['user_id'];
$login_type = $row['login_type'];

}	
?>



<?php
	


$billing_address=$_POST['billing_address'];
$bill_state=$_POST['state'];
$bill_city=$_POST['city'];
$state_code=$_POST['state_code'];
$billing_GST_no=$_POST['billing_GST_no'];
$billing_PAN_no=$_POST['billing_PAN_no'];
$bill_pincode=$_POST['pincode'];
$customer_name = $_POST['c_id'];
$country = $_POST['country'];
$billing_contact_person=$_POST['billing_contact_person'];
$tel_no=$_POST['tel_no'];
$cell_no=$_POST['cell_no'];
$email_id=$_POST['email_id'];
$website=$_POST['website'];
$nature_of_company=$_POST['nature_of_company'];
$cust_category=$_POST['cust_category'];
$application=$_POST['application'];
$reference = $_POST['reference'];


$buyer_name=$_POST['buyer_name'];
$buyer_state=$_POST['buyer_state'];
$buyer_state_code=$_POST['buyer_state_code'];
$buyer_GST_no = $_POST['buyer_GST_no'];
$buyer_PAN_no=$_POST['buyer_PAN_no'];
$buyer_address = $_POST['buyer_address'];

$vendor_code = $_POST['vendor_code'];

$same_as_billing = $_POST['same_as_billing'];

if($same_as_billing=='YES'){

$shipping_address=$billing_address;
}
 $qryauto="insert into mst_customer(customer_name,billing_address,location,state,pincode,billing_GST_no,billing_PAN_no,billing_contact_person,tel_no,cell_no,email_id,website,same_as_billing,country,state_code,shipping_address,buyer_name,buyer_state,buyer_state_code,buyer_GST_no,buyer_PAN_no,buyer_address,vendor_code) values ('$customer_name','$billing_address','$bill_city','$bill_state','$bill_pincode','$billing_GST_no','$billing_PAN_no','$billing_contact_person','$tel_no','$cell_no','$email_id','$website','$same_as_billing','$country','$state_code','$shipping_address','$buyer_name','$buyer_state','$buyer_state_code','$buyer_GST_no','$buyer_PAN_no','$buyer_address','$vendor_code')";
$rauto=mysqli_query($conn,$qryauto);
//echo $rauto;
//exit();




//exit();

?>



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


