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

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

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

  $retValue = Array();
  $retValue = [
    "wseq" => "",
    "smode" => "",
    "lcnt1" => "",
    "lcnt2" => "",
    "lcnt3" => "",
    "lcnt4" => "",
    "ret" => "0",
		"msg" => "",
    "retwseq" => ""
  ];

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

  $logger->info("data", $data );

  // SQL実行
  $result = doGetCsv($dbutil, $data);
  $response["data"]   = json_encode($result,true);
  $response["status"] = "OK";

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

?>
