File "req_list.php"

Full path: /www/ansys/qgis/002_kujyusaki/intercomm/req_list.php
File size: 13.36 KiB (13685 bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Back

<?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/01 KMK-Teraoka
//===============================================
define("DEBUG_MODE", "0");
Debug::setMode(DEBUG_MODE);
if (DEBUG_MODE == 1)
{
	Stopwatch::start();
}

//===============================================
//	CommonUtilities
//	備考		:	
//	更新		:	2012/11/01 KMK-Teraoka
//===============================================
$PENTA_OCEAN = "五洋建設株式会社";
$TAIL_PENTA_OCEAN = "penta-ocean";
$SCRIPT_TITLE = "GCM送信管理";
$CONST_ID = "4";
$APP_ID = "3";
$HOST = "192.168.100.153";
$DB = "ansys";
$USER = "postgres";
$PASS = "am#71ZJ*";
$TERMINALS_TABLE = "qgis.gcm_event";
$TOP_FORM = "../index.php";

$VIEW_LIST = array(
	"0"		=>	array("head"	=>	"登録ID",			"object"	=>	"event_id",			"width"		=>	"5%"),
	"1"		=>	array("head"	=>	"要求端末",			"object"	=>	"from_android_id",	"width"		=>	"10%"),
	"2"		=>	array("head"	=>	"イベント端末",		"object"	=>	"to_android_id",	"width"		=>	"10%"),
	"3"		=>	array("head"	=>	"イベント1",		"object"	=>	"ev_01",			"width"		=>	"5%"),
	"4"		=>	array("head"	=>	"イベント2",		"object"	=>	"ev_02",			"width"		=>	"5%"),
	"5"		=>	array("head"	=>	"イベント3",		"object"	=>	"ev_03",			"width"		=>	"5%"),
	"6"		=>	array("head"	=>	"イベント4",		"object"	=>	"ev_04",			"width"		=>	"5%"),
	"7"		=>	array("head"	=>	"送信日時",			"object"	=>	"snddatetime",		"width"		=>	"10%"),
	"8"		=>	array("head"	=>	"送信戻り値",		"object"	=>	"req_ret",			"width"		=>	"10%"),
	"9"		=>	array("head"	=>	"端末からの返答",	"object"	=>	"ret",				"width"		=>	"5%"),
	"10"	=>	array("head"	=>	"返答日時",			"object"	=>	"retdatetime",		"width"		=>	"10%"),
	"11"	=>	array("head"	=>	"更新日時",			"object"	=>	"upddatetime",		"width"		=>	"10%"),
);
$PAGE_LIMIT = 30;

//===============================================
//	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/18 KMK-Teraoka
	//================================================
	$conn = pg_connect("
		host	=	". $HOST. "
		dbname	=	". $DB. "
		user	=	". $USER. "
		password=	". $PASS. "
	");
	if (!$conn)
	{
		throw new Exception("データベースへの接続に失敗しました");
	}
	
	//===============================================
	//	POST、GETパラメータの受け取り
	//	備考		:	
	//	更新		:	2012/11/01 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;
	$btnSearch = isset($_POST["btnSearch"]) ? htmlspecialchars($_POST["btnSearch"]) : "";
	
	if (strcmp($delList, "消去") == 0)
	{
		$delList = "DELETE FROM ". $TERMINALS_TABLE. ";";
		$resRowCnt = pg_query($conn, $delList);
	}
	
	//===============================================
	//	WHERE句の作成
	//	備考		:	
	//	更新		:	2012/11/01 KMK-Teraoka
	//===============================================
	$whereObj = " WHERE const_id='". $CONST_ID. "' AND app_id='". $APP_ID. "'";
	Debug::write($whereObj);
	
	//===============================================
	//	ORDER句の作成
	//	備考		:	
	//	更新		:	2012/11/01 KMK-Teraoka
	//===============================================
	$orderObj = " ORDER BY regdatetime DESC";
	
	//===============================================
	//	見出し
	//	備考		:	Table内TableでBorderを細くする
	//	更新		:	2012/11/01 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 "GCM要求一覧一覧";
	print "</td>";
	print "</tr>";
	print "</table>";
	print "</td>";
	print "</tr>";
	print "</table>";
	print "<br />";
	
	//===============================================
	//	トップ画面へ戻るのLink
	//	備考		:	
	//	更新		:	2012/11/01 KMK-Teraoka
	//===============================================
	print "<form name=\"topForm_1\" method=\"post\" action=\"". $TOP_FORM. "\" style=\"display:inline\">";
	print "<a href=\"javascript:topForm_1.submit()\">トップ画面</a>";
	print "</form>";
	
	print "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	print "<form name=\"delForm\" method=\"post\" action=\"". $TOP_FORM. "\" style=\"display:inline\">";
	print "<a href=\"javascript:delForm.submit()\">リスト消去</a>";
	print "<input type=\"hidden\" name=\"delList\" value=\"消去\">";
	print "</form>";
	
	print "<br />";
	
	//===============================================
	//	ページリンクの作成
	//	備考		:	Table内TableでBorderを細くする
	//	更新		:	2012/11/01 KMK-Teraoka
	//===============================================
	$selRowCnt = "SELECT count(*) as count FROM ". $TERMINALS_TABLE. "";
	if (strcmp($whereObj, "") != 0)
	{
		$selRowCnt .= $whereObj;
	}
	$selRowCnt .= ";";
	Debug::write($selRowCnt);
	if (!($resRowCnt = pg_query($conn, $selRowCnt)))
	{
		throw new Exception("行数の取得に失敗<br />". $selRowCnt. "<br />". pg_last_error(). "<br />");
	}
	$rowRowCnt = pg_fetch_array($resRowCnt, 0, PGSQL_ASSOC);
	$pageLinkCnt = ceil(($rowRowCnt["count"] / $PAGE_LIMIT));
	for($iCount = 0; $iCount < $pageLinkCnt; $iCount++)
	{
		if ($viewPage == ($iCount + 1))
		{
			print ($iCount + 1). "";
		}
		else
		{
			print "<form name=\"ownForm". ($iCount + 1). "_1\" method=\"post\" action=\"". $_SERVER['PHP_SELF']. "\" style=\"display:inline\">";
			print "<a href=\"javascript:ownForm". ($iCount + 1). "_1.submit()\">". ($iCount + 1). "</a>";
			print "<input type=\"hidden\" name=\"selSearch\" value=\"". $selSearch. "\">";
			print "<input type=\"hidden\" name=\"txtSearchObj\" value=\"". $txtSearchObj. "\">";
			print "<input type=\"hidden\" name=\"hPage\" value=\"". ($iCount + 1). "\">";
			print "</form>";
		}
		if ($iCount < ($pageLinkCnt - 1))
		{
			print "&nbsp;";
		}
	}
	print "<br />";
	
	//===============================================
	//	一覧の取得
	//	備考		:	
	//	更新		:	2012/11/01 KMK-Teraoka
	//===============================================
	$selList = "SELECT * FROM ". $TERMINALS_TABLE. "";
	if (strcmp($whereObj, "") != 0)
	{
		$selList .= $whereObj;
	}
	if (strcmp($orderObj, "") != 0)
	{
		$selList .= $orderObj;
	}
	$selList .= " LIMIT 30";
	$selList .= " OFFSET ". (($viewPage - 1) * 30). "";
	$selList .= ";";
	Debug::write($selList);
	if (!($resList = pg_query($conn, $selList)))
	{
		throw new Exception("一覧の取得に失敗<br />". $selList. "<br />". pg_last_error(). "<br />");
	}
	
	//===============================================
	//	一覧の表示
	//	備考		:	
	//	更新		:	2012/11/01 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\">";
	for($iCount = 0; $iCount < count($VIEW_LIST); $iCount++)
	{
		print "<th style=\"width:". $VIEW_LIST[$iCount]["width"]. ";height:25px;\">";
		print $VIEW_LIST[$iCount]["head"];
		print "</th>";
	}
	print "</tr>";
	
	for($iCount = 0; $iCount < pg_num_rows($resList); $iCount++)
	{
		$rowList = pg_fetch_array($resList, $iCount, PGSQL_ASSOC);
		if ($rowList["ret"] == f)
		{
			print "<tr bgcolor=\"#FF0000\" align=\"center\">";
		}
		else
		{
			print "<tr bgcolor=\"#FFFFFF\" align=\"center\">";
		}
		for($jCount = 0; $jCount < count($VIEW_LIST); $jCount++)
		{
			print "<td style=\"height:25px;\">";
			if (strcmp($VIEW_LIST[$jCount]["object"], "") == 0)
			{
				print "<form name=\"cForm_2_". $rowList["android_id"]. "\" method=\"post\" action=\"". $VIEW_FORM. "\" style=\"display:inline\">";
				print "<a href=\"javascript:cForm_2_". $rowList["android_id"]. ".submit()\">参照</a>";
				print "<input type=\"hidden\" name=\"editId\" value=\"". $rowList["android_id"]. "\">";
				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 "&nbsp;|&nbsp;";
				
				print "<form name=\"cForm_3_". $rowList["android_id"]. "\" method=\"post\" action=\"". $EDIT_FORM. "\" style=\"display:inline\">";
				print "<a href=\"javascript:cForm_3_". $rowList["android_id"]. ".submit()\">編集</a>";
				print "<input type=\"hidden\" name=\"editId\" value=\"". $rowList["android_id"]. "\">";
				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 "&nbsp;|&nbsp;";
				
				print "<form name=\"cForm_4_". $rowList["android_id"]. "\" method=\"post\" action=\"". $DELETE_FORM. "\" style=\"display:inline\">";
				print "<a href=\"javascript:cForm_4_". $rowList["android_id"]. ".submit()\">削除</a>";
				print "<input type=\"hidden\" name=\"editId\" value=\"". $rowList["android_id"]. "\">";
				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>";
			}
			else if (strcmp($rowList[$VIEW_LIST[$jCount]["object"]], "") != 0)
			{
				print $rowList[$VIEW_LIST[$jCount]["object"]];
			}
			else
			{
				print "&nbsp;";
			}
			print "</td>";
		}
		print "</tr>";
	}
	print "</table>";
	print "</td>";
	print "</tr>";
	print "</table>";
	print "<input type=\"hidden\" name=\"hPage\" value=\"". $viewPage. "\">";
	
	//===============================================
	//	ページリンクの作成
	//	備考		:	
	//	更新		:	2012/11/01 KMK-Teraoka
	//===============================================
	$pageLinkCnt = ceil(($rowRowCnt["count"] / $PAGE_LIMIT));
	for($iCount = 0; $iCount < $pageLinkCnt; $iCount++)
	{
		if ($viewPage == ($iCount + 1))
		{
			print ($iCount + 1). "";
		}
		else
		{
			print "<form name=\"ownForm". ($iCount + 1). "_2\" method=\"post\" action=\"". $_SERVER['PHP_SELF']. "\" style=\"display:inline\">";
			print "<a href=\"javascript:ownForm". ($iCount + 1). "_2.submit()\">". ($iCount + 1). "</a>";
			print "<input type=\"hidden\" name=\"selSearch\" value=\"". $selSearch. "\">";
			print "<input type=\"hidden\" name=\"txtSearchObj\" value=\"". $txtSearchObj. "\">";
			print "<input type=\"hidden\" name=\"hPage\" value=\"". ($iCount + 1). "\">";
			print "</form>";
		}
		if ($iCount < ($pageLinkCnt - 1))
		{
			print "&nbsp;";
		}
	}
	print "<br />";
}
catch(Exception $exc)
{
	print "<font color=\"#FF0000\">";
	print "【スクリプトエラー】<br />";
	print $exc->getMessage(). "<br />";
	print "</font>";
}

//===============================================
//	トップ画面へ戻るのLink
//	備考		:	
//	更新		:	2012/11/01 KMK-Teraoka
//===============================================
print "<form name=\"topForm_2\" method=\"post\" action=\"". $TOP_FORM. "\" style=\"display:inline\">";
print "<a href=\"javascript:topForm_2.submit()\">トップ画面</a>";
print "</form>";
print "<br />";

//===============================================
//	Postgresql終了処理
//	備考		:	
//	更新		:	2012/11/01 KMK-Teraoka
//===============================================
pg_close($conn);

//===============================================
//	HTML終了処理
//	備考		:	
//	更新		:	2012/11/01 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>";
?>

PHP File Manager