diff --git a/Layout/default/Calendar/View.php b/Layout/default/Calendar/View.php index 2286ae0ca..93cc517a5 100644 --- a/Layout/default/Calendar/View.php +++ b/Layout/default/Calendar/View.php @@ -391,12 +391,12 @@ endforeach;
-
+
-
+
Typ
-
+
- +
- +
-
+
@@ -437,7 +437,7 @@ endforeach;
-
+
@@ -448,7 +448,7 @@ endforeach; aria-describedby="Datum">
-
+
-
+
@@ -592,7 +592,7 @@ endforeach;
-
+
@@ -613,7 +613,7 @@ endforeach;
- -
+
-
+
@@ -660,12 +660,19 @@ endforeach;
- -
+
+ + +
- - @@ -712,7 +719,7 @@ endforeach;
-
+
@@ -725,8 +732,8 @@ endforeach;
-
-
+
+
@@ -745,24 +752,30 @@ endforeach;
@@ -791,6 +804,7 @@ endforeach; let requestUpdateStateUrl = " 'updateCalendarEventState']) ?>"; let requestUpdateColorUrl = " 'updateCalendarColor']) ?>"; let requestDeleteUrl = " 'deleteCalendarEvent']) ?>"; + let requestCancelUrl = " 'cancelCalendarEvent']) ?>"; let requestUpdateEventsUrl = "/calendarStream?user="; let requestgetpreviewtUrl = " 'getPreview']) ?>"; let calendarRights = ''; diff --git a/application/Calendar/CalendarController.php b/application/Calendar/CalendarController.php index f6cc0b006..c781787ac 100644 --- a/application/Calendar/CalendarController.php +++ b/application/Calendar/CalendarController.php @@ -168,6 +168,44 @@ class CalendarController extends mfBaseController $id = ($r->id); CalendarModel::deleteCalendarEvent($r); die(); + case "cancelCalendarEvent": + $r = $this->request; + $id = ($r->id); + if ($r->customer_info_check) { + if ($r->customer_info_type == 1) { + $body = $r->customer_info_text; + $email = new Emailnotification(); + $email->setSubject('Technikertermin Xinon Absage'); + $email->setBody($body); + $email->setFrom('termin@xinon.at', 'Terminbestätigung'); + $email->setTo($r->customer_info_type_text); + $email->send(); + } else if ($r->customer_info_type == 2) { + $sms = new SmsNotification(); + $customerText = trim($r->customer_info_text); + $body = "Xinon Terminabsage:" . PHP_EOL . $customerText; + $sms->setBody($body); + $customerNumber = trim($r->customer_info_type_text); + $customerNumber = str_replace(" ", "", $customerNumber); + $customerNumber = str_replace("(", "", $customerNumber); + $customerNumber = str_replace(")", "", $customerNumber); + $customerNumber = str_replace("-", "", $customerNumber); + $customerNumber = str_replace("/", "", $customerNumber); + $customerNumber = str_replace(".", "", $customerNumber); + $customerNumber = str_replace(",", "", $customerNumber); + $customerNumber = str_replace(";", "", $customerNumber); + $customerNumber = str_replace(":", "", $customerNumber); + if (preg_match('/^0/', $customerNumber)) { + $customerNumber = "+43" . substr($customerNumber, 1); + } + $sms->setRecipient($customerNumber); + if (!empty($customerNumber) && !empty($customerText)) { + $sms->send(); + } + } + } + CalendarModel::cancelCalendarEvent($r,$this->me); + die(); case "updateCalendarColor": $r = $this->request; $calendar_id = ($r->calendar_id); diff --git a/application/Calendar/CalendarModel.php b/application/Calendar/CalendarModel.php index e6e2a2a75..d49ed5fd9 100644 --- a/application/Calendar/CalendarModel.php +++ b/application/Calendar/CalendarModel.php @@ -461,7 +461,7 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda } $Allcalendar['Daniel Whoknows'] = 2; $Allcalendar['Stefan Plaschg'] = 26; - $res = $dbcal->select("cal_events", "id, uuid, calendar_id, user_id, start_time, end_time, timezone, all_day_event, name, description, location, repeat_end_time, reminder, ctime, mtime, muser_id, busy, status, resource_event_id, private, rrule, background, files_folder_id, read_only, category_id, exception_for_event_id, recurrence_id, recurrence, is_organizer,event_type,customer,customer_info,customer_info_send,customer_info_reminder,busy,attendees,organizer,is_organizer,accepted", "1=1 AND id='" . $id . "' ORDER BY id"); + $res = $dbcal->select("cal_events", "id, uuid, calendar_id, user_id, start_time, end_time, timezone, all_day_event, name, description, location, repeat_end_time, reminder, ctime, mtime, muser_id, busy, status, resource_event_id, private, rrule, background, files_folder_id, read_only, category_id, exception_for_event_id, recurrence_id, recurrence, is_organizer,event_type,customer,customer_info,customer_info_send,customer_info_reminder,busy,attendees,organizer,is_organizer,accepted,canceld", "1=1 AND id='" . $id . "' ORDER BY id"); if ($dbcal->num_rows($res)) { $data = $dbcal->fetch_array($res); if ($data['recurrence']) { @@ -559,6 +559,7 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda 'customer_info_reminder' => array('customer_info_reminder' => $data['customer_info_reminder']), 'privateflag' => array('privateflag' => $data['private'], 'order' => $data['private']), 'isorganizer' => array('isorganizer' => $data['is_organizer']), + 'canceld' => array('canceld' => $data['canceld']), 'attendees' => array('attendees' => json_encode($AttendeeArray)), 'organizer' => array('organizer' => self::replace_unicode_sequences($data['organizer'])), 'accepted' => array('accepted' => $data['accepted']), @@ -997,6 +998,103 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda die(); } + public static function cancelCalendarEvent($r,$me) + { + $id = $r->id; + $users = $r->users; + foreach ($users as $key => $value) { + $user_id = $value; + } + date_default_timezone_set('Europe/Berlin'); + header('Content-Type: application/json'); + $db = self::dbKalender(); + $res = $db->select("cal_calendars", "id,ms_user_id", "id = '" . $user_id . "' LIMIT 1"); + if ($db->num_rows($res)) { + $result = $db->fetch_object($res); + $microsoft_user_id = $result->ms_user_id; + + } + $updateArray = []; + $res = $db->select("cal_events", 'id,microsoft_id,name,microsoft_ical_uid,start_time,end_time', "id = '" . $id . "' LIMIT 1"); + if ($db->num_rows($res)) { + $result = $db->fetch_object($res); + + if (($r->customer_info_type)) { + $customer_info_type = $r->customer_info_type; + } + if (($r->customer_info_text)) { + $customer_info_text = $r->customer_info_text; + } + if (($r->customer_info_type_text)) { + $customer_info_type_text = $r->customer_info_type_text; + } + $customerJson = array('customer_info_type' => $customer_info_type, 'customer_info_text' => $customer_info_text, 'customer_info_type_text' => $customer_info_type_text); + $updateArray['customer_info'] = json_encode($customerJson); + if ($r->customer_info_check) { + $customerJson['sendby'] = $me->name; + $customerJson['sendtime'] = time(); + $updateArray['customer_info_send'] = json_encode($customerJson); + } + + $newname = "Absage: " . $result->name; + $microsoft_id = $result->microsoft_id; + $updateArray['name'] = $newname; + $updateArray['busy'] = '0'; + $updateArray['start_time'] = $result->start_time; + $updateArray['end_time'] = $result->end_time; + $updateArray['customer_info_reminder'] = 0; + $updateArray['canceld'] = 1; + $db->update("cal_events", $updateArray, "id = '" . $id . "'"); + $json_data = json_encode($updateArray); + $data = []; + $data['ms_user_id'] = $microsoft_user_id; + $data['ms_event_id'] = $microsoft_id; + $data['data'] = $json_data; + $data['type'] = 'u'; + $data['status'] = 'p'; + $data['edit'] = time(); + $data['create'] = time(); + $data['edit_by'] = 89; + $data['create_by'] = 89; + $db->insert("TheTool_CalendarQueue", $data); + $res = $db->select("cal_events", 'id,microsoft_id,name,microsoft_ical_uid,start_time,end_time,calendar_id', "id != '" . $id . "' AND microsoft_ical_uid = '" . $result->microsoft_ical_uid . "' "); + while ($row = $db->fetch_object($res)) { + $updateArray = []; + $updateArray['name'] = $newname; + $updateArray['busy'] = '0'; + $updateArray['start_time'] = $row->start_time; + $updateArray['end_time'] = $row->end_time; + $updateArray['customer_info_reminder'] = 0; + $updateArray['canceld'] = 1; + $updateArray['customer_info'] = json_encode($customerJson); + if ($r->customer_info_check) { + $customerJson['sendby'] = $me->name; + $customerJson['sendtime'] = time(); + $updateArray['customer_info_send'] = json_encode($customerJson); + } + $db->update("cal_events", $updateArray, "id = '" . $row->id . "'"); + $json_data = json_encode($updateArray); + $rescal = $db->select("cal_calendars", "id,ms_user_id", "id = '" . $row->calendar_id . "' LIMIT 1"); + $resultcal = $db->fetch_object($rescal); + + $data = []; + $data['ms_user_id'] = $resultcal->ms_user_id; + $data['ms_event_id'] = $row->microsoft_id; + $data['data'] = $json_data; + $data['type'] = 'u'; + $data['status'] = 'p'; + $data['edit'] = time(); + $data['create'] = time(); + $data['edit_by'] = 89; + $data['create_by'] = 89; + $db->insert("TheTool_CalendarQueue", $data); + } + } + + + die(); + } + public static function generateDataRecurrence($graph) { $data = []; diff --git a/public/css/pages/Calendar/View.css b/public/css/pages/Calendar/View.css index bf51586b5..668721f1c 100644 --- a/public/css/pages/Calendar/View.css +++ b/public/css/pages/Calendar/View.css @@ -425,13 +425,20 @@ thead .fc-day-today .fc-scrollgrid-sync-inner .fc-col-header-cell-cushion { } .fa-calendar-lines-pen:before { - color: #ff0000; + color: #ff6200; } .fa-calendar-circle-plus:before { color: #0d9f00; } +.fa-calendar-circle-exclamation +{ + color: #ff0000; +} + + + .fa-del-attachment { color: #ff0000; cursor: pointer; diff --git a/public/js/pages/Calendar/View.js b/public/js/pages/Calendar/View.js index dffde6675..5dd4594da 100644 --- a/public/js/pages/Calendar/View.js +++ b/public/js/pages/Calendar/View.js @@ -475,9 +475,7 @@ document.addEventListener('DOMContentLoaded', function () { html: true }); } - } - else if (data.data.type.type == "7") - { + } else if (data.data.type.type == "7") { $('.ticket-div').hide(); $('.customer-div').show(); if (data.data.customer.customer) { @@ -554,8 +552,7 @@ document.addEventListener('DOMContentLoaded', function () { html: true }); } - } - else if (data.data.type.type == "5") { + } else if (data.data.type.type == "5") { $('.ticket-div').show(); $('.customer-div').hide(); if (data.data.customer.customer) { @@ -586,6 +583,11 @@ document.addEventListener('DOMContentLoaded', function () { $('.event-organizer-div').hide(); $('.show-update').show(); $('.show-attendee').hide(); + if (data.data.type.type == 2 || data.data.type.type == 3 || data.data.type.type == 4 || data.data.type.type == 7) { + $('#cancel-event').show(); + } else { + $('#cancel-event').hide(); + } } else { const organizer = JSON.parse(data.data.organizer.organizer); $('.event-organizer-div').show(); @@ -612,6 +614,7 @@ document.addEventListener('DOMContentLoaded', function () { } $('.show-update').hide(); $('.show-attendee').show(); + $('#cancel-event').hide(); $('.show-attendee').data('id', info.event.id); } @@ -632,6 +635,7 @@ document.addEventListener('DOMContentLoaded', function () { } if (info.event.extendedProps.rruleflag == true) { $('#delete-event').hide(); + $('#cancel-event').hide(); $('#update-event').hide(); $('.show-attendee').hide(); $('#recurringCheck').prop('checked', true); @@ -648,6 +652,12 @@ document.addEventListener('DOMContentLoaded', function () { } } + if (data.data.canceld.canceld == 1) { + $('#delete-event').hide(); + $('#cancel-event').hide(); + $('#update-event').hide(); + $('.show-attendee').hide(); + } }); if (info.event.extendedProps.clickable) { @@ -713,9 +723,13 @@ document.addEventListener('DOMContentLoaded', function () { // $('#description').val(info.event.extendedProps.description); $('#delete-event').data('id', info.event.id); $('#update-event').data('id', info.event.id); + $('#cancel-event').data('id', info.event.id); + $('#cancelled-event').data('id', info.event.id); + $('#cancelled-abort').data('id', info.event.id); $('#EventModalLabel').data('id', info.event.id); $('#EventModalLabel span').text('Termin bearbeiten'); $('#EventModalLabel .fa-calendar-symbol').removeClass('fa-calendar-circle-plus'); + $('#EventModalLabel .fa-calendar-symbol').removeClass('fa-calendar-circle-exclamation'); $('#EventModalLabel .fa-calendar-symbol').addClass('fa-calendar-lines-pen'); $('#add-event').hide(); // $('#calendar-users').select2('destroy'); @@ -1266,9 +1280,13 @@ $(document).ready(function () { $('#EventModal').on('show.bs.modal', function (event) { $(document).off('focusin.modal'); + $('.hide-cancelled').show(); + $('.show-cancelled').hide(); + $('#name-col').removeClass('col-9').addClass('col-6'); $('.attachment-div').empty(); $('#reminder').val('NULL'); $('#type').val('1'); + $('.privacy-click').removeClass('fa-lock'); $('.privacy-click').removeClass('fa-unlock'); $('.privacy-click').addClass('fa-unlock'); @@ -1284,6 +1302,7 @@ $(document).ready(function () { $('#EventModalLabel span').text('Termin erstellen'); $('#EventModalLabel .fa-calendar-symbol').addClass('fa-calendar-circle-plus'); $('#EventModalLabel .fa-calendar-symbol').removeClass('fa-calendar-lines-pen'); + $('#EventModalLabel .fa-calendar-symbol').removeClass('fa-calendar-circle-exclamation'); $('#EventModalLabel').data('id', ''); $('.show-attendee').data('id', ''); $('.eventmodal-input').val(''); @@ -1459,6 +1478,86 @@ $(document).ready(function () { $('#EventModal').modal('hide'); }); + + $('body').on('click', '#cancelled-event', function () { + let id = $(this).data('id'); + let title = $('#name').val(); + let users = []; + let customer_info_text; + let customer_info_type; + let customer_info_type_text; + let customer_info_check = 0; + $('#calendar-users > option:selected').each(function () { + users.push($(this).val()); + }); + customer_info_text = $('#customer-info-text').val(); + customer_info_type = $('#customer-info-type').val(); + customer_info_type_text = $('#customer-info-type-text').val(); + + if ($('#customer-info-check-cancelled').is(':checked')) { + customer_info_check = 1; + } + if (confirm('Termin wirklich absagen?')) { + $.post(requestCancelUrl, { + id: id, + users: users, + customer_info_text: customer_info_text, + customer_info_type: customer_info_type, + customer_info_type_text: customer_info_type_text, + customer_info_check:customer_info_check, + title: title + }, function (data) { + + }).done(function (data) { + }); + $('#EventModal').modal('hide'); + } + + }); + $('body').on('click', '#cancel-event', function () { + let id = $(this).data('id'); + let users = []; + $('.hide-cancelled').hide(); + $('.show-cancelled').show(); + $('#name').val("Absage: " + $('#name').val()); + $('#name-col').removeClass('col-6').addClass('col-9'); + + // + // + $('#EventModalLabel .fa-calendar-symbol').removeClass('fa-calendar-circle-plus'); + $('#EventModalLabel .fa-calendar-symbol').removeClass('fa-calendar-lines-pen'); + $('#EventModalLabel .fa-calendar-symbol').addClass('fa-calendar-circle-exclamation'); + $('#EventModalLabel span').text('Termin absagen'); + // $('#calendar-users > option:selected').each(function () { + // users.push($(this).val()); + // }); + // + // + // if (confirm('Termin wirklich absagen?')) { + // $.post(requestCancelUrl, { + // id: id, + // users: users + // }, function (data) { + // + // }).done(function (data) { + // }); + // $('#EventModal').modal('hide'); + // } + }); + $('body').on('click', '#cancelled-abort', function () { + const id = $(this).data('id'); + const eventEl = document.querySelector('.cal-class-id-' + id); + if (!eventEl) return console.warn('Event-Element nicht gefunden:', id); + $('#EventModal').one('hidden.bs.modal', function () { + eventEl.dispatchEvent(new MouseEvent('click', { + bubbles: true, + cancelable: true + })); + }); + $('#EventModal').modal('hide'); + }); + + $('body').on('click', '#update-event', function () { let valid = true; @@ -1487,6 +1586,9 @@ $(document).ready(function () { let title = $('#name').val(); let location = $('#location').val(); let description = tinymce.activeEditor.getContent(); + if (description == "") { + description = ' '; + } let newkey = $('#attachments').data('newkey'); let allday = 0; let reminder = $('#reminder').val(); @@ -1512,7 +1614,7 @@ $(document).ready(function () { if ($('#customer-info-check').is(':checked')) { customer_info_check = 1; } - if (type == '2' || type == '3' || type == '4' || type=='7') { + if (type == '2' || type == '3' || type == '4' || type == '7') { customer_info_text = $('#customer-info-text').val(); customer_info_type = $('#customer-info-type').val(); customer_info_type_text = $('#customer-info-type-text').val(); @@ -1906,7 +2008,7 @@ $(document).ready(function () { } } }); - }else if ($(this).val() == "6") { + } else if ($(this).val() == "6") { $('.customer-div').show(); $('.ticket-div').hide(); $('#customer').select2({ @@ -2052,11 +2154,14 @@ $(document).ready(function () { $('#customer-info-type-text').val(data.mobilenumber); } } - if ($("#customer").select2('data')[0].spin) {// ID deines Editors - var currentContent = tinymce.activeEditor.getContent(); - tinymce.activeEditor.setContent(currentContent + '

Service Pin: ' + $("#customer").select2('data')[0].spin + '

'); - // - // $('#description').val('Service Pin: ' + $("#customer").select2('data')[0].spin + '\n'); + if ($(this).attr('id') == 'customer') { + + if ($("#customer").select2('data')[0].spin) {// ID deines Editors + var currentContent = tinymce.activeEditor.getContent(); + tinymce.activeEditor.setContent(currentContent + '

Service Pin: ' + $("#customer").select2('data')[0].spin + '

'); + // + // $('#description').val('Service Pin: ' + $("#customer").select2('data')[0].spin + '\n'); + } }