<?php
//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
//	自動でクラスを参照する
//	関数名	：	__autoload()
//	備考	：	参照先は./class/XXX.phpとする
//	更新	：	2012/10/19 KMK-Teraoka
//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
function __autoload($className)
{
	$fPath = "./class/" . str_replace("_", "/", $className) . ".php";
	require_once $fPath;
}

function addWhere($now_, $add_)
{
	$ret = "";
	if (strcmp($now_, "") == 0)
		$ret .= " WHERE ". $add_;
	else
		$ret .= $now_. " AND ". $add_;
	return $ret;
}
//===============================================
//	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 = "コンクリート運搬記録一覧";
$TOP_FORM = "../index.php";
$HOST = "192.168.100.153";
$DB = "ansys";
$USER = "postgres";
$PASS = "am#71ZJ*";
$CONSTRUCTION_TABLE = "qgis.concrete_shipping_record";
$CONST_ID = "7";
$APPLICATION_ID = "13";
$WHERE_PATTERN = array(
	"0"		=>	array("name"	=>	"端末名称",		"object"	=>	"android_id",		"pattern"	=>	"middle"),
);

$VIEW_LIST = array(
	array("head"	=>	"管理",				"object"	=>	"manage",			"width"		=>	"2%"),
	array("head"	=>	"時刻",				"object"	=>	"record_date",		"width"		=>	"10%"),
	array("head"	=>	"端末名称",			"object"	=>	"terminal_name",	"width"		=>	"10%"),
	array("head"	=>	"状態",				"object"	=>	"status",			"width"		=>	"10%"),
	array("head"	=>	"登録",				"object"	=>	"regdatetime",		"width"		=>	"10%"),
	array("head"	=>	"入力",				"object"	=>	"user_add",			"width"		=>	"10%"),
	//array("head"	=>	"端末ID",			"object"	=>	"android_id",		"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/10/18 KMK-Teraoka
	//===============================================
	if (DEBUG_MODE == 1)
	{
		extract($_POST);
		extract($_GET);
		Debug::writes($_POST);
	}
	$txtSearchObj = isset($_POST["txtSearchObj"]) ? htmlspecialchars($_POST["txtSearchObj"]) : "";
	$searchRecordDate = isset($_POST["searchRecordDate"]) ? htmlspecialchars($_POST["searchRecordDate"]) : "";
	if (strcmp($searchRecordDate, "") == "")
		$searchRecordDate = date("Y-m-d");
	$rdioSortRecordDate = isset($_POST["rdioSortRecordDate"]) ? htmlspecialchars($_POST["rdioSortRecordDate"]) : "";
	$viewPage = isset($_POST["hPage"]) ? htmlspecialchars($_POST["hPage"]) : "";
	if ($viewPage == "")
		$viewPage = 1;
	$btnSearch = isset($_POST["btnSearch"]) ? htmlspecialchars($_POST["btnSearch"]) : "";
	if (strcmp($btnSearch, "検索条件をクリア") == 0)
	{
		$txtSearchObj = "";
		$searchRecordDate = date("Y-m-d");
		$rdioSortRecordDate = "";
	}
	else if (strcmp($btnSearch, "指定条件で検索") == 0)
	{
		$viewPage = 1;
	}
	
	$hControl = isset($_POST["hControl"]) ? htmlspecialchars($_POST["hControl"]) : "";
	if (strcmp($hControl, "regist") == 0)
	{
		$txtRecordDate = isset($_POST["txtRecordDate"]) ? htmlspecialchars($_POST["txtRecordDate"]) : "";
		$selTerminalName = isset($_POST["selTerminalName"]) ? htmlspecialchars($_POST["selTerminalName"]) : "";
		$selStatus = isset($_POST["selStatus"]) ? htmlspecialchars($_POST["selStatus"]) : "";
		Debug::write("登録処理");
		$selRecord = "SELECT count(*) FROM qgis.concrete_shipping_record";
		$selRecord .= " WHERE record_date='". $txtRecordDate. "'";
		$selRecord .= " AND android_id='". $selTerminalName. "'";
		$selRecord .= " AND status='". $selStatus. "'";
		$selRecord .= ";";
		if (!($resRecord = pg_query($conn, $selRecord)))
			throw new Exception("データ取得に失敗<br />". $resRecord. "<br />". pg_last_error(). "<br />");
		$rowRecord = pg_fetch_assoc($resRecord, 0);
		if ($rowRecord["count"] == 0)
		{
			$insRecord = "INSERT INTO qgis.concrete_shipping_record";
			$insRecord .= " VALUES ('". $txtRecordDate. "', '". $CONST_ID. "', '". $APPLICATION_ID. "', '". $selTerminalName. "', '". $selStatus. "', current_timestamp, '1')";
			$insRecord .= ";";
			Debug::write($insRecord);
			if (!($resRecord = pg_query($conn, $insRecord)))
				throw new Exception("データ挿入に失敗<br />". $resRecord. "<br />". pg_last_error(). "<br />");
		}
	}
	else if (strcmp($hControl, "delete") == 0)
	{
		$hDelRecordDate = isset($_POST["hDelRecordDate"]) ? htmlspecialchars($_POST["hDelRecordDate"]) : "";
		$hDelAndroidId = isset($_POST["hDelAndroidId"]) ? htmlspecialchars($_POST["hDelAndroidId"]) : "";
		$hDelStatus = isset($_POST["hDelStatus"]) ? htmlspecialchars($_POST["hDelStatus"]) : "";
		$hDelRegDate = isset($_POST["hDelRegDate"]) ? htmlspecialchars($_POST["hDelRegDate"]) : "";
		Debug::write("削除処理");
		
		$delRecord = "DELETE FROM qgis.concrete_shipping_record";
		$delRecord .= " WHERE record_date='". $hDelRecordDate. "'";
		$delRecord .= " AND android_id='". $hDelAndroidId. "'";
		$delRecord .= " AND status='". $hDelStatus. "'";
		$delRecord .= " AND regdatetime='". $hDelRegDate. "'";
		$delRecord .= ";";
		
		Debug::write($delRecord);
		if (!($resRecord = pg_query($conn, $delRecord)))
				throw new Exception("データ削除に失敗<br />". $resRecord. "<br />". pg_last_error(). "<br />");
	}
	//===============================================
	//	端末名称の取得
	//	備考		：	
	//	更新		：	2013/09/18 KMK-Teraoka
	//===============================================
	$terminals = array();
	$selectTerminal = "SELECT android_id, terminal_name FROM qgis.ts_terminal";
	$selectTerminal .= " WHERE const_id='". $CONST_ID. "'";
	$selectTerminal .= " AND app_id='". $APPLICATION_ID. "'";
	$selectTerminal .= " AND android_id!='d033ad24ea7c5d77'";
	$selectTerminal .= " AND android_id!='198903985b36c4b2'";
	$selectTerminal .= " AND android_id!='b606848df7aa45ce'";
	$selectTerminal .= " AND android_id!='74b6c682dbe5c270'";
	$selectTerminal .= " ORDER BY terminal_name";
	$selectTerminal .= ";";
	Debug::write($selectTerminal);
	if (!($resTerminalName = pg_query($conn, $selectTerminal)))
	{
		throw new Exception("端末名称の取得に失敗<br />". $selectTerminal. "<br />". pg_last_error(). "<br />");
	}
	$numTerminalName = pg_num_rows($resTerminalName);
	for($iCount = 0; $iCount < $numTerminalName; $iCount++)
	{
		$rowTerminalName = pg_fetch_array($resTerminalName, $iCount, PGSQL_ASSOC);
		$terminals[$iCount]["android_id"] = $rowTerminalName["android_id"];
		$terminals[$iCount]["terminal_name"] = $rowTerminalName["terminal_name"];
	}
	//Debug::writes($terminals);
	
	//===============================================
	//	データ存在日付の抽出
	//	備考		：	
	//	更新		：	2013/09/24 KMK-Teraoka
	//===============================================
	$distRecordDate = array();
	$seldRecordDate = "SELECT DISTINCT(DATE(record_date)) as record_date FROM ". $CONSTRUCTION_TABLE. "";
	$seldRecordDate .= " ORDER BY record_date DESC";
	$seldRecordDate .= ";";
	Debug::write($seldRecordDate);
	if (!($resdRecordDate = pg_query($conn, $seldRecordDate)))
		throw new Exception("データ存在日付の取得に失敗<br />". $seldRecordDate. "<br />". pg_last_error(). "<br />");
	
	$numdRecordDate = pg_num_rows($resdRecordDate);
	for($iCount = 0; $iCount < $numdRecordDate; $iCount++)
	{
		$rowdRecordDate = pg_fetch_assoc($resdRecordDate, $iCount);
		$distRecordDate[$iCount] = $rowdRecordDate["record_date"];
	}
	//Debug::writes($distRecordDate);
	
	//===============================================
	//	WHERE句の作成
	//	備考		：	
	//	更新		：	2012/10/18 KMK-Teraoka
	//===============================================
	$whereObj = "";
	if (strcmp($searchRecordDate, "all") != 0)
	{
		$whereObj = addWhere($whereObj, "record_date >= '". $searchRecordDate. " 00:00:00'");
		$whereObj = addWhere($whereObj, "record_date <= '". $searchRecordDate. " 23:59:59'");
	}
	
	if (strcmp($txtSearchObj, "") != 0)
	{
		$searchId = "";
		for($iCount = 0; $iCount < $numTerminalName; $iCount++)
			if (strcmp($txtSearchObj, $terminals[$iCount]["terminal_name"]) == 0)
				$searchId = $terminals[$iCount]["android_id"];
		$whereObj = addWhere($whereObj, "android_id='". $searchId. "'");
	}
	Debug::write($whereObj);
	
	//===============================================
	//	ORDER句の作成
	//	備考		：	
	//	更新		：	2012/10/18 KMK-Teraoka
	//===============================================
	if (strcmp($rdioSortRecordDate, "昇順") == 0)
		$orderObj = " ORDER BY record_date ASC";
	else
		$orderObj = " ORDER BY record_date DESC";
	
	//===============================================
	//	見出し
	//	備考		：	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/18 KMK-Teraoka
	//===============================================
	print "<form action=\"". $_SERVER['PHP_SELF']. "\" method=\"post\" style=\"display:inline\">";
	print "【検索条件指定】<br />";
	
	// 日付での検索
	print "日付：";
	print "&nbsp;";
	print "<select name=\"searchRecordDate\" id=\"select_option\">";
	$numDistRecord = count($distRecordDate);
	print "<option value=\"all\">全件</option>";
	for($iCount = 0; $iCount < $numDistRecord; $iCount++)
	{
		$chk = "";
		if (strcmp($searchRecordDate, $distRecordDate[$iCount]) == 0)
			$chk = " selected";
		print "<option value=\"". $distRecordDate[$iCount]. "\" ". $chk. ">". $distRecordDate[$iCount]. "</option>";
	}
	print "</select>";
	$rdchecked = array("", "");
	if (strcmp($rdioSortRecordDate, "昇順") == 0)
		$rdchecked["0"] = " checked";
	else
		$rdchecked["1"] = " checked";
	print "<input type=\"radio\" name=\"rdioSortRecordDate\" value=\"昇順\"". $rdchecked["0"]. " />昇順";
	print "<input type=\"radio\" name=\"rdioSortRecordDate\" value=\"降順\"". $rdchecked["1"]. " />降順";
	print "<br />";
	
	print "端末名称：";
	print "&nbsp;";
	print "<input type=\"text\" name=\"txtSearchObj\" value=\"". $txtSearchObj. "\" style=\"width:120px\" id=\"text\">";
	print "&nbsp;";
	
	print "<input type=\"submit\" name=\"btnSearch\" value=\"指定条件で検索\" style=\"width:130px\" id=\"submit_button\">";
	print "&nbsp;";
	print "<input type=\"submit\" name=\"btnSearch\" value=\"検索条件をクリア\" style=\"width:130px\" id=\"submit_button\">";
	print "<br />";
	print "<input type=\"hidden\" name=\"hPage\" value=\"". $viewPage. "\">";
	//print "<br />";
	print "</form>";
	
	//===============================================
	//	新規作成、トップ画面へ戻るのLink
	//	備考		：	
	//	更新		：	2012/10/18 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 "<br />";
	
	//===============================================
	//	ページリンクの作成
	//	備考		：	Table内TableでBorderを細くする
	//	更新		：	2012/10/18 KMK-Teraoka
	//===============================================
	print "<table border=\"0\" style=\"width:100%;\">";
	print "<tr>";
	print "<td align=\"left\" style=\"width:50%;\">";
	$selRowCnt = "SELECT count(*) as count FROM ". $CONSTRUCTION_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=\"txtSearchObj\" value=\"". $txtSearchObj. "\">";
			print "<input type=\"hidden\" name=\"searchRecordDate\" value=\"". $searchRecordDate. "\">";
			print "<input type=\"hidden\" name=\"rdioSortRecordDate\" value=\"". $rdioSortRecordDate. "\">";
			print "<input type=\"hidden\" name=\"hPage\" value=\"". ($iCount + 1). "\">";
			print "</form>";
		}
		if ($iCount < ($pageLinkCnt - 1))
		{
			print "&nbsp;";
		}
	}
	print "</td>";
	print "<td align=\"right\" style=\"width:50%;\">";
	print "<form action=\"". "../output/sheet_shipping.php". "\" method=\"post\" style=\"display:inline\">";
	print "<input type=\"submit\" name=\"btnPrint\" value=\"csv出力\" id=\"submit_button\">";
	print "<input type=\"hidden\" name=\"txtSearchObj\" value=\"". $txtSearchObj. "\">";
	print "<input type=\"hidden\" name=\"searchRecordDate\" value=\"". $searchRecordDate. "\">";
	print "<input type=\"hidden\" name=\"rdioSortRecordDate\" value=\"". $rdioSortRecordDate. "\">";
	print "</form>";
	print "</td>";
	print "</tr>";
	print "</table>";
	//print "<br />";
	
	//===============================================
	//	一覧の取得
	//	備考		：	
	//	更新		：	2012/10/18 KMK-Teraoka
	//===============================================
	$selList = "SELECT * FROM ". $CONSTRUCTION_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/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\">";
	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>";
	
	// 新規登録行
	print "<form name=\"ownFormRegist\" method=\"post\" action=\"". $_SERVER['PHP_SELF']. "\" style=\"display:inline\">";
	
	print "<tr bgcolor=\"#ccffcc\" align=\"center\">";
	print "<td>";
	print "<a href=\"javascript:ownFormRegist.submit()\">登録</a>";
	print "</td>";
	print "<td align=\"center\">";
	$nowdate = date("Y-m-d H:i");
	print "<input type=\"text\" name=\"txtRecordDate\" value=\"". $nowdate. "\" style=\"width:100%;\" />";
	print "</td>";
	print "<td>";
	print "<select name=\"selTerminalName\" style=\"width:100%;\">";
	$numTerminals = count($terminals);
	for($iCount = 0; $iCount < $numTerminals; $iCount++)
	{
		print "<option value=\"". $terminals[$iCount]["android_id"]. "\">". $terminals[$iCount]["terminal_name"]. "</option>";
	}
	print "</select>";
	print "</td>";
	print "<td>";
	print "<select name=\"selStatus\" style=\"width:100%;\">";
	print "<option value=\"1\">出荷</option>";
	print "<option value=\"2\">搬入</option>";
	print "</select>";
	print "</td>";
	print "<td>";
	print "-";
	print "</td>";
	print "<td>";
	print "-";
	print "</td>";
	//print "<td>";
	//print "-";
	//print "</td>";
	print "</tr>";
	print "<input type=\"hidden\" name=\"txtSearchObj\" value=\"". $txtSearchObj. "\">";
	print "<input type=\"hidden\" name=\"searchRecordDate\" value=\"". $searchRecordDate. "\">";
	print "<input type=\"hidden\" name=\"rdioSortRecordDate\" value=\"". $rdioSortRecordDate. "\">";
	print "<input type=\"hidden\" name=\"hPage\" value=\"". $viewPage. "\">";
	print "<input type=\"hidden\" name=\"hControl\" value=\"regist\">";
	print "</form>";
	
	// データ行
	$numList = pg_num_rows($resList);
	for($iCount = 0; $iCount < $numList; $iCount++)
	{
		$rowList = pg_fetch_array($resList, $iCount, PGSQL_ASSOC);
		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"], "status") == 0)
			{
				if (strcmp($rowList[$VIEW_LIST[$jCount]["object"]], "1") == 0)
				{
					print "出荷";
				}
				else if (strcmp($rowList[$VIEW_LIST[$jCount]["object"]], "2") == 0)
				{
					print "搬入";
				}
				else
				{
					print "不明";
				}
			}
			else if (strcmp($VIEW_LIST[$jCount]["object"], "terminal_name") == 0)
			{
				$numTerminals = count($terminals);
				for($kCount = 0; $kCount < $numTerminals; $kCount++)
				{
					if (strcmp($terminals[$kCount]["android_id"], $rowList["android_id"]) == 0)
						print $terminals[$kCount]["terminal_name"];
				}
			}
			else if (strcmp($VIEW_LIST[$jCount]["object"], "user_add") == 0)
			{
				if (strcmp($rowList[$VIEW_LIST[$jCount]["object"]], "0") == 0)
					print "自動";
				else
					print "手動";
			}
			else if (strcmp($VIEW_LIST[$jCount]["object"], "record_date") == 0)
			{
				print date("Y-m-d H:i", strtotime($rowList[$VIEW_LIST[$jCount]["object"]]));
			}
			else if (strcmp($rowList[$VIEW_LIST[$jCount]["object"]], "") != 0)
			{
				print $rowList[$VIEW_LIST[$jCount]["object"]];
			}
			else if (strcmp($VIEW_LIST[$jCount]["object"], "manage") == 0)
			{
				if (strcmp($rowList["user_add"], "1") == 0)
				{
					print "<form name=\"ownFormDelete_". ($iCount + 1). "\" method=\"post\" action=\"". $_SERVER['PHP_SELF']. "\" style=\"display:inline\">";
					print "<a href=\"javascript:ownFormDelete_". ($iCount + 1). ".submit()\">削除</a>";
					print "<input type=\"hidden\" name=\"txtSearchObj\" value=\"". $txtSearchObj. "\">";
					print "<input type=\"hidden\" name=\"searchRecordDate\" value=\"". $searchRecordDate. "\">";
					print "<input type=\"hidden\" name=\"rdioSortRecordDate\" value=\"". $rdioSortRecordDate. "\">";
					print "<input type=\"hidden\" name=\"hPage\" value=\"". $viewPage. "\">";
					
					print "<input type=\"hidden\" name=\"hDelRecordDate\" value=\"". $rowList["record_date"]. "\">";
					print "<input type=\"hidden\" name=\"hDelAndroidId\" value=\"". $rowList["android_id"]. "\">";
					print "<input type=\"hidden\" name=\"hDelStatus\" value=\"". $rowList["status"]. "\">";
					print "<input type=\"hidden\" name=\"hDelRegDate\" value=\"". $rowList["regdatetime"]. "\">";
					
					print "<input type=\"hidden\" name=\"hControl\" value=\"delete\">";
					print "</form>";
				}
				else
				{
					print "-";
				}
			}
			else
			{
				print "&nbsp;";
			}
			print "</td>";
		}
		print "</tr>";
	}
	print "</table>";
	print "</td>";
	print "</tr>";
	print "</table>";
	
	//===============================================
	//	ページリンクの作成
	//	備考		：	
	//	更新		：	2012/10/18 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=\"txtSearchObj\" value=\"". $txtSearchObj. "\">";
			print "<input type=\"hidden\" name=\"searchRecordDate\" value=\"". $searchRecordDate. "\">";
			print "<input type=\"hidden\" name=\"rdioSortRecordDate\" value=\"". $rdioSortRecordDate. "\">";
			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/10/18 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/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>";
?>
