<?php
//共通
require_once '../../base/common.php';

/**
 * af226x共通カスタム関数
 * by M.Sasaki
 */

/*
  修正可能かチェック
*/
function chkModify($dbutil, $data){
  $logger = new logger(basename(__FILE__));
    global $stringUtil;
  $logger->info("chkModify>>",$data);
  $ret_array = array(
    "ret" => "0",
    "cnt" => "0",
    "msg" => "",
  );
  $ret = "0";

  $valutil = new getValueUtil();

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

  try {
    //sbat取得
    $result = $valutil->getSbat("1","0",$ktktcd,$data["cucd"],$data["cuscd"]);
  $logger->info("sbat:",$result);
    $ret = $result["ret"];
    $sbat = $result["sbat"];
    $cdat = $result["cdat"];
    $sts = $result["sts"];
    if ($ret == "0") {  //sbat OK
      $sql = file_get_contents("./sql/chkAur32.sql");
      $whereParams = array();
      $whereParams["ktktcd"] = $ktktcd;
      $whereParams["vseq"] = $data["vseq"];
      $whereParams["cucd"] = $data["cucd"];
      $whereParams["cuscd"] = $data["cuscd"];
      $whereParams["tcls"] = $data["tcls"];
      $whereParams["sts"] = $sts;
      $whereParams["sbat"] = $sbat;
      $whereParams["viseq"] = $data["viseq"];
$logger->info($sql,$whereParams);
      $result = $dbutil->selectNocount($sql, $whereParams);
$logger->info($reesult);
      $cnt = $result[0]["cnt"];
    } else {
      $ret = "-9";
      $msg = "データ取得に失敗しました。";
    }

    $ret_array["cnt"] = $cnt;
    $ret_array["ret"] = $ret;
    $ret_array["msg"] = $msg;
  } catch(userException $ue) {
    $retData["code"]  = $ue->getErrorCode();
    $retData["msg"]   = $ue->getErrorMessage();
    $response["status"] = "NG";
    $ret_array["ret"] = '-9';
  } catch(Exception $e) {
    $response["status"] = "NG";
    $response["data"]   = $e->getMessage();
    $ret_array["ret"] = '-9';
  }

  return $ret_array;
}



?>
