ok
Direktori : /home2/selectio/www/lilyexpresslive/software/admin/data-tables/ |
Current File : /home2/selectio/www/lilyexpresslive/software/admin/data-tables/custom-function.php |
<?php session_start(); include("../inc/config.php"); //Delete Pickup Entry Details if(isset($_POST['type']) && $_POST['type']=="delete_pickup_entry"){ $delete_ids = $_POST['delete_id']; $delete_id="0"; $delete_customer_id="0"; foreach($delete_ids as $ids){ $delete_id.=",".$ids; $statement = $pdo->prepare("SELECT tbl_customer.cust_id FROM `pickup_entry` inner join tbl_customer on pickup_entry.customer_id=tbl_customer.cust_id where tbl_customer.cust_type='one_time' and pickup_entry.id='$ids'"); $statement->execute(); $results = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($results as $row) { $customer_id = $row['cust_id']; $delete_customer_id.=",".$customer_id; } } $statement = $pdo->prepare("delete from pickup_entry WHERE id in (".$delete_id.") ;delete from tbl_tracking WHERE pickup_entry_id in (".$delete_id.") ;delete from tbl_pod WHERE awb_id in (".$delete_id.") ; delete from tbl_customer WHERE cust_type='one_time' and cust_id in (".$delete_customer_id.") ;"); $result=$statement->execute(); echo $delete_id."customer ids: ".$delete_customer_id; } //Get Client Details if(isset($_POST['type']) && $_POST['type']=="get_client" && isset($_POST['branch_id'])){ $branch_id=$_POST['branch_id']; if($branch_id==0){ $condition="";}else{$condition="and branch_id=".$branch_id;} $statement = $pdo->prepare("SELECT * FROM tbl_user WHERE role_type=4 and status='Active' $condition ORDER BY id ASC"); $statement->execute(); $result = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($result as $fetch) { $id = $fetch['id']; $client_name = $fetch['full_name']; $final_result[] = array("id" => $id, "client_name" => $client_name); } echo json_encode($final_result); } //Get Branch Details if(isset($_POST['type']) && $_POST['type']=="get_branch"){ $tbl_branch=""; if($_SESSION['lily_express_software_live']['id']!=1){ $tbl_branch=" and id in (".$_SESSION['lily_express_software_live']['role_branches'].")"; } $statement = $pdo->prepare("SELECT * FROM tbl_branch WHERE status='Active' $tbl_branch"); $statement->execute(); $result = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($result as $fetch) { $id = $fetch['id']; $branch_name = $fetch['branch_name']; $final_result[] = array("id" => $id, "branch_name" => $branch_name); } echo json_encode($final_result); } if(isset($_POST['type']) && $_POST['type']=="delete_awb_numbers"){ $delete_ids = $_POST['delete_id']; $delete_id="0"; foreach($delete_ids as $ids){ $statement = $pdo->prepare("SELECT * FROM `tbl_awb` where id='$ids'"); $statement->execute(); $results = $statement->fetchAll(PDO::FETCH_ASSOC); foreach($results as $r){ if($r['status']==1){ $delete_id.=",".$ids; }else{ $statement = $pdo->prepare("SELECT * FROM `pickup_entry` where pickup_entry.ref_no=".$r['awb_code']); $statement->execute(); $results = $statement->fetchAll(PDO::FETCH_ASSOC); if(!$results){ $delete_id.=",".$ids; } } } } $statement = $pdo->prepare("delete from tbl_awb WHERE id in (".$delete_id.")") ; $result=$statement->execute(); } ?>