File "data_regist_202200424.php"

Full path: /www/geye/OLD/data_regist_202200424.php
File size: 29.65 KiB (30357 bytes)
MIME-type: text/html
Charset: utf-8

Download   Open   Back

<HTML>
<HEAD>
<META Http-Equiv="Content-Type" Content="text/html;charset=UTF-8">
<TITLE>検査立会申請一覧</TITLE>
<LINK REL="stylesheet" HREF="pict.css" TYPE="text/css">
</HEAD>
<BODY>

<script type="text/javascript">
function goDeleteServlet(){

 //チェックボタンは配列に入っている
 checks = document.getElementsByName("check");

	var data_no = null;

	for(var i = 0; i < checks.length; i++)
	{
		if(checks[i].checked)
		{
			if(data_no == null)
			{
				data_no = checks[i].value;
			}
			else
			{
				 data_no = data_no + ","  + checks[i].value ;
			}
		}
	}
	
	if(data_no != null)
	{
		if(window.confirm('削除してもよろしいですか?'))
		{
			location.href = "data_regist.php?del=" + data_no ;
		} 
		else
		{
			location.href = "data_regist.php";
		}
	}
	else
	{
		if(window.confirm('削除のチェックが選択されていません'))
		{
			//document.getElementById('form').action='<%=request.getContextPath() + "/mng/FindAll?currentPage="%>${requestScope.currentPage}';
			//return true;
		}
		else
		{
			//document.getElementById('form').action='<%=request.getContextPath() + "/mng/FindAll?currentPage="%>${requestScope.currentPage}';
			//return false;
		}
	}

}





function CheckPush(id_,no_){

	//チェックボタンは配列に入っている
	confirmer_ = document.getElementsByName("confirmer_reg");
	implementation_date_ = document.getElementsByName("implementation_date");
	
	console.log(confirmer_[id_].value);
	console.log(implementation_date_ [id_].value);
	
	var conf = confirmer_[id_].value;
	var imp = implementation_date_ [id_].value;	
	
	location.href = "data_view.php?chk=" + no_ + "&conf=" + conf + "&imp=" + imp;
	
	//  console.log(no_);
//	location.href = "data_view.php?chk=" + no_ ;

}
</script>




<FONT>
<!--<A HREF="./conc_data_today2_view.php">非表示のデータ一覧</A>-->

<!--<FORM ACTION="<?php $_SERVER[PHP_SELF]; ?>" METHOD="POST">
<INPUT TYPE="button" onclick="location.href='menu.php'" value="メニューへ戻る" style="WIDTH: 120px; HEIGHT: 50px">
<INPUT TYPE="submit" NAME="prc"  VALUE="チェックを入れた項目が非表示になります" style="WIDTH: 300px; HEIGHT: 50px">
-->


<?php

//プルダウン作成
//●数値型
function Pulldown_create_int($width ,$name_,$min_int, $max_int,$interval,$selected,$Space){
	print "<select name='" .$name_ ."' style='width:" .$width ."px;'>";
	
	//
	
	
	for($j= $min_int ;$j < $max_int;$j += $interval)
	{	
		$sel = ($j == $selected) ? "selected" : "";
		print "<option value='" .$j ."' " .$sel ." >" .$j ."</option>";
	}
	
	
	if (is_null($selected) && $Space)
	{
		print "<option value='' selected >  </option>";
	}
	print "</select>";
}

//●現在時刻の取得
$now_time = time() + 86400;
$now_time_date = date("Y年m月d日 H時i分",$now_time);
$reg_date_time = $now_time;
$date_y = date("Y",$now_time);
$date_m = date("m",$now_time );
$date_d = date("d",$now_time);
$time_h = date("H",$now_time);
$time_m = date("i",$now_time);


//■初期値設定
//////////////////
//Function定義
/////////////////

//func:データをSQL用に変換
function cnv_sqlstr($string)
{
  if (!strlen($string)) return "null";
    if (get_magic_quotes_gpc()) {
        $string = stripslashes($string);
    }
    $string = htmlspecialchars($string);
    $string = pg_escape_string($string);

    return "'".$string."'";
}

$enc_db = "UTF-8";
$enc_disp = "SJIS";


//■フォルダ内のファイル削除($dirは該当ファイルがあるディレクトリの絶対パス)
function deleteData ( $dir )
{
    if ( $dirHandle = opendir ( $dir )) {
        while ( false !== ( $fileName = readdir ( $dirHandle ) ) ) {
            if ( $fileName != "." && $fileName != ".." ) {
                unlink ( $dir.$fileName );
            }
        }
        closedir ( $dirHandle );
    }
}

//■フォルダ内のファイル移動($dir1元ディレクトリ,$dir2移動先ディレクトリ)
function moveData ( $dir1,$dir2 )
{
    if ( $dirHandle = opendir ( $dir1 )) {
        while ( false !== ( $fileName = readdir ( $dirHandle ) ) ) {
            if ( $fileName != "." && $fileName != ".." ) {
				rename($dir1.$fileName , $dir2.$fileName);
            }
        }
        closedir ( $dirHandle );
    }
}


//アップロード時の一時保存パス
$tmp_record_dir = '/www/geye/tmp_record/';
$tmp_pict_dir = '/www/geye/tmp_pict/';


//アップロード時の保存パス
$record_dir = '/www/geye/inspection/record/';
$pict_dir = '/www/geye/inspection/pict/';


//■元画像からサムネイル画像の作成
function ThumbnailMake($in_pict,$x_size,$y_size)
{
	
    list($width, $hight) = getimagesize($in_pict);	 // 元の画像名を指定してサイズを取得

    $baseImage = imagecreatefromjpeg($in_pict); 	// 元の画像から新しい画像を作る準備
    $image = imagecreatetruecolor($x_size, $y_size); // サイズを指定して新しい画像のキャンバスを作成

    // 画像のコピーと伸縮
    imagecopyresampled($image, $baseImage, 0, 0, 0, 0, $x_size, $y_size, $width, $hight);

    // コピーした画像を出力する

    $name_split = explode(".",$in_pict);
    
    $out_pict = $name_split[0] ."_s." .$name_split[1];
    imagejpeg($image , $out_pict);

}


//----------------------------------------------------------------------
// 接続設定(サーバ/データベース/ユーザ/パスワード)


$sv = "192.168.100.153";
$dbname = "geye";
$user = "postgres";
$pass = "postgres";
$conn = pg_connect("host=$sv dbname=$dbname user=$user password=$pass") or die("接続エラー");

EXTRACT($_GET);
print_r($_GET);
print_r($_POST);
//■削除処理
if($del)
{
	$DelSql = "UPDATE inspection_record SET ";
	$DelSql .= "del_flag = 'TRUE' ";
	$DelSql .= " WHERE id IN (" .$del .");";
	
	if (!($resDelSql = pg_query($conn, $DelSql)))
	{
		print pg_last_error() ."<BR>";
//		throw new Exception("データ取得に失敗<br />". $DelArea. "<br />". pg_last_error(). "<br />");
	}
	
}

//■編集処理
if($edit)
{
//	print "chk==" .$chk;
	//現在の確認状況を取得
	$sql_ch = "SELECT * FROM inspection_record WHERE id = " .$chk ." AND del_flag ='false' ;";
	$res_ch = pg_query($conn,$sql_ch);
	$row_ch = pg_fetch_array($res_ch,0);
	
	//print $row_ch['chk_flag'] ."<BR>";
	$chk_flag = ($row_ch['chk_flag'] == 'f') ? "true" : "false";
	
	$sql_chup = "UPDATE inspection_record SET ";
	$sql_chup .= "confirmer = '" .$conf ."', ";
	$sql_chup .= "implementation_date = '" .$imp ."',";
	$sql_chup .= "chk_flag = '" .$chk_flag ."' ";
	$sql_chup .= " WHERE id = " .$chk .";";
	
	if (!($res_chup = pg_query($conn, $sql_chup )))
	{
		print pg_last_error() ."<BR>";
//		throw new Exception("データ取得に失敗<br />". $DelArea. "<br />". pg_last_error(). "<br />");
	}
	
}




//$row[chk] = "未確認";

//print_r($_POST);
//print_r($_GET);


print "<form enctype='multipart/form-data' action='$_SERVER[PHP_SELF]' method='post'>";
print "<INPUT TYPE='submit' NAME='reload' VALUE='画面更新' class='button'>";
print "</form>";
print "<HR>";


//■申請処理
if($_POST['request'])
{
	print "【新規申請】<BR>";
	
	if($_POST['send_address'])
	{
		//現在のデータ登録数を取得(ファイル名の頭につける)
		$sql_max = "SELECT max(id) FROM inspection_record;";
		$res_max = pg_query($conn,$sql_max);
		$row_max = pg_fetch_array($res_max,0);
		$id = $row_max[0] + 1;
		
		
		//print $id ."<BR>";// "seq==" .$row_seq[0] ."<BR>";
		
		//一時フォルダ内のファイルの削除(調書・画像)
		deleteData ($tmp_record_dir);
		deleteData ($tmp_pict_dir);
		
		//アップロードファイルの確認(一時的に保存)
		//①調書ファイルがあれば処理実行
		if(isset($_FILES['upfile_record']))
		{

		    // アップロードされたファイル件を処理
		    for($i = 0; $i < count($_FILES['upfile_record']['name']); $i++ )
		    {
		        // アップロードされたファイルか検査
		        if(is_uploaded_file($_FILES['upfile_record']['tmp_name'][$i]))
		        {
        			//ファイル名をナンバリングする
        			$ii = $i+1;
		        	$record_file_name = $id ."_" .$ii ."_" .$_FILES['upfile_record']['name'][$i];
		        	
		        	//データベース登録用(ファイル名:aaaa.pdf,bbbb.pdf・・・)
		        	$record_regist_name .= ($i >= 1) ? "," :"";
		        	$record_regist_name .= $record_file_name;
		            //ファイルを一時保存フォルダへ移動
		            move_uploaded_file($_FILES['upfile_record']['tmp_name'][$i], "./tmp_record/" .$record_file_name);
		        }
		    }
		}

		//②画像ファイルがあれば処理実行
		if(isset($_FILES['upfile_pict']))
		{
		    // アップロードされたファイル件を処理
		    for($j = 0; $j < count($_FILES['upfile_pict']['name']); $j++ )
		    {
		        // アップロードされたファイルか検査
		        if(is_uploaded_file($_FILES['upfile_pict']['tmp_name'][$j]))
		        {
        			//ファイル名をナンバリングする
        			$jj = $j+1;
		        	$pict_file_name = $id ."_" .$jj ."_" .$_FILES['upfile_pict']['name'][$j];
		        	
		        	//データベース登録用(ファイル名:aaaa.pdf,bbbb.pdf・・・)
		        	$pict_regist_name .= ($j >= 1) ? "," :"";
		        	$pict_regist_name .= $pict_file_name;
		            
		            // ファイルをお好みの場所に移動
		            $tmp_pict_path =  "/www/geye/tmp_pict/" .$pict_file_name;
		            move_uploaded_file($_FILES['upfile_pict']['tmp_name'][$j],$tmp_pict_path);
		            
		            //サムネイル画像作成
		            ThumbnailMake($tmp_pict_path,77,75);
		            
		        }
		    }
		}

				
		print "以下の内容で申請します。よろしいですか?";
		print "<BR>";
		print "※申請先メールアドレスへメールが送信されます";

		print "<TABLE BORDER=\"1\">";
		print "<TR>";
		print "<TH BGCOLOR='blue' WIDTH='150'><FONT SIZE ='2' COLOR='white'>申請先メールアドレス</FONT></TH>";
		print "<TD WIDTH='200'>" .$_POST['send_address'] ."</TD>";
		print "</TR>";
		print "<TR>";
		
		
		//	print "<TD WIDTH='200'>";
	//	print Pulldown_create_int(60,"date_y_",2020,2025,1,$date_y,0) ."年";
	//	print Pulldown_create_int(30,"date_m_",1,13,1,$date_m,0) ."月";
	//	print Pulldown_create_int(40,"date_d_",1,32,1,$date_d,0) ."日";
	//	print Pulldown_create_int(50,"time_h_",0,60,1,$time_h,0) ."時";
	//	print Pulldown_create_int(50,"time_m_",0,60,1,$time_m,0) ."分";
		
		$make_date = $_POST['date_y_'] ."年" .$_POST['date_m_'] ."月" .$_POST['date_d_'] ."日";
		$make_date .=   $_POST['time_h_'] ."時" .$_POST['time_m_'] ."分";
		$mk_date_reg = mktime($_POST['time_h_'],$_POST['time_m_'],0,$_POST['date_m_'],$_POST['date_d_'],$_POST['date_y_']);
	//	print $mk_date_reg;
		
		
		print "<TH BGCOLOR='blue' WIDTH='20'><FONT SIZE ='2' COLOR='white'>希望日</FONT></TH>";
		print "<TD WIDTH='200'>" .$make_date ."</TD>";
		print "</TR>";
		print "<TR>";
		print "<TH BGCOLOR='blue' WIDTH='130'><FONT SIZE ='2' COLOR='white'>場所</FONT></TH>";
		print "<TD WIDTH='200'>" .$_POST['place_reg'] ."</TD>";
		print "</TR>";
		print "<TR>";
		print "<TH BGCOLOR='blue' WIDTH='130'><FONT SIZE ='2' COLOR='white'>工種</FONT></TH>";
		print "<TD WIDTH='200'>" .$_POST['construction_reg'] ."</TD>";
		print "</TR>";
		print "<TR>";
		print "<TH BGCOLOR='blue' WIDTH='130'><FONT SIZE ='2' COLOR='white'>検査項目</FONT></TH>";
		print "<TD WIDTH='200'>" .$_POST['inspection_name_reg'] ."</TD>";
		print "</TR>";
		print "<TR>";
		print "<TH BGCOLOR='blue' WIDTH='100'><FONT SIZE ='2' COLOR='white'>監理技術者</FONT></TH>";
		print "<TD WIDTH='200'>" .$_POST['supervision_engineer_reg'] ."</TD>";
		print "</TR>";
		print "</TABLE>";

		print "<form enctype='multipart/form-data' action='$_SERVER[PHP_SELF]' method='post'>";
		print "<INPUT TYPE='submit' NAME='sentaku_yes' VALUE='はい' class='button'>";
		print "<INPUT TYPE='submit' NAME='sentaku_no' VALUE='いいえ' class='button'>";

		print "<INPUT TYPE='hidden' NAME='send_address' VALUE='" .$_POST['send_address'] ."'>";
		print "<INPUT TYPE='hidden' NAME='scheduled_date_reg' VALUE='" .$mk_date_reg ."'>";
		print "<INPUT TYPE='hidden' NAME='place_reg' VALUE='" .$_POST['place_reg'] ."'>";
		print "<INPUT TYPE='hidden' NAME='construction_reg' VALUE='" .$_POST['construction_reg'] ."'>";
		print "<INPUT TYPE='hidden' NAME='inspection_name_reg' VALUE='" .$_POST['inspection_name_reg'] ."'>";
		print "<INPUT TYPE='hidden' NAME='supervision_engineer_reg' VALUE='" .$_POST['supervision_engineer_reg'] ."'>";
		print "<INPUT TYPE='hidden' NAME='record_reg' VALUE='" .$record_regist_name ."'>";
		print "<INPUT TYPE='hidden' NAME='pict_reg' VALUE='" .$pict_regist_name ."'>";
		print "</form>";
	}
	else
	{
		print "正しいメールアドレスを入力してください。";
	}
}
else if($_POST['edit_id'])
{
	$sql_e = "SELECT * FROM inspection_record WHERE id =" .$_POST['edit_id'] ." ORDER BY scheduled_date DESC;";
	$res_e = pg_query($conn,$sql_e);
	$row_e = pg_fetch_array($res_e,0);
	
	$scheduled_date = $row_e['scheduled_date'];					//希望日
	$place = $row_e['place'];							//場所
  	$construction = $row_e['construction'];						//工種
	$inspection_name = $row_e['inspection_name'];				//検査項目
  	$supervision_engineer = $row_e['supervision_engineer'];		//管理技術者
  	$confirmer = $row_e['confirmer'];							//確認者
	$implementation_date = $row_e['implementation_date'];		//実施日
	$record = $row_e['record'];									//調書(ファイル名1,ファイル名2,・・・)
	$pict = $row_e['pict'];										//写真(ファイル名1,ファイル名2,・・・)
	$memo = $row_e['memo'];										//記事(メモ)
  	$updatetime = $row_e['updatetime'];							//更新日時(最終編集日時)
  	$regdatetime = $row_e['updatetime'];						//登録日時(申請日時)
	$chk_flag = $row_e['chk_flag'];								//確認フラグ(true:確認済み、false:未確認)
  	$del_flag = $row_e['del_flag'];								//削除フラグ(true:無効データ[削除状態]、false:有効データ)
  	$request_status = $row_e['request_status'];					//立会承認(0:未承認、1:承認済、2:差戻、3:メール未送信)
  	$mail_address = $row_e['mail_address'];						//メールアドレス(承認先)
	
	
	//■申請先メールアドレス
	//立会承認が"メール未送信"の場合のみ、編集可能
	$mail_disabled = ($request_status == 3) ? "":"disabled='disabled'";

	
	print "【編集中】<BR>";
	print "<form enctype='multipart/form-data' action='$_SERVER[PHP_SELF]' method='post'>";
	print "<TABLE BORDER=\"1\">";
	print "<TR>";
	print "<TH BGCOLOR='blue' WIDTH='150'><FONT SIZE ='2' COLOR='white'>申請先メールアドレス</FONT></TH>";
	print "<TD WIDTH='200'><INPUT TYPE='text' size='40'  NAME='send_address' " .$mail_disabled ."></TD>";
	print "</TR>";
	print "<TR>";
	print "<TH BGCOLOR='blue' WIDTH='20'><FONT SIZE ='2' COLOR='white'>希望日</FONT></TH>";
	print "<TD WIDTH='240'>";
	print Pulldown_create_int(60,"date_y_",2020,2025,1,$date_y,0) ."年";
	print Pulldown_create_int(60,"date_m_",1,13,1,$date_m,0) ."月";
	print Pulldown_create_int(60,"date_d_",1,32,1,$date_d,0) ."日";
	print "<BR>";
	print Pulldown_create_int(60,"time_h_",0,60,1,$time_h,0) ."時";
	print Pulldown_create_int(60,"time_m_",0,60,1,$time_m,0) ."分";
	print "</TD>";
	print "</TR>";
	print "<TR>";
	print "<TH BGCOLOR='blue' WIDTH='130'><FONT SIZE ='2' COLOR='white'>場所</FONT></TH>";
	print "<TD WIDTH='200'><INPUT TYPE='text' size='40' NAME='place_reg' VALUE='" .$place ."'></TD>";
	print "</TR>";
	print "<TR>";
	print "<TH BGCOLOR='blue' WIDTH='130'><FONT SIZE ='2' COLOR='white'>工種</FONT></TH>";
	print "<TD WIDTH='200'><INPUT TYPE='text' size='40' NAME='construction_reg' VALUE='" .$construction ."'></TD>";
	print "</TR>";
	print "<TR>";
	print "<TH BGCOLOR='blue' WIDTH='130'><FONT SIZE ='2' COLOR='white'>検査項目</FONT></TH>";
	print "<TD WIDTH='200'><INPUT TYPE='text' size='40' NAME='inspection_name_reg' VALUE='" .$inspection_name ."'></TD>";
	print "</TR>";
	print "<TR>";
	print "<TH BGCOLOR='blue' WIDTH='100'><FONT SIZE ='2' COLOR='white'>監理技術者</FONT></TH>";
	print "<TD WIDTH='200'><INPUT TYPE='text' size='40' NAME='supervision_engineer_reg' VALUE='" .$supervision_engineer ."'></TD>";
	print "</TR>";
	print "<TR>";
	print "<TH BGCOLOR='blue' WIDTH='100'><FONT SIZE ='2' COLOR='white'>確認者</FONT></TH>";
	print "<TD WIDTH='200'><INPUT TYPE='text' size='40' NAME='supervision_engineer_reg' VALUE='" .$confirmer ."'></TD>";
	print "</TR>";
	print "<TR>";
	print "<TH BGCOLOR='blue' WIDTH='100'><FONT SIZE ='2' COLOR='white'>実施日</FONT></TH>";
	print "<TD WIDTH='200'>";
	//<INPUT TYPE='text' size='40' NAME='supervision_engineer_reg' VALUE='" .$implementation_date ."'>
	print Pulldown_create_int(60,"date_y_",2020,2025,1,$date_y,0) ."年";
	print Pulldown_create_int(60,"date_m_",1,13,1,$date_m,0) ."月";
	print Pulldown_create_int(60,"date_d_",1,32,1,$date_d,0) ."日";
	print "<BR>";
	print Pulldown_create_int(60,"time_h_",0,60,1,$time_h,0) ."時";
	print Pulldown_create_int(60,"time_m_",0,60,1,$time_m,0) ."分";
	print "</TD>";
	print "</TR>";
	print "<TR>";
	print "<TH BGCOLOR='blue' WIDTH='100'><FONT SIZE ='2' COLOR='white'>調書</FONT></TH>";
	print "<TD WIDTH='200'><INPUT TYPE='file' multiple NAME='upfile_record[]' size='40'></TD>";
	print "</TR>";
	print "<TR>";
	print "<TH BGCOLOR='blue' WIDTH='100'><FONT SIZE ='2' COLOR='white'>写真</FONT></TH>";
	print "<TD WIDTH='200'><INPUT TYPE='file' multiple NAME='upfile_pict[]' size='40'></TD>";
	print "</TR>";
	print "<TR>";
	print "<TH BGCOLOR='blue' WIDTH='100'><FONT SIZE ='2' COLOR='white'>記事</FONT></TH>";
	print "<TD WIDTH='200'><INPUT TYPE='text' size='40' NAME='supervision_engineer_reg' ></TD>";
	print "</TR>";
	print "</TABLE>";



	//■再申請ボタンの表示・非表示
	//立会承認が"差戻"、"メール未送信"の場合、"再申請"ボタンの表示
	if($request_status >= 2)
	{
		print "<INPUT TYPE='submit' NAME='edit_request' VALUE='再申請' class='button'>";
	}
	
	print "<INPUT TYPE='submit' NAME='edit_save' VALUE='保存' class='button'>";
	print "<INPUT TYPE='submit' NAME='edit_cancel' VALUE='キャンセル' class='button'>";
	print "</form>";
	

	
	//写真の表示
/*
		print "<TD>";
		
		for($cp = 0 ;$cp < $pict_ct;$cp++)
		{
			if($pict[$cp])
			{
				$thum_name = "inspection/pict/" .str_replace("." ,"_s." ,$pict[$cp]);
				$pict_name = "inspection/pict/" .$pict[$cp];
				print "<a href='download.php?f=" .$pict_name ."'.><img src='" .$thum_name ."' alt='" .$pict_name ."'></a>";
				print "&nbsp;&nbsp;";
			}
		}

		print "&nbsp;</TD>";
		print "<TD>" .$memo ."&nbsp;</TD>";
		print "</TR>";
*/

}
else
{
	print "【新規申請】<BR>";
	if($_POST['sentaku_yes'])
	{
		//データの登録
		$sql_ins = "INSERT INTO inspection_record(scheduled_date, place, construction, inspection_name, supervision_engineer,";
        $sql_ins .= "record, pict,updatetime,regdatetime, mail_address) VALUES (";
        $sql_ins .= "'" .date("Y-m-d H:i", $_POST['scheduled_date_reg']) ."',";
        $sql_ins .= "'" .$_POST['place_reg'] ."',";
        $sql_ins .= "'" .$_POST['construction_reg'] ."',";
        $sql_ins .= "'" .$_POST['inspection_name_reg'] ."',";
        $sql_ins .= "'" .$_POST['supervision_engineer_reg'] ."',";
        $sql_ins .= "'" .$_POST['record_reg'] ."',";
        $sql_ins .= "'" .$_POST['pict_reg'] ."',";
        $sql_ins .= "'" .date("Y-m-d H:i", time()) ."',";
        $sql_ins .= "'" .date("Y-m-d H:i", time()) ."',";
        $sql_ins .= "'" .$_POST['send_address'] ."')";

		$res_ins = pg_query($conn,$sql_ins) or die(pg_last_error() ."<BR>" .$sql_ins);

		//一時ファイルを本来アップロードするフォルダへ移動
		moveData($tmp_record_dir,$record_dir);
		moveData($tmp_pict_dir,$pict_dir);

		
		//現在のデータ登録数を取得
		$sql_max = "SELECT max(id) FROM inspection_record;";
		$res_max = pg_query($conn,$sql_max);
		$row_max = pg_fetch_array($res_max,0);
		$id = $row_max[0];
//		print $count;

		
		//承認用URLの作成
		$ok_url = "https://penta-02.ptgw.net/geye/data_update.php?id=" .$id ."&request=1";
		
		//否認用URLの作成
		$ng_url = "https://penta-02.ptgw.net/geye/data_update.php?id=" .$id ."&request=2";


		
		//■内部文字エンコーディングを設定 
		mb_internal_encoding("ISO-2022-JP");

		//ヘッダー設定
		$header  = "From: " ."五洋立会申請" ."<www@penta-05.ptgw2.net>" ."\n";
		$header .= "Reply-To: " ."五洋立会申請" ."<www@penta-05.ptgw2.net>" ."\n";
		//$header.= "Cc: " .$send_to1 ."," .$send_to2 ."\n";
		//$header.= "Bcc: " ."'blue.puny@gmail.com'" ."\n";
		$header .= "Content-Type: text/html;charset=ISO-2022-JP" ."\n";
		$header .= "X-Mailer: myphpMail ". phpversion(). "\n";

		//件名設定
		$Subject = mb_convert_encoding("【立会申請】","ISO-2022-JP","UTF-8");
		//print $_POST['scheduled_date_reg'];
		//本文設定
		$message = mb_convert_encoding("※このメールはシステム側から送信しています" ."<BR><BR>" ,"ISO-2022-JP","UTF-8");
		$message .= mb_convert_encoding("以下の内容で立会申請がされました。" ."<BR>" ,"ISO-2022-JP","UTF-8");
		$message .= mb_convert_encoding("承認・差戻を選択してURLをクリックしてください。" ."<BR>" ,"ISO-2022-JP","UTF-8");
		$message .= mb_convert_encoding("選択を誤ってしまった場合は、正しい方をクリックしなおしてください。" ."<BR><BR>" ,"ISO-2022-JP","UTF-8");
		
		$message .= mb_convert_encoding("[承認]" .$ok_url ."<BR><BR>" ,"ISO-2022-JP","UTF-8");
		$message .= mb_convert_encoding("[差戻]" .$ng_url ."<BR><BR>" ,"ISO-2022-JP","UTF-8");

		$message .= mb_convert_encoding("希望日時 :" .date("Y年m月d日 H時i分" ,($_POST['scheduled_date_reg'])) ."<BR>" ,"ISO-2022-JP","UTF-8");
		$message .= mb_convert_encoding("場所   :" .$_POST['place_reg'] ."<BR>" ,"ISO-2022-JP","UTF-8");
		$message .= mb_convert_encoding("工種   :" .$_POST['construction_reg'] ."<BR>" ,"ISO-2022-JP","UTF-8");
		$message .= mb_convert_encoding("検査項目 :" .$_POST['inspection_name_reg'] ."<BR>","ISO-2022-JP","UTF-8");
		$message .= mb_convert_encoding("監理技術者:" .$_POST['supervision_engineer_reg'],"ISO-2022-JP","UTF-8");
		$message = wordwrap($message, 70);

		//送信する
		//print "送信しました" ."<BR>";

//		$test = mb_send_mail("kikuchi.katsumi@gmail.com", $Subject , $message,$header);

		if(mb_send_mail($_POST['send_address'], $Subject , $message,$header))
		{
			print "<script type='text/javascript'>";
			print "alert('メールを送信しました');";
			print "</script>";
		}
		
	}
	else if($_POST['sentaku_no'])
	{
			print "<script type='text/javascript'>";
			print "alert('メールを送信しませんでした');";
			print "</script>";
	}
	
	
	print "<form enctype='multipart/form-data' action='$_SERVER[PHP_SELF]' method='post'>";
	print "<TABLE BORDER=\"1\">";
	print "<TR>";
	print "<TH BGCOLOR='blue' WIDTH='150'><FONT SIZE ='2' COLOR='white'>申請先メールアドレス</FONT></TH>";
	print "<TD WIDTH='200'><INPUT TYPE='text' size='40' NAME='send_address' ></TD>";
	print "</TR>";
	print "<TR>";
	print "<TH BGCOLOR='blue' WIDTH='20'><FONT SIZE ='2' COLOR='white'>希望日</FONT></TH>";
	print "<TD WIDTH='240'>";
	print Pulldown_create_int(60,"date_y_",2020,2025,1,$date_y,0) ."年";
	print Pulldown_create_int(60,"date_m_",1,13,1,$date_m,0) ."月";
	print Pulldown_create_int(60,"date_d_",1,32,1,$date_d,0) ."日";
	print "<BR>";
	print Pulldown_create_int(60,"time_h_",0,60,1,$time_h,0) ."時";
	print Pulldown_create_int(60,"time_m_",0,60,1,$time_m,0) ."分";
	print "</TD>";
	print "</TR>";
	print "<TR>";
	print "<TH BGCOLOR='blue' WIDTH='130'><FONT SIZE ='2' COLOR='white'>場所</FONT></TH>";
	print "<TD WIDTH='200'><INPUT TYPE='text' size='40' NAME='place_reg' ></TD>";
	print "</TR>";
	print "<TR>";
	print "<TH BGCOLOR='blue' WIDTH='130'><FONT SIZE ='2' COLOR='white'>工種</FONT></TH>";
	print "<TD WIDTH='200'><INPUT TYPE='text' size='40' NAME='construction_reg' ></TD>";
	print "</TR>";
	print "<TR>";
	print "<TH BGCOLOR='blue' WIDTH='130'><FONT SIZE ='2' COLOR='white'>検査項目</FONT></TH>";
	print "<TD WIDTH='200'><INPUT TYPE='text' size='40' NAME='inspection_name_reg' ></TD>";
	print "</TR>";
	print "<TR>";
	print "<TH BGCOLOR='blue' WIDTH='100'><FONT SIZE ='2' COLOR='white'>監理技術者</FONT></TH>";
	print "<TD WIDTH='200'><INPUT TYPE='text' size='40' NAME='supervision_engineer_reg' ></TD>";
	print "</TR>";
	print "<TR>";
	print "<TH BGCOLOR='blue' WIDTH='100'><FONT SIZE ='2' COLOR='white'>調書</FONT></TH>";
	print "<TD WIDTH='200'><INPUT TYPE='file' multiple NAME='upfile_record[]' size='40'></TD>";
	print "</TR>";
	print "<TR>";
	print "<TH BGCOLOR='blue' WIDTH='100'><FONT SIZE ='2' COLOR='white'>写真</FONT></TH>";
	print "<TD WIDTH='200'><INPUT TYPE='file' multiple NAME='upfile_pict[]' size='40'></TD>";
	print "</TR>";
	print "</TABLE>";

	print "<INPUT TYPE='submit' NAME='request'  VALUE='申請' class='button'>";
	print "</form>";

	print "<BR>";
	print "チェック項目の ";
	print "<INPUT TYPE='submit' NAME='download' VALUE='ダウンロード' class='button'>";
	print "<INPUT TYPE='submit' NAME='delite' VALUE='削除' onclick='goDeleteServlet()' class='hoge button'>";

	print "<TABLE BORDER=\"1\">";
	print "<TR BGCOLOR='blue'>";
	print "<TH WIDTH='20' COLSPAN='2'><FONT SIZE ='2' COLOR='white'>CB</FONT></TH>";
	print "<TH WIDTH='130'><FONT SIZE ='2' COLOR='white'>立会承認</FONT></TH>";
	print "<TH WIDTH='130'><FONT SIZE ='2' COLOR='white'>確認</FONT></TH>";
	print "<TH WIDTH='130'><FONT SIZE ='2' COLOR='white'>希望日</FONT></TH>";
	print "<TH WIDTH='100'><FONT SIZE ='2' COLOR='white'>場所</FONT></TH>";
	print "<TH WIDTH='100'><FONT SIZE ='2' COLOR='white'>工種</FONT></TH>";
	print "<TH WIDTH='120'><FONT SIZE ='2' COLOR='white'>検査項目</FONT></TH>";
	print "<TH WIDTH='100'><FONT SIZE ='2' COLOR='white'>管理技術者</FONT></TH>";
	print "<TH WIDTH='100'><FONT SIZE ='2' COLOR='white'>確認者</FONT></TH>";
	print "<TH WIDTH='100'><FONT SIZE ='2' COLOR='white'>実施日</FONT></TH>";
	print "<TH WIDTH='50'><FONT SIZE ='2' COLOR='white'>調書</FONT></TH>";
	print "<TH WIDTH='50'><FONT SIZE ='2' COLOR='white'>写真</FONT></TH>";
	print "<TH WIDTH='50'><FONT SIZE ='2' COLOR='white'>記事</FONT></TH>";
	print "</TR>";

	//$test = date("Y/m/d H:i",time());

	//現在のデータの抽出
	$sql_v = "SELECT * FROM inspection_record WHERE del_flag ='false' ORDER BY scheduled_date DESC;";
	$res_v = pg_query($conn,$sql_v);
	$ct_v = pg_num_rows($res_v);



	for($i = 0 ;$i < $ct_v;$i++)
	{
		print "<TR ALIGN='center'>";
		$row = pg_fetch_array($res_v,$i);

		$no = $row[0];
		$scheduled_date = date("Y-m-d" ,strtotime($row[1])) ."<BR>" .date("H:i" ,strtotime($row[1]));
		$place =  $row[2];
		$construction =  $row[3];
		$inspection_name = $row[4];
		$supervision_engineer = $row[5];
		$confirmer = $row[6];
		$implementation_date = ($row[7]) ? date("Y-m-d" ,strtotime($row[7])) : "";
		$record =  explode(",",$row[8]);
		$record_ct =  count($record);
		$pict =  explode(",",$row[9]);
		$pict_ct = count($pict);
		
		if($row[15] == 0)
		{
			$request_status = "承認待ち";
		}
		else if($row[15] == 1)
		{
			$request_status = "承認済";
		}
		else if($row[15] == 2)
		{
			$request_status = "<FONT color= 'red'>差戻";
			$request_status .= "<BR>※条件を変えて<BR>再申請して下さい</FONT><BR>";
		}
		else
		{
			$request_status = "<FONT color= 'red'>メール送信失敗";
			$request_status .= "<BR>※アドレスを確認し<BR>再申請して下さい</FONT><BR>";
		}
		
			

		$memo =  $row[10];
		$updatetime =  $row[11];
		$regdatetime =  $row[12];
		$chk_flag = ($row[13] === f) ? '--------':'確認済';

		//確認者・実施日のテキストボックスの有効/無効切り替え
		$disabled = ($row[13] === f) ? "":"disabled='disabled'";


		print "<TD><INPUT TYPE='checkbox' NAME='check' VALUE='$no' ></TD>";
		
				
		print "<FORM enctype='multipart/form-data' action='$_SERVER[PHP_SELF]' method='post'>";
		print "<TD><INPUT TYPE='submit' NAME='edit[]' VALUE='編集'>";
		print "<INPUT TYPE='hidden' NAME='edit_id' VALUE='" .$no ."'>";
		
		print "</FORM>";
		print "</TD>";



		print "<TD><FONT SIZE ='2'>" .$request_status ."</FONT></TD>";
		print "<TD>" .$chk_flag ."&nbsp;</TD>";
		print "<TD><FONT SIZE ='2'>" .$scheduled_date ."</FONT></TD>";
		print "<TD>" .$place ."&nbsp;</TD>";
		print "<TD>" .$construction ."&nbsp;</TD>";


		//確認者_実施日
		print "<TD>" .$inspection_name ."&nbsp;</TD>";
		print "<TD>" .$supervision_engineer ."&nbsp;</TD>";
		print "<TD>" .$confirmer ."&nbsp;</TD>";
		print "<TD>" .$implementation_date ."</TD>";
//		print "<TD><INPUT TYPE='text' size='10' NAME='implementation_date' VALUE='$implementation_date' "  .$disabled ."></TD>";
		//調書のダウンロードリンク表示
		print "<TD>";

		for($cp = 0 ;$cp < $record_ct;$cp++)
		{
			if($record[$cp])
			{
				$record_name = $record[$cp];
				$record_name_v = explode("_",$record[$cp]);
				print "<a href='download.php?u=1&f=" .$record_name ."'>" .$record_name_v[2] ."</a><BR>";
			}
		}

		print "&nbsp;</TD>";
		
		//写真の表示
		print "<TD ALIGN='left'>";
		
		for($cp = 0 ;$cp < $pict_ct;$cp++)
		{
			if($pict[$cp])
			{
				$thum_name = "inspection/pict/" .str_replace("." ,"_s." ,$pict[$cp]);
				$pict_name = $pict[$cp];
				print "<a href='download.php?u=2&f=" .$pict_name ."'.><img src='" .$thum_name ."' alt='" .$pict_name ."'></a>";
				print "&nbsp;&nbsp;";
			}
		}

		print "&nbsp;</TD>";
		print "<TD>" .$memo ."&nbsp;</TD>";
		print "</TR>";

	}

	print "</TABLE>";
}






?>

<!--
<BR>
<INPUT type="button" onclick="location.href='menu.php'" value="メニューへ戻る" style="WIDTH: 120px; HEIGHT: 50px">
<INPUT TYPE="submit" NAME="prc"  VALUE="チェックを入れた項目が非表示になります" style="WIDTH: 300px; HEIGHT: 50px">
</FORM>
</FONT>
<HR>
<FONT SIZE=4 COLOR="#000000" FACE="Arial">
<CENTER><B><I>penta-ocean</I></B></CENTER>
</FONT>
-->
	
</BODY>
</HTML>

PHP File Manager