410 lines
16 KiB
PHP
410 lines
16 KiB
PHP
<?php require_once('include/headscript.php'); ?>
|
|
|
|
<?php
|
|
// Creazione della connessione
|
|
$conn = new mysqli($servername, $username, $password, $dbname);
|
|
|
|
// 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 (per il form DayOff)
|
|
$idTeacher = 1;
|
|
|
|
// Gestione dell'inserimento del DayOff
|
|
if (isset($_POST['submit'])) {
|
|
$dayoffdate = $_POST['dayoff'];
|
|
$insertQuery = "INSERT INTO dayoff (idteacher, dayoffdate) VALUES (?, ?)";
|
|
$stmt = $conn->prepare($insertQuery);
|
|
$stmt->bind_param("is", $idTeacher, $dayoffdate);
|
|
if ($stmt->execute()) {
|
|
$message = 'success_dayoff';
|
|
} else {
|
|
$message = 'error_dayoff';
|
|
}
|
|
$stmt->close();
|
|
}
|
|
|
|
// Gestione dell'aggiornamento della data di scadenza
|
|
if (isset($_POST['update_expiry'])) {
|
|
$order_id = $_POST['order_id'];
|
|
$new_expiry = $_POST['new_expiry'];
|
|
$stmt = $conn->prepare("UPDATE orderbook SET expireon = ? WHERE order_id = ?");
|
|
$stmt->bind_param("si", $new_expiry, $order_id);
|
|
if ($stmt->execute()) {
|
|
$message = 'success';
|
|
} else {
|
|
$message = 'error';
|
|
}
|
|
$stmt->close();
|
|
}
|
|
|
|
// Gestione del filtro per gli ordini
|
|
$filter = isset($_GET['filter']) ? $_GET['filter'] : 'all';
|
|
$today = date("Y-m-d");
|
|
$whereClause = "";
|
|
if ($filter == 'active') {
|
|
$whereClause = "WHERE expireon > '$today'";
|
|
} elseif ($filter == 'expired') {
|
|
$whereClause = "WHERE expireon <= '$today'";
|
|
}
|
|
|
|
// Query SQL per recuperare tutti gli ordini con join su service
|
|
$query = "SELECT o.order_id, o.first_name, o.last_name, s.servicename, o.expireon, o.status, o.nticket
|
|
FROM orderbook o
|
|
LEFT JOIN service s ON o.idservice = s.idservice
|
|
$whereClause
|
|
ORDER BY o.order_id DESC";
|
|
$result = $conn->query($query);
|
|
$orders = [];
|
|
if ($result->num_rows > 0) {
|
|
while ($row = $result->fetch_assoc()) {
|
|
$orders[] = $row;
|
|
}
|
|
}
|
|
|
|
// Query SQL per i DayOff
|
|
$query_dayoff = "SELECT iddayoff, dayoffdate FROM dayoff WHERE idteacher = '1'";
|
|
$result_dayoff = $conn->query($query_dayoff);
|
|
$documents = [];
|
|
if ($result_dayoff->num_rows > 0) {
|
|
while ($row = $result_dayoff->fetch_assoc()) {
|
|
$documents[] = $row;
|
|
}
|
|
}
|
|
?>
|
|
|
|
<!doctype html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>YogiBook - Prenotazioni YogaSoul</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@10"></script>
|
|
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
|
|
<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>
|
|
<script>
|
|
$(function() {
|
|
// Inizializzazione del Datepicker per i campi DayOff
|
|
$("#dayoff").datepicker({
|
|
dateFormat: "yy-mm-dd",
|
|
minDate: 0
|
|
});
|
|
|
|
// Inizializzazione del Datepicker per i campi di scadenza editabili
|
|
$(document).on('focus', '.expiryDateInput', function() {
|
|
$(this).datepicker({
|
|
dateFormat: "yy-mm-dd",
|
|
minDate: 0,
|
|
onSelect: function(dateText) {
|
|
let orderId = $(this).data('order-id');
|
|
confirmUpdate(orderId, dateText);
|
|
}
|
|
});
|
|
});
|
|
|
|
// Rendere il campo scadenza editabile al click
|
|
$(document).on('click', '.expiry-date', function() {
|
|
let orderId = $(this).data('order-id');
|
|
let currentDate = $(this).text().trim();
|
|
$(this).html(`<input type="text" class="form-control expiryDateInput" data-order-id="${orderId}" value="${currentDate}" />`);
|
|
$(this).find('.expiryDateInput').focus();
|
|
});
|
|
|
|
// Funzione per confermare l'aggiornamento della scadenza
|
|
function confirmUpdate(orderId, newExpiry) {
|
|
Swal.fire({
|
|
title: "Sei sicuro?",
|
|
text: "La data di scadenza verrà modificata!",
|
|
icon: "warning",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#3085d6",
|
|
cancelButtonColor: "#d33",
|
|
confirmButtonText: "Sì, modifica!",
|
|
cancelButtonText: "Annulla"
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
let form = $('<form>', {
|
|
'method': 'POST',
|
|
'action': ''
|
|
}).append(
|
|
$('<input>', {
|
|
'type': 'hidden',
|
|
'name': 'order_id',
|
|
'value': orderId
|
|
}),
|
|
$('<input>', {
|
|
'type': 'hidden',
|
|
'name': 'new_expiry',
|
|
'value': newExpiry
|
|
}),
|
|
$('<input>', {
|
|
'type': 'hidden',
|
|
'name': 'update_expiry',
|
|
'value': '1'
|
|
})
|
|
);
|
|
$('body').append(form);
|
|
form.submit();
|
|
} else {
|
|
location.reload();
|
|
}
|
|
});
|
|
}
|
|
|
|
// Funzione per confermare la cancellazione (mantenuta dal template originale)
|
|
function confirmDelete(id, deletePageUrl) {
|
|
Swal.fire({
|
|
title: "Sei sicuro?",
|
|
text: "Questa prenotazione verrà cancellata definitivamente! Ricordati poi di riprogrammare la tua lezione!",
|
|
icon: "warning",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#d33",
|
|
cancelButtonColor: "#3085d6",
|
|
confirmButtonText: "Sì, cancella!",
|
|
cancelButtonText: "Annulla"
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
window.location.href = `deleteclass.php?id=${id}`;
|
|
}
|
|
});
|
|
}
|
|
});
|
|
</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;
|
|
border: none;
|
|
padding: 8px 12px;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
transition: background-color 0.2s;
|
|
}
|
|
|
|
.custom-action-button:hover {
|
|
background-color: #e0e0e0;
|
|
}
|
|
|
|
.expiry-date {
|
|
cursor: pointer;
|
|
}
|
|
|
|
.expiry-date:hover {
|
|
background-color: #f0f0f0;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.custom-card {
|
|
flex-direction: column;
|
|
}
|
|
|
|
.custom-date-box,
|
|
.custom-event-details {
|
|
width: 100%;
|
|
border-radius: 0;
|
|
}
|
|
|
|
.custom-event-time {
|
|
font-size: 24px;
|
|
}
|
|
}
|
|
</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">Riepilogo Ordini</h4>
|
|
</div>
|
|
</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>
|
|
</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>
|
|
</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-xl-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h5>Riepilogo Ordini (Amministratore)</h5>
|
|
<p>Tutti gli ordini registrati</p>
|
|
<div class="mb-3">
|
|
<a href="?filter=all" class="btn btn-secondary <?php echo $filter == 'all' ? 'active' : ''; ?>">Tutti</a>
|
|
<a href="?filter=active" class="btn btn-success <?php echo $filter == 'active' ? 'active' : ''; ?>">Attivi</a>
|
|
<a href="?filter=expired" class="btn btn-danger <?php echo $filter == 'expired' ? 'active' : ''; ?>">Scaduti</a>
|
|
</div>
|
|
<div class="table-responsive">
|
|
<table class="table table-striped mb-0">
|
|
<thead>
|
|
<tr>
|
|
<th>Stato</th>
|
|
<th>Numero Ordine</th>
|
|
<th>Nome</th>
|
|
<th>Cognome</th>
|
|
<th>Nome Classe</th>
|
|
<th>Numero Ticket</th>
|
|
<th>Scadenza</th>
|
|
<th>Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($orders as $order) {
|
|
$isActive = ($order["expireon"] > $today);
|
|
$badgeClass = $isActive ? 'badge bg-success' : 'badge bg-danger';
|
|
$badgeText = $isActive ? 'Attivo' : 'Scaduto';
|
|
?>
|
|
<tr>
|
|
<td><span class="<?php echo $badgeClass; ?>"><?php echo $badgeText; ?></span></td>
|
|
<td><?php echo $order["order_id"]; ?></td>
|
|
<td><?php echo $order["first_name"]; ?></td>
|
|
<td><?php echo $order["last_name"]; ?></td>
|
|
<td><?php echo $order["servicename"]; ?></td>
|
|
<td><?php echo $order["nticket"]; ?></td>
|
|
<td class="expiry-date" data-order-id="<?php echo $order['order_id']; ?>"><?php echo $order["expireon"]; ?></td>
|
|
<td><?php echo $order["status"]; ?></td>
|
|
</tr>
|
|
<?php } ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php include('include/footer.php'); ?>
|
|
</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>
|