ok
Direktori : /proc/self/root/home2/selectio/www/y1jobportal.in/admin/api/carrier-api/ |
Current File : //proc/self/root/home2/selectio/www/y1jobportal.in/admin/api/carrier-api/shipment-status-api.php |
<?php include_once('../config/config.php'); include_once('../config/custom-functions.php'); include '../config/send-sms.php'; $fn = new custom_functions(); if(isset($_POST['type']) && $_POST['type']=="shipment_status_update"){ try{ $pdo->beginTransaction(); error_log('Status Update Inside Loop Working...'); $shipment_updated_status = 0; $id=0; if (!isset($_POST['awb_no'])) { $response['error'] = true; $response['message'] = "awb number can't be empty!"; print_r(json_encode($response)); return false; exit(); }else if (!isset($_POST['status'])) { $response['error'] = true; $response['message'] = "status can't be empty!"; print_r(json_encode($response)); return false; exit(); } if (!isset($_POST['status_date'])) { error_log('status date is empty'); } $status_code=$fn->get_status_code($fn->xss_clean($_POST['status'])); $status_name=$fn->get_status_name($status_code); $shipment_updated_date = (isset($_POST['status_date'])) ? $fn->xss_clean($_POST['status_date']) : date("Y-m-d"); $awb_no =(isset($_POST['awb_no'])) ? $fn->xss_clean($_POST['awb_no']) : ""; $statement = $pdo->prepare("SELECT * FROM `shipment` WHERE carrier_awb='$awb_no'"); $statement->execute(); $res = $statement->fetchAll(PDO::FETCH_ASSOC); $num = $statement->rowCount(); if($num>0){ $id=$res[0]['id']; }else{ $response['error']=true; $response['message']='invalid shipment awb no does not exist out system..'; print_r(json_encode($response)); return false; exit(); } /*Optional Fields*/ $receiver_name =(isset($_POST['receiver_name'])) ? $fn->xss_clean($_POST['receiver_name']) : ""; $receiver_mobile =(isset($_POST['receiver_mobile'])) ? $fn->xss_clean($_POST['receiver_mobile']) : ""; $status_location =(isset($_POST['status_location'])) ? $fn->xss_clean($_POST['status_location']) : ""; /*Optional Fields*/ $statement = $pdo->prepare("UPDATE `shipment` SET `shipment_updated_status`=?, `shipment_updated_date`=?,shipment_updated_status_name=? WHERE id=?"); $result = $statement->execute(array($status_code,$shipment_updated_date,$status_name,$id)); $uuid=$fn->gen_uuid(); $statement = $pdo->prepare("INSERT INTO `shipment_tracking`( `uuid`, `shipment_id`, `status`, `status_name`,`status_location`, `status_updated_date`) VALUES (?,?,?,?,?,?)"); $result = $statement->execute(array($uuid, $id,$status_code,$status_name,$status_location,$shipment_updated_date)); if($result){ $response['error']=false; $response['message']="shipment status Updated Successfully"; }else{ $response['error']=true; $response['message']='somthing went wrong..'; } $pdo->commit(); $pdo=null; echo json_encode($response); }catch(Exception $e){ $response['error']=true; $response['message']='something went wrong try again...'; $pdo->rollBack(); echo json_encode($response); $pdo=null; } }else{ $response['error']=true; $response['message']='...'; echo json_encode($response); $pdo=null; } ?>