297 lines
20 KiB
PHP
297 lines
20 KiB
PHP
<?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">
|
|
<?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>
|
|
<!-- 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 ?>"/> <?php if (!$calendars->id): ?>
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label">Benutzer-Typ</label>
|
|
<div class="col-lg-3">
|
|
<select class="form-control" id="user_type" name="user_type">
|
|
<option value="system">TheTool-Benutzer</option>
|
|
<option value="extern">Externer Benutzer</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="form-group row" id="user_select_row" style="display: none;">
|
|
<label class="col-lg-2 col-form-label" for="user_id">TheTool Benutzer *</label>
|
|
<div class="col-lg-3">
|
|
<select class="form-control select2" id="user_id" name="user_id">
|
|
<option value="">-- Benutzer auswählen --</option>
|
|
<?php foreach ($users as $user): ?>
|
|
<option value="<?= $user->id ?>" data-email="<?= htmlspecialchars($user->email) ?>">
|
|
<?= $user->name ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group row" id="name_input_row">
|
|
<label class="col-lg-2 col-form-label" for="user_id">Name *</label>
|
|
<div class="col-lg-3">
|
|
<?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"/>
|
|
<input type="text" id="calendar_lastname" name="calendar_lastname"
|
|
value="<?= $calendars->calendar_lastname ?>"
|
|
placeholder="Nachname" class="form-control"/>
|
|
<?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 *</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"/>
|
|
</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">
|
|
<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 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">
|
|
<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: ""});
|
|
localStorage.setItem('calendarActiveTab', '#user-tab');
|
|
|
|
$('#user_type').on('change', function() {
|
|
var type = $(this).val();
|
|
|
|
if (type === 'system') {
|
|
$('#user_select_row').show();
|
|
$('#name_input_row').hide();
|
|
$('#email_input_row').hide();
|
|
$('#calendar_firstname, #calendar_lastname').removeAttr('required');
|
|
$('#user_id').attr('required', 'required');
|
|
} else {
|
|
$('#user_select_row').hide();
|
|
$('#name_input_row').show();
|
|
$('#email_input_row').show();
|
|
|
|
$('#calendar_firstname, #calendar_lastname').attr('required', 'required');
|
|
$('#user_id').removeAttr('required');
|
|
}
|
|
});
|
|
$('#user_id').on('change', function() {
|
|
var selectedUserId = $(this).val();
|
|
if (selectedUserId) {
|
|
var selectedOption = $(this).find('option:selected');
|
|
var email = selectedOption.data('email');
|
|
|
|
if (email) {
|
|
$('#calendar_email').val(email); // Kein readonly
|
|
$('#email_input_row').show();
|
|
}
|
|
} else {
|
|
$('#calendar_email').val('');
|
|
$('#email_input_row').hide();
|
|
}
|
|
});
|
|
$('#user_type').trigger('change');
|
|
|
|
$('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"); ?>
|