API Anpassungen
* Abwesenenheiten für Kalender implementiert
This commit is contained in:
@@ -11,6 +11,7 @@ class CalendarApicontroller extends mfBaseApicontroller
|
|||||||
$this->addRoute("/calendar/calendarUserSubscriptions", "updatecalendarUserSubscriptions", "POST");
|
$this->addRoute("/calendar/calendarUserSubscriptions", "updatecalendarUserSubscriptions", "POST");
|
||||||
$this->addRoute("/calendar/calendarUsers", "getcalendarUsers", "GET");
|
$this->addRoute("/calendar/calendarUsers", "getcalendarUsers", "GET");
|
||||||
$this->addRoute("/calendar/calendarAbsence", "getCalendarAbsence", "GET");
|
$this->addRoute("/calendar/calendarAbsence", "getCalendarAbsence", "GET");
|
||||||
|
$this->addRoute("/calendar/calendarAbsence", "updateCalendarAbsence", "POST");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -45,36 +46,37 @@ class CalendarApicontroller extends mfBaseApicontroller
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function getCalendarAbsence()
|
protected function getCalendarAbsence()
|
||||||
{ $db = FronkDB::singleton();
|
{
|
||||||
$sql = "SELECT `Timerecording`.`id`, `Timerecording`.`start` start_time, `Timerecording`.`end` end_time,`Calendar`.`microsoft_id`,`Calendar`.`go_calendar_id` calendar_id,`TimerecordingCategory`.`name`,`TimerecordingCategory`.`id` CategoryId,`Timerecording`.`create` ctime,`Timerecording`.`edit` mtime FROM `Timerecording`
|
$starttime = time() - 86400 * 30;
|
||||||
|
$db = FronkDB::singleton();
|
||||||
|
$sql = "SELECT `Timerecording`.`id`, `Timerecording`.`start` start_time, `Timerecording`.`end` end_time,`Calendar`.`microsoft_id`,`Timerecording`.`microsoft_event_id`,`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 `TimerecordingCategory` ON `TimerecordingCategory`.`id`=`Timerecording`.`timerecordingCategory_id`
|
||||||
INNER JOIN `Calendar` ON `Calendar`.`user_id`=`Timerecording`.`user_id`
|
INNER JOIN `Calendar` ON `Calendar`.`user_id`=`Timerecording`.`user_id`
|
||||||
WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourday`!='7' AND `TimerecordingCategory`.`hourday`!='5'";
|
WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourday`!='7' AND `TimerecordingCategory`.`hourday`!='5' AND `Timerecording`.start >= $starttime
|
||||||
|
AND `Timerecording`.`user_id` = '89'
|
||||||
|
";
|
||||||
$res = $db->query($sql);
|
$res = $db->query($sql);
|
||||||
if ($db->num_rows($res)) {
|
if ($db->num_rows($res)) {
|
||||||
while ($data = $db->fetch_array($res)) {
|
while ($data = $db->fetch_array($res)) {
|
||||||
|
|
||||||
if ($data['CategoryId'] != 11) {
|
if ($data['CategoryId'] != 11) {
|
||||||
$starttime = date("Y-m-d", $data['start_time']);
|
$data['start_time'] = $data['start_time'];
|
||||||
$endtime = date("Y-m-d", $data['end_time']);
|
$all_day_event = 1;
|
||||||
if ($starttime != $endtime) {
|
|
||||||
$endtime = $data['end_time'] + 86400;
|
|
||||||
$endtime = date("Y-m-d", $endtime);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$starttime = date("Y-m-d H:i", $data['start_time']);
|
$starttime = date("Y-m-d H:i", $data['start_time']);
|
||||||
$endtime = date("Y-m-d H:i", $data['end_time']);
|
$endtime = date("Y-m-d H:i", $data['end_time']);
|
||||||
|
$all_day_event = 0;
|
||||||
}
|
}
|
||||||
$rows[] = array(
|
$rows[] = array(
|
||||||
'id' => array('id' => "9999" . $data['id']),
|
'id' => $data['id'],
|
||||||
'category' => array('category' => $data['name']),
|
'name' => $data['name'],
|
||||||
'ccategory' => array('ccategory' => $data['name']),
|
'start_time' => $data['start_time'],
|
||||||
'cstart' => array('cstart' => $starttime),
|
'end_time' => $data['end_time'],
|
||||||
'cend' => array('cend' => $endtime),
|
'all_day_event' => $all_day_event,
|
||||||
'calendar_id' => array('calendar_id' => $data['calendar_id']),
|
'calendar_id' => $data['calendar_id'],
|
||||||
'microsoft_id' => array('microsoft_id' => $data['microsoft_id']),
|
'microsoft_id' => $data['microsoft_id'],
|
||||||
'description' => array('description' => "")
|
'microsoft_event_id' => $data['microsoft_event_id'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,11 +84,36 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda
|
|||||||
$json['success'] = true;
|
$json['success'] = true;
|
||||||
$json['data'] = $rows;
|
$json['data'] = $rows;
|
||||||
$json['status'] = "success";
|
$json['status'] = "success";
|
||||||
$result = json_encode($json,JSON_UNESCAPED_UNICODE );
|
$result = json_encode($json, JSON_UNESCAPED_UNICODE);
|
||||||
echo $result;
|
echo $result;
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function updateCalendarAbsence()
|
||||||
|
{
|
||||||
|
$id = $this->post['id'];
|
||||||
|
|
||||||
|
$microsoft_event_id = $this->post['microsoft_event_id'];
|
||||||
|
|
||||||
|
$timercording = new Timerecording($id);
|
||||||
|
|
||||||
|
if (!($timercording->id) || $timercording->id != $id) {
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
$data = [];
|
||||||
|
if ($microsoft_event_id) {
|
||||||
|
$data['microsoft_event_id'] = $microsoft_event_id;
|
||||||
|
} else {
|
||||||
|
$data['microsoft_event_id'] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$timercording->update($data);
|
||||||
|
$timercording->save();
|
||||||
|
$json['status'] = "success";
|
||||||
|
$result = json_encode($json);
|
||||||
|
echo $result;
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
protected function getcalendarUserSubscriptions()
|
protected function getcalendarUserSubscriptions()
|
||||||
{
|
{
|
||||||
@@ -218,7 +245,7 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda
|
|||||||
$message[0]['start_time'] = date('Y-m-d H:i', $json['start_time']);
|
$message[0]['start_time'] = date('Y-m-d H:i', $json['start_time']);
|
||||||
$message[0]['end_time'] = date('Y-m-d H:i', $json['end_time']);
|
$message[0]['end_time'] = date('Y-m-d H:i', $json['end_time']);
|
||||||
}
|
}
|
||||||
$message[0]['name']= $Calendarevent['data'][0]['category']['category'];
|
$message[0]['name'] = $Calendarevent['data'][0]['category']['category'];
|
||||||
$message[0]['description'] = $Calendarevent['data'][0]['description']['description'];
|
$message[0]['description'] = $Calendarevent['data'][0]['description']['description'];
|
||||||
$message[0]['location'] = $Calendarevent['data'][0]['location']['location'];
|
$message[0]['location'] = $Calendarevent['data'][0]['location']['location'];
|
||||||
$message[0]['event_type'] = $Calendarevent['data'][0]['event_type']['event_type'];
|
$message[0]['event_type'] = $Calendarevent['data'][0]['event_type']['event_type'];
|
||||||
@@ -234,7 +261,7 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda
|
|||||||
$message[0]['ctime'] = $Calendarevent['data'][0]['ctime']['ctime'];
|
$message[0]['ctime'] = $Calendarevent['data'][0]['ctime']['ctime'];
|
||||||
$message[0]['cname'] = $Calendarevent['data'][0]['cname']['cname'];
|
$message[0]['cname'] = $Calendarevent['data'][0]['cname']['cname'];
|
||||||
$message[0]['busy'] = $Calendarevent['data'][0]['busy']['busy'];
|
$message[0]['busy'] = $Calendarevent['data'][0]['busy']['busy'];
|
||||||
$message[0]['canceld']= $Calendarevent['data'][0]['canceld']['canceld'];
|
$message[0]['canceld'] = $Calendarevent['data'][0]['canceld']['canceld'];
|
||||||
$message[0]['calendar_id_check'] = array('calendar_id' => $json['calendar_id'], 'order' => $json['calendar_id']);;
|
$message[0]['calendar_id_check'] = array('calendar_id' => $json['calendar_id'], 'order' => $json['calendar_id']);;
|
||||||
$message[0]['userr'] = $Calendar[0]->calendar_id;
|
$message[0]['userr'] = $Calendar[0]->calendar_id;
|
||||||
$message[0]['bgColor'] = $calendarColors[$json['calendar_id']]['bgcolor'];
|
$message[0]['bgColor'] = $calendarColors[$json['calendar_id']]['bgcolor'];
|
||||||
|
|||||||
@@ -238,6 +238,9 @@ class CalendarModel
|
|||||||
$attachment = 0;
|
$attachment = 0;
|
||||||
$attachmentLinks = "";
|
$attachmentLinks = "";
|
||||||
}
|
}
|
||||||
|
if (in_array("Abwesenheit", $categories)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ($data['all_day_event'] == 1) {
|
if ($data['all_day_event'] == 1) {
|
||||||
if (in_array("Feiertag", $categories)) {
|
if (in_array("Feiertag", $categories)) {
|
||||||
continue;
|
continue;
|
||||||
@@ -344,59 +347,60 @@ class CalendarModel
|
|||||||
'mname' => array('mname' => $data['mname']),
|
'mname' => array('mname' => $data['mname']),
|
||||||
'isorganizer' => array('isorganizer' => $data['is_organizer']),
|
'isorganizer' => array('isorganizer' => $data['is_organizer']),
|
||||||
'busy' => array('busy' => $data['busy']),
|
'busy' => array('busy' => $data['busy']),
|
||||||
'canceld'=> array('canceld' => $data['canceld']),
|
'canceld' => array('canceld' => $data['canceld']),
|
||||||
'timerecording' => array('timerecording' => 0),
|
'timerecording' => array('timerecording' => 0),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db = FronkDB::singleton();
|
if ($id == 0) {
|
||||||
$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`
|
$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 `TimerecordingCategory` ON `TimerecordingCategory`.`id`=`Timerecording`.`timerecordingCategory_id`
|
||||||
INNER JOIN `Calendar` ON `Calendar`.`user_id`=`Timerecording`.`user_id`
|
INNER JOIN `Calendar` ON `Calendar`.`user_id`=`Timerecording`.`user_id`
|
||||||
WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourday`!='7' AND `TimerecordingCategory`.`hourday`!='5' $whereTimeRecording";
|
WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourday`!='7' AND `TimerecordingCategory`.`hourday`!='5' $whereTimeRecording";
|
||||||
$res = $db->query($sql);
|
$res = $db->query($sql);
|
||||||
if ($db->num_rows($res)) {
|
if ($db->num_rows($res)) {
|
||||||
while ($data = $db->fetch_array($res)) {
|
while ($data = $db->fetch_array($res)) {
|
||||||
|
|
||||||
if ($calendarColors[$data['calendar_id']]['bgcolor']) {
|
if ($calendarColors[$data['calendar_id']]['bgcolor']) {
|
||||||
$bgcolor = $calendarColors[$data['calendar_id']]['bgcolor'];
|
$bgcolor = $calendarColors[$data['calendar_id']]['bgcolor'];
|
||||||
$txtcolor = $calendarColors[$data['calendar_id']]['txtcolor'];
|
$txtcolor = $calendarColors[$data['calendar_id']]['txtcolor'];
|
||||||
} else {
|
} else {
|
||||||
$bgcolor = $standardCalendarColors[$colorCounter];
|
$bgcolor = $standardCalendarColors[$colorCounter];
|
||||||
$txtcolor = "#000";
|
$txtcolor = "#000";
|
||||||
$colorCounter++;
|
$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 ($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 {
|
} else {
|
||||||
$starttime = date("Y-m-d H:i", $data['start_time']);
|
$starttime = date("Y-m-d H:i", $data['start_time']);
|
||||||
$endtime = date("Y-m-d H:i", $data['end_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['success'] = true;
|
||||||
$json['data'] = $rows;
|
$json['data'] = $rows;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class TimerecordingModel
|
|||||||
private $comment;
|
private $comment;
|
||||||
private $approved;
|
private $approved;
|
||||||
private $completed;
|
private $completed;
|
||||||
|
private $microsoft_even_id;
|
||||||
|
|
||||||
|
|
||||||
public static function find($data)
|
public static function find($data)
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Phinx\Migration\AbstractMigration;
|
||||||
|
|
||||||
|
final class TimerecordingAddMicrosoftEventId extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
if($this->getEnvironment() == "thetool") {
|
||||||
|
$table = $this->table("Timerecording", ["signed" => true]);
|
||||||
|
$table->addColumn("microsoft_event_id", "string", ["null" => true, "after" => "completed"]);
|
||||||
|
$table->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->getEnvironment() == "addressdb") {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
if($this->getEnvironment() == "thetool") {
|
||||||
|
$this->table("Timerecording")->removeColumn("microsoft_event_id")->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->getEnvironment() == "addressdb") {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1164,8 +1164,8 @@ if (typeof (EventSource) !== 'undefined') {
|
|||||||
calendar.render();
|
calendar.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (event.change_type == '1' || !cevent) {
|
} else if ((event.change_type == '1' || !cevent) && event.change_type != '3') {
|
||||||
if (event.calendar_id == event.calendar_id) {
|
if (event.calendar_id == event.calendar_id && event.name) {
|
||||||
let info = calendar.addEvent({
|
let info = calendar.addEvent({
|
||||||
id: event.cal_events_id,
|
id: event.cal_events_id,
|
||||||
title: event.name,
|
title: event.name,
|
||||||
@@ -1192,7 +1192,7 @@ if (typeof (EventSource) !== 'undefined') {
|
|||||||
busy: event.busy
|
busy: event.busy
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else if (event.name) {
|
||||||
let info = calendar.addEvent({
|
let info = calendar.addEvent({
|
||||||
id: event.cal_events_id,
|
id: event.cal_events_id,
|
||||||
title: event.name,
|
title: event.name,
|
||||||
@@ -1222,7 +1222,9 @@ if (typeof (EventSource) !== 'undefined') {
|
|||||||
calendar.render();
|
calendar.render();
|
||||||
} else if (event.change_type == '3') {
|
} else if (event.change_type == '3') {
|
||||||
let cevent = calendar.getEventById(event.cal_events_id);
|
let cevent = calendar.getEventById(event.cal_events_id);
|
||||||
cevent.remove();
|
if (cevent) {
|
||||||
|
cevent.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user