Added dropdown to chose list
This commit is contained in:
@@ -1,16 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
$worklist_url = 'https://www.wina.be/worklists';
|
||||||
|
$worklistsData = file_get_contents($worklist_url);
|
||||||
|
preg_match_all('/href="\/worklists\/(\d*)">(.*?)<\/a>/s', $worklistsData, $lists);
|
||||||
|
|
||||||
|
$worklists = [];
|
||||||
|
|
||||||
|
foreach($lists[1] as $key => $list) {
|
||||||
|
$worklists[$list] = $lists[2][$key];
|
||||||
|
}
|
||||||
|
natsort($worklists);
|
||||||
|
|
||||||
|
$checkedLists = $_GET['worklist'];
|
||||||
|
|
||||||
$monthTrans = ['jan' => 'Jan', 'feb' => 'Feb', 'maa' => 'Mar', 'apr' => 'Apr', 'mei' => 'May', 'jul' => 'Jul', 'aug' => 'Aug', 'sep' => 'Sep',
|
$monthTrans = ['jan' => 'Jan', 'feb' => 'Feb', 'maa' => 'Mar', 'apr' => 'Apr', 'mei' => 'May', 'jul' => 'Jul', 'aug' => 'Aug', 'sep' => 'Sep',
|
||||||
'okt' => 'Oct', 'nov' => 'Nov', 'dec' => 'Dec'];
|
'okt' => 'Oct', 'nov' => 'Nov', 'dec' => 'Dec'];
|
||||||
|
|
||||||
$sites = ['https://www.wina.be/worklists/341', 'https://www.wina.be/worklists/336', 'https://www.wina.be/worklists/337'];
|
|
||||||
|
|
||||||
$all_names = [];
|
$all_names = [];
|
||||||
$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;
|
$totalShifted = 0;
|
||||||
$total = 0;
|
$total = 0;
|
||||||
foreach ($sites as $site) {
|
|
||||||
|
foreach ($checkedLists as $site) {
|
||||||
|
$site = 'https://www.wina.be/worklists/' . $site;
|
||||||
$data = file_get_contents($site);
|
$data = file_get_contents($site);
|
||||||
|
|
||||||
preg_match_all('/<div id="(data_shift.*?<table.*?>.*?<\/table>)/s', $data, $shiften);
|
preg_match_all('/<div id="(data_shift.*?<table.*?>.*?<\/table>)/s', $data, $shiften);
|
||||||
@@ -53,11 +64,12 @@ $avg = $totalShifted / count($all_names);
|
|||||||
<head>
|
<head>
|
||||||
|
|
||||||
|
|
||||||
<title>Wina 24u shift counter</title>
|
<title>Wina shift counter</title>
|
||||||
|
|
||||||
<!-- Bootstrap core CSS -->
|
<!-- Bootstrap core CSS -->
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
|
||||||
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/dt-1.10.18/datatables.min.css"/>
|
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/dt-1.10.18/datatables.min.css"/>
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.2/css/bootstrap-select.min.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@@ -65,12 +77,25 @@ $avg = $totalShifted / count($all_names);
|
|||||||
<main role="main" class="container mt-2">
|
<main role="main" class="container mt-2">
|
||||||
|
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h1>Wina 24 urenloop shift counter</h1>
|
<h1>Wina shift counter</h1>
|
||||||
<p><?php echo floor($totalShifted) . ' uur en ' . ($totalShifted - floor($totalShifted)) * 60 . ' minuten'; ?> shifted!<br>
|
<form class="mb-2" method="get">
|
||||||
Gemiddeld: <?php echo floor($avg) . ' uur en ' . round(($avg - floor($avg)) * 60) . ' minuten'; ?></p>
|
<select name="worklist[]" class="selectpicker" data-style="btn-primary" multiple>
|
||||||
</div>
|
<?php
|
||||||
|
foreach($worklists as $key => $list) {
|
||||||
|
echo "<option " . (in_array($key, $checkedLists) ? "selected " : '') . "value='$key'>" . $list . "</option>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</form>
|
||||||
|
|
||||||
<p><?php echo $resp_icon; ?> = verantwoordelijke</p>
|
<?php
|
||||||
|
if (count($checkedLists) > 0) {
|
||||||
|
echo '<p>' . floor($totalShifted) . ' uur en ' . ($totalShifted - floor($totalShifted)) * 60 . ' minuten geshift!<br>
|
||||||
|
Gemiddeld: ' . floor($avg) . ' uur en ' . round(($avg - floor($avg)) * 60) . ' minuten<p>';
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table id="table" class="table">
|
<table id="table" class="table">
|
||||||
@@ -83,13 +108,7 @@ $avg = $totalShifted / count($all_names);
|
|||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
foreach ($all_names as $name => $val) {
|
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>";
|
echo "<tr><td data-order='$name'>$name</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 $resp_icon</td><td data-order='0'>0h 0min</td></tr>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@@ -109,10 +128,16 @@ $avg = $totalShifted / count($all_names);
|
|||||||
<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://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>
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
|
||||||
<script type="text/javascript" src="https://cdn.datatables.net/v/bs4/dt-1.10.18/datatables.min.js"></script>
|
<script type="text/javascript" src="https://cdn.datatables.net/v/bs4/dt-1.10.18/datatables.min.js"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.2/js/bootstrap-select.min.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready( function () {
|
$(document).ready( function () {
|
||||||
$('#table').DataTable();
|
$('#table').DataTable();
|
||||||
|
$('.selectpicker').selectpicker();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.selectpicker').on('hidden.bs.select', function() {
|
||||||
|
$('form').submit();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
Reference in New Issue
Block a user