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

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

$response["status"] = "OK";

$listutil = null;

// 再ページ読込用
$header = Array();
foreach($_POST as $key => $val) {
  $header[$key] = $val;
}
$logger->info('data>>',$header);
//コンボボックス作成
$listutil = null;
$listutil = new getListUtil();
$assign_var["listMhno"] = $listutil->getlistAfm90('T'); //区分

//POPUP
$assign_var["hasPopAf993m"] = "1";

try {
  $assign_var["noeventClassHeader"] = "";
  $assign_var["noeventClassBody"]   = "";

  //権限名
  $lblName = Array();
  $sql = file_get_contents("./sql/getLabel.sql");
  $result = $dbutil->select($sql);
$logger->info('lbl>>',$result);
  if ($result != null) {
    foreach ($result as $key => $detail) {
      $lblName['lbl'.$detail['cd']] = $detail['nm'];
    }
  }

  // sqlの条件を設定する
  $whereParams = array();
  $whereParams["mhno"] = $header["mhno"];
  $sql = file_get_contents("./sql/search.sql");
  $logger->info("whereParams",$whereParams);
  $result = $dbutil->select($sql, $whereParams);
  if ($result == null) {
    $assign_var["isNoData"] = false;
    $assign_var["noeventClassHeader"] = "noevent";
    $assign_var["noeventClassBody"]   = "";
    $assign_var["dataList"] = $dataList;
  } else {
    $assign_var["noeventClassHeader"] = "noevent";
    $assign_var["noeventClassBody"]   = "";
    $dataList = $result;

    $assign_var["isNoData"] = false;
    $assign_var["dataList"] = $dataList;
  }

  $logger->info('head', $header);
  $assign_var["header"] = $header;
  $assign_var["label"] = $lblName;

} catch(userException $ue) {
  $dbutil->rollback();
  $assign_var["hasError"] = true;
  $assign_var["errorMsg"] = $ue->getMessage();
  $assign_var["noeventClassHeader"] = "";
  $assign_var["noeventClassBody"]   = "noevent";
  $assign_var["header"] = $header;
} catch(Exception $e) {
  $dbutil->rollback();

  $assign_var["hasError"] = true;
  $assign_var["errorMsg"] = $e->getMessage();
  $assign_var["noeventClassHeader"] = "";
  $assign_var["noeventClassBody"]   = "noevent";
  $assign_var["header"] = $header;
}

//$logger->info("smarty", $assign_var);

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

$smarty->display("index");

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