* 1st Upload aller Files Inclusive API Controller
This commit is contained in:
Daniel Spitzer
2024-11-03 18:38:11 +01:00
parent 6e16b34476
commit 6b2b169f25
9 changed files with 4527 additions and 0 deletions

View File

@@ -0,0 +1,115 @@
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<link href="<?= self::getResourcePath() ?>assets/css/select2-cstm.css?<?= date('U') ?>" rel="stylesheet"
type="text/css"/>
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="<?= self::getUrl("Dashboard") ?>"><?= MFAPPNAME_SLUG ?></a>
</li>
<li class="breadcrumb-item"><a
href="<?= self::getUrl("Calendar") ?>">Kalender Verwaltung</a></li>
<li class="breadcrumb-item active"><?= ($calendars->id) ? "bearbeiten" : "Neu" ?></li>
</ol>
</div>
<h4 class="page-title"><?= ($calendars->id) ? "Kalender Verwaltung bearbeiten" : "Neuer Kalender Verwaltung" ?></h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
<div class="card bg-light">
<div class="card-body">
<h4 class="header-title mb-2"><?= ($calendars->id) ? "Kalender Verwaltung bearbeiten" : "Neuer Kalender Verwaltung" ?></h4>
<form class="form-horizontal" method="post"
action="<?= self::getUrl("Calendar", "save") ?>">
<div class="card no-shadow">
<div class="card-body">
<input type="hidden" name="id" value="<?= $calendars->id ?>"/>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="user_id">Name *</label>
<div class="col-lg-3">
<select disabled="disabled" required="required" id="user_id" name="user_id"
class="select2 form-control">
<option value=""></option>
<?php foreach ($users as $user): ?>
<option value="<?= $user->id ?>" <?= ($calendars->user_id == $user->id) ? "selected='selected'" : "" ?>><?= $user->name ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="go_calendar_id">GO Kalender ID</label>
<div class="col-lg-3">
<input type="text" id="go_calendar_id" name="go_calendar_id"
value="<?= $calendars->go_calendar_id ?>" class="form-control"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="microsoft_id">Microsoft Id</label>
<div class="col-lg-3">
<input type="text" id="microsoft_id" name="microsoft_id" class="form-control"
value="<?= $calendars->microsoft_id ?>"/>
</div>
</div>
<!-- <div class="form-group row">-->
<!-- <label class="col-lg-2 col-form-label" for="rights">Kalenderrechte</label>-->
<!-- <div class="col-lg-3">-->
<!-- <input type="text" id="rights" name="rights" class="form-control"-->
<!-- value="--><?php //= $calendars->rights ?><!--"/>-->
<!-- </div>-->
<!-- </div>-->
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="active">Aktiv</label>
<div class="col-lg-3">
<div class="custom-control custom-switch mt-1">
<input type="checkbox" <?= ($calendars->active==1) ? 'checked="checked"' : '' ?> class="custom-control-input" value="1"
id="active" name="active">
<label class="custom-control-label no-user-select" for="active"></label>
</div>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2"></label>
<div class="col-lg-10">
<button type="submit" class="btn btn-primary">Speichern</button>
<a href="<?= self::getUrl("Calendar") ?>">
<button type="button" class="btn btn-secondary">Abbrechen</button>
</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<?php
?>
<script type="text/javascript">
$(".select2").select2({placeholder: ""});
// disable mousewheel on a input number field when in focus
$('form').on('focus', 'input[type=number]', function (e) {
$(this).on('wheel.disableScroll', function (e) {
e.preventDefault()
})
});
$('form').on('blur', 'input[type=number]', function (e) {
$(this).off('wheel.disableScroll')
});
</script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -0,0 +1,108 @@
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= date('U') ?>" rel="stylesheet"
type="text/css"/>
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="<?= self::getUrl("Dashboard") ?>"><?= MFAPPNAME_SLUG ?></a>
</li>
<li class="breadcrumb-item active">Kalender Verwaltung</li>
</ol>
</div>
<h4 class="page-title">Kalender Verwaltung</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="card">
<div class="card-body mb-3">
<div class="row">
<div class="col-12">
<div class="float-left">
<h4 class="header-title">Liste aller Kalender Verwaltung</h4>
</div>
<div class="float-right">
<a class="btn btn-primary mb-2" href="<?= self::getUrl("Calendar", "add") ?>"><i
class="fas fa-plus"></i> Neuen Kalender Verwaltung anlegen</a>
</div>
</div>
</div>
<table id="datatable" class="table table-striped table-hover table-sm">
<thead>
<tr>
<th class="text-center">Name</th>
<th class="text-center">GO Kalender ID</th>
<th class="text-center">Microsoft Id</th>
<th class="text-center">Kalenderrechte</th>
<th class="text-center">Webhook</th>
<th class="text-center">Webhook Timeout</th>
<th class="text-center">Aktiv</th>
<th class="edit-width"></th>
</tr>
<tr id="filterrow">
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach ($calendars as $calendar):
$calenadarRights = json_decode($calendar->rights, true);
$rights = "";
foreach ($calenadarRights as $key => $value) {
if ($key != $calendar->go_calendar_id) {
$rights .= $calendars[$key]->user->name . " : " . $value . "<br>";
}
}
?>
<tr>
<td><?= $calendar->user->name ?></td>
<td class="text-center"><?= $calendar->go_calendar_id ?></td>
<td class="text-nowrap"><?= $calendar->microsoft_id ?></td>
<td><?= $rights ?></td>
<td class="text-nowrap"><?= $calendar->subscription_id ?></td>
<td class="text-center"><?= ($calendar->expirationDateTime) ? date("d.m.Y H:i", $calendar->expirationDateTime) : '' ?></td>
<td class="text-center"><?= ($calendar->active==1) ? '<i class="fa-regular fa-circle-check mr-1"></i>' : '<i class="fa-regular fa-circle-xmark mr-1"></i>' ?></td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?= self::getUrl("Calendar", "edit", ["id" => $calendar->id]) ?>"><i
class="far fa-edit" title="Bearbeiten"></i></a>
<a href="<?= self::getUrl("Calendar", "delete", ["id" => $calendar->id]) ?>"
onclick="if(!confirm('Kalender Verwaltung wirklich löschen?')) return false;"
class="text-danger"
title="Löschen"><i class="fas fa-trash"></i></a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var hidesearch = [8];
$(document).ready(function () {
});
</script>
<script type="text/javascript"
src="<?= self::getResourcePath() ?>assets/js/datatables-std.js?<?= date('U') ?>"></script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -0,0 +1,656 @@
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php");
$daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
//if ($Calendar->colors) {
// $encryptedUser = $Calendar->user->id;
//} else {
// $encryptedUser = "";
//}
if ($Calendar[0]->colors) {
$Calendar_colors = json_decode($Calendar[0]->colors, true);
} else {
$encryptedUser = "";
}
$rights = json_decode($Calendar[0]->rights, true);
$colorCounter = 0;
if (!is_array($Calendar_colors[$Calendar[0]->go_calendar_id])) {
$Calendar_colors[$Calendar[0]->go_calendar_id]['bgcolor'] = $standardCalendarColors[$colorCounter];
$Calendar_colors[$Calendar[0]->go_calendar_id]['txtcolor'] = '#000000';
$colorCounter++;
}
$specialCalendars = array(999 => 'Abwesenheiten', 998 => 'Geburtstage', 997 => 'Feiertage');
foreach ($rights as $key => $right) :
$CalArray[$CalendarAll[$key]->user->name] = $key;
endforeach;
?>
<script language="JavaScript">
var firstcall = false;
</script>
<link href="<?= self::getResourcePath() ?>assets/css/select2-cstm.css?<?= $git_merge_ts ?>" rel="stylesheet"
type="text/css"/>
<link href="<?= self::getResourcePath() ?>css/pages/Calendar/View.css?<?= $git_merge_ts ?>" rel="stylesheet"
type="text/css"/>
<style>
</style>
<script type="text/javascript"
src="<?= self::getResourcePath() ?>assets/js/calendar/moment/moment.min.js?<?= $git_merge_ts ?>"></script>
<!-- <script type="text/javascript"-->
<!-- src="--><?php //= self::getResourcePath() ?><!--assets/js/calendar/index.global.min.js?--><?php //= $git_merge_ts ?><!--"</script>-->
<script src='https://cdn.jsdelivr.net/npm/fullcalendar-scheduler@6.1.15/index.global.min.js'></script>
<script src="https://raw.githack.com/SortableJS/Sortable/master/Sortable.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery-sortablejs@latest/jquery-sortable.js"></script>
<script type="text/javascript"
src="<?= self::getResourcePath() ?>assets/js/calendar/moment/index.global.min.js?<?= $git_merge_ts ?>"></script>
<script type="text/javascript"
src="<?= self::getResourcePath() ?>assets/js/calendar/locales-all.global.min.js?<?= $git_merge_ts ?>"></script>
<script type="text/javascript"
src="<?= self::getResourcePath() ?>assets/js/calendar/tooltip.min.js?<?= $git_merge_ts ?>"></script>
<script type="text/javascript"
src="<?= self::getResourcePath() ?>assets/js/calendar/eventsource.min.js?<?= $git_merge_ts ?>"></script>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= $git_merge_ts ?>" rel="stylesheet"
type="text/css"/>
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="<?= self::getUrl("Dashboard") ?>"><?= MFAPPNAME_SLUG ?></a>
</li>
<li class="breadcrumb-item active">Kalender</li>
</ol>
</div>
<h4 class="page-title">Kalender</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="card text-center">
<div class="card-body mb-3 ">
<div class="row ">
<div class="col-12">
<div class="float-left">
<h4 class="header-title">Kalender</h4>
</div>
<?php if (!$rights) : ?>
<div class="alert alert-danger" role="alert">
<span class="font-18 font-weight-500">Du wurdest nicht für den Kalender frei geschalten.</span>
</div>
<?php die(); endif; ?>
<div class="d-inline-block w-50 search-div" style="margin-top: -7px;">
<select id="jumpevent" class="jumpevent"></select>
</div>
<div class="float-right">
<i id="card-size" class="fa-regular fa-window-maximize"></i>
</div>
</div>
</div>
<div clas="row">
</div>
<div class="row ">
<div id="calendar-side-div" class="col-12 col-lg-2">
<div class="calendar-side-borders-main">
<h3 class="no-movable" data-id="<?= $Calendar[0]->id ?>" id="calendar-id">Kalender
<div class="add-cal-group-div"><i title="Kalendergruppe hinzufügen"
class="fa-duotone fa-solid fa-rectangle-history-circle-plus"></i>
</div>
</h3>
<?php
if ($Calendar[0]->groups) : ?>
<div class="add-cal-group-div-sub">
<?php
$groups = json_decode($Calendar[0]->groups, true);
foreach ($groups as $group) :
?>
<div class="calendar-side-borders-sub mb-2" data-origin="<?= $group['origin'] ?>">
<h5 data-id="<?= $group['id'] ?>" id="calendar-id"><span
class="<?= ($group['origin']) ? '' : 'cal-group-name' ?>""><?= $group['name'] ?></span>
<div class="group-checkbox-div"><input
class="form-check-input group-checkbox"
name="form-check-input" type="checkbox"></div>
<div class="move-group-div">
<i class="fa-regular fa-arrows-up-down-left-right handle"></i>
</div>
<div class="dropdown-group-div"><i
class="fa-duotone fa-solid dropdown-group <?= ($group['show']) ? 'fa-square-arrow-up' : 'fa-square-arrow-down' ?> "></i>
</div>
</h5>
<div class="calendar-side-borders-sub-inner <?= ($group['origin']) ? 'data-origin-' . $group['origin'] : '' ?>"
style="<?= ($group['show']) ? '' : 'display:none;' ?>">
<?php foreach ($group['calendars'] as $calendar) : ?>
<div class="form-check text-left ml-2"
data-origin="<?= $calendar['origin'] ?>">
<input data-calendar_id="<?= $calendar['calendar_id'] ?>"
class="form-check-input calendar-check"
name="form-check-input" type="checkbox"
<?= ($calendar['checked']) ? 'checked="checked"' : '' ?>
value="2">
<input
data-calendar_id="<?= $calendar['calendar_id'] ?>"
type="color"
class="form-control-color color-input"
value="<?= $Calendar_colors[$calendar['calendar_id']]['bgcolor'] ?>"
title="Hintergrundfarbe">
<input data-calendar_id="<?= $calendar['calendar_id'] ?>"
type="color"
class="form-control-color color-text-input"
value="<?= ($Calendar_colors[$calendar['calendar_id']]['txtcolor']) ? $Calendar_colors[$calendar['calendar_id']]['txtcolor'] : '#000000' ?>"
title="Textfarbe">
<label class="calendar-side-label" style="margin-top:2px;">
<?= ($CalendarAll[$calendar['calendar_id']]->user->name) ?: $specialCalendars[$calendar['calendar_id']] ?>
</label>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endforeach;
?>
</div>
<?php else : ?>
<script language="JavaScript">
firstcall = true;
</script>
<div class="add-cal-group-div-sub">
<div class="calendar-side-borders-sub mb-2" data-origin="1">
<h5>Persönlich
<div class="move-group-div">
<i class="fa-regular fa-arrows-up-down-left-right handle"></i>
</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 data-origin-1">
<div class="form-check text-left ml-2" data-origin="1">
<input data-calendar_id="<?= $Calendar[0]->go_calendar_id ?>"
class="form-check-input calendar-check"
name="form-check-input"
type="checkbox" checked="checked" value="2">
<input
data-calendar_id="<?= $Calendar[0]->go_calendar_id ?>" type="color"
class="form-control-color color-input"
value="<?= $Calendar_colors[$Calendar[0]->go_calendar_id]['bgcolor'] ?>"
title="Hintergrundfarbe">
<input data-calendar_id="<?= $Calendar[0]->go_calendar_id ?>" type="color"
class="form-control-color color-text-input"
value="<?= ($Calendar_colors[$Calendar[0]->go_calendar_id]['txtcolor']) ? $Calendar_colors[$Calendar[0]->go_calendar_id]['txtcolor'] : '#000000' ?>"
title="Textfarbe">
<label class="calendar-side-label" style="margin-top:2px;">
Mein Kalender
</label>
</div>
<?php
if (count($rights) > 1) :
foreach ($rights as $key => $right) :
$CalArray[$CalendarAll[$key]->user->name] = $key;
if (!is_array($Calendar_colors[$key])) {
$Calendar_colors[$key]['bgcolor'] = $standardCalendarColors[$colorCounter];
$Calendar_colors[$key]['txtcolor'] = '#ffffff';
$colorCounter++;
}
if ($key != $Calendar[0]->go_calendar_id) : ?>
<div class="form-check text-left ml-2" data-origin="1">
<input data-calendar_id="<?= $key ?>"
class="form-check-input calendar-check"
name="form-check-input" type="checkbox"
value="2">
<input
data-calendar_id="<?= $key ?>" type="color"
class="form-control-color color-input"
value="<?= $Calendar_colors[$key]['bgcolor'] ?>"
title="Hintergrundfarbe">
<input data-calendar_id="<?= $key ?>" type="color"
class="form-control-color color-text-input"
value="#000000"
title="Textfarbe">
<label class="calendar-side-label" style="margin-top:2px;">
<?= $CalendarAll[$key]->user->name ?>
</label>
</div>
<?php endif;
endforeach;
ksort($CalArray);
endif;
?>
</div>
</div>
<div class="calendar-side-borders-sub mb-2" data-origin="2">
<h5>Allgemein
<div class="move-group-div">
<i class="fa-regular fa-arrows-up-down-left-right handle"></i>
</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 data-origin-2">
<div class="form-check text-left ml-2" data-origin="2">
<input data-calendar_id="999" class="form-check-input calendar-check"
name="form-check-input"
type="checkbox" value="">
<input data-calendar_id="999" type="color"
class="form-control-color color-input"
value="<?= ($Calendar_colors[999]['bgcolor']) ?: $specialCalendarColors[999] ?>"
title="Hintergrundfarbe">
<input data-calendar_id="999" type="color"
class="form-control-color color-text-input"
value="<?= ($Calendar_colors[999]['txtcolor']) ? $Calendar_colors[999]['txtcolor'] : '#ffffff' ?>"
title="Textfarbe">
<label class="calendar-side-label" for="" style="margin-top:2px;">
Abwesenheiten
</label>
</div>
<div class="form-check text-left ml-2" data-origin="2">
<input data-calendar_id="998" class="form-check-input calendar-check"
name="form-check-input"
type="checkbox" value="">
<input data-calendar_id="998" type="color"
class="form-control-color color-input"
value="<?= ($Calendar_colors[998]['bgcolor']) ?: $specialCalendarColors[998] ?>"
title="Hintergrundfarbe">
<input data-calendar_id="998" type="color"
class="form-control-color color-text-input"
value="<?= ($Calendar_colors[998]['txtcolor']) ?: '#ffffff' ?>"
title="Textfarbe">
<label class="calendar-side-label" for="" style="margin-top:2px;">
Geburtstage
</label>
</div>
<div class="form-check text-left ml-2" data-origin="2">
<input data-calendar_id="997" class="form-check-input calendar-check"
name="form-check-input"
type="checkbox" value="">
<input data-calendar_id="997" type="color"
class="form-control-color color-input"
value="<?= ($Calendar_colors[997]['bgcolor']) ?: $specialCalendarColors[997] ?>"
title="Hintergrundfarbe">
<input data-calendar_id="997" type="color"
class="form-control-color color-text-input"
value="<?= ($Calendar_colors[997]['txtcolor']) ?: '#ffffff' ?>"
title="Textfarbe">
<label class="calendar-side-label" for="" style="margin-top:2px;">
Feiertage
</label>
</div>
</div>
</div>
</div>
<?php endif; ?>
</div>
<div>
</div>
</div>
<div id="calendar-main-div" class="col-12 col-lg-10">
<div id='calendar'></div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="EventModal" tabindex="-1" aria-labelledby="EventModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title font-18 ml-2" id="EventModalLabel"><i
class="fa-duotone fa-solid fa-calendar-symbol"></i> <span>neuer Termin</span></h1>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="row justify-content-center">
<div class="col-1">
<label for="name" class="col-form-label fw-medium ">Betreff</label>
</div>
<div class="col-6">
<div class="mb-2">
<input type="text" class="form-control is-require eventmodal-input" id="name">
</div>
</div>
<div class="col-1 text-right">
<label for="location" class="col-form-label fw-medium ">Typ</label>
</div>
<div class="col-3">
<div class="mb-2">
<select class="form-control form-select" aria-label="Default select" id="type">
<option value="1">Termin</option>
<option value="2">IBN</option>
</select>
</div>
</div>
</div>
<div class="row justify-content-center">
<div class="col-1">
<label for="location" class="col-form-label fw-medium ">Ort</label>
</div>
<div class="col-6">
<div class="mb-2">
<input type="text" class="form-control eventmodal-input" id="location">
</div>
</div>
<div class="col-1 text-right">
<label for="location" class="col-form-label fw-medium ">Anzeige</label>
</div>
<div class="col-3">
<div class="mb-2">
<select class="form-control form-select" aria-label="Default select" id="busy">
<option value="1">gebucht</option>
<option value="0">frei</option>
<option value="2">mit Vorbehalt</option>
</select>
</div>
</div>
</div>
<div class="row justify-content-center">
<div class="col-4">
<div class="input-group mb-2">
<span class="input-group-text spanwidht">Start</span>
<input id="start-date" type="date" class="form-control is-require eventmodal-input"
placeholder="Datum"
aria-label="Datum"
aria-describedby="Datum">
</div>
</div>
<div class="col-2">
<input id="start-time" type="time" class="form-control is-require eventmodal-input"
placeholder="Uhrzeit"
aria-label="Uhrzeit"
aria-describedby="Uhrzeit">
</div>
<div class="col-3 text-center">
<div class="form-check" style="margin-top: 7px;">
<input class="form-check-input eventmodal-checkbox" type="checkbox" value=""
id="allday"> <label class="form-check-label fw-medium checkbox-label" for="allday">
Ganztägig
</label>
</div>
</div>
</div>
<div class="row justify-content-center">
<div class="col-4">
<div class="input-group mb-2">
<span class="input-group-text spanwidht">Ende</span>
<input id="end-date" type="date" class="form-control is-require eventmodal-input"
placeholder="Datum"
aria-label="Datum"
aria-describedby="Datum">
</div>
</div>
<div class="col-2">
<input id="end-time" type="time" class="form-control is-require eventmodal-input"
placeholder="Uhrzeit"
aria-label="Uhrzeit"
aria-describedby="Uhrzeit">
</div>
<div class="col-3">
<div class="input-group mb-2">
<span title="Erinnerung" class="input-group-text spanwidht"><i
class="fa-regular fa-bell"></i></span>
<select class="form-control form-select select2" aria-label="Default select" id="reminder">
<option value="NULL">Keine</option>
<option value="0">Zum Termin</option>
<option value="300">5 Minuten</option>
<option value="600">10 Minuten</option>
<option value="900">15 Minuten</option>
<option value="1800">30 Minuten</option>
<option value="3600">1 Stunde</option>
<option value="86400">1 Tag</option>
<option value="604800">1 Woche</option>
</select>
</div>
</div>
</div>
<?php if (count($rights) > 1) : ?>
<div class="row justify-content-center mt-2">
<div class="col-2">
<label for="name" class="col-form-label fw-medium ">Kalender</label>
</div>
<div class="col-8">
<select class="form-control form-select select2-multiple" id="calendar-users"
name="calendar-users"
>
<?php foreach ($CalArray as $key => $value) :
if ($rights[$value] != "all") continue;
if ($value != $Calendar[0]->go_calendar_id) : ?>
<option value="<?= $value ?>"><?= $key ?></option>
<?php else : ?>
<option data-mainuser="1" selected="selected"
value="<?= $value ?>"><?= $key ?></option>
<?php endif;
endforeach; ?>
</select>
</div>
</div>
<?php endif; ?>
<div class="row justify-content-center mt-2">
<div class="col-2">
<label for="name" class="col-form-label fw-medium ">Teilnehmer</label>
</div>
<div class="col-8">
<select class="form-control form-select select2-multiple-tag" id="calendar-attendees"
name="calendar-users[]"
multiple="multiple">
<option value=""></option>
<?php foreach ($CalArray as $key => $value) :
if ($rights[$value] != "all") continue;
if ($value != $Calendar[0]->go_calendar_id) : ?>
<option value="<?= $value ?>"><?= $key ?></option>
<?php else : ?>
<?php endif;
endforeach; ?>
</select>
</div>
</div>
<div class="row mt-2 justify-content-center">
<div class="col-10">
<label for="location" class="col-form-label fw-medium">Beschreibung</label>
<textarea class="form-control eventmodal-input" id="description" rows="2"></textarea>
</div>
</div>
<div class="customer-div">
<div class="row mt-2 justify-content-center">
<div class="col-10">
<label for="location" class="col-form-label fw-medium">Kunde</label>
<div class="form-check ml-3" style="margin-top: 7px;display:inline-block">
<div class="d-inline-block">
<input class="form-check-input eventmodal-checkbox" type="checkbox" value=""
id="customer-info-check">
<label class="form-check-label fw-medium checkbox-label" for="customer-info-check">
Info senden
</label>
</div>
<div class="d-inline-block ml-2">
<div class="dropdown">
<button style="padding: 1px 8px;" class="btn btn-info dropdown-toggle"
type="button" data-toggle="dropdown" aria-expanded="false">
Vorlagen
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item text-template" data-id="1">Erstinformation</a>
</li>
<li><a class="dropdown-item text-template" data-id="2">Erinnerung</a></li>
<li><a class="dropdown-item text-template" data-id="3">Rahmeninformation</a>
</li>
</ul>
</div>
</div>
<div class="d-inline-block ml-4">
<input class="form-check-input eventmodal-checkbox" type="checkbox" value=""
id="customer-info-reminder-check">
<label class="form-check-label fw-medium checkbox-label"
for="customer-info-reminder-check">
1 Tages Reminder
</label>
</div>
<div class="d-inline-block" id="customer-info-check-info"></div>
</div>
<select id="customer" class="jumpevent"></select>
</div>
</div>
</div>
<div class="customer-div customer-info-div">
<div class="row mt-2 justify-content-center">
<div class="col-10">
<label for="location" class="col-form-label fw-medium w-100">Kundeninformation <select
id="customer-info-type"
style="display: inline-block; width: unset" class="form-control">
<option value="1">Email</option>
<option value="2">SMS</option>
</select><input id="customer-info-type-text" placeholder="E-Mail/Handynummer"
type="text"
style="display: inline-block; width: 60%"
class="form-control ml-1 eventmodal-input" id="customer"></label>
<textarea id="customer-info-text" class="form-control eventmodal-input" id="customer"
rows="5"></textarea>
</div>
</div>
</div>
<div id="documents" class="row mt-2 mb-2 justify-content-center">
<div class="col-10" id="attachments" data-newkey="">
<label class="col-form-label fw-medium">Anlagen</label>
<div class="input-group mb-2">
<div class="custom-file">
<input type="file" class="custom-file-input" id="files-input" name="files[]"
multiple>
<label class="custom-file-label" for="files-input"
aria-describedby="">Datei(en) auswählen oder hereinziehen</label>
</div>
</div>
<div class="attachment-div mb-2"></div>
<div id="uploadsts"></div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success" id="add-event">Hinzufügen</button>
<button style="display:none" type="button" class="btn btn-success show-update" id="update-event">
Speichern
</button>
<button style="display:none" type="button" class="btn btn-danger show-update" id="delete-event">
Löschen
</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Abbrechen</button>
</div>
</div>
</div>
</div>
<div id="output"></div>
<script type="text/javascript" src="<?= self::getResourcePath() ?>plugins/select2/js/i18n/de.js"></script>
<script>
let requestUrl = "<?= self::getUrl("Calendar", "api", ['do' => 'getCalendarEvents']) ?>";
let requestEventUrl = "<?= self::getUrl("Calendar", "api", ['do' => 'getCalendarEvent']) ?>";
let requestEventSearchURL = "<?= self::getUrl("Calendar", "api", ['do' => 'searchCalendarEvents']) ?>";
let requestEventAttachmentUrl = "<?= self::getUrl("Calendar", "api", ['do' => 'getCalendarEventAttachment']) ?>";
let requestEventAttachmentTmpUrl = "<?= self::getUrl("Calendar", "api", ['do' => 'getCalendarEventAttachmentTmp']) ?>";
let requestEventAttachmentTmpDeleteUrl = "<?= self::getUrl("Calendar", "api", ['do' => 'deleteCalendarEventAttachmentTmp']) ?>";
let requestEventAttachmentUploadUrl = "<?= self::getUrl("Calendar", "api", ['do' => 'uploadCalendarEventAttachment']) ?>";
let requestAddressUrl = "<?= self::getUrl("Calendar", "api", ['do' => 'getAddress']) ?>";
let requestInsertUrl = "<?= self::getUrl("Calendar", "api", ['do' => 'insertCalendarEvent']) ?>";
let requestUpdateUrl = "<?= self::getUrl("Calendar", "api", ['do' => 'updateCalendarEvent']) ?>";
let requestUpdateColorUrl = "<?= self::getUrl("Calendar", "api", ['do' => 'updateCalendarColor']) ?>";
let requestDeleteUrl = "<?= self::getUrl("Calendar", "api", ['do' => 'deleteCalendarEvent']) ?>";
let requestUpdateEventsUrl = "https://thetool-dev.xinon.at/api/v1/calendar/calendarStream?user=<?= $encryptedUser ?>";
let calendarRights = '<?php echo json_encode($rights); ?>';
var holiDays = [];
var birthdays = [];
<?php
$counter = 10000;
foreach ($timerecordingholidays as $timerecordingholiday) :?>
holiDays.push({
id: <?= $counter ?>,
start: '<?= date("Y-m-d", $timerecordingholiday->timestamp) ?>',
end: '<?= date("Y-m-d", $timerecordingholiday->timestamp) ?>',
title: '<?= $timerecordingholiday->description ?>',
backgroundColor: '<?= ($Calendar_colors[997]['bgcolor']) ? $Calendar_colors[997]['bgcolor'] : $specialCalendarColors[997] ?>',
textColor: '<?= ($Calendar_colors[997]['txtcolor']) ? $Calendar_colors[997]['txtcolor'] : '#ffffff'?>',
calendar_id: <?= json_encode(array('calendar_id' => 997, 'order' => 997)) ?>,
classNames: ['cal-class-group-997', 'cal-class-id-' + <?= $counter ?>],
resourceId: 997,
description: '<?= $timerecordingholiday->description ?>',
editable: false
});
<?php
$counter++;
endforeach;
foreach ($timerecordingemployees as $timerecordingemployee) :
if ($timerecordingemployee->birthday) :
$year = date("Y", time());
$year = $year - 1;
$Byear = date("Y", $timerecordingemployee->birthday);
for ($i = 0; $i < 5; $i++) :
$age = $year - $Byear;
?>
birthdays.push({
id: <?= $counter ?>,
start: '<?= date("$year-m-d", $timerecordingemployee->birthday) ?>',
end: '<?= date("$year-m-d", $timerecordingemployee->birthday) ?>',
title: '<?= $timerecordingemployee->user->name ?> (<?= $age ?>)',
backgroundColor: '<?= ($Calendar_colors[998]['bgcolor']) ?: $specialCalendarColors[998] ?>',
textColor: '<?= ($Calendar_colors[998]['txtcolor']) ?: '#ffffff'?>',
calendar_id: <?= json_encode(array('calendar_id' => 998, 'order' => 998)) ?>,
classNames: ['cal-class-group-998', 'cal-class-id-' + <?= $counter ?>],
resourceId: 998,
description: 'Geburtstag <?= $timerecordingemployee->user->name ?> (<?= $age ?>)',
editable: false
});
<?php
$year++;
endfor;
$counter++;
endif;
endforeach; ?>
</script>
<script type="text/javascript"
src="<?= self::getResourcePath() ?>js/pages/Calendar/View.js?<?= $git_merge_ts ?>"></script>
<script type="text/javascript"
src="<?= self::getResourcePath() ?>assets/js/datatables-std.js?<?= $git_merge_ts ?>"></script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -0,0 +1,213 @@
<?php
class CalendarApicontroller extends mfBaseApicontroller
{
protected function init()
{
$this->addRoute("/calendar/calendarStream", "calendarStream", "GET");
$this->addRoute("/calendar/calendarNotify", "calendarNotify", "POST");
$this->addRoute("/calendar/calendarUserSubscriptions", "getcalendarUserSubscriptions", "GET");
$this->addRoute("/calendar/calendarUserSubscriptions", "updatecalendarUserSubscriptions", "POST");
$this->addRoute("/calendar/calendarUsers", "getcalendarUsers", "GET");
}
protected function calendarNotify()
{
$myfile = fopen(__DIR__ . "/../../../var/log/microsoft_notify_log.txt", "a") or die("Unable to open file!");
$get = json_encode($_GET);
fwrite($myfile, "\nGET: " . $get);
$post = serialize($_POST);
fwrite($myfile, "\nPOST: " . $post);
if ($_GET['validationToken']) {
echo $_GET['validationToken'];
die();
}
$input = file_get_contents('php://input');
fwrite($myfile, "\nINPUT: " . $input);
$result = 'ok';
CalendarModel::insertMicrosoftCalendarEvent($input);
die();
}
protected function getcalendarUsers()
{
$users = UserModel::search(['employee' => 'true']);
$json['data'] = $users;
$json['status'] = "success";
$result = json_encode($json);
echo $result;
die();
}
protected function getcalendarUserSubscriptions()
{
if ($_GET['onlymsuser']) {
$userSubscriptions = CalendarModel::search(array("checkSubscriptions" => 1));
} else {
$userSubscriptions = CalendarModel::getAll();
}
$json['data'] = $userSubscriptions;
$json['status'] = "success";
$result = json_encode($json);
echo $result;
die();
}
protected function updatecalendarUserSubscriptions()
{
$id = $this->post['id'];
$user_id = $this->post['user_id'];
$go_calendar_id = $this->post['go_calendar_id'];
$microsoft_id = $this->post['microsoft_id'];
$subscription_id = $this->post['subscription_id'];
$expirationDateTime = $this->post['expirationDateTime'];
$Calendar = new Calendar($id);
if (!($Calendar->id) || $Calendar->id != $id) {
$mode = "add";
} else {
$mode = "update";
}
$data = [];
if ($user_id) {
$data['user_id'] = $user_id;
}
if ($go_calendar_id) {
$data['go_calendar_id'] = $go_calendar_id;
}
if ($microsoft_id) {
$data['microsoft_id'] = $microsoft_id;
}
if ($subscription_id) {
$data['subscription_id'] = $subscription_id;
}
if ($expirationDateTime) {
$data['expirationDateTime'] = $expirationDateTime;
}
if ($mode == "add") {
$data['create_by'] = '154';
}
$data['edit_by'] = '154';
$Calendar->update($data);
$Calendar->save();
$json['status'] = "success";
$result = json_encode($json);
echo $result;
die();
}
protected function decryptString($cipherText, $password, $salt)
{
// Definiere den Algorithmus und die Länge des Initialisierungsvektors
$cipher = "aes-256-cbc";
$ivlen = openssl_cipher_iv_length($cipher);
// Dekodiere den verschlüsselten Text von base64
$cipherText = base64_decode($cipherText);
// Extrahiere den Initialisierungsvektor und den verschlüsselten Text
$iv = substr($cipherText, 0, $ivlen);
$cipherText = substr($cipherText, $ivlen);
// Erzeuge einen Schlüssel aus dem Passwort und dem Salt
$key = hash_pbkdf2("sha256", $password, $salt, 1000, 32, true);
// Entschlüssele den Text
$plainText = openssl_decrypt($cipherText, $cipher, $key, 0, $iv);
return $plainText;
}
protected function calendarStream()
{
$decstring = $this->decryptString($_GET['user'], "testpw", "testsalt");
date_default_timezone_set('Europe/Berlin');
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
header('Connection: keep-alive');
$timestamp = time();
$Calendar = CalendarModel::search(array("user_id" => $decstring));
$rights = json_decode($Calendar[0]->rights, true);
if (!$Calendar[0]->rights) {
$allowedCalendar[] = $Calendar[0]->calendar_id;
} else {
foreach (json_decode($Calendar[0]->rights, true) as $key => $value) {
$allowedCalendar[] = $key;
}
}
if ($Calendar[0]->colors) {
$calendarColors = json_decode($Calendar[0]->colors, true);
}
$redis = new Redis();
//Connecting to Redis
$redis->connect('172.16.5.5', '6379');
//$redis->auth('password');
$oldoutput = "";
$now = floor(microtime(true) * 1000);
$timenow = time();
while (true) {
$colors = $redis->get('thetool_calendar_usercolors_' . $decstring);
if ($colors) {
$calendarColors = json_decode($colors, true);
}
$output = $redis->get('thetool_calendar_event_tigger');
$json = json_decode($output, true);
$message[0] = $json;
if ($json['time'] > $now && $output !== $oldoutput) {
$timenow = time();
// $Calendar=CalendarModel::getCalendarEvents($decstring, $json['cal_events_id']);
$Calendarevent = json_decode(CalendarModel::getCalendarEvents($decstring, $json['cal_events_id']), true);
if ($json['all_day_event'] == 1) {
$message[0]['start_time'] = date('Y-m-d', $json['start_time']);
$message[0]['end_time'] = date('Y-m-d', $json['end_time']);
} else {
$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]['event_type'] = $Calendarevent['data'][0]['event_type']['event_type'];
$message[0]['attachment'] = $Calendarevent['data'][0]['attachment']['attachment'];
$message[0]['attachments'] = $Calendarevent['data'][0]['attachments']['attachments'];
$message[0]['calendar_name'] = $Calendarevent['data'][0]['calendar_name']['calendar_name'];
$message[0]['mtime'] = $Calendarevent['data'][0]['mtime']['mtime'];
$message[0]['mname'] = $Calendarevent['data'][0]['mname']['mname'];
$message[0]['ctime'] = $Calendarevent['data'][0]['ctime']['ctime'];
$message[0]['cname'] = $Calendarevent['data'][0]['cname']['cname'];
$message[0]['busy'] = $Calendarevent['data'][0]['busy']['busy'];
$message[0]['calendar_id_check'] = array('calendar_id' => $json['calendar_id'], 'order' => $json['calendar_id']);;
$message[0]['userr'] = $Calendar[0]->calendar_id;
$message[0]['bgColor'] = $calendarColors[$json['calendar_id']]['bgcolor'];
$message[0]['txtColor'] = $calendarColors[$json['calendar_id']]['txtcolor'];
$message[0]['rights'] = $rights[$json['calendar_id']];
$result = json_encode($message);
if (in_array($message[0]['calendar_id'], $allowedCalendar)) {
echo "data: " . ($result) . "\n\n";
}
unset($Array);
$now = floor(microtime(true) * 1000);;
}
if (ob_get_level() > 0) {
ob_flush();
}
if ($timenow + 300 < time()) {
die();
}
flush();
if (connection_aborted()) die();
usleep(100000);
$oldoutput = $output;;
}
die();
}
}

View File

@@ -0,0 +1,60 @@
<?php
class Calendar extends mfBaseModel
{
private $editor;
private $creator;
private $user;
public function getProperty($name)
{
if ($this->$name == null) {
if (!$this->id) {
return null;
}
if ($name == "creator") {
$this->creator = mfValuecache::singleton()->get("Worker-id-" . $this->create_by);
if ($this->creator === null) {
$this->creator = new User($this->create_by);
if ($this->creator->id) {
mfValuecache::singleton()->set("Worker-id-" . $this->create_by, $this->creator);
}
}
return $this->creator;
}
if ($name == "editor") {
$this->editor = mfValuecache::singleton()->get("Worker-id-" . $this->edit_by);
if ($this->editor === null) {
$this->editor = new User($this->edit_by);
if ($this->editor->id) {
mfValuecache::singleton()->set("Worker-id-" . $this->edit_by, $this->editor);
}
}
return $this->editor;
}
$classname = ucfirst($name);
$idfield = $name . "_id";
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-" . $this->$idfield);
if (!$this->$name) {
$this->$name = new $classname($this->$idfield);
}
if ($this->$name->id) {
mfValuecache::singleton()->set("mfObjectmodel-$name-" . $this->$name->id, $this->$name);
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}

View File

@@ -0,0 +1,435 @@
<?php
class CalendarController extends mfBaseController
{
protected function init()
{
$this->needlogin = true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me", $me);
if (!$me->is(["Admin"])) {
$this->redirect("Dashboard");
}
}
protected function detailAction()
{
$this->layout()->setTemplate("Calendar/Detail");
}
protected function apiAction()
{
if (!$this->me->is(["Admin"])) {
$return = false;
}
$do = $this->request->do;
switch ($do) {
case "getCalendarEvents":
$r = $this->request;
$calendarEvents = CalendarModel::getCalendarEvents($this->me->id, 0, $r);
return $calendarEvents;
die();
case "getCalendarEvent":
$r = $this->request;
$id = ($r->id);
$calendarEvents = CalendarModel::getCalendarEvent($id);
return $calendarEvents;
die();
case "searchCalendarEvents" :
$r = $this->request;
$calendarEvents = CalendarModel::searchCalendarEvents($r);
return $calendarEvents;
die();
case "getCalendarEventAttachment" :
$r = $this->request;
$id = ($r->id);
$this->getCalendarAttachment($id);
die();
case "getCalendarEventAttachmentTmp" :
$r = $this->request;
$id = ($r->id);
$name = ($r->name);
$this->getCalendarAttachmentTmp($id, $name);
die();
case "updateCalendarEvent":
$r = $this->request;
$calendarEvents = CalendarModel::updateCalendarEvent($r, $this->me);
if ($r->customer_info_check) {
if ($r->customer_info_type == 1) {
$body = $r->customer_info_text;
$email = new Emailnotification();
$email->setSubject('Inbetriebnahme');
$email->setBody($body);
$email->setFrom('termin@xinon.at', 'Terminbestätigung');
$email->setTo($r->customer_info_type_text);
$email->send();
} else if ($r->customer_info_type == 2) {
$sms = new SmsNotification();
$body = "Xinon Terminbestätigung:" . PHP_EOL . $r->customer_info_text;
$sms->setBody($body);
$sms->setRecipient($r->customer_info_type_text);
$sms->send();
}
}
die();
case "getAddress":
$r = $this->request;
$this->getAddress($r);
die();
case "insertCalendarEvent":
$r = $this->request;
$calendarEvents = CalendarModel::insertCalendarEvent($r, $this->me);
if ($r->customer_info_check) {
if ($r->customer_info_type == 1) {
$body = $r->customer_info_text;
$email = new Emailnotification();
$email->setSubject('Inbetriebnahme');
$email->setBody($body);
$email->setFrom('termin@xinon.at', 'Terminbestätigung');
$email->setTo($r->customer_info_type_text);
$email->send();
} else if ($r->customer_info_type == 2) {
$sms = new SmsNotification();
$body = "Xinon Terminbestätigung:" . PHP_EOL . $r->customer_info_text;
$sms->setBody($body);
$sms->setRecipient($r->customer_info_type_text);
$sms->send();
}
}
die();
case "deleteCalendarEvent":
$r = $this->request;
$id = ($r->id);
CalendarModel::deleteCalendarEvent($r);
die();
case "updateCalendarColor":
$r = $this->request;
$calendar_id = ($r->calendar_id);
$bgcolors = ($r->bgcolors);
$txtcolors = ($r->txtcolors);
$id = ($r->id);
$this->updateCalendarColor($id, $calendar_id, $bgcolors, $txtcolors);
die();
case "uploadCalendarEventAttachment":
$r = $this->request;
$filename = $_FILES['upload_file']['name'];
$filesize = $_FILES['upload_file']['size'];
$file_content = file_get_contents($_FILES['upload_file']['tmp_name']);
$filetype = $_FILES['upload_file']['type'];
$file_content = base64_encode($file_content);
$newkey = $r->newkey;
$id = CalendarModel::insertCalendarEventAttachmentTemp($filename, $filetype, $file_content, $filesize, $newkey);
if ($id) {
$json['success'] = true;
$json['id'] = $id;
}
$json = json_encode($json);
echo $json;
die();
case "deleteCalendarEventAttachmentTmp":
$r = $this->request;
$newkey = ($r->newkey);
$name = ($r->name);
CalendarModel::deleteCalendarEventAttachmentTemp($newkey, $name);
die();
default:
$return = false;
}
}
protected function encryptString($plainText, $password, $salt)
{
// Definiere den Algorithmus und die Länge des Initialisierungsvektors
$cipher = "aes-256-cbc";
$ivlen = openssl_cipher_iv_length($cipher);
// Generiere einen Initialisierungsvektor
$iv = openssl_random_pseudo_bytes($ivlen);
// Erzeuge einen Schlüssel aus dem Passwort und dem Salt
$key = hash_pbkdf2("sha256", $password, $salt, 1000, 32, true);
// Verschlüssele den String
$cipherText = openssl_encrypt($plainText, $cipher, $key, 0, $iv);
// Füge den IV an den verschlüsselten Text an, da dieser für die Entschlüsselung benötigt wird
$cipherText = base64_encode($iv . $cipherText);
return $cipherText;
}
protected function updateCalendarColor($id, $calendar_id, $bgcolors, $txtcolors)
{
$r = $this->request;
$groups = $r->groups;
$redis = new Redis();
//Connecting to Redis
$redis->connect('172.16.5.5', '6379');
//$redis->auth('password');
$Calendar = new Calendar($id);
foreach ($bgcolors as $key => $value) {
$colordata[$calendar_id[$key]]['bgcolor'] = $value;
$colordata[$calendar_id[$key]]['txtcolor'] = $txtcolors[$key];
}
$Calendar->colors = json_encode($colordata);
if ($groups) {
$Calendar->groups = $groups;
}
$redis->set('thetool_calendar_usercolors_' . $this->me->id, json_encode($colordata));
$Calendar->save();
die();
}
protected function viewAction()
{
$Calendar = CalendarModel::search(array("user_id" => $this->me->id));
$CalendarAll = CalendarModel::getAll();
$encryptedUser = $this->encryptString($this->me->id, "testpw", "testsalt");
$this->layout()->set("Calendar", $Calendar);
$this->layout()->set("CalendarAll", $CalendarAll);
$this->layout()->set("encryptedUser", $encryptedUser);
$timerecordingholidays = TimerecordingHolidayModel::getAll();
$this->layout()->set("timerecordingholidays", $timerecordingholidays);
$timerecordingemployees = TimerecordingEmployeeModel::getAll();
$standardCalendarColors = CalendarModel::$standardCalendarColors;
$specialCalendarColors = CalendarModel::$specialCalendarColors;
$this->layout()->set("timerecordingemployees", $timerecordingemployees);
$this->layout()->set("standardCalendarColors", $standardCalendarColors);
$this->layout()->set("specialCalendarColors", $specialCalendarColors);
$this->layout()->setTemplate("Calendar/View");
}
private function getCalendarAttachment($id)
{
$content = CalendarModel::getCalendarEventAttachment($id);
//
// header('Content-Type: application/octet-stream');
header('Content-Type: ' . $content['contentType']);
header('Content-disposition: attachment; filename="' . $content['name'] . '"');
echo base64_decode($content['content']);
exit;
}
private function getCalendarAttachmentTmp($id, $name)
{
$content = CalendarModel::getCalendarEventAttachmentTmp($id, $name);
//
// header('Content-Type: application/octet-stream');
header('Content-Type: ' . $content['contentType']);
header('Content-disposition: attachment; filename="' . $content['name'] . '"');
echo base64_decode($content['content']);
exit;
}
private function getAddress($r)
{
$address = AddressModel::search(array("Controller!" => 'Calendar', "search_term!" => $r->term), array('count' => '20'));
$mobiles = CalendarModel::$austrian_mobile_prefixes;
$prefixes = array('0043', '43 ', '43', '0');
foreach ($address as $key => $value) {
unset($mobilenumber);
$id = $value->id;
if ($value->company) {
$text = "(F) " . $value->company;
} else {
$text = "(P) " . $value->firstname . " " . $value->lastname;
}
if ($value->mobile) {
foreach ($mobiles as $mobile) {
foreach ($prefixes as $prefix) {
if (strpos($value->mobile, $prefix . $mobile) !== false) {
$mobilenumber = str_replace($prefix . $mobile, '+43' . $mobile, $value->mobile);
$found = 1;
break;
}
}
if ($found) {
break;
}
}
}
if ($value->phone) {
foreach ($mobiles as $mobile) {
foreach ($prefixes as $prefix) {
if (strpos($value->phone, $prefix . $mobile) !== false) {
$mobilenumber = str_replace($prefix . $mobile, '+43' . $mobile, $value->phone);
$found = 1;
break;
}
}
if ($found) {
break;
}
}
}
if ($mobilenumber) {
if (strlen($mobilenumber) > 0 && strlen($mobilenumber) < 22) {
$mobilenumber = str_replace(" ", "", $mobilenumber);
$mobilenumber = str_replace("(", "", $mobilenumber);
$mobilenumber = str_replace(")", "", $mobilenumber);
$mobilenumber = str_replace("-", "", $mobilenumber);
$mobilenumber = str_replace("/", "", $mobilenumber);
$mobilenumber = str_replace(".", "", $mobilenumber);
$mobilenumber = str_replace(",", "", $mobilenumber);
$mobilenumber = str_replace(";", "", $mobilenumber);
$mobilenumber = str_replace(":", "", $mobilenumber);
}
} else if ($value->mobile) {
$mobilenumber = $value->mobile;
} else if ($value->phone) {
$mobilenumber = $value->phone;
} else {
$mobilenumber = "";
}
$rows[] = array(
'id' => $id,
'text' => $value->customer_number . " " . $text . " - " . $value->street . ", " . $value->zip . " " . $value->city,
'mail' => $value->email,
'mobilenumber' => $mobilenumber,
'location' => $value->street . ", " . $value->zip . " " . $value->city,
'name' => $value->customer_number . " " . $text
);
}
$json['incomplete_results'] = false;
$json['total_count'] = count($rows);
$json['items'] = $rows;
$json = json_encode($json);
echo trim($json);
die();
}
protected function indexAction()
{
$this->layout()->setTemplate("Calendar/Index");
$calendars = CalendarModel::getAll();
$this->layout()->set("calendars", $calendars);
}
protected function addAction()
{
$users = UserModel::getAll();
$this->layout()->set("users", $users);
$this->layout()->setTemplate("Calendar/Form");
}
protected function editAction()
{
$id = $this->request->id;
if (!is_numeric($id) || !$id) {
$this->layout()->setFlash("Kalender Verwaltung nicht gefunden", "error");
$this->redirect("Calendar");
}
$calendars = new Calendar($id);
if ($calendars->id != $id) {
$this->layout()->setFlash("Kalender Verwaltung nicht gefunden", "error");
$this->redirect("Calendar");
}
$this->layout()->set("calendars", $calendars);
return $this->addAction();
}
protected function saveAction()
{
$r = $this->request;
$id = $r->id;
//var_dump($r->get());exit;
if (is_numeric($id) && $id > 0) {
$mode = "edit";
$calendars = new Calendar($id);
if (!$calendars->id) {
$this->layout()->setFlash("Kalender Verwaltung nicht gefunden", "error");
$this->redirect("Calendar");
}
} else {
$mode = "add";
}
$data = [];
if ($mode == "add") {
$data['user_id'] = trim($r->user_id);
if (!$data['user_id']) {
$this->layout()->setFlash("Name darf nicht leer sein", "error");
$this->redirect("Calendar");
}
}
$data['go_calendar_id'] = trim($r->go_calendar_id);
$data['microsoft_id'] = trim($r->microsoft_id);
// $data['rights'] = trim($r->rights);
// $data['colors'] = trim($r->colors);
// $data['subscription_id'] = trim($r->subscription_id);
// $data['expirationDateTime'] = trim($r->expirationDateTime);
$data['active'] = trim($r->active);
if (!$data['go_calendar_id']) {
$data['go_calendar_id'] = NULL;
}
if (!$data['microsoft_id']) {
$data['microsoft_id'] = NULL;
}
if (!$data['active']) {
$data['active'] = '0';
}
if ($mode == "edit") {
$calendars->update($data);
} else {
$calendars = CalendarModel::create($data);
}
$id = $calendars->save();
if (!$id) {
$this->layout()->setFlash("Kalender Verwaltung konnte nicht angelegt werden", "error");
$this->redirect("Calendar");
}
if ($mode == "edit") {
$this->layout()->setFlash("Kalender Verwaltung erfolgreich geändert", "success");
} else if ($mode = "add") {
$this->layout()->setFlash("Kalender Verwaltung erfolgreich angelegt", "success");
}
$this->redirect("Calendar");
}
protected function deleteAction()
{
$id = $this->request->id;
$calendars = new Calendar($id);
if (!$calendars->id || $calendars->id != $id) {
$this->layout()->setFlash("Kalender Verwaltung nicht gefunden.", "error");
$this->redirect("Calendar");
}
$calendars->delete();
$this->redirect("Calendar");
}
}

View File

@@ -0,0 +1,792 @@
<?php
class CalendarModel
{
private $user_id;
private $go_calendar_id;
private $microsoft_id;
private $rights;
private $colors;
private $groups;
private $subscription_id;
private $expirationDateTime;
private $active;
public static $austrian_mobile_prefixes = array(
'650', // Tele2 / Magenta
'651', // A1 (ehemals T-Mobile)
'652', // 3 Hutchison
'653', // Lycamobile
'655', //
'660', // T-Mobile / Magenta
'662', // tele.ring (nun Magenta)
'663', // tele.ring (nun Magenta)
'664', // A1
'670', // HOT (HoT - Hofer Telekom)
'676', // A1
'677', // Yesss! (A1)
'678', // Ventocom (Spusu)
'680', // Spusu
'681', // Spusu
'688', // Educom
'690', // Spusu
'699' // 3 (Drei)
);
public static $standardCalendarColors = [
'#b3d5f3', '#d0e2c0', '#bac2d4', '#c6d4c0', '#e3e3e3',
'#acdce5', '#cdb6c0', '#aae0e1', '#d9d9d9', '#d9e5d5',
'#c8a7d5', '#aad8d0', '#dcadc3', '#d9e8e5', '#e4d8d5',
'#b4dcc5', '#b9d1e2', '#a3c1c2', '#cdd2b9', '#e3c8ce',
'#aae2c5', '#c7d0cc', '#d0c0da', '#dbdfc8', '#b4e3d7',
'#c3e4e3', '#c5c4e3', '#d0b7e5', '#b6e98c', '#e3d1de'
];
public static $specialCalendarColors = array(997 => '#bd0000', 998 => '#8000A3', 999 => '#08769b');
public static function dbKalender()
{
if (!TT_CALENDAR_ENABLE) {
$json['errormessage'] = "Calendar is is disabled.";
$json['success'] = false;
$json = json_encode($json);
echo trim($json);
die();
}
$db = FronkDB::singleton(TT_CALENDAR_HOSTNAME, TT_CALENDAR_USERNAME, TT_CALENDAR_PASSWORD, TT_CALENDAR_DATABASE);
return $db;
}
public static function searchCalendarEvents($r)
{
$dbcal = self::dbKalender();
$termstring = trim($r->term);
$termExplode = explode(" ", $termstring);
$where = "";
foreach ($termExplode as $term) {
$where .= " AND (name LIKE '%" . $term . "%' OR location LIKE '%" . $term . "%') ";
}
$res = $dbcal->select("cal_events", "id, uuid, calendar_id, user_id, start_time, end_time, timezone, all_day_event, name, description, location, repeat_end_time, reminder, ctime, mtime, muser_id, busy, status, resource_event_id, private, rrule, background, files_folder_id, read_only, category_id, exception_for_event_id, recurrence_id, is_organizer,event_type", "1=1 $where ORDER BY name");
while ($data = $dbcal->fetch_array($res)) {
if ($data['location']) {
$searchName = $data['name'] . " @" . $data['location'];
} else {
$searchName = $data['name'];
}
$id = $data['id'] . ";" . date("Y-m-d", $data['start_time']);
$rows[] = array(
'id' => $id,
'text' => $searchName . " (" . date("Y-m-d", $data['start_time']) . ")"
);
}
$json['incomplete_results'] = false;
$json['total_count'] = count($rows);
$json['items'] = $rows;
$json = json_encode($json);
echo trim($json);
die();
}
public static function getCalendarEvents($me, $id = 0, $r = 0)
{
$calendar = self::search(array("user_id" => $me));
$standardCalendarColors = CalendarModel::$standardCalendarColors;
$calendarColors = json_decode($calendar[0]->colors, true);
$calenderRights = json_decode($calendar[0]->rights, true);
$colorCounter = 0;
foreach ($calenderRights as $key => $value) {
if (!$calendarColors[$key]['bgcolor']) {
$calendarColors[$key]['bgcolor'] = $standardCalendarColors[$colorCounter];;
$calendarColors[$key]['txtcolor'] = '#000';
$colorCounter++;
}
}
$dbcal = self::dbKalender();
$req = $dbcal->select("cal_events_attachments", "id,cal_events_id,name,size,contentType", "");
$oldcalevent = "";
while ($data = $dbcal->fetch_array($req)) {
if ($oldcalevent != $data['cal_events_id']) {
$counter = 0;
}
$attachments[$data['cal_events_id']]['attachments'][$counter]['name'] = $data['name'];
$attachments[$data['cal_events_id']]['attachments'][$counter]['id'] = $data['id'];
$attachments[$data['cal_events_id']]['attachments'][$counter]['size'] = $data['size'];
$attachments[$data['cal_events_id']]['attachments'][$counter]['contentType'] = $data['contentType'];
$oldcalevent = $data['cal_events_id'];
$counter++;
}
if ($id != 0) {
$where = " AND `cal_events`.id='" . $id . "'";
} else {
$where = "";
}
$visibleCalendars = $r->visibleCalendars;
if ($visibleCalendars) {
$where .= " AND calendar_id IN (" . implode(",", $visibleCalendars) . ")";
}
$sql = "SELECT `cal_events`.id, uuid, calendar_id, `cal_events`.user_id, start_time, end_time, timezone, all_day_event, `cal_events`.name,`cal_calendars`.name calendar_name, description, location, repeat_end_time, reminder, ctime,cname, mtime,mname, muser_id, busy, status, resource_event_id, private, rrule, `cal_events`.background, `cal_events`.files_folder_id, read_only, category_id, exception_for_event_id, recurrence_id, is_organizer,event_type,busy FROM cal_events INNER JOIN `cal_calendars` ON (`cal_calendars`.`id`=`cal_events`.`calendar_id`) WHERE 1=1 $where ";
$res = $dbcal->query($sql);
if ($dbcal->num_rows($res)) {
while ($data = $dbcal->fetch_array($res)) {
if ($attachments[$data['uuid']]) {
$attachment = 1;
$attachmentLinks = json_encode($attachments[$data['uuid']]['attachments']);
} else {
$attachment = 0;
$attachmentLinks = "";
}
if ($data['all_day_event'] == 1) {
if (strpos($data['name'], "Bereitschaft") === false && strpos($data['name'], "Blocker") === false) {
continue;
}
$starttime = date("Y-m-d", $data['start_time']);
$endtime = date("Y-m-d", $data['end_time']);
} else {
$starttime = date("Y-m-d H:i", $data['start_time']);
$endtime = date("Y-m-d H:i", $data['end_time']);
}
if (!empty($fetch['location'])) {
$name = $data['name'] . " @ " . $data['location'];
} else {
$name = $data['name'];
}
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 ($calenderRights[$data['calendar_id']]) {
$rights = $calenderRights[$data['calendar_id']];
$rows[] = array(
'id' => array('id' => $data['id']),
'cstart' => array('cstart' => $starttime),
'cend' => array('cend' => $endtime),
'ccategory' => array('ccategory' => $name),
'category' => array('category' => $name),
'calendar_id' => array('calendar_id' => $data['calendar_id']),
'bgColor' => array('bgColor' => $bgcolor),
'txtColor' => array('txtColor' => $txtcolor),
'rights' => array('rights' => $rights, 'order' => $rights),
'location' => array('location' => $data['location']),
'busy' => array('busy' => $data['busy']),
'event_type' => array('event_type' => $data['event_type']),
'description' => array('description' => ($data['description'])),
'attachment' => array('attachment' => $attachment),
'attachments' => array('attachments' => $attachmentLinks),
'calendar_name' => array('calendar_name' => $data['calendar_name']),
'ctime' => array('ctime' => date("d.m.Y H:i", $data['ctime'])),
'cname' => array('cname' => $data['cname']),
'mtime' => array('mtime' => date("d.m.Y H:i", $data['mtime'])),
'mname' => array('mname' => $data['mname']),
'busy' => array('busy' => $data['busy']),
);
}
}
$json['success'] = true;
$json['data'] = $rows;
} else {
$json['success'] = true;
$json['errormessage'] = "No data found.";
}
$json = json_encode($json);
if ($id == 0) {
echo trim($json);
die();
} else {
return $json;
}
}
public static function getCalendarEventAttachment($id)
{
$return = array();
$dbcal = self::dbKalender();
$req = $dbcal->select("cal_events_attachments", "id, cal_events_id,name,contentType,content,size", "1=1 AND id='" . $id . "' ORDER BY id");
if ($dbcal->num_rows($req)) {
$data = $dbcal->fetch_array($req);
$return = $data;
}
return $return;
}
public static function getCalendarEventAttachmenttmp($id, $name)
{
$return = array();
$dbcal = self::dbKalender();
$req = $dbcal->select("tmp_cal_events_attachments", "id,name,contentType,content,size", "1=1 AND newkey='" . $id . "' AND name='" . $name . "' ORDER BY id");
if ($dbcal->num_rows($req)) {
$data = $dbcal->fetch_array($req);
$return = $data;
}
return $return;
}
public static function getCalendarEvent($id)
{
$calendar = self::search(array("user_id" => $me));
$dbcal = self::dbKalender();
$res = $dbcal->select("cal_events", "id, uuid, calendar_id, user_id, start_time, end_time, timezone, all_day_event, name, description, location, repeat_end_time, reminder, ctime, mtime, muser_id, busy, status, resource_event_id, private, rrule, background, files_folder_id, read_only, category_id, exception_for_event_id, recurrence_id, is_organizer,event_type,customer,customer_info,customer_info_send,customer_info_reminder,busy,attendees,is_organizer", "1=1 AND id='" . $id . "' ORDER BY id");
if ($dbcal->num_rows($res)) {
$data = $dbcal->fetch_array($res);
$attachment = 0;
if ($data['all_day_event'] == 1) {
$starttime = date("Y-m-d", $data['start_time']);
$endtime = date("Y-m-d", $data['end_time']);
} else {
$starttime = date("Y-m-d H:i", $data['start_time']);
$endtime = date("Y-m-d H:i", $data['end_time']);
}
if (!empty($fetch['location'])) {
$name = $data['name'] . " @ " . $data['location'];
} else {
$name = $data['name'];
}
$req = $dbcal->select("cal_events_attachments", "id, cal_events_id,name,contentType,size", "1=1 AND cal_events_id='" . $data['uuid'] . "' ORDER BY id");
$counter = 0;
$contentType['application/pdf'] = 'fa-file-pdf';
$contentType['application/vnd.openxmlformats-officedocument.wordprocessingml.document'] = 'fa-file-doc';
$contentType['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'] = 'fa-file-xls';
$contentType['application/octet-stream'] = 'fa-file-csv';
$contentType['text/csv'] = 'fa-file-csv';
$contentType['application/vnd.openxmlformats-officedocument.presentationml.presentation'] = 'fa-file-ppt';
$contentType['application/zip'] = 'fa-file-zip';
$contentType['application/x-zip-compressed'] = 'fa-file-zip';
$contentType['application/x-rar-compressed'] = 'fa-file-archive';
$contentType['application/x-7z-compressed'] = 'fa-file-archive';
$contentType['application/x-tar'] = 'fa-file-archive';
$contentType['application/x-gzip'] = 'fa-file-archive';
$contentType['application/x-bzip2'] = 'fa-file-archive';
$contentType['text/xml'] = 'fa-file-xml';
$contentType['application/xml'] = 'fa-file-xml';
$contentType['audio/mpeg'] = 'fa-file-mp3';
$contentType['application/x-7z-compressed'] = 'fa-file-archive';
$contentType['image/png'] = 'fa-file-png';
$contentType['image/jpeg'] = 'fa-file-jpg';
while ($dataAttachments = $dbcal->fetch_array($req)) {
$attachment = 1;
$attachments[$counter]['name'] = $dataAttachments['name'];
$attachments[$counter]['contentType'] = $dataAttachments['contentType'];
$attachments[$counter]['size'] = $dataAttachments['size'];
$attachments[$counter]['id'] = $dataAttachments['id'];
if ($contentType[$dataAttachments['contentType']]) {
$attachments[$counter]['icon'] = $contentType[$dataAttachments['contentType']];
} else {
$attachments[$counter]['icon'] = 'fa-file';
}
$counter++;
}
$rows = array(
'id' => array('id' => $data['id'], 'order' => $data['id']),
'cstart' => array('cstart' => $starttime, 'order' => $data['ctime']),
'cend' => array('cend' => $endtime, 'order' => $data['mtime']),
'ccategory' => array('ccategory' => $name, 'order' => $data['name']),
'category' => array('category' => $name, 'order' => $data['name']),
'calendar_id' => array('calendar_id' => $data['calendar_id'], 'order' => $data['calendar_id']),
'location' => array('location' => $data['location'], 'order' => $data['location']),
'description' => array('description' => $data['description'], 'order' => $data['description']),
'reminder' => array('reminder' => $data['reminder'], 'order' => $data['reminder']),
'busy' => array('busy' => $data['busy'], 'order' => $data['busy']),
'type' => array('type' => $data['event_type'], 'order' => $data['event_type']),
'customer' => array('customer' => $data['customer']),
'customer_info' => array('customer_info' => $data['customer_info']),
'customer_info_send' => array('customer_info_send' => $data['customer_info_send']),
'customer_info_reminder' => array('customer_info_reminder' => $data['customer_info_reminder']),
'isorganizer' => array('isorganizer' => $data['is_organizer']),
'attendees' => array('attendees' => $data['attendees']),
'attachment' => array('attachment' => $attachment, 'order' => $attachment),
'attachments' => array('attachments' => $attachments, 'order' => $attachments)
);
$json['success'] = true;
$json['data'] = $rows;
} else {
$json['success'] = false;
$json['errormessage'] = "No data found.";
}
$json = json_encode($json);
echo trim($json);
die();
}
public static function insertMicrosoftCalendarEvent($request)
{
$db = self::dbKalender();
$json_data = json_decode($request, true);
$data = [];
$data['ms_event_id'] = $json_data['value'][0]['resourceData']['id'];
$msUserIdExplode = explode("/", $json_data['value'][0]['resource']);
$data['ms_user_id'] = trim($msUserIdExplode[1]);
$Calendar = self::search(array("microsoft_id" => $data['ms_user_id']));
$data['go_calendar_id'] = $Calendar[0]->go_calendar_id;
$data['data'] = $request;
$data['source'] = 'ms';
if ($json_data['value'][0]['changeType'] == 'created')
$data['type'] = 'c';
else if ($json_data['value'][0]['changeType'] == 'updated')
$data['type'] = 'u';
else if ($json_data['value'][0]['changeType'] == 'deleted')
$data['type'] = 'd';
$data['status'] = 'p';
$data['edit'] = time();
$data['create'] = time();
$data['edit_by'] = 89;
$data['create_by'] = 89;
$db->insert("TheTool_CalendarQueue", $data);
return "";
die();
}
public static function updateCalendarEvent($r, $me)
{
$description = ($r->description);
$attachments = ($r->attachments);
$location = ($r->location);
$title = ($r->title);
$start = ((($r->start - 7200000) / 1000));
$end = ((($r->end - 7200000) / 1000));
if ($title) {
$start = strtotime($r->start);
$end = strtotime($r->end);
}
$allday = ($r->allday);
$reminder = ($r->reminder);
$newkey = ($r->newkey);
$id = ($r->id);
$type = ($r->type);
$busy = ($r->busy);
$users = ($r->users);
foreach ($users as $key => $value) {
$user_id = $value;
}
date_default_timezone_set('Europe/Berlin');
header('Content-Type: application/json');
$db = self::dbKalender();
$sql = "SELECT `cal_events`.id,microsoft_id,uuid,ms_user_id FROM `cal_events` INNER JOIN `cal_calendars` ON (`cal_calendars`.`id`=`cal_events`.`calendar_id`) WHERE `cal_events`.id = '" . $id . "' LIMIT 1";
$res = $db->query($sql);
if ($db->num_rows($res)) {
$result = $db->fetch_object($res);
$microsoft_id = $result->microsoft_id;
$cal_events_id = $result->uuid;
$microsoft_user_id = $result->ms_user_id;
}
$updateArray['start_time'] = $start;
$updateArray['end_time'] = $end;
$updateArray['mtime'] = time();
$updateArray['mname'] = $me->name;
if ($title) {
$updateArray['name'] = $title;
}
if ($description)
$updateArray['description'] = $description;
if ($location)
$updateArray['location'] = $location;
if (isset($allday))
$updateArray['all_day_event'] = $allday;
if (isset($reminder)) {
if ($reminder == 'NULL')
$updateArray['reminder'] = NULL;
else
$updateArray['reminder'] = $reminder;
}
if ($type)
$updateArray['event_type'] = $type;
if (isset($busy))
$updateArray['busy'] = $busy;
if ($type == 2) {
if ($r->customer)
$updateArray['customer'] = $r->customer;
else
$updateArray['customer'] = NULL;
if (($r->customer_info_type)) {
$customer_info_type = $r->customer_info_type;
}
if (($r->customer_info_text)) {
$customer_info_text = $r->customer_info_text;
}
if (($r->customer_info_type_text)) {
$customer_info_type_text = $r->customer_info_type_text;
}
if ($r->customer_info_reminder_check) {
$updateArray['customer_info_reminder'] = $r->customer_info_reminder_check;
}
$customerJson = array('customer_info_type' => $customer_info_type, 'customer_info_text' => $customer_info_text, 'customer_info_type_text' => $customer_info_type_text);
$updateArray['customer_info'] = json_encode($customerJson);
if ($r->customer_info_check) {
$customerJson['sendby'] = $me->name;
$customerJson['sendtime'] = time();
$updateArray['customer_info_send'] = json_encode($customerJson);
}
}
if ($type == 1) {
$updateArray['customer'] = NULL;
$updateArray['customer_info'] = NULL;
}
$db->update("cal_events", $updateArray, "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)) {
while ($dataAttachment = $db->fetch_array($res)) {
$toolattachments[$dataAttachment['id']] = 1;
}
}
foreach ($attachments as $key => $value) {
unset($toolattachments[$value]);
}
if (!empty($toolattachments)) {
foreach ($toolattachments as $key => $value) {
$db->delete("cal_events_attachments", "id = '" . $key . "'");
}
}
$res = $db->select("tmp_cal_events_attachments", "id,name,contentType,content,size,create_timestamp,edit_timestamp", "1=1 AND newkey='" . $newkey . "' ORDER BY id");
if ($db->num_rows($res)) {
while ($data = $db->fetch_array($res)) {
$tmpid = $data['id'];
unset($data['id']);
$data['cal_events_id'] = $cal_events_id;
$db->insert("cal_events_attachments", $data);
$db->delete("tmp_cal_events_attachments", "id = '" . $tmpid . "'");
}
}
$updateArray['attachments'] = $attachments;
}
$json_data = json_encode($updateArray);
$data = [];
$data['ms_user_id'] = $microsoft_user_id;
$data['ms_event_id'] = $microsoft_id;
$data['data'] = $json_data;
$data['type'] = 'u';
$data['status'] = 'p';
$data['edit'] = time();
$data['create'] = time();
$data['edit_by'] = 89;
$data['create_by'] = 89;
$db->insert("TheTool_CalendarQueue", $data);
}
public static function insertCalendarEvent($r, $me)
{
$description = ($r->description);
$attachments = ($r->attachments);
$location = ($r->location);
$title = ($r->title);
$start = strtotime($r->start);
$end = strtotime($r->end);
$allday = ($r->allday);
$reminder = ($r->reminder);
$newkey = ($r->newkey);
$type = ($r->type);
$busy = ($r->busy);
$users = ($r->users);
$customer_info_reminder_check = 0;
date_default_timezone_set('Europe/Berlin');
header('Content-Type: application/json');
foreach ($users as $key => $value) {
$user_id = $value;
}
$db = self::dbKalender();
$res = $db->select("cal_calendars", "id,ms_user_id", "id = '" . $user_id . "' LIMIT 1");
if ($db->num_rows($res)) {
$result = $db->fetch_object($res);
$microsoft_user_id = $result->ms_user_id;
}
if ($reminder == 'NULL') {
$reminder = NULL;
}
if ($type == 2) {
$customer = $r->customer;
$customer_info_type = $r->customer_info_type;
$customer_info_text = $r->customer_info_text;
$customer_info_type_text = $r->customer_info_type_text;
$customerJson = array('customer_info_type' => $customer_info_type, 'customer_info_text' => $customer_info_text, 'customer_info_type_text' => $customer_info_type_text);
$customer_info = json_encode($customerJson);
if ($r->customer_info_reminder_check) {
$customer_info_reminder_check = $r->customer_info_reminder_check;
}
if ($r->customer_info_check) {
$customerJson['sendby'] = $me->name;
$customerJson['sendtime'] = time();
$customer_info_send = json_encode($customerJson);
}
} else {
$customer = NULL;
$customer_info = NULL;
$customer_info_send = NULL;
}
$data = array("start_time" => $start, 'end_time' => $end, 'name' => $title, 'description' => $description, 'location' => $location, 'calendar_id' => $user_id, 'uuid' => "a5eb79b3-fca7-5378-a09e-" . rand(100000000000, 999999999999), 'user_id' => 1, 'timezone' => 'Europe/Amsterdam', 'all_day_event' => 0, 'repeat_end_time' => 0, 'reminder' => $reminder, 'ctime' => time(), 'cname' => $me->name, 'mtime' => time(), 'mname' => $me->name, 'user_id' => 1, 'busy' => $busy, 'status' => 'CONFIRMED', 'resource_event_id' => 0, 'private' => 0, 'rrule' => '', 'background' => 'EBF1E2', 'files_folder_id' => 0, 'read_only' => 0, 'exception_for_event_id' => 0, 'recurrence_id' => 0, 'is_organizer' => 1, 'event_type' => $type, 'customer' => $customer, 'customer_info' => $customer_info, 'customer_info_send' => $customer_info_send, 'customer_info_reminder' => $customer_info_reminder_check);
$db->insert("cal_events", $data);
$event_id = $data['uuid'];
if ($newkey) {
$res = $db->select("tmp_cal_events_attachments", "id,name,contentType,content,size,create_timestamp,edit_timestamp", "1=1 AND newkey='" . $newkey . "' ORDER BY id");
if ($db->num_rows($res)) {
while ($data = $db->fetch_array($res)) {
$tmpid = $data['id'];
unset($data['id']);
$data['cal_events_id'] = $event_id;
$db->insert("cal_events_attachments", $data);
$db->delete("tmp_cal_events_attachments", "id = '" . $tmpid . "'");
}
}
}
$data['attachments'] = $attachments;
$json_data = json_encode($data);
$data = [];
$data['ms_user_id'] = $microsoft_user_id;
$data['event_id'] = $event_id;
$data['data'] = $json_data;
$data['type'] = 'c';
$data['status'] = 'p';
$data['edit'] = time();
$data['create'] = time();
$data['edit_by'] = 89;
$data['create_by'] = 89;
$db->insert("TheTool_CalendarQueue", $data);
}
public static function insertCalendarEventAttachmentTemp($name, $contantType, $content, $size, $newkey)
{
$db = self::dbKalender();
$data = [];
$data['name'] = $name;
$data['contentType'] = $contantType;
$data['content'] = $content;
$data['size'] = $size;
$data['newkey'] = $newkey;
$data['create_timestamp'] = time();
$data['edit_timestamp'] = time();
$db->insert("tmp_cal_events_attachments", $data);
echo "insert_id: " . $db->insert_id;
return $db->insert_id;
}
public static function deleteCalendarEventAttachmentTemp($newkey, $name)
{
$db = self::dbKalender();
$db->delete("tmp_cal_events_attachments", "newkey = '" . $newkey . "' AND name = '" . $name . "'");
}
public static function deleteCalendarEvent($r)
{
$id = $r->id;
$users = $r->users;
foreach ($users as $key => $value) {
$user_id = $value;
}
date_default_timezone_set('Europe/Berlin');
header('Content-Type: application/json');
$db = self::dbKalender();
$res = $db->select("cal_calendars", "id,ms_user_id", "id = '" . $user_id . "' LIMIT 1");
if ($db->num_rows($res)) {
$result = $db->fetch_object($res);
$microsoft_user_id = $result->ms_user_id;
}
$res = $db->select("cal_events", 'id,microsoft_id', "id = '" . $id . "' LIMIT 1");
if ($db->num_rows($res)) {
$result = $db->fetch_object($res);
$data = [];
$data['ms_user_id'] = $microsoft_user_id;
$data['ms_event_id'] = $result->microsoft_id;
$data['type'] = 'd';
$data['status'] = 'p';
$data['edit'] = time();
$data['create'] = time();
$data['edit_by'] = 89;
$data['create_by'] = 89;
$db->insert("TheTool_CalendarQueue", $data);
}
$db->delete("cal_events", "id = '" . $id . "'");
die();
}
public static function create(array $data)
{
$model = new Calendar();
foreach ($data as $field => $value) {
if (property_exists(get_called_class(), $field)) {
if (substr($field, 0, 5) == "vlan_" && !$value) {
$model->$field = null;
continue;
}
$model->$field = $value;
}
}
$me = mfValuecache::singleton()->get("me");
if (!$me) {
$me = new User();
$me->loadMe();
mfValuecache::singleton()->set("me", $me);
}
if ($model->create_by === null) {
$model->create_by = $me->id;
}
if ($model->edit_by === null) {
$model->edit_by = $me->id;
}
return $model;
}
public static function getOne($id)
{
if (!is_numeric($id) || !$id) {
throw new Exception("Invalid number", 400);
}
$item = [];
$db = FronkDB::singleton();
$res = $db->select("Calendar", "*", "id=$id LIMIT 1");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Calendar($data);
}
return $item;
}
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$res = $db->select("Calendar", "*", "1=1");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[$data->go_calendar_id] = new Calendar($data);
}
}
return $items;
}
public static function getAllIndex()
{
$items = [];
$db = FronkDB::singleton();
$res = $db->select("Calendar", "*", "1=1");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new Calendar($data);
}
}
return $items;
}
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Calendar", "*", "$where ");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Calendar($data);
if ($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function search($filter)
{
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Calendar", "*", "$where");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new Calendar($data);
}
}
return $items;
}
private static function getSqlFilter($filter)
{
$where = "1=1 ";
//var_dump($filter);exit;
if (array_key_exists("user_id", $filter)) {
$user_id = $filter['user_id'];
if (is_numeric($user_id)) {
$where .= " AND user_id=$user_id";
}
}
if (array_key_exists("microsoft_id", $filter)) {
$microsoft_id = $filter['microsoft_id'];
$where .= " AND microsoft_id='$microsoft_id'";
}
if (array_key_exists("checkSubscriptions", $filter)) {
$where .= " AND microsoft_id!='' AND microsoft_id IS NOT NULL AND active=1";
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -0,0 +1,557 @@
.fc-event {
border-radius: 2px;
border: none;
cursor: move;
font-size: 13px;
margin: 3px 7px;
padding: 3px 5px;
text-align: center;
}
.fc-toolbar {
@media (max-width: 767px) {
flex-direction: column;
.fc-toolbar-chunk {
margin-bottom: 12px;
}
}
}
.fc .fc-button-primary:focus {
box-shadow: none;
}
.fc .fc-button:focus {
box-shadow: none;
outline: 0px;
}
.fc .fc-button-primary:not(:disabled).fc-button-active:focus, .fc .fc-button-primary:not(:disabled):active:focus {
box-shadow: none;
}
.popper, .tooltip {
position: absolute;
z-index: 9999;
/* background: #FFC107; */
color: #0f5be9;
width: auto;
/* border-radius: 3px; */
/* box-shadow: 0 0 1px rgba(0, 0, 0, 0.5); */
padding: 10px;
text-align: center;
opacity: 0.9;
}
.tooltip-inner {
max-width: 500px;
padding: 0.4rem 0.8rem;
color: #fff;
text-align: center;
background-color: #2c3e50;
border-radius: 0.2rem;
}
.style5 .tooltip {
background: #1E252B;
color: #FFFFFF;
max-width: 200px;
width: auto;
font-size: .8rem;
padding: .5em 1em;
}
.popper .popper__arrow,
.tooltip .tooltip-arrow {
width: 0;
height: 0;
border-style: solid;
position: absolute;
margin: 5px;
}
.tooltip .tooltip-arrow,
.popper .popper__arrow {
border-color: #FFC107;
}
.style5 .tooltip .tooltip-arrow {
border-color: #1E252B;
}
.popper[x-placement^="top"],
.tooltip[x-placement^="top"] {
margin-bottom: 5px;
}
.popper[x-placement^="top"] .popper__arrow,
.tooltip[x-placement^="top"] .tooltip-arrow {
border-width: 5px 5px 0 5px;
border-left-color: transparent;
border-right-color: transparent;
border-bottom-color: transparent;
bottom: -5px;
left: calc(50% - 5px);
margin-top: 0;
margin-bottom: 0;
}
.popper[x-placement^="bottom"],
.tooltip[x-placement^="bottom"] {
margin-top: 5px;
}
.tooltip[x-placement^="bottom"] .tooltip-arrow,
.popper[x-placement^="bottom"] .popper__arrow {
border-width: 0 5px 5px 5px;
border-left-color: transparent;
border-right-color: transparent;
border-top-color: transparent;
top: -5px;
left: calc(50% - 5px);
margin-top: 0;
margin-bottom: 0;
}
.tooltip[x-placement^="right"],
.popper[x-placement^="right"] {
margin-left: 5px;
}
.popper[x-placement^="right"] .popper__arrow,
.tooltip[x-placement^="right"] .tooltip-arrow {
border-width: 5px 5px 5px 0;
border-left-color: transparent;
border-top-color: transparent;
border-bottom-color: transparent;
left: -5px;
top: calc(50% - 5px);
margin-left: 0;
margin-right: 0;
}
.popper[x-placement^="left"],
.tooltip[x-placement^="left"] {
margin-right: 5px;
}
.popper[x-placement^="left"] .popper__arrow,
.tooltip[x-placement^="left"] .tooltip-arrow {
border-width: 5px 0 5px 5px;
border-top-color: transparent;
border-right-color: transparent;
border-bottom-color: transparent;
right: -5px;
top: calc(50% - 5px);
margin-left: 0;
margin-right: 0;
}
thead .fc-day-today .fc-scrollgrid-sync-inner {
background-color: #2c3e50;
}
thead .fc-day-today .fc-scrollgrid-sync-inner .fc-col-header-cell-cushion {
color: #fff;
}
.fc .fc-col-header-cell-cushion {
color: #2c3e50;
}
.fc .fc-daygrid-day-number {
color: #2c3e50;
}
.fc .fc-daygrid-day.fc-day-today {
background-color: rgb(44 62 80 / 12%);
}
.fc-event-title {
font-weight: 500;
}
.fc-day-today .fc-daygrid-day-top {
background-color: #2c3e50;
}
.fc-day-today .fc-daygrid-day-number {
color: #fff;
}
.card-fullscreen {
display: block;
z-index: 1040;
position: fixed;
width: 100%;
height: 100%;
top: 0;
right: 0;
left: 0;
bottom: 0;
overflow: auto;
}
.fa-window-maximize, .fa-window-restore {
font-size: 20px;
cursor: pointer;
color: #323a36;
}
.color-input {
height: 20px;
width: 30px;
padding: 0;
margin: 0;
block-size: 20px;
border-image: none;
inline-size: 30px;
border-radius: 5px;
border-color: #ccc;
padding-block: 0;
padding-inline: 0;
background-color: #fff;
}
.color-input::-webkit-color-swatch {
border-radius: 3px;
border: none;
}
.color-input::-moz-color-swatch {
border-radius: 3px;
border: none;
}
.color-text-input {
height: 20px;
width: 30px;
padding: 0;
margin: 0;
block-size: 20px;
border-image: none;
inline-size: 20px;
border-radius: 5px;
border-color: #ccc;
padding-block: 0;
padding-inline: 0;
background-color: #fff;
}
.color-text-input::-webkit-color-swatch {
border-radius: 3px;
border: 1px #ccc;
}
.color-text-input::-moz-color-swatch {
border-radius: 3px;
border: 1px #ccc;
}
.calendar-side-borders-sub {
border: 1px solid #ccc;
border-radius: 5px;
position: relative;
}
.calendar-side-borders-main {
border: 1px solid #ccc;
padding: 0px 5px 15px 5px;
border-radius: 5px;
}
.calendar-side-label {
font-size: 13px;
}
.fc-daygrid-day-events .fc-event {
margin-bottom: 10px;
padding-left: 8px;
padding-right: 8px;
border-radius: 2px;
border: 0;
border-left: 3px solid #6571ff;
color: #000;
font-weight: 500;
text-align: left;
}
.fc-daygrid-dot-event .fc-event-title {
font-weight: 500;
}
.fc-daygrid-day-events .fc-event {
text-align: center;
border: 1px solid #3788d840;
}
.tooltip-description {
font-size: 13px;
font-weight: 300;
}
.tooltip-location {
font-size: 13px;
font-weight: 300;
}
.fc-timegrid-event-harness-inset .fc-timegrid-event, .fc-timegrid-event.fc-event-mirror, .fc-timegrid-more-link {
box-shadow: 0px 0px 1px 1px #535353;
}
.fc-event-attachment {
position: absolute;
right: 1px;
top: 0;
}
.fc-event-type {
position: absolute;
top: 0;
left: 1px;
}
.fa-duotone {
font-size: 20px;
cursor: pointer;
}
.doc-icon-div {
width: 25px;
}
.fa-file-pdf:after {
content: "\f1c1\f1c1";
color: #f00;
opacity: 0.5;
}
.fa-file-xls:after {
content: "\f1c1\f1c1";
color: #279800;
opacity: 0.5;
}
.fa-file-csv:after {
content: "\f1c1\f1c1";
color: #279800;
opacity: 0.5;
}
.fa-file-zip:after {
content: "\f1c1\f1c1";
color: #d9c800;
opacity: 0.8;
}
.fa-file-doc:after {
content: "\f1c1\f1c1";
color: #003498;
opacity: 0.5;
}
.fa-file-ppt:after {
content: "\f1c1\f1c1";
color: #ff6400;
opacity: 0.5;
}
.fa-file-xml:after {
content: "\f1c1\f1c1";
color: #009091;
opacity: 0.6;
}
.fa-file-mp3:after {
content: "\f1c1\f1c1";
color: #d104ad;
opacity: 0.6;
}
.fa-file-png:after, .fa-file-jpg:after {
content: "\f1c1\f1c1";
color: #001dff;
opacity: 0.5;
}
.fa-calendar-symbol:after {
color: #0600ff;
opacity: 0.7;
}
.fa-calendar-lines-pen:before {
color: #ff0000;
}
.fa-calendar-circle-plus:before {
color: #0d9f00;
}
.fa-del-attachment {
color: #ff0000;
cursor: pointer;
}
.fa-circle-info {
font-size: 21px;
vertical-align: bottom;
margin-left: 5px;
cursor: pointer;
}
.fa-circle-info:before, .fa-info-circle:before {
content: "\f05a";
color: #e70404;
}
.doc-main-div {
border-bottom: 1px dotted #ccc;
margin-top: 4px;
}
.doc-content-div {
cursor: pointer;
max-width: 70%;
vertical-align: middle;
}
.doc-content-div a {
color: #000;
}
.doc-content-tooltip-div a {
color: #fff;
}
.modal-title {
color: #1b1d1c;
}
.checkbox-label {
margin-top: 2px;;
}
#documents {
margin-left: -30px;
margin-right: -30px;
}
.custom-file-input:lang(en) ~ .custom-file-label::after {
content: "Durchsuchen";
}
.required {
background-color: #fba5a5;
}
.event-search-result {
box-shadow: 0px 0px 3px 3px #48ff00 !important;
}
.search-div .select2 {
text-align: left;
}
.text-template {
cursor: pointer;
}
.font-12 {
font-size: 12px !important;
}
.form-check-input {
position: absolute;
margin-top: 5px;
margin-left: -1.25rem;
}
.add-cal-group-div {
position: absolute;
right: 24px;
top: 11px;
font-size: 22px;
color: #2a8504;
}
.fa-rectangle-history-circle-plus:after {
color: #0600ff;
opacity: 0.7;
}
#calendar-side-div {
max-height: 850px;
overflow: scroll;
}
/* width */
::-webkit-scrollbar {
width: 7px;
}
/* Track */
::-webkit-scrollbar-track {
background: #f1f1f1;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #d7d3f9;
border-radius: 10px;
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: #8577f9;
}
.dropdown-group-div {
position: absolute;
right: 10px;
top: 6px;
font-size: 20px;
color: #000000;
}
.move-group-div {
position: absolute;
left: 7px;
top: 10px;
font-size: 15px;
color: #676767;
cursor: grab;
}
.fa-square-arrow-down:after {
color: #0eb202;
opacity: 0.3;
}
.fa-square-arrow-up:after {
color: #ff3434;
opacity: 0.3;
}
.group-checkbox-div {
position: absolute;
top: 7px;
left: 58px;
}
.event-free {
border-left: 5px solid #0043d3;
}
.event-busy {
border-left: 5px solid #24ab00;
}
.event-tentative {
border-left: 5px solid #df0000;
}

File diff suppressed because it is too large Load Diff