<?php
include("config.php");
if(isset($_POST['submit'])){
    $track_id = $_POST['trackid'];
	$sender = $_POST['sendername'];
	$receiver = $_POST['receivername'];
	$destination = $_POST['destination'];
	$expecteddate = $_POST['expecteddate'];
	$location = $_POST['location'];
	
	// Track Id //
// 	$sql2 = "SELECT `track_id` FROM `shipment_datalis` ORDER BY `shipment_datalis`.`id` DESC LIMIT 1";
//         $result2 = mysqli_query($con,$sql2);
//         if($result2){
//         	while($row1 = mysqli_fetch_assoc($result2)){
//         		$get_id = $row1['track_id'];
//         	}
//         	if($get_id == ""){
//         	$track_id = '20241';
//         	}
//         	else{
//         	$get_id1 = substr($get_id, 4);
//         	$get_id2 = '2024';
//         	$get_id3 = ($get_id1 + 01);
//         	$track_id = $get_id2.$get_id3;
// 			}
//         }
// 	$track_id = strtoupper(uniqid().date("dmy"));
	
    $sql ="INSERT INTO `shipment_datalis`(`id`,`track_id`,`sendername`, `receivername`, `destination`, `arrival`, `c_location`, `realtime`,`status`) VALUES (NULL,'$track_id','$sender','$receiver','$destination','$expecteddate','$location',CURRENT_TIMESTAMP,'0')";
    $res = mysqli_query($con,$sql);

    if($res){
    	header("Location: ../view.php");
    }
}
?>