diff --git a/application/Calendar/CalendarModel.php b/application/Calendar/CalendarModel.php index f4f242898..eef462ce9 100644 --- a/application/Calendar/CalendarModel.php +++ b/application/Calendar/CalendarModel.php @@ -246,7 +246,8 @@ class CalendarModel $attachment = 0; $attachmentLinks = ""; } - if (in_array("Abwesenheit", $categories)) { + + if (!empty($categories) && in_array("Abwesenheit", $categories)) { continue; } if ($data['all_day_event'] == 1) { @@ -275,8 +276,10 @@ class CalendarModel if ($rrulefreq[$recurrence['pattern']['type']]) { unset ($byweekday); $freq = $rrulefreq[$recurrence['pattern']['type']]; - foreach ($recurrence['pattern']['daysOfWeek'] as $value) { - $byweekday[] = strtolower(substr($value, 0, 2)); + if (isset($recurrence['pattern']['daysOfWeek'])) { + foreach ($recurrence['pattern']['daysOfWeek'] as $value) { + $byweekday[] = strtolower(substr($value, 0, 2)); + } } $duration = ($data['end_time'] - $data['start_time']) * 1000; $until = $recurrence['range']['endDate']; @@ -541,24 +544,26 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda } $attendees = json_decode($data['attendees'], true); $organizer = json_decode($data['organizer'], true); - foreach ($attendees as $key => $value) { - if ($key == "required" || $key == "optional") { - foreach ($value as $attendeekey => $attendee) { - $attendee['name'] = self::replace_unicode_sequences($attendee['name']); - if ($attendee['email'] == $organizer['email']) { + if ($attendees) { + foreach ($attendees as $key => $value) { + if ($key == "required" || $key == "optional") { - } elseif ($Allcalendar[$attendee['name']] && $Allcalendar[$attendee['name']] == $data['calendar_id']) { + foreach ($value as $attendeekey => $attendee) { + $attendee['name'] = self::replace_unicode_sequences($attendee['name']); + if ($attendee['email'] == $organizer['email']) { - } else if ($Allcalendar[$attendee['name']]) { - $AttendeeArray[] = $Allcalendar[$attendee['name']]; - } else { - $AttendeeArray[] = $attendee['email']; + } elseif ($Allcalendar[$attendee['name']] && $Allcalendar[$attendee['name']] == $data['calendar_id']) { + + } else if ($Allcalendar[$attendee['name']]) { + $AttendeeArray[] = $Allcalendar[$attendee['name']]; + } else { + $AttendeeArray[] = $attendee['email']; + } } } } } - if (!$data['accepted'] && $data['busy'] == 1) { $data['accepted']['ok'] = 1; $data['accepted'] = json_encode($data['accepted']); @@ -644,11 +649,19 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda $title = ($r->title); $start = ((($r->start - 7200000) / 1000)); $end = ((($r->end - 7200000) / 1000)); + + $originalend = $end; if ($title) { $start = strtotime($r->start); $end = strtotime($r->end); } $allday = ($r->allday); + if ($allday) { + $start = $start + 7200; + $originalend = $end + 7200; + $end = $end + 7200 + 86400; + + } $reminder = ($r->reminder); $newkey = ($r->newkey); $id = ($r->id); @@ -706,7 +719,11 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda $updateArray['event_type'] = $type; $calEventCategories = self::$eventCategories; foreach ($calEventCategories as $key => $value) { - $arraykey = array_search($value, $categories); + if ($categories) { + $arraykey = array_search($value, $categories); + } else { + $arraykey = false; + } if (!empty($arraykey || $arraykey === 0)) { unset($categories[$arraykey]); } @@ -766,8 +783,10 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda $toolattachments[$dataAttachment['id']] = 1; } } - foreach ($attachments as $key => $value) { - unset($toolattachments[$value]); + if ($attachments) { + foreach ($attachments as $key => $value) { + unset($toolattachments[$value]); + } } if (!empty($toolattachments)) { foreach ($toolattachments as $key => $value) { @@ -788,6 +807,7 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda $updateArray['attachments'] = $attachments; + $updateArray['end_time'] = $originalend; } if ($attendees) $updateArray['attendees'] = $attendees; @@ -866,6 +886,7 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda $title = ($r->title); $start = strtotime($r->start); $end = strtotime($r->end); + $originalend = $end; $allday = ($r->allday); $reminder = ($r->reminder); $newkey = ($r->newkey); @@ -890,6 +911,10 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda } if (!$allday) { $allday = 0; + } else { + $start = $start + 7200; + $originalend= $end + 7200; + $end = $end + 7200 + 86400; } if ($reminder == 'NULL') { $reminder = NULL; @@ -947,6 +972,7 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda if ($rrules) { $dataarray['rrule'] = $rrules; } + $dataarray['end_time'] = $originalend; $json_data = json_encode($dataarray); $data = []; diff --git a/public/js/pages/Calendar/View.js b/public/js/pages/Calendar/View.js index 4d57915a0..f15cf6bbb 100644 --- a/public/js/pages/Calendar/View.js +++ b/public/js/pages/Calendar/View.js @@ -322,6 +322,7 @@ document.addEventListener('DOMContentLoaded', function () { if (info.resource) { resourceId = info.resource.id; } + let allDay = info.allDay; let cestDate = new Date(info.startStr); let cestOffset = 0; // 2 Stunden in Minuten let utcTime = cestDate.getTime() - cestOffset * 60 * 1000; @@ -336,22 +337,35 @@ document.addEventListener('DOMContentLoaded', function () { let StartformattedDate = year + "-" + month + "-" + day; let StarteformattedTime = hours + ":" + minutes; - - cestDate = new Date(info.endStr); - cestOffset = 0; // 2 Stunden in Minuten - utcTime = cestDate.getTime() - cestOffset * 60 * 1000; - - utcDate = new Date(utcTime); - year = utcDate.getUTCFullYear(); - month = String(utcDate.getUTCMonth() + 1).padStart(2, '0'); - day = String(utcDate.getUTCDate()).padStart(2, '0'); - hours = String(utcDate.getUTCHours()).padStart(2, '0'); - minutes = String(utcDate.getUTCMinutes()).padStart(2, '0'); - seconds = String(utcDate.getUTCSeconds()).padStart(2, '0'); - - let EndformattedDate = year + "-" + month + "-" + day; - let EndformattedTime = hours + ":" + minutes; - + let EndformattedDate; + let EndformattedTime; + if (!allDay) { + cestDate = new Date(info.endStr); + cestOffset = 0; // 2 Stunden in Minuten + utcTime = cestDate.getTime() - cestOffset * 60 * 1000; + utcDate = new Date(utcTime); + year = utcDate.getUTCFullYear(); + month = String(utcDate.getUTCMonth() + 1).padStart(2, '0'); + day = String(utcDate.getUTCDate()).padStart(2, '0'); + hours = String(utcDate.getUTCHours()).padStart(2, '0'); + minutes = String(utcDate.getUTCMinutes()).padStart(2, '0'); + seconds = String(utcDate.getUTCSeconds()).padStart(2, '0'); + EndformattedDate = year + "-" + month + "-" + day; + EndformattedTime = hours + ":" + minutes; + } else { + cestDate = new Date(info.endStr); + cestOffset = 120; // 2 Stunden in Minuten + utcTime = cestDate.getTime() - cestOffset * 60 * 1000; + utcDate = new Date(utcTime); + year = utcDate.getUTCFullYear(); + month = String(utcDate.getUTCMonth() + 1).padStart(2, '0'); + day = String(utcDate.getUTCDate()).padStart(2, '0'); + hours = String(utcDate.getUTCHours()).padStart(2, '0'); + minutes = String(utcDate.getUTCMinutes()).padStart(2, '0'); + seconds = String(utcDate.getUTCSeconds()).padStart(2, '0'); + EndformattedDate = year + "-" + month + "-" + day; + EndformattedTime = '23' + ":" + '59'; + } $('#EventModal').modal('show'); if (resourceId) { @@ -362,6 +376,15 @@ document.addEventListener('DOMContentLoaded', function () { $('#start-time').val(StarteformattedTime); $('#end-date').val(EndformattedDate); $('#end-time').val(EndformattedTime); + if (allDay) { + $('#allday').prop('checked', true); + $('#allday').change(); + + $('#end-time').val(''); + $('#end-date').val(EndformattedDate); + $('#start-time').val(''); + + } }, eventClick: function (info, element) { let isOrganizer; @@ -674,25 +697,33 @@ document.addEventListener('DOMContentLoaded', function () { let StartformattedDate = year + "-" + month + "-" + day; let StarteformattedTime = hours + ":" + minutes; + let EndformattedDate; + let EndformattedTime; + if (info.event.endStr) { + cestDate = new Date(info.event.endStr); + cestOffset = 0; - cestDate = new Date(info.event.endStr); - cestOffset = 0; // 2 Stunden in Minuten + // 2 Stunden in Minuten - utcTime = cestDate.getTime() - cestOffset * 60 * 1000; - if (info.event.allDay) { - utcTime = utcTime - 60; + utcTime = cestDate.getTime() - cestOffset * 60 * 1000; + if (info.event.allDay) { + utcTime = utcTime - 60; + } + utcDate = new Date(utcTime); + year = utcDate.getUTCFullYear(); + month = String(utcDate.getUTCMonth() + 1).padStart(2, '0'); + day = String(utcDate.getUTCDate()).padStart(2, '0'); + hours = String(utcDate.getUTCHours()).padStart(2, '0'); + minutes = String(utcDate.getUTCMinutes()).padStart(2, '0'); + seconds = String(utcDate.getUTCSeconds()).padStart(2, '0'); + + EndformattedDate = year + "-" + month + "-" + day; + EndformattedTime = hours + ":" + minutes; + } else { + EndformattedDate = StartformattedDate; + EndformattedTime = StarteformattedTime; } - utcDate = new Date(utcTime); - year = utcDate.getUTCFullYear(); - month = String(utcDate.getUTCMonth() + 1).padStart(2, '0'); - day = String(utcDate.getUTCDate()).padStart(2, '0'); - hours = String(utcDate.getUTCHours()).padStart(2, '0'); - minutes = String(utcDate.getUTCMinutes()).padStart(2, '0'); - seconds = String(utcDate.getUTCSeconds()).padStart(2, '0'); - - let EndformattedDate = year + "-" + month + "-" + day; - let EndformattedTime = hours + ":" + minutes; $('#EventModal').modal('show'); @@ -2806,7 +2837,6 @@ $(document).ready(function () { } }); $(document).ready(function () { - // Checkbox toggelt das RRule-Panel $('#recurringCheck').on('change', function () { if ($(this).is(':checked')) { $('#recurring-settings').show(); @@ -2820,8 +2850,6 @@ $(document).ready(function () { $('#rrule-frequency').on('change', function () { var freq = $(this).val(); - - // Alles erstmal verstecken $('#weekly-options').hide(); $('#monthly-options').hide();