<?php 

require 'db.php';
if(isset($_GET['sid']) && isset($_GET['token']))
{
    $shop_id = $_GET['sid'];
    $shop_code = $_GET['token'];

    include 'token_check.php';
    
    if($token_check)
    {
        $sels = $con->query("select * from rate_order where shop_id='$shop_id' and shop_code='$shop_code' order by id DESC");
        while($rows = $sels->fetch_assoc())
        {
            $order_id = $rows['oid'];
            $cat =  $con->query("select rid,uid,order_date from orders where order_id= '$order_id' and shop_id='$shop_id' and shop_code='$shop_code'");
        	if($row = $cat->fetch_assoc())
        	{
        	    $rider = $row['rid'];
        	    $userid = $row['uid'];
        	    $cat1 =  $con->query("select name from assist_details where deli_code='$rider'");
            	if($row1 = $cat1->fetch_assoc())
            	{
            	    $p['rider'] = $row1['name'];
            	}
            	$cat2 =  $con->query("select name from user where id='$userid' and shop_id='$shop_id' and shop_code='$shop_code'");
            	if($row2 = $cat2->fetch_assoc())
            	{
            	    $p['name'] = $row2['name'];
            	}
            	$date=date_create($row['order_date']);
        	    $p['order_date'] = date_format($date,"d-m-Y");
        	}
        	$p['order_id'] = $rows['oid'];
            $p['rate'] = $rows['rate'];
        	$p['message'] = $rows['msg'];
        	$cp[] = $p;
        }
        
        echo json_encode($cp);
    }
    else
    {
        $rows = array('status'=>"",'message' => 'Data Error');
        echo json_encode($rows);
    }
}

?>