2124 lines
96 KiB
JavaScript
2124 lines
96 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',
|
|
|
|
// Weitere Typen und Klassen hinzufügen...
|
|
};
|
|
var calendar;
|
|
var 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) {
|
|
var userevents = [];
|
|
var otherevents = [];
|
|
var resources = [];
|
|
var category = "";
|
|
var rights = false;
|
|
var movable = false;
|
|
var resourceCounter = 0;
|
|
var rrule = null;
|
|
var duration = null;
|
|
var 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.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();
|
|
} else if (data.data.type.type == "2") {
|
|
$('.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) {
|
|
$('#customer-info-reminder-check').prop('checked', true);
|
|
}
|
|
$('#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',
|
|
});
|
|
var typeText;
|
|
if (obj.customer_info_type == 1) {
|
|
typeText = 'E-Mail';
|
|
} else if (obj.customer_info_type == 2) {
|
|
typeText = 'SMS';
|
|
}
|
|
var title = `<div class="text-center font-weight-500">Letzte gesendete Info (` + typeText + `):</div>
|
|
<div class="text-left">` + obj.customer_info_text.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1<br />$2') + `</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>
|
|
|
|
`;
|
|
console.log(title);
|
|
var tooltip = new Tooltip($('.customer-info-point'), {
|
|
title: title,
|
|
placement: 'right',
|
|
trigger: 'hover',
|
|
container: 'body',
|
|
html: true
|
|
});
|
|
}
|
|
}
|
|
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)) {
|
|
var 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();
|
|
|
|
}
|
|
|
|
});
|
|
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) {
|
|
var eventstart = new Date(info.event.startStr);
|
|
var eventend = new Date(info.event.endStr);
|
|
|
|
var 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) {
|
|
var 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>");
|
|
}
|
|
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>");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
var tooltip = new Tooltip(info.el, {
|
|
title: title,
|
|
placement: 'right',
|
|
delay: {hide: 50},
|
|
trigger: 'hover',
|
|
container: 'body',
|
|
html: true,
|
|
});
|
|
|
|
var tooltips = info.event.extendedProps['tooltips'] || [];
|
|
tooltips.push(tooltip);
|
|
info.event.setExtendedProp('tooltips', tooltips);
|
|
},
|
|
|
|
eventWillUnmount: function (info) {
|
|
for (var tooltip of info.event.extendedProps['tooltips']) {
|
|
tooltip.dispose();
|
|
}
|
|
},
|
|
eventResize: function (info) {
|
|
|
|
var start = info.event.start.getTime();
|
|
const offsetstart = getOffset(start);
|
|
start = (start / 1000 + offsetstart) * 1000;
|
|
var end = info.event.end.getTime();
|
|
const offsetend = getOffset(end);
|
|
end = (end / 1000 + offsetend) * 1000;
|
|
var id = info.event.id;
|
|
$.post(requestUpdateUrl, {
|
|
start: start,
|
|
end: end,
|
|
id: id
|
|
}, function (data) {
|
|
|
|
}).done(function (data) {
|
|
var tooltip = new Tooltip(info.el, {
|
|
title: info.event.extendedProps.description,
|
|
placement: 'right',
|
|
trigger: 'hover',
|
|
container: 'body'
|
|
});
|
|
|
|
var tooltips = info.event.extendedProps['tooltips'] || [];
|
|
tooltips.push(tooltip);
|
|
info.event.setExtendedProp('tooltips', tooltips);
|
|
});
|
|
|
|
},
|
|
eventDrop: function (info) {
|
|
// sleep(2000).then(() => {
|
|
var start = info.event.start.getTime();
|
|
const offsetstart = getOffset(start);
|
|
start = (start / 1000 + offsetstart) * 1000;
|
|
var end = info.event.end.getTime();
|
|
const offsetend = getOffset(end);
|
|
end = (end / 1000 + offsetend) * 1000;
|
|
var 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...');
|
|
|
|
var 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) {
|
|
var 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 visibleCalendars = [];
|
|
let mycalendar_id = $('#calendar-id').data('calendarid');
|
|
visibleCalendars.push(0);
|
|
checkbox.each(function () {
|
|
if ($(this).prop('checked')) {
|
|
visibleCalendars.push($(this).data('calendar_id'));
|
|
}
|
|
});
|
|
jsondata = JSON.parse(e.data);
|
|
jsondata.forEach(function (event) {
|
|
if (!visibleCalendars.includes(event.calendar_id)) {
|
|
return;
|
|
}
|
|
var cevent = calendar.getEventById(event.cal_events_id);
|
|
var rights = false;
|
|
var movable = false;
|
|
var rrule = null;
|
|
var duration = null;
|
|
var rruleflag = false;
|
|
let cursorclass = '';
|
|
if (event.rrule) {
|
|
rrule = event.rrule;
|
|
duration = event.duration;
|
|
rruleflag = true;
|
|
}
|
|
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) {
|
|
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
|
|
});
|
|
} 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) {
|
|
var 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 {
|
|
var 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') {
|
|
var 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();
|
|
});
|
|
|
|
$('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'));
|
|
|
|
});
|
|
|
|
}
|
|
});
|
|
|
|
$('#EventModal').on('hide.bs.modal', function (event) {
|
|
// $('.select2-multiple').select2('destroy');
|
|
});
|
|
|
|
|
|
$('#EventModal').on('show.bs.modal', function (event) {
|
|
|
|
$('.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('');
|
|
$('.event-organizer-div').hide();
|
|
$('#calendar-attendees').val('').trigger('change');
|
|
$('.customer-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');
|
|
});
|
|
|
|
// $('.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));
|
|
});
|
|
|
|
$('body').on('click', '#add-event', function () {
|
|
var valid = true;
|
|
|
|
$('#EventModal .is-require').each(function (index, value) {
|
|
if ($(this).val() == "") {
|
|
valid = false;
|
|
$(this).addClass('required');
|
|
} else {
|
|
$(this).removeClass('required');
|
|
}
|
|
});
|
|
|
|
if (!valid) {
|
|
return;
|
|
}
|
|
var attachments = [];
|
|
$('.doc-main-div').each(function (index, value) {
|
|
if ($(this).data('docid')) {
|
|
attachments.push($(this).data('docid'));
|
|
}
|
|
});
|
|
|
|
var start = $('#start-date').val() + ' ' + $('#start-time').val();
|
|
var end = $('#end-date').val() + ' ' + $('#end-time').val();
|
|
var title = $('#name').val();
|
|
var location = $('#location').val();
|
|
var description = $('#description').val();
|
|
var newkey = $('#attachments').data('newkey');
|
|
var allday = 0;
|
|
var reminder = $('#reminder').val();
|
|
var type = $('#type').val();
|
|
var busy = $('#busy').val();
|
|
var customer;
|
|
var customer_info_check = 0;
|
|
var customer_info_text;
|
|
var customer_info_type;
|
|
var customer_info_type_text;
|
|
var customer_info_reminder_check = 0;
|
|
var private = $('.privacy-click');
|
|
var privateflag = 0;
|
|
if (private.hasClass('fa-lock')) {
|
|
privateflag = 1;
|
|
}
|
|
var users = [];
|
|
|
|
if ($('#allday').is(':checked')) {
|
|
allday = 1;
|
|
}
|
|
if ($('#customer-info-check').is(':checked')) {
|
|
customer_info_check = 1;
|
|
}
|
|
if (type == '2') {
|
|
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());
|
|
});
|
|
|
|
|
|
$.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,
|
|
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 () {
|
|
|
|
var valid = true;
|
|
|
|
$('#EventModal .is-require').each(function (index, value) {
|
|
if ($(this).val() == "") {
|
|
valid = false;
|
|
$(this).addClass('required');
|
|
} else {
|
|
$(this).removeClass('required');
|
|
}
|
|
});
|
|
|
|
if (!valid) {
|
|
return;
|
|
}
|
|
var attachments = [];
|
|
$('.doc-main-div').each(function (index, value) {
|
|
if ($(this).data('docid')) {
|
|
attachments.push($(this).data('docid'));
|
|
}
|
|
});
|
|
|
|
var start = $('#start-date').val() + ' ' + $('#start-time').val();
|
|
var end = $('#end-date').val() + ' ' + $('#end-time').val();
|
|
var title = $('#name').val();
|
|
var location = $('#location').val();
|
|
var description = $('#description').val();
|
|
var newkey = $('#attachments').data('newkey');
|
|
var allday = 0;
|
|
var reminder = $('#reminder').val();
|
|
var type = $('#type').val();
|
|
var busy = $('#busy').val();
|
|
var customer;
|
|
var customer_info_check = 0;
|
|
var customer_info_text;
|
|
var customer_info_type;
|
|
var customer_info_type_text;
|
|
var customer_info_reminder_check = 0;
|
|
var private = $('.privacy-click');
|
|
var privateflag = 0;
|
|
if (private.hasClass('fa-lock')) {
|
|
privateflag = 1;
|
|
}
|
|
var users = [];
|
|
|
|
if ($('#allday').is(':checked')) {
|
|
allday = 1;
|
|
}
|
|
|
|
if ($('#customer-info-check').is(':checked')) {
|
|
customer_info_check = 1;
|
|
}
|
|
if (type == '2') {
|
|
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;
|
|
}
|
|
|
|
|
|
}
|
|
var id = $(this).data('id');
|
|
|
|
$('#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 () {
|
|
var id = $(this).data('id');
|
|
var 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) {
|
|
var bgcolors = [];
|
|
var txtcolors = [];
|
|
var calendar_id = [];
|
|
var 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 {
|
|
}
|
|
|
|
});
|
|
|
|
|
|
var 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('change', '.calendar-check', function (event, init = 0) {
|
|
|
|
if ($(this).prop('checked')) {
|
|
refreshCalendarEvents()
|
|
} else {
|
|
refreshCalendarEvents()
|
|
}
|
|
var resources = calendar.getResources();
|
|
$.each(resources, function (index, value) {
|
|
value.remove();
|
|
});
|
|
var 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) {
|
|
var fileList = $('#files-input').prop("files");
|
|
var 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'));
|
|
|
|
|
|
var request = $.ajax({
|
|
url: requestEventAttachmentUploadUrl,
|
|
cache: false,
|
|
contentType: false,
|
|
processData: false,
|
|
async: true,
|
|
data: form_data,
|
|
type: 'POST',
|
|
xhr: function () {
|
|
var xhr = $.ajaxSettings.xhr();
|
|
if (xhr.upload) {
|
|
xhr.upload.addEventListener('progress', function (event) {
|
|
var 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 () {
|
|
var fileList = $('#files-input').prop("files");
|
|
|
|
$('#uploadsts').html('');
|
|
var 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 () {
|
|
if ($(this).val() == "1") {
|
|
$('.customer-div').hide();
|
|
} else if ($(this).val() == "2") {
|
|
$('.customer-div').show();
|
|
$('#customer').select2({
|
|
placeholder: "Kunden Suche",
|
|
minimumInputLength: 3,
|
|
// dropdownParent: $('#EventModal'),
|
|
dropdownParent: jQuery('#relContainer2'),
|
|
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
|
|
};
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
$('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 Variable, 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 textTemplate;
|
|
if ($(this).data('id') == 1) {
|
|
textTemplate = `Sehr geehrter Kunde,
|
|
Ihr Technikertermin findet am ` + formattedDate + ` ` + daytimetext + ` statt.
|
|
Mit Freundlichen Grüßen
|
|
Xinon GMbH`;
|
|
} else if ($(this).data('id') == 2) {
|
|
textTemplate = `Sehr geehrter Kunde,
|
|
wir möchten Sie daran erinnern, dass Ihr Technikertermin am ` + formattedDate + ` ` + daytimetext + ` stattfindet.
|
|
Mit Freundlichen Grüßen
|
|
Xinon GMbH`;
|
|
} else if ($(this).data('id') == 3) {
|
|
textTemplate = formattedDate + ` zwischen ` + starttime + ` und ` + endtime;
|
|
}
|
|
|
|
$('#customer-info-text').val(textTemplate);
|
|
});
|
|
|
|
|
|
$('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);
|
|
}
|
|
}
|
|
|
|
|
|
});
|
|
|
|
$("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 + '">');
|
|
var 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()
|
|
}
|
|
var resources = calendar.getResources();
|
|
$.each(resources, function (index, value) {
|
|
value.remove();
|
|
});
|
|
var 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("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 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) {
|
|
var userevents = [];
|
|
var otherevents = [];
|
|
var resources = [];
|
|
var category = "";
|
|
var rights = false;
|
|
var movable = false;
|
|
var resourceCounter = 0;
|
|
var rrule = null;
|
|
var duration = null;
|
|
var 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);
|
|
}
|
|
}
|
|
;
|
|
});
|
|
}
|
|
|
|
|
|
})
|
|
;
|