File "conc_data_edit.php"
Full path: /www/ansys/qgis/004_iwakuni/list/conc_data_edit.php
File size: 14.05 KiB (14386 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/10/19 KMK-Teraoka
//===============================================
define("DEBUG_MODE", "0");
Debug::setMode(DEBUG_MODE);
if (DEBUG_MODE == 1)
{
Stopwatch::start();
}
//===============================================
// CommonUtilities
// 備考 :
// 更新 : 2012/10/19 KMK-Teraoka
//===============================================
$PENTA_OCEAN = "五洋建設株式会社";
$TAIL_PENTA_OCEAN = "penta-ocean";
$SCRIPT_TITLE = "コンクリート品質管理データ一覧";
$LIST_FORM = "./conc_data_list.php";
$EDIT_FORM = "./conc_data_edit.php";
$VIEW_FORM = "./conc_data_view.php";
$DELETE_FORM = "./conc_data_delete.php";
$CREATE_FORM = "./conc_data_create.php";
$HOST = "192.168.100.153";
$DB = "ansys";
$USER = "postgres";
$PASS = "am#71ZJ*";
$CONCRETE_TABLE = "qgis.quality_of_concrete";
$VIEW_LIST = array(
array("head" => "登録日時", "object" => "iptdatetime", "type" => "0", "control" => "-"),
array("head" => "車番", "object" => "car_number", "type" => "1", "control" => "txtCarNumber"),
array("head" => "スランプ", "object" => "slump", "type" => "1", "control" => "txtSlump"),
array("head" => "空気量", "object" => "amount_air", "type" => "1", "control" => "txtAmountAir"),
array("head" => "単位水量", "object" => "unit_water", "type" => "1", "control" => "txtUnitWater"),
array("head" => "コンクリート温度", "object" => "concrete_temp", "type" => "1", "control" => "txtConcreteTemp"),
array("head" => "外気温", "object" => "temperature", "type" => "1", "control" => "txtTemperature"),
array("head" => "塩化物イオン量", "object" => "chloride_ion", "type" => "1", "control" => "txtChlorideIon"),
);
//===============================================
// HTML-HEAD-
// 備考 :
// 更新 : 2012/10/18 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/10/18 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/10/19 KMK-Teraoka
//================================================
$conn = pg_connect("
host = ". $HOST. "
dbname = ". $DB. "
user = ". $USER. "
password= ". $PASS. "
");
if (!$conn)
{
throw new Exception("データベースへの接続に失敗しました");
}
//===============================================
// POST、GETパラメータの受け取り
// 備考 :
// 更新 : 2012/10/19 KMK-Teraoka
//===============================================
if (DEBUG_MODE == 1)
{
extract($_POST);
extract($_GET);
Debug::writes($_POST);
}
$editId = isset($_POST["editId"]) ? htmlspecialchars($_POST["editId"]) : "";
if (strcmp($editId, "") == 0)
{
throw new Exception("データIDが指定されていません");
}
$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)
{
// 更新SQL
$updCarNumber = isset($_POST["updCarNumber"]) ? htmlspecialchars($_POST["updCarNumber"]) : "";
if (strcmp($updCarNumber, "") == 0)
{
throw new Exception("車番が入力されていません");
}
$updSlump = isset($_POST["updSlump"]) ? htmlspecialchars($_POST["updSlump"]) : "";
$updAmountAir = isset($_POST["updAmountAir"]) ? htmlspecialchars($_POST["updAmountAir"]) : "";
$updUnitWater = isset($_POST["updUnitWater"]) ? htmlspecialchars($_POST["updUnitWater"]) : "";
$updConcreteTemp = isset($_POST["updConcreteTemp"]) ? htmlspecialchars($_POST["updConcreteTemp"]) : "";
$updTemperature = isset($_POST["updTemperature"]) ? htmlspecialchars($_POST["updTemperature"]) : "";
$updChlorideIon = isset($_POST["updChlorideIon"]) ? htmlspecialchars($_POST["updChlorideIon"]) : "";
$updData = "UPDATE ". $CONCRETE_TABLE. " SET";
$updData .= " car_number='". $updCarNumber. "'";
$updData .= ", slump='". $updSlump. "'";
$updData .= ", amount_air='". $updAmountAir. "'";
$updData .= ", unit_water='". $updUnitWater. "'";
$updData .= ", concrete_temp='". $updConcreteTemp. "'";
$updData .= ", temperature='". $updTemperature. "'";
$updData .= ", chloride_ion='". $updChlorideIon. "'";
$updData .= ", upddatetime=current_timestamp";
$updData .= " WHERE reg_id='". $editId. "'";
$updData .= ";";
Debug::write($updData);
if (!(pg_query($conn, $updData)))
{
throw new Exception("ID:[". $editId. "]のデータ更新に失敗しました<br />". $updData. "<br />". pg_last_error(). "<br />");
}
$mgrMsg = "コンクリート品質管理データ[". $editId. "]のデータを更新しました<br />";
}
else if (strcmp($btnUpdate, "確認") == 0)
{
$txtCarNumber = isset($_POST["txtCarNumber"]) ? htmlspecialchars($_POST["txtCarNumber"]) : "";
if (strcmp($txtCarNumber, "") == 0)
throw new Exception("車番が入力されていません");
$txtSlump = isset($_POST["txtSlump"]) ? htmlspecialchars($_POST["txtSlump"]) : "";
$txtAmountAir = isset($_POST["txtAmountAir"]) ? htmlspecialchars($_POST["txtAmountAir"]) : "";
$txtUnitWater = isset($_POST["txtUnitWater"]) ? htmlspecialchars($_POST["txtUnitWater"]) : "";
$txtConcreteTemp = isset($_POST["txtConcreteTemp"]) ? htmlspecialchars($_POST["txtConcreteTemp"]) : "";
$txtTemperature = isset($_POST["txtTemperature"]) ? htmlspecialchars($_POST["txtTemperature"]) : "";
$txtChlorideIon = isset($_POST["txtChlorideIon"]) ? htmlspecialchars($_POST["txtChlorideIon"]) : "";
$confMode = 1;
$confValue = array(
"car_number" => $txtCarNumber,
"slump" => $txtSlump,
"amount_air" => $txtAmountAir,
"unit_water" => $txtUnitWater,
"concrete_temp" => $txtConcreteTemp,
"temperature" => $txtTemperature,
"chloride_ion" => $txtChlorideIon,
);
$mgrMsg = "下記内容で更新します<br />";
Debug::writes($confValue);
}
//===============================================
// WHERE句の作成
// 備考 :
// 更新 : 2012/10/19 KMK-Teraoka
//===============================================
$whereObj = "";
$whereObj .= " WHERE reg_id='". $editId. "'";
Debug::write($whereObj);
//===============================================
// 見出し
// 備考 : Table内TableでBorderを細くする
// 更新 : 2012/10/18 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/10/19 KMK-Teraoka
//===============================================
$selData = "SELECT * FROM ". $CONCRETE_TABLE;
if (strcmp($whereObj, "") != 0)
{
$selData .= $whereObj;
}
$selData .= ";";
Debug::write($selData);
if (!($resData = pg_query($conn, $selData)))
{
throw new Exception("ID:[". $editId. "]のデータ取得に失敗しました<br />". $selData. "<br />". pg_last_error(). "<br />");
}
$rowData = pg_fetch_array($resData, 0, PGSQL_ASSOC);
//===============================================
// 管理メッセージの表示
// 備考 :
// 更新 : 2012/10/18 KMK-Teraoka
//===============================================
print "<font color=\"#FF0000\">";
print $mgrMsg;
print "</font>";
//===============================================
// 一覧の表示
// 備考 :
// 更新 : 2012/10/18 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:
print $rowData[$VIEW_LIST[$iCount]["object"]];
break;
case 1:
if ($confMode == 1)
{
print $confValue[$VIEW_LIST[$iCount]["object"]];
}
else
{
print "<input type=\"text\" name=\"". $VIEW_LIST[$iCount]["control"]. "\" value=\"". $rowData[$VIEW_LIST[$iCount]["object"]]. "\" style=\"width:100%\" id=\"text\">";
}
break;
case 2:
break;
case 3:
if ($confMode == 1)
{
print $VIEW_LIST[$iCount]["control"];
}
else
{
print $rowData[$VIEW_LIST[$iCount]["object"]];
}
break;
default:
throw new Exception("リストに存在しません");
break;
}
print "</td>";
print "</tr>";
}
print "</table>";
print "</td>";
print "</tr>";
print "</table>";
//===============================================
// 確認、登録ボタン
// 備考 :
// 更新 : 2012/10/19 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=\"updCarNumber\" value=\"". $confValue["car_number"]. "\">";
print "<input type=\"hidden\" name=\"updSlump\" value=\"". $confValue["slump"]. "\">";
print "<input type=\"hidden\" name=\"updAmountAir\" value=\"". $confValue["amount_air"]. "\">";
print "<input type=\"hidden\" name=\"updUnitWater\" value=\"". $confValue["unit_water"]. "\">";
print "<input type=\"hidden\" name=\"updConcreteTemp\" value=\"". $confValue["concrete_temp"]. "\">";
print "<input type=\"hidden\" name=\"updTemperature\" value=\"". $confValue["temperature"]. "\">";
print "<input type=\"hidden\" name=\"updChlorideIon\" value=\"". $confValue["chloride_ion"]. "\">";
print "<br />";
}
else
{
print "<input type=\"submit\" name=\"btnUpdate\" value=\"確認\" style=\"width:60px\" id=\"submit_button\">";
print "<br />";
}
print "<input type=\"hidden\" name=\"editId\" value=\"". $editId. "\">";
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 />";
//===============================================
// 参照リンク
// 備考 :
// 更新 : 2012/10/19 KMK-Teraoka
//===============================================
print "<form name=\"viewForm\" method=\"post\" action=\"". $VIEW_FORM. "\" style=\"display:inline\">";
print "<a href=\"javascript:viewForm.submit()\">参照</a>";
print "<input type=\"hidden\" name=\"editId\" value=\"". $editId. "\">";
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 " | ";
}
catch(Exception $exe)
{
print "<font color=\"#FF0000\">";
print "【スクリプトエラー】<br />";
print $exe->getMessage(). "<br />";
print "</font>";
}
//===============================================
// 一覧リンク
// 備考 :
// 更新 : 2012/10/19 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/10/19 KMK-Teraoka
//===============================================
pg_close($conn);
//===============================================
// HTML終了処理
// 備考 :
// 更新 : 2012/10/19 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>";
?>