Files
yogibook_aury_new/public/pendingbookedclass.php
T
2026-08-09 07:01:23 +02:00

309 lines
9.8 KiB
PHP

<?php
require_once('include/headscript.php');
/**
* Pannello admin: prenotazioni in stato "pending" (richieste di
* riprogrammazione) da accettare o rifiutare.
*/
$pdo = DBHandlerSelect::getInstance()->getConnection();
function e($value): string
{
return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
}
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)];
}
// Solo i campi che servono davvero (evita conflitti da SELECT *)
$sql = "SELECT bookingclass.idbookingclass, bookingclass.status AS booking_status,
bookingclass.prevbookingstart, bookingclass.bookingstart,
auth_users.first_name, auth_users.last_name,
service.servicename, service.day, service.time
FROM bookingclass
LEFT JOIN auth_users ON bookingclass.iduser = auth_users.id
LEFT JOIN service ON bookingclass.idservice = service.idservice
WHERE bookingclass.status = 'pending'
ORDER BY bookingclass.bookingstart";
$documents = $pdo->query($sql)->fetchAll();
$fmt = function ($dt) {
if (empty($dt)) return '-';
$ts = strtotime($dt);
return $ts ? date('d-m-Y H:i', $ts) : '-';
};
?>
<!doctype html>
<html lang="it">
<head>
<meta charset="utf-8" />
<title>YogiBook - Prenotazioni in attesa</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="YogiBook - Prenotazione facile YogaSoul" name="description" />
<meta content="Advanced Creative Solutions" name="author" />
<link rel="shortcut icon" href="assets/images/favicon.ico">
<link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/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">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
.admin-card {
border: none;
border-radius: 14px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}
.admin-card .card-body {
padding: 26px 30px;
}
.section-title {
font-size: 15px;
font-weight: 700;
letter-spacing: 0.04em;
text-transform: uppercase;
color: #6b7280;
margin-bottom: 4px;
}
.section-lead {
color: #9ca3af;
font-size: 14px;
margin-bottom: 22px;
}
.pending-table {
margin-bottom: 0;
}
.pending-table thead th {
font-size: 12px;
text-transform: uppercase;
letter-spacing: 0.03em;
color: #6b7280;
border-bottom: 2px solid #eef0f3;
white-space: nowrap;
}
.pending-table td {
vertical-align: middle;
}
.user-cell {
display: flex;
align-items: center;
gap: 10px;
}
.avatar {
width: 38px;
height: 38px;
border-radius: 50%;
color: #fff;
font-weight: 700;
font-size: 14px;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.user-name {
font-weight: 600;
color: #1f2937;
}
.status-chip {
display: inline-block;
font-size: 11px;
font-weight: 700;
padding: 3px 10px;
border-radius: 20px;
background: #fff3cd;
color: #856404;
text-transform: capitalize;
}
.date-old {
color: #c0392b;
}
.date-new {
color: #1a7f52;
font-weight: 600;
}
.btn-accept,
.btn-reject {
border: none;
border-radius: 8px;
padding: 7px 14px;
font-size: 13px;
font-weight: 600;
color: #fff;
cursor: pointer;
transition: filter 0.15s;
white-space: nowrap;
}
.btn-accept {
background: #27ae60;
}
.btn-reject {
background: #e74c3c;
}
.btn-accept:hover,
.btn-reject:hover {
filter: brightness(0.93);
}
.empty-state {
text-align: center;
padding: 40px 10px;
color: #9ca3af;
}
.empty-state i {
font-size: 34px;
margin-bottom: 10px;
display: block;
color: #d5d9e0;
}
</style>
</head>
<body>
<div id="layout-wrapper">
<header id="page-topbar" class="isvertical-topbar">
<div class="navbar-header">
<div class="d-flex">
<?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>
<div class="page-title-box align-self-center d-none d-md-block">
<h4 class="page-title mb-0">Prenotazioni in attesa</h4>
</div>
</div>
<div class="d-flex">
<?php include('include/languageselection.php'); ?>
<?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>
</div>
<div class="topnav">
<div class="container-fluid">
<nav class="navbar navbar-light navbar-expand-lg topnav-menu"></nav>
</div>
</div>
</header>
<div class="main-content">
<div class="page-content">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card admin-card">
<div class="card-body">
<div class="section-title">Richieste in attesa</div>
<p class="section-lead">
Ciao <?php echo e($firstname); ?>, qui trovi le richieste di riprogrammazione da accettare o rifiutare.
</p>
<div class="table-responsive">
<table class="table pending-table align-middle">
<thead>
<tr>
<th>Utente</th>
<th>Stato</th>
<th>Classe</th>
<th>Data cancellata</th>
<th>Data proposta</th>
<th class="text-end">Azioni</th>
</tr>
</thead>
<tbody>
<?php if (empty($documents)) : ?>
<tr>
<td colspan="6">
<div class="empty-state">
<i class="fas fa-inbox"></i>
Nessuna prenotazione in attesa al momento.
</div>
</td>
</tr>
<?php else : ?>
<?php foreach ($documents as $d) :
$fullName = trim($d['first_name'] . ' ' . $d['last_name']);
$idbc = (int) $d['idbookingclass'];
?>
<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><span class="status-chip"><?php echo e($d['booking_status']); ?></span></td>
<td>
<?php echo e($d['servicename']); ?>
<small class="text-muted d-block">
<?php echo e(trim($d['day'] . ' ' . $d['time'], ' -')); ?>
</small>
</td>
<td class="date-old"><?php echo e($fmt($d['prevbookingstart'])); ?></td>
<td class="date-new"><?php echo e($fmt($d['bookingstart'])); ?></td>
<td class="text-end">
<a href="acceptbookingclass.php?idbookingclass=<?php echo $idbc; ?>">
<button type="button" class="btn-accept"><i class="bx bx-check-double"></i> Accetta</button>
</a>
<a href="rejectbookingclass.php?idbookingclass=<?php echo $idbc; ?>">
<button type="button" class="btn-reject"><i class="bx bx-block"></i> Rifiuta</button>
</a>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include('include/footer.php'); ?>
</div>
</div>
</div>
<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>
<script src="assets/libs/eva-icons/eva.min.js"></script>
<script src="assets/js/app.js"></script>
</body>
</html>