<?php 
ob_start();
session_start();
include("../inc/config.php");
$clientId=$_SESSION['user']['id'];
if(isset($_POST['type']) && $_POST['type']=='create_zone'){
    try{
        $pdo->beginTransaction(); 
        $insert_ids = implode(',', $_POST['inserted_id']);
        //$updated_box_ids = implode(',', $_POST['updated_awb_box']);
        
        
        
        $client_id=$_POST['client_id'];
        $client_from=$_POST['client_from'];
        $zone_id=$_POST['zone_id'];
        $states_id=$_POST['states_id'];
        
        
        $statement1 = $pdo->prepare("INSERT INTO `tbl_generate_zone`(`client_id`, `from_city`, `zone_id`, `state_id`, `selected_city`) 
        VALUES ('$client_id','$delivery_boy_name','$phone_no','$vehicle_no','$delivery_date','$insert_ids',1,'$count','$sheet_no')");
        $result= $statement1->execute();
        $run_sheet_id = $pdo->lastInsertId();
       
        $pdo->commit();
        $response['error']=false;
        $response['meassge']='Generate Zone Created Successfully: ';
        $response['run_sheet_id']=$run_sheet_id;
    }catch(exception $e){
        $pdo->rollBack();
        $response['error']=true;
        $response['meassge']="Something Went Wrong";
        error_log($e);
    }
    print_r(json_encode($response));
}
?>