ok
Direktori : /home2/selectio/www/y1jobportal.in/admin/api/ |
Current File : //home2/selectio/www/y1jobportal.in/admin/api/pickup-address.php |
<?php include_once('config/config.php'); include_once('config/custom-functions.php'); include 'config/send-sms.php'; $fn = new custom_functions(); /* ------------------------------------------- APIs for Speedconnect ------------------------------------------- 2. add pickup address 3. Edit pickup address 4. delete pickup address ------------------------------------------- */ if(isset($_POST['type']) && $_POST['type']=="add_pickup_address"){ try{ if (!isset($_POST['contact_person']) && empty(trim($_POST['contact_person']))) { $response['error'] = true; $response['message'] = "contact_person can't be empty!"; print_r(json_encode($response)); return false; exit(); }else if (!isset($_POST['contact_number']) && empty(trim($_POST['contact_number']))){ $response['error'] = true; $response['message'] = "contact_number can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['contact_email']) && empty(trim($_POST['contact_email']))){ $response['error'] = true; $response['message'] = "contact_email can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['contact_phone']) && empty(trim($_POST['contact_phone']))){ $response['error'] = true; $response['message'] = "contact_phone can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['contact_address']) && empty(trim($_POST['contact_address']))){ $response['error'] = true; $response['message'] = "contact_address can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['contact_pincode']) && empty(trim($_POST['contact_pincode']))){ $response['error'] = true; $response['message'] = "contact_pincode can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['contact_city']) && empty(trim($_POST['contact_city']))){ $response['error'] = true; $response['message'] = "contact_city can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['contact_state']) && empty(trim($_POST['contact_state']))){ $response['error'] = true; $response['message'] = "contact_state can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['contact_country']) && empty(trim($_POST['contact_country']))){ $response['error'] = true; $response['message'] = "contact_country can't be empty!"; print_r(json_encode($response)); return false; exit(); } $name = (isset($_POST['contact_person'])) ? $fn->xss_clean($_POST['contact_person']) : ""; $mobile = (isset($_POST['contact_number'])) ? $fn->xss_clean($_POST['contact_number']) : ""; $email = (isset($_POST['contact_email'])) ? $fn->xss_clean($_POST['contact_email']) : ""; $phone = (isset($_POST['contact_phone'])) ? $fn->xss_clean($_POST['contact_phone']) : ""; $address = (isset($_POST['contact_address'])) ? $fn->xss_clean($_POST['contact_address']) : ""; $pincode = (isset($_POST['contact_pincode'])) ? $fn->xss_clean($_POST['contact_pincode']) : ""; $city = (isset($_POST['contact_city'])) ? $fn->xss_clean($_POST['contact_city']) : ""; $state = (isset($_POST['contact_state'])) ? $fn->xss_clean($_POST['contact_state']) : ""; $country = (isset($_POST['contact_country'])) ? $fn->xss_clean($_POST['contact_country']) : ""; $address_type = (isset($_POST['address_type'])) ? $fn->xss_clean($_POST['address_type']) : "Home"; $landmark = (isset($_POST['contact_landmark'])) ? $fn->xss_clean($_POST['contact_landmark']) : ""; $supplier_vendor_name = (isset($_POST['supplier_vendor_name'])) ? $fn->xss_clean($_POST['supplier_vendor_name']) : ""; $supplier_vendor_gst = (isset($_POST['supplier_vendor_gst'])) ? $fn->xss_clean($_POST['supplier_vendor_gst']) : ""; $rto_address = (isset($_POST['rto_address'])) ? $fn->xss_clean($_POST['rto_address']) : "0"; if(!isset($_POST['add_supplier_vendor_address'])){ $supplier_vendor_name='';$supplier_vendor_gst=''; }if(!isset($_POST['add_rto_address'])){ $rto_address='0'; } $client_id =(isset($_POST['contact_client_id'])) ? $fn->xss_clean($_POST['contact_client_id']) : "1"; $uuid=$fn->gen_uuid(); $statement = $pdo->prepare("INSERT INTO `pickup_address`(`uuid`, `type`, `name`, `mobile`, `email`, `alter_mobile`, `address_line1`, `address_line2`, `pincode`, `city`, `state`, `country`, `client_id` , `supplier_vendor_name`, `supplier_vendor_gst`, `rto_address`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); $result = $statement->execute(array($uuid, $address_type,$name,$mobile,$email,$phone,$address,$landmark,$pincode,$city,$state,$country,$client_id,$supplier_vendor_name,$supplier_vendor_gst,$rto_address)); if($result){ $response['error']=false; $response['message']="pickup address details added successfuly"; }else{ $response['error']=true; $response['message']='failed'; } }catch(Exception $e){ $response['error']=true; $response['message']='something went wrong :'.$e; } echo json_encode($response); }else if(isset($_POST['type']) && $_POST['type']=="update_pickup_address"){ try{ if (!isset($_POST['contact_person']) && empty(trim($_POST['contact_person']))) { $response['error'] = true; $response['message'] = "contact_person can't be empty!"; print_r(json_encode($response)); return false; exit(); }else if (!isset($_POST['contact_number']) && empty(trim($_POST['contact_number']))){ $response['error'] = true; $response['message'] = "contact_number can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['contact_email']) && empty(trim($_POST['contact_email']))){ $response['error'] = true; $response['message'] = "contact_email can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['contact_phone']) && empty(trim($_POST['contact_phone']))){ $response['error'] = true; $response['message'] = "contact_phone can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['contact_address']) && empty(trim($_POST['contact_address']))){ $response['error'] = true; $response['message'] = "contact_address can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['contact_pincode']) && empty(trim($_POST['contact_pincode']))){ $response['error'] = true; $response['message'] = "contact_pincode can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['contact_city']) && empty(trim($_POST['contact_city']))){ $response['error'] = true; $response['message'] = "contact_city can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['contact_state']) && empty(trim($_POST['contact_state']))){ $response['error'] = true; $response['message'] = "contact_state can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['contact_country']) && empty(trim($_POST['contact_country']))){ $response['error'] = true; $response['message'] = "contact_country can't be empty!"; print_r(json_encode($response)); return false; exit(); }else if (empty(trim($_POST['id']))) { $response['error'] = true; $response['message'] = "pass pickup address id!"; print_r(json_encode($response)); return false; exit(); } $statement = $pdo->prepare("SELECT * FROM `pickup_address` WHERE id='$id'"); $statement->execute(); $res = $statement->fetchAll(PDO::FETCH_ASSOC); $num = $statement->rowCount(); if($num>0){ $response['error']=true; $response['message']='invalid pickup address id..'; print_r(json_encode($response)); return false; exit(); } $name = (isset($_POST['contact_person'])) ? $fn->xss_clean($_POST['contact_person']) : $res[0]['name']; $mobile = (isset($_POST['contact_number'])) ? $fn->xss_clean($_POST['contact_number']) : $res[0]['number']; $email = (isset($_POST['contact_email'])) ? $fn->xss_clean($_POST['contact_email']) : $res[0]['email']; $phone = (isset($_POST['contact_phone'])) ? $fn->xss_clean($_POST['contact_phone']) : $res[0]['phone']; $address = (isset($_POST['contact_address'])) ? $fn->xss_clean($_POST['contact_address']) : $res[0]['address']; $pincode = (isset($_POST['contact_pincode'])) ? $fn->xss_clean($_POST['contact_pincode']) : $res[0]['pincode']; $city = (isset($_POST['contact_city'])) ? $fn->xss_clean($_POST['contact_city']) : $res[0]['city']; $state = (isset($_POST['contact_state'])) ? $fn->xss_clean($_POST['contact_state']) : $res[0]['state']; $country = (isset($_POST['contact_country'])) ? $fn->xss_clean($_POST['contact_country']) : $res[0]['country']; $address_type = (isset($_POST['address_type'])) ? $fn->xss_clean($_POST['address_type']) : $res[0]['address_type']; $landmark = (isset($_POST['contact_landmark'])) ? $fn->xss_clean($_POST['contact_landmark']) : $res[0]['landmark']; $supplier_vendor_name = (isset($_POST['supplier_vendor_name'])) ? $fn->xss_clean($_POST['supplier_vendor_name']) : $res[0]['supplier_vendor_name']; $supplier_vendor_gst = (isset($_POST['supplier_vendor_gst'])) ? $fn->xss_clean($_POST['supplier_vendor_gst']) : $res[0]['supplier_vendor_gst']; $rto_address = (isset($_POST['rto_address'])) ? $fn->xss_clean($_POST['rto_address']) : $res[0]['rto_address']; if(!isset($_POST['add_supplier_vendor_address'])){ $supplier_vendor_name='';$supplier_vendor_gst=''; }if(!isset($_POST['add_rto_address'])){ $rto_address='0'; } $client_id =(isset($_POST['contact_client_id'])) ? $fn->xss_clean($_POST['contact_client_id']) : "1"; $id = $_POST['id']; $statement = $pdo->prepare("UPDATE `pickup_address` SET `type`=?, `name`=?, `mobile`=?, `email`=?, `alter_mobile`=?, `address_line1`=?, `address_line2`=?, `pincode`=?, `city`=?, `state`=?, `country`=?, `client_id`=? , `supplier_vendor_name`=? , `supplier_vendor_gst`=? , `rto_address`=? WHERE id=?"); $result = $statement->execute(array($address_type,$name,$mobile,$email,$phone,$address,$landmark,$pincode,$city,$state,$country,$client_id,$supplier_vendor_name,$supplier_vendor_gst,$rto_address,$id)); if($result){ $response['error']=false; $response['message']="pickup address Updated Successfully"; }else{ $response['error']=true; $response['message']='somthing went wrong..'; } }catch(exception $e){ $response['error']=true; $response['message']='something went wrong:'.$e; } echo json_encode($response); }else if(isset($_POST['type']) && $_POST['type']=="delete_pickup_address"){ try{ if (!isset($_POST['id'])) { $response['error'] = true; $response['message'] = "Pickup Address Not Available"; print_r(json_encode($response)); return false; exit(); } $id = $_POST['id']; $statement = $pdo->prepare("DELETE FROM `pickup_address` WHERE id='$id'"); $result = $statement->execute(); if($result){ $response['error']=false; $response['message']="Deleted Successfully"; }else{ $response['error']=true; $response['message']='Somthing Went Wrong..'; } }catch(exception $e){ $response['error']=true; $response['message']='something went wrong:'.$e; } echo json_encode($response); }else if(isset($_POST['type']) && $_POST['type']=="primary_pickup_address"){ try{ if (!isset($_POST['id'])) { $response['error'] = true; $response['message'] = "Pickup Address Not Available"; print_r(json_encode($response)); return false; exit(); } if (!isset($_POST['client_id'])) { $response['error'] = true; $response['message'] = "Invalid paramter passing"; print_r(json_encode($response)); return false; exit(); } $id = $_POST['id']; $client_id = $_POST['client_id']; $statement = $pdo->prepare("UPDATE `pickup_address` SET status=0 WHERE client_id='$client_id'"); $result = $statement->execute(); $statement = $pdo->prepare("UPDATE `pickup_address` SET status=1 WHERE id='$id'"); $result = $statement->execute(); if($result){ $response['error']=false; $response['message']="primary pickup address updated"; }else{ $response['error']=true; $response['message']='Somthing Went Wrong..'; } }catch(exception $e){ $response['error']=true; $response['message']='something went wrong:'.$e; } echo json_encode($response); } else{ $response['error']=true; $response['message']='Invalid API Call :'; echo json_encode($response); } ?>