"; } else if($dl_type_ == 1) { //$list_no = filemtime($dir .$file); $list_no = $time_list[$fct]; print "" .$file_list[$fct] ."
"; print "
"; print " "; print " "; print " "; print " "; print "
"; } else { $thum_name = "./inspection/" .$id_ ."/pict_s/" .str_replace("." ,"_s." ,$file_list[$fct]); print ""; print "" .$file_list[$fct] .""; print "  "; } } } } //------------------------------------------------------------------------------------------------ //初期値設定 //------------------------------------------------------------------------------------------------ //$age = $_SERVER['HTTP_USER_AGENT']; //print $age ."
"; //アップロード時の保存パス //$record_dir = '/www/geye/inspection/record/'; //$pict_dir = '/www/geye/inspection/pict/'; //$pict_dir_s = '/www/geye/inspection/pict_s/'; //■アップロード時の保存パス $save_dir = "/www/geye/inspection/"; $record_dir = "/record/"; $pict_dir = "/pict/"; $pict_dir_s = "/pict_s/"; $delete_dir = "/delete/"; $upload_pict_dir = "/www/geye/pict/"; //print time(); //zip保存用 $zip_dir = '/geye/'; //削除時のPOSTのデータを取得 $del = $_POST['del']; $yes_ = $_POST['yes_']; $no_ = $_POST['no_']; //GETデータの出力(データ抽出) EXTRACT($_GET); print_r($_GET); print_r($_POST); //------------------------------------------------------------------------------------------------- // DB接続設定(サーバ/データベース/ユーザ/パスワード) //------------------------------------------------------------------------------------------------- $sv = "192.168.100.153"; $dbname = "geye"; $user = "postgres"; $pass = "postgres"; $conn = pg_connect("host=$sv dbname=$dbname user=$user password=$pass") or die("接続エラー"); //------------------------------------------------------------------------------------------------- // 調書に使用する項目リストをDBから取得 //------------------------------------------------------------------------------------------------- //$sql_item = "SELECT * FROM check_item_name ORDER BY id;"; //$res_item = pg_query($conn,$sql_item); //$count_item = pg_num_rows($res_item); //------------------------------------------------------------------------------------------------- //検査項目のリストをDBから取得 //------------------------------------------------------------------------------------------------- //■DBから最新データの抽出 /* $sql_i = "SELECT DISTINCT(inspection_id),inspection_name FROM check_item_name2 WHERE del_flag ='false' ORDER BY inspection_id;"; $res_i = pg_query($conn,$sql_i); $ct_i = pg_num_rows($res_i); $inspection_id_ = array(); $inspection_name_ = array(); for($z=0;$z < $ct_i;$z++) { $row = pg_fetch_array($res_i,$z); $id_ = $row['inspection_id']; $inspection_id_[$id_] = $row['inspection_id']; $inspection_name_[$id_] = $row['inspection_name']; } */ //------------------------------------------------------------------------------------------------- // アップロードされた画像の振り分け //------------------------------------------------------------------------------------------------- if($_POST['pictupload']) { $sql_p = "SELECT * FROM inspection_record WHERE del_flag=false ORDER BY scheduled_date desc;"; $res_p = pg_query($conn,$sql_p); $count_p = pg_num_rows($res_p); //対象データの期間(デフォルト3時間) $range_1 = 10800; //秒 $range_2 = 10800; //秒 for($p=0;$p<$count_p;$p++) { $row_p = pg_fetch_array($res_p,$p); $id = $row_p['id']; $schedul_unix = strtotime($row_p['scheduled_date']); $schedul_date = date("Ymd" ,$schedul_unix); //希望日から*時間前 $past_unix = $schedul_unix - $range_1; $past_date = date("Ymd" ,$past_unix); //希望日から*時間後 $future_unix = $schedul_unix + $range_2; $future_date = date("Ymd" ,$future_unix); //今日のフォルダ画像を検索 $upload_pict_dir_ = $upload_pict_dir .$schedul_date; if ($dirHandle = opendir ($upload_pict_dir_)) { while ( false !== ( $fileName = readdir ( $dirHandle))) { if ( $fileName != "." && $fileName != ".." ) { //ファイルの更新時間 $file_datetime = filemtime($upload_pict_dir_ ."/" .$fileName); //print $id ."_" .$past_unix ."_" .$file_datetime ."_" .$future_unix ."
"; if(($past_unix < $file_datetime) && ($file_datetime < $future_unix)) { //print $id ."_" .$past_unix ."_" .$file_datetime ."_" .$future_unix ."_" .$fileName ."
"; copy($upload_pict_dir_ ."/" .$fileName , $save_dir .$id .$pict_dir.$fileName ); ThumbnailMake($save_dir .$id .$pict_dir,$fileName,$save_dir .$id .$pict_dir_s ,77,75); } } } closedir ( $dirHandle ); } if($schedul_date != $past_date) { print "前日"; //前日のフォルダ画像を検索 $upload_pict_dir_ = $upload_pict_dir .$past_date; //print $upload_pict_dir_ ."
"; if ($dirHandle = opendir ($upload_pict_dir_)) { while ( false !== ( $fileName = readdir ( $dirHandle))) { if ( $fileName != "." && $fileName != ".." ) { //ファイルの更新時間 $file_datetime = filemtime($upload_pict_dir_ ."/" .$fileName); //print $id ."_" .$past_unix ."_" .$file_datetime ."_" .$future_unix ."
"; if(($past_unix < $file_datetime) && ($file_datetime < $future_unix)) { //print $id ."_" .$past_unix ."_" .$file_datetime ."_" .$future_unix ."
"; copy($upload_pict_dir_ ."/" .$fileName , $save_dir .$id .$pict_dir.$fileName ); ThumbnailMake($save_dir .$id .$pict_dir,$fileName,$save_dir .$id .$pict_dir_s ,77,75); } } } closedir ( $dirHandle ); } } if($schedul_date != $future_date) { print "後日"; //後日のフォルダ画像を検索 $upload_pict_dir_ = $upload_pict_dir .$future_date; //print $upload_pict_dir_ ."
"; if ($dirHandle = opendir ($upload_pict_dir_)) { while ( false !== ( $fileName = readdir ( $dirHandle))) { if ( $fileName != "." && $fileName != ".." ) { //ファイルの更新時間 $file_datetime = filemtime($upload_pict_dir_ ."/" .$fileName); if(($past_unix < $file_datetime) && ($file_datetime < $future_unix)) { //print $id ."_" .$past_unix ."_" .$file_datetime ."_" .$future_unix ."
"; copy($upload_pict_dir_ ."/" .$fileName , $save_dir .$id .$pict_dir.$fileName ); ThumbnailMake($save_dir .$id .$pict_dir,$fileName,$save_dir .$id .$pict_dir_s ,77,75); } } } closedir ( $dirHandle ); } } } } //------------------------------------------------------------------------------------------------- //フォームアクション処理(削除・確認画面・ダウンロード) //------------------------------------------------------------------------------------------------- //■確認処理 if($chk) { /* //現在の確認状況を取得 $sql_ch = "SELECT * FROM inspection_record_t WHERE id = " .$chk ." AND del_flag ='false' ;"; $res_ch = pg_query($conn,$sql_ch); $row_ch = pg_fetch_array($res_ch,0); $chk_flag = ($row_ch['chk_flag'] == 'f') ? "true" : "false"; $sql_chup = "UPDATE inspection_record_t SET "; $sql_chup .= "confirmer = '" .$conf ."', "; $sql_chup .= "implementation_date = '" .$imp ."',"; $sql_chup .= "memo = '" .$memo ."',"; $sql_chup .= "chk_flag = '" .$chk_flag ."' "; $sql_chup .= " WHERE id = " .$chk .";"; if (!($res_chup = pg_query($conn, $sql_chup ))) ;//print pg_last_error() ."
"; */ //現在の確認状況を取得 $sql_chup = "UPDATE inspection_record SET "; $sql_chup .= ($conf) ? "confirmer = '" .$conf ."'," : "confirmer = null,"; $sql_chup .= ($imp) ? "implementation_date = '" .$imp ."'," : "implementation_date = null,"; $sql_chup .= ($memo) ? "memo = '" .$memo ."'" : "memo = null"; $sql_chup .= " WHERE id = " .$chk .";"; if (!($res_chup = pg_query($conn, $sql_chup ))) ;//print pg_last_error() ."
"; } //------------------------------------------------------------------------------------------------- // データの一覧表の作成 //------------------------------------------------------------------------------------------------- //■削除処理 if($yes_) { $DelSql = "UPDATE inspection_record SET "; $DelSql .= "del_flag = 'TRUE' "; $DelSql .= " WHERE id IN (" .$del .");"; if (!($resDelSql = pg_query($conn, $DelSql))) print pg_last_error() ."
"; print "対象のデータを削除しました" ."
"; //削除対象のIDを初期化 $del = ""; } else if($no_) { //削除対象のIDを初期化 $del = ""; } //■削除確認 if($del) { print "
"; //■DBから最新データの抽出 $sql_v = "SELECT * FROM inspection_record WHERE id in(" .$del .") AND del_flag ='false' ORDER BY id DESC;"; $res_v = pg_query($conn,$sql_v); $ct_v = pg_num_rows($res_v); //■フォームボタンの作成(ダウンロード・削除) print "以下のデータを削除してもよろしいですか?
"; print ""; print ""; print ""; print "
"; //■データ表の作成 print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; for($i = 0 ;$i < $ct_v;$i++) { $row = pg_fetch_array($res_v,$i); $no = $row[0]; $scheduled_date = date("Y/m/d" ,strtotime($row[1])) ."
" .date("H:i" ,strtotime($row[1])); $place = $row[2]; $construction = $row[3]; $inspection_name = $row[4]; $inspection_id = $row['inspection_id']; $supervision_engineer = $row[5]; $confirmer = $row[6]; $implementation_date = ($row[7]) ? date("Y-m-d" ,strtotime($row[7])) : ""; $memo = $row[8]; $updatetime = $row[9]; $regdatetime = $row[10]; $chk_flag = ($row[11] === f) ? '--------':'確認済'; print ""; //●確認者・実施日のテキストボックスの有効/無効切り替え $disabled = "disabled='disabled'"; print ""; //print ""; print ""; print ""; print ""; print ""; //●確認者 実施日 print ""; print ""; print ""; print ""; //●調書 print ""; //●写真の表示 print ""; //●記事の表示 print ""; print ""; } print "
No確認希望日場所工種検査項目管理技術者確認者実施日調書写真記事
" .$no ."" .$chk_flag ."" .$scheduled_date ."" .$place ." " .$construction ." " .$inspection_name ." " .$supervision_engineer ." " .$confirmer ." "; DlLinkMake(0,$no,$inspection_id,$save_dir,$record_dir,0); print ""; DlLinkMake(2,$no,0,$save_dir,$pict_dir,0); print " " .$memo ."
"; } else if($file_dl) { //■ダウンロード処理 //$file_dl = 0; //データidの分割 $id_ = explode(",",$file_dl); $id_count_ = count($id_); //zip用ファイルの初期化(削除) $cmd_del = "rm -Rf " .$zip_dir ."*"; exec($cmd_del); //deleteData($zip_dir); for($k = 0;$k < $id_count_ ;$k++) { //ZIP用のフォルダの作成 $zip_sub_dir = $zip_dir.$id_[$k]; mkdir($zip_sub_dir , 0777); $zip_sub_dir_rec = $zip_sub_dir ."/record/"; $zip_sub_dir_pict = $zip_sub_dir ."/pict/"; mkdir($zip_sub_dir_rec , 0777); mkdir($zip_sub_dir_pict , 0777); //対象ファイルをコピー $cmd_1 = "cp -a " .$save_dir .$id_[$k] .$record_dir ."*" ." " .$zip_sub_dir_rec; $cmd_2 = "cp -a " .$save_dir .$id_[$k] .$pict_dir ."*" ." " .$zip_sub_dir_pict; exec($cmd_1); exec($cmd_2); } //zipの作成 $file_name_date = date("YmdHis" ,time()); $zip_path = $zip_dir .$file_name_date .".zip"; //$zip_path = $id_[$k] .".zip"; $cmd_3 = "zip -r " .$zip_path ." /geye/*"; exec($cmd_3); //print $cmd_3 ; $file_name = $file_name_date .".zip"; $link = "http://penta-02.ptgw.net/geye/download.php?u=3&f=" .$file_name; print "
"; print ""; print "
"; print "【データのダウンロード】"; print "
"; print "   "; print "" .$file_name .""; // header("Location: $link"); // header('Location: https://penta-02.ptgw.net/geye/download.php?u=3&f=' .$file_name ); print "

"; print "【データ内容】"; //if($_POST['']) //■DBから最新データの抽出 $sql_v = "SELECT * FROM inspection_record WHERE id in(" .$file_dl .") AND del_flag ='false' ORDER BY id DESC;"; $res_v = pg_query($conn,$sql_v); $ct_v = pg_num_rows($res_v); //■フォームボタンの作成(ダウンロード・削除) //print ""; //■データ表の作成 print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; for($i = 0 ;$i < $ct_v;$i++) { $row = pg_fetch_array($res_v,$i); $no = $row[0]; $scheduled_date = date("Y/m/d" ,strtotime($row[1])) ."
" .date("H:i" ,strtotime($row[1])); $place = $row[2]; $construction = $row[3]; $inspection_name = $row[4]; $inspection_id = $row['inspection_id']; $supervision_engineer = $row[5]; $confirmer = $row[6]; $implementation_date = ($row[7]) ? date("Y-m-d" ,strtotime($row[7])) : ""; $memo = $row[8]; $updatetime = $row[9]; $regdatetime = $row[10]; $chk_flag = ($row[11] === f) ? '--------':'確認済'; print ""; //●確認者・実施日のテキストボックスの有効/無効切り替え $disabled = "disabled='disabled'"; print ""; //print ""; print ""; print ""; print ""; print ""; //●確認者 実施日 print ""; print ""; print ""; print ""; //●調書 print ""; //●写真の表示 print ""; //●記事の表示 print ""; print ""; } print "
No確認希望日場所工種検査項目管理技術者確認者実施日調書写真記事
" .$no ."" .$chk_flag ."" .$scheduled_date ."" .$place ." " .$construction ." " .$inspection_name ." " .$supervision_engineer ." " .$confirmer ." "; DlLinkMake(0,$no,$inspection_id,$save_dir,$record_dir,0); print ""; DlLinkMake(2,$no,0,$save_dir,$pict_dir,0); print " " .$memo ."
"; } else if(!$_POST['record_chk'] && !$_GET['list_no_']) { //if($_POST['']) //■DBから最新データの抽出 $sql_v = "SELECT * FROM inspection_record WHERE del_flag ='false' ORDER BY id DESC;"; $res_v = pg_query($conn,$sql_v); $ct_v = pg_num_rows($res_v); //■フォームボタンの作成(ダウンロード・削除) print ""; print ""; print ""; // print ""; print "
"; print "
"; print ""; print "
"; print "
"; // print "
"; // print ""; // print "
"; // print "
"; // print "
"; print "チェック項目の "; print ""; print ""; //print "
"; //■データ表の作成 print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; for($i = 0 ;$i < $ct_v;$i++) { $row = pg_fetch_array($res_v,$i); $no = $row[0]; $scheduled_date = date("Y/m/d" ,strtotime($row[1])) ."
" .date("H:i" ,strtotime($row[1])); $place = $row[2]; $construction = $row[3]; $inspection_name = $row[4]; $inspection_id = $row['inspection_id']; $supervision_engineer = $row[5]; $confirmer = $row[6]; $implementation_date = ($row[7]) ? date("Y-m-d" ,strtotime($row[7])) : ""; $memo = $row[8]; $updatetime = $row[9]; $regdatetime = $row[10]; $chk_flag = ($row[11] === f) ? '--------':'確認済'; print ""; //●確認者・実施日のテキストボックスの有効/無効切り替え //$disabled = ($row[11] === f) ? "":"disabled='disabled'"; print ""; print ""; //print ""; print ""; print ""; print ""; print ""; //●確認者 実施日 print ""; print ""; print ""; print ""; //●調書 print ""; //●写真の表示 print ""; //●記事の表示 print ""; print ""; print ""; } print "
CBNo確認希望日場所工種検査項目管理技術者確認者実施日調書写真記事登録
" .$no ."" .$chk_flag ."" .$scheduled_date ."" .$place ." " .$construction ." " .$inspection_name ." " .$supervision_engineer ." "; DlLinkMake(1,$no,$inspection_id,$save_dir,$record_dir,0); print ""; DlLinkMake(2,$no,0,$save_dir,$pict_dir,0); print " 
"; // print ""; } else { $no = ($_POST['id_']) ? $_POST['id_'] : $_GET['id_']; $list_no = ($_POST['list_no_']) ? $_POST['list_no_']: $_GET['list_no_']; $inspection_id = ($_POST['inspection_id_']) ? $_POST['inspection_id_'] : $_GET['inspection_id_']; //検査項目名から確認項目を取得 $sql_item = "SELECT * FROM check_item_name2 WHERE inspection_id = " .$inspection_id ." AND del_flag=false ORDER BY sort_no;"; $res_item = pg_query($conn,$sql_item); $count_item = pg_num_rows($res_item); $date_time = date("Y-m-d H:i:s",time()); $item_name = array(); for($ict = 0;$ict < $count_item;$ict++) { $row_item = pg_fetch_array($res_item,$ict); $item_name[$ict] = $row_item['item_name']; //調書出力用のデータが存在しているかを確認 $sql_record = "SELECT * FROM record_check_list WHERE data_no=" .$no ." AND inspection_id = " .$row_item['inspection_id'] ." AND list_no=" .$list_no ." AND item_no=" .$row_item['item_id'] ." AND del_flag=false;"; $res_record = pg_query($conn,$sql_record); $count_record = pg_num_rows($res_record); //print $sql_record ."
"; if(!$count_record) { //データの登録 $sql_list_ins = "INSERT INTO record_check_list(data_no, inspection_id,list_no ,item_no,sort_no,regdatetime)"; $sql_list_ins .= "VALUES ("; $sql_list_ins .= $no .","; $sql_list_ins .= $row_item['inspection_id'] .","; $sql_list_ins .= $list_no .","; $sql_list_ins .= $row_item['item_id'] .","; $sql_list_ins .= $row_item['sort_no'] .","; $sql_list_ins .= "'" .$date_time ."')"; $res_list_ins = pg_query($conn,$sql_list_ins); //$res_list_ins = pg_query($conn,$sql_list_ins) or die(pg_last_error() ."
" .$sql_list_ins); } } //確認チェックリストが未登録の場合はDB作成 //■項目がチェックされた場合、DBをアップデート if($_GET['list_no_']) { if($_GET['item_no']) { //編集中のIDをテキストファイルに出力 //キャプチャ画像と結びつけるため $fp_id = fopen("editing_id.txt","w"); fwrite($fp_id,$no ."," .$list_no ."," .$_GET['item_no']); fclose($fp_id); ///////////////////////////////////// $regdate = date("Y-m-d H:i:s",time()); $sql_up = "UPDATE record_check_list SET "; $sql_up .= ($_GET['chk']=='true') ? "regdatetime='" .$regdate ."'," :""; $sql_up .= "chk=" .$_GET['chk']; $sql_up .= " WHERE data_no=" .$no ." AND list_no=" .$list_no ." AND item_no=" .$_GET['item_no'] ." AND del_flag=false"; $res_up = pg_query($conn,$sql_up)OR DIE (pg_last_error() .$sql_up ."
"); //確認が全て終わっているか確認・終わっていれば確認済みにする $sel_ct = "SELECT count(data_no = " .$no ." or null) AS data_ct,count(chk=true or null) AS chk_ct FROM record_check_list WHERE data_no=" .$no ." AND del_flag=false" ; $res_ct = pg_query($conn,$sel_ct); $row_ct = pg_fetch_array($res_ct,0); if($row_ct['data_ct'] == $row_ct['chk_ct']) { $sql_up2 = "UPDATE inspection_record SET "; $sql_up2 .= "chk_flag=true"; $sql_up2 .= " WHERE id=" .$no ; $res_up2 = pg_query($conn,$sql_up2)OR DIE (pg_last_error() .$sql_up2 ."
"); } else { $sql_up2 = "UPDATE inspection_record SET "; $sql_up2 .= "chk_flag=false"; $sql_up2 .= " WHERE id=" .$no ; $res_up2 = pg_query($conn,$sql_up2)OR DIE (pg_last_error() .$sql_up2 ."
"); } } } //■DBから最新データの抽出 $sql_v = "SELECT * FROM inspection_record WHERE id=" .$no .";"; $res_v = pg_query($conn,$sql_v); $ct_v = pg_num_rows($res_v); //■DBからチェックリストの抽出 $sql_cl = "SELECT * FROM record_check_list WHERE data_no=" .$no ." AND list_no=" .$list_no ." AND del_flag=false ORDER BY sort_no;"; $res_cl = pg_query($conn,$sql_cl); $ct_cl = pg_num_rows($res_cl); //■DBからチェックリストの項目名を抽出 //for($ict =0;$ict< $count_item;$ict++) //{ // $row_item = pg_fetch_array($res_item,$ict); // $id_item = $row_item['id']; // $item_name[$id_item] = $row_item['name']; //} //■データ表の作成 print ""; print ""; // print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; $row = pg_fetch_array($res_v,0); $no = $row[0]; $scheduled_date = date("Y/m/d" ,strtotime($row[1])) ."
" .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); $memo = $row[8]; $updatetime = $row[9]; $regdatetime = $row[10]; $chk_flag = ($row[11] === f) ? '--------':'確認済'; print ""; //●確認者・実施日のテキストボックスの有効/無効切り替え //$disabled = ($row[11] === f) ? "":"disabled='disabled'"; print ""; //print ""; print ""; print ""; print ""; print ""; //●確認者 実施日 print ""; print ""; print ""; print ""; // print ""; print ""; //●写真の表示 print ""; //●記事の表示 print ""; print ""; print "
CBNo確認希望日場所工種検査項目管理技術者確認者実施日調書写真記事"; print ""; print "
"; print ""; print "
"; print "
" .$no ."" .$chk_flag ."" .$scheduled_date ."" .$place ." " .$construction ." " .$inspection_name ." " .$supervision_engineer ." "; //●調書 $dir = $save_dir .$no .$record_dir; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if ( $file != "." && $file != ".." ) { $list_no_ = filemtime($dir .$file); if($list_no_ == $list_no) { print "" .$file ."
"; print "
"; for($cl =0;$cl< $ct_cl;$cl++) { $row_cl = pg_fetch_array($res_cl,$cl); $cl_id = $row_cl['item_no']; $chk = $row_cl['chk']; $checked = ($row_cl['chk'] === t) ? "checked" : ""; print "" .$item_name[$cl] ."
"; } print "
"; } } } closedir($dh); } } print " 
"; DlLinkMake(2,$no,0,$save_dir,$pict_dir,0); print " 
"; } ?>