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

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

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

    try {
      $cnt = 0;
      $ins_cnt = 0;

      //ヘッダー情報(検索条件)
      $ktktcd = $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["LGKTKTCD"];


      //入力月度から、sbatを取得
      $sql = file_get_contents("./sql/callGet_sbat2.sql");
      $whereParams=array();
      $whereParams["ktktcd"] = $ktktcd;
      $whereParams["dats"]   = $header["dats"];
      $retSbat = $dbutil->select($sql, $whereParams);
      $sbat = $retSbat[0]["sbat"];


      $sql = file_get_contents("./sql/callFm_AF481X_Get.sql");   //afw85 insert (チェック行)
      $wseq = $dbutil->nextVal("innerwseq");
      $whereParams = array();
      $whereParams["wseq"]["in"]   = $wseq;
      $whereParams["ktktcd"]["in"] = $ktktcd;
      $whereParams["sbat"]["in"]   = $sbat;
      $whereParams["cucd"]["in"]   = $header["cucd"];
      $whereParams["ret"]["out"]   = "";

      $retPlsql = $dbutil->call($sql, $whereParams);
      $ret = $retPlsql["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;
    $ret_array["sbat"] = $sbat;

    return $ret_array;
  }



?>
