File "status_view.php"

Full path: /www/ansys/qgis/000_nasu2/status/status_view.php
File size: 13.1 KiB (13416 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;
}

//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
//	値を元に表示値を検索
//	関数名	:	retView
//	備考	:	
//	更新	:	2013/04/19 KMK-Teraoka
//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
function retView($value_, $list_)
{
	$row = count($list_);
	
	for($iCount = 0; $iCount < $row; $iCount++)
	{
		if (strcmp($list_[$iCount]["value"], $value_) == 0)
		{
			return $list_[$iCount]["view"];
		}
	}
	return "<font color=\"#FF0000\">リストに存在しません[". $value_. "]</font>";
}

//===============================================
//	DEBUG_MODE
//	備考		:	
//	更新		:	2012/10/18 KMK-Teraoka
//===============================================
define("DEBUG_MODE", "0");
Debug::setMode(DEBUG_MODE);
if (DEBUG_MODE == 1)
{
	Stopwatch::start();
}

//===============================================
//	CommonUtilities
//	備考		:	
//	更新		:	2012/10/18 KMK-Teraoka
//===============================================
$PENTA_OCEAN = "五洋建設株式会社";
$TAIL_PENTA_OCEAN = "penta-ocean";
$SCRIPT_TITLE = "運行管理-横浜港南本牧地区- 端末状態詳細確認";
$APP_ID = "18";
$CONST_ID = "1";
$HOST = "192.168.100.153";
$DB = "ansys";
$USER = "postgres";
$PASS = "am#71ZJ*";
$TERMINALS_TABLE = "qgis.ts_terminal";
$VIEW_LIST = array(
	"0"		=>	array("head"	=>	"アンドロイドID",			"object"	=>	"android_id",				"type"		=>	"0",		"control"		=>		"-"),
	"1"		=>	array("head"	=>	"端末名称",					"object"	=>	"terminal_name",			"type"		=>	"0",		"control"		=>		"-"),
	"2"		=>	array("head"	=>	"緯度",						"object"	=>	"lat",						"type"		=>	"0",		"control"		=>		"-"),
	"3"		=>	array("head"	=>	"経度",						"object"	=>	"lon",						"type"		=>	"0",		"control"		=>		"-"),
	"4"		=>	array("head"	=>	"測位精度",					"object"	=>	"acc",						"type"		=>	"0",		"control"		=>		"-"),
	"5"		=>	array("head"	=>	"車速[km/h]",				"object"	=>	"spd",						"type"		=>	"0",		"control"		=>		"-"),
	"6"		=>	array("head"	=>	"測位時間",					"object"	=>	"mesdatetime",				"type"		=>	"0",		"control"		=>		"-"),
	"7"		=>	array("head"	=>	"測位間隔",					"object"	=>	"measure_interval",			"type"		=>	"1",		"control"		=>		"-"),
	"8"		=>	array("head"	=>	"測位結果の扱い",			"object"	=>	"measure_result",			"type"		=>	"2",		"control"		=>		"-"),
	"9"		=>	array("head"	=>	"測位結果の送信間隔",		"object"	=>	"location_send_interval",	"type"		=>	"3",		"control"		=>		"-"),
	"10"	=>	array("head"	=>	"測位精度での切り捨て",		"object"	=>	"acc_omit",					"type"		=>	"4",		"control"		=>		"-"),
	"11"	=>	array("head"	=>	"停止判定距離",				"object"	=>	"stop_distance",			"type"		=>	"5",		"control"		=>		"-"),
	"12"	=>	array("head"	=>	"イベント定義ファイル",		"object"	=>	"area_events_fname",		"type"		=>	"0",		"control"		=>		"-"),
	"13"	=>	array("head"	=>	"作業役割",					"object"	=>	"work_status",				"type"		=>	"6",		"control"		=>		"-"),
);

$MEASURE_INTERVAL_LIST = array(
	"0"		=>	array("value"	=>	"0",			"view"	=>	"最大"),
	"1"		=>	array("value"	=>	"500",			"view"	=>	"0.5秒"),
	"2"		=>	array("value"	=>	"1000",			"view"	=>	"1秒"),
	"3"		=>	array("value"	=>	"3000",			"view"	=>	"3秒"),
	"4"		=>	array("value"	=>	"5000",			"view"	=>	"5秒"),
	"5"		=>	array("value"	=>	"10000",		"view"	=>	"10秒"),
	"6"		=>	array("value"	=>	"15000",		"view"	=>	"15秒"),
	"7"		=>	array("value"	=>	"30000",		"view"	=>	"30秒"),
	"8"		=>	array("value"	=>	"60000",		"view"	=>	"1分")
);

$MEASURE_RESULT_LIST = array(
	"0"		=>	array("value"	=>	"1",			"view"	=>	"定期送信"),
	"1"		=>	array("value"	=>	"2",			"view"	=>	"ファイル保存"),
	"2"		=>	array("value"	=>	"-1",			"view"	=>	"送信しない"),
	"3"		=>	array("value"	=>	"0",			"view"	=>	"定期送信"),
);

$LOCATION_SEND_INTERVAL_LIST = array(
	"0"		=>	array("value"	=>	"1000",			"view"	=>	"1秒"),
	"1"		=>	array("value"	=>	"3000",			"view"	=>	"3秒"),
	"2"		=>	array("value"	=>	"5000",			"view"	=>	"5秒"),
	"3"		=>	array("value"	=>	"10000",		"view"	=>	"10秒"),
	"4"		=>	array("value"	=>	"15000",		"view"	=>	"15秒"),
	"5"		=>	array("value"	=>	"30000",		"view"	=>	"30秒"),
	"6"		=>	array("value"	=>	"60000",		"view"	=>	"1分"),
);

$ACC_OMIT_LIST = array(
	"0"		=>	array("value"	=>	"-1",			"view"	=>	"利用しない"),
	"1"		=>	array("value"	=>	"30",			"view"	=>	"30.0[m]"),
	"2"		=>	array("value"	=>	"20",			"view"	=>	"20.0[m]"),
	"3"		=>	array("value"	=>	"15",			"view"	=>	"15.0[m]"),
	"4"		=>	array("value"	=>	"10",			"view"	=>	"10.0[m]"),
	"5"		=>	array("value"	=>	"8",			"view"	=>	"8.0[m]"),
	"6"		=>	array("value"	=>	"5",			"view"	=>	"5.0[m]"),
	"7"		=>	array("value"	=>	"3",			"view"	=>	"3.0[m]"),
);

$STOP_DISTANCE_LIST = array(
	"0"		=>	array("value"	=>	"-1",			"view"	=>	"利用しない"),
	"1"		=>	array("value"	=>	"1",			"view"	=>	"1.0[m]"),
	"2"		=>	array("value"	=>	"3",			"view"	=>	"3.0[m]"),
	"3"		=>	array("value"	=>	"5",			"view"	=>	"5.0[m]"),
	"4"		=>	array("value"	=>	"8",			"view"	=>	"8.0[m]"),
	"5"		=>	array("value"	=>	"10",			"view"	=>	"10.0[m]"),
	"6"		=>	array("value"	=>	"15",			"view"	=>	"15.0[m]"),
	"7"		=>	array("value"	=>	"20",			"view"	=>	"20.0[m]"),
	"8"		=>	array("value"	=>	"30",			"view"	=>	"30.0[m]"),
);

$WORK_STATUS_LIST = array(
	"0"		=>	array("value"	=>	"0",			"view"	=>	"五洋建設職員"),
	"1"		=>	array("value"	=>	"999",			"view"	=>	"五洋建設職員"),
);

//===============================================
//	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/10/18 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が指定されていません");
	}
	$workStatus = isset($_POST["workStatus"]) ? htmlspecialchars($_POST["workStatus"]) : "";
	switch($workStatus)
	{
		case 0:
			$listLink = "./status_list.php";
			break;
		case 1:
			$listLink = "./status_tc.php";
			break;
		case 2:
			$listLink = "./status_nd.php";
			break;
		case 3:
			$listLink = "./status_su.php";
			break;
		case 999:
			$listLink = "./status_list.php";
			break;
		default:
			$listLink = "../index.php";
			throw new Exception("存在しない作業役割が指定されています");
			break;
	}
	$selSearch = isset($_POST["selSearch"]) ? htmlspecialchars($_POST["selSearch"]) : "";
	$txtSearchObj = isset($_POST["txtSearchObj"]) ? htmlspecialchars($_POST["txtSearchObj"]) : "";
	$viewPage = isset($_POST["hPage"]) ? htmlspecialchars($_POST["hPage"]) : 1;
	
	//===============================================
	//	WHERE句の作成
	//	備考		:	
	//	更新		:	2012/10/18 KMK-Teraoka
	//===============================================
	$whereObj = "";
	$whereObj .= " WHERE android_id='". $editId. "'";
	$whereObj .= " AND const_id='". $CONST_ID. "'";
	$whereObj .= " AND app_id='". $APP_ID. "'";
	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 ". $TERMINALS_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:
				$ret = retView($rowData[$VIEW_LIST[$iCount]["object"]], $MEASURE_INTERVAL_LIST);
				print $ret;
				break;
			case 2:
				$ret = retView($rowData[$VIEW_LIST[$iCount]["object"]], $MEASURE_RESULT_LIST);
				print $ret;
				break;
			case 3:
				$ret = retView($rowData[$VIEW_LIST[$iCount]["object"]], $LOCATION_SEND_INTERVAL_LIST);
				print $ret;
				break;
			case 4:
				$ret = retView($rowData[$VIEW_LIST[$iCount]["object"]], $ACC_OMIT_LIST);
				print $ret;
				break;
			case 5:
				$ret = retView($rowData[$VIEW_LIST[$iCount]["object"]], $STOP_DISTANCE_LIST);
				print $ret;
				break;
			case 6:
				$ret = retView($rowData[$VIEW_LIST[$iCount]["object"]], $WORK_STATUS_LIST);
				print $ret;
				break;
			default:
				throw new Exception("リストに存在しません");
				break;
		}
		print "</td>";
		print "</tr>";
	}
	print "</table>";
	print "</td>";
	print "</tr>";
	print "</table>";
	print "</form>";
	print "<br />";
}
catch(Exception $exc)
{
	print "<font color=\"#FF0000\">";
	print "【スクリプトエラー】<br />";
	print $exc->getMessage(). "<br />";
	print "</font>";
}

//===============================================
//	一覧リンク
//	備考		:	
//	更新		:	2012/10/19 KMK-Teraoka
//===============================================
print "<form name=\"listForm\" method=\"post\" action=\"". $listLink. "\" 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>";
print "<br />";

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

//===============================================
//	HTML終了処理
//	備考		:	
//	更新		:	2012/10/18 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