<?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/installation.php';

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

$database = new Database();
$db = $database->getConnection();
 
$installation = new Installation($db);
$data = json_decode(file_get_contents("php://input"));
	
$installation->id_no = $data->id_no;
$installation->invoice_no = $data->invoice_no;
$installation->customer_id = $data->customer_id;
$installation->install_date = $data->install_date;
$installation->technician1 = $data->technician1;
$installation->technician2 = $data->technician2;
$installation->technician3 = $data->technician3;
$installation->install_address = $data->install_address;
$installation->entry_by = $_SESSION['user'];
$installation->entry_date_time = date("Y-m-d H:i:s");	


	if($installation->create()){
		$arr = array(
			"message" => "created",
			"last_id" => $installation->id
		);
	}else{
		$arr = array(
			"message" => "error"
		);
	}

echo json_encode($arr);
?>