summaryrefslogtreecommitdiff
path: root/includes/pages
diff options
context:
space:
mode:
authorjwacalex <ich-bin@jwacalex.de>2018-12-22 02:07:17 +0100
committermsquare <msquare@notrademark.de>2018-12-22 12:10:16 +0100
commit60a9c15454453251b21f83377b4c41a5170aa718 (patch)
treec10506745c88f072130f551299bdcc18bfb68c6c /includes/pages
parentb1d8fede465950e5d1a0d6521a6d862a02e9ce36 (diff)
first draft for #536
Diffstat (limited to 'includes/pages')
-rw-r--r--includes/pages/admin_shifts.php30
1 files changed, 25 insertions, 5 deletions
diff --git a/includes/pages/admin_shifts.php b/includes/pages/admin_shifts.php
index d697a496..817e9b9a 100644
--- a/includes/pages/admin_shifts.php
+++ b/includes/pages/admin_shifts.php
@@ -114,7 +114,7 @@ function admin_shifts()
if (
$request->has('change_hours')
&& preg_match(
- '/^(\d{2}(,|$))/',
+ '/^((\d{2}(:\d{2})?(,|$))*)/',
trim(str_replace(' ', '', $request->input('change_hours')))
)
) {
@@ -216,10 +216,18 @@ function admin_shifts()
$day = parse_date('Y-m-d H:i', date('Y-m-d', $start) . ' 00:00');
$change_index = 0;
// Ersten/nächsten passenden Schichtwechsel suchen
- foreach ($change_hours as $i => $change_hour) {
- if ($start < $day + $change_hour * 60 * 60) {
+ foreach ($change_hours as $i => $change_time) {
+ if(!preg_match('/\d{2}:\d{2}/',$change_time)) {
+ $change_time = $change_time.":00";
+ }
+
+ $change_time = explode(':',$change_time);
+ $change_hour = $change_time[0];
+ $change_minute = $change_time[1];
+
+ if ($start < $day + $change_hour * 60 * 60 + $change_minute * 60) {
$change_index = $i;
- } elseif ($start == $day + $change_hour * 60 * 60) {
+ } elseif ($start == $day + $change_hour * 60 * 60 + $change_minute * 60) {
// Start trifft Schichtwechsel
$change_index = ($i + count($change_hours) - 1) % count($change_hours);
break;
@@ -231,7 +239,19 @@ function admin_shifts()
$shift_start = $start;
do {
$day = parse_date('Y-m-d H:i', date('Y-m-d', $shift_start) . ' 00:00');
- $shift_end = $day + $change_hours[$change_index] * 60 * 60;
+
+ $change_time=$change_hours[$change_index];
+ if(!preg_match('/\d{2}:\d{2}/',$change_time)) {
+ $change_time = $change_time.":00";
+ }
+
+ $change_time = explode(':',$change_time);
+ $change_hour = $change_time[0];
+ $change_minute = $change_time[1];
+
+
+ $shift_end = $day + $change_hour * 60 * 60 + $change_minute * 60;
+
if ($shift_end > $end) {
$shift_end = $end;