API Anpassungen

* Abwesenenheiten für Kalender implementiert
This commit is contained in:
Daniel Spitzer
2025-05-25 18:18:24 +02:00
parent 08e70ad73d
commit 955aa0fbd2
5 changed files with 130 additions and 65 deletions

View File

@@ -238,6 +238,9 @@ class CalendarModel
$attachment = 0;
$attachmentLinks = "";
}
if (in_array("Abwesenheit", $categories)) {
continue;
}
if ($data['all_day_event'] == 1) {
if (in_array("Feiertag", $categories)) {
continue;
@@ -344,59 +347,60 @@ class CalendarModel
'mname' => array('mname' => $data['mname']),
'isorganizer' => array('isorganizer' => $data['is_organizer']),
'busy' => array('busy' => $data['busy']),
'canceld'=> array('canceld' => $data['canceld']),
'canceld' => array('canceld' => $data['canceld']),
'timerecording' => array('timerecording' => 0),
);
}
}
$db = FronkDB::singleton();
$sql = "SELECT `Timerecording`.`id`, `Timerecording`.`start` start_time, `Timerecording`.`end` end_time,`Calendar`.`go_calendar_id` calendar_id,`TimerecordingCategory`.`name`,`TimerecordingCategory`.`id` CategoryId,`Timerecording`.`create` ctime,`Timerecording`.`edit` mtime FROM `Timerecording`
if ($id == 0) {
$db = FronkDB::singleton();
$sql = "SELECT `Timerecording`.`id`, `Timerecording`.`start` start_time, `Timerecording`.`end` end_time,`Calendar`.`go_calendar_id` calendar_id,`TimerecordingCategory`.`name`,`TimerecordingCategory`.`id` CategoryId,`Timerecording`.`create` ctime,`Timerecording`.`edit` mtime FROM `Timerecording`
INNER JOIN `TimerecordingCategory` ON `TimerecordingCategory`.`id`=`Timerecording`.`timerecordingCategory_id`
INNER JOIN `Calendar` ON `Calendar`.`user_id`=`Timerecording`.`user_id`
WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourday`!='7' AND `TimerecordingCategory`.`hourday`!='5' $whereTimeRecording";
$res = $db->query($sql);
if ($db->num_rows($res)) {
while ($data = $db->fetch_array($res)) {
$res = $db->query($sql);
if ($db->num_rows($res)) {
while ($data = $db->fetch_array($res)) {
if ($calendarColors[$data['calendar_id']]['bgcolor']) {
$bgcolor = $calendarColors[$data['calendar_id']]['bgcolor'];
$txtcolor = $calendarColors[$data['calendar_id']]['txtcolor'];
} else {
$bgcolor = $standardCalendarColors[$colorCounter];
$txtcolor = "#000";
$colorCounter++;
}
if ($data['CategoryId'] != 11) {
$starttime = date("Y-m-d", $data['start_time']);
$endtime = date("Y-m-d", $data['end_time']);
if ($starttime != $endtime) {
$endtime = $data['end_time'] + 86400;
$endtime = date("Y-m-d", $endtime);
if ($calendarColors[$data['calendar_id']]['bgcolor']) {
$bgcolor = $calendarColors[$data['calendar_id']]['bgcolor'];
$txtcolor = $calendarColors[$data['calendar_id']]['txtcolor'];
} else {
$bgcolor = $standardCalendarColors[$colorCounter];
$txtcolor = "#000";
$colorCounter++;
}
if ($data['CategoryId'] != 11) {
$starttime = date("Y-m-d", $data['start_time']);
$endtime = date("Y-m-d", $data['end_time']);
if ($starttime != $endtime) {
$endtime = $data['end_time'] + 86400;
$endtime = date("Y-m-d", $endtime);
}
} else {
$starttime = date("Y-m-d H:i", $data['start_time']);
$endtime = date("Y-m-d H:i", $data['end_time']);
} else {
$starttime = date("Y-m-d H:i", $data['start_time']);
$endtime = date("Y-m-d H:i", $data['end_time']);
}
$rows[] = array(
'id' => array('id' => "9999" . $data['id']),
'category' => array('category' => $data['name']),
'ccategory' => array('ccategory' => $data['name']),
'cstart' => array('cstart' => $starttime),
'cend' => array('cend' => $endtime),
'calendar_id' => array('calendar_id' => $data['calendar_id']),
'ctime' => array('ctime' => date("d.m.Y H:i", $data['ctime'])),
'cname' => array('cname' => $CalendarUsers[$data['calendar_id']]),
'mtime' => array('mtime' => date("d.m.Y H:i", $data['mtime'])),
'mname' => array('mname' => $CalendarUsers[$data['calendar_id']]),
'description' => array('description' => ""),
'bgColor' => array('bgColor' => $bgcolor),
'txtColor' => array('txtColor' => $txtcolor),
'timerecording' => array('timerecording' => 1),
'calendar_name' => array('calendar_name' => $CalendarUsers[$data['calendar_id']]),
);
}
$rows[] = array(
'id' => array('id' => "9999" . $data['id']),
'category' => array('category' => $data['name']),
'ccategory' => array('ccategory' => $data['name']),
'cstart' => array('cstart' => $starttime),
'cend' => array('cend' => $endtime),
'calendar_id' => array('calendar_id' => $data['calendar_id']),
'ctime' => array('ctime' => date("d.m.Y H:i", $data['ctime'])),
'cname' => array('cname' => $CalendarUsers[$data['calendar_id']]),
'mtime' => array('mtime' => date("d.m.Y H:i", $data['mtime'])),
'mname' => array('mname' => $CalendarUsers[$data['calendar_id']]),
'description' => array('description' => ""),
'bgColor' => array('bgColor' => $bgcolor),
'txtColor' => array('txtColor' => $txtcolor),
'timerecording' => array('timerecording' => 1),
'calendar_name' => array('calendar_name' => $CalendarUsers[$data['calendar_id']]),
);
}
}
$json['success'] = true;
$json['data'] = $rows;