maintaince module
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
<?php include(__DIR__ . '/../include/headscript.php'); ?>
|
||||
<?php
|
||||
require_once __DIR__ . '/include/functions.php';
|
||||
|
||||
$pdo = mnt_pdo();
|
||||
|
||||
if (!userCan('maintenance.calendar.view')) {
|
||||
http_response_code(403);
|
||||
exit('Permesso negato.');
|
||||
}
|
||||
|
||||
$formData = mnt_form_data($pdo);
|
||||
|
||||
$MNT_TITLE = 'Calendario manutenzioni';
|
||||
$MNT_PLUGINS = ['fullcalendar'];
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="it">
|
||||
|
||||
<head>
|
||||
<?php include __DIR__ . '/include/page_head.php'; ?>
|
||||
<style>
|
||||
#mntCalendar { --fc-border-color: #e6eef0; }
|
||||
#mntCalendar .fc-toolbar-title { font-size: 1.05rem; font-weight: 700; color: var(--mnt-heading); }
|
||||
#mntCalendar .fc-event { cursor: pointer; font-size: 0.75rem; }
|
||||
@media (max-width: 767.98px) {
|
||||
#mntCalendar .fc-toolbar { flex-direction: column; gap: 0.5rem; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php include __DIR__ . '/include/wrapper_open.php'; ?>
|
||||
<?php include(__DIR__ . '/../include/navbar.php'); ?>
|
||||
<?php include(__DIR__ . '/../include/topbar.php'); ?>
|
||||
|
||||
<div class="page-wrapper">
|
||||
<div class="page-content">
|
||||
|
||||
<div class="card mnt-card">
|
||||
<div class="card-header d-flex align-items-center justify-content-between flex-wrap gap-2">
|
||||
<h5><i class="fa-solid fa-calendar-days me-2"></i>Calendario manutenzioni</h5>
|
||||
<div class="header-actions d-flex gap-2 flex-wrap">
|
||||
<a href="manutenzioni/calendar_global.php" class="btn btn-mnt-outline d-inline-flex align-items-center gap-2">
|
||||
<i class="fa-solid fa-layer-group"></i><span>Calendario cumulativo</span>
|
||||
</a>
|
||||
<a href="manutenzioni/maintenances.php" class="btn btn-mnt-outline d-inline-flex align-items-center gap-2">
|
||||
<i class="fa-solid fa-list"></i><span>Elenco</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="mnt-filter-bar">
|
||||
<select class="form-select" id="filterType">
|
||||
<option value="">Programmate e straordinarie</option>
|
||||
<?php foreach (mnt_intervention_types() as $value => $label): ?>
|
||||
<option value="<?= mnt_h($value) ?>">Solo <?= mnt_h(mb_strtolower($label)) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
<select class="form-select" id="filterCategory">
|
||||
<option value="">Tutte le categorie</option>
|
||||
<?php foreach ($formData['categories'] as $category): ?>
|
||||
<option value="<?= (int)$category['id'] ?>"><?= mnt_h($category['name']) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="d-flex gap-3 flex-wrap mb-3 small">
|
||||
<span><span class="mnt-badge mnt-badge-overdue">Scaduta</span></span>
|
||||
<span><span class="mnt-badge mnt-badge-soon">In scadenza</span></span>
|
||||
<span><span class="mnt-badge mnt-badge-ok">In regola (colore della categoria)</span></span>
|
||||
</div>
|
||||
|
||||
<div id="mntCalendar"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php include(__DIR__ . '/../include/footer.php'); ?>
|
||||
</div>
|
||||
|
||||
<?php include(__DIR__ . '/../jsinclude.php'); ?>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const el = document.getElementById('mntCalendar');
|
||||
const isMobile = window.innerWidth < 768;
|
||||
|
||||
const calendar = new FullCalendar.Calendar(el, {
|
||||
locale: 'it',
|
||||
initialView: isMobile ? 'listMonth' : 'dayGridMonth',
|
||||
headerToolbar: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: isMobile ? 'listMonth,dayGridMonth' : 'dayGridMonth,listMonth'
|
||||
},
|
||||
height: 'auto',
|
||||
firstDay: 1,
|
||||
events: function (info, success, failure) {
|
||||
$.getJSON('manutenzioni/ajax/get_calendar_events.php', {
|
||||
start: info.startStr,
|
||||
end: info.endStr,
|
||||
type: $('#filterType').val(),
|
||||
category: $('#filterCategory').val()
|
||||
}).done(success).fail(failure);
|
||||
},
|
||||
eventClick: function (info) {
|
||||
window.location = 'manutenzioni/equipment.php?id=' + info.event.extendedProps.equipmentId;
|
||||
}
|
||||
});
|
||||
|
||||
calendar.render();
|
||||
$('#filterType, #filterCategory').on('change', () => calendar.refetchEvents());
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user