Zeiterfassung Update

* Nicht freigegebene Abwesenheiten werden nun in der Kalenderübersicht strichliert dargestellt
* Anpassungen in den Genehmigungsemails
This commit is contained in:
Daniel Spitzer
2025-10-07 17:02:32 +02:00
parent 5a3d1d16f0
commit e2c0a3f963

View File

@@ -646,8 +646,6 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda
public static function updateCalendarEvent($r, $me)
{
$description = ($r->description);
$attachments = ($r->attachments);
$location = ($r->location);
@@ -788,6 +786,8 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda
$db->update("cal_events", $updateArray, "id = '" . $id . "'");
// error_log("=== NACH ERSTEM UPDATE ===");
// error_log("Suche nach linked events für Event ID: " . $id);
if ($newkey) {
$res = $db->select("cal_events_attachments", "id,cal_events_id", "1=1 AND cal_events_id = '" . $cal_events_id . "'");
if ($db->num_rows($res)) {
@@ -852,10 +852,33 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda
$db->insert("TheTool_CalendarQueue", $data);
}
$resMain = $db->select("cal_events", 'linked_event_uid,is_organizer', "id = '" . $id . "' LIMIT 1");
// error_log("=== MAIN EVENT CHECK ===");
// error_log("num_rows: " . $db->num_rows($resMain));
if ($db->num_rows($resMain)) {
// error_log("DEBUG: Vor fetch_object");
$mainEvent = $db->fetch_object($resMain);
// error_log("DEBUG: Nach fetch_object");
if ($mainEvent && $mainEvent->is_organizer == 1 && empty($mainEvent->linked_event_uid)) {
$new_linked_uid = 'LINKED-' . strtoupper(uniqid()) . '-' . time();
$db->update("cal_events", array('linked_event_uid' => $new_linked_uid), "id = '" . $id . "'");
$mainEvent->linked_event_uid = $new_linked_uid;
// error_log("DEBUG: Alte Event - linked_event_uid erstellt: " . $new_linked_uid);
}
if (!$mainEvent) {
// error_log("ERROR: fetch_object returned false/null!");
} else {
// error_log("DEBUG: mainEvent Object: " . print_r($mainEvent, true));
// error_log("mainEvent->is_organizer: " . ($mainEvent->is_organizer ?? 'NULL'));
// error_log("mainEvent->linked_event_uid: " . ($mainEvent->linked_event_uid ?? 'NULL'));
if ($mainEvent->is_organizer == 1 && !empty($mainEvent->linked_event_uid)) {
if (isset($mainEvent->is_organizer) && isset($mainEvent->linked_event_uid)) {
// error_log("Bedingung erfüllt? " . (($mainEvent->is_organizer == 1 && !empty($mainEvent->linked_event_uid)) ? "JA" : "NEIN"));
} else {
// error_log("ERROR: is_organizer oder linked_event_uid nicht gesetzt!");
}
}
if ($mainEvent->is_organizer == 1 && ($mainEvent->linked_event_uid)) {
$sqlLinked = "SELECT ce.id, ce.calendar_id, cc.ms_user_id microsoft_id
FROM cal_events ce
LEFT JOIN cal_calendars cc ON ce.calendar_id = cc.id
@@ -995,10 +1018,19 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda
$newAttendeeCalId = intval($emailCalData->go_calendar_id);
}
}
error_log("=== NEUER TEILNEHMER CHECK ===");
error_log("newAttendee Wert: " . print_r($newAttendee, true));
error_log("newAttendeeCalId: " . ($newAttendeeCalId ?: 'NULL'));
error_log("currentAttendeeCalendarIds: " . print_r($currentAttendeeCalendarIds, true));
error_log("Ist in currentAttendeeCalendarIds? " . (in_array($newAttendeeCalId, $currentAttendeeCalendarIds) ? "JA" : "NEIN"));
// DEBUG ENDE
if ($newAttendeeCalId) {
if (!in_array($newAttendeeCalId, $currentAttendeeCalendarIds)) {
$newAttCal = self::search(array("go_calendar_id" => $newAttendeeCalId));
if (count($newAttCal) > 0) {
// ÄNDERUNG: Prüfe ms_user_id in cal_calendars statt microsoft_id in Calendar
$resCheckNewAttMs = $db->select("cal_calendars", "ms_user_id", "id = '" . $newAttendeeCalId . "' LIMIT 1");
$hasMsId = false;
if ($db->num_rows($resCheckNewAttMs)) {