<?php 
require 'db.php';
$data = json_decode(file_get_contents('php://input'), true);
if($data['uid'] == '' || $data['shop_id'] == '')
{
    $returnArr = array("ResponseCode"=>"401","Result"=>"false","ResponseMsg"=>"Something Went Wrong!");    
}
else
{
    // $uid =  "143";
    // $shop_id = "8316293";
    // $shop_code = "Ey3a8s7U79";
    
    $uid =  strip_tags(mysqli_real_escape_string($con,$data['uid']));
    $shop_id = strip_tags(mysqli_real_escape_string($con,$data['shop_id']));
    $shop_code = strip_tags(mysqli_real_escape_string($con,$data['shop_code']));
    
    $sel = $con->query("select * from orders where uid = '$uid' and shop_id = '$shop_id' and shop_code = '$shop_code' order by order_date desc"); 
    $g=array();
    $po= array();
    if($sel->num_rows != 0)
    {
        while($row = $sel->fetch_assoc())
        {
            $g['order_id'] = $row['order_id'];
            $g['status'] = $row['status'];
            $g['rate'] = $row['rate'];
            $g['order_date'] = $row['order_date'];
            $g['total'] = $row['total'];
            $g['rider_status'] = $row['r_status'];
            $delicode = $row['rid'];
            $rdata = $con->query("select * from assist_details where deli_code='$delicode'")->fetch_assoc();
            $g['rider_name'] = $rdata['name'];
            $g['rider_mobile'] = $rdata['mobile_no'];
            $po[] = $g;
        }
        $returnArr = array("Data"=>$po,"ResponseCode"=>"200","Result"=>"true","ResponseMsg"=>"Order History  Get Successfully!!!");
    }
    else 
    {
        $res_msg = "No Past Orders";
        $returnArr = array("ResponseCode"=>"401","Result"=>"false","ResponseMsg"=>$res_msg);
    }
}
echo json_encode($returnArr);
?>