2690 lines
125 KiB
JavaScript
2690 lines
125 KiB
JavaScript
var hidesearch = [2, 3, 4, 8];
|
|
var columnfilter = [7];
|
|
var columnoptions = '<option value=""></option><option value="Offen">Offen</option><option value="Genehmigt">Genehmigt</option><option value="Abgelehnt">Abgelehnt</option>';
|
|
|
|
|
|
const fileTypeClasses = {
|
|
'image/png': 'fa-file-png',
|
|
'image/jpeg': 'fa-file-jpg',
|
|
'application/pdf': 'fa-file-pdf',
|
|
'application/zip': 'fa-file-zip',
|
|
'application/x-zip-compressed': 'fa-file-zip',
|
|
'application/octet-stream': 'fa-file-csv',
|
|
'text/csv': 'fa-file-csv',
|
|
'text/xml': 'fa-file-xml',
|
|
'application/xml': 'fa-file-xml',
|
|
'audio/mpeg': 'fa-file-mp3',
|
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'fa-file-doc',
|
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'fa-file-xls',
|
|
'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'fa-file-ppt',
|
|
'application/x-rar-compressed': 'fa-file-archive',
|
|
'application/msword': 'fa-file-doc',
|
|
'application/vnd.ms-excel': 'fa-file-xls',
|
|
'application/vnd.ms-powerpoint': 'fa-file-ppt',
|
|
'application/vnd.ms-outlook': 'fa-file-outlook',
|
|
'application/vnd.ms-access': 'fa-file-access',
|
|
'application/vnd.ms-project': 'fa-file-project',
|
|
'application/vnd.ms-visio': 'fa-file-visio',
|
|
'application/vnd.ms-publisher': 'fa-file-publisher',
|
|
};
|
|
let calendar;
|
|
let calendarEl = document.getElementById('calendar');
|
|
calendarRights = JSON.parse(calendarRights);
|
|
|
|
function formatFileSize(bytes) {
|
|
// Wenn die Dateigröße größer als 1 MB ist
|
|
if (bytes >= 1024 * 1024) {
|
|
const megabytes = bytes / (1024 * 1024);
|
|
return megabytes.toFixed(2) + ' MB';
|
|
}
|
|
// Wenn die Dateigröße größer als 1 KB ist
|
|
else if (bytes >= 1024) {
|
|
const kilobytes = bytes / 1024;
|
|
return kilobytes.toFixed(2) + ' KB';
|
|
}
|
|
// Wenn die Dateigröße kleiner als 1 KB ist (also in Bytes)
|
|
else {
|
|
return Math.round(bytes) + ' Bytes'; // Keine Nachkommastellen
|
|
}
|
|
}
|
|
|
|
function getOffset(unixTimestamp) {
|
|
const date = new Date(unixTimestamp); // Convert to milliseconds
|
|
const isDST = date.getTimezoneOffset() < Math.max(
|
|
new Date(date.getFullYear(), 0, 1).getTimezoneOffset(),
|
|
new Date(date.getFullYear(), 6, 1).getTimezoneOffset()
|
|
);
|
|
|
|
return isDST ? 7200 : 3600;
|
|
}
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
let checkbox = $(".form-check-input");
|
|
let visibleCalendars = [];
|
|
let mycalendar_id = $('#calendar-id').data('calendarid');
|
|
visibleCalendars.push(0);
|
|
checkbox.each(function () {
|
|
if ($(this).prop('checked')) {
|
|
visibleCalendars.push($(this).data('calendar_id'));
|
|
}
|
|
});
|
|
|
|
|
|
$.post(requestUrl, {visibleCalendars: visibleCalendars}, function (data) {
|
|
|
|
}, 'json').done(function (json) {
|
|
if (json.success == true) {
|
|
let userevents = [];
|
|
let otherevents = [];
|
|
let resources = [];
|
|
let category = "";
|
|
let rights = false;
|
|
let movable = false;
|
|
let resourceCounter = 0;
|
|
let rrule = null;
|
|
let duration = null;
|
|
let rruleflag = false;
|
|
let allDAy;
|
|
let cursorclass = "";
|
|
$.each($('.calendar-check'), function (index, value) {
|
|
if ($(this).prop('checked')) {
|
|
rights = true;
|
|
resources.push({
|
|
id: $(this).data('calendar_id'),
|
|
title: $.trim($(this).closest('div').find('label').text()),
|
|
order: resourceCounter
|
|
});
|
|
resourceCounter++;
|
|
}
|
|
});
|
|
|
|
$.each(json.data, function (index, value) {
|
|
if (!value.timerecording.timerecording) {
|
|
allDAy = false;
|
|
rrule = null;
|
|
duration = null;
|
|
rruleflag = false;
|
|
category = value.ccategory.ccategory;
|
|
cursorclass = "";
|
|
|
|
if (value.calendar_id.calendar_id in calendarRights) {
|
|
if (calendarRights[value.calendar_id.calendar_id] == 'all') {
|
|
rights = true;
|
|
} else {
|
|
rights = false;
|
|
}
|
|
if (value.privateflag.privateflag == '1' && mycalendar_id != value.calendar_id.calendar_id) {
|
|
rights = false;
|
|
|
|
}
|
|
|
|
|
|
if (value.isorganizer.isorganizer == '1' && rights) {
|
|
movable = true;
|
|
|
|
} else if (rights) {
|
|
movable = false;
|
|
cursorclass = "cursor-alias";
|
|
} else {
|
|
movable = false;
|
|
}
|
|
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, cursorclass],
|
|
textColor: value.txtColor.txtColor,
|
|
backgroundColor: value.bgColor.bgColor,
|
|
privateflag: value.privateflag.privateflag,
|
|
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, cursorclass],
|
|
textColor: value.txtColor.txtColor,
|
|
backgroundColor: value.bgColor.bgColor,
|
|
privateflag: value.privateflag.privateflag,
|
|
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 {
|
|
otherevents.push({
|
|
id: value.id.id,
|
|
start: value.cstart.cstart,
|
|
end: value.cend.cend,
|
|
title: category,
|
|
description: category,
|
|
color: 'red',
|
|
editable: false,
|
|
rruleflag: rruleflag,
|
|
rrule: rrule,
|
|
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],
|
|
attachment: value.attachment.attachment,
|
|
attachments: value.attachments.attachments,
|
|
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
|
|
});
|
|
|
|
}
|
|
} else {
|
|
let event = {
|
|
id: value.id.id,
|
|
start: value.cstart.cstart,
|
|
end: value.cend.cend,
|
|
title: value.category.category,
|
|
description: value.description.description,
|
|
calendar_id: value.calendar_id,
|
|
textColor: value.txtColor.txtColor,
|
|
backgroundColor: value.bgColor.bgColor,
|
|
resourceId: value.calendar_id.calendar_id,
|
|
calendar_name: value.calendar_name.calendar_name,
|
|
mtime: value.mtime.mtime,
|
|
mname: value.mname.mname,
|
|
ctime: value.ctime.ctime,
|
|
cname: value.cname.cname,
|
|
editable: false,
|
|
|
|
};
|
|
userevents.push(event);
|
|
}
|
|
});
|
|
|
|
function sleep(ms) {
|
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
}
|
|
|
|
const eventSources = [];
|
|
eventSources.push(userevents);
|
|
eventSources.push(otherevents);
|
|
if (visibleCalendars.includes(997)) {
|
|
eventSources.push(holiDays);
|
|
}
|
|
if (visibleCalendars.includes(998)) {
|
|
eventSources.push(birthdays);
|
|
}
|
|
|
|
|
|
calendar = new FullCalendar.Calendar(calendarEl, {
|
|
schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
|
|
timeZone: 'UTC',
|
|
locale: 'de',
|
|
height: 'auto',
|
|
resourceAreaWidth: '220px',
|
|
themeSystem: 'bootstrap4',
|
|
snapDuration: '00:15:00',
|
|
selectable: true,
|
|
weekNumbers: true,
|
|
headerToolbar: {
|
|
left: "prev,today,next",
|
|
center: 'title',
|
|
right: 'dayGridMonth,timeGridWeek,timeGridDay,resourceTimelineDay,listMonth'
|
|
},
|
|
views: {
|
|
timeGridDay: {
|
|
titleFormat: {
|
|
weekday: 'long',
|
|
year: 'numeric',
|
|
month: 'short',
|
|
day: 'numeric'
|
|
}
|
|
},
|
|
resourceTimelineDay: {
|
|
titleFormat: {
|
|
weekday: 'long',
|
|
year: 'numeric',
|
|
month: 'short',
|
|
day: 'numeric'
|
|
}
|
|
}
|
|
},
|
|
buttonText: {
|
|
resourceTimelineDay: 'Planung'
|
|
},
|
|
select: function (info) {
|
|
let resourceId = "";
|
|
if (info.resource) {
|
|
resourceId = info.resource.id;
|
|
}
|
|
let cestDate = new Date(info.startStr);
|
|
let cestOffset = 0; // 2 Stunden in Minuten
|
|
let utcTime = cestDate.getTime() - cestOffset * 60 * 1000;
|
|
|
|
let utcDate = new Date(utcTime);
|
|
let year = utcDate.getUTCFullYear();
|
|
let month = String(utcDate.getUTCMonth() + 1).padStart(2, '0');
|
|
let day = String(utcDate.getUTCDate()).padStart(2, '0');
|
|
let hours = String(utcDate.getUTCHours()).padStart(2, '0');
|
|
let minutes = String(utcDate.getUTCMinutes()).padStart(2, '0');
|
|
let seconds = String(utcDate.getUTCSeconds()).padStart(2, '0');
|
|
|
|
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;
|
|
|
|
|
|
$('#EventModal').modal('show');
|
|
if (resourceId) {
|
|
$('#calendar-users').val(resourceId).trigger('change');
|
|
$('.calendar-users-all').show();
|
|
}
|
|
$('#start-date').val(StartformattedDate);
|
|
$('#start-time').val(StarteformattedTime);
|
|
$('#end-date').val(EndformattedDate);
|
|
$('#end-time').val(EndformattedTime);
|
|
|
|
}, eventClick: function (info, element) {
|
|
let isOrganizer;
|
|
$.getJSON(requestEventUrl, {
|
|
id: info.event.id
|
|
}, function (data) {
|
|
}).done(function (data) {
|
|
if (data.data.description.description) {
|
|
tinymce.activeEditor.setContent(data.data.description.description);
|
|
}
|
|
if (data.data.attachment.attachment) {
|
|
let docs = "";
|
|
$.each(data.data.attachments.attachments, function (index, value) {
|
|
docs += `<div data-docid="` + value.id + `" class="doc-main-div"><div class="d-inline-block doc-icon-div"><i class="fa-duotone fa-solid ` + value.icon + `"></i></div><div class="d-inline-block doc-content-div"><a href="` + requestEventAttachmentUrl + `&id=` + value.id + `" target="_blank" >` + value.name + `</a></div><span class="float-right"><i title="` + value.name + ` entfernen" class="fas fa-trash fa-del-attachment ml-2"></i></span><span class="float-right">` + formatFileSize(value.size) + `</span></div>`;
|
|
});
|
|
$('.attachment-div').append(docs);
|
|
}
|
|
if (data.data.reminder.reminder) {
|
|
$('#reminder').val(data.data.reminder.reminder);
|
|
} else {
|
|
$('#reminder').val('NULL');
|
|
}
|
|
if (data.data.privateflag.privateflag == 1) {
|
|
$('.privacy-click').removeClass('fa-unlock');
|
|
$('.privacy-click').removeClass('fa-lock');
|
|
$('.privacy-click').addClass('fa-lock');
|
|
}
|
|
|
|
|
|
$('#type').val(data.data.type.type);
|
|
$('#busy').val(data.data.busy.busy);
|
|
isOrganizer = data.data.isorganizer.isorganizer;
|
|
if (data.data.type.type == "1") {
|
|
$('.customer-div').hide();
|
|
$('.ticket-div').hide();
|
|
} else if (data.data.type.type == "2" || data.data.type.type == "3" || data.data.type.type == "4" || data.data.type.type == "6") {
|
|
$('.ticket-div').hide();
|
|
$('.customer-div').show();
|
|
if (data.data.customer.customer) {
|
|
$('#customer').html('<option>' + data.data.customer.customer + '</option>');
|
|
} else {
|
|
$('#customer').html('<option></option>');
|
|
}
|
|
if (data.data.customer_info_reminder.customer_info_reminder) {
|
|
if (data.data.customer_info_reminder.customer_info_reminder == 1) {
|
|
$('#customer-info-reminder-check').prop('checked', true);
|
|
} else {
|
|
$('#customer-info-reminder-check').prop('checked', false);
|
|
}
|
|
}
|
|
$('#customer').select2({
|
|
placeholder: "Kunden Suche",
|
|
minimumInputLength: 3,
|
|
dropdownParent: jQuery('#relContainer2'),
|
|
// dropdownParent: $('#EventModal'),
|
|
language: "de",
|
|
ajax: {
|
|
url: requestAddressUrl,
|
|
dataType: 'json',
|
|
delay: 250,
|
|
processResults: function (data) {
|
|
// Transforms the top-level key of the response object from 'items' to 'results'
|
|
return {
|
|
results: data.items
|
|
};
|
|
}
|
|
}
|
|
});
|
|
if (data.data.customer_info.customer_info) {
|
|
const obj = JSON.parse(data.data.customer_info.customer_info);
|
|
$('#customer-info-text').val(obj.customer_info_text);
|
|
$('#customer-info-type').val(obj.customer_info_type);
|
|
$('#customer-info-type-text').val(obj.customer_info_type_text);
|
|
}
|
|
if (data.data.customer_info_send.customer_info_send) {
|
|
const obj = JSON.parse(data.data.customer_info_send.customer_info_send);
|
|
$('#customer-info-check-info').html('<i class="fa-sharp-duotone fa-solid fa-circle-info customer-info-point"></i>');
|
|
const unixTime = obj.sendtime;
|
|
const date = new Date(unixTime * 1000);
|
|
const germanDateTime = date.toLocaleString('de-DE', {
|
|
day: '2-digit',
|
|
month: '2-digit',
|
|
year: 'numeric',
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
second: '2-digit',
|
|
});
|
|
let typeText;
|
|
if (obj.customer_info_type == 1) {
|
|
typeText = 'E-Mail';
|
|
} else if (obj.customer_info_type == 2) {
|
|
typeText = 'SMS';
|
|
}
|
|
let customer_info_text = "";
|
|
if (obj.customer_info_text) {
|
|
customer_info_text = obj.customer_info_text.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1<br />$2');
|
|
}
|
|
let title = `<div class="text-center font-weight-500">Letzte gesendete Info (` + typeText + `):</div>
|
|
<div class="text-left">` + customer_info_text + `</div>
|
|
<div class="text-left"><span class="font-weight-500">gesendet an:</span> ` + obj.customer_info_type_text + `</div>
|
|
<div class="text-left"><span class="font-weight-500">gesendet von:</span> ` + obj.sendby + `</div>
|
|
<div class="text-left"><span class="font-weight-500">gesendet am:</span> ` + germanDateTime + `</div>
|
|
|
|
`;
|
|
let tooltip = new Tooltip($('.customer-info-point'), {
|
|
title: title,
|
|
placement: 'right',
|
|
trigger: 'hover',
|
|
container: 'body',
|
|
html: true
|
|
});
|
|
}
|
|
}
|
|
else if (data.data.type.type == "7")
|
|
{
|
|
$('.ticket-div').hide();
|
|
$('.customer-div').show();
|
|
if (data.data.customer.customer) {
|
|
$('#customer').html('<option>' + data.data.customer.customer + '</option>');
|
|
} else {
|
|
$('#customer').html('<option></option>');
|
|
}
|
|
if (data.data.customer_info_reminder.customer_info_reminder) {
|
|
if (data.data.customer_info_reminder.customer_info_reminder == 1) {
|
|
$('#customer-info-reminder-check').prop('checked', true);
|
|
} else {
|
|
$('#customer-info-reminder-check').prop('checked', false);
|
|
}
|
|
}
|
|
$('#customer').select2({
|
|
placeholder: "Kunden Suche",
|
|
minimumInputLength: 3,
|
|
dropdownParent: jQuery('#relContainer2'),
|
|
// dropdownParent: $('#EventModal'),
|
|
language: "de",
|
|
ajax: {
|
|
url: requestAddressSbidiUrl,
|
|
dataType: 'json',
|
|
delay: 250,
|
|
processResults: function (data) {
|
|
// Transforms the top-level key of the response object from 'items' to 'results'
|
|
return {
|
|
results: data.items
|
|
};
|
|
}
|
|
}
|
|
});
|
|
if (data.data.customer_info.customer_info) {
|
|
const obj = JSON.parse(data.data.customer_info.customer_info);
|
|
$('#customer-info-text').val(obj.customer_info_text);
|
|
$('#customer-info-type').val(obj.customer_info_type);
|
|
$('#customer-info-type-text').val(obj.customer_info_type_text);
|
|
}
|
|
if (data.data.customer_info_send.customer_info_send) {
|
|
const obj = JSON.parse(data.data.customer_info_send.customer_info_send);
|
|
$('#customer-info-check-info').html('<i class="fa-sharp-duotone fa-solid fa-circle-info customer-info-point"></i>');
|
|
const unixTime = obj.sendtime;
|
|
const date = new Date(unixTime * 1000);
|
|
const germanDateTime = date.toLocaleString('de-DE', {
|
|
day: '2-digit',
|
|
month: '2-digit',
|
|
year: 'numeric',
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
second: '2-digit',
|
|
});
|
|
let typeText;
|
|
if (obj.customer_info_type == 1) {
|
|
typeText = 'E-Mail';
|
|
} else if (obj.customer_info_type == 2) {
|
|
typeText = 'SMS';
|
|
}
|
|
let customer_info_text = "";
|
|
if (obj.customer_info_text) {
|
|
customer_info_text = obj.customer_info_text.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1<br />$2');
|
|
}
|
|
let title = `<div class="text-center font-weight-500">Letzte gesendete Info (` + typeText + `):</div>
|
|
<div class="text-left">` + customer_info_text + `</div>
|
|
<div class="text-left"><span class="font-weight-500">gesendet an:</span> ` + obj.customer_info_type_text + `</div>
|
|
<div class="text-left"><span class="font-weight-500">gesendet von:</span> ` + obj.sendby + `</div>
|
|
<div class="text-left"><span class="font-weight-500">gesendet am:</span> ` + germanDateTime + `</div>
|
|
|
|
`;
|
|
let tooltip = new Tooltip($('.customer-info-point'), {
|
|
title: title,
|
|
placement: 'right',
|
|
trigger: 'hover',
|
|
container: 'body',
|
|
html: true
|
|
});
|
|
}
|
|
}
|
|
else if (data.data.type.type == "5") {
|
|
$('.ticket-div').show();
|
|
$('.customer-div').hide();
|
|
if (data.data.customer.customer) {
|
|
$('#customer').html('<option>' + data.data.customer.customer + '</option>');
|
|
} else {
|
|
$('#customer').html('<option></option>');
|
|
}
|
|
$('#ticket').select2({
|
|
placeholder: "Ticket",
|
|
minimumInputLength: 3,
|
|
dropdownParent: jQuery('#relContainer3'),
|
|
// dropdownParent: $('#EventModal'),
|
|
language: "de",
|
|
ajax: {
|
|
url: requestTicketUrl,
|
|
dataType: 'json',
|
|
delay: 250,
|
|
processResults: function (data) {
|
|
// Transforms the top-level key of the response object from 'items' to 'results'
|
|
return {
|
|
results: data.items
|
|
};
|
|
}
|
|
}
|
|
})
|
|
}
|
|
if (isOrganizer == "1") {
|
|
$('.event-organizer-div').hide();
|
|
$('.show-update').show();
|
|
$('.show-attendee').hide();
|
|
} else {
|
|
const organizer = JSON.parse(data.data.organizer.organizer);
|
|
$('.event-organizer-div').show();
|
|
$('.event-organizer').text(organizer.name);
|
|
$('.accepted-status').removeClass('fa-circle-check');
|
|
$('.accepted-status').removeClass('fa-circle-info');
|
|
let accepted = data.data.accepted.accepted;
|
|
if (accepted) {
|
|
const accept = JSON.parse(accepted);
|
|
if (accept.time) {
|
|
const datetime = new Date(accept.time * 1000);
|
|
const germanDateTime = datetime.toLocaleString('de-DE');
|
|
$('.accepted-status').prop('title', accept.user + ' (' + germanDateTime + ')');
|
|
} else {
|
|
$('.accepted-status').prop('title', '');
|
|
}
|
|
|
|
$('.accepted-status').addClass('fa-circle-check');
|
|
$('.event-accepted').text('Akzeptiert');
|
|
} else {
|
|
$('.accepted-status').addClass('fa-circle-info');
|
|
$('.accepted-status').prop('title', 'Termin wurde noch nicht bestätigt');
|
|
$('.event-accepted').text('Offen');
|
|
}
|
|
$('.show-update').hide();
|
|
$('.show-attendee').show();
|
|
$('.show-attendee').data('id', info.event.id);
|
|
}
|
|
|
|
if (data.data.attendees.attendees) {
|
|
let attendees = JSON.parse(data.data.attendees.attendees);
|
|
$.each(attendees, function (index, value) {
|
|
if (!Number.isInteger(value)) {
|
|
let valueExists = $("#calendar-attendees option").filter(function () {
|
|
return $(this).val() === value;
|
|
}).length > 0;
|
|
if (!valueExists) {
|
|
$("#calendar-attendees").append(new Option(value, value, true, true))
|
|
}
|
|
}
|
|
});
|
|
|
|
$('#calendar-attendees').val(attendees).trigger('change');
|
|
}
|
|
if (info.event.extendedProps.rruleflag == true) {
|
|
$('#delete-event').hide();
|
|
$('#update-event').hide();
|
|
$('.show-attendee').hide();
|
|
$('#recurringCheck').prop('checked', true);
|
|
$('#recurringCheck').change();
|
|
if (data.data.recurrence) {
|
|
$('#rrule-frequency').val(data.data.recurrence.recurrence.rrule_frequency);
|
|
$('#rrule-frequency').trigger('change');
|
|
$('#rrule-interval').val(data.data.recurrence.recurrence.rrule_interval);
|
|
$('#rrule-byweekday').val(data.data.recurrence.recurrence.rrule_byweekday);
|
|
$('#rrule-until').val(data.data.recurrence.recurrence.rrule_until);
|
|
$('#monthly-type').val(data.data.recurrence.recurrence.monthly_type);
|
|
$('#monthly-type').trigger('change');
|
|
$('#rrule-bymonthday').val(data.data.recurrence.recurrence.rrule_bymonthday);
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
if (info.event.extendedProps.clickable) {
|
|
let cestDate = new Date(info.event.startStr);
|
|
let cestOffset = 0; // 2 Stunden in Minuten
|
|
let utcTime = cestDate.getTime() - cestOffset * 60 * 1000;
|
|
|
|
let utcDate = new Date(utcTime);
|
|
let year = utcDate.getUTCFullYear();
|
|
let month = String(utcDate.getUTCMonth() + 1).padStart(2, '0');
|
|
let day = String(utcDate.getUTCDate()).padStart(2, '0');
|
|
let hours = String(utcDate.getUTCHours()).padStart(2, '0');
|
|
let minutes = String(utcDate.getUTCMinutes()).padStart(2, '0');
|
|
let seconds = String(utcDate.getUTCSeconds()).padStart(2, '0');
|
|
|
|
let StartformattedDate = year + "-" + month + "-" + day;
|
|
let StarteformattedTime = hours + ":" + minutes;
|
|
|
|
cestDate = new Date(info.event.endStr);
|
|
cestOffset = 0; // 2 Stunden in Minuten
|
|
|
|
|
|
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');
|
|
|
|
let EndformattedDate = year + "-" + month + "-" + day;
|
|
let EndformattedTime = hours + ":" + minutes;
|
|
|
|
|
|
$('#EventModal').modal('show');
|
|
$('#start-date').val(StartformattedDate);
|
|
$('#start-time').val(StarteformattedTime);
|
|
$('#end-date').val(EndformattedDate);
|
|
$('#end-time').val(EndformattedTime);
|
|
|
|
$('#EventModal').modal('show');
|
|
if (info.event.allDay) {
|
|
$('#allday').prop('checked', true)
|
|
$('#allday').change();
|
|
|
|
$('#end-time').val('');
|
|
$('#end-date').val(EndformattedDate);
|
|
$('#start-time').val('');
|
|
} else {
|
|
$('#end-date').val(EndformattedDate);
|
|
$('#allday').prop('checked', false);
|
|
$('#end-time').val(EndformattedTime);
|
|
$('#start-time').val(StarteformattedTime);
|
|
}
|
|
|
|
|
|
$('#name').val(info.event.title);
|
|
$('#location').val(info.event.extendedProps.location);
|
|
// $('#description').val(info.event.extendedProps.description);
|
|
$('#delete-event').data('id', info.event.id);
|
|
$('#update-event').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').addClass('fa-calendar-lines-pen');
|
|
$('#add-event').hide();
|
|
// $('#calendar-users').select2('destroy');
|
|
// $('#calendar-users').select2();
|
|
$('#calendar-users').val(info.event.extendedProps.calendar_id.calendar_id).trigger('change');
|
|
$('#calendar-users').select2("enable", false)
|
|
}
|
|
},
|
|
eventDidMount: function (info) {
|
|
let eventstart = new Date(info.event.startStr);
|
|
let eventend = new Date(info.event.endStr);
|
|
|
|
let title;
|
|
if (!info.event.allDay) {
|
|
eventstart = String(eventstart.getUTCHours()).padStart(2, '0') + ':' + String(eventstart.getUTCMinutes()).padStart(2, '0');
|
|
eventend = String(eventend.getUTCHours()).padStart(2, '0') + ':' + String(eventend.getUTCMinutes()).padStart(2, '0');
|
|
title = '<div class="tooltip-description text-center">von ' + eventstart + ' bis ' + eventend + '</div>';
|
|
} else {
|
|
eventstart = String(eventstart.getUTCDate()).padStart(2, '0') + '.' + String(eventstart.getUTCMonth() + 1).padStart(2, '0') + '.' + eventstart.getUTCFullYear();
|
|
eventend = String(eventend.getUTCDate()).padStart(2, '0') + '.' + String(eventend.getUTCMonth() + 1).padStart(2, '0') + '.' + eventend.getUTCFullYear();
|
|
if (eventend == "NaN.NaN.NaN") {
|
|
eventend = eventstart;
|
|
}
|
|
title = '<div class="tooltip-description text-center">Ganztägig von ' + eventstart + ' bis ' + eventend + ' </div>';
|
|
}
|
|
|
|
|
|
title += info.event.title;
|
|
if (info.event.extendedProps['description']) {
|
|
title += '<div class="tooltip-description text-left">' + info.event.extendedProps['description'] + '</div>';
|
|
}
|
|
if (info.event.extendedProps['location']) {
|
|
title += '<div class="text-left tooltip-location">@ ' + info.event.extendedProps['location'] + '</div>';
|
|
}
|
|
if (info.event.extendedProps['attachment'] == 1) {
|
|
const obj = JSON.parse(info.event.extendedProps['attachments']);
|
|
let docs = "";
|
|
$.each(obj, function (index, value) {
|
|
let filename;
|
|
if (fileTypeClasses[value.contentType]) {
|
|
filename = fileTypeClasses[value.contentType];
|
|
} else {
|
|
filename = 'fa-file';
|
|
}
|
|
docs += `<div class="doc-main-div font-13"><div class="d-inline-block doc-icon-div"><i class="fa-duotone fa-solid ` + filename + ` font-15"></i></div><div class="d-inline-block doc-content-tooltip-div"><a href="` + requestEventAttachmentUrl + `&id=` + value.id + `" target="_blank" >` + value.name + `</a></div><span class="float-right d-inline-block ml-1 font-12">` + formatFileSize(value.size) + `</span></div>`;
|
|
});
|
|
title += '<div class="text-left tooltip-attachments font-13">' + docs + '</div>';
|
|
}
|
|
if (info.event.extendedProps['ctime']) {
|
|
title += '<div class="text-left font-13"><span class="font-weight-500">Kalender: </span>' + info.event.extendedProps['calendar_name'] + '</div>';
|
|
title += '<div class="text-left font-13"><span class="font-weight-500">erstellt am </span>' + info.event.extendedProps['ctime'] + '</div>';
|
|
title += '<div class="text-left font-13"><span class="font-weight-500">erstellt von </span>' + info.event.extendedProps['cname'] + '</div>';
|
|
title += '<div class="text-left font-13"><span class="font-weight-500">geändert am </span> ' + info.event.extendedProps['mtime'] + '</div>';
|
|
title += '<div class="text-left font-13"><span class="font-weight-500">geändert von </span> ' + info.event.extendedProps['mname'] + '</div>';
|
|
}
|
|
if ($('.fc-button-active').hasClass('fc-timeGridWeek-button') || $('.fc-button-active').hasClass('fc-timeGridDay-button')) {
|
|
|
|
if (info.event.extendedProps['event_type'] == '2') {
|
|
|
|
// info.el.querySelector(".fc-event-title").insertAdjacentHTML("afterend", "<div class=\"fc-event-type\"><i class=\"fa-light fa-user-helmet-safety\"></i></div>");
|
|
info.el.querySelector(".fc-event-title").insertAdjacentHTML("afterend", "<div class=\"fc-event-type\"><img style='height: 13px;vertical-align: top;' src='/img/xinon-logo.png'></div>");
|
|
}
|
|
if (info.event.extendedProps['event_type'] == '3') {
|
|
|
|
// info.el.querySelector(".fc-event-title").insertAdjacentHTML("afterend", "<div class=\"fc-event-type\"><i class=\"fa-light fa-user-helmet-safety\"></i></div>");
|
|
info.el.querySelector(".fc-event-title").insertAdjacentHTML("afterend", "<div class=\"fc-event-type\"><img style='height: 13px;vertical-align: top;' src='/img/estmk_logo.png'></div>");
|
|
}
|
|
if (info.event.extendedProps['event_type'] == '7') {
|
|
|
|
// info.el.querySelector(".fc-event-title").insertAdjacentHTML("afterend", "<div class=\"fc-event-type\"><i class=\"fa-light fa-user-helmet-safety\"></i></div>");
|
|
info.el.querySelector(".fc-event-title").insertAdjacentHTML("afterend", "<div class=\"fc-event-type\"><img style='height: 15px;vertical-align: top;margin-top:-1px' src='/img/sbidi-logo.png'></div>");
|
|
}
|
|
if (info.event.extendedProps['event_type'] == '4') {
|
|
|
|
// info.el.querySelector(".fc-event-title").insertAdjacentHTML("afterend", "<div class=\"fc-event-type\"><i class=\"fa-light fa-user-helmet-safety\"></i></div>");
|
|
info.el.querySelector(".fc-event-title").insertAdjacentHTML("afterend", "<div class=\"fc-event-type\"><img style='height: 13px;vertical-align: top;' src='/img/snop-logo.png'></div>");
|
|
}
|
|
if (info.event.extendedProps['event_type'] == '6') {
|
|
|
|
// info.el.querySelector(".fc-event-title").insertAdjacentHTML("afterend", "<div class=\"fc-event-type\"><i class=\"fa-light fa-user-helmet-safety\"></i></div>");
|
|
info.el.querySelector(".fc-event-title").insertAdjacentHTML("afterend", "<div class=\"fc-event-type\"><i class=\"fa-duotone fa-solid fa-phone-volume fa-calendar-call\"></i></div>");
|
|
}
|
|
if (info.event.extendedProps['event_type'] == '5') {
|
|
|
|
// info.el.querySelector(".fc-event-title").insertAdjacentHTML("afterend", "<div class=\"fc-event-type\"><i class=\"fa-light fa-user-helmet-safety\"></i></div>");
|
|
info.el.querySelector(".fc-event-title").insertAdjacentHTML("afterend", "<div class=\"fc-event-type\"><i class=\"fa-duotone fa-solid fa-triangle-exclamation fa-calendar-alert\"></i></div>");
|
|
}
|
|
if (info.event.extendedProps['privateflag'] == 1) {
|
|
info.el.querySelector(".fc-event-title").insertAdjacentHTML("afterend", "<div class=\"fc-event-private\"><i class=\"fa-regular fa-event-lock fa-lock\"></i></div>");
|
|
}
|
|
if (info.event.extendedProps['attachment'] && info.event.extendedProps['privateflag'] == 1) {
|
|
info.el.querySelector(".fc-event-title").insertAdjacentHTML("afterend", "<div class=\"fc-event-attachment-mr\"><i class=\"fa-light fa-paperclip-vertical\"></i></div>");
|
|
} else if (info.event.extendedProps['attachment']) {
|
|
info.el.querySelector(".fc-event-title").insertAdjacentHTML("afterend", "<div class=\"fc-event-attachment\"><i class=\"fa-light fa-paperclip-vertical\"></i></div>");
|
|
}
|
|
if (info.event.extendedProps['rruleflag']) {
|
|
info.el.querySelector(".fc-event-title").insertAdjacentHTML("afterend", "<div class=\"fc-event-recurrence\"><i class=\"fa-regular fa-arrows-rotate\"></i></div>");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
let tooltip = new Tooltip(info.el, {
|
|
title: title,
|
|
placement: 'right',
|
|
delay: {hide: 50},
|
|
trigger: 'hover',
|
|
container: 'body',
|
|
html: true,
|
|
});
|
|
|
|
let tooltips = info.event.extendedProps['tooltips'] || [];
|
|
tooltips.push(tooltip);
|
|
info.event.setExtendedProp('tooltips', tooltips);
|
|
},
|
|
|
|
eventWillUnmount: function (info) {
|
|
for (let tooltip of info.event.extendedProps['tooltips']) {
|
|
tooltip.dispose();
|
|
}
|
|
},
|
|
eventResize: function (info) {
|
|
info.event.remove();
|
|
let start = info.event.start.getTime();
|
|
// const offsetstart = getOffset(start);
|
|
const offsetstart = 0;
|
|
start = (start / 1000 + offsetstart) * 1000;
|
|
let end = info.event.end.getTime();
|
|
// const offsetend = getOffset(end);
|
|
const offsetend = 0;
|
|
end = (end / 1000 + offsetend) * 1000;
|
|
let id = info.event.id;
|
|
$.post(requestUpdateUrl, {
|
|
start: start,
|
|
end: end,
|
|
id: id
|
|
}, function (data) {
|
|
|
|
}).done(function (data) {
|
|
let tooltip = new Tooltip(info.el, {
|
|
title: info.event.extendedProps.description,
|
|
placement: 'right',
|
|
trigger: 'hover',
|
|
container: 'body'
|
|
});
|
|
|
|
let tooltips = info.event.extendedProps['tooltips'] || [];
|
|
tooltips.push(tooltip);
|
|
info.event.setExtendedProp('tooltips', tooltips);
|
|
});
|
|
},
|
|
eventDrop: function (info) {
|
|
info.event.remove();
|
|
let start = info.event.start.getTime();
|
|
// const offsetstart = getOffset(start);
|
|
const offsetstart = 0;
|
|
start = (start / 1000 + offsetstart) * 1000;
|
|
let end = info.event.end.getTime();
|
|
// const offsetend = getOffset(end);
|
|
const offsetend = 0;
|
|
end = (end / 1000 + offsetend) * 1000;
|
|
let id = info.event.id;
|
|
$.post(requestUpdateUrl, {
|
|
start: start,
|
|
end: end,
|
|
id: id
|
|
}, function (data) {
|
|
|
|
}).done(function (data) {
|
|
});
|
|
// });
|
|
},
|
|
eventClassNames: function (info) {
|
|
|
|
let result = '';
|
|
|
|
if (typeof info.event.extendedProps.calendar_id === 'undefined') {
|
|
return '';
|
|
}
|
|
let checkbox = $(".form-check-input");
|
|
checkbox.each(function () {
|
|
if ($(this).prop('checked')) {
|
|
if (Number(info.event.extendedProps.calendar_id.calendar_id) === $(this).data('calendar_id')) {
|
|
|
|
}
|
|
} else {
|
|
if (Number(info.event.extendedProps.calendar_id.calendar_id) === $(this).data('calendar_id')) {
|
|
result = "";
|
|
}
|
|
}
|
|
});
|
|
if (info.event.extendedProps.busy == '0') {
|
|
result += ' event-free';
|
|
} else if (info.event.extendedProps.busy == '1') {
|
|
result += ' event-busy';
|
|
} else if (info.event.extendedProps.busy == '2') {
|
|
result += ' event-tentative';
|
|
}
|
|
|
|
|
|
return result;
|
|
},
|
|
datesSet: function (dateInfo) {
|
|
$('.event-search-result').removeClass('event-search-result');
|
|
$('#jumpevent').val(null).trigger('change');
|
|
;
|
|
// $('#jumpevent').change();
|
|
},
|
|
editable: true,
|
|
droppable: true, // this allows things to be dropped onto the calendar
|
|
fixedWeekCount: true,
|
|
// height: 300,
|
|
initialView: 'timeGridWeek',
|
|
timeZone: 'UTC',
|
|
hiddenDays: [],
|
|
navLinks: 'true',
|
|
events: [],
|
|
height: 800,
|
|
eventSources: eventSources,
|
|
resourceOrder: 'order',
|
|
resources: resources,
|
|
});
|
|
calendar.render();
|
|
|
|
} else {
|
|
$('#calendar').closest('.row').html('<div class="col-12"><h3 class="alert alert-danger text-center">' + json.errormessage + '</h3></div>');
|
|
}
|
|
}
|
|
)
|
|
;
|
|
});
|
|
|
|
|
|
if (typeof (EventSource) !== 'undefined') {
|
|
console.info('Starting connection...');
|
|
|
|
let source = new EventSourcePolyfill(requestUpdateEventsUrl, {
|
|
// Specifying custom request headers
|
|
headers: {
|
|
'X-API-KEY': 'wcdqEHXcXl5f1sZTEHKPTutqpFBbRf55'
|
|
},
|
|
heartbeatTimeout: 6000000
|
|
});
|
|
source.addEventListener('open', function (e) {
|
|
console.info('Connection was opened.');
|
|
}, false);
|
|
let jsondata;
|
|
source.addEventListener('error', function (e) {
|
|
let txt;
|
|
switch (Event.target.readyState) {
|
|
// if reconnecting
|
|
case EventSource.CONNECTING:
|
|
txt = 'Reconnecting...';
|
|
break;
|
|
// if error was fatal
|
|
case EventSource.CLOSED:
|
|
txt = 'Connection failed. Will not retry.';
|
|
break;
|
|
}
|
|
console.error('Connection error: ' + txt);
|
|
}, false);
|
|
|
|
source.addEventListener('message', function (e) {
|
|
// document.getElementById('result').innerHTML += e.data + '<br>';
|
|
let checkbox = $(".form-check-input");
|
|
let calendarFilter = $('.btn-light-search');
|
|
let visibleCalendars = [];
|
|
let visibleCalendarTypes = [];
|
|
let mycalendar_id = $('#calendar-id').data('calendarid');
|
|
visibleCalendars.push(0);
|
|
checkbox.each(function () {
|
|
if ($(this).prop('checked')) {
|
|
visibleCalendars.push(parseInt($(this).data('calendar_id')));
|
|
}
|
|
});
|
|
calendarFilter.each(function () {
|
|
if (!$(this).hasClass('top-search-filter')) {
|
|
visibleCalendarTypes.push(parseInt($(this).data('ctype')));
|
|
}
|
|
});
|
|
jsondata = JSON.parse(e.data);
|
|
|
|
jsondata.forEach(function (event) {
|
|
if (!visibleCalendars.includes(parseInt(event.calendar_id))) {
|
|
return;
|
|
}
|
|
if (visibleCalendarTypes.length > 0 && !visibleCalendarTypes.includes(parseInt(event.event_type))) {
|
|
return;
|
|
}
|
|
|
|
let cevent = calendar.getEventById(event.cal_events_id);
|
|
let rights = false;
|
|
let movable = false;
|
|
let rrule = null;
|
|
let duration = null;
|
|
let rruleflag = false;
|
|
let cursorclass = '';
|
|
if (event.rrule) {
|
|
$('.calendar-check').eq(0).trigger('change');
|
|
rrule = event.rrule;
|
|
duration = event.duration;
|
|
rruleflag = true;
|
|
return;
|
|
}
|
|
if (event.calendar_id in calendarRights) {
|
|
if (calendarRights[event.calendar_id] == 'all') {
|
|
rights = true;
|
|
} else {
|
|
rights = false;
|
|
}
|
|
if (event.isorganizer == '1' && rights) {
|
|
movable = true;
|
|
} else if (rights) {
|
|
cursorclass = "cursor-alias"
|
|
movable = false;
|
|
} else {
|
|
movable = false;
|
|
}
|
|
if (event.privateflag == '1' && mycalendar_id != event.calendar_id_check.calendar_id) {
|
|
rights = false;
|
|
movable = false;
|
|
|
|
}
|
|
|
|
}
|
|
if (event.change_type == '2' && cevent) {
|
|
if (cevent) {
|
|
if (event.calendar_id == event.calendar_id) {
|
|
// console.log(jsondata);
|
|
cevent.remove();
|
|
calendar.addEvent({
|
|
id: event.cal_events_id,
|
|
title: event.name,
|
|
start: event.start_time,
|
|
end: event.end_time,
|
|
description: event.description,
|
|
calendar_id: event.calendar_id_check,
|
|
textColor: event.txtColor,
|
|
backgroundColor: event.bgColor,
|
|
location: event.location,
|
|
event_type: event.event_type,
|
|
classNames: ['cal-class-group-' + event.calendar_id, 'cal-class-id-' + event.cal_events_id, cursorclass],
|
|
attachment: event.attachment,
|
|
attachments: event.attachments,
|
|
editable: movable,
|
|
privateflag: event.privateflag,
|
|
rruleflag: rruleflag,
|
|
rrule: rrule,
|
|
duration: duration,
|
|
resourceId: event.calendar_id,
|
|
calendar_name: event.calendar_name,
|
|
clickable: rights,
|
|
mtime: event.mtime,
|
|
mname: event.mname,
|
|
ctime: event.ctime,
|
|
cname: event.cname,
|
|
busy: event.busy
|
|
});
|
|
// cevent.setProp('title', event.name);
|
|
// console.log(event.start_time);
|
|
// console.log(event.end_time);
|
|
// console.log(event.name);
|
|
// cevent.setDates(event.start_time, event.end_time);
|
|
//
|
|
// // Farben und Klassennamen
|
|
// cevent.setProp('backgroundColor', event.bgColor);
|
|
// cevent.setProp('textColor', event.txtColor);
|
|
// cevent.setProp('classNames', [
|
|
// 'cal-class-group-' + event.calendar_id,
|
|
// 'cal-class-id-' + event.cal_events_id,
|
|
// cursorclass
|
|
// ]);
|
|
// cevent.setExtendedProp('description', event.description);
|
|
// cevent.setExtendedProp('calendar_id', event.calendar_id_check);
|
|
// cevent.setExtendedProp('location', event.location);
|
|
// cevent.setExtendedProp('event_type', event.event_type);
|
|
// cevent.setExtendedProp('attachment', event.attachment);
|
|
// cevent.setExtendedProp('attachments', event.attachments);
|
|
// cevent.setExtendedProp('privateflag', event.privateflag);
|
|
// cevent.setExtendedProp('rruleflag', event.rruleflag);
|
|
// cevent.setExtendedProp('rrule', event.rrule);
|
|
// cevent.setExtendedProp('duration', event.duration);
|
|
// cevent.setExtendedProp('resourceId', event.calendar_id);
|
|
// cevent.setExtendedProp('calendar_name', event.calendar_name);
|
|
// cevent.setExtendedProp('clickable', event.rights);
|
|
// cevent.setExtendedProp('mtime', event.mtime);
|
|
// cevent.setExtendedProp('mname', event.mname);
|
|
// cevent.setExtendedProp('ctime', event.ctime);
|
|
// cevent.setExtendedProp('cname', event.cname);
|
|
// cevent.setExtendedProp('busy', event.busy);
|
|
// cevent.setProp('editable', movable);
|
|
|
|
} else {
|
|
cevent.remove();
|
|
calendar.addEvent({
|
|
id: event.cal_events_id,
|
|
title: event.name,
|
|
start: event.start_time,
|
|
end: event.end_time,
|
|
description: event.description,
|
|
calendar_id: event.calendar_id_check,
|
|
color: '#ab0000',
|
|
editable: false,
|
|
location: event.location,
|
|
event_type: event.event_type,
|
|
classNames: ['cal-class-group-' + event.calendar_id, 'cal-class-id-' + event.cal_events_id, cursorclass],
|
|
attachment: event.attachment,
|
|
attachments: event.attachments,
|
|
calendar_id: event.calendar_id_check,
|
|
resourceId: event.calendar_id,
|
|
privateflag: event.privateflag,
|
|
calendar_name: event.calendar_name,
|
|
clickable: rights,
|
|
mtime: event.mtime,
|
|
mname: event.mname,
|
|
ctime: event.ctime,
|
|
cname: event.cname,
|
|
busy: event.busy
|
|
});
|
|
}
|
|
calendar.render();
|
|
}
|
|
|
|
} else if (event.change_type == '1' || !cevent) {
|
|
if (event.calendar_id == event.calendar_id) {
|
|
let info = calendar.addEvent({
|
|
id: event.cal_events_id,
|
|
title: event.name,
|
|
start: event.start_time,
|
|
end: event.end_time,
|
|
description: event.description,
|
|
calendar_id: event.calendar_id_check,
|
|
textColor: event.txtColor,
|
|
backgroundColor: event.bgColor,
|
|
location: event.location,
|
|
privateflag: event.privateflag,
|
|
event_type: event.event_type,
|
|
classNames: ['cal-class-group-' + event.calendar_id, 'cal-class-id-' + event.cal_events_id, cursorclass],
|
|
attachment: event.attachment,
|
|
attachments: event.attachments,
|
|
editable: movable,
|
|
resourceId: event.calendar_id,
|
|
calendar_name: event.calendar_name,
|
|
clickable: rights,
|
|
mtime: event.mtime,
|
|
mname: event.mname,
|
|
ctime: event.ctime,
|
|
cname: event.cname,
|
|
busy: event.busy
|
|
});
|
|
|
|
} else {
|
|
let info = calendar.addEvent({
|
|
id: event.cal_events_id,
|
|
title: event.name,
|
|
start: event.start_time,
|
|
end: event.end_time,
|
|
description: event.description,
|
|
calendar_id: event.calendar_id_check,
|
|
color: '#ab0000',
|
|
editable: false,
|
|
location: event.location,
|
|
privateflag: event.privateflag,
|
|
event_type: event.event_type,
|
|
classNames: ['cal-class-group-' + event.calendar_id, 'cal-class-id-' + event.cal_events_id, cursorclass],
|
|
attachment: event.attachment,
|
|
attachments: event.attachments,
|
|
calendar_id: event.calendar_id_check,
|
|
resourceId: event.calendar_id,
|
|
calendar_name: event.calendar_name,
|
|
clickable: rights,
|
|
mtime: event.mtime,
|
|
mname: event.mname,
|
|
ctime: event.ctime,
|
|
cname: event.cname,
|
|
busy: event.busy
|
|
});
|
|
}
|
|
calendar.render();
|
|
} else if (event.change_type == '3') {
|
|
let cevent = calendar.getEventById(event.cal_events_id);
|
|
cevent.remove();
|
|
}
|
|
|
|
});
|
|
}, false);
|
|
} else {
|
|
alert('Your browser does not support Server-sent events! Please upgrade it!');
|
|
console.error('Connection aborted');
|
|
}
|
|
$(document).ready(function () {
|
|
let eventdialog = $('#EventModal').html();
|
|
$('body').on('click', '.fa-window-maximize', function () {
|
|
$('.card').addClass('card-fullscreen');
|
|
$('#card-size').removeClass('fa-window-maximize').addClass('fa-window-restore');
|
|
calendar.render();
|
|
});
|
|
|
|
$(document).on('show.bs.dropdown', '.dropdown', function () {
|
|
let previewMenue = '';
|
|
$.getJSON(requestgetpreviewtUrl, {
|
|
event_type: $('#type').val()
|
|
}, function (data) {
|
|
|
|
}).done(function (data) {
|
|
;
|
|
|
|
let counter = 1;
|
|
$.each(data.data, function (index, item) {
|
|
previewMenue += '<li><a class="dropdown-item text-template" data-text="' + item.data.text + '">' + item.data.name + '</a></li>';
|
|
counter++;
|
|
});
|
|
$('.dropdown-menu').html(previewMenue);
|
|
});
|
|
});
|
|
|
|
$('body').on('click', '.fa-window-restore', function () {
|
|
$('.card').removeClass('card-fullscreen');
|
|
$('#card-size').removeClass('fa-window-restore').addClass('fa-window-maximize');
|
|
calendar.render();
|
|
});
|
|
|
|
$(document).keyup(function (e) {
|
|
if (e.key === "Escape") { // escape key maps to keycode `27`
|
|
if ($('.card').hasClass('card-fullscreen')) {
|
|
$('.card').removeClass('card-fullscreen');
|
|
$('#card-size').removeClass('fa-window-restore').addClass('fa-window-maximize');
|
|
}
|
|
$('.cal-group-name-input').each(function (index, value) {
|
|
$(this).closest('div').find('.dropdown-group-div').show();
|
|
$(this).closest('div').find('.move-group-div').show();
|
|
$(this).closest('div').find('.group-checkbox-div').show();
|
|
$(this).closest('.cal-group-name').text($(this).data('oldname'));
|
|
|
|
});
|
|
|
|
}
|
|
});
|
|
$('#myModal').on('shown.bs.modal', function () {
|
|
$(document).off('focusin.modal');
|
|
});
|
|
|
|
// Sobald der Link-Dialog geschlossen wird, fügen wir die "modal-open"-Klasse wieder hinzu, falls noch ein Modal offen ist.
|
|
$('#EventModal').on('hidden.bs.modal', function (event) {
|
|
tinymce.activeEditor.setContent('');
|
|
});
|
|
|
|
|
|
$('#EventModal').on('show.bs.modal', function (event) {
|
|
$(document).off('focusin.modal');
|
|
$('.attachment-div').empty();
|
|
$('#reminder').val('NULL');
|
|
$('#type').val('1');
|
|
$('.privacy-click').removeClass('fa-lock');
|
|
$('.privacy-click').removeClass('fa-unlock');
|
|
$('.privacy-click').addClass('fa-unlock');
|
|
$('#customer-info-check-info').empty();
|
|
$('#customer-info-type').val('1');
|
|
$('#customer').val('');
|
|
$('#ticket').val('');
|
|
$('.event-organizer-div').hide();
|
|
$('#calendar-attendees').val('').trigger('change');
|
|
$('.customer-div').hide();
|
|
$('.ticket-div').hide();
|
|
$('.calendar-users-all').hide();
|
|
$('#EventModalLabel span').text('Termin erstellen');
|
|
$('#EventModalLabel .fa-calendar-symbol').addClass('fa-calendar-circle-plus');
|
|
$('#EventModalLabel .fa-calendar-symbol').removeClass('fa-calendar-lines-pen');
|
|
$('#EventModalLabel').data('id', '');
|
|
$('.show-attendee').data('id', '');
|
|
$('.eventmodal-input').val('');
|
|
$('.eventmodal-input').prop('disabled', false);
|
|
$('.eventmodal-checkbox').prop('checked', false);
|
|
$('#EventModal .is-require').each(function (index, value) {
|
|
$(this).removeClass('required');
|
|
});
|
|
$('#recurring-settings').hide();
|
|
$('#weekly-options').hide();
|
|
$('#monthly-type').val('BYMONTHDAY');
|
|
$('#rrule-frequency').val('');
|
|
$('#rrule-count').val('');
|
|
$('#rrule-until').val('');
|
|
$('#rrule-byweekday').val('');
|
|
$('#rrule-bymonthday').val('1');
|
|
$('#monthly-options').hide();
|
|
// $('.select2-multiple').select2();
|
|
$('#calendar-users').prop("disabled", false);
|
|
$("#calendar-users option").each(function () {
|
|
if ($(this).data('mainuser') == "1") {
|
|
$(this).prop('selected', true).trigger('change');
|
|
}
|
|
});
|
|
$('#type').val('1');
|
|
$('#busy').val('1');
|
|
$('#files-input').val('');
|
|
$('#start-time').addClass('is-require');
|
|
$('#end-time').addClass('is-require');
|
|
$('.show-update').hide();
|
|
$('.show-attendee').hide();
|
|
$('#add-event').show();
|
|
$('#attachments').data('newkey', Math.floor(Math.random() * 10000));
|
|
});
|
|
tinymce.init({
|
|
//font_formats: "Arial=arial,sans-serif;",
|
|
selector: '#description',
|
|
dialog_container: '#EventModal',
|
|
language: 'de',
|
|
branding: false,
|
|
height: 250,
|
|
menubar: false,
|
|
forced_root_block_attrs: {
|
|
style: 'margin:0;'
|
|
},
|
|
skin: "tinymce-5",
|
|
plugins: ' code link autolink lists table',
|
|
paste_block_drop: true,
|
|
paste_as_text: true,
|
|
paste_data_images: false,
|
|
promotion: false,
|
|
toolbar1: 'undo redo | styles | bold italic underline strikethrough | fontfamily fontsize forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent | table | link unlink',
|
|
content_css: "/assets/css/tinymce.css",
|
|
content_style: "body { font-family: 'Calibri', sans-serif; }",
|
|
font_family_formats: "Calibri=Calibri, sans-serif;Arial=arial,sans-serif; Courier New=courier new,courier,monospace; Georgia=georgia,palatino,serif; Helvetica=helvetica,sans-serif; Lucida Sans=lucida sans unicode,sans-serif; Tahoma=tahoma,arial,helvetica,sans-serif; Times New Roman=times new roman,times,serif",
|
|
setup: function (editor) {
|
|
|
|
}
|
|
|
|
});
|
|
$('body').on('click', '#add-event', function () {
|
|
let valid = true;
|
|
|
|
$('#EventModal .is-require').each(function (index, value) {
|
|
if ($(this).val() == "") {
|
|
valid = false;
|
|
$(this).addClass('required');
|
|
} else {
|
|
$(this).removeClass('required');
|
|
}
|
|
});
|
|
|
|
if (!valid) {
|
|
return;
|
|
}
|
|
let attachments = [];
|
|
$('.doc-main-div').each(function (index, value) {
|
|
if ($(this).data('docid')) {
|
|
attachments.push($(this).data('docid'));
|
|
}
|
|
});
|
|
|
|
let start = $('#start-date').val() + ' ' + $('#start-time').val();
|
|
let end = $('#end-date').val() + ' ' + $('#end-time').val();
|
|
let title = $('#name').val();
|
|
let location = $('#location').val();
|
|
let description = tinymce.activeEditor.getContent();
|
|
let newkey = $('#attachments').data('newkey');
|
|
let allday = 0;
|
|
let reminder = $('#reminder').val();
|
|
let type = $('#type').val();
|
|
let busy = $('#busy').val();
|
|
let customer;
|
|
let customer_info_check = 0;
|
|
let customer_info_text;
|
|
let customer_info_type;
|
|
let customer_info_type_text;
|
|
let customer_info_reminder_check = 0;
|
|
let private = $('.privacy-click');
|
|
let privateflag = 0;
|
|
if (private.hasClass('fa-lock')) {
|
|
privateflag = 1;
|
|
}
|
|
let users = [];
|
|
|
|
if ($('#allday').is(':checked')) {
|
|
allday = 1;
|
|
}
|
|
if ($('#customer-info-check').is(':checked')) {
|
|
customer_info_check = 1;
|
|
}
|
|
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();
|
|
customer = $('#customer option:selected').text();
|
|
if ($('#customer-info-reminder-check').is(':checked')) {
|
|
customer_info_reminder_check = 1;
|
|
}
|
|
}
|
|
$('#calendar-users > option:selected').each(function () {
|
|
users.push($(this).val());
|
|
});
|
|
|
|
if ($('#recurringCheck').is(':checked') && $('#rrule-frequency').val() !== '') {
|
|
var rruleData = {};
|
|
rruleData.rrule_frequency = $('#rrule-frequency').val();
|
|
|
|
if (rruleData.rrule_frequency === 'WEEKLY') {
|
|
// Mehrere Wochentage als Array
|
|
rruleData['rrule-byweekday'] = $('#rrule-byweekday').val();
|
|
} else if (rruleData.rrule_frequency === 'MONTHLY') {
|
|
rruleData.monthly_type = $('#monthly-type').val();
|
|
if (rruleData.monthly_type === 'BYMONTHDAY') {
|
|
rruleData.rrule_bymonthday = $('#rrule-bymonthday').val();
|
|
} else if (rruleData.monthly_type === 'BYSETPOS') {
|
|
rruleData.rrule_setpos = $('#rrule-setpos').val();
|
|
rruleData.rrule_bynweekday = $('#rrule-bynweekday').val();
|
|
}
|
|
}
|
|
// Optionale Felder
|
|
rruleData.rrule_count = $('#rrule-count').val();
|
|
rruleData.rrule_until = $('#rrule-until').val();
|
|
}
|
|
|
|
|
|
$.post(requestInsertUrl, {
|
|
start: start,
|
|
end: end,
|
|
allday: allday,
|
|
title: title,
|
|
location: location,
|
|
reminder: reminder,
|
|
type: type,
|
|
busy: busy,
|
|
description: description,
|
|
attachments: attachments,
|
|
users: users,
|
|
privateflag: privateflag,
|
|
rruleData: rruleData,
|
|
attendees: $('#calendar-attendees').val(),
|
|
customer: customer,
|
|
customer_info_check: customer_info_check,
|
|
customer_info_text: customer_info_text,
|
|
customer_info_type: customer_info_type,
|
|
customer_info_type_text: customer_info_type_text,
|
|
customer_info_reminder_check: customer_info_reminder_check,
|
|
newkey: newkey
|
|
}, function (data) {
|
|
|
|
}).done(function (data) {
|
|
});
|
|
$('#EventModal').modal('hide');
|
|
});
|
|
|
|
$('body').on('click', '#update-event', function () {
|
|
|
|
let valid = true;
|
|
|
|
$('#EventModal .is-require').each(function (index, value) {
|
|
if ($(this).val() == "") {
|
|
valid = false;
|
|
$(this).addClass('required');
|
|
} else {
|
|
$(this).removeClass('required');
|
|
}
|
|
});
|
|
|
|
if (!valid) {
|
|
return;
|
|
}
|
|
let attachments = [];
|
|
$('.doc-main-div').each(function (index, value) {
|
|
if ($(this).data('docid')) {
|
|
attachments.push($(this).data('docid'));
|
|
}
|
|
});
|
|
|
|
let start = $('#start-date').val() + ' ' + $('#start-time').val();
|
|
let end = $('#end-date').val() + ' ' + $('#end-time').val();
|
|
let title = $('#name').val();
|
|
let location = $('#location').val();
|
|
let description = tinymce.activeEditor.getContent();
|
|
let newkey = $('#attachments').data('newkey');
|
|
let allday = 0;
|
|
let reminder = $('#reminder').val();
|
|
let type = $('#type').val();
|
|
let busy = $('#busy').val();
|
|
let customer;
|
|
let customer_info_check = 0;
|
|
let customer_info_text;
|
|
let customer_info_type;
|
|
let customer_info_type_text;
|
|
let customer_info_reminder_check = 0;
|
|
let private = $('.privacy-click');
|
|
let privateflag = 0;
|
|
if (private.hasClass('fa-lock')) {
|
|
privateflag = 1;
|
|
}
|
|
let users = [];
|
|
|
|
if ($('#allday').is(':checked')) {
|
|
allday = 1;
|
|
}
|
|
|
|
if ($('#customer-info-check').is(':checked')) {
|
|
customer_info_check = 1;
|
|
}
|
|
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();
|
|
customer = $('#customer option:selected').text();
|
|
if ($('#customer-info-reminder-check').is(':checked')) {
|
|
customer_info_reminder_check = 1;
|
|
}
|
|
|
|
|
|
}
|
|
let id = $(this).data('id');
|
|
const cevent = calendar.getEventById(id);
|
|
cevent.remove();
|
|
$('#calendar-users > option:selected').each(function () {
|
|
users.push($(this).val());
|
|
});
|
|
|
|
$.post(requestUpdateUrl, {
|
|
id: id,
|
|
start: start,
|
|
end: end,
|
|
allday: allday,
|
|
title: title,
|
|
location: location,
|
|
reminder: reminder,
|
|
type: type,
|
|
busy: busy,
|
|
description: description,
|
|
attachments: attachments,
|
|
users: users,
|
|
privateflag: privateflag,
|
|
attendees: $('#calendar-attendees').val(),
|
|
customer: customer,
|
|
customer_info_check: customer_info_check,
|
|
customer_info_text: customer_info_text,
|
|
customer_info_type: customer_info_type,
|
|
customer_info_type_text: customer_info_type_text,
|
|
customer_info_reminder_check: customer_info_reminder_check,
|
|
newkey: newkey
|
|
}, function (data) {
|
|
|
|
}).done(function (data) {
|
|
});
|
|
$('#EventModal').modal('hide');
|
|
});
|
|
|
|
$("body").on("click", ".show-attendee", function (e) {
|
|
let eventAction = $(this).data("event-action");
|
|
let eventactionGerman;
|
|
let id = $(this).data('id');
|
|
let users = [];
|
|
$('#calendar-users > option:selected').each(function () {
|
|
users.push($(this).val());
|
|
});
|
|
if (eventAction === "accept") {
|
|
eventactionGerman = "zusagen";
|
|
} else if (eventAction === "decline") {
|
|
eventactionGerman = "absagen";
|
|
}
|
|
if (confirm('Termin ' + eventactionGerman + '?')) {
|
|
$.post(requestUpdateStateUrl, {
|
|
id: id,
|
|
eventAction: eventAction,
|
|
users: users
|
|
}, function (data) {
|
|
|
|
}).done(function (data) {
|
|
});
|
|
$('#EventModal').modal('hide');
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
$('body').on('click', '#delete-event', function () {
|
|
let id = $(this).data('id');
|
|
let users = [];
|
|
$('#calendar-users > option:selected').each(function () {
|
|
users.push($(this).val());
|
|
});
|
|
|
|
|
|
if (confirm('Eintrag wirklich löschen?')) {
|
|
$.post(requestDeleteUrl, {
|
|
id: id,
|
|
users: users
|
|
}, function (data) {
|
|
|
|
}).done(function (data) {
|
|
});
|
|
$('#EventModal').modal('hide');
|
|
}
|
|
});
|
|
|
|
$('body').on('change', '#allday', function () {
|
|
if ($(this).is(':checked')) {
|
|
$('#start-time').prop('disabled', true);
|
|
$('#end-time').prop('disabled', true);
|
|
$('#start-time').removeClass('is-require');
|
|
$('#end-time').removeClass('is-require');
|
|
} else {
|
|
$('#start-time').prop('disabled', false);
|
|
$('#end-time').prop('disabled', false);
|
|
if ($('#start-time').val() == "") {
|
|
$('#start-time').val('08:00');
|
|
}
|
|
if ($('#end-time').val() == "") {
|
|
$('#end-time').val('10:00');
|
|
}
|
|
}
|
|
});
|
|
|
|
$('body').on('change', '.color-input,.color-text-input', function (event, init = 0) {
|
|
let bgcolors = [];
|
|
let txtcolors = [];
|
|
let calendar_id = [];
|
|
let thisis = $(this);
|
|
$.each($('.color-input'), function (index, value) {
|
|
if ($(this).data('calendar_id')) {
|
|
bgcolors.push($(this).closest('div').find('.color-input').val());
|
|
txtcolors.push($(this).closest('div').find('.color-text-input').val());
|
|
calendar_id.push($(this).data('calendar_id'));
|
|
} else {
|
|
}
|
|
|
|
});
|
|
|
|
|
|
let id = $('#calendar-id').data('id');
|
|
let groups = getGroups();
|
|
$.post(requestUpdateColorUrl, {
|
|
id: id,
|
|
bgcolors: bgcolors,
|
|
txtcolors: txtcolors,
|
|
calendar_id: calendar_id,
|
|
groups: groups
|
|
}, function (data) {
|
|
|
|
}).done(function (data) {
|
|
if (init === 0) {
|
|
refreshCalendarEvents();
|
|
}
|
|
})
|
|
});
|
|
|
|
|
|
$('body').on('click', '.btn-light-search', function (event, init = 0) {
|
|
if ($(this).hasClass('top-search-filter')) {
|
|
$(this).removeClass('top-search-filter');
|
|
} else {
|
|
$(this).addClass('top-search-filter');
|
|
}
|
|
refreshCalendarEvents();
|
|
});
|
|
|
|
$('body').on('change', '.calendar-check', function (event, init = 0) {
|
|
|
|
if ($(this).prop('checked')) {
|
|
refreshCalendarEvents()
|
|
} else {
|
|
refreshCalendarEvents()
|
|
}
|
|
let resources = calendar.getResources();
|
|
$.each(resources, function (index, value) {
|
|
value.remove();
|
|
});
|
|
let resourceCounter = 0;
|
|
$.each($('.calendar-check'), function (index, value) {
|
|
if ($(this).prop('checked')) {
|
|
rights = true;
|
|
calendar.addResource({
|
|
id: $(this).data('calendar_id'),
|
|
title: $.trim($(this).closest('div').find('label').text()),
|
|
order: resourceCounter
|
|
});
|
|
resourceCounter++;
|
|
}
|
|
|
|
});
|
|
$(".color-input").eq(0).trigger("change", 1);
|
|
checkGroupCheckboxes();
|
|
}
|
|
)
|
|
;
|
|
|
|
function uploadajax(ttl, cl) {
|
|
let fileList = $('#files-input').prop("files");
|
|
let form_data = "";
|
|
|
|
form_data = new FormData();
|
|
form_data.append("upload_file", fileList[cl]);
|
|
form_data.append("event_id", $('#EventModalLabel').data('id'));
|
|
form_data.append("newkey", $('#attachments').data('newkey'));
|
|
|
|
|
|
let request = $.ajax({
|
|
url: requestEventAttachmentUploadUrl,
|
|
cache: false,
|
|
contentType: false,
|
|
processData: false,
|
|
async: true,
|
|
data: form_data,
|
|
type: 'POST',
|
|
xhr: function () {
|
|
let xhr = $.ajaxSettings.xhr();
|
|
if (xhr.upload) {
|
|
xhr.upload.addEventListener('progress', function (event) {
|
|
let percent = 0;
|
|
if (event.lengthComputable) {
|
|
percent = Math.ceil(event.loaded / event.total * 100);
|
|
}
|
|
$('.pb-' + fileList[cl].size).css('width', percent + '%').attr('aria-valuenow', percent);
|
|
}, false);
|
|
}
|
|
return xhr;
|
|
},
|
|
success: function (res, status) {
|
|
if (status == 'success') {
|
|
percent = 0;
|
|
$('.pb-' + fileList[cl].size).closest('.progress').remove();
|
|
if (cl < ttl) {
|
|
uploadajax(ttl, cl + 1);
|
|
} else {
|
|
}
|
|
}
|
|
},
|
|
fail: function (res) {
|
|
alert('Failed');
|
|
}
|
|
})
|
|
}
|
|
|
|
|
|
$('body').on('change', '#files-input', function () {
|
|
let fileList = $('#files-input').prop("files");
|
|
|
|
$('#uploadsts').html('');
|
|
let i;
|
|
for (i = 0; i < fileList.length; i++) {
|
|
let newkey = $('#attachments').data('newkey');
|
|
const filetype = fileList[i].type;
|
|
const classContentType = fileTypeClasses[filetype] || 'fa-file';
|
|
// $('#uploadsts').append('<p class="upload-page">' + fileList[i].name + '<span class="loading-prep" id="prog' + i + '"></span></p>');
|
|
$('.attachment-div').append(`<div class="doc-main-div" data-name="` + fileList[i].name + `" data-newkey="` + newkey + `"><div class="d-inline-block doc-icon-div"><i class="fa-duotone fa-solid ` + classContentType + `"></i></div>
|
|
<div class="d-inline-block doc-content-div" style="margin-left: -3px;"><a href="` + requestEventAttachmentTmpUrl + `&id=` + newkey + `&name=` + fileList[i].name + `" target="_blank">` + fileList[i].name + `</a></div>
|
|
<span class="float-right"><i title="` + fileList[i].name + `" class="fas fa-trash fa-del-attachment ml-2"></i></span><span class="float-right">` + formatFileSize(fileList[i].size) + `</span></div>
|
|
<div class="progress">
|
|
<div class="progress-bar progress-bar-striped progress-bar-animated pb-` + fileList[i].size + `" role="progressbar" style="width: 0%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
|
|
</div>
|
|
`);
|
|
if (i == fileList.length - 1) {
|
|
uploadajax(fileList.length - 1, 0);
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
$('body').on('click', '.fa-del-attachment', function () {
|
|
if ($(this).closest('.doc-main-div').data('newkey') && $(this).closest('.doc-main-div').data('name')) {
|
|
let newkey = $(this).closest('.doc-main-div').data('newkey');
|
|
let name = $(this).closest('.doc-main-div').data('name');
|
|
$.post(requestEventAttachmentTmpDeleteUrl, {
|
|
newkey: newkey,
|
|
name: name
|
|
}, function (data) {
|
|
|
|
}).done(function (data) {
|
|
|
|
});
|
|
}
|
|
$(this).closest('.doc-main-div').remove();
|
|
});
|
|
$('body').on('click', '#customer', function () {
|
|
|
|
|
|
})
|
|
$('body').on('change', '#type', function () {
|
|
$('#customer').val('');
|
|
if ($(this).val() == "1") {
|
|
$('.customer-div').hide();
|
|
$('.ticket-div').hide();
|
|
} else if ($(this).val() == "2") {
|
|
$('.customer-div').show();
|
|
$('.ticket-div').hide();
|
|
$('#customer').select2({
|
|
placeholder: "Kunden Suche",
|
|
minimumInputLength: 3,
|
|
// dropdownParent: $('#EventModal'),
|
|
dropdownParent: jQuery('#relContainer2'),
|
|
language: "de",
|
|
ajax: {
|
|
url: requestAddressUrl,
|
|
dataType: 'json',
|
|
delay: 250,
|
|
data: function (params) {
|
|
return {
|
|
term: params.term,
|
|
xinon: 1,
|
|
};
|
|
},
|
|
processResults: function (data) {
|
|
// Transforms the top-level key of the response object from 'items' to 'results'
|
|
return {
|
|
results: data.items
|
|
};
|
|
}
|
|
}
|
|
});
|
|
} else if ($(this).val() == "3") {
|
|
$('.customer-div').show();
|
|
$('.ticket-div').hide();
|
|
$('#customer').select2({
|
|
placeholder: "Kunden Suche",
|
|
minimumInputLength: 3,
|
|
// dropdownParent: $('#EventModal'),
|
|
dropdownParent: jQuery('#relContainer2'),
|
|
language: "de",
|
|
ajax: {
|
|
url: requestAddressUrl,
|
|
dataType: 'json',
|
|
delay: 250,
|
|
data: function (params) {
|
|
return {
|
|
term: params.term,
|
|
xinon: 0,
|
|
};
|
|
},
|
|
|
|
processResults: function (data) {
|
|
// Transforms the top-level key of the response object from 'items' to 'results'
|
|
return {
|
|
results: data.items
|
|
};
|
|
}
|
|
}
|
|
});
|
|
} else if ($(this).val() == "4") {
|
|
$('.customer-div').show();
|
|
$('.ticket-div').hide();
|
|
$('#customer').select2({
|
|
placeholder: "Kunden Suche",
|
|
minimumInputLength: 3,
|
|
// dropdownParent: $('#EventModal'),
|
|
dropdownParent: jQuery('#relContainer2'),
|
|
language: "de",
|
|
ajax: {
|
|
url: requestAddressUrl,
|
|
dataType: 'json',
|
|
delay: 250,
|
|
data: function (params) {
|
|
return {
|
|
term: params.term,
|
|
xinon: 0,
|
|
};
|
|
},
|
|
|
|
processResults: function (data) {
|
|
// Transforms the top-level key of the response object from 'items' to 'results'
|
|
return {
|
|
results: data.items
|
|
};
|
|
}
|
|
}
|
|
});
|
|
} else if ($(this).val() == "7") {
|
|
$('.customer-div').show();
|
|
$('.ticket-div').hide();
|
|
$('#customer').select2({
|
|
placeholder: "Kunden Suche",
|
|
minimumInputLength: 3,
|
|
// dropdownParent: $('#EventModal'),
|
|
dropdownParent: jQuery('#relContainer2'),
|
|
language: "de",
|
|
ajax: {
|
|
url: requestAddressSbidiUrl,
|
|
dataType: 'json',
|
|
delay: 250,
|
|
data: function (params) {
|
|
return {
|
|
term: params.term,
|
|
xinon: 0,
|
|
};
|
|
},
|
|
|
|
processResults: function (data) {
|
|
// Transforms the top-level key of the response object from 'items' to 'results'
|
|
return {
|
|
results: data.items
|
|
};
|
|
}
|
|
}
|
|
});
|
|
}else if ($(this).val() == "6") {
|
|
$('.customer-div').show();
|
|
$('.ticket-div').hide();
|
|
$('#customer').select2({
|
|
placeholder: "Kunden Suche",
|
|
minimumInputLength: 3,
|
|
// dropdownParent: $('#EventModal'),
|
|
dropdownParent: jQuery('#relContainer2'),
|
|
language: "de",
|
|
ajax: {
|
|
url: requestAddressUrl,
|
|
dataType: 'json',
|
|
delay: 250,
|
|
data: function (params) {
|
|
return {
|
|
term: params.term,
|
|
xinon: 1,
|
|
};
|
|
},
|
|
|
|
processResults: function (data) {
|
|
// Transforms the top-level key of the response object from 'items' to 'results'
|
|
return {
|
|
results: data.items
|
|
};
|
|
}
|
|
}
|
|
});
|
|
} else if ($(this).val() == "5") {
|
|
$('.customer-div').hide();
|
|
$('.ticket-div').show();
|
|
$('#ticket').select2({
|
|
placeholder: "Ticket",
|
|
minimumInputLength: 3,
|
|
dropdownParent: jQuery('#relContainer3'),
|
|
// dropdownParent: $('#EventModal'),
|
|
language: "de",
|
|
ajax: {
|
|
url: requestTicketUrl,
|
|
dataType: 'json',
|
|
delay: 250,
|
|
processResults: function (data) {
|
|
// Transforms the top-level key of the response object from 'items' to 'results'
|
|
return {
|
|
results: data.items
|
|
};
|
|
}
|
|
}
|
|
})
|
|
}
|
|
});
|
|
|
|
|
|
$('body').on('change', '#jumpevent', function () {
|
|
$('.event-search-result').removeClass('event-search-result');
|
|
if ($(this).val() == "" || $(this).val() == null) {
|
|
return;
|
|
}
|
|
const valueArray = $(this).val().split(";");
|
|
let id = valueArray[0];
|
|
let date = valueArray[1];
|
|
calendar.gotoDate(date)
|
|
$('.cal-class-id-' + id).addClass('event-search-result');
|
|
|
|
})
|
|
|
|
$('#jumpevent').select2({
|
|
placeholder: "Termin Suche",
|
|
minimumInputLength: 3,
|
|
language: "de",
|
|
ajax: {
|
|
url: requestEventSearchURL,
|
|
data: function (params) {
|
|
let checkbox = $(".calendar-check");
|
|
let visibleCalendars = [];
|
|
visibleCalendars.push(0);
|
|
checkbox.each(function () {
|
|
if ($(this).prop('checked')) {
|
|
visibleCalendars.push($(this).data('calendar_id'));
|
|
}
|
|
});
|
|
return {
|
|
q: params.term, // Der Suchbegriff
|
|
term: params.term, // Der Suchbegriff
|
|
calendars: visibleCalendars, // Die dynamische letiable, die du hinzufügen möchtest
|
|
cal_id: $('#calendar-id').data('calendarid')
|
|
};
|
|
},
|
|
dataType: 'json',
|
|
delay: 250,
|
|
processResults: function (data) {
|
|
// Transforms the top-level key of the response object from 'items' to 'results'
|
|
return {
|
|
results: data.items
|
|
};
|
|
}
|
|
}
|
|
});
|
|
$('body').on('click', '.text-template', function () {
|
|
const date = new Date($('#start-date').val());
|
|
const formattedDate = date.toLocaleDateString('de-DE', {
|
|
day: '2-digit',
|
|
month: '2-digit',
|
|
year: 'numeric'
|
|
});
|
|
let starttime = $('#start-time').val();
|
|
let [stunden, minuten] = starttime.split(":").map(Number);
|
|
let endtime = $('#end-time').val();
|
|
let daytimetext;
|
|
if (stunden < 12) {
|
|
daytimetext = "vormittags";
|
|
} else {
|
|
daytimetext = "nachmittags";
|
|
}
|
|
let text = $(this).data('text');
|
|
text = text.replace(/\[&&vmnm&&\]/g, daytimetext);
|
|
text = text.replace(/\[&&date&&\]/g, formattedDate);
|
|
text = text.replace(/\[&&start&&\]/g, starttime);
|
|
text = text.replace(/\[&&end&&\]/g, endtime);
|
|
|
|
|
|
$('#customer-info-text').val(text);
|
|
});
|
|
|
|
|
|
$('body').on('change', '#customer,#customer-info-type', function () {
|
|
|
|
if ($('#name').val() == "") {
|
|
$('#name').val('IBN: ' + $("#customer").select2('data')[0].name);
|
|
}
|
|
if ($('#location').val() == "") {
|
|
$('#location').val($("#customer").select2('data')[0].location);
|
|
}
|
|
|
|
if ($('#customer-info-type').val() == 1) {
|
|
let data = $("#customer").select2('data')[0];
|
|
if (data) {
|
|
$('#customer-info-type-text').val(data.mail);
|
|
}
|
|
|
|
} else if ($('#customer-info-type').val() == 2) {
|
|
let data = $("#customer").select2('data')[0];
|
|
if (data) {
|
|
$('#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 + '<p style="margin-bottom: 0"><b>Service Pin: </b>' + $("#customer").select2('data')[0].spin + '</p>');
|
|
//
|
|
// $('#description').val('Service Pin: ' + $("#customer").select2('data')[0].spin + '\n');
|
|
}
|
|
|
|
|
|
});
|
|
$('body').on('change', '#ticket', function () {
|
|
|
|
if ($('#name').val() == "") {
|
|
$('#name').val('Störung: ' + $("#ticket").select2('data')[0].name);
|
|
}
|
|
if ($('#location').val() == "") {
|
|
$('#location').val($("#ticket").select2('data')[0].location);
|
|
}
|
|
var currentContent = tinymce.activeEditor.getContent();
|
|
tinymce.activeEditor.setContent(currentContent + '<p style="margin-bottom: 0"><b>Ticket Nr.: </b><a href="https://project.xinon.at/projects/storungen-and-support/work_packages/' + $("#ticket").select2('data')[0].id + '/activity" target="_blank">' + $("#ticket").select2('data')[0].id + '</a></p>\n' + $("#ticket").select2('data')[0].subject);
|
|
// $('#description').val('<a href="https://project.xinon.at/projects/storungen-and-support/work_packages/' + $("#ticket").select2('data')[0].id + '/activity" target="_blank">Ticket Nr.: ' + $("#ticket").select2('data')[0].id + '</a>\n' + $("#ticket").select2('data')[0].subject);
|
|
|
|
|
|
});
|
|
|
|
$("body").on("click", "#customer-info-check", function () {
|
|
if ($(this).prop('checked')) {
|
|
$('#customer-info-reminder-check').prop('checked', true);
|
|
}
|
|
|
|
});
|
|
$("body").on("click", ".add-cal-group-div", function () {
|
|
$('.add-cal-group-div-sub').prepend(` <div class="calendar-side-borders-sub mb-2">
|
|
<h5 ><span class="cal-group-name">Gruppe </span>
|
|
<div class="move-group-div">
|
|
<i class="fa-regular fa-arrows-up-down-left-right handle"></i>
|
|
</div>
|
|
<div class="group-checkbox-div"><input class="form-check-input group-checkbox" name="form-check-input" type="checkbox"></div>
|
|
<div class="dropdown-group-div"><i class="fa-duotone fa-solid dropdown-group fa-square-arrow-up"></i></div>
|
|
</h5> <div class="calendar-side-borders-sub-inner"></div>`);
|
|
$('.calendar-side-borders-sub-inner').sortable({
|
|
group: 'shared',
|
|
filter: 'h5',
|
|
});
|
|
});
|
|
|
|
$("body").on("dblclick", ".cal-group-name", function () {
|
|
if ($(this).find('.cal-group-name-input').length) {
|
|
return;
|
|
}
|
|
$(this).closest('div').find('.dropdown-group-div').hide();
|
|
$(this).closest('div').find('.move-group-div').hide();
|
|
$(this).closest('div').find('.group-checkbox-div').hide();
|
|
|
|
let groupname = $.trim($(this).text());
|
|
$(this).html('<input type="text" data-oldname="' + groupname + '" class="form-control cal-group-name-input" value="' + groupname + '">');
|
|
let strLength = $(this).find('.cal-group-name-input').val().length * 2;
|
|
|
|
|
|
$(this).find('.cal-group-name-input')[0].setSelectionRange(strLength, strLength);
|
|
$(this).find('.cal-group-name-input').focus();
|
|
});
|
|
|
|
$("body").on("click", ".group-checkbox", function () {
|
|
if ($(this).prop('checked')) {
|
|
$(this).closest('.calendar-side-borders-sub').find('.form-check-input').prop('checked', true);
|
|
|
|
refreshCalendarEvents()
|
|
|
|
|
|
} else {
|
|
|
|
$(this).closest('.calendar-side-borders-sub').find('.form-check-input').prop('checked', false);
|
|
refreshCalendarEvents()
|
|
}
|
|
let resources = calendar.getResources();
|
|
$.each(resources, function (index, value) {
|
|
value.remove();
|
|
});
|
|
let resourceCounter = 0;
|
|
$.each($('.calendar-check'), function (index, value) {
|
|
if ($(this).prop('checked')) {
|
|
rights = true;
|
|
calendar.addResource({
|
|
id: $(this).data('calendar_id'),
|
|
title: $.trim($(this).closest('div').find('label').text()),
|
|
order: resourceCounter
|
|
});
|
|
resourceCounter++;
|
|
}
|
|
|
|
});
|
|
$(".color-input").eq(0).trigger("change", 1);
|
|
checkGroupCheckboxes();
|
|
});
|
|
$("body").on("click", ".calendar-users-all", function () {
|
|
const resources = calendar.getResources();
|
|
let users = [];
|
|
$.each(resources, function (index, value) {
|
|
|
|
if (value.id < 900 && $('#calendar-users').val() != value.id) {
|
|
users.push(value.id);
|
|
}
|
|
});
|
|
$('#calendar-attendees').val(users).trigger('change');
|
|
|
|
});
|
|
$("body").on("click", ".dropdown-group", function () {
|
|
if ($(this).hasClass('fa-square-arrow-up')) {
|
|
$(this).removeClass('fa-square-arrow-up');
|
|
$(this).addClass('fa-square-arrow-down');
|
|
$(this).closest('.calendar-side-borders-sub').find('.calendar-side-borders-sub-inner').hide();
|
|
$(".color-input").eq(0).trigger("change", 1);
|
|
} else {
|
|
$(this).removeClass('fa-square-arrow-down');
|
|
$(this).addClass('fa-square-arrow-up');
|
|
$(this).closest('.calendar-side-borders-sub').find('.calendar-side-borders-sub-inner').show();
|
|
$(".color-input").eq(0).trigger("change", 1);
|
|
}
|
|
});
|
|
|
|
|
|
$("body").on("click", ".privacy-click", function (e) {
|
|
if ($(this).hasClass('fa-unlock')) {
|
|
$(this).removeClass('fa-unlock');
|
|
$(this).addClass('fa-lock');
|
|
$(this).prop('title', 'Privat');
|
|
} else {
|
|
$(this).removeClass('fa-lock');
|
|
$(this).addClass('fa-unlock');
|
|
$(this).prop('title', 'Normal');
|
|
}
|
|
});
|
|
|
|
$("body").on("keyup", ".cal-group-name-input", function (e) {
|
|
if (e.keyCode === 13) {
|
|
let groupname = $.trim($(this).val());
|
|
if (groupname.length > 3) {
|
|
$(this).closest('div').find('.dropdown-group-div').show();
|
|
$(this).closest('div').find('.move-group-div').show();
|
|
$(this).closest('div').find('.group-checkbox-div').show();
|
|
$(this).closest('.cal-group-name').text(groupname);
|
|
$(".color-input").eq(0).trigger("change", 1);
|
|
} else if (groupname.length == 0) {
|
|
if (confirm('Gruppe wirklich löschen?')) {
|
|
$(this).closest('.calendar-side-borders-sub').find('.form-check').each(function (index, value) {
|
|
let calendar = $(this).html();
|
|
$('.data-origin-' + $(this).data('origin')).append(`<div class="form-check text-left ml-2" data-origin="` + $(this).data('origin') + `">` + calendar + `</div>`);
|
|
});
|
|
$(this).closest('.calendar-side-borders-sub').remove();
|
|
$(".color-input").eq(0).trigger("change", 1);
|
|
}
|
|
$(this).closest('div').find('.dropdown-group-div').show();
|
|
$(this).closest('div').find('.move-group-div').show();
|
|
$(this).closest('div').find('.group-checkbox-div').show();
|
|
$(this).closest('.cal-group-name').text($(this).data('oldname'));
|
|
}
|
|
}
|
|
});
|
|
|
|
$("body").on("click", ".fa-xls-calendar", function (e) {
|
|
let checkbox = $(".calendar-check");
|
|
let calendarFilter = $('.btn-light-search');
|
|
let visibleCalendars = [];
|
|
let visibleCalendarTypes = [];
|
|
let mycalendar_id = $('#calendar-id').data('calendarid');
|
|
visibleCalendars.push(0);
|
|
checkbox.each(function () {
|
|
if ($(this).prop('checked')) {
|
|
visibleCalendars.push($(this).data('calendar_id'));
|
|
}
|
|
});
|
|
calendarFilter.each(function () {
|
|
if (!$(this).hasClass('top-search-filter')) {
|
|
visibleCalendarTypes.push($(this).data('ctype'));
|
|
}
|
|
});
|
|
|
|
|
|
$.ajax({
|
|
url: requestgenerateEventsxlsx,
|
|
method: 'POST',
|
|
data: {
|
|
visibleCalendars: visibleCalendars,
|
|
visibleCalendarTypes: visibleCalendarTypes
|
|
},
|
|
xhrFields: {
|
|
responseType: 'blob' // Erwartet binäre Daten als Blob
|
|
},
|
|
success: function (data, status, xhr) {
|
|
// Header auslesen, um den Dateinamen zu erhalten
|
|
var disposition = xhr.getResponseHeader('Content-Disposition');
|
|
var filename = "download.xlsx";
|
|
if (disposition && disposition.indexOf('attachment') !== -1) {
|
|
var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
|
|
var matches = filenameRegex.exec(disposition);
|
|
if (matches != null && matches[1]) {
|
|
filename = matches[1].replace(/['"]/g, '');
|
|
}
|
|
}
|
|
// Blob in eine URL umwandeln und Download auslösen
|
|
var url = window.URL.createObjectURL(data);
|
|
var a = document.createElement('a');
|
|
a.href = url;
|
|
a.download = filename;
|
|
document.body.appendChild(a);
|
|
a.click();
|
|
a.remove();
|
|
window.URL.revokeObjectURL(url);
|
|
},
|
|
error: function (jqXHR, status, error) {
|
|
console.error("Download error:", error);
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
$("body").on("blur", ".cal-group-name-input", function (e) {
|
|
let groupname = $.trim($(this).val());
|
|
if (groupname.length > 3) {
|
|
|
|
$(this).closest('div').find('.dropdown-group-div').show();
|
|
$(this).closest('div').find('.move-group-div').show();
|
|
$(this).closest('div').find('.group-checkbox-div').show();
|
|
$(this).closest('.cal-group-name').text(groupname);
|
|
$(".color-input").eq(0).trigger("change", 1);
|
|
} else {
|
|
$(this).closest('div').find('.dropdown-group-div').show();
|
|
$(this).closest('div').find('.move-group-div').show();
|
|
$(this).closest('div').find('.group-checkbox-div').show();
|
|
$(this).closest('.cal-group-name').text($(this).data('oldname'));
|
|
}
|
|
});
|
|
|
|
function getGroups() {
|
|
const groups = [];
|
|
|
|
$('.calendar-side-borders-sub').each(function (index, value) {
|
|
let show;
|
|
if ($(this).find('.fa-square-arrow-up').length) {
|
|
show = 1;
|
|
} else {
|
|
show = 0;
|
|
}
|
|
const group = {
|
|
name: $.trim($(this).find('h5').text()),
|
|
show: show,
|
|
origin: $(this).data('origin'),
|
|
calendars: []
|
|
};
|
|
$(this).find(('.form-check')).each(function (index, value) {
|
|
let checkbox = $(this).find('.calendar-check');
|
|
let checked;
|
|
if (checkbox.prop('checked')) {
|
|
checked = 1;
|
|
} else {
|
|
checked = 0;
|
|
}
|
|
group.calendars[index] = {
|
|
'calendar_id': $.trim(checkbox.data('calendar_id')),
|
|
'checked': checked,
|
|
origin: $(this).data('origin')
|
|
};
|
|
});
|
|
groups.push(group);
|
|
});
|
|
let groupsJson = JSON.stringify(groups);
|
|
return groupsJson;
|
|
}
|
|
|
|
|
|
function checkGroupCheckboxes() {
|
|
$('.group-checkbox').each(function (index, value) {
|
|
let checked = 0;
|
|
let unchecked = 0;
|
|
let thisis = $(this);
|
|
let ok = 0;
|
|
$(this).closest('.calendar-side-borders-sub').find('.calendar-check').each(function (index, value) {
|
|
if ($(this).prop('checked')) {
|
|
checked++;
|
|
} else {
|
|
unchecked++;
|
|
}
|
|
if (checked > 0 && unchecked > 0) {
|
|
$(this).closest('.calendar-side-borders-sub').find('.group-checkbox').prop('checked', false);
|
|
thisis.prop("indeterminate", true);
|
|
ok = 1;
|
|
return;
|
|
}
|
|
});
|
|
if (ok == 0) {
|
|
if (checked == 0) {
|
|
thisis.prop("indeterminate", false);
|
|
thisis.prop('checked', false);
|
|
} else {
|
|
thisis.prop("indeterminate", false);
|
|
thisis.prop('checked', true);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
$('.calendar-side-borders-sub-inner').sortable({
|
|
group: 'shared',
|
|
filter: '.no-movable',
|
|
delay: 0,
|
|
animation: 0,
|
|
onEnd: function (evt) {
|
|
$('.calendar-check').eq(0).trigger('change');
|
|
},
|
|
});
|
|
$('.add-cal-group-div-sub').sortable({
|
|
filter: '.no-movable',
|
|
handle: '.handle',
|
|
delay: 0,
|
|
onEnd: function (evt) {
|
|
$('.calendar-check').eq(0).trigger('change');
|
|
},
|
|
});
|
|
if (firstcall) {
|
|
$('.color-input').trigger('change', 1);
|
|
}
|
|
$('.select2-multiple').select2(
|
|
{
|
|
dropdownParent: jQuery('#relContainer')
|
|
}
|
|
);
|
|
|
|
$('.select2-multiple-tag').select2(
|
|
{
|
|
tags: true,
|
|
tokenSeparators: [',', ' '],
|
|
dropdownParent: jQuery('#relContainer')
|
|
}
|
|
);
|
|
|
|
|
|
// $(document).on("select2:opening", (e) => {
|
|
// $('.modal-body').css('overflow', 'visible');
|
|
// });
|
|
// $(document).on("select2:open", (e) => {
|
|
// $('.modal-body').css('overflow', 'auto');
|
|
// });
|
|
// $.fn.select2.defaults.set("dropdownParent", $('#EventModal'));
|
|
checkGroupCheckboxes();
|
|
|
|
|
|
function refreshCalendarEvents() {
|
|
calendar.removeAllEvents();
|
|
let checkbox = $(".calendar-check");
|
|
let calendarFilter = $('.btn-light-search');
|
|
let visibleCalendars = [];
|
|
let visibleCalendarTypes = [];
|
|
let mycalendar_id = $('#calendar-id').data('calendarid');
|
|
visibleCalendars.push(0);
|
|
checkbox.each(function () {
|
|
if ($(this).prop('checked')) {
|
|
visibleCalendars.push($(this).data('calendar_id'));
|
|
}
|
|
});
|
|
calendarFilter.each(function () {
|
|
if (!$(this).hasClass('top-search-filter')) {
|
|
visibleCalendarTypes.push($(this).data('ctype'));
|
|
}
|
|
});
|
|
|
|
|
|
$.post(requestUrl, {
|
|
visibleCalendars: visibleCalendars,
|
|
visibleCalendarTypes: visibleCalendarTypes
|
|
}, function (data) {
|
|
|
|
}, 'json').done(function (json) {
|
|
if (json.success == true) {
|
|
let userevents = [];
|
|
let otherevents = [];
|
|
let resources = [];
|
|
let category = "";
|
|
let rights = false;
|
|
let movable = false;
|
|
let resourceCounter = 0;
|
|
let rrule = null;
|
|
let duration = null;
|
|
let rruleflag = false;
|
|
let allDAy = false;
|
|
let cursorclass = "";
|
|
$.each($('.calendar-check'), function (index, value) {
|
|
if ($(this).prop('checked')) {
|
|
rights = true;
|
|
|
|
resources.push({
|
|
id: $(this).data('calendar_id'),
|
|
title: $.trim($(this).closest('div').find('label').text()),
|
|
order: resourceCounter
|
|
});
|
|
|
|
resourceCounter++;
|
|
}
|
|
});
|
|
|
|
|
|
$.each(json.data, function (index, value) {
|
|
if (!value.timerecording.timerecording) {
|
|
rrule = null;
|
|
duration = null;
|
|
rruleflag = false;
|
|
allDAy = false;
|
|
cursorclass = "";
|
|
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') {
|
|
rights = true;
|
|
} else {
|
|
rights = false;
|
|
}
|
|
if (value.isorganizer.isorganizer == '1' && rights) {
|
|
movable = true;
|
|
} else if (rights) {
|
|
movable = false;
|
|
cursorclass = "cursor-alias";
|
|
} else {
|
|
movable = false;
|
|
}
|
|
|
|
if (value.privateflag.privateflag == '1' && mycalendar_id != value.calendar_id.calendar_id) {
|
|
rights = false;
|
|
movable = false;
|
|
|
|
}
|
|
|
|
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, cursorclass],
|
|
textColor: value.txtColor.txtColor,
|
|
backgroundColor: value.bgColor.bgColor,
|
|
editable: rights,
|
|
privateflag: value.privateflag.privateflag,
|
|
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, cursorclass],
|
|
textColor: value.txtColor.txtColor,
|
|
backgroundColor: value.bgColor.bgColor,
|
|
editable: rights,
|
|
privateflag: value.privateflag.privateflag,
|
|
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,
|
|
start: value.cstart.cstart,
|
|
end: value.cend.cend,
|
|
title: category,
|
|
description: category,
|
|
color: 'red',
|
|
editable: false,
|
|
rruleflag: rruleflag,
|
|
rrule: rrule,
|
|
duration: duration,
|
|
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],
|
|
attachment: value.attachment.attachment,
|
|
attachments: value.attachments.attachments,
|
|
resourceId: value.calendar_id.calendar_id,
|
|
calendar_name: value.calendar_name.calendar_name,
|
|
clickable: false,
|
|
mtime: value.mtime.mtime,
|
|
mname: value.mname.mname,
|
|
ctime: value.ctime.ctime,
|
|
cname: value.cname.cname,
|
|
busy: value.busy.busy
|
|
});
|
|
|
|
}
|
|
} else {
|
|
let event = {
|
|
id: value.id.id,
|
|
start: value.cstart.cstart,
|
|
end: value.cend.cend,
|
|
title: value.category.category,
|
|
description: value.description.description,
|
|
calendar_id: value.calendar_id,
|
|
textColor: value.txtColor.txtColor,
|
|
backgroundColor: value.bgColor.bgColor,
|
|
resourceId: value.calendar_id.calendar_id,
|
|
calendar_name: value.calendar_name.calendar_name,
|
|
mtime: value.mtime.mtime,
|
|
mname: value.mname.mname,
|
|
ctime: value.ctime.ctime,
|
|
cname: value.cname.cname,
|
|
editable: false,
|
|
|
|
};
|
|
userevents.push(event);
|
|
}
|
|
|
|
});
|
|
calendar.addEventSource(userevents);
|
|
if (visibleCalendars.includes(998)) {
|
|
calendar.addEventSource(birthdays);
|
|
}
|
|
if (visibleCalendars.includes(997)) {
|
|
calendar.addEventSource(holiDays);
|
|
}
|
|
}
|
|
;
|
|
});
|
|
}
|
|
|
|
$(document).on('focusin', function (e) {
|
|
if ($(e.target).closest(".tox-tinymce, .tox-tinymce-aux, .moxman-window, .tam-assetmanager-root").length) {
|
|
e.stopImmediatePropagation();
|
|
}
|
|
});
|
|
$(document).ready(function () {
|
|
// Checkbox toggelt das RRule-Panel
|
|
$('#recurringCheck').on('change', function () {
|
|
if ($(this).is(':checked')) {
|
|
$('#recurring-settings').show();
|
|
$('#rrule-until').attr('min', $('#start-date').val());
|
|
} else {
|
|
$('#recurring-settings').hide();
|
|
$('#weekly-options').hide();
|
|
$('#monthly-options').hide();
|
|
}
|
|
});
|
|
|
|
// Falls eine Frequenz gewählt wird, passende Felder (weekly/monthly) einblenden
|
|
$('#rrule-frequency').on('change', function () {
|
|
var freq = $(this).val();
|
|
|
|
// Alles erstmal verstecken
|
|
$('#weekly-options').hide();
|
|
$('#monthly-options').hide();
|
|
|
|
if (freq === 'WEEKLY') {
|
|
$('#weekly-options').show();
|
|
} else if (freq === 'MONTHLY') {
|
|
$('#monthly-options').show();
|
|
}
|
|
});
|
|
|
|
// Zeige/Verstecke im monatlichen Bereich "Tag des Monats" oder "X. Wochentag"
|
|
$('#monthly-type').on('change', function () {
|
|
var monthlyType = $(this).val();
|
|
if (monthlyType === 'BYMONTHDAY') {
|
|
$('#monthly-day-select').show();
|
|
$('#monthly-setpos-select').hide();
|
|
} else {
|
|
$('#monthly-day-select').hide();
|
|
$('#monthly-setpos-select').show();
|
|
}
|
|
});
|
|
|
|
// Du kannst bei Klick auf "Hinzufügen" oder "Speichern" dann aus den ausgewählten Werten
|
|
// dein RRule-String generieren (z.B. mit rrule.js oder manuell).
|
|
|
|
});
|
|
|
|
});
|