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

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

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

    $data = json_decode(file_get_contents("php://input"));

    $arr=array();

    $sales->ed = date('Y-m-d',(strtotime ( '+3 day' , strtotime ( $data->date ) ) ));
	$sales->rd = date('Y-m-d',(strtotime ( '0 day' , strtotime ( $data->date ) ) ));

	$arr=array(
		"total_expired_count" => (int)$sales->getExpireSMSCount($data->city,$sales->ed),
		"total_reminder_count" => (int)$sales->getReminderSMSCount($data->city,$sales->rd),
		"a" => $sales->ed
		// "total_renew_count" => (int)$sales->getRenewSMSCount($data->city,$data->date),
		// "ced_count" => (int)$sales->getCEDSMSCount($data->city,$data->date)
	);

	echo json_encode($arr);
?>