added responsibles and license

This commit is contained in:
2018-10-14 13:47:38 +02:00
parent 79d300f2d4
commit 3106f8ce05
2 changed files with 27 additions and 11 deletions

View File

@@ -5,9 +5,8 @@ $monthTrans = ['jan' => 'Jan', 'feb' => 'Feb', 'maa' => 'Mar', 'apr' => 'Apr', '
$sites = ['https://www.wina.be/worklists/341', 'https://www.wina.be/worklists/336', 'https://www.wina.be/worklists/337'];
$all_names = [];
$resp = ['William Vandermaesen'];
$responsibles = ['William Vandermaesen', 'Samuel Nassen', 'Robin Broekmans'];
$resp_icon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-user-plus"><path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="8.5" cy="7" r="4"></circle><line x1="20" y1="8" x2="20" y2="14"></line><line x1="23" y1="11" x2="17" y2="11"></line></svg>';
$totalShifted = 0;
$total = 0;
@@ -17,7 +16,6 @@ foreach ($sites as $site) {
preg_match_all('/<div id="(data_shift.*?<table.*?>.*?<\/table>)/s', $data, $shiften);
$shiften = $shiften[1];
foreach ($shiften as $shift) {
preg_match_all('/data_shift.*?Start<\/td>.*?>.*?(\d.*?)<\/td>/s', $shift, $start);
preg_match_all('/data_shift.*?Einde<\/td>.*?>.*?(\d.*?)<\/td>/s', $shift, $einde);
@@ -29,7 +27,7 @@ foreach ($sites as $site) {
$einde = DateTime::createFromFormat('j M Y - G:i', implode(' ', $einde));
$diff = ($einde->getTimestamp() - $start->getTimestamp()) / 3600;
preg_match_all('/data_shift.*?Invulling.*?<td.*?>(.*?)<\/td>/s', $shift, $blockNames);
if (count($blockNames[1]) !== 0) {
preg_match_all('/<span.*?>(.*?)<\/span>/s', $blockNames[1][0], $names);
@@ -48,7 +46,6 @@ foreach ($sites as $site) {
$avg = $totalShifted / count($all_names);
?>
<!doctype html>
@@ -69,11 +66,11 @@ $avg = $totalShifted / count($all_names);
<div class="text-center">
<h1>Wina 24 urenloop shift counter</h1>
<p><?php echo floor($totalShifted) . ' uur en ' . ($totalShifted - floor($totalShifted)) * 60 . ' minuten' ; ?> shifted!<br>
<p><?php echo floor($totalShifted) . ' uur en ' . ($totalShifted - floor($totalShifted)) * 60 . ' minuten'; ?> shifted!<br>
Gemiddeld: <?php echo floor($avg) . ' uur en ' . round(($avg - floor($avg)) * 60) . ' minuten'; ?></p>
</div>
<p><?php echo $resp_icon;?> = verantwoordelijke</p>
<p><?php echo $resp_icon; ?> = verantwoordelijke</p>
<div class="table-responsive">
<table id="table" class="table">
@@ -84,10 +81,16 @@ $avg = $totalShifted / count($all_names);
</tr>
</thead>
<tbody>
<?php
foreach ($all_names as $key => $name) {
echo "<tr><td data-order='$key'>" . (in_array($key, $resp) ? "$resp_icon " : '') . "$key</td><td data-order='$name'>". floor($name).'h ' . ($name - floor($name)) * 60 . 'min' . "</td></tr>";
}
<?php
foreach ($all_names as $name => $val) {
echo "<tr><td data-order='$name'>$name" . (in_array($name, $responsibles) ? " $resp_icon" : '') . "</td><td data-order='$val'>" . floor($val) . 'h ' . ($val - floor($val)) * 60 . 'min' . "</td></tr>";
}
foreach($responsibles as $resp) {
if (!key_exists($resp, $all_names)) {
echo "<tr><td data-order='$resp'>$resp_icon $resp</td><td data-order='0'>0h 0min</td></tr>";
}
}
?>
</tbody>
@@ -96,6 +99,12 @@ foreach ($all_names as $key => $name) {
</main><!-- /.container -->
<footer class="mt-5">
<div class="container">
<span class="text-muted">© 2017-2018 Arthur Bols <a href="https://git.principis.be/Principis/shiftcounter">source</span>
</div>
</footer>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>