File "area_regist.php"
Full path: /www/ansys/qgis/000_nasu/area_events/area_regist.php
File size: 20.53 KiB (21023 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;
}
//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
// メッセージ一覧を取得する
// 関数名 : getMessagesList
// 備考 :
// 更新 : 2013/04/08 KMK-Teraoka
//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
function getMessagesList($conn_)
{
$ret = array();
$selectMsg = "SELECT msg_id, msg_info, msg_file_name FROM apc_common.messages";
$selectMsg .= ";";
Debug::write($insData);
if (!($resMsg = pg_query($conn_, $selectMsg)))
{
return -1;
}
$row = pg_num_rows($resMsg);
$ret[0]["msg_id"] = "-1";
$ret[0]["msg_info"] = "利用しない";
$ret[0]["msg_file_name"] = "-";
for($iCount = 0; $iCount < $row; $iCount++)
{
$rowMsg = pg_fetch_array($resMsg, $iCount, PGSQL_ASSOC);
$ret[$iCount + 1]["msg_id"] = $rowMsg["msg_id"];
$ret[$iCount + 1]["msg_info"] = $rowMsg["msg_info"];
$ret[$iCount + 1]["msg_file_name"] = $rowMsg["msg_file_name"];
}
return $ret;
}
//===============================================
// 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
//===============================================
$eventsName = isset($_POST["events_name"]) ? htmlspecialchars($_POST["events_name"]) : "";
$PENTA_OCEAN = "五洋建設株式会社";
$TAIL_PENTA_OCEAN = "penta-ocean";
$SCRIPT_TITLE = "エリア編集 -". $eventsName. "-";
$CONST_ID = 4;
$APP_ID = 3;
$REGIST_FORM = "./area_regist.php";
$LIST_FORM = "./area_list.php";
$EDIT_FORM = "./area_edit.php";
$VIEW_FORM = "./area_view.php";
$DELETE_FORM = "./area_delete.php";
$HOST = "192.168.100.153";
$DB = "ansys";
$USER = "postgres";
$PASS = "am#71ZJ*";
$AREA_TABLE = "qgis.area_list";
$MESSAGES_TABLE = "apc_common.messages";
$WHERE_PATTERN = array(
"0" => array("name" => "エリアID", "object" => "area_id", "pattern" => "all"),
);
$VIEW_LIST = array(
"0" => array("head" => "形式", "object" => "format", "type" => "3", "control" => "selectFormat", "defval" => "-"),
"1" => array("head" => "優先度", "object" => "priority", "type" => "3", "control" => "selectPriority", "defval" => "-"),
"2" => array("head" => "メッセージ1", "object" => "msg_id1", "type" => "3", "control" => "selectMsg1", "defval" => "-"),
"3" => array("head" => "メッセージ2", "object" => "msg_id2", "type" => "3", "control" => "selectMsg2", "defval" => "-"),
"4" => array("head" => "メッセージ3", "object" => "msg_id3", "type" => "3", "control" => "selectMsg3", "defval" => "-"),
"5" => array("head" => "メッセージ4", "object" => "msg_id4", "type" => "3", "control" => "selectMsg4", "defval" => "-"),
"6" => array("head" => "間隔[ms]", "object" => "msg_interval", "type" => "1", "control" => "txtInterval", "defval" => "0"),
"7" => array("head" => "無効[ms]", "object" => "msg_invalid", "type" => "1", "control" => "txtInvalid", "defval" => "10000"),
"8" => array("head" => "頂点数", "object" => "rect_vertex", "type" => "1", "control" => "txtRectVertex", "defval" => "4"),
"9" => array("head" => "備考", "object" => "remarks", "type" => "1", "control" => "txtRemarks", "defval" => ""),
"10" => array("head" => "更新時間", "object" => "upddatetime", "type" => "0", "control" => "-", "defval" => "-"),
);
$FORMAT_LIST = array(
"0" => array("value" => "1", "view" => "侵入時発生(矩形)"),
);
$PRIORITY_LIST = array(
"0" => array("value" => "1", "view" => "警告"),
);
$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("データベースへの接続に失敗しました");
}
//===============================================
// メッセージ一覧を取得する
// 備考 :
// 更新 : 2013/04/08 KMK-Teraoka
//===============================================
$msgList = getMessagesList($conn);
//===============================================
// POST、GETパラメータの受け取り
// 備考 :
// 更新 : 2012/11/02 KMK-Teraoka
//===============================================
if (DEBUG_MODE == 1)
{
extract($_POST);
extract($_GET);
Debug::writes($_POST);
}
$listId = isset($_POST["list_id"]) ? htmlspecialchars($_POST["list_id"]) : "";
if (strcmp($listId, "") == 0)
{
throw new Exception("登録IDが指定されていません");
}
$btnUpdate = isset($_POST["btnUpdate"]) ? htmlspecialchars($_POST["btnUpdate"]) : "";
if (strcmp($btnUpdate, "確認") == 0)
{
$selectFormat = isset($_POST["selectFormat"]) ? htmlspecialchars($_POST["selectFormat"]) : "";
$selectPriority = isset($_POST["selectPriority"]) ? htmlspecialchars($_POST["selectPriority"]) : "";
$selectMsg1 = isset($_POST["selectMsg1"]) ? htmlspecialchars($_POST["selectMsg1"]) : "";
$selectMsg1 = isset($_POST["selectMsg1"]) ? htmlspecialchars($_POST["selectMsg1"]) : "";
$selectMsg1 = isset($_POST["selectMsg1"]) ? htmlspecialchars($_POST["selectMsg1"]) : "";
$selectMsg1 = isset($_POST["selectMsg1"]) ? htmlspecialchars($_POST["selectMsg1"]) : "";
$txtInterval = isset($_POST["txtInterval"]) ? htmlspecialchars($_POST["txtInterval"]) : "";
if (strcmp($txtInterval, "") == 0)
throw new Excption("メッセージ間隔が指定されていません");
else
if (!preg_match("/^[0-9]+$/", $txtInterval))
throw new Exception("メッセージ間隔は半角数字のみで指定できます");
$txtInvalid = isset($_POST["txtInvalid"]) ? htmlspecialchars($_POST["txtInvalid"]) : "";
if (strcmp($txtInvalid, "") == 0)
throw new Exception("同一イベント再生可能までのミリ秒が指定されていません");
else
if (!preg_match("/^[0-9]+$/", $txtInvalid))
throw new Exception("同一イベント再生可能までのミリ秒は半角数字のみで指定できます");
$txtRectVertex = isset($_POST["txtRectVertex"]) ? htmlspecialchars($_POST["txtRectVertex"]) : "";
if (strcmp($txtRectVertex, "") == 0)
throw new Exception("頂点数が指定されていません");
else
if (!preg_match("/^[0-9]+$/", $txtRectVertex))
throw new Exception("頂点数は半角数字のみで指定できます");
else
if ($txtRectVertex < 3)
throw new Exception("頂点数は3以上を指定して下さい");
$txtRemarks = isset($_POST["txtRemarks"]) ? htmlspecialchars($_POST["txtRemarks"]) : "";
$confMode = 1;
$confValue = array(
"area_id" => "",
"format" => $selectFormat,
"priority" => $selectPriority,
"msg_id1" => $selectMsg1,
"msg_id2" => $selectMsg2,
"msg_id3" => $selectMsg3,
"msg_id4" => $selectMsg4,
"msg_interval" => $txtInterval,
"msg_invalid" => $txtInvalid,
"rect_vertex" => $txtRectVertex,
"remarks" => $txtRemarks,
"upddatetime" => ""
);
Debug::writes($confValue);
$mgrMsg = "下記内容で登録します<br />";
}
else if (strcmp($btnUpdate, "登録") == 0)
{
$regFormat = isset($_POST["regFormat"]) ? htmlspecialchars($_POST["regFormat"]) : "";
$regPriority = isset($_POST["regPriority"]) ? htmlspecialchars($_POST["regPriority"]) : "";
$regMsgId1 = isset($_POST["regMsgId1"]) ? htmlspecialchars($_POST["regMsgId1"]) : "";
$regMsgId2 = isset($_POST["regMsgId2"]) ? htmlspecialchars($_POST["regMsgId2"]) : "";
$regMsgId3 = isset($_POST["regMsgId3"]) ? htmlspecialchars($_POST["regMsgId3"]) : "";
$regMsgId4 = isset($_POST["regMsgId4"]) ? htmlspecialchars($_POST["regMsgId4"]) : "";
$regInterval = isset($_POST["regInterval"]) ? htmlspecialchars($_POST["regInterval"]) : "";
$regInvalid = isset($_POST["regInvalid"]) ? htmlspecialchars($_POST["regInvalid"]) : "";
$regRectVertex = isset($_POST["regRectVertex"]) ? htmlspecialchars($_POST["regRectVertex"]) : "";
$regRemarks = isset($_POST["regRemarks"]) ? htmlspecialchars($_POST["regRemarks"]) : "";
$insData = "INSERT INTO ". $AREA_TABLE. " (";
$insData .= "list_id, format, priority, msg_id1, msg_id2, msg_id3, msg_id4, msg_interval, msg_invalid, rect_vertex, remarks, upddatetime, regdatetime";
$insData .= ") VALUES (";
$insData .= "'". $listId. "', '". $regFormat. "', '". $regPriority. "', '". $regMsgId1. "', '". $regMsgId2. "', '". $regMsgId3. "', '". $regMsgId4. "', '". $regInterval. "', '". $regInvalid. "', '". $regRectVertex. "', '". $regRemarks. "', 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;
$resLsSeqId = pg_query($conn, "SELECT currval('qgis.area_list_area_id_seq');");
$rowLsSeqId = pg_fetch_assoc($resLsSeqId);
$regAreaId = $rowLsSeqId["currval"];
$selectRegArea = "SELECT * FROM ". $AREA_TABLE. "";
$selectRegArea .= " WHERE area_id='". $regAreaId. "'";
$selectRegArea .= ";";
if (!($resRegArea = pg_query($conn, $selectRegArea)))
{
throw new Exception("最新データの取得に失敗しました<br />". $selectRegArea. "<br />". pg_last_error(). "<br />");
}
$rowNewData = pg_fetch_array($resRegArea, 0, PGSQL_ASSOC);
$mgrMsg = "エリア登録を行いました<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 == 1)
{
if (strcmp($VIEW_LIST[$iCount]["object"], "format") == 0)
{
$row = count($FORMAT_LIST);
for($jCount = 0; $jCount < $row; $jCount++)
{
if ($FORMAT_LIST[$jCount]["value"] == $confValue[$VIEW_LIST[$iCount]["object"]])
{
print $FORMAT_LIST[$jCount]["view"];
break;
}
}
}
else if (strcmp($VIEW_LIST[$iCount]["object"], "priority") == 0)
{
$row = count($PRIORITY_LIST);
for($jCount = 0; $jCount < $row; $jCount++)
{
if ($PRIORITY_LIST[$jCount]["value"] == $confValue[$VIEW_LIST[$iCount]["object"]])
{
print $PRIORITY_LIST[$jCount]["view"];
break;
}
}
}
else if (strcmp($VIEW_LIST[$iCount]["object"], "msg_id1") == 0 || strcmp($VIEW_LIST[$iCount]["object"], "msg_id2") == 0 || strcmp($VIEW_LIST[$iCount]["object"], "msg_id3") == 0 || strcmp($VIEW_LIST[$iCount]["object"], "msg_id4") == 0)
{
$row = count($msgList);
for($jCount = 0; $jCount< $row; $jCount++)
{
if ($msgList[$jCount]["msg_id"] == $confValue[$VIEW_LIST[$iCount]["object"]])
{
print $msgList[$jCount]["msg_info"];
break;
}
}
}
}
else if ($confMode == 2)
{
print $rowNewData[$VIEW_LIST[$iCount]["object"]];
}
else
{
if (strcmp($VIEW_LIST[$iCount]["object"], "format") == 0)
{
print "<select name=\"". $VIEW_LIST[$iCount]["control"]. "\" id=\"select_option\">";
$listLength = count($FORMAT_LIST);
for($jCount = 0; $jCount < $listLength; $jCount++)
{
print "<option value=\"". $FORMAT_LIST[$jCount]["value"]. "\">". $FORMAT_LIST[$jCount]["view"]. "</option>";
}
print "</select>";
}
else if (strcmp($VIEW_LIST[$iCount]["object"], "priority") == 0)
{
print "<select name=\"". $VIEW_LIST[$iCount]["control"]. "\" id=\"select_option\">";
$listLength = count($PRIORITY_LIST);
for($jCount = 0; $jCount < $listLength; $jCount++)
{
print "<option value=\"". $PRIORITY_LIST[$jCount]["value"]. "\">". $PRIORITY_LIST[$jCount]["view"]. "</option>";
}
print "</select>";
}
else if (strcmp($VIEW_LIST[$iCount]["object"], "msg_id1") == 0 || strcmp($VIEW_LIST[$iCount]["object"], "msg_id2") == 0 || strcmp($VIEW_LIST[$iCount]["object"], "msg_id3") == 0 || strcmp($VIEW_LIST[$iCount]["object"], "msg_id4") == 0)
{
print "<select name=\"". $VIEW_LIST[$iCount]["control"]. "\" id=\"select_option\">";
$listLength = count($msgList);
for($jCount = 0; $jCount < $listLength; $jCount++)
{
print "<option value=\"". $msgList[$jCount]["msg_id"]. "\">". $msgList[$jCount]["msg_info"]. "</option>";
}
print "</select>";
}
}
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=\"regFormat\" value=\"". $confValue["format"]. "\">";
print "<input type=\"hidden\" name=\"regPriority\" value=\"". $confValue["priority"]. "\">";
print "<input type=\"hidden\" name=\"regMsgId1\" value=\"". $confValue["msg_id1"]. "\">";
print "<input type=\"hidden\" name=\"regMsgId2\" value=\"". $confValue["msg_id2"]. "\">";
print "<input type=\"hidden\" name=\"regMsgId3\" value=\"". $confValue["msg_id3"]. "\">";
print "<input type=\"hidden\" name=\"regMsgId4\" value=\"". $confValue["msg_id4"]. "\">";
print "<input type=\"hidden\" name=\"regInterval\" value=\"". $confValue["msg_interval"]. "\">";
print "<input type=\"hidden\" name=\"regInvalid\" value=\"". $confValue["msg_invalid"]. "\">";
print "<input type=\"hidden\" name=\"regRectVertex\" value=\"". $confValue["rect_vertex"]. "\">";
print "<input type=\"hidden\" name=\"regRemarks\" value=\"". $confValue["remarks"]. "\">";
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=\"list_id\" value=\"". $listId. "\">";
print "<input type=\"hidden\" name=\"events_name\" value=\"". $eventsName. "\">";
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=\"list_id\" value=\"". $listId. "\">";
print "<input type=\"hidden\" name=\"events_name\" value=\"". $eventsName. "\">";
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>";
?>