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

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

/*
  商品情報取得
*/
function chkRegBefore($dbutil, $data){
$logger = new logger(basename(__FILE__));
  global $stringUtil;
$logger->info("chkRegBefore>>",$data);
  $ret_array = array(
    "ret" => "0", //0:OK, -1:マスタと重複
  );
  $ret = '0';

  $valutil = new getValueUtil();

  $header = $data["header"][0];
  $dataList = $data["data"];

  foreach($dataList as $detail) {
    $whereParams = array();

    $logger->info("cntAfm90_detail",$detail);
      
    $whereParams["cls"]=$header["cls"];
    $whereParams["scls1"]=$detail["scls1"];
    $whereParams["scls2"]=$detail["scls2"];
    $whereParams["scls3"]=$detail["scls3"];
    $whereParams["scls4"]=$detail["scls4"];
    $sql = file_get_contents("./sql/cntAfm90.sql");
    
    $logger->info("cntAfm90".$sql,$whereParams);
    $ret_cnt = $dbutil->select($sql, $whereParams);
    $logger->info("result_cntAfm90",$ret_cnt);

    if($ret_cnt[0]["cnt"] != '0') {
      $ret = '-1';
      $dupliScls1=$detail["scls1"];
      $dupliScls2=$detail["scls2"];
      $dupliScls3=$detail["scls3"];
      $dupliScls4=$detail["scls4"];
      $orgScls1=$detail["orgScls1"];
      $orgScls2=$detail["orgScls2"];
      $orgScls3=$detail["orgScls3"];
      $orgScls4=$detail["orgScls4"];
      break;
    }
  }

  $ret_array["ret"] = $ret;
  $ret_array["dupliScls1"] = $dupliScls1;
  $ret_array["dupliScls2"] = $dupliScls2;
  $ret_array["dupliScls3"] = $dupliScls3;
  $ret_array["dupliScls4"] = $dupliScls4;
  $ret_array["orgScls1"] = $orgScls1;
  $ret_array["orgScls2"] = $orgScls2;
  $ret_array["orgScls3"] = $orgScls3;
  $ret_array["orgScls4"] = $orgScls4;

  return $ret_array;
}

?>
