diff --git a/application/Calendar/CalendarModel.php b/application/Calendar/CalendarModel.php index 48b91790c..62a13db1c 100644 --- a/application/Calendar/CalendarModel.php +++ b/application/Calendar/CalendarModel.php @@ -157,12 +157,17 @@ class CalendarModel $where .= " AND calendar_id IN (" . implode(",", $visibleCalendars) . ")"; $whereTimeRecording = " AND `Calendar`.`go_calendar_id` IN (" . implode(",", $visibleCalendars) . ")"; } - $sql = "SELECT `cal_events`.id, uuid, calendar_id, `cal_events`.user_id, start_time, end_time, timezone, all_day_event, `cal_events`.name,`cal_calendars`.name calendar_name, description, location, repeat_end_time, reminder, ctime,cname, mtime,mname, muser_id, busy, status, resource_event_id, private, rrule, `cal_events`.background, `cal_events`.files_folder_id, read_only, category_id, exception_for_event_id, recurrence_id, is_organizer,event_type,busy,recurrence FROM cal_events INNER JOIN `cal_calendars` ON (`cal_calendars`.`id`=`cal_events`.`calendar_id`) WHERE 1=1 $where "; + $sql = "SELECT `cal_events`.id,`cal_events`.categories, uuid, calendar_id, `cal_events`.user_id, start_time, end_time, timezone, all_day_event, `cal_events`.name,`cal_calendars`.name calendar_name, description, location, repeat_end_time, reminder, ctime,cname, mtime,mname, muser_id, busy, status, resource_event_id, private, rrule, `cal_events`.background, `cal_events`.files_folder_id, read_only, category_id, exception_for_event_id, recurrence_id, is_organizer,event_type,busy,recurrence,rrule_events FROM cal_events INNER JOIN `cal_calendars` ON (`cal_calendars`.`id`=`cal_events`.`calendar_id`) WHERE 1=1 $where "; $res = $dbcal->query($sql); if ($dbcal->num_rows($res)) { while ($data = $dbcal->fetch_array($res)) { + if ($data['categories']) { + $categories = json_decode($data['categories'], true); + } else { + $categories = []; + } unset($byweekday); $rrule = false; if ($attachments[$data['uuid']]) { @@ -173,7 +178,7 @@ class CalendarModel $attachmentLinks = ""; } if ($data['all_day_event'] == 1) { - if (strpos($data['name'], "Bereitschaft") === false && strpos($data['name'], "Blocker") === false) { + if (in_array("Feiertag", $categories)) { continue; } $starttime = date("Y-m-d", $data['start_time']); @@ -190,6 +195,7 @@ class CalendarModel if ($data['recurrence']) { $recurrence = json_decode($data['recurrence'], true); + $rrule_events= json_decode($data['rrule_events'], true); if ($rrulefreq[$recurrence['pattern']['type']]) { unset ($byweekday); $freq = $rrulefreq[$recurrence['pattern']['type']]; @@ -220,6 +226,7 @@ class CalendarModel } } else { $rrule = false; + $rrule_events = false; } if ($calendarColors[$data['calendar_id']]['bgcolor']) { @@ -245,7 +252,9 @@ class CalendarModel 'rights' => array('rights' => $rights, 'order' => $rights), 'location' => array('location' => $data['location']), 'busy' => array('busy' => $data['busy']), + 'allDay' => array('allDay' => $data['all_day_event']), 'rrule' => array('rrule' => $rrule), + 'rrule_events' => array('rrule_events' => $rrule_events), 'duration' => array('duration' => $duration), 'event_type' => array('event_type' => $data['event_type']), 'description' => array('description' => ($data['description'])), diff --git a/public/js/pages/Calendar/View.js b/public/js/pages/Calendar/View.js index b910bca8e..f700af3c4 100644 --- a/public/js/pages/Calendar/View.js +++ b/public/js/pages/Calendar/View.js @@ -85,6 +85,7 @@ document.addEventListener('DOMContentLoaded', function () { var rrule = null; var duration = null; var rruleflag = false; + let allDAy; $.each($('.calendar-check'), function (index, value) { if ($(this).prop('checked')) { rights = true; @@ -102,16 +103,12 @@ document.addEventListener('DOMContentLoaded', function () { $.each(json.data, function (index, value) { if (!value.timerecording.timerecording) { + allDAy = false; rrule = null; duration = null; rruleflag = false; category = value.ccategory.ccategory; - if (value.rrule.rrule) { - rrule = value.rrule.rrule; - duration = value.duration.duration; - rruleflag = true; - } if (value.calendar_id.calendar_id in calendarRights) { if (calendarRights[value.calendar_id.calendar_id] == 'all') { @@ -124,38 +121,90 @@ document.addEventListener('DOMContentLoaded', function () { } else { movable = false; } - let event = { - id: value.id.id, - start: value.cstart.cstart, - end: value.cend.cend, - title: category, - description: value.description.description, - location: value.location.location, - attachment: value.attachment.attachment, - attachments: value.attachments.attachments, - calendar_id: value.calendar_id, - event_type: value.event_type.event_type, - classNames: ['cal-class-group-' + value.calendar_id.calendar_id, 'cal-class-id-' + value.id.id], - textColor: value.txtColor.txtColor, - backgroundColor: value.bgColor.bgColor, - editable: rights, - rruleflag: rruleflag, - rrule: rrule, - duration: duration, - droppable: movable, - startEditable: movable, - durationEditable: movable, - resizableFromStart: movable, - resourceId: value.calendar_id.calendar_id, - calendar_name: value.calendar_name.calendar_name, - clickable: rights, - mtime: value.mtime.mtime, - mname: value.mname.mname, - ctime: value.ctime.ctime, - cname: value.cname.cname, - busy: value.busy.busy - }; - userevents.push(event); + if (value.allDay.allDay == "1") { + allDAy = true; + } + if (value.rrule.rrule) { + $.each(value.rrule_events.rrule_events, function (index, rrule_event) { + rruleflag = true; + let busy; + if (rrule_event.showAs == 'busy') { + busy = "1"; + } else if (rrule_event.showAs == 'tentative') { + busy = '2'; + } else if (rrule_event.showAs == 'free') { + busy = '0'; + } + let event = { + id: value.id.id, + start: rrule_event.start, + end: rrule_event.end, + title: rrule_event.subject, + description: value.description.description, + location: value.location.location, + allDay: allDAy, + attachment: value.attachment.attachment, + attachments: value.attachments.attachments, + calendar_id: value.calendar_id, + event_type: value.event_type.event_type, + classNames: ['cal-class-group-' + value.calendar_id.calendar_id, 'cal-class-id-' + value.id.id], + textColor: value.txtColor.txtColor, + backgroundColor: value.bgColor.bgColor, + editable: rights, + rruleflag: rruleflag, + dates: rrule, + duration: duration, + droppable: movable, + startEditable: movable, + durationEditable: movable, + resizableFromStart: movable, + resourceId: value.calendar_id.calendar_id, + calendar_name: value.calendar_name.calendar_name, + clickable: rights, + mtime: value.mtime.mtime, + mname: value.mname.mname, + ctime: value.ctime.ctime, + cname: value.cname.cname, + busy: busy + }; + userevents.push(event); + }); + + } else { + let event = { + id: value.id.id, + start: value.cstart.cstart, + end: value.cend.cend, + title: category, + description: value.description.description, + location: value.location.location, + allDay: allDAy, + attachment: value.attachment.attachment, + attachments: value.attachments.attachments, + calendar_id: value.calendar_id, + event_type: value.event_type.event_type, + classNames: ['cal-class-group-' + value.calendar_id.calendar_id, 'cal-class-id-' + value.id.id], + textColor: value.txtColor.txtColor, + backgroundColor: value.bgColor.bgColor, + editable: rights, + rruleflag: rruleflag, + dates: rrule, + duration: duration, + droppable: movable, + startEditable: movable, + durationEditable: movable, + resizableFromStart: movable, + resourceId: value.calendar_id.calendar_id, + calendar_name: value.calendar_name.calendar_name, + clickable: rights, + mtime: value.mtime.mtime, + mname: value.mname.mname, + ctime: value.ctime.ctime, + cname: value.cname.cname, + busy: value.busy.busy + }; + userevents.push(event); + } if (value.rrule.rrule) { } } else { @@ -1767,6 +1816,7 @@ Xinon GMbH`; var rrule = null; var duration = null; var rruleflag = false; + let allDAy = false; $.each($('.calendar-check'), function (index, value) { if ($(this).prop('checked')) { rights = true; @@ -1787,6 +1837,7 @@ Xinon GMbH`; rrule = null; duration = null; rruleflag = false; + allDAy = false; category = value.ccategory.ccategory; if (value.rrule.rrule) { rrule = value.rrule.rrule; @@ -1805,33 +1856,90 @@ Xinon GMbH`; } else { movable = false; } - userevents.push({ - id: value.id.id, - start: value.cstart.cstart, - end: value.cend.cend, - title: category, - description: value.description.description, - location: value.location.location, - attachment: value.attachment.attachment, - attachments: value.attachments.attachments, - calendar_id: value.calendar_id, - event_type: value.event_type.event_type, - classNames: ['cal-class-group-' + value.calendar_id.calendar_id, 'cal-class-id-' + value.id.id], - textColor: value.txtColor.txtColor, - backgroundColor: value.bgColor.bgColor, - editable: movable, - rruleflag: rruleflag, - rrule: rrule, - duration: duration, - resourceId: value.calendar_id.calendar_id, - calendar_name: value.calendar_name.calendar_name, - clickable: rights, - mtime: value.mtime.mtime, - mname: value.mname.mname, - ctime: value.ctime.ctime, - cname: value.cname.cname, - busy: value.busy.busy - }); + if (value.allDay.allDay == "1") { + allDAy = true; + } + if (value.rrule.rrule) { + $.each(value.rrule_events.rrule_events, function (index, rrule_event) { + rruleflag = true; + let busy; + if (rrule_event.showAs == 'busy') { + busy = "1"; + } else if (rrule_event.showAs == 'tentative') { + busy = '2'; + } else if (rrule_event.showAs == 'free') { + busy = '0'; + } + let event = { + id: value.id.id, + start: rrule_event.start, + end: rrule_event.end, + title: rrule_event.subject, + description: value.description.description, + location: value.location.location, + allDay: allDAy, + attachment: value.attachment.attachment, + attachments: value.attachments.attachments, + calendar_id: value.calendar_id, + event_type: value.event_type.event_type, + classNames: ['cal-class-group-' + value.calendar_id.calendar_id, 'cal-class-id-' + value.id.id], + textColor: value.txtColor.txtColor, + backgroundColor: value.bgColor.bgColor, + editable: rights, + rruleflag: rruleflag, + dates: rrule, + duration: duration, + droppable: movable, + startEditable: movable, + durationEditable: movable, + resizableFromStart: movable, + resourceId: value.calendar_id.calendar_id, + calendar_name: value.calendar_name.calendar_name, + clickable: rights, + mtime: value.mtime.mtime, + mname: value.mname.mname, + ctime: value.ctime.ctime, + cname: value.cname.cname, + busy: busy + }; + userevents.push(event); + }); + + } else { + let event = { + id: value.id.id, + start: value.cstart.cstart, + end: value.cend.cend, + title: category, + description: value.description.description, + location: value.location.location, + allDay: allDAy, + attachment: value.attachment.attachment, + attachments: value.attachments.attachments, + calendar_id: value.calendar_id, + event_type: value.event_type.event_type, + classNames: ['cal-class-group-' + value.calendar_id.calendar_id, 'cal-class-id-' + value.id.id], + textColor: value.txtColor.txtColor, + backgroundColor: value.bgColor.bgColor, + editable: rights, + rruleflag: rruleflag, + dates: rrule, + duration: duration, + droppable: movable, + startEditable: movable, + durationEditable: movable, + resizableFromStart: movable, + resourceId: value.calendar_id.calendar_id, + calendar_name: value.calendar_name.calendar_name, + clickable: rights, + mtime: value.mtime.mtime, + mname: value.mname.mname, + ctime: value.ctime.ctime, + cname: value.cname.cname, + busy: value.busy.busy + }; + userevents.push(event); + } } else { otherevents.push({ id: value.id.id,