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

/**
 * af2a4x共通カスタム関数
 */

/*
execProc
*/
function execProc($dbutil, $data){
  $logger = new logger(basename(__FILE__));
    global $stringUtil;
$logger->info("execProc>>",$data);
    $ret_array = array(
      "ret" => "0", //0:OK, -9:プリンタ登録エラー
      "msg" => "",
      "wseq" => "",
    );
    $ret = '0';

    try {
      $cnt = 0;
      $ins_cnt = 0;
    
      $header = $data["header"][0];
    
      foreach($data["data"] as $detail) {
        $whereParams = array();
        $whereParams["ktktcd"] = $detail["ktktcd"];
        $whereParams["tday"]   = $detail["tday"];
        $sql_upd05 = file_get_contents("./sql/updateAfm05.sql"); 
        $result = $dbutil->update($sql_upd05, $whereParams);
      }
      $dbutil->commit();
    

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

      $sql = file_get_contents("./sql/callAf862s.sql"); //commitはplsql内で行うらしい
      $whereParams = array();
      $whereParams["ktktcd"]["in"] = $ktktcd;
      $whereParams["ret"]["out"] = "";
      $result = $dbutil->call($sql,$whereParams);
$logger->info("retAf862s",$result);

      $ret = $result["ret"];


    } catch(userException $ue) {
      $ret = '-999';
      $msg = $ue->getErrorMessage();
    } catch(Exception $e) {
      $ret = '-999';
      $msg = $e->getMessage();
    }

    $ret_array["ret"] = $ret;
    $ret_array["msg"] = $msg;
    $ret_array["wseq"] = $wseq;

    return $ret_array;
  }


?>
