<?php
// required headers
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");    
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");

include_once '../config/database.php';
include_once '../objects/order_list.php';

date_default_timezone_set('Asia/Rangoon');
session_start();

$database = new Database();
$db = $database->getConnection();

$order_list = new OrderList($db);

$order_list->city = $_GET['city'];
$order_list->ty = $_GET['ty'];

$stmt = $order_list->getToInstall();

$num = $stmt->rowCount();

$arr = array();
$arr["data"] = array();
$i = 0;

if($num>0){
    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
        extract($row);
        $detail = array(
            ++$i,
            $order_no,
            $order_date,
            $name,
            $phone,
            $address,
            $customer_id,
            $id_no,
            $slot_id,
            $pon_port,
            $odb,
            $service_port,
            $geolocation

        );
        array_push($arr["data"], $detail);
    }
}

echo json_encode($arr);
?>