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

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


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

try {
  global $dbutil;
  global $stringUtil;
$logger->info('af999i',$data);
  $header = $data['header'];
  $data = $data['data'][0];

  $whereParams = array();
  $whereParams['rcflg'] = $data['rcflg'];
  $whereParams['rcnt'] = $stringUtil->toNumber($data['rcnt']);
  $whereParams['pkiflg'] = $data['pkiflg'];
  $whereParams['pkigen'] = $stringUtil->toNumber($data['pkigen']);
  $whereParams['pkeflg'] = $data['pkeflg'];
  $whereParams['pketa'] = $stringUtil->toNumber($data['pketa']);
  $whereParams['preflg'] = $data['preflg'];
  $whereParams['precycl'] = $stringUtil->toNumber($data['precycl']);
  $whereParams['dlogflg'] = $data['dlogflg'];
  $whereParams['ktktcd'] = $header['ktktcd'];
  $sql = file_get_contents("./sql/update.sql");
$logger->info('up>>',$whereParams);
  $result = $dbutil->update($sql, $whereParams);

  $dbutil->commit();

} 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 {
  $logger->info("response", $response );
  print( json_encode($response) );
}

$logger->info("=== ai999x_updata_end ===");

?>
