File "index.php"

Full path: /www/hm-genkai/tohyu_eco_ajk/index.php
File size: 16.72 KiB (17125 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="hm.css" TYPE="text/css">-->
</HEAD>

<?php
$age =  $_SERVER['HTTP_USER_AGENT'];

if(strpos($age, "Windows") || strpos($age, "iPad"))
{

}
else
{
	print "<style type='text/css'>";
	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 "</style>";
}




?>
<script type = "text/javascript">

function functionName(cm_ct_)
{
    var cid = document.forms['formName'].elements['campany'].value;
	var uid_name = 'user_' + cid;
	document.forms['formName'].elements[uid_name].style.display = "block";
	document.forms['formName'].elements[uid_name].disabled = false;
	
	for(var i = 1;i <= cm_ct_;i++)
	{
		if(i != cid)
		{
			//未選択のプルダウンを非表示
			var del_name = 'user_' + i;
			document.forms['formName'].elements[del_name].style.display = "none";
			document.forms['formName'].elements[del_name].disabled = true;
		}
	}
}

//ユーザーデータの読み込み
function data_read()
{
	var cid = document.forms['formName'].elements['campany'].value;
	var uid_name = 'user_' + cid;
	var uid = document.forms['formName'].elements[uid_name].value;
	var date_ = document.forms['formName'].elements['date_'].value;
	
	//日時データの再形成
	//const date = date_.replace(/-/g, '')

	console.log(cid);
	console.log(uid);
	window.location.href = "index.php?cid=" + cid + "&uid=" + uid+ "&date=" + date_;
}

//日付データからユーザーデータ読み込み

</script>


<?php
//●プルダウン作成
//横幅,データタイプ,NAME,VALUE,selected
function Pulldown_create($width,$type_ ,$name_,$value_,$selected){
	print "<select name='" .$name_ ."' style='width:" .$width ."px;' class='txt3'>";
	
	$value_ct = count($value_);
	
	if ($selected == 999) $sel = "selected";
	print "<option value='999' " .$sel .">   </option>";
	
	for($j= 1 ;$j < $value_ct;$j++)
	{
		if($type_ == 0)
		{
			$sel = ($value_[$j] == $selected) ? "selected" : "";
			print "<option value='" .$value_[$j]."' " .$sel ." >" .$value_[$j] ."</option>";
		}
		else
		{
			$split = explode("_",$value_[$j]);
			$sel = ($split[0] == $selected) ? "selected" : "";
			print "<option value='" .$split[0]."' " .$sel ." >" .$split[1] ."</option>";
		}
	}

	print "</select>";
}

//●会社名プルダウン
function Pulldown_create_campany($width,$cm_ct_ ,$name_,$data_ ,$selected)
{
	
	print "<select name='" .$name_ ."' onChange='functionName(\"" .$cm_ct_ ."\")' style='width:" .$width ."px;' class='txt3'>";
	$value_ct = count($data_);
	for($j= 0 ;$j < $value_ct;$j++)
	{
		$sel_data = explode(",",$data_[$j]);
		$sel = ($sel_data[0] == $selected) ? "selected" : "";
		print "<option value='" .$sel_data[0] ."' " .$sel ." >" .$sel_data[2] ."</option>";
	}
	print "</select>";
}

//●ユーザー名プルダウン
function Pulldown_create_user($width ,$cm_ct_,$data_,$selected)
{
	$value_ct = count($data_);
	for($i= 0 ;$i < $cm_ct_;$i++)
	{
		$ii = $i+1;
		print "<select name='user_" .$ii ."'  onChange='data_read()' style='width:" .$width ."px;display:none' id='user_" .$ii ."' class='txt3'>";
//		print "<select name='user_" .$ii ."'  style='width:" .$width ."px;display:none'>";
		$value_ct = count($data_);
		for($j= 0 ;$j < $value_ct;$j++)
		{
			$sel_data = explode(",",$data_[$j]);
			if( $ii == $sel_data[1])
			{
				$sel = ($sel_data[0] == $selected) ? "selected" : "";
				print "<option value='" .$sel_data[0] ."' " .$sel ." >" .$sel_data[4] ."</option>";
			}
		}
		print "</select>";
	}
}

function Pulldown_create_user2($width ,$cp_id,$data_,$selected)
{
	$value_ct = count($data_);

	print "<select name='user_" .$cp_id ."'  onChange='data_read()' style='width:" .$width ."px;display:none' id='user_" .$cp_id ."' class='txt3'>";
//		print "<select name='user_" .$ii ."'  style='width:" .$width ."px;display:none'>";
	print "<option value='' >名前を選択して下さい</option>";
	$value_ct = count($data_);
	for($j= 0 ;$j < $value_ct;$j++)
	{
		$sel_data = explode(",",$data_[$j]);
		if( $cp_id == $sel_data[1])
		{
			$sel = ($sel_data[0] == $selected) ? "selected" : "";
			print "<option value='" .$sel_data[0] ."' " .$sel ." >" .$sel_data[4] ."</option>";
		}
	}
	print "</select>";

}

//●ラジオボタン作成
function Radio_create($type_ ,$name_,$value_,$selected)
{
	print "<div class='txt3' >";
	$value_ct = count($value_);

	for($j= 1 ;$j < $value_ct;$j++)
	{
		if($type_ == 0)
		{
			$sel = ($value_[$j] == $selected) ? "checked='checked'" : "";
			print "<input type='radio' name='" .$name_  ."' value='" .$value_[$j]."' " .$sel .">" .$value_[$j] ."&nbsp;&nbsp;&nbsp;";
		}
		else
		{
			$split = explode("_",$value_[$j]);
			$sel = ($split[0] == $selected) ? "checked='checked'" : "";
			print "<input type='radio' name='" .$name_  ."' value='" .$split[0]."' " .$sel ."  >" .$split[1] ."&nbsp;&nbsp;&nbsp;";
		}
	}
	print "</div>";
}

/////////////////////////////////////////////////////////////////////////
EXTRACT($_GET);
//print_r($_GET);

//●定数設定
//会社名・ユーザー名一覧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++)
{
	$pull_list[$i] = str_replace("\n", '', $pull_list[$i]);
	$list[] = explode(",",$pull_list[$i]);
}


//プルダウンリスト(ユーザー名)読み込み
$fp2 = fopen($user_csv,"r");
$cp_id= 6;
$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_tmp == $cp_id))
		{
			$cp_list[0] = $cp_id_tmp ."," .$explode_tmp[2] ."," .$explode_tmp[3];
	//		$cp_id = $cp_id + 1;
		}
		
		$user_list[] = $line;
	//}
}
/*
$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;
	}
}
*/


//●会社数
$cm_ct = count($cp_list);
fclose($fp);

//日付 デフォルト
$now_date = date("Y-m-d",time());

//登録処理
function ascToHex($string)
{
    $hex = dechex(ord($string));
    if (strlen($hex) == 1) $hex = '0' . $hex;
    $string = '\\' . $hex;
    return $string;
}

if($_POST['data_input'])
{
	//会社ID,ユーザーID,日付を取得
	$company_id = $_POST['campany'];
	$user_id = $_POST["user_" .$company_id];
	$date_ = $_POST['date_'];

	if($user_id)
	{
		
		$now_date = $date_;
		//●ユーザーデータが存在するかチェック
		//日付・ユーザー名
		$csv_file_name = $date_ ."-" .str_pad($company_id,2,0,STR_PAD_LEFT) ."-" .str_pad($user_id,3,0,STR_PAD_LEFT) .".csv";
		//print $csv_file_name ."<BR>";
			
		$csv_data = $csv_data_folder .$csv_file_name;
		
		//ユーザーマスタからユーザーを検索
		$fp2 = fopen($user_csv,"r");
		while ($line = fgets($fp2))
		{
			$split = explode(",",$line);
			if($split[0] == $user_id)
			{
				$user_data = $line;
				break;
			}
		}
		fclose($fp2);
		
		//取得したユーザーデータを分割
		$user_data_ = explode(",",$user_data);
		$file_csv = fopen($csv_data, "w");
		
		
		//出力するデータの準備
		$bt_asa = ($_POST[asa] == 999) ? "":$_POST[asa];
		$bt_hiru = ($_POST[hiru] == 999) ? "":$_POST[hiru];
		$bt_yuu = ($_POST[yuu] == 999) ? "":$_POST[yuu];
		$pc_seki=  ($_POST[seki] == 0) ? "なし" : "有";
		$pc_iki=  ($_POST[iki] == 0) ? "なし" : "有";
		$pc_hana=  ($_POST[hana] == 0) ? "なし" : "有";
		$pc_nodo=  ($_POST[nodo] == 0) ? "なし" : "有";
		$pc_zutsu=  ($_POST[zutsu] == 0) ? "なし" : "有";
		$pc_geri=  ($_POST[geri] == 0) ? "なし" : "有";
		$pc_mikaku=  ($_POST[mikaku] == 0) ? "なし" : "有";
		$pc_kyukaku=  ($_POST[kyukaku] == 0) ? "なし" : "有";
		$pc_kentai=  ($_POST[kentai] == 0) ? "なし" : "有";

		print $user_data_[4] ."  様 のデータを登録しました" ."<BR>";
		$output_title = "会社名,氏名,日付,体温(朝),体温(昼),体温(夕),せき,息苦しさ,鼻水・鼻づまり,のどの痛み,頭痛,腹痛・下痢,味覚異常,嗅覚異常,倦怠感,その他";
		$output_data = $user_data_[3] ."," .$user_data_[4] ."," .$date_ ."," .$bt_asa ."," .$bt_hiru ."," .$bt_yuu ."," .$pc_seki ."," .$pc_iki ."," .$pc_hana ."," .$pc_nodo ."," .$pc_zutsu ."," .$pc_geri ."," .$pc_mikaku ."," .$pc_kyukaku ."," .$pc_kentai ."," .$_POST[etc];
		
		//出力するデータのエンコードを変更
		$output_title_conv = mb_convert_encoding($output_title , "Shift-JIS", "UTF-8");
		$output_data_conv =  mb_convert_encoding($output_data  , "Shift-JIS", "UTF-8");

		//csvへ出力
		fwrite($file_csv,$output_title_conv ."\r\n");
		fwrite($file_csv, $output_data_conv ."\r\n");
		fclose($file_csv);
	}

}
else if($_GET[cid])
{
	$company_id = $_GET[cid];
	$user_id = $_GET[uid];
	$date_ = $_GET[date];
	$now_date = $date_;
	
	//日付・ユーザー名
	$csv_file_name = $date_ ."-" .str_pad($company_id,2,0,STR_PAD_LEFT) ."-" .str_pad($user_id,3,0,STR_PAD_LEFT) .".csv";
	//print $csv_file_name ."<BR>";
		
	$csv_data = $csv_data_folder .$csv_file_name;
	
	//ユーザーデータが存在するかチェック
	if (file_exists($csv_data))
	{
		//ユーザーのステータス取得
		$fp3 = fopen($csv_data,"r");
		while ($line = fgets($fp3))
		{
			$user_satatus = $line;
		}
		fclose($fp3);
		
		$user_st = explode(",",$user_satatus);
		
		//文字コード変換
		$user_st[6] = mb_convert_encoding($user_st[6] , "UTF-8", "Shift-JIS");
		$user_st[7] = mb_convert_encoding($user_st[7] , "UTF-8", "Shift-JIS");
		$user_st[8] = mb_convert_encoding($user_st[8] , "UTF-8", "Shift-JIS");
		$user_st[9] = mb_convert_encoding($user_st[9] , "UTF-8", "Shift-JIS");
		$user_st[10] = mb_convert_encoding($user_st[10] , "UTF-8", "Shift-JIS");
		$user_st[11] = mb_convert_encoding($user_st[11] , "UTF-8", "Shift-JIS");
		$user_st[12] = mb_convert_encoding($user_st[12] , "UTF-8", "Shift-JIS");
		$user_st[13] = mb_convert_encoding($user_st[13] , "UTF-8", "Shift-JIS");
		$user_st[14] = mb_convert_encoding($user_st[14] , "UTF-8", "Shift-JIS");
		$user_st[15] = mb_convert_encoding($user_st[15] , "UTF-8", "Shift-JIS");

		$bt_asa = ($_POST[asa] == 999) ? "":$_POST[asa];
		$bt_hiru = ($_POST[hiru] == 999) ? "":$_POST[hiru];
		$bt_yuu = ($_POST[yuu] == 999) ? "":$_POST[yuu];
		
		$_POST[asa] = ($user_st[3]) ? $user_st[3]:999;
		$_POST[hiru] = ($user_st[4]) ? $user_st[4]:999;
		$_POST[yuu] = ($user_st[5]) ? $user_st[5]:999;
		$_POST[seki] = (!strcmp($user_st[6],"なし")) ? 0 : 1;
		$_POST[iki] = (!strcmp($user_st[7],"なし")) ? 0 : 1;
		$_POST[hana] = (!strcmp($user_st[8],"なし")) ? 0 : 1;
		$_POST[nodo] = (!strcmp($user_st[9],"なし")) ? 0 : 1;
		$_POST[zutsu] = (!strcmp($user_st[10],"なし")) ? 0 : 1;
		$_POST[geri] = (!strcmp($user_st[11],"なし")) ? 0 : 1;
		$_POST[mikaku] = (!strcmp($user_st[12],"なし")) ? 0 : 1;
		$_POST[kyukaku] = (!strcmp($user_st[13],"なし")) ? 0 : 1;
		$_POST[kentai] = (!strcmp($user_st[14],"なし")) ? 0 : 1;
		$_POST[etc] = $user_st[15];
	}
	else
	{
		$_POST[asa] = 999;
		$_POST[hiru] = 999;
		$_POST[yuu] = 999;
		$_POST[seki] = 0;
		$_POST[iki] = 0;
		$_POST[hana] = 0;
		$_POST[nodo] = 0;
		$_POST[zutsu] = 0;
		$_POST[geri] = 0;
		$_POST[mikaku] = 0;
		$_POST[kyukaku] = 0;
		$_POST[kentai] = 0;
	}
}
else
{
	$_POST[asa] = 999;
	$_POST[hiru] = 999;
	$_POST[yuu] = 999;
	$_POST[seki] = 0;
	$_POST[iki] = 0;
	$_POST[hana] = 0;
	$_POST[nodo] = 0;
	$_POST[zutsu] = 0;
	$_POST[geri] = 0;
	$_POST[mikaku] = 0;
	$_POST[kyukaku] = 0;
	$_POST[kentai] = 0;
}

//print "<body bgcolor onLoad='functionName_t(\"" .$user_list ."\");data_read()'>";
print "<body onLoad='functionName(\"" .$cm_ct ."\")'>";
print "<form name='formName' enctype='multipart/form-data' action='$_SERVER[PHP_SELF]' method='post'>";

print "<div class='wrap'>";
print "<TABLE BORDER='1' class='table'>";
print "<TR>";
print "<TD COLSPAN='2'  ALIGN='center' class='txt3'>" ."会社名" ."</TD>";
print "<TD WIDTH='150'>";
print Pulldown_create_campany(250,$cm_ct,"campany",$cp_list,$company_id);
print "</TD>";
print "</TR>";

print "<TR>";
print "<TD COLSPAN='2'  ALIGN='center' class='txt3'>" ."氏名" ."</TD>";
print "<TD WIDTH='150'>";

//print Pulldown_create_user(250,$cm_ct,$user_list,$user_id);
print Pulldown_create_user2(250,$cp_id,$user_list,$user_id);
print "</TD>";
print "</TR>";

print "<TR>";
print "<TD COLSPAN='2'  ALIGN='center' class='txt3'>" ."日付" ."</TD>";
print "<TD WIDTH='150'>";
print "<input type='date' name='date_' value='" .$now_date ."'  onChange='data_read()' style='width:250px;' class='txt3'></input>";
print "</TD>";
print "</TR>";


//print "<select name='user_" .$ii ."'  onChange='data_read(\"user_" .$ii ."\")' style='width:" .$width ."px;display:none' id='user_" .$ii ."' class='txt3'>";



print "<TR ALIGN='center'>";
print "<TD ROWSPAN='3'  WIDTH='40' class='txt3'>" ."体温" ."</TD>";
print "<TD WIDTH='120' class='txt3'>" ."朝" ."</TD>";
print "<TD ALIGN='left' class='txt3'>";

print Pulldown_create(150,0,"asa",$list[2],$_POST[asa]);
print "℃" ."</TD>";
print "</TR>";
print "<TR ALIGN='center'>";
print "<TD class='txt3'>" ."昼" ."</TD>";
print "<TD ALIGN='left' class='txt3'>";
print Pulldown_create(150,0,"hiru",$list[3],$_POST[hiru]);
print "℃" ."</TD>";
print "</TR>";
print "<TR ALIGN='center'>";
print "<TD class='txt3'>" ."夕" ."</TD>";
print "<TD ALIGN='left' class='txt3'>";
print Pulldown_create(150,0,"yuu",$list[4],$_POST[yuu]);
print "℃" ."</TD>";
print "</TR>";

print "<TR ALIGN='center'>";
print "<TD ROWSPAN='10' class='txt3'>" ."体調" ."</TD>";
print "<TD  class='txt3'>" ."せき" ."</TD>";
print "<TD ALIGN='left'>";
print Radio_create(1,'seki',$list[5],$_POST[seki]);
print "</TD>";
print "</TR>";
print "<TR ALIGN='center'>";
print "<TD class='txt3'>" ."息苦しさ" ."</TD>";
print "<TD ALIGN='left'>";
print Radio_create(1,'iki',$list[6],$_POST[iki]);
print "</TD>";
print "</TR>";
print "<TR ALIGN='center'>";
print "<TD class='txt3'>" ."鼻水・鼻づまり" ."</TD>";
print "<TD ALIGN='left'>";
print Radio_create(1,'hana',$list[7],$_POST[hana]);
print "</TD>";
print "</TR>";
print "<TR ALIGN='center'>";
print "<TD class='txt3'>" ."のどの痛み" ."</TD>";
print "<TD ALIGN='left'>";
print Radio_create(1,'nodo',$list[8],$_POST[nodo]);
print "</TD>";
print "</TR>";
print "<TR ALIGN='center'>";
print "<TD class='txt3'>" ."頭痛" ."</TD>";
print "<TD ALIGN='left'>";
print Radio_create(1,'zutsu',$list[9],$_POST[zutsu]);
print "</TD>";
print "</TR>";
print "<TR ALIGN='center'>";
print "<TD class='txt3'>" ."腹痛・下痢" ."</TD>";
print "<TD ALIGN='left'>";
print Radio_create(1,'geri',$list[10],$_POST[geri]);
print "</TD>";
print "</TR>";
print "<TR ALIGN='center'>";
print "<TD class='txt3'>" ."味覚異常" ."</TD>";
print "<TD ALIGN='left'>";
print Radio_create(1,'mikaku',$list[11],$_POST[mikaku]);
print "</TD>";
print "</TR>";
print "<TR ALIGN='center'>";
print "<TD class='txt3'>" ."嗅覚異常" ."</TD>";
print "<TD ALIGN='left'>";
print Radio_create(1,'kyukaku',$list[12],$_POST[kyukaku]);
print "</TD>";
print "</TR>";
print "<TR ALIGN='center'>";
print "<TD class='txt3'>" ."倦怠感" ."</TD>";
print "<TD ALIGN='left'>";
print Radio_create(1,'kentai',$list[13],$_POST[kentai]);
print "</TD>";
print "</TR>";
print "<TR ALIGN='center'>";
print "<TD class='txt3'>" ."その他" ."</TD>";
if($_POST[etc]) $etc_value = " value = '" .$_POST[etc] ."'"; 
print "<TD ALIGN='left'>" ."<INPUT TYPE='text' size='20' NAME='etc' " .$etc_value ." class='txt3'>" ."</TD>";
print "</TR>";
print "<TR ALIGN='center'>";
print "<TD COLSPAN='3'>";
print "<INPUT TYPE='submit' NAME='data_input' VALUE='登録' style='width:300px;height:40px;font-size:15pt'>";
print "</TD>";
print "</TR>";
print "</TABLE>";
print "</div>";
print "</div>";

print "</form>";
?>

</BODY>
</HTML>

PHP File Manager