ok
Direktori : /home2/selectio/www/lilyexpresslive/software/admin/ajax-code-api/ |
Current File : /home2/selectio/www/lilyexpresslive/software/admin/ajax-code-api/dash-api.php |
<?php ob_start(); session_start(); include("../inc/config.php"); ini_set('memory_limit','2048M'); try{ $ids=$_POST['client_id']; $count=$_POST['count']; $data['status']=false; if($ids==''){ $ids=0; } $sql="SELECT COUNT(id),client_id FROM `tbl_awb` where client_id not in ($ids) GROUP BY client_id limit 1"; // error_log('Sql :'.$sql); $statement = $pdo->prepare($sql); $statement->execute(); $client_result = $statement->fetchAll(PDO::FETCH_ASSOC); $r=1; foreach($client_result as $client){ $statement = $pdo->prepare("SELECT id,full_name, (select MIN(awb_code) from tbl_awb WHERE is_return_awb=0 and client_id=tbl_user.id) as forward_start_awb ,(select MAX(awb_code) from tbl_awb WHERE is_return_awb=0 and client_id=tbl_user.id) as forward_ending_awb ,(select count(awb_code) from tbl_awb WHERE is_return_awb=0 and client_id=tbl_user.id and status=1) as forward_available ,(select count(awb_code) from tbl_awb WHERE is_return_awb=0 and client_id=tbl_user.id and status=2) as forward_waiting_for_order ,(select count(awb_code) from tbl_awb WHERE is_return_awb=0 and client_id=tbl_user.id and status=0) as forward_used ,(select MIN(awb_code) from tbl_awb WHERE is_return_awb=1 and client_id=tbl_user.id) as reverse_start_awb ,(select MAX(awb_code) from tbl_awb WHERE is_return_awb=1 and client_id=tbl_user.id) as reverse_ending_awb ,(select count(awb_code) from tbl_awb WHERE is_return_awb=1 and client_id=tbl_user.id and status=1) as reverse_available ,(select count(awb_code) from tbl_awb WHERE is_return_awb=1 and client_id=tbl_user.id and status=2) as reverse_waiting_for_order ,(select count(awb_code) from tbl_awb WHERE is_return_awb=1 and client_id=tbl_user.id and status=0) as reverse_used FROM `tbl_user` WHERE id=".$client_result[0]['client_id']); $statement->execute(); $awb_result = $statement->fetchAll(PDO::FETCH_ASSOC); $data['status']=true; $data['id']=$client_result[0]['client_id']; $data['data']= '<tr> <th>'.$count.'</th> <th>'.$awb_result[0]['full_name'].'</th> <th>'.$awb_result[0]['forward_start_awb'].'</th> <th>'.$awb_result[0]['forward_ending_awb'].'</th> <th><a href="excel/awb-number.php?client_id='.$client_result[0]['client_id'].'&status=1&type=0" target="_blank">'.$awb_result[0]['forward_available'].'</a></th> <th><a href="excel/awb-number.php?client_id='.$client_result[0]['client_id'].'&status=2&type=0" target="_blank">'.$awb_result[0]['forward_waiting_for_order'].'</a></th> <th><a href="excel/awb-number.php?client_id='.$client_result[0]['client_id'].'&status=0&type=0" target="_blank">'.$awb_result[0]['forward_used'].'</a></th> <th>'.$awb_result[0]['reverse_start_awb'].'</th> <th>'.$awb_result[0]['reverse_ending_awb'].'</th> <th><a href="excel/awb-number.php?client_id='.$client_result[0]['client_id'].'&status=1&type=1" target="_blank">'.$awb_result[0]['reverse_available'].'</a></th> <th><a href="excel/awb-number.php?client_id='.$client_result[0]['client_id'].'&status=2&type=1" target="_blank">'.$awb_result[0]['reverse_waiting_for_order'].'</a></th> <th><a href="excel/awb-number.php?client_id='.$client_result[0]['client_id'].'&status=0&type=1" target="_blank">'.$awb_result[0]['reverse_used'].'</a></th> </tr>'; } echo json_encode($data); }catch(Exception $e){ $data['status']=false; echo json_encode($data); }