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

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


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

$logger->info("data", $data);
$header = $data["header"];

try {
  global $dbutil;
  global $stringUtil;
  $valutil = new getValueUtil();

  $detail = $data["data"][0];
  $logger->info("data", $detail );
  $logger->info("header",$header);
  
  //PL/SQL Call
  $whereParams = array();
  $whereParams["ktktcd"]["in"] = $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["LGKTKTCD"];
  $whereParams["ret"]["out"] = "";
  $whereParams["mode"]["in"] = "1";
  $sql = file_get_contents("./sql/callAf840s.sql");
  $result = $dbutil->call($sql, $whereParams);
  $logger->info("ret_callAf840s",$result);
  
  $ret_array["ret"] = $result["ret"];
  $ret_array["status"] = "OK";

  $response["data"] = $ret_array;
  
  $dbutil->commit();

} catch(userException $ue) {
  $retData["code"]  = $ue->getErrorCode();
  $retData["msg"]   = $ue->getErrorMessage();
  $retData["status"]   = "NG";  

  $response["data"]   = $retData;

  $dbutil->rollback();

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

  $dbutil->rollback();

} finally {
  $logger->info("response", $response );
  print( json_encode($response) );
}

$logger->info("=== af28ax_callAf840s_end ===");
?>
