Kalenderupdate
* Komplette Verwaltung von Kalender Rechte von internen und externen Mitarbeiteren
This commit is contained in:
@@ -15,7 +15,15 @@
|
||||
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title"><?= ($calendars->id) ? "Kalender Verwaltung bearbeiten" : "Neuer Kalender Verwaltung" ?></h4>
|
||||
<h4 class="page-title">
|
||||
<?php if ($calendars->id && $calendars->user_id): ?>
|
||||
Kalender Verwaltung bearbeiten
|
||||
<?php elseif ($calendars->id && !$calendars->user_id): ?>
|
||||
Benutzer bearbeiten
|
||||
<?php else: ?>
|
||||
Neuen Kalender Benutzer anlegen
|
||||
<?php endif; ?>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -35,15 +43,31 @@
|
||||
<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>
|
||||
<?php if ($calendars->user_id): ?>
|
||||
<input type="text" value="<?= $calendars->user->name ?>" class="form-control" disabled/>
|
||||
<?php else: ?>
|
||||
<input type="text" id="calendar_firstname" name="calendar_firstname"
|
||||
value="<?= $calendars->calendar_firstname ?>"
|
||||
placeholder="Vorname" class="form-control mb-2" required/>
|
||||
<input type="text" id="calendar_lastname" name="calendar_lastname"
|
||||
value="<?= $calendars->calendar_lastname ?>"
|
||||
placeholder="Nachname" class="form-control" required/>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (!$calendars->id || !$calendars->user_id): ?>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="calendar_email">E-Mail (optional)</label>
|
||||
<div class="col-lg-3">
|
||||
<input type="email" id="calendar_email" name="calendar_email"
|
||||
value="<?= $calendars->calendar_email ?>" class="form-control"
|
||||
placeholder="wird automatisch aus Name generiert"/>
|
||||
<small class="form-text text-muted">
|
||||
Automatisch: vorname.nachname@xinon.extern
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<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">
|
||||
@@ -76,7 +100,108 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="calendar_admin">Kalender Admin</label>
|
||||
<div class="col-lg-3">
|
||||
<div class="custom-control custom-switch mt-1">
|
||||
<input type="checkbox" <?= ($calendars->calendar_admin==1) ? 'checked="checked"' : '' ?> class="custom-control-input" value="1"
|
||||
id="calendar_admin" name="calendar_admin">
|
||||
<label class="custom-control-label no-user-select" for="calendar_admin"></label>
|
||||
</div>
|
||||
<small class="form-text text-muted">
|
||||
Bekommt automatisch "all"-Rechte auf alle neuen Benutzer
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($calendars->id): ?>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label">Kalenderrechte</label>
|
||||
<div class="col-lg-8">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<table class="table table-sm table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Kalender</th>
|
||||
<th width="120" class="text-center">Keine</th>
|
||||
<th width="120" class="text-center">Lesen</th>
|
||||
<th width="120" class="text-center">Alle Rechte</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$currentRights = json_decode($calendars->rights, true) ?: [];
|
||||
$allCalendars = CalendarModel::getAll();
|
||||
$sortedCalendars = [];
|
||||
foreach ($allCalendars as $cal) {
|
||||
if ($cal->id == $calendars->id || !$cal->go_calendar_id) continue;
|
||||
|
||||
$name = $cal->user_id ? $cal->user->name : $cal->calendar_name;
|
||||
$sortedCalendars[] = [
|
||||
'cal' => $cal,
|
||||
'name' => $name
|
||||
];
|
||||
}
|
||||
usort($sortedCalendars, function($a, $b) {
|
||||
return strcasecmp($a['name'], $b['name']);
|
||||
});
|
||||
|
||||
foreach ($sortedCalendars as $item):
|
||||
$cal = $item['cal'];
|
||||
$calendarName = $item['name'];
|
||||
$currentRight = isset($currentRights[$cal->go_calendar_id]) ? $currentRights[$cal->go_calendar_id] : 'none';
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><?= htmlspecialchars($calendarName) ?></strong>
|
||||
<?php if ($cal->user_id): ?>
|
||||
<span class="badge badge-success badge-sm ml-1">Mitarbeiter</span>
|
||||
<?php else: ?>
|
||||
<span class="badge badge-info badge-sm ml-1">Extern</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<div class="custom-control custom-radio">
|
||||
<input type="radio"
|
||||
class="custom-control-input"
|
||||
id="right_<?= $cal->go_calendar_id ?>_none"
|
||||
name="rights[<?= $cal->go_calendar_id ?>]"
|
||||
value="none"
|
||||
<?= ($currentRight == 'none') ? 'checked' : '' ?>>
|
||||
<label class="custom-control-label" for="right_<?= $cal->go_calendar_id ?>_none"></label>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<div class="custom-control custom-radio">
|
||||
<input type="radio"
|
||||
class="custom-control-input"
|
||||
id="right_<?= $cal->go_calendar_id ?>_read"
|
||||
name="rights[<?= $cal->go_calendar_id ?>]"
|
||||
value="read"
|
||||
<?= ($currentRight == 'read') ? 'checked' : '' ?>>
|
||||
<label class="custom-control-label" for="right_<?= $cal->go_calendar_id ?>_read"></label>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<div class="custom-control custom-radio">
|
||||
<input type="radio"
|
||||
class="custom-control-input"
|
||||
id="right_<?= $cal->go_calendar_id ?>_all"
|
||||
name="rights[<?= $cal->go_calendar_id ?>]"
|
||||
value="all"
|
||||
<?= ($currentRight == 'all') ? 'checked' : '' ?>>
|
||||
<label class="custom-control-label" for="right_<?= $cal->go_calendar_id ?>_all"></label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
@@ -100,8 +225,7 @@
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$(".select2").select2({placeholder: ""});
|
||||
|
||||
// disable mousewheel on a input number field when in focus
|
||||
localStorage.setItem('calendarActiveTab', '#user-tab');
|
||||
$('form').on('focus', 'input[type=number]', function (e) {
|
||||
$(this).on('wheel.disableScroll', function (e) {
|
||||
e.preventDefault()
|
||||
|
||||
Reference in New Issue
Block a user