File "area_events_regist.php"
Full path: /www/ansys/qgis/000_nasu/area_events/area_events_regist.php
File size: 13.24 KiB (13554 bytes)
MIME-type: text/x-php
Charset: utf-8
<?php
//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
// 自動でクラスを参照する
// 関数名 : __autoload()
// 備考 : 参照先は./class/XXX.phpとする
// 更新 : 2012/10/19 KMK-Teraoka
//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
function __autoload($className)
{
$fPath = "./class/" . str_replace("_", "/", $className) . ".php";
require_once $fPath;
}
//===============================================
// DEBUG_MODE
// 備考 :
// 更新 : 2012/11/02 KMK-Teraoka
//===============================================
define("DEBUG_MODE", "1");
Debug::setMode(DEBUG_MODE);
if (DEBUG_MODE == 1)
{
Stopwatch::start();
}
//===============================================
// CommonUtilities
// 備考 :
// 更新 : 2012/11/02 KMK-Teraoka
//===============================================
$PENTA_OCEAN = "五洋建設株式会社";
$TAIL_PENTA_OCEAN = "penta-ocean";
$SCRIPT_TITLE = "運行管理 -那須試験(沖縄)- イベントエリア";
$CONST_ID = 4;
$APP_ID = 3;
$TOP_FORM = "../index.php";
$REGIST_FORM = "./area_events_regist.php";
$LIST_FORM = "./area_events_list.php";
$EDIT_FORM = "./area_events_edit.php";
$VIEW_FORM = "./area_events_view.php";
$DELETE_FORM = "./area_events_delete.php";
$HOST = "192.168.100.153";
$DB = "ansys";
$USER = "postgres";
$PASS = "am#71ZJ*";
$AREA_EVENTS_TABLE = "qgis.area_events_list";
$WHERE_PATTERN = array(
"0" => array("name" => "登録ID", "object" => "list_id", "pattern" => "all"),
"1" => array("name" => "イベント名称", "object" => "events_name", "pattern" => "middle")
);
$VIEW_LIST = array(
"0" => array("head" => "登録ID", "object" => "list_id", "type" => "1", "control" => "txtListId"),
"1" => array("head" => "イベント名称", "object" => "events_name", "type" => "1", "control" => "txtEventsName"),
"2" => array("head" => "ファイル名称", "object" => "events_file", "type" => "1", "control" => "txtEventsFile"),
"3" => array("head" => "更新日時", "object" => "upddatetime", "type" => "0", "control" => "-"),
);
$PAGE_LIMIT = 30;
//===============================================
// HTML-HEAD-
// 備考 :
// 更新 : 2012/11/02 KMK-Teraoka
//===============================================
print "<html>";
print "<head>";
print "<meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">";
print "<link rel=\"stylesheet\" type=\"text/css\" href=\"/ansys/config/css/style.css\">";
print "<link rel=\"shortcut icon\" href=\"/ansys/config/favicon.ico\">";
print "<title>". $SCRIPT_TITLE. "</title>";
print "</head>";
//===============================================
// HTML-BODY部開始-
// 備考 :
// 更新 : 2012/11/02 KMK-Teraoka
//===============================================
print "<body>";
print "<center>";
print "<font size=\"3\">";
print "<b>";
print "". $SCRIPT_TITLE. "<br>";
print "【". $PENTA_OCEAN. "】";
print "</b>";
print "</font>";
print "</center>";
print "<hr />";
try
{
//================================================
// データベース接続
// 備考 :
// 更新 : 2012/11/02 KMK-Teraoka
//================================================
$conn = pg_connect("
host = ". $HOST. "
dbname = ". $DB. "
user = ". $USER. "
password= ". $PASS. "
");
if (!$conn)
{
throw new Exception("データベースへの接続に失敗しました");
}
//===============================================
// POST、GETパラメータの受け取り
// 備考 :
// 更新 : 2012/11/02 KMK-Teraoka
//===============================================
if (DEBUG_MODE == 1)
{
extract($_POST);
extract($_GET);
Debug::writes($_POST);
}
$selSearch = isset($_POST["selSearch"]) ? htmlspecialchars($_POST["selSearch"]) : "";
$txtSearchObj = isset($_POST["txtSearchObj"]) ? htmlspecialchars($_POST["txtSearchObj"]) : "";
$viewPage = isset($_POST["hPage"]) ? htmlspecialchars($_POST["hPage"]) : 1;
$btnUpdate = isset($_POST["btnUpdate"]) ? htmlspecialchars($_POST["btnUpdate"]) : "";
if (strcmp($btnUpdate, "確認") == 0)
{
$txtListId = isset($_POST["txtListId"]) ? htmlspecialchars($_POST["txtListId"]) : "";
if (strcmp($txtListId, "") == 0)
{
throw new Exception("登録IDが指定されていません");
}
else
{
if (!preg_match("/^[0-9]+$/", $txtListId))
{
throw new Exception("登録IDは半角数字のみにしてください");
}
}
$txtEventsName = isset($_POST["txtEventsName"]) ? htmlspecialchars($_POST["txtEventsName"]) : "";
if (strcmp($txtEventsName, "") == 0)
{
throw new Exception("イベント名称が入力されていません");
}
$txtEventsFile = isset($_POST["txtEventsFile"]) ? htmlspecialchars($_POST["txtEventsFile"]) : "";
if (strcmp($txtEventsFile, "") == 0)
{
throw new Exception("イベントファイル名称が入力されていません");
}
$confMode = 1;
$confValue = array(
"list_id" => $txtListId,
"events_name" => $txtEventsName,
"events_file" => $txtEventsFile,
"upddatetime" => ""
);
$mgrMsg = "下記内容で更新します<br />";
}
else if (strcmp($btnUpdate, "登録") == 0)
{
$regListId = isset($_POST["regListId"]) ? htmlspecialchars($_POST["regListId"]) : "";
$regEventsName = isset($_POST["regEventsName"]) ? htmlspecialchars($_POST["regEventsName"]) : "";
$regEventsFile = isset($_POST["regEventsFile"]) ? htmlspecialchars($_POST["regEventsFile"]) : "";
// 最新のlist_idを取得
$insData = "INSERT INTO ". $AREA_EVENTS_TABLE. " (";
$insData .= "list_id, const_id, app_id, events_name, events_file, del_flg, upddatetime, regdatetime";
$insData .= ") VALUES (";
$insData .= "'". $regListId. "', '". $CONST_ID. "', '". $APP_ID. "', '". $regEventsName. "', '". $regEventsFile. "', 'f', current_timestamp, current_timestamp";
$insData .= ")";
$insData .= ";";
Debug::write($insData);
if (!($resData = pg_query($conn, $insData)))
{
throw new Exception("データの登録に失敗しました<br />". $insData. "<br />". pg_last_error(). "<br />");
}
$confMode = 2;
$selectNewData = "SELECT * FROM ". $AREA_EVENTS_TABLE. "";
$selectNewData .= " WHERE list_id='". $regListId. "'";
$selectNewData .= " AND const_id='". $CONST_ID. "'";
$selectNewData .= " AND app_id='". $APP_ID. "'";
$selectNewData .= ";";
if (!($resNewData = pg_query($conn, $selectNewData)))
{
throw new Exception("最新データの取得に失敗しました<br />". $selectNewData. "<br />". pg_last_error(). "<br />");
}
$rowNewData = pg_fetch_array($resNewData, 0, PGSQL_ASSOC);
$mgrMsg = "ID[". $rowNewData["list_id"]. "]:エリアイベント登録を行いました<br />";
}
//===============================================
// 見出し
// 備考 : Table内TableでBorderを細くする
// 更新 : 2012/11/02 KMK-Teraoka
//===============================================
print "<table width=\"100%\" border=\"0\" bgcolor=\"#000000\" cellspacing=\"0\" cellpadding=\"0\">";
print "<tr>";
print "<td>";
print "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"3\">";
print "<tr bgcolor=\"#99CCFF\">";
print "<td align=\"left\">";
print "イベントエリア登録";
print "</td>";
print "</tr>";
print "</table>";
print "</td>";
print "</tr>";
print "</table>";
print "<br />";
//===============================================
// 管理メッセージの表示
// 備考 :
// 更新 : 2012/11/02 KMK-Teraoka
//===============================================
print "<font color=\"#FF0000\">";
print $mgrMsg;
print "</font>";
//===============================================
// 一覧の表示
// 備考 :
// 更新 : 2012/11/02 KMK-Teraoka
//===============================================
print "<form action=\"". $_SERVER['PHP_SELF']. "\" method=\"post\" style=\"display:inline\">";
print "<table width=\"45%\" border=\"0\" bgcolor=\"#000000\" cellspacing=\"0\" cellpadding=\"0\">";
print "<tr>";
print "<td>";
print "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"3\">";
for($iCount = 0; $iCount < count($VIEW_LIST); $iCount++)
{
print "<tr bgcolor=\"#FFFFFF\" align=\"left\">";
print "<td bgcolor=\"#99CCFF\" style=\"width:30%;height:25px;\">";
print $VIEW_LIST[$iCount]["head"];
print "</td>";
print "<td bgcolor=\"#FFFFFF\" style=\"width:70%\">";
switch($VIEW_LIST[$iCount]["type"])
{
case 0:
if ($confMode == 2)
{
print $rowNewData[$VIEW_LIST[$iCount]["object"]];
}
else
{
print "-";
}
break;
case 1:
if ($confMode == 1)
{
print $confValue[$VIEW_LIST[$iCount]["object"]];
}
else if ($confMode == 2)
{
print $rowNewData[$VIEW_LIST[$iCount]["object"]];
}
else
{
print "<input type=\"text\" name=\"". $VIEW_LIST[$iCount]["control"]. "\" value=\"". $VIEW_LIST[$iCount]["defval"]. "\" style=\"width:100%\" id=\"text\">";
}
break;
case 2:
if ($confMode == 1)
{
print $confValue[$VIEW_LIST[$iCount]["object"]];
}
else if ($confMode == 2)
{
print $rowNewData[$VIEW_LIST[$iCount]["object"]];
}
else
{
print "<input type=\"text\" name=\"". $VIEW_LIST[$iCount]["control"]. "_y\" value=\"\" style=\"width:34px;ime-mode:inactive\" maxlength=\"4\" id=\"text\">";
print "-";
print "<input type=\"text\" name=\"". $VIEW_LIST[$iCount]["control"]. "_m\" value=\"\" style=\"width:21px;ime-mode:inactive\" maxlength=\"2\" id=\"text\">";
print "-";
print "<input type=\"text\" name=\"". $VIEW_LIST[$iCount]["control"]. "_d\" value=\"\" style=\"width:21px;ime-mode:inactive\" maxlength=\"2\" id=\"text\">";
print " ";
print "<input type=\"text\" name=\"". $VIEW_LIST[$iCount]["control"]. "_h\" value=\"\" style=\"width:21px;ime-mode:inactive\" maxlength=\"2\" id=\"text\">";
print ":";
print "<input type=\"text\" name=\"". $VIEW_LIST[$iCount]["control"]. "_i\" value=\"\" style=\"width:21px;ime-mode:inactive\" maxlength=\"2\" id=\"text\">";
print ":";
print "<input type=\"text\" name=\"". $VIEW_LIST[$iCount]["control"]. "_s\" value=\"\" style=\"width:21px;ime-mode:inactive\" maxlength=\"2\" id=\"text\">";
}
break;
case 3:
if ($confMode == 2)
{
print $rowNewData[$VIEW_LIST[$iCount]["object"]];
}
else
{
print "-";
}
break;
case 4:
if ($confMode == 1)
{
print $confValue[$VIEW_LIST[$iCount]["object"]];
}
else if ($confMode == 2)
{
print $rowNewData[$VIEW_LIST[$iCount]["object"]];
}
else
{
print "<input type=\"checkbox\" name=\"". $VIEW_LIST[$iCount]["control"]. "\" value=\"1\" id=\"text\">";
}
break;
default:
throw new Exception("リストに存在しません");
break;
}
print "</td>";
print "</tr>";
}
print "</table>";
print "</td>";
print "</tr>";
print "</table>";
//===============================================
// 確認、登録ボタン
// 備考 :
// 更新 : 2012/11/02 KMK-Teraoka
//===============================================
if ($confMode == 1)
{
print "<input type=\"submit\" name=\"btnUpdate\" value=\"登録\" style=\"width:60px\" id=\"submit_button\">";
print " ";
print "<input type=\"submit\" name=\"btnUpdate\" value=\"修正\" style=\"width:60px\" id=\"submit_button\">";
print "<input type=\"hidden\" name=\"regListId\" value=\"". $confValue["list_id"]. "\">";
print "<input type=\"hidden\" name=\"regEventsName\" value=\"". $confValue["events_name"]. "\">";
print "<input type=\"hidden\" name=\"regEventsFile\" value=\"". $confValue["events_file"]. "\">";
print "<br />";
}
else if($confMode == 2)
{
}
else
{
print "<input type=\"submit\" name=\"btnUpdate\" value=\"確認\" style=\"width:60px\" id=\"submit_button\">";
print "<br />";
}
print "<input type=\"hidden\" name=\"selSearch\" value=\"". $selSearch. "\">";
print "<input type=\"hidden\" name=\"txtSearchObj\" value=\"". $txtSearchObj. "\">";
print "<input type=\"hidden\" name=\"hPage\" value=\"". $viewPage. "\">";
print "</form>";
print "<br />";
}
catch(Exception $exe)
{
print "<font color=\"#FF0000\">";
print "【スクリプトエラー】<br />";
print $exe->getMessage(). "<br />";
print "</font>";
}
//===============================================
// 一覧へ戻るリンク
// 備考 :
// 更新 : 2012/11/02 KMK-Teraoka
//===============================================
print "<form name=\"listForm\" method=\"post\" action=\"". $LIST_FORM. "\" style=\"display:inline\">";
print "<a href=\"javascript:listForm.submit()\">一覧</a>";
print "<input type=\"hidden\" name=\"selSearch\" value=\"". $selSearch. "\">";
print "<input type=\"hidden\" name=\"txtSearchObj\" value=\"". $txtSearchObj. "\">";
print "<input type=\"hidden\" name=\"hPage\" value=\"". $viewPage. "\">";
print "</form>";
//===============================================
// Postgresql終了処理
// 備考 :
// 更新 : 2012/11/02 KMK-Teraoka
//===============================================
pg_close($conn);
//===============================================
// HTML終了処理
// 備考 :
// 更新 : 2012/11/02 KMK-Teraoka
//===============================================
print "<hr />";
print "<font size=\"3\" color=\"#000000\" face=\"Arial\">";
print "<center>";
print "<b>";
print "<i>";
print $TAIL_PENTA_OCEAN;
print "</i>";
print "</b>";
print "</center>";
print "</font>";
print "</body>";
print "</html>";
?>