"; print ".wrap {"; print " width: 100%;"; print "}.table {"; print " width: 100%;"; print " table-layout: fixed;"; print "}"; print ".table td,"; print ".table th {"; print " border: 1px solid #DFDFDF;"; print " padding: 1rem;"; print "}"; print ".table tr > td:first-child,"; print ".table tr > th:first-child{"; print " width: 30%; ";// 最初のカラムだけ30%のwidthを確保 print "}"; print "div.content {"; print " width: 100%;"; print "}"; print "div.content pre {"; print " display: block;"; print " width: 100%;"; print " overflow-x: auto;"; print " overflow-y: hidden;"; print " height: auto;"; print "}"; print ".txt3{"; print " font-size: 160%;"; print "}"; print ".txt4{"; print " font-size: 120%;"; print "}"; print ""; } //表示するCSVを選択 $csv_view = 2; //会社ID $cp_id_v = 1; //CSV出力パターン(1~4) //1:全て(日付-ユーザーID順) 2:個別(日付-ユーザーID順) 3:全て(ユーザーID-日付順) 4:個別(ユーザーID-日付順) $csv_out = 2; ///////////////////////////////////////////////////////////////////////// EXTRACT($_GET); print_r($_GET); print_r($_POST); //●定数設定 //会社名・ユーザー名一覧CSV $user_csv= "../setting/user.csv"; //プルダウンCSV $list_csv = "../setting/list.csv"; //CSVデータ出力フォルダ $csv_data_folder = "../data/"; //●プルダウンリストの読み込み $fp = fopen($list_csv,"r"); $pull_list = array(); $list = array(); // ファイルを1行ずつ取得する while ($line = fgets($fp)) { $pull_list[] = "$line"; } $ct = count($pull_list); //各リストを,で分割 for($i = 0;$i < $ct;$i++) { $list[] = explode(",",$pull_list[$i]); } //プルダウンリスト(ユーザー名)読み込み $fp2 = fopen($user_csv,"r"); $cp_id= 0; $cp_list =array(); $user_list = array(); while ($line = fgets($fp2)) { $explode_tmp = explode(",",$line); $cp_id_tmp = $explode_tmp[1]; if(($cp_id_tmp != null) && $cp_id_tmp <= 8) { if(($cp_id_tmp != null) && ($cp_id != $cp_id_tmp)) { $cp_list[$cp_id] = $cp_id_tmp ."," .$explode_tmp[2] ."," .$explode_tmp[3]; $cp_id = $cp_id + 1; } $user_list[] = $line; } } //●ユーザー数 $user_ct = count($user_list); //●会社数 $cm_ct = count($cp_list); fclose($fp); //日付 デフォルト $now_date = date("Y-m-d",time()); //■CSV出力処理 //日付-ユーザーID if(($_POST[csv_out] == 1) || ($csv_view == 1)) { //全て出力 // ディレクトリハンドルの取得 $dir_h = opendir( $csv_data_folder ) ; // ファイル・ディレクトリの一覧を $file_list 配列に while (false !== ($file_list[] = readdir($dir_h))) ; // ディレクトリハンドルを閉じる closedir( $dir_h ) ; // ファイル名(降順)にする sort($file_list) ; //出力ファイル名の設定 $out_put_file_name = date("Y-m-d",time()) .".csv"; $fp_csv = fopen($csv_data_folder .$out_put_file_name ,"w"); $item = mb_convert_encoding("日付,会社名,ユーザーID,氏名,体温(朝),体温(昼),体温(夕),せき,息苦しさ,鼻水・鼻づまり,のどの痛み,頭痛,腹痛・下痢,味覚異常,嗅覚異常,倦怠感,その他", "Shift-JIS", "UTF-8"); fwrite($fp_csv,$item ."\n"); //ディレクトリ内のファイル名を1つずつを取得 foreach ( $file_list as $file_name ) { //ファイルのみを表示 if( (is_file( $csv_data_folder . $file_name)) && (strlen($file_name) == 21) ) { //fwrite($fp_csv,$file_name ."\n"); $fp_d = fopen($csv_data_folder . $file_name ,"r"); $data_ = array(); //$list_ = array(); // ファイルを1行ずつ取得する while ($line = fgets($fp_d)) { $data_[] = $line; } //各リストを,で分割 $list_ = explode(",",$data_[1]); $split = explode("-",$file_name); $regist_date_ = $split[0] ."-" .$split[1] ."-" .$split[2]; $regist_gp_ = $split[3]; $regist_id_ = substr($split[4],0,3); //$regist_date_ = mb_convert_encoding($regist_date_ , "UTF-8", "Shift-JIS"); $date_ =(!strcmp($now_date_,$regist_date_)) ? "":$regist_date_; fwrite($fp_csv, $date_ ."," .$list_[0] ."," .$regist_id_ ."," .$list_[1] ."," .$list_[3] ."," .$list_[4] ."," .$list_[5] ."," .$list_[6] ."," .$list_[7] ."," .$list_[8] ."," .$list_[9] ."," .$list_[10] ."," .$list_[11] ."," .$list_[12] ."," .$list_[13]."," .$list_[14]."," .$list_[15]); fclose($fp_d); $now_date_ = $regist_date_; //print $file_name ."
"; } } fclose($fp_csv); } else if(($_POST[csv_out] == 2) || ($csv_view == 2)) { //グループ(会社)ごと出力 // ディレクトリハンドルの取得 $dir_h = opendir( $csv_data_folder ) ; // ファイル・ディレクトリの一覧を $file_list 配列に while (false !== ($file_list[] = readdir($dir_h))) ; // ディレクトリハンドルを閉じる closedir( $dir_h ) ; // ファイル名(降順)にする sort($file_list); //グループ数だけCSVファイルを出力 //for($g = 0;$g < $cm_ct;$g++) //{ //出力ファイル名の設定 //$g_no = $g + 1; $g_no = $cp_id_v; $out_put_file_name = "g" .str_pad($g_no,2,0,STR_PAD_LEFT) .".csv"; $fp_csv[$g_no] = fopen($csv_data_folder .$out_put_file_name ,"w"); $item = mb_convert_encoding("日付,ユーザーID,氏名,体温(朝),体温(昼),体温(夕),せき,息苦しさ,鼻水・鼻づまり,のどの痛み,頭痛,腹痛・下痢,味覚異常,嗅覚異常,倦怠感,その他", "Shift-JIS", "UTF-8"); fwrite($fp_csv[$g_no],$item ."\n"); //} //ディレクトリ内のファイル名を1つずつを取得 foreach ( $file_list as $file_name ) { //ファイルのみを表示 if( (is_file( $csv_data_folder . $file_name)) && (strlen($file_name) == 21) ) { //fwrite($fp_csv,$file_name ."\n"); $fp_d = fopen($csv_data_folder . $file_name ,"r"); $data_ = array(); //$list_ = array(); // ファイルを1行ずつ取得する while ($line = fgets($fp_d)) { $data_[] = $line; } //各リストを,で分割 $list_ = explode(",",$data_[1]); $split = explode("-",$file_name); $regist_date_ = $split[0] ."-" .$split[1] ."-" .$split[2]; $regist_gp_ = intval($split[3]); $regist_id_ = substr($split[4],0,3); //$regist_date_ = mb_convert_encoding($regist_date_ , "UTF-8", "Shift-JIS"); $date_ =(!strcmp($now_date_[$regist_gp_],$regist_date_)) ? "":$regist_date_; fwrite($fp_csv[$regist_gp_], $date_ ."," .$regist_id_ ."," .$list_[1] ."," .$list_[3] ."," .$list_[4] ."," .$list_[5] ."," .$list_[6] ."," .$list_[7] ."," .$list_[8] ."," .$list_[9] ."," .$list_[10] ."," .$list_[11] ."," .$list_[12] ."," .$list_[13]."," .$list_[14]."," .$list_[15]); fclose($fp_d); $now_date_[$regist_gp_] = $regist_date_; //print $file_name ."
"; } } //for($g = 0;$g < $cm_ct;$g++) //{ //出力ファイル名の設定 //$g_no = $g + 1; $g_no = $cp_id_v; fclose($fp_csv[$g_no]); //} //zipの作成 //$zip_path = "g01_" .str_pad($cm_ct,2,0,STR_PAD_LEFT) .".zip"; //print $zip_path; //$cmd_3 = "zip -jD " .$csv_data_folder .$zip_path ." " .$csv_data_folder ."g*"; //exec($cmd_3); //$out_put_file_name = $zip_path; } else if(($_POST[csv_out] == 3) || ($csv_view == 3)) { //ユーザーID-日付 //全て出力 // ディレクトリハンドルの取得 $dir_h = opendir( $csv_data_folder ) ; // ファイル・ディレクトリの一覧を $file_list 配列に while (false !== ($file_list[] = readdir($dir_h))) ; // ディレクトリハンドルを閉じる closedir( $dir_h ) ; // ファイル名(降順)にする sort($file_list) ; //出力ファイル名の設定 $out_put_file_name = date("Y-m-d",time()) ."_2.csv"; $fp_csv = fopen($csv_data_folder .$out_put_file_name ,"w"); $item = mb_convert_encoding("ユーザーID,氏名,会社名,日付,体温(朝),体温(昼),体温(夕),せき,息苦しさ,鼻水・鼻づまり,のどの痛み,頭痛,腹痛・下痢,味覚異常,嗅覚異常,倦怠感,その他", "Shift-JIS", "UTF-8"); fwrite($fp_csv,$item ."\n"); //ディレクトリ内のファイル名を1つずつを取得 $user_data = array(); foreach ( $file_list as $file_name ) { //ファイルのみを表示 if( (is_file( $csv_data_folder . $file_name)) && (strlen($file_name) == 21) ) { //fwrite($fp_csv,$file_name ."\n"); $fp_d = fopen($csv_data_folder . $file_name ,"r"); $data_ = array(); //$list_ = array(); // ファイルを1行ずつ取得する while ($line = fgets($fp_d)) { $data_[] = $line; } //各リストを,で分割 $list_ = explode(",",$data_[1]); $split = explode("-",$file_name); $regist_date_ = $split[0] ."-" .$split[1] ."-" .$split[2]; $regist_gp_ = intval($split[3]); $regist_id_ = intval(substr($split[4],0,3)); $user_data[$regist_id_] .= (!$user_data[$regist_id_]) ? substr($split[4],0,3) ."," .$list_[1] ."," .$list_[0] ."," .$regist_date_ ."," .$list_[3] ."," .$list_[4] ."," .$list_[5] ."," .$list_[6] ."," .$list_[7] ."," .$list_[8] ."," .$list_[9] ."," .$list_[10] ."," .$list_[11] ."," .$list_[12] ."," .$list_[13]."," .$list_[14]."," .$list_[15]: ",,," .$regist_date_ ."," .$list_[3] ."," .$list_[4] ."," .$list_[5] ."," .$list_[6] ."," .$list_[7] ."," .$list_[8] ."," .$list_[9] ."," .$list_[10] ."," .$list_[11] ."," .$list_[12] ."," .$list_[13]."," .$list_[14]."," .$list_[15]; //$regist_date_ = mb_convert_encoding($regist_date_ , "UTF-8", "Shift-JIS"); //fwrite($fp_csv, $date_ ."," .$list_[0] ."," .$regist_id_ ."," .$list_[1] ."," .$list_[3] ."," .$list_[4] ."," .$list_[5] ."," .$list_[6] ."," .$list_[7] ."," .$list_[8] ."," .$list_[9] ."," .$list_[10] ."," .$list_[11] ."," .$list_[12] ."," .$list_[13]."," .$list_[14]."," .$list_[15]); fclose($fp_d); } } $csv_output = ""; for($u = 1;$u <= $user_ct;$u++) { if($user_data[$u]) { $csv_output .=$user_data[$u]; } } fwrite($fp_csv,$csv_output); //print $file_name ."
"; fclose($fp_csv); } else if(($_POST[csv_out] == 4) || ($csv_view == 4)) { //グループ(会社)ごと出力 //$cm_ct // ディレクトリハンドルの取得 $dir_h = opendir( $csv_data_folder ) ; // ファイル・ディレクトリの一覧を $file_list 配列に while (false !== ($file_list[] = readdir($dir_h))) ; // ディレクトリハンドルを閉じる closedir( $dir_h ) ; // ファイル名(降順)にする sort($file_list) ; //グループ数だけCSVファイルを出力 for($g = 0;$g < $cm_ct;$g++) { //出力ファイル名の設定 $g_no = $g + 1; $out_put_file_name = "ug" .str_pad($g_no,2,0,STR_PAD_LEFT) .".csv"; $fp_csv[$g_no] = fopen($csv_data_folder .$out_put_file_name ,"w"); $item = mb_convert_encoding("ユーザーID,氏名,日付,体温(朝),体温(昼),体温(夕),せき,息苦しさ,鼻水・鼻づまり,のどの痛み,頭痛,腹痛・下痢,味覚異常,嗅覚異常,倦怠感,その他", "Shift-JIS", "UTF-8"); fwrite($fp_csv[$g_no],$item ."\n"); } //ディレクトリ内のファイル名を1つずつを取得 foreach ( $file_list as $file_name ) { //ファイルのみを表示 if( (is_file( $csv_data_folder . $file_name)) && (strlen($file_name) == 21) ) { //fwrite($fp_csv,$file_name ."\n"); $fp_d = fopen($csv_data_folder . $file_name ,"r"); $data_ = array(); //$list_ = array(); // ファイルを1行ずつ取得する while ($line = fgets($fp_d)) { $data_[] = $line; } //各リストを,で分割 $list_ = explode(",",$data_[1]); $split = explode("-",$file_name); $regist_date_ = $split[0] ."-" .$split[1] ."-" .$split[2]; $regist_gp_ = intval($split[3]); $regist_id_ = intval(substr($split[4],0,3)); $user_data[$regist_gp_][$regist_id_] .= (!$user_data[$regist_gp_][$regist_id_]) ? substr($split[4],0,3) ."," .$list_[1] ."," .$regist_date_ ."," .$list_[3] ."," .$list_[4] ."," .$list_[5] ."," .$list_[6] ."," .$list_[7] ."," .$list_[8] ."," .$list_[9] ."," .$list_[10] ."," .$list_[11] ."," .$list_[12] ."," .$list_[13]."," .$list_[14]."," .$list_[15]: ",," .$regist_date_ ."," .$list_[3] ."," .$list_[4] ."," .$list_[5] ."," .$list_[6] ."," .$list_[7] ."," .$list_[8] ."," .$list_[9] ."," .$list_[10] ."," .$list_[11] ."," .$list_[12] ."," .$list_[13]."," .$list_[14]."," .$list_[15]; //$regist_date_ = mb_convert_encoding($regist_date_ , "UTF-8", "Shift-JIS"); //$date_ =(!strcmp($now_date_[$regist_gp_],$regist_date_)) ? "":$regist_date_; //fwrite($fp_csv[$regist_gp_], $date_ ."," .$regist_id_ ."," .$list_[1] ."," .$list_[3] ."," .$list_[4] ."," .$list_[5] ."," .$list_[6] ."," .$list_[7] ."," .$list_[8] ."," .$list_[9] ."," .$list_[10] ."," .$list_[11] ."," .$list_[12] ."," .$list_[13]."," .$list_[14]."," .$list_[15]); //fclose($fp_d); //$now_date_[$regist_gp_] = $regist_date_; //print $file_name ."
"; } } $csv_output = ""; for($u = 1;$u <= $user_ct;$u++) { if($user_data[$u]) { $csv_output .=$user_data[$u]; } } fwrite($fp_csv,$csv_output); //print $file_name ."
"; for($g = 0;$g < $cm_ct;$g++) { $csv_output =""; $g_no = $g + 1; for($u = 1;$u <= $user_ct;$u++) { if($user_data[$g_no][$u]) { $csv_output .=$user_data[$g_no][$u]; } } fwrite($fp_csv[$g_no],$csv_output); //出力ファイル名の設定 fclose($fp_csv[$g_no]); } //zipの作成 $zip_path = "ug01_" .str_pad($cm_ct,2,0,STR_PAD_LEFT) .".zip"; //print $zip_path; $cmd_3 = "zip -jD " .$csv_data_folder .$zip_path ." ./data/ug*"; exec($cmd_3); $out_put_file_name = $zip_path; } //CSV出力ボタンが押された場合、出力処理 if($_POST[csv_out]) { header('Location: ../download.php?f=' .$out_put_file_name ); } //■データ一覧表 print ""; print ""; print ""; print "
"; print "
"; print ""; print "
"; print "
"; print "
"; print ""; print ""; print "
"; print "
"; print ""; print ""; if(($csv_view == 1) || ($csv_view == 3)) { //CSVファイルを開く $fp_c = fopen($csv_data_folder .$out_put_file_name,"r"); $list = array(); $data = array(); // ファイルを1行ずつ取得する while ($line = fgets($fp_c)) { $list[] = "$line"; } $ct = count($list); //print mb_convert_encoding($list[$i], "UTF-8", "Shift-JIS") ."
"; print ""; //各リストを,で分割 for($i = 0;$i < $ct;$i++) { $data = explode(",",$list[$i]); $data_ct = count($data); print ""; $TD_start = ($i == 0) ? ""; for($d = 0;$d < $data_ct;$d++) { print $TD_start; print mb_convert_encoding($data[$d], "UTF-8", "Shift-JIS"); print $TD_end; } print ""; } print "
" :""; $TD_end = ($i == 0) ? "" :"
"; fclose($fp_c); } else if(($csv_view == 2) || ($csv_view == 4)) { $file_type = ($csv_view == 2) ? "g" : "ug"; //グループ数だけCSVファイルを出力 //for($g = 0;$g < $cm_ct;$g++) //{ $g = $cp_id_v -1; //会社名の取得 $campany_data = explode(",",$cp_list[$g]); $campany_name = $campany_data[2]; //読み込むファイルを設定 $g_no = $cp_id_v; $out_put_file_name = $file_type .str_pad($g_no,2,0,STR_PAD_LEFT) .".csv"; //CSVファイルを開く $fp_gc = fopen($csv_data_folder . $out_put_file_name ,"r"); $list = array(); $data = array(); // ファイルを1行ずつ取得する while ($line = fgets($fp_gc)) { $list[] = "$line"; } $ct = count($list); print "■" .$campany_name ."
"; print ""; //各リストを,で分割 for($i = 0;$i < $ct;$i++) { $data = explode(",",$list[$i]); $data_ct = count($data); print ""; $width =""; $TD_start = ($i == 0) ? ""; for($d = 0;$d < $data_ct;$d++) { print $TD_start; print mb_convert_encoding($data[$d], "UTF-8", "Shift-JIS"); print $TD_end; } print ""; } print "
" :""; $TD_end = ($i == 0) ? "" :"
"; fclose($fp_c); print "
"; //} } ?>