<?php
// required headers
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
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);
$data = json_decode(file_get_contents("php://input"));

$order_list->city = $data->city;
$order_list->order_no = $data->order_no;
$order_list->order_date = $data->order_date;
$order_list->plan = $data->plan;
$order_list->month = $data->month;
$order_list->customer_id = $data->customer_id;
$order_list->name = $data->name;
$order_list->phone = $data->phone;
$order_list->member_type = $data->member_type;
$order_list->address = $data->address;
$order_list->entry_by = $_SESSION['user'];
$order_list->entry_date_time = date("Y-m-d H:i:s");	

	if($order_list->exist()){
        $msg_arr = array(
            "message" => "duplicate"
        );
    }else if($order_list->create()){
		$msg_arr = array(
			"message" => "created",
			"id" => $order_list->id
		);
	}else{
		$msg_arr = array(
			"message" => "errorc"
		);	
	}

echo json_encode($msg_arr);
?>	