<?php
include("../config/database.php");
$shop_id           = $_POST['shop_id'];
$from_date         = $_POST['from_date'];
$to_date         = $_POST['to_date'];
$sqlOrder          = mysqli_query($cn,"SELECT *,sum(qty) FROM `tbl_order` WHERE `shop_id`='".$shop_id."' and (`order_date` between '$from_date' and '$to_date') group by `order_id` order by `order_id` DESC");
$count             = mysqli_num_rows($sqlOrder);
if($count > 0)
{	
    $list = array();   
    while($data = mysqli_fetch_array($sqlOrder))
    {			        
		$list[] = array("order_id"=>str_pad($data['order_id'], 4, "0", STR_PAD_LEFT), "order_date"=>date('d M, Y', strtotime($data['order_date'])), "total_qty"=>$data['sum(qty)'], "order_total"=>$data['order_total']);						   		
	}
    $arr  = array("status"=>true, "orderList"=>$list);	
}
else
{
    $arr = array("status"=>false, 'msg'=>"Order List Not Found.");
}
echo json_encode($arr);		    	
mysqli_close($cn);
?>