<?php

/*
name  : getPopupCount
func  : 件数確認 200件超えたらエラー
io    : $sql, $dbutil, $whereParams
return: 0=OK, -1=データなし, -2=200件超える
*/
function getPopupCount($dbutil, $sql, $whereParams) {
$logger = new logger(basename(__FILE__));
$logger->info("getPopupCount>>",$sql);

  $retarray = array(
    "ret" => 0,
    "msg" => "検索結果が200行を超えています。\n条件を見直し、再検索してください。",
  );

  $sqlmain = "select count(*) as cnt from (".$sql.")";
  $result = $dbutil->select($sqlmain, $whereParams);
  $dcnt = intval($result[0]["cnt"]);
  if ($dcnt == 0) {
    $retarray["ret"] = -1;
  } else if($dcnt > 200) {
    $retarray["ret"] = -2;
  } else {  //データ有, 200件まで
    $retarray["ret"] = 0;
  }

  return $retarray;
}

/*
name   : getPopupAfm02x
func   : jan検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAfm02x($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;
    global $dbutil;

    //明細取得
    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAfm02x.sql";
    $logger->info("FILE", $file);
    //条件
    $whereParams = array();
    $whereParams["jan"]      = $data["jan"];
    $whereParams["vjan"]     = $data["vjan"];
    $whereParams["gdjnm"]    = $data["gdjnm"];
    $whereParams["mcd"]      = $data["mcd"];
    $whereParams["mnm"]      = $data["mnm"];
    $whereParams["gdcls9"]   = $data["gdcls9"];
    $whereParams["stpflg"]   = $data["stpflg"];

    $sql = file_get_contents($file);    //sql取得

    if($data["ord"] == "jan") {
      $sql = $sql . " order by a.jan";
    } else if ($data["ord"] == "vjan") {
      $sql = $sql . " order by a.vjan";
    }


//$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

//  return $result;
  return $ret_Array;
}

/*
name   : getPopupAfm02x1
func   : jan検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAfm02x1($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;
    global $dbutil;

    //明細取得
    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAfm02x1.sql";
    $logger->info("FILE", $file);
    //条件
    $whereParams = array();
    $whereParams["jan"]      = $data["jan"];
    $whereParams["stpflg"]   = $data["stpflg"];

    $sql = file_get_contents($file);    //sql取得

//$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

//  return $result;
  return $ret_Array;
}


/*
name   : getPopupAfm03x
func   : cucd検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAfm03x($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAfm03x.sql";

    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["ccd"]      = $data["ccd"];    //cucd
    $whereParams["cnm"]      = $data["cnm"];
    $whereParams["zip"]      = $data["zip"];
    $whereParams["sadd"]     = $data["add"];
    $whereParams["tel"]      = $data["tel"];
    $whereParams["fax"]      = $data["fax"];
    $whereParams["stpflg"]   = $data["stpflg"];

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

//  return $result;
  return $ret_Array;
}

/*
name   : getPopupAfm03x1
func   : cucd選択用ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAfm03x1($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAfm03x1.sql";

    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["ccd"]      = $data["ccd"];    //cucd
    $whereParams["stpflg"]   = $data["stpflg"];

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

//  return $result;
  return $ret_Array;
}

/*
name   : getPopupAfm032x
func   : cucd検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAfm032x($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAfm032x.sql";

    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["ccd"]      = $data["ccd"];    //cucd
    $whereParams["cd"]       = $data["cd"];    //cuscd
    $whereParams["nm"]       = $data["nm"];
    $whereParams["zip"]      = $data["zip"];
    $whereParams["sadd"]     = $data["add"];
    $whereParams["tel"]      = $data["tel"];
    $whereParams["fax"]      = $data["fax"];
    $whereParams["cshcd"]    = $data["cshcd"];
    $whereParams["spcat"]    = $data["spcat"];
    $whereParams["splnk"]    = $data["splnk"];
    $whereParams["shflg"]    = $data["shflg"];
    $whereParams["cuclcls"]  = $data["cuclcls"];
    $whereParams["stpflg"]   = $data["stpflg"];

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

//  return $result;
  return $ret_Array;
}

/*
name   : getPopupAfm032x1
func   : cucd検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAfm032x1($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAfm032x1.sql";

    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["ccd"]      = $data["ccd"];    //cucd
    $whereParams["cd"]       = $data["cd"];    //cuscd
    $whereParams["stpflg"]   = $data["stpflg"];

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

//  return $result;
  return $ret_Array;
}

/*
name   : getPopupAfm036x
func   : cshcd検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAfm036x($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAfm036x.sql";
    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["ccd"]     = $data["ccd"];
    $whereParams["cd"]      = $data["cd"];
    $whereParams["nm"]      = $data["nm"];
    $whereParams["zip"]     = $data["zip"];
    $whereParams["sadd"]    = $data["add"];
    $whereParams["tel"]     = $data["tel"];
    $whereParams["fax"]     = $data["fax"];

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

//  return $result;
  return $ret_Array;
}

/*
name   : getPopupAfm03cx
func   : オンライン識別子検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAfm03cx($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAfm03cx.sql";
    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["cd"]      = $data["cd"];

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

//  return $result;
  return $ret_Array;
}

/*
name   : getPopupAfm04x
func   : mcd検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAfm04x($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAfm04x.sql";
    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["cd"]      = $data["cd"];
    $whereParams["nm"]      = $data["nm"];
    $whereParams["zip"]      = $data["zip"];
    $whereParams["madd"]      = $data["add"];
    $whereParams["tel"]      = $data["tel"];
    $whereParams["fax"]      = $data["fax"];
    $whereParams["stpflg"]   = $data["stpflg"];

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }

  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

//  return $result;
  return $ret_Array;
}

/*
name   : getPopupAfm05x
func   : ktktcd検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAfm05x($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAfm05x.sql";
    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["cd"]     = $data["cd"];
    $whereParams["nm"]     = $data["nm"];
    $whereParams["zip"]    = $data["zip"];
    $whereParams["ad"]     = $data["add"];
    $whereParams["tel"]    = $data["tel"];
    $whereParams["fax"]    = $data["fax"];
    $whereParams["ktcls"]  = $data["ktcls"]; // null,0,1 -> all OK, 2:ktcls in (02,70,04)
    $whereParams["stpflg"] = $data["stpflg"];

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

//  return $result;
  return $ret_Array;
}

/*
name   : getPopupAfm08x
func   : chgcd検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAfm08x($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAfm08x.sql";
    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["chgnm"]      = $data["nm"];
    $whereParams["chgcd"]      = $data["cd"];
    $whereParams["stpflg"]   = $data["stpflg"];

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

//  return $result;
  return $ret_Array;
}

/*
name   : getPopupAfm90x
func   : 雑マスタ検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAfm90x($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAfm90x.sql";
    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["cls"] = $data["cls"];
    $whereParams["scls1"] = $data["scls1"];
    $whereParams["scls2"] = $data["scls2"];
    $whereParams["nm"] = $data["nm"];

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

  return $ret_Array;
}


/*
name   : getPopupAf203x1
func   : 受注入力 複写伝票選択ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAf203x1($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAf203x1.sql";
    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["cucd"]  = $data["cucd"];
    $whereParams["cuscd"] = $data["cuscd"];
    $whereParams["wseq"]  = $data["wseq"];

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

  return $ret_Array;
}

/*
name   : getPopupAf203x2
func   : 受注入力 伝票検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAf203x2($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAf203x2.sql";
    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["cucd"]  = $data["cucd"];
    $whereParams["cuscd"] = $data["cuscd"];
    $whereParams["vseq"]  = $data["vseq"];
    $whereParams["jdats"] = $data["jdats"];
    $whereParams["jdate"] = $data["jdate"];
    $whereParams["chgcd"] = $data["chgcd"];
    $whereParams["ktktcd"] = $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["LGKTKTCD"];
    $whereParams["spktcd"] = $data["spktcd"];

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

  return $ret_Array;
}

/*
name   : getPopupAf212x1
func   : 発注番号検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAf212x1($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAf212x1.sql";
    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["ktktcd"] =  $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["LGKTKTCD"];
    $whereParams["spktcd"] = $data["spktcd"];
    $whereParams["dat1s"]  = $data["dat1s"];
    $whereParams["dat1e"]  = $data["dat1e"];
    $whereParams["mcd"]    = $data["mcd"];
    $whereParams["pmode"]  = $data["mode"]; //null or 0 -> 発注入力から, else -> 直送発注入力から


    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

  return $ret_Array;
}

/*
name   : getPopupAf215x1
func   : 受注入力 複写伝票選択ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAf215x1($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAf215x1.sql";
    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["cucd"]  = $data["cucd"];
    $whereParams["cuscd"] = $data["cuscd"];
    $whereParams["wseq"]  = $data["wseq"];

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

  return $ret_Array;
}

/*
name   : getPopupAf222x1
func   : 売上伝票検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAf222x1($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAf222x1.sql";
    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["ktktcd"] = $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["LGKTKTCD"];
    $whereParams["cucd"]  = $data["cucd"];
    $whereParams["cuscd"] = $data["cuscd"];
    $whereParams["vseq"]  = $data["vseq"];
    $whereParams["cls"]  = $data["cls"];
    $whereParams["adats"]  = $data["adats"];
    $whereParams["adate"]  = $data["adate"];
    $whereParams["spktcd"]  = $data["spktcd"];
    $whereParams["tcls"]  = $data["tcls"];
    $whereParams["pmode"]  = $data["pmode"];
    $whereParams["pmode2"]  = $data["pmode2"];

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

  return $ret_Array;
}

/*
name   : getPopupAf233x1
func   : 仕入伝票検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAf233x1($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAf233x1.sql";
    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["ktktcd"] = $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["LGKTKTCD"];
    $whereParams["mcd"]  = $data["mcd"];
    $whereParams["vseq"]  = $data["vseq"];
    $whereParams["dat1s"]  = $data["dat1s"];
    $whereParams["dat1e"]  = $data["dat1e"];
    $whereParams["spktcd"]  = $data["spktcd"];
    $whereParams["pmode2"]  = $data["pmode2"];

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info("getPopupAf233x1>>".$sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

  return $ret_Array;
}

/*
name   : getPopupAf241x1
func   : 得意先返品伝票検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAf241x1($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    if ($data["pmode"] == "W") {  //伝票重複の時
      $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAf241x1W.sql";
    } else {
      $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAf241x1.sql";
    }
    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams = array();
    $whereParams["ktktcd"] = $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["LGKTKTCD"];
    $whereParams["cucd"]  = $data["cucd"];
    $whereParams["cuscd"] = $data["cuscd"];
    $whereParams["vseq"]  = $data["vseq"];
    if ($data["pmode"] == "W") {  //伝票重複の時
      $whereParams["sts"]  = $data["sts"];
      $whereParams["sbat"]  = $data["sbat"];
    } else {
      $whereParams["dat1s"]  = $data["dat1s"];
      $whereParams["dat1e"]  = $data["dat1e"];
      $whereParams["spktcd"]  = $data["spktcd"];
    }
    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info("getPopupAf241x1>>".$sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

  return $ret_Array;
}

/*
name   : getPopupAf244x1
func   : 仕入先返品伝票検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAf244x1($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    if ($data["pmode"] == "W") {  //伝票重複の時
      $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAf244x1w.sql";
    } else {
      $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAf244x1.sql";
    }

    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams = array();
    $whereParams["ktktcd"] = $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["LGKTKTCD"];
    $whereParams["mcd"]  = $data["mcd"];
    $whereParams["spktcd"]  = $data["spktcd"];
    $whereParams["vseq"]  = $data["vseq"];
    if ($data["pmode"] == "W") {  //伝票重複の時
    } else {
      $whereParams["dat1s"]  = $data["dat1s"];
      $whereParams["dat1e"]  = $data["dat1e"];
    }

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info("getPopupAf241x1>>".$sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

  return $ret_Array;
}

/*
name   : getPopupAf251x1
func   : 売上伝票検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAf251x1($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAf251x1.sql";
    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["ktktcd"]  = $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["LGKTKTCD"];
    $whereParams["vdat"]    = $data["vdat"];
    $whereParams["spktcd1"] = $data["spktcd1"];
    $whereParams["spktcd2"] = $data["spktcd2"];
    $whereParams["jan"]     = $data["jan"];
    $whereParams["vseq"]    = $data["vseq"];

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

  return $ret_Array;
}

/*
name   : getPopupAf254x1
func   : 売上伝票検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAf254x1($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAf254x1.sql";
    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["ktktcd"]  = $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["LGKTKTCD"];
    $whereParams["dat"]     = $data["dat"];
    $whereParams["spktcd1"] = $data["spktcd1"];
    $whereParams["spktcd2"] = $data["spktcd2"];
    $whereParams["jan"]     = $data["jan"];

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

  return $ret_Array;
}

/*
name   : getPopupAf265x1
func   : 入金伝票検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAf265x1($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAf265x1.sql";
    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["ktktcd"] = $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["LGKTKTCD"];
    $whereParams["cucd"]  = $data["cucd"];
    $whereParams["cuscd"] = $data["cuscd"];
    $whereParams["vseq"]  = $data["vseq"];
    $whereParams["adats"]  = $data["adats"];
    $whereParams["adate"]  = $data["adate"];

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info($sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

  return $ret_Array;
}

/*
name   : getPopupAf271x1
func   : 支払入力検索ポップアップ
io     : $data
return : 一覧データ
*/
function getPopupAf271x1($data) {
  $logger = new logger(basename(__FILE__));
  $logger->info("util>>",$data);

  $sdday = null;
  try {
    global $serverUtil;
    global $stringUtil;

    $file = $serverUtil->getProjectDir() . "/util/sql/popup/getPopupAf271x1.sql";
    $logger->info("FILE", $file);
    global $dbutil;
    //条件
    $whereParams["ktktcd"] = $_SESSION[$GLOBALS['SYSTEM_NAME_EN']]["LGKTKTCD"];
    $whereParams["mcd"]  = $data["mcd"];
    $whereParams["vseq"]  = $data["vseq"];
    $whereParams["dat1s"]  = $data["dat1s"];
    $whereParams["dat1e"]  = $data["dat1e"];

    $sql = "";
    $sql = file_get_contents($file);    //sql取得
$logger->info("getPopupAf271x1>>".$sql, $whereParams);
    $result = $dbutil->select($sql, $whereParams);

    if ($stringUtil->isEmpty($result)) {
      $ret_Array[0]['ret'] = '-1';
    } else {
      $ret_Array = $result;
      $i = 0;
      foreach ($ret_Array as $data) {
        $ret_Array[$i]['ret'] = '0';
        $i++;
      }
      $ret_Array[0]['ret'] = '0';
    }
  } catch(userException $ue) {
    $dbutil->rollback();
    $ret_Array['0']['ret'] = '-2';
    $ret_Array['0']['code'] = $ue->getErrorCode();
    $ret_Array['0']['msg']  = $ue->getErrorMessage();
  } catch(Exception $e) {
    $dbutil->rollback();
  }

  return $ret_Array;
}

?>
