-
Notifications
You must be signed in to change notification settings - Fork 0
/
schedule.php
108 lines (99 loc) · 3.5 KB
/
schedule.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/index.php';
$objPHPExcel = PHPExcel_IOFactory::load(__DIR__ . '/xlsx/rasp.xlsx');
$objWorksheet = $objPHPExcel->getActiveSheet();
$highestRow = $objWorksheet->getHighestDataRow();
$startReading = 2;
for ($i = $startReading; $i <= $highestRow; $i++) {
$pass = $objPHPExcel->getActiveSheet()->getCell('A' . $i)->getValue();
$date = $objPHPExcel->getActiveSheet()->getCell('B' . $i)->getValue();
$date = PHPExcel_Shared_Date::ExcelToPHP($date);
if (!is_null($pass)) {
$row[$i]['pass'] = $pass;
$row[$i]['date'] = strtotime('-3 hours', $date);
$row[$i]['event'] = $objPHPExcel->getActiveSheet()->getCell('C' . $i)->getValue();
$row[$i]['reminder'] = $objPHPExcel->getActiveSheet()->getCell('D' . $i)->getValue();
}
}
$eventDate = $row;
foreach ($eventDate as $eventKey => $eventValue) {
$arrayDate[$eventKey] = $eventValue['date'];
}
array_multisort($arrayDate, SORT_ASC, $eventDate);
unset($eventKey);
unset($eventValue);
unset($arrayDate);
foreach ($eventDate as $eventValue) {
$eventTime = strtotime('-15 minutes', $eventValue['date']);
if (time() < $eventTime) {
$arrayDate[] = $eventTime;
}
}
$nextDate = array_slice($arrayDate, 0, 1)[0];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Лист событий</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<style>
body {
font-size: 12px;
}
.info {
padding-top: 25px;
font-size: 14px;
}
.info .label-default {
background-color: #c3c3c3;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-6">
<h2>Лист событий</h2>
</div>
<div class="col-md-6">
<p class="pull-right info">
<span class="label label-success">Отправлено</span>
<span class="label label-danger">Ближайшее</span>
<span class="label label-default">Ожидает</span>
</p>
</div>
</div>
<table class="table table-bordered table-hover">
<tr>
<th width="15%"><?php echo $objPHPExcel->getActiveSheet()->getCell('A' . 1)->getValue(); ?></th>
<th width="15%"><?php echo $objPHPExcel->getActiveSheet()->getCell('B' . 1)->getValue(); ?></th>
<th width="35%"><?php echo $objPHPExcel->getActiveSheet()->getCell('C' . 1)->getValue(); ?></th>
<th width="35%"><?php echo $objPHPExcel->getActiveSheet()->getCell('D' . 1)->getValue(); ?></th>
</tr>
<?php
foreach ($row as $item) {
if (strtotime('-15 minutes', $item['date']) === $nextDate) {
echo '<tr class="danger">';
} else if (time() < strtotime('-15 minutes', $item['date'])) {
echo '<tr class="active">';
} else {
echo '<tr class="success">';
}
echo '<td>' . $item['pass'] . '</td>';
echo '<td>' . date('d.m.y G:i', $item['date']) . '</td>';
echo '<td>' . $item['event'] . '</td>';
echo '<td>' . $item['reminder'] . '</td>';
echo '</tr>';
}
?>
</table>
</div>
</body>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</html>