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

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

try {
  global $dbutil;

  $requestBody = file_get_contents('php://input');
  $data = json_decode($requestBody, true);
  $logger->info("data", $data );

  $whereParams["mvseq"] = $data["mvseq"];

  // SQL実行
  $result = $dbutil->nextVal("innerwseq");
  if( $result != null ) {
    $response["status"] = "OK";
    $response["data"]   = json_encode($result,true);
  } else {
    $retData["msg"]     = $dbutil->getNoDataMsg();
    $response["data"]   = $retData;
  }


} 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("=== end ===", $response);


?>
