File "usen.php"

Full path: /www/nakagusuku/wpos/edit/usen.php
File size: 3.07 KiB (3142 bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Back

<?php
$editid = isset($_GET["pid"]) ? htmlspecialchars($_GET["pid"]) : "";

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>退避管理システム</title>";
print "</head>";

print "<body>";
print "<center>";
print "<font size=\"3\"><b>";
print "退避管理システム<br>-使用状況切替-";
print "【五洋建設株式会社】";
print "</b></font>";
print "</center>";
print "<hr />";

try
{
	if (strcmp($editid, "") == 0)
	{
		$editid = isset($_POST["hipid"]) ? htmlspecialchars($_POST["hipid"]) : "";
		if (strcmp($editid, "") == 0)
			throw new Exception("IDが指定されていません");
	}
	
	$conn = pg_connect("
	host	=	192.168.100.153
	dbname	=	cnbs
	user	=	postgres
	password=	am#71ZJ*
	");
	if (!$conn)
		throw new Exception("データベースへの接続に失敗");
	
	$btnref = isset($_POST["btnref"]) ? htmlspecialchars($_POST["btnref"]) : "";
	if (strcmp($btnref, "切替") == 0)
	{
		$baseuseflg = isset($_POST["hiuseflg"]) ? htmlspecialchars($_POST["hiuseflg"]) : "";
		if (strcmp($baseuseflg, "") == 0)
			throw new Exception("使用状況の値が不正です");
		$chuseflg = (strcmp($baseuseflg, "t") == 0 ? "f" : "t");
		$updateUse = "UPDATE nakagusuku.worker_name SET useflg='". $chuseflg. "' WHERE dispno='". $editid. "';";
		//print $updateUse. "<br>";
		pg_query($conn, $updateUse);
		print "<font color=\"#ff0000\">";
		print "表示状況を切り替えました<br>";
		print "</font>";
	}
	$selectWname = "SELECT dispno, wname, useflg FROM nakagusuku.worker_name WHERE dispno=". $editid. ";";
	$res = pg_query($conn, $selectWname);
	
	$rowcnt = pg_num_rows($res);
	if ($rowcnt == 0)
		throw new Exception("指定されたIDのデータは存在しません");
	
	$row = pg_fetch_assoc($res, 0);
	
	print "<form method=\"post\">";
	print "<center>";
	print "<table border=\"1\" style=\"width:50%\">";
	print "<tr align=\"center\"><th bgcolor=\"#ff6666\">表示番号</th><td>". $row["dispno"]. "</td></tr>";
	print "<tr align=\"center\"><th bgcolor=\"#ff6666\">氏名</th><td>". $row["wname"]. "</td></tr>";
	print "<tr align=\"center\"><th bgcolor=\"#ff6666\">使用状況</th><td>". (strcmp($row["useflg"], "t") == 0 ? "使用中" : "未使用"). "</td></tr>";
	print "<tr align=\"right\"><th colspan=\"2\"><input type=\"submit\" name=\"btnref\" value=\"切替\"></th></tr>";
	print "</table>";
	print "</center>";
	print "<input type=\"hidden\" name=\"hipid\" value=\"". $editid. "\">";
	print "<input type=\"hidden\" name=\"hiuseflg\" value=\"". $row["useflg"]. "\">";
	print "</form>";
}
catch(Exception $exc)
{
	print "<font color=\"#ff0000\">";
	print $exc. "<br>";
	print "</font>";
}
pg_close($conn);

print "<p style=\"text-align:right;\">";
print "<a href=\"./listn.php\">戻る</a>";
print "</p>";
print "<hr>";
print "<center>";
print "<font size=\"3\" face=\"Arial\"><b><i>";
print "penta-ocean";
print "</i></b></font>";
print "</center>";
?>

PHP File Manager