<?php 
ob_start();
session_start();
include("inc/config.php");
/*select the login details for checking client and admin*/
if($_SESSION['user']['role']=='Modicare')
{
$clientId=$_SESSION['user']['id'];
$clientLocation=$_SESSION['user']['location'];
$clientType=$_SESSION['user']['role'];
}else
{
$session_id=$_SESSION['user']['id'];
$statement = $pdo->prepare("SELECT * FROM `tbl_user` WHERE id=1");
$statement->execute();
$response = $statement->fetchAll(PDO::FETCH_ASSOC);
 foreach($response as $res)
 {
$clientId=$res['id'];
$clientLocation=$res['location'];
$clientType=$res['role'];
 }
}


    $awb_type = $_POST['awb_type'];
    $awb = $_POST['awb'];
    
    
    if($clientType=="Admin"){
	$statement = $pdo->prepare("SELECT * FROM tbl_pod where awb_no='$awb' and awb_type='$awb_type' ORDER BY id ASC"); }
	else{
	  $statement = $pdo->prepare("SELECT tp.* FROM tbl_pod tp INNER JOIN pickup_entry pk ON tp.awb_id=pk.id where pk.client_id=$clientId and tp.awb_no=$awb and tp.awb_type='$awb_type' ORDER BY pk.id ASC"); }  
                        	
                        	$statement->execute();
							$result = $statement->fetchAll(PDO::FETCH_ASSOC);
							$total = $statement->rowCount();
							if($total>0){
                             foreach ($result as $row) {
                                    $url_1[] = $row['url_1'];
                                    $url_2[] = $row['url_2'];
                                    $url_3[] = $row['url_3'];
                                    $url_4[] = $row['url_4'];
                                    $url_5[] = $row['url_5'];
                                    $type[] = $row['type'];
                                    $pod_type[] = $row['pod_type'];
                              } 
							}else{
							    $url_1[] = '';
                                    $url_2[] = '';
                                    $url_3[] = '';
                                    $url_4[] = '';
                                    $url_5[] = '';
                                    $type[] = '';
                                    $pod_type[] = '';
							}
                              $datas[] = array('url_1' => $url_1,'url_2' => $url_2,'url_3' => $url_3,'url_4' => $url_4,'url_5' => $url_5, 'type' => $type, 'pod_type' => $pod_type,'count'=>$total);
                              
                         echo json_encode($datas);     
?>