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

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

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

$listutil = null;

$logger->info('post', $_POST['area']);
// 再ページ読込用
$header = Array();
foreach($_POST as $key => $val) {
  $header[$key] = $val;
}

//コンボボックス作成
  $listutil = null;
  $listutil = new getListUtil();
  $assign_var["listAprf"] = $listutil->getlistAprf();    //都道府県

//POPUP
$assign_var["listSearchKbn"] = $cbo_searchkbn;
$assign_var["hasPopArea"] = "1";
$assign_var["listAprf1"] = $listutil->getlistAxm90("7");
$assign_var["hasPopAt906e"] = "1";

try {

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


  // POSTの情報を取得する
  $whereParams["area"] = $_POST["area"];

  // SQL実行
  $sql = file_get_contents("./sql/search.sql");
  $result = $dbutil->select($sql, $whereParams);
  if ($result == null) {
    $assign_var["isNoData"] = true;
    // 1:新規, 2:修正, 3:削除
    $header["smode"] = '1';
  } else {
    $dataList = $result[0];

    // 1:新規, 2:修正
    $header["smode"] = '2';
    $assign_var["isNoData"] = false;
    $assign_var["data"] = $dataList;
  }

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

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

  $assign_var["hasError"] = true;
  $assign_var["errorMsg"] = $e->getMessage();

}

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

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

$smarty->display("index");

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