<?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/stock_out.php';
session_start();
date_default_timezone_set('Asia/Rangoon'); 

$database = new Database();
$db = $database->getConnection();
 
$stock_out = new StockOut($db);
$data = json_decode(file_get_contents("php://input"));

$stock_out->stock_out_date = $data->stock_out_date;
$stock_out->reason = $data->reason;
$stock_out->store = $data->store;
$stock_out->item_code = $data->item_code;
$stock_out->item_name = $data->item_name;
$stock_out->quantity = $data->quantity;
$stock_out->capital_price = $data->capital_price;
$stock_out->sales_price = $data->sales_price;
$stock_out->entry_by = isset($_SESSION['user']) ? $_SESSION['user'] : "";

if($stock_out->create()){
    echo 'created';
}else{
    echo 'error';
}

?>