regenrates pages
This commit is contained in:
+196
-230
@@ -1,96 +1,68 @@
|
||||
<?php require_once('include/headscript.php'); ?>
|
||||
<?php
|
||||
// Creazione della connessione
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
require_once('include/headscript.php');
|
||||
|
||||
// Verifica della connessione
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione fallita: " . $conn->connect_error);
|
||||
}
|
||||
if (isset($_GET['message'])) {
|
||||
$message = $_GET['message'];
|
||||
} else {
|
||||
$message = 'n';
|
||||
}
|
||||
// ID dell'insegnante
|
||||
$idTeacher = 1;
|
||||
/**
|
||||
* Vista admin di tutti i certificati caricati dagli utenti,
|
||||
* con DataTables per ricerca e ordinamento.
|
||||
*/
|
||||
$pdo = DBHandlerSelect::getInstance()->getConnection();
|
||||
|
||||
// Controlla se il form è stato inviato
|
||||
if (isset($_POST['submit'])) {
|
||||
// Recupera la data dal form
|
||||
$dayoffdate = $_POST['dayoff'];
|
||||
|
||||
// Query SQL per l'inserimento del day off
|
||||
$insertQuery = "INSERT INTO dayoff (idteacher, dayoffdate) VALUES ($idTeacher, '$dayoffdate')";
|
||||
|
||||
// Esegui la query di inserimento
|
||||
if ($conn->query($insertQuery) === TRUE) {
|
||||
echo "Inserimento riuscito!";
|
||||
} else {
|
||||
echo "Errore nell'inserimento: " . $conn->error;
|
||||
}
|
||||
function e($value): string
|
||||
{
|
||||
return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
// Query SQL
|
||||
$query = "SELECT * FROM certificateuserprofile LEFT JOIN auth_users ON certificateuserprofile.iduser=auth_users.id ORDER BY auth_users.last_name";
|
||||
|
||||
// Esecuzione della query
|
||||
$result = $conn->query($query);
|
||||
|
||||
// Recupero delle date di permesso
|
||||
$documents = [];
|
||||
if ($result->num_rows > 0) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$documents[] = $row;
|
||||
}
|
||||
function initials(string $first, string $last): string
|
||||
{
|
||||
$ini = strtoupper(mb_substr(trim($first), 0, 1) . mb_substr(trim($last), 0, 1));
|
||||
return $ini !== '' ? $ini : '?';
|
||||
}
|
||||
|
||||
function avatarColor(string $seed): string
|
||||
{
|
||||
$palette = ['#1ebf73', '#2980b9', '#8e44ad', '#e67e22', '#16a085', '#c0392b', '#2c3e50', '#d35400'];
|
||||
return $palette[abs(crc32($seed)) % count($palette)];
|
||||
}
|
||||
|
||||
$message = $_GET['message'] ?? 'n';
|
||||
|
||||
// Elenco certificati con dati utente
|
||||
$sql = "SELECT certificateuserprofile.*, auth_users.first_name, auth_users.last_name
|
||||
FROM certificateuserprofile
|
||||
LEFT JOIN auth_users ON certificateuserprofile.iduser = auth_users.id
|
||||
ORDER BY auth_users.last_name, auth_users.first_name";
|
||||
$documents = $pdo->query($sql)->fetchAll();
|
||||
|
||||
// Determina se un certificato è scaduto (per evidenziarlo)
|
||||
$today = date('Y-m-d');
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<html lang="it">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>YogiBook - Prenotazioni YogaSoul</title>
|
||||
<title>YogiBook - Certificati (admin)</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta content="YogiBook - Prenotazione facile YogaSOul" name="description" />
|
||||
<meta content="YogiBook - Prenotazione facile YogaSoul" name="description" />
|
||||
<meta content="Advanced Creative Solutions" name="author" />
|
||||
<!-- App favicon -->
|
||||
<link rel="shortcut icon" href="assets/images/favicon.ico">
|
||||
|
||||
<!-- Bootstrap Css -->
|
||||
<link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
|
||||
<!-- Icons Css -->
|
||||
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
|
||||
<!-- App Css-->
|
||||
<link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
|
||||
<!-- DataTables CSS -->
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/dataTables.bootstrap5.min.css">
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
|
||||
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
||||
<!-- DataTables JS -->
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/dataTables.bootstrap5.min.js"></script>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$("#expiryDate").datepicker({
|
||||
dateFormat: "yy-mm-dd",
|
||||
minDate: 0,
|
||||
});
|
||||
$("#dayoff").datepicker({
|
||||
dateFormat: "yy-mm-dd"
|
||||
});
|
||||
// Initialize DataTables
|
||||
$('#certificateTable').DataTable({
|
||||
"language": {
|
||||
"url": "//cdn.datatables.net/plug-ins/1.11.5/i18n/it-IT.json"
|
||||
},
|
||||
"pageLength": 100,
|
||||
"pageLength": 50,
|
||||
"order": [
|
||||
[0, "asc"]
|
||||
]
|
||||
@@ -100,12 +72,12 @@ if ($result->num_rows > 0) {
|
||||
function confirmDelete(id) {
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
text: "Questo certificato verrà cancellato definitivamente!",
|
||||
text: "Questo certificato verrà cancellato definitivamente.",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#3085d6",
|
||||
confirmButtonText: "Sì, cancella!",
|
||||
confirmButtonText: "Sì, cancella",
|
||||
cancelButtonText: "Annulla"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
@@ -114,212 +86,206 @@ if ($result->num_rows > 0) {
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.custom-card {
|
||||
margin: 10px auto;
|
||||
display: flex;
|
||||
width: 90%;
|
||||
max-width: 700px;
|
||||
background-color: white;
|
||||
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.custom-card:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.custom-date-box {
|
||||
flex: 1;
|
||||
background-color: red;
|
||||
color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 0;
|
||||
font-size: 60px;
|
||||
font-weight: bold;
|
||||
border-top-left-radius: 8px;
|
||||
border-bottom-left-radius: 8px;
|
||||
}
|
||||
|
||||
.custom-day {
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.custom-month {
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.custom-event-details {
|
||||
flex: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px 20px;
|
||||
background-color: lightblue;
|
||||
}
|
||||
|
||||
.custom-heading {
|
||||
margin-top: 0;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.custom-paragraph {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.custom-actions {
|
||||
display: none;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.custom-card.expanded .custom-actions {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.custom-action-button {
|
||||
background-color: #f0f0f0;
|
||||
.admin-card {
|
||||
border: none;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
border-radius: 14px;
|
||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.custom-action-button:hover {
|
||||
background-color: #e0e0e0;
|
||||
.admin-card .card-body {
|
||||
padding: 26px 30px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.custom-card {
|
||||
flex-direction: column;
|
||||
}
|
||||
.section-title {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
color: #6b7280;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.custom-date-box,
|
||||
.custom-event-details {
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
}
|
||||
.section-lead {
|
||||
color: #9ca3af;
|
||||
font-size: 14px;
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
|
||||
.custom-event-time {
|
||||
font-size: 24px;
|
||||
}
|
||||
#certificateTable thead th {
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.03em;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
#certificateTable td {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.user-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
font-size: 13px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.user-name {
|
||||
font-weight: 600;
|
||||
color: #1f2937;
|
||||
}
|
||||
|
||||
.exp-chip {
|
||||
display: inline-block;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
padding: 3px 10px;
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.exp-ok {
|
||||
background: #e3f2ec;
|
||||
color: #1a7f52;
|
||||
}
|
||||
|
||||
.exp-expired {
|
||||
background: #fdecec;
|
||||
color: #c0392b;
|
||||
}
|
||||
|
||||
.doc-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: #1ebf73;
|
||||
font-weight: 600;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.doc-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- Begin page -->
|
||||
<div id="layout-wrapper">
|
||||
<!-- Top Bar -->
|
||||
<header id="page-topbar" class="isvertical-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex">
|
||||
<!-- LOGO -->
|
||||
<?php include('include/logoarea.php'); ?>
|
||||
<button type="button" class="btn btn-sm px-3 font-size-24 header-item waves-effect vertical-menu-btn">
|
||||
<i class="bx bx-menu align-middle"></i>
|
||||
</button>
|
||||
<!-- start page title -->
|
||||
<div class="page-title-box align-self-center d-none d-md-block">
|
||||
<h4 class="page-title mb-0">Prenotazione Classi</h4>
|
||||
<h4 class="page-title mb-0">Certificati</h4>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
</div>
|
||||
<div class="d-flex">
|
||||
<?php include('include/languageselection.php'); ?>
|
||||
<div class="dropdown d-inline-block">
|
||||
<button type="button" class="btn header-item noti-icon" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="bx bx-search icon-sm align-middle"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-end p-0">
|
||||
<form class="p-2">
|
||||
<div class="search-box">
|
||||
<div class="position-relative">
|
||||
<input type="text" class="form-control rounded bg-light border-0" placeholder="Search...">
|
||||
<i class="bx bx-search search-icon"></i>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php include('include/profiletopbar.php'); ?>
|
||||
</div>
|
||||
<?php include('include/profiletopbar.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<?php include('include/sidebar.php'); ?>
|
||||
<header class="ishorizontal-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex"></div>
|
||||
</header>
|
||||
<?php include('include/sidebar.php'); ?>
|
||||
<header class="ishorizontal-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex"></div>
|
||||
</div>
|
||||
<div class="topnav">
|
||||
<div class="container-fluid">
|
||||
<nav class="navbar navbar-light navbar-expand-lg topnav-menu"></nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<!-- Start right Content here -->
|
||||
<div class="main-content">
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<?php if ($message == 'success') { ?>
|
||||
<div class="alert alert-success" role="alert">
|
||||
Certificato rimosso con successo
|
||||
</div>
|
||||
<?php } ?>
|
||||
<h5>Benvenuta/o <?php echo $firstname; ?> </h5>
|
||||
<p>Certificati</p>
|
||||
<div class="table-responsive">
|
||||
<table id="certificateTable" class="table table-striped mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nome</th>
|
||||
<th>Scadenza</th>
|
||||
<th>Data Caricamento</th>
|
||||
<th>Documento</th>
|
||||
<th>Azione</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($documents as $document) { ?>
|
||||
</header>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
<?php if ($message === 'success') : ?>
|
||||
<div class="alert alert-success" role="alert">Certificato rimosso con successo.</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card admin-card">
|
||||
<div class="card-body">
|
||||
<div class="section-title">Certificati caricati</div>
|
||||
<p class="section-lead">Ciao <?php echo e($firstname); ?>, qui trovi tutti i certificati medici caricati dagli utenti.</p>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="certificateTable" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?php echo $document["first_name"]; ?> <?php echo $document["last_name"]; ?></td>
|
||||
<td><?php echo $document["expirydatedocument"]; ?></td>
|
||||
<td><?php echo $document["uploaded_at"] ?? 'N/D'; ?></td>
|
||||
<td><a href="user/document/<?php echo $document["filenamedocument"]; ?>" target="_blank">DOC</a></td>
|
||||
<td>
|
||||
<button class="btn btn-danger btn-sm" onclick="confirmDelete(<?php echo $document['idcertificateuserprofile']; ?>)">
|
||||
<i class="fas fa-trash"></i> Cancella
|
||||
</button>
|
||||
</td>
|
||||
<th>Utente</th>
|
||||
<th>Descrizione</th>
|
||||
<th>Scadenza</th>
|
||||
<th>Caricato il</th>
|
||||
<th>Documento</th>
|
||||
<th>Azione</th>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($documents as $d) :
|
||||
$fullName = trim($d['first_name'] . ' ' . $d['last_name']);
|
||||
$idc = (int) $d['idcertificateuserprofile'];
|
||||
$expTs = strtotime($d['expirydatedocument']);
|
||||
$isExpired = $expTs && date('Y-m-d', $expTs) < $today;
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="user-cell">
|
||||
<div class="avatar" style="background: <?php echo avatarColor($fullName); ?>;">
|
||||
<?php echo e(initials($d['first_name'] ?? '', $d['last_name'] ?? '')); ?>
|
||||
</div>
|
||||
<span class="user-name"><?php echo e($fullName); ?></span>
|
||||
</div>
|
||||
</td>
|
||||
<td><?php echo e($d['documentdescription']); ?></td>
|
||||
<td>
|
||||
<span class="exp-chip <?php echo $isExpired ? 'exp-expired' : 'exp-ok'; ?>">
|
||||
<?php echo e($d['expirydatedocument']); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td><?php echo e($d['uploaded_at'] ?? 'N/D'); ?></td>
|
||||
<td>
|
||||
<a class="doc-link" href="user/document/<?php echo e(rawurlencode($d['filenamedocument'])); ?>" target="_blank" rel="noopener">
|
||||
<i class="fas fa-file-arrow-down"></i> Apri
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-danger btn-sm" onclick="confirmDelete(<?php echo $idc; ?>)">
|
||||
<i class="fas fa-trash"></i> Cancella
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
<!-- End Page-content -->
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
<!-- end main content-->
|
||||
</div>
|
||||
<!-- END layout-wrapper -->
|
||||
<!-- JAVASCRIPT -->
|
||||
|
||||
<script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="assets/libs/metismenujs/metismenujs.min.js"></script>
|
||||
<script src="assets/libs/simplebar/simplebar.min.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user