<?php
require_once("config/configDB.php"); 

function validation_input($data) {
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return $data;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {

    $vehiclename    = stripslashes($_POST['vehicleno']);
    $brandtype      = stripslashes($_POST['brandtype']);
    $brandname      = stripslashes($_POST['brandname']);
    $model          = stripslashes($_POST['model']);
    $purchasedate   = stripslashes($_POST['purchasedate']);
    $openingkm      = stripslashes($_POST['openingkm']);
	$openinghrs      = stripslashes($_POST['openinghrs']);
    $vehicletype    = stripslashes($_POST['vehicletype']);
    $ownership      = stripslashes($_POST['ownership']);
	 $companymileage      = stripslashes($_POST['companymileage']);
	$fastag      = stripslashes($_POST['fastag']);
	
	$regname      = stripslashes($_POST['regname']);
	$reg_address      = "";

    $ins_policynumber   = "";
    $ins_policyfrom     = "";
    $ins_policyto       = "";
    $ins_policyremindon = "";
	$insurancecompany = "";

    $fcnumber       = "";
    $fcfrom         = "";
    $fcto           = "";
    $fcremindon     = "";

    $permitnumber    = "";
    $permitfrom      = "";
    $permitto        = "";
    $permitremindon  = "";
	
	$pypermitnumber    = "";
    $pypermitfrom      = "";
    $pypermitto        = "";
    $pypermitremindon  = "";

    $taxnumber       = "";
    $taxfrom         = "";
    $taxto           = "";
    $taxremindon     = "";
	
	$pytaxnumber       = "";
    $pytaxfrom         = "";
    $pytaxto           = "";
    $pytaxremindon     = "";

    $loannumber       = "";
    $loanfrom         = "";
    $loanto           = "";
    $loanremindon     = "";
    $loan_financier   = "";
    $loan_amt         = "";
    $loan_interest    = "";
    $loan_tenure      = "";
    $loan_emiamt      = "";
    
    $createdate  	= date("Y-m-d");
    $createdby      = $_SESSION['username'];
    $userID         = $_SESSION['user_id'];
	
	$autoinc=mysqli_query($conn,"ALTER TABLE vehicle_master CHANGE id id INT(11) NOT NULL AUTO_INCREMENT ");
	$autoinc2=mysqli_query($conn,"ALTER TABLE vehicle_renewal CHANGE id id INT(11) NOT NULL AUTO_INCREMENT ");
        
    $sql  = "INSERT INTO vehicle_master(vehicleno, brandtype, brandname, model, purchasedate, openingkm,openinghrs, vehicletype, vownership,regname,reg_address,companymileage,fastag, ins_policynumber, ins_policyfrom, ins_policyto, ins_policyremindon,insurancecompany, fcnumber, fcfrom, fcto, fcremindon, permitnumber, permitfrom, permitto, permitremindon, pypermitnumber, pypermitfrom, pypermitto, pypermitremindon, taxnumber, taxfrom, taxto, taxremindon,pytaxnumber, pytaxfrom, pytaxto, pytaxremindon, loannumber, loanfrom, loanto, loanremindon, loan_financier, loan_amt, loan_interest, loan_tenure, loan_emiamt, createdate, createdby, userID, isdelete) VALUES ('".$vehiclename."','".$brandtype."','".$brandname."','".$model."','".$purchasedate."','".$openingkm."','".$openinghrs."','".$vehicletype."','".$ownership."','".$regname."','".$reg_address."','".$companymileage."','".$fastag."','".$ins_policynumber."','".$ins_policyfrom."','".$ins_policyto."','".$ins_policyremindon."','".$insurancecompany."','".$fcnumber."','".$fcfrom."','".$fcto."','".$fcremindon."','".$permitnumber."','".$permitfrom."','".$permitto."','".$permitremindon."','".$pypermitnumber."','".$pypermitfrom."','".$pypermitto."','".$pypermitremindon."','".$taxnumber."','".$taxfrom."','".$taxto."','".$taxremindon."','".$pytaxnumber."','".$pytaxfrom."','".$pytaxto."','".$pytaxremindon."','".$loannumber."','".$loanfrom."','".$loanto."','".$loanremindon."','".$loan_financier."','".$loan_amt."','".$loan_interest."','".$loan_tenure."','".$loan_emiamt."','".$createdate."','".$createdby."','".$userID."',1)";

  //print_r($sql);die;
    mysqli_query($conn,$sql);

    $vehicleID = mysqli_insert_id($conn);
   /* if($vehicleID) {
        
        $sqlr  = "INSERT INTO vehicle_renewal(vehicleno,ins_policynumber, ins_policyfrom, ins_policyto, ins_policyremindon,insurancecompany, fcnumber, fcfrom, fcto, fcremindon, permitnumber, permitfrom, permitto, permitremindon,pypermitnumber, pypermitfrom, pypermitto, pypermitremindon, taxnumber, taxfrom, taxto, taxremindon,pytaxnumber, pytaxfrom, pytaxto, pytaxremindon, loannumber, loanfrom, loanto, loanremindon, createdate, createdby, userID, isdelete) VALUES ('".$vehicleID."','".$ins_policynumber."','".$ins_policyfrom."','".$ins_policyto."','".$ins_policyremindon."','".$insurancecompany."','".$fcnumber."','".$fcfrom."','".$fcto."','".$fcremindon."','".$permitnumber."','".$permitfrom."','".$permitto."','".$permitremindon."','".$pypermitnumber."','".$pypermitfrom."','".$pypermitto."','".$pypermitremindon."','".$taxnumber."','".$taxfrom."','".$taxto."','".$taxremindon."','".$pytaxnumber."','".$pytaxfrom."','".$pytaxto."','".$pytaxremindon."','".$loannumber."','".$loanfrom."','".$loanto."','".$loanremindon."','".$createdate."','".$createdby."','".$userID."',1)";
        
        mysqli_query($conn,$sqlr);
    }*/
    header("Location:vehicleMasterDashboard.php");

}





?>