"; // for($j= $min_int ;$j < $max_int;$j += $interval) { $sel = ($j == $selected) ? "selected" : ""; print ""; } if (is_null($selected) && $Space) { print ""; } print ""; } //●現在時刻の取得 $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() ."
"; // throw new Exception("データ取得に失敗
". $DelArea. "
". pg_last_error(). "
"); } } //■編集処理 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'] ."
"; $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() ."
"; // throw new Exception("データ取得に失敗
". $DelArea. "
". pg_last_error(). "
"); } } //$row[chk] = "未確認"; //print_r($_POST); //print_r($_GET); print "
"; print ""; print "
"; print "
"; //■申請処理 if($_POST['request']) { print "【新規申請】
"; 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 ."
";// "seq==" .$row_seq[0] ."
"; //一時フォルダ内のファイルの削除(調書・画像) 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 "
"; 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 "
申請先メールアドレス" .$_POST['send_address'] ."
"; // 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 "希望日" .$make_date ."
場所" .$_POST['place_reg'] ."
工種" .$_POST['construction_reg'] ."
検査項目" .$_POST['inspection_name_reg'] ."
監理技術者" .$_POST['supervision_engineer_reg'] ."
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; } 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['scheduled_date']; //場所 $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']; //メールアドレス(承認先) //■申請先メールアドレス //立会承認が"メール未送信"の場合のみ、編集可能 $disabled = ($request_status === 3) ? "":"disabled='disabled'"; //■再申請ボタンの表示・非表示 //立会承認が"差戻"、"メール未送信"の場合、"再申請"ボタンの表示 //if($request_status) //$disabled = ($row[13] === f) ? "":"disabled='disabled'"; 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 ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
申請先メールアドレス
希望日"; 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 "
"; 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 "
場所
工種
検査項目
監理技術者
確認者
実施日
調書
写真
記事
"; print ""; print ""; print ""; print "
"; //写真の表示 /* print ""; 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 "" .$pict_name .""; print "  "; } } print " "; print "" .$memo ." "; print ""; */ } else { print "【新規申請】
"; 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() ."
" .$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: " ."五洋立会申請" ."" ."\n"; $header .= "Reply-To: " ."五洋立会申請" ."" ."\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("※このメールはシステム側から送信しています" ."

" ,"ISO-2022-JP","UTF-8"); $message .= mb_convert_encoding("以下の内容で立会申請がされました。" ."
" ,"ISO-2022-JP","UTF-8"); $message .= mb_convert_encoding("承認・差戻を選択してURLをクリックしてください。" ."
" ,"ISO-2022-JP","UTF-8"); $message .= mb_convert_encoding("選択を誤ってしまった場合は、正しい方をクリックしなおしてください。" ."

" ,"ISO-2022-JP","UTF-8"); $message .= mb_convert_encoding("[承認]" .$ok_url ."

" ,"ISO-2022-JP","UTF-8"); $message .= mb_convert_encoding("[差戻]" .$ng_url ."

" ,"ISO-2022-JP","UTF-8"); $message .= mb_convert_encoding("希望日時 :" .date("Y年m月d日 H時i分" ,($_POST['scheduled_date_reg'])) ."
" ,"ISO-2022-JP","UTF-8"); $message .= mb_convert_encoding("場所   :" .$_POST['place_reg'] ."
" ,"ISO-2022-JP","UTF-8"); $message .= mb_convert_encoding("工種   :" .$_POST['construction_reg'] ."
" ,"ISO-2022-JP","UTF-8"); $message .= mb_convert_encoding("検査項目 :" .$_POST['inspection_name_reg'] ."
","ISO-2022-JP","UTF-8"); $message .= mb_convert_encoding("監理技術者:" .$_POST['supervision_engineer_reg'],"ISO-2022-JP","UTF-8"); $message = wordwrap($message, 70); //送信する //print "送信しました" ."
"; // $test = mb_send_mail("kikuchi.katsumi@gmail.com", $Subject , $message,$header); if(mb_send_mail($_POST['send_address'], $Subject , $message,$header)) { print ""; } } else if($_POST['sentaku_no']) { 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 ""; print "
申請先メールアドレス
希望日"; 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 "
"; 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 "
場所
工種
検査項目
監理技術者
調書
写真
"; print ""; print "
"; print "
"; print "チェック項目の "; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; //$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 ""; $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]; $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 = "差戻"; $request_status .= "
※条件を変えて
再申請して下さい

"; } else { $request_status = "メール送信失敗"; $request_status .= "
※アドレスを確認し
再申請して下さい

"; } $memo = $row[10]; $updatetime = $row[11]; $regdatetime = $row[12]; $chk_flag = ($row[13] === f) ? '--------':'確認済'; //確認者・実施日のテキストボックスの有効/無効切り替え $disabled = ($row[13] === f) ? "":"disabled='disabled'"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; //確認者_実施日 print ""; print ""; print ""; print ""; // print ""; //調書のダウンロードリンク表示 print ""; //写真の表示 print ""; print ""; print ""; } print "
CB立会承認確認希望日場所工種検査項目管理技術者確認者実施日調書写真記事
"; print ""; print ""; print "" .$request_status ."" .$chk_flag ." " .$scheduled_date ."" .$place ." " .$construction ." " .$inspection_name ." " .$supervision_engineer ." " .$confirmer ." " .$implementation_date .""; for($cp = 0 ;$cp < $record_ct;$cp++) { if($record[$cp]) { $record_name = $record[$cp]; $record_name_v = explode("_",$record[$cp]); print "" .$record_name_v[2] ."
"; } } print " 
"; for($cp = 0 ;$cp < $pict_ct;$cp++) { if($pict[$cp]) { $thum_name = "inspection/pict/" .str_replace("." ,"_s." ,$pict[$cp]); $pict_name = $pict[$cp]; print "" .$pict_name .""; print "  "; } } print " " .$memo ." 
"; } ?>