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

$logger = new logger(basename(__FILE__));
$logger->info("=== af292x_index_start ===");

//$assign_var["noeventClassHeader"] = "";
//$assign_var["noeventClassBody"]   = "noevent";

//コンボボックス作成
$listutil = null;
$listutil = new getListUtil();
$assign_var["listGdcls9"] = $listutil->getListAfm90('6'); //改廃区分

//POPUP
$assign_var["hasPopKtktcd"]="1";
$assign_var["hasPopJan"]="1";
$assign_var["hasPopScls90"] = "1"; //afm90
$assign_var["hasPopAf05m"] = "1"; 

$header = array();


try {
  global $dbutil;

  // SQL実行
  $whereParams=array();
  $sql = file_get_contents("./sql/getLblcls.sql");
  
  $result = $dbutil->select($sql, $whereParams);
  if ($result == null) {
    $header["lblcls"] = "(修正区分の登録がありません)";
  } else {

    $cnt = 1;
    $header["lblcls"] = "(";
    foreach($result as $key => $val) {
      if($cnt > 1) {
        $header["lblcls"] = $header["lblcls"].",";
      }
      $header["lblcls"] = $header["lblcls"].$val["scls1"].':'.$val["nm"];
      $cnt = $cnt + 1;
    }
    if($cnt>1) {
      $header["lblcls"] = $header["lblcls"].")";
    } else {
      $header["lblcls"] = $header["lblcls"]."修正区分の登録がありません)";
    }
  }


} catch(userException $ue) {
  $retData["code"]  = $ue->getErrorCode();
  $retData["msg"]   = $ue->getErrorMessage();
  $response["status"] = "NG";
  $response["data"]   = $retData;
} catch(Exception $e) {
  $response["status"] = "NG";
  $response["data"]   = $e->getMessage();
}

$assign_var["header"] = $header;
$assign_var["lblclslist"] = json_encode($result);  //登録前のチェックで区分をチェックするために持っておくよう

// 初期表示
$gInit_array = array( //初期値
  "orgpno" => '0',
  "newpno" => '0',
);

//$assign_var["data"] = $gInit_array;
$assign_var["init_data"] = json_encode($gInit_array);

$logger->info('assign_var',$assign_var);

//Smartyへアサイン
$smarty->assign($assign_var);
$smarty->display("index");

$logger->info("=== af292x_index_end ===");
?>
