File "work_list_OLD20140403.php"

Full path: /www/haneda/qr/work_list_OLD20140403.php
File size: 7.66 KiB (7848 bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Back

<?php
//===============================================
//	CommonUtilities
//	備考		:	
//	更新		:	2012/11/01 KMK-Teraoka
//===============================================

$PENTA_OCEAN = "五洋・清水特定建設工事企業体";
$TAIL_PENTA_OCEAN = "penta-ocean";
$SCRIPT_TITLE = "登録一覧";

$TOP_FORM = "./index.php";
$VIEW_FORM = "./work_list_details.php";
$HOST = "192.168.100.153";
$DB = "pntdb";
$USER = "postgres";
$PASS = "am#71ZJ*";
$WORK_TABLE = "qr.work_data";
$REGIST_TABLE = "qr.regist_data";
$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 />";


	//================================================
	//	データベース接続
	//	備考		:	
	//	更新		:	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($btnSearch, "クリア") == 0)
	{
		$txtSearchObj = "";
	}
	else if (strcmp($btnSearch, "検索") == 0)
	{
		$viewPage = 1;
	}
*/	
	//===============================================
	//	WHERE句の作成
	//	備考		:	
	//	更新		:	2012/11/01 KMK-Teraoka
	//===============================================
	//最新の作業時間を抽出
	$select_w = "SELECT distinct date FROM " .$WORK_TABLE ." ORDER BY date desc;";
	$res_w = pg_query($conn,$select_w);
	$data_ct = pg_num_rows($res_w);
	
	//===============================================
	//	見出し
	//	備考		:	Table内TableでBorderを細くする
	//	更新		:	2012/11/01 KMK-Teraoka
	//===============================================
//	print $select_w ."<BR>";

	//●日付用プルダウン作成
	print "<form action=\"". "./work_list_csv.php". "\" method=\"post\" style=\"display:inline\">";
	print "<select name=\"Date\" >";
	for($iCount = 0; $iCount < $data_ct; $iCount++)
	{
		$rowObserve = pg_fetch_assoc($res_w, $iCount);
		
		$selOption = "";
		print "<option value=\"". $rowObserve["date"]. "\" ". $selOption. ">". date("Y-m-d" ,strtotime($rowObserve['date'])). "</option>";
	}
	print "</select>";
	//////////////////////////////////////////

	//●昼/夜用プルダウン作成
	print "<select name=\"TimeZone\" >";
	$selOption = "";
	print "<option value=\"99\"". $selOption. ">1日</option>";
	print "<option value=\"0\"". "\" ". $selOption. ">昼間</option>";
	print "<option value=\"1\"". "\" ". $selOption. ">夜間</option>";
	print "</select>";
	print "<input type=\"submit\" name=\"btnPrint\" value=\"csv出力\" style=\"width:90px\">"; 
	print "</form>";
	//////////////////////////////////////////

//	print "<table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">";
	print "<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">";
	print "<tr>";
	print "<td align='center' width='150' rowspan='2'>";
	print "日時";
	print "</td>";
	print "<td align='center' width='400' colspan='4'>";
	print "貸出/返却の状況";
	print "</td>";
	print "<tr>";
	print "<td align='center' width='200' colspan='2'>";
	print "昼間";
	print "</td>";
	print "<td align='center' width='200' colspan='2'>";
	print "夜間";
	print "</td>";
	print "</tr>";

	for($i = 0;$i < $data_ct;$i++)
	{
		$row_w = pg_fetch_array($res_w,$i);
		$select_date = date("Y-m-d",strtotime($row_w['date']));

		for($j = 1 ;$j >= 0;$j--)
		{
			//昼間/夜間の作業検索
			$SELECT_C = "SELECT distinct date,time_zone FROM qr.work_data  WHERE date=" ." '" .$row_w['date'] ."' AND time_zone = '" .$j ."'";
			$RES_C = pg_query($conn,$SELECT_C);
			$C_ct = pg_num_rows($RES_C);

			if($C_ct)
			{
				$select_r = "SELECT user_id_flag,user_dentification_flag,car_dentification_flag, car_id_flag, flag_number_flag,mark_number_flag,manual_number_flag,fire_flag FROM " .$REGIST_TABLE ;
				$select_r .= " WHERE  date =  '" .$row_w['date'] ."' AND time_zone = '" .$j ."' AND del_flag = false ORDER BY regdatetime;";
				$res_r = pg_query($conn,$select_r);
				$flag_ct = pg_num_rows($res_r);
				$flag_check = 0;

				for($ii =0;$ii < $flag_ct;$ii++)
				{
					$row_r = pg_fetch_array($res_r,$ii);
					if($row_r[0] == 1) $flag_check = 1;
					if($row_r[1] == 1) $flag_check = 1;
					if($row_r[2] == 1) $flag_check = 1;
					if($row_r[3] == 1) $flag_check = 1;
					if($row_r[4] == 1) $flag_check = 1;
					if($row_r[5] == 1) $flag_check = 1;
					if($row_r[6] == 1) $flag_check = 1;
					if($row_r[7] == 1) $flag_check = 1;
				}

				if(($i == 0))
				{
						$status[$j] = "--------";
						$LinkT[$j] = "<td width='100' bgcolor='#FFFFFF'><a href='work_list_details.php" ."?d=" .$select_date ."&t=" .$j ."'>一覧</a></td>";
				}
				else if($flag_check == 1)
				{
					$status[$j] = "未返却有";
					$LinkT[$j] = "<td width='100' bgcolor='#FFFFFF'><a href='work_list_details.php" ."?d=" .$select_date ."&t=" .$j ."'>一覧</a></td>";
					$bgcolor[$j] = "bgcolor='#FF0000'";
				}
				else
				{
					$status[$j] ="";
					$LinkT[$j] = "<td width='100' bgcolor='#FFFFFF'><a href='work_list_details.php" ."?d=" .$select_date ."&t=" .$j ."'>一覧</a></td>";
					$bgcolor[$j] = "bgcolor='#FFFFFF'";
				}
			}
			else
			{
				$status[$j] ="";
				$LinkT[$j] = "<td width='100' bgcolor='#FFFFFF'><font color='#D3D3D3'>一覧 </font></td>";
				$bgcolor[$j] = "bgcolor='#FFFFFF'";
				$no_flag = 1;
			}
		}
		
		if($i == 0)
		{
			if($status[1])
			{
				$status[0] = "";
			}
		}
		

		print "<tr align='center'>";
		print "<td>" .$select_date ."</td>";
		print $LinkT[0];
		print "<td width='100'>" .$status[0] ."</td>";
		print $LinkT[1];
		print "<td width='100'>" .$status[1] ."</td>";
		print "</tr>";
	}



	print "</table>";
	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