<?php
//共通
require_once '../../base/common.php';
require_once './allways.php';
$logger = new logger(basename(__FILE__));
$logger->info("===calcPrice_start===");

$response["status"] = "NG";

try {
  global $dbutil;

  $requestBody = file_get_contents('php://input');
  $data = json_decode($requestBody, true);

  $logger->info($data );

  $ktktcd = $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["LGKTKTCD"];
  $sdday = $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["SDDAY"];

  $valutil = new getValueUtil();
  $result = array();
  $result["gdbcst"] = $valutil->calc_gdbcst('1','1',$ktktcd,$data["cucd"],$data["ijan"],$data["gdbcst1"],$sdday);
  $result["gdsal"] = $valutil->calc_tax('1','1',$ktktcd,$data["cucd"],$data["ijan"],$data["gdsal1"],$sdday);

  // SQL実行
  $logger->info('calcPrice_ret',$result );
  $response["status"] = "OK";
  $response["data"]   = json_encode($result);
} catch(userException $ue) {
  $retData["code"]  = $ue->getErrorCode();
  $retData["msg"]   = $ue->getErrorMessage();

  $response["status"] = "NG";
  $response["data"]   = $retData;

  $dbutil->rollback();
} catch(Exception $e) {
  $response["status"] = "NG";
  $response["data"]   = $e->getMessage();

  $dbutil->rollback();

} finally {
  print(json_encode($response));
}


$logger->info("=== end01 ===", $response);

?>
