Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
Binary file removed data/.DS_Store
Binary file not shown.
5 changes: 1 addition & 4 deletions data/shift.dat
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
たかけん,6,10,0000111
いのうえ,15,23,0111000
ふじた,8,15,1001100
おりまー,17,22,1011010
たかけん,6,12,0001110
1 change: 1 addition & 0 deletions data/worker.dat
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
いのうえ,inoue.jpeg
ふじた,huzita.jpeg
おりまー,olimer.jpeg
かすみ,kasumis.png
137 changes: 62 additions & 75 deletions host.php
Original file line number Diff line number Diff line change
@@ -1,106 +1,93 @@
<?php
$times = array(6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 1, 2, 3, 4, 5);
//表に表示する曜日
$weekJpNames = array("月", "火", "水", "木", "金", "土", "日");

$shiftDatPath = "./data/shift.dat";
$weekJpNames = array("月", "火", "水", "木", "金", "土", "日");
$times = array(6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 1, 2, 3, 4, 5);
$shiftDatPath = "./data/shift.dat";
$workerDatPath = "./data/worker.dat";
$hours = 24;
$oneWeekDays = 7;

$hours = 24;
$oneWeekDays = 7;

$shiftTimes = file($shiftDatPath);
//従業員管理ファイルを読み込む
$workerData = file($workerDatPath);
$newWorkerMax = count($workerData);

//従業員管理ファイルを配列化
for($i = 0; $i < $newWorkerMax; $i++) {
//$workerIcons[][0]登録した従業員の名前
//$workerIcons[][1]登録した従業員の画像
$workerIcons[] = explode(",", $workerData[$i]);
}

$workerMax = count($shiftTimes);
$workerMax = count($shiftTimes);
for($i = 0; $i < $workerMax; $i++) {
//$workerShifts[][0]名前
//$workerShifts[][1]開始時間
//$workerShifts[][2]終了時間
//$workerShifts[][3]曜日
$workerShifts[] = explode(",", $shiftTimes[$i]);
}

//従業員管理ファイルを読み込む
$workerData = file($workerDatPath);
$newWorkerMax = count($workerData);
//従業員管理ファイルを配列化
$workerIcons = ["workerName" => "workerIcon"];
for($i = 0; $i < $newWorkerMax; $i++) {
//$workerIcons[][0]登録した従業員の名前
//$workerIcons[][1]登録した従業員の画像
$workerIcon[] = explode(",", $workerData[$i]);
$workerIcons += [$workerIcon[$i][0] => $workerIcon[$i][1]];
}
?>
<!DOCTYPE html>
<html lang ='ja'>
<html lang='ja'>
<head>
<meta charaset = 'UTF-8'>
<meta charaset='UTF-8'>
<title>シフトが出来上がったよ</title>
<link rel="stylesheet" href="./stylesheet/style.css">
<!-- <link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css"> -->
</head>
<body>
<h1>完成したシフト表はこちら</h1>
<table>
<?php
//週の曜日の7行+時間帯の表示の1行を表示させるため<=条件式とする
for($i = 0; $i <= $oneWeekDays; $i++):
if ($i == 0){
echo "<thead>";
} elseif($i == 1){
echo "<tbody>";
}
//週の曜日の7行+時間帯の表示の1行を表示させるため<=条件式とする
for($i = 0; $i <= $oneWeekDays; $i++):
//ここも3項演算子
($i == 0) ? print "<thead>" : print "<tbody>";
?>
<tr>
<?php
//1日24時間分の列+曜日の表示の1列を表示させるため<=条件式とする
for($j = 0; $j <= $hours; $j++):
?>
<tr>
<?php
//1日24時間分の列+曜日の表示の1列を表示させるため<=条件式とする
for($j = 0; $j <= $hours; $j++):
?>
<td>
<?php
//表に曜日と時間を表示
if($i == 0 && $j > 0) {
echo $times[$j-1];
} elseif ($i > 0 && $j == 0) {
echo $weekJpNames[$i-1];
} else {
echo ' ';
}

<td>
<?php
//表に曜日と時間を表示
if($j > 0 && $i == 0) {
echo $times[$j-1];
} elseif ($j == 0 && $i > 0) {
echo $weekJpNames[$i-1];
} else {
echo ' ';
for($k = 0; $k < $workerMax; $k++) {
//表示するためにtime配列内のシフトの開始時間と終了時間の添え字を取り出す
for($l = 0; $l <= $hours; $l++) {
if($workerShifts[$k][1] == $times[$l]) {
$startTime = $l;
}

for($k = 0; $k < $workerMax; $k++) {
//表示するためにtime配列内のシフトの開始時間と終了時間の添え字を取り出す
for($l = 0; $l <= $hours; $l++) {
if($times[$l] == $workerShifts[$k][1]) {
$startTime = $l;
}
if($times[$l] == $workerShifts[$k][2]) {
$endTime = $l;
}
}
if($i > 0 && $j - 1 >= $startTime && $j - 1 <= $endTime && $workerShifts[$k][3][$i-1] == 1) {
for($m = 0; $m < $newWorkerMax; $m++) {
if($workerShifts[$k][0] == $workerIcons[$m][0]) {
echo "<img src='./workericons/{$workerIcons[$m][1]}'>\n";
}
}
}
if($workerShifts[$k][2] == $times[$l]) {
$endTime = $l;
}
?>
</td>
<?php endfor; ?>
</tr>
<?php
if ($i == 0) {
echo "</thead>";
} elseif ($i == $oneWeekDays) {
echo "</tbody>";
}
?>
}

if($i > 0 && $workerShifts[$k][3][$i-1] == 1 && $j - 1 >= $startTime && $j - 1 <= $endTime) {
echo "<img src='./pictures/".$workerIcons[$workerShifts[$k][0]]."'>\n";
}
}
?>
</td>
<?php endfor; ?>
</tr>
<?php
($i == 0) ? print "</thead>" : "</tbody>";
?>
<?php endfor; ?>
</table>
<br>
<a href="shift.php">シフト登録はこちら</a>
<a href="owner.php">シフトを修正はこちら</a>
<br>
<a href="shift.php">シフト登録はこちら</a>
<a href="owner.php">シフトを修正はこちら</a>
<br><br><br>
</body>
</html>
Loading