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

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

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

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

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

      $sql = file_get_contents("./sql/callAf830s.sql");
      $whereParams = array();
      $whereParams["ktktcd"]["in"] = $ktktcd;
      $whereParams["cudt"]["in"] = $header["cudt"];
      $whereParams["cdat"]["in"] = $header["cdat"];
      $whereParams["ret"]["out"] = "";
      $result = $dbutil->call($sql,$whereParams);
$logger->info("retAf830s",$result);

      $ret = $result["ret"];
      
      if($ret != '0') {
        if($ret == '-1') {
          $msg = "請求訂正中の請求先が含まれています。";
        } else if($ret == '-8') {
          $msg = "他の端末で実行中です。";
        } else {
          $msg = "エラーが発生しました。(".$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;
  }


?>
