fixed orders and riprogrammazione con scadenza
This commit is contained in:
parent
9254d420d2
commit
2d83c9da13
@ -1,45 +1,13 @@
|
||||
<?php require_once('include/headscript.php'); ?>
|
||||
<?php // require_once('Connections/bkngstm.php'); ?>
|
||||
<?php // require_once('webassist/mysqli/rsobj.php'); ?>
|
||||
<?php // require_once('webassist/mysqli/queryobj.php'); ?>
|
||||
<?php // optionquery
|
||||
<?php
|
||||
// optionquery
|
||||
$optionquery = new WA_MySQLi_RS("optionquery", $bkngstm, 0);
|
||||
$optionquery->setQuery("SELECT * FROM option");
|
||||
$optionquery->execute();
|
||||
?>
|
||||
<?php // array servicesordered
|
||||
/* $conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
// Verifica della connessione
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione al database fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// ID dell'utente per cui eseguire la query
|
||||
$iduser = 1;
|
||||
|
||||
// Query per selezionare i valori della colonna idservice per lo specifico iduser
|
||||
$sql = "SELECT idservice FROM orderbook WHERE iduser = $iduser";
|
||||
$result = $conn->query($sql);
|
||||
|
||||
$idserviceordered = array();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
// Memorizza i valori della colonna idservice nell'array $idserviceordered
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$idserviceordered[] = $row['idservice'];
|
||||
}
|
||||
} else {
|
||||
echo "Nessun risultato trovato.";
|
||||
}
|
||||
|
||||
// Chiudi la connessione al database
|
||||
$conn->close();
|
||||
|
||||
// Esempio di stampa dei valori memorizzati nell'array $idserviceordered
|
||||
print_r($idserviceordered); */
|
||||
?>
|
||||
<?php // array service possible
|
||||
<?php
|
||||
// array service possible
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
// Verifica della connessione
|
||||
@ -47,7 +15,7 @@ if ($conn->connect_error) {
|
||||
die("Connessione al database fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Prendi il valore di idservieordered dalla variabile GET
|
||||
// Prendi il valore di idservieordered dalla variabile GET o POST
|
||||
if (isset($_GET['id'])) {
|
||||
$idpreviousbooking = $_GET['id'];
|
||||
}
|
||||
@ -61,25 +29,37 @@ if (isset($_POST['idserviceordered'])) {
|
||||
$idserviceordered = $_POST['idserviceordered'];
|
||||
}
|
||||
|
||||
// Recupera la data di scadenza dell'ordine
|
||||
$expiryQuery = "SELECT expireon FROM orderbook WHERE order_id = ?";
|
||||
$stmt = $conn->prepare($expiryQuery);
|
||||
$stmt->bind_param("i", $idpreviousbooking);
|
||||
$stmt->execute();
|
||||
$expiryResult = $stmt->get_result();
|
||||
$expiryDate = null;
|
||||
if ($expiryResult->num_rows > 0) {
|
||||
$row = $expiryResult->fetch_assoc();
|
||||
$expiryDate = new DateTime($row['expireon']);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
|
||||
// Query sulla tabella associateclass
|
||||
$sql = "SELECT idassociateservice FROM associateclass WHERE idmainservice = $idserviceordered";
|
||||
$result = $conn->query($sql);
|
||||
$sql = "SELECT idassociateservice FROM associateclass WHERE idmainservice = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("i", $idserviceordered);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
$idassociateservices = array();
|
||||
array_push($idassociateservices, $idserviceordered);
|
||||
if ($result->num_rows > 0) {
|
||||
// Memorizza i valori della colonna idassociateservice nell'array $idassociateservices
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$idassociateservices[] = $row['idassociateservice'];
|
||||
}
|
||||
}
|
||||
|
||||
// Chiudi la connessione al database
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
|
||||
// Esempio di stampa dei valori memorizzati nell'array $idassociateservices
|
||||
//print_r($idassociateservices);
|
||||
?>
|
||||
|
||||
<?php
|
||||
@ -96,13 +76,21 @@ if (isset($_GET['prev_month'])) {
|
||||
|
||||
$currentMonthEnd = date("Y-m-t", strtotime($currentMonthStart));
|
||||
|
||||
// Aggiungi filtro per la data di scadenza se definita, includendo la data di scadenza
|
||||
$expiryCondition = '';
|
||||
if ($expiryDate) {
|
||||
$expiryCondition = "AND (serviceschedule.dateschedule <= '{$expiryDate->format('Y-m-d 23:59:59')}' OR serviceschedule.dateschedule = '{$expiryDate->format('Y-m-d')}')";
|
||||
}
|
||||
|
||||
$bookedclass->setQuery("SELECT * FROM serviceschedule
|
||||
LEFT JOIN service ON serviceschedule.idservice = service.idservice
|
||||
WHERE serviceschedule.dateschedule BETWEEN '$currentMonthStart' AND DATE_ADD('$currentMonthEnd', INTERVAL 1 DAY) ORDER BY serviceschedule.dateschedule");
|
||||
WHERE serviceschedule.dateschedule BETWEEN '$currentMonthStart' AND DATE_ADD('$currentMonthEnd', INTERVAL 1 DAY)
|
||||
$expiryCondition
|
||||
ORDER BY serviceschedule.dateschedule");
|
||||
$bookedclass->execute();
|
||||
?>
|
||||
<?php
|
||||
|
||||
<?php
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
@ -128,7 +116,6 @@ if ($result->num_rows > 0) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$idOrdine = $row["idorderbook"];
|
||||
$totalTickets = $row["total_tickets"];
|
||||
|
||||
}
|
||||
} else {
|
||||
$totalTickets = 0; // Imposta a zero se non ci sono righe nella query
|
||||
@ -136,20 +123,17 @@ if ($result->num_rows > 0) {
|
||||
|
||||
$conn->close();
|
||||
?>
|
||||
<?php //check tickets
|
||||
// Connessione al database
|
||||
|
||||
<?php
|
||||
//check tickets
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione al database fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// ID dell'utente per il quale si desidera eseguire la query
|
||||
$iduser = 1; // Sostituisci con l'ID utente desiderato
|
||||
|
||||
// Data e ora attuali
|
||||
$currentDateTime = date("Y-m-d H:i:s");
|
||||
|
||||
// Query per contare i record con data e ora passate e future
|
||||
$query = "SELECT COUNT(*) AS total,
|
||||
SUM(CASE WHEN serviceschedule.dateschedule <= '$currentDateTime' THEN 1 ELSE 0 END) AS passed,
|
||||
SUM(CASE WHEN serviceschedule.dateschedule > '$currentDateTime' THEN 1 ELSE 0 END) AS future
|
||||
@ -163,10 +147,8 @@ if ($result) {
|
||||
$totalRecords = $row['total'];
|
||||
$passedRecords = $row['passed'];
|
||||
$futureRecords = $row['future'];
|
||||
|
||||
|
||||
}
|
||||
// Chiusura della connessione
|
||||
|
||||
$conn->close();
|
||||
?>
|
||||
|
||||
@ -174,23 +156,16 @@ $conn->close();
|
||||
<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" />
|
||||
<!-- App favicon -->
|
||||
<meta content="Advanced Creative Solutions" author />
|
||||
<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">
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
|
||||
|
||||
<style>
|
||||
@ -280,7 +255,8 @@ $conn->close();
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.custom-date-box, .custom-event-details {
|
||||
.custom-date-box,
|
||||
.custom-event-details {
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
}
|
||||
@ -289,8 +265,7 @@ $conn->close();
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
|
||||
.month-navigation {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
@ -310,62 +285,38 @@ $conn->close();
|
||||
margin: 0 20px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script>
|
||||
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) {
|
||||
// Reindirizza direttamente alla pagina di cancellazione con l'ID come parametro.
|
||||
window.location.href = `deleteclass.php?id=${id}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.pastel-color {
|
||||
border: 1px solid #D1C4CC;
|
||||
padding: 0px;
|
||||
text-align: center;
|
||||
border-radius: 10px;
|
||||
margin-right: 20px; /* Spazio tra i box */
|
||||
margin-right: 20px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.pastel-color.blue {
|
||||
background-color: #D4E1F1; /* Azzurro pastello */
|
||||
background-color: #D4E1F1;
|
||||
}
|
||||
|
||||
.pastel-color.green {
|
||||
background-color: #FFD8B5; /* Verde pastello */
|
||||
background-color: #FFD8B5;
|
||||
}
|
||||
|
||||
.pastel-color.pink {
|
||||
background-color: #C3E6CB; /* Rosa pastello */
|
||||
background-color: #C3E6CB;
|
||||
}
|
||||
|
||||
.pastel-color.purple {
|
||||
background-color: #F4CCCC; /* Viola pastello */
|
||||
}
|
||||
background-color: #F4CCCC;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.pastel-color {
|
||||
margin-right: 0; /* Rimuovi lo spazio tra i box */
|
||||
margin-bottom: 20px; /* Spazio tra i box */
|
||||
margin-right: 0;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
|
||||
.booking-details {
|
||||
margin-top: 10px;
|
||||
border-top: 1px solid #ccc;
|
||||
@ -396,107 +347,69 @@ $conn->close();
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
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>
|
||||
|
||||
<body>
|
||||
|
||||
<!-- <body data-layout="horizontal"> -->
|
||||
|
||||
<!-- 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">Riprogramma la tua lezione</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>
|
||||
</div>
|
||||
</form>
|
||||
</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 class="d-flex"></div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="topnav">
|
||||
<div class="container-fluid">
|
||||
<nav class="navbar navbar-light navbar-expand-lg topnav-menu">
|
||||
|
||||
|
||||
</nav>
|
||||
<nav class="navbar navbar-light navbar-expand-lg topnav-menu"></nav>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- ============================================================== -->
|
||||
<!-- Start right Content here -->
|
||||
<!-- ============================================================== -->
|
||||
<div class="main-content">
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
|
||||
|
||||
<?php
|
||||
$toprogram = $totalTickets - $passedRecords - $futureRecords;
|
||||
|
||||
?>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<div class="">
|
||||
<div class="row mb-2">
|
||||
<div class="col-xl-3 col-md-12">
|
||||
@ -504,12 +417,10 @@ $conn->close();
|
||||
<form class="email-search">
|
||||
<div class="position-relative">
|
||||
<h3>Riprogrammazione Lezione</h3>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xl-9 col-md-12">
|
||||
<div class="text-sm-end">
|
||||
<?php if ($toprogram > 0) {
|
||||
@ -517,31 +428,16 @@ $conn->close();
|
||||
}
|
||||
?>
|
||||
<button type="button" class="btn btn-success btn-rounded waves-effect waves-light mb-2 me-2" data-bs-toggle="modal" data-bs-target=".create-task"><i class="mdi mdi-plus me-1"></i> Acquista Pacchetto Lezioni</button>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
|
||||
<div class="container-fluid">
|
||||
<!-- starts cards -->
|
||||
|
||||
|
||||
|
||||
<!-- Aggiungi le frecce per la navigazione tra i mesi -->
|
||||
<?php
|
||||
$italianMonths = [
|
||||
"January" => "Gennaio",
|
||||
@ -557,143 +453,73 @@ $conn->close();
|
||||
"November" => "Novembre",
|
||||
"December" => "Dicembre"
|
||||
];
|
||||
|
||||
?>
|
||||
<div class="month-navigation">
|
||||
|
||||
<a href="?prev_month=<?php echo date('Y-m', strtotime('-1 month', strtotime($currentMonthStart))); ?>&idserviceordered=<?php echo $idserviceordered; ?>&id=<?php echo $idpreviousbooking; ?>" class="arrow-link">
|
||||
<i class="fas fa-chevron-left fa-2x"></i>
|
||||
</a>
|
||||
|
||||
<h2><?php echo $italianMonths[date("F", strtotime($currentMonthStart))] . ' ' . date("Y", strtotime($currentMonthStart)); ?></h2>
|
||||
<a href="?next_month=<?php echo date('Y-m', strtotime('+1 month', strtotime($currentMonthStart))); ?>&idserviceordered=<?php echo $idserviceordered; ?>&id=<?php echo $idpreviousbooking; ?>" class="arrow-link">
|
||||
<i class="fas fa-chevron-right fa-2x"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
$wa_startindex = 0;
|
||||
|
||||
if ($bookedclass->TotalRows == 0) {
|
||||
echo "<p>Classi non presenti per questo mese</p>";
|
||||
echo "<p>Classi non presenti per questo mese o oltre la data di scadenza</p>";
|
||||
} else {
|
||||
while (!$bookedclass->atEnd()) {
|
||||
$wa_startindex = $bookedclass->Index;
|
||||
?>
|
||||
<?php
|
||||
// Data dalla variabile $bookedclass->getColumnVal("dateschedule")
|
||||
$dateschedule = $bookedclass->getColumnVal("dateschedule");
|
||||
|
||||
// Converti la data in un oggetto DateTime
|
||||
$dateObj = new DateTime($dateschedule);
|
||||
|
||||
// Estrai il giorno e il mese in italiano
|
||||
$dayInItalian = $dateObj->format("d");
|
||||
$monthInItalian = $dateObj->format("F");
|
||||
|
||||
// Mappa dei nomi dei mesi in italiano
|
||||
$italianMonths = [
|
||||
"January" => "Gennaio",
|
||||
"February" => "Febbraio",
|
||||
"March" => "Marzo",
|
||||
"April" => "Aprile",
|
||||
"May" => "Maggio",
|
||||
"June" => "Giugno",
|
||||
"July" => "Luglio",
|
||||
"August" => "Agosto",
|
||||
"September" => "Settembre",
|
||||
"October" => "Ottobre",
|
||||
"November" => "Novembre",
|
||||
"December" => "Dicembre"
|
||||
];
|
||||
|
||||
// Sostituisci il nome del mese con la versione italiana
|
||||
$monthInItalian = $italianMonths[$monthInItalian];
|
||||
?>
|
||||
<?php
|
||||
// Data dalla variabile $bookedclass->getColumnVal("dateschedule")
|
||||
$dateschedule = $bookedclass->getColumnVal("dateschedule");
|
||||
|
||||
// Converti la data in un oggetto DateTime
|
||||
$dateObj = new DateTime($dateschedule);
|
||||
|
||||
// Formatta la data nel nuovo formato desiderato
|
||||
$monthInItalian = $italianMonths[$dateObj->format("F")];
|
||||
$newDateFormat = $dateObj->format("d-m-Y H:i");
|
||||
|
||||
// Calculate the time difference in hours
|
||||
$currentTime = new DateTime();
|
||||
$classTime = new DateTime($dateschedule);
|
||||
$timeDifference = $classTime->diff($currentTime);
|
||||
$hoursDifference = $timeDifference->h + $timeDifference->days * 24;
|
||||
|
||||
// Check if the time difference is less than 6 hours
|
||||
$timetocancel = $optionquery->getColumnVal("maxbeforetimecancell");
|
||||
$canBeDeleted = ($hoursDifference >= $timetocancel);
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<?php $mysqli = new mysqli($servername, $username, $password, $dbname);
|
||||
// Esegui una nuova query per ottenere le persone prenotate per l'evento corrente
|
||||
$mysqli = new mysqli($servername, $username, $password, $dbname);
|
||||
$eventId = $bookedclass->getColumnVal("idserviceschedule");
|
||||
$bookingQuery = "SELECT iduser FROM bookingclass
|
||||
WHERE bookingclass.idserviceschedule = $eventId AND bookingclass.status='booked'";
|
||||
$bookingResult = $mysqli->query($bookingQuery);
|
||||
|
||||
// Calcola il numero di persone prenotate
|
||||
$bookingQuery = "SELECT iduser FROM bookingclass WHERE bookingclass.idserviceschedule = ? AND bookingclass.status='booked'";
|
||||
$stmt = $mysqli->prepare($bookingQuery);
|
||||
$stmt->bind_param("i", $eventId);
|
||||
$stmt->execute();
|
||||
$bookingResult = $stmt->get_result();
|
||||
$countPersons = $bookingResult->num_rows;
|
||||
$stmt->close();
|
||||
|
||||
?>
|
||||
<?php // check if service possible to bookedclass
|
||||
|
||||
// Esempio: Simula il valore di $bookedclass->getColumnVal("servicename")
|
||||
$cardservice = $bookedclass->getColumnVal("idservice");
|
||||
|
||||
// Verifica se il valore di $cardservice è presente nell'array $idassociateservices
|
||||
if (in_array($cardservice, $idassociateservices)) {
|
||||
// Il valore è presente, esegui il codice successivo
|
||||
|
||||
?>
|
||||
<?php
|
||||
$maxcapacity = $bookedclass->getColumnVal("maxcapacity");
|
||||
$freeplace = $maxcapacity - $countPersons;
|
||||
?>
|
||||
|
||||
<?php //query check active bookingclass
|
||||
// Crea la connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
// Variabili dei dati da verificare
|
||||
$idcheckservice = $bookedclass->getColumnVal("idserviceschedule"); // Sostituisci con il tuo valore
|
||||
$iduser = $iduserlog; // Sostituisci con il tuo valore
|
||||
|
||||
// Query per verificare l'esistenza del record
|
||||
$query = "SELECT * FROM bookingclass WHERE idserviceschedule = $idcheckservice AND iduser = $iduser";
|
||||
$resultcheck = $conn->query($query);
|
||||
|
||||
if ($resultcheck->num_rows > 0) {
|
||||
$alreadybooked='Y'; // record found
|
||||
} else {
|
||||
$alreadybooked='N';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$idcheckservice = $bookedclass->getColumnVal("idserviceschedule");
|
||||
$iduser = $iduserlog;
|
||||
$query = "SELECT * FROM bookingclass WHERE idserviceschedule = ? AND iduser = ?";
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->bind_param("ii", $idcheckservice, $iduser);
|
||||
$stmt->execute();
|
||||
$resultcheck = $stmt->get_result();
|
||||
$alreadybooked = $resultcheck->num_rows > 0 ? 'Y' : 'N';
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
|
||||
|
||||
<div class="custom-card" onclick="toggleCard(this)">
|
||||
|
||||
|
||||
|
||||
|
||||
<?php if ($alreadybooked == 'Y') { ?>
|
||||
<div class="custom-date-box" style="background-color:#FF6609">
|
||||
<?php } elseif ($freeplace > 0) { ?><div class="custom-date-box" style="background-color: #1ebf73">
|
||||
<?php } else { ?><div class="custom-date-box" style="background-color: #9C9C9C"><?php } ?>
|
||||
<?php } elseif ($freeplace > 0) { ?>
|
||||
<div class="custom-date-box" style="background-color:#1ebf73">
|
||||
<?php } else { ?>
|
||||
<div class="custom-date-box" style="background-color:#9C9C9C">
|
||||
<?php } ?>
|
||||
<div class="custom-day"><?php echo $dayInItalian; ?></div>
|
||||
<div class="custom-month"><?php echo $monthInItalian; ?></div>
|
||||
</div>
|
||||
@ -701,57 +527,46 @@ if ($resultcheck->num_rows > 0) {
|
||||
<div class="custom-event-details" style="background-color:#FFAC7A">
|
||||
<?php } elseif ($freeplace > 0) { ?>
|
||||
<div class="custom-event-details" style="background-color:<?php echo ($bookedclass->getColumnVal("colorclass")); ?>">
|
||||
<?php } else { ?><div class="custom-event-details" style="background-color:#CDCDCD"><?php } ?>
|
||||
<?php } else { ?>
|
||||
<div class="custom-event-details" style="background-color:#CDCDCD">
|
||||
<?php } ?>
|
||||
<h2 class="custom-heading"><?php echo ($bookedclass->getColumnVal("servicename")); ?> -<?php echo $countPersons; ?>/<?php echo ($bookedclass->getColumnVal("maxcapacity")); ?></h2>
|
||||
<p class="custom-paragraph">Quando: <?php echo $newDateFormat; ?></p>
|
||||
<p class="custom-paragraph">Luogo: via Valassina 62/B Seregno - Sala Contesto Yoga</p>
|
||||
<?php $idnewbooking = $bookedclass->getColumnVal("idserviceschedule"); ?>
|
||||
<?php $idservicenew = $bookedclass->getColumnVal("idservice"); ?>
|
||||
<!-- Mostra l'elenco delle persone prenotate solo se ce ne sono -->
|
||||
|
||||
<div class="booking-details">
|
||||
<?php if ($alreadybooked == 'Y') { ?>
|
||||
<button class="booking-button"><i class="fa fa-check"></i> Sei già prenotata/o</button>
|
||||
<?php } elseif ($freeplace > 0) { ?>
|
||||
<a href="rebookandgo.php?idpreviousbooking=<?php echo $idpreviousbooking; ?>&idservicenew=<?php echo $idservicenew; ?>&idnewbooking=<?php echo $idnewbooking; ?>&iduser=<?php echo $iduserlogin; ?>"?><button class="booking-button"><i class="fas fa-arrow-circle-right"></i> Riprogramma Classe</button></a>
|
||||
<a href="rebookandgo.php?idpreviousbooking=<?php echo $idpreviousbooking; ?>&idservicenew=<?php echo $idservicenew; ?>&idnewbooking=<?php echo $idnewbooking; ?>&iduser=<?php echo $iduserlogin; ?>"><button class="booking-button"><i class="fas fa-arrow-circle-right"></i> Riprogramma Classe</button></a>
|
||||
<?php } else { ?>
|
||||
<button class="booking-button"><i class="fa fa-stop"></i> Classe Piena</button>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
}
|
||||
$bookedclass->moveNext();
|
||||
}
|
||||
}
|
||||
|
||||
$bookedclass->moveFirst(); // Ritorna all'inizio del recordset
|
||||
$bookedclass->moveFirst();
|
||||
unset($wa_startindex);
|
||||
unset($wa_repeatcount);
|
||||
?>
|
||||
<!-- Aggiungi altre card qui con le stesse classi -->
|
||||
|
||||
<div class="month-navigation">
|
||||
|
||||
<a href="?prev_month=<?php echo date('Y-m', strtotime('-1 month', strtotime($currentMonthStart))); ?>&idserviceordered=<?php echo $idserviceordered; ?>&id=<?php echo $idpreviousbooking; ?>" class="arrow-link">
|
||||
<i class="fas fa-chevron-left fa-2x"></i>
|
||||
</a>
|
||||
|
||||
<h2><?php echo $italianMonths[date("F", strtotime($currentMonthStart))] . ' ' . date("Y", strtotime($currentMonthStart)); ?></h2>
|
||||
<a href="?next_month=<?php echo date('Y-m', strtotime('+1 month', strtotime($currentMonthStart))); ?>&idserviceordered=<?php echo $idserviceordered; ?>&id=<?php echo $idpreviousbooking; ?>" class="arrow-link">
|
||||
<i class="fas fa-chevron-right fa-2x"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function toggleCard(card) {
|
||||
@ -759,32 +574,16 @@ unset($wa_repeatcount);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Page-content -->
|
||||
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
<!-- end main content-->
|
||||
|
||||
</div>
|
||||
<!-- END layout-wrapper -->
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- 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>
|
||||
<script src="assets/libs/eva-icons/eva.min.js"></script>
|
||||
|
||||
<script src="assets/js/app.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -1,5 +1,6 @@
|
||||
<?php require_once('include/headscript.php'); ?>
|
||||
<?php // optionquery
|
||||
<?php
|
||||
// optionquery
|
||||
$optionquery = new WA_MySQLi_RS("optionquery", $bkngstm, 0);
|
||||
$optionquery->setQuery("SELECT * FROM option");
|
||||
$optionquery->execute();
|
||||
@ -8,83 +9,363 @@ $optionquery->execute();
|
||||
<?php
|
||||
// Verifica se è stato inviato un modulo
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// Verifica se è stato caricato un file correttamente
|
||||
if (isset($_FILES["fileToUpload"]) && $_FILES["fileToUpload"]["error"] === UPLOAD_ERR_OK) {
|
||||
|
||||
|
||||
// Crea la connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
// Verifica la connessione
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione al database fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Ottieni l'ID dell'utente (da dove viene?)
|
||||
$iduserlogin = $_POST["iduserlogin"];
|
||||
|
||||
|
||||
|
||||
// Chiudi la connessione al database
|
||||
$conn->close();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
// Crea la connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
// Verifica la connessione
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione al database fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Query per selezionare i dati filtrati per iduser
|
||||
$query = "SELECT * FROM orderbook LEFT JOIN service ON orderbook.idservice=service.idservice WHERE iduser = '$iduserlogin'";
|
||||
$query = "SELECT o.*, s.servicename, s.day, s.time
|
||||
FROM orderbook o
|
||||
LEFT JOIN service s ON o.idservice = s.idservice
|
||||
WHERE o.iduser = '$iduserlogin'";
|
||||
$result = $conn->query($query);
|
||||
|
||||
// Array per memorizzare i risultati
|
||||
$documents = array();
|
||||
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
// Get lesson details for each order
|
||||
$order_id = $row['order_id'];
|
||||
$lesson_query = "SELECT bc.bookingstart, bc.status, bc.lostlesson, bc.expirylesson, s.servicename
|
||||
FROM bookingclass bc
|
||||
LEFT JOIN service s ON bc.idservice = s.idservice
|
||||
WHERE bc.idorder = '$order_id'";
|
||||
$lesson_result = $conn->query($lesson_query);
|
||||
$lessons = array();
|
||||
while ($lesson_row = $lesson_result->fetch_assoc()) {
|
||||
$lessons[] = $lesson_row;
|
||||
}
|
||||
$row['lessons'] = $lessons;
|
||||
$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" />
|
||||
<!-- 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">
|
||||
|
||||
<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() {
|
||||
$("#expiryDate").datepicker({ dateFormat: "yy-mm-dd" });
|
||||
$("#expiryDate").datepicker({
|
||||
dateFormat: "yy-mm-dd"
|
||||
});
|
||||
|
||||
// Handle order click for popup
|
||||
$('.order-row').click(function() {
|
||||
var lessons = $(this).data('lessons');
|
||||
var total = $(this).data('total');
|
||||
var orderId = $(this).data('order-id');
|
||||
var isExpired = $(this).data('is-expired');
|
||||
|
||||
// Calcolo delle date
|
||||
var now = new Date();
|
||||
|
||||
// Calcolo dei conteggi
|
||||
var completed = lessons.filter(l => {
|
||||
var lessonDate = new Date(l.bookingstart);
|
||||
return (l.status === 'completed') ||
|
||||
(l.status === 'booked' && lessonDate < now && l.lostlesson !== 'Y' && l.expirylesson !== 'Y');
|
||||
}).length;
|
||||
var lost = lessons.filter(l => l.lostlesson === 'Y').length;
|
||||
var expired = lessons.filter(l => l.expirylesson === 'Y').length;
|
||||
var booked = lessons.filter(l => {
|
||||
var lessonDate = new Date(l.bookingstart);
|
||||
return (l.status === 'booked' && lessonDate >= now && l.lostlesson !== 'Y' && l.expirylesson !== 'Y');
|
||||
}).length;
|
||||
var toSchedule = total - (booked + completed + lost + expired);
|
||||
|
||||
var htmlContent = `
|
||||
<h4 style="margin-bottom: 20px; color: #333; font-weight: 600;">
|
||||
Dettagli Ordine #${orderId}
|
||||
<span class="badge ${isExpired ? 'bg-danger' : 'bg-primary'}" style="margin-left: 10px; color: white;">
|
||||
${isExpired ? 'Scaduto' : 'Attivo'}
|
||||
</span>
|
||||
</h4>
|
||||
<div style="display: flex; justify-content: space-around; margin-bottom: 30px; gap: 10px;">
|
||||
<div class="stat-box" style="background-color: #d1e7dd; border: 1px solid #a3cfbb;">
|
||||
<h5 style="margin: 0; color: #0f5132; font-size: 14px;">Totale</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #0f5132;">${total}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #d4edda; border: 1px solid #b1d4b6;">
|
||||
<h5 style="margin: 0; color: #155724; font-size: 14px;">Fatte</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #155724;">${completed}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #f8d7da; border: 1px solid #f1aeb5;">
|
||||
<h5 style="margin: 0; color: #721c24; font-size: 14px;">Perse</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #721c24;">${lost}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #fff3cd; border: 1px solid #ffecb5;">
|
||||
<h5 style="margin: 0; color: #856404; font-size: 14px;">Scadute</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #856404;">${expired}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #e2d3f5; border: 1px solid #c3b2d6;">
|
||||
<h5 style="margin: 0; color: #4c2c92; font-size: 14px;">Da Programmare</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #4c2c92;">${toSchedule}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 8px;">
|
||||
<table class="lesson-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Data e Ora</th>
|
||||
<th>Lezione</th>
|
||||
<th>Stato</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
`;
|
||||
|
||||
if (lessons.length === 0) {
|
||||
htmlContent += `
|
||||
<tr>
|
||||
<td colspan="3" style="text-align: center; padding: 10px; color: #666; font-size: 13px;">
|
||||
Nessuna lezione trovata per questo ordine.
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
} else {
|
||||
lessons.forEach(function(lesson, index) {
|
||||
var lessonDate = new Date(lesson.bookingstart);
|
||||
var statusText = lesson.status;
|
||||
var badgeClass = 'bg-primary';
|
||||
var badgeTextColor = '#fff';
|
||||
if (lesson.status === 'completed') {
|
||||
badgeClass = 'bg-success';
|
||||
badgeTextColor = '#fff';
|
||||
statusText = 'Completata';
|
||||
} else if (lesson.lostlesson === 'Y') {
|
||||
badgeClass = 'bg-danger';
|
||||
badgeTextColor = '#fff';
|
||||
statusText = 'Persa';
|
||||
} else if (lesson.expirylesson === 'Y') {
|
||||
badgeClass = 'bg-warning';
|
||||
badgeTextColor = '#000';
|
||||
statusText = 'Scaduta';
|
||||
} else if (lesson.status === 'booked') {
|
||||
if (lessonDate < now && lesson.lostlesson !== 'Y' && lesson.expirylesson !== 'Y') {
|
||||
statusText = 'Completata';
|
||||
badgeClass = 'bg-success';
|
||||
badgeTextColor = '#fff';
|
||||
} else {
|
||||
statusText = 'Programmata';
|
||||
}
|
||||
}
|
||||
|
||||
htmlContent += `
|
||||
<tr class="${index % 2 === 0 ? 'even-row' : 'odd-row'}">
|
||||
<td style="padding: 8px; font-size: 13px;">${lessonDate.toLocaleString('it-IT', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
})}</td>
|
||||
<td style="padding: 8px; font-size: 13px;">${lesson.servicename}</td>
|
||||
<td style="padding: 8px;">
|
||||
<span class="badge ${badgeClass}" style="color: ${badgeTextColor}; padding: 6px 10px; font-size: 12px; font-weight: 500;">${statusText}</span>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
}
|
||||
|
||||
htmlContent += `
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
`;
|
||||
|
||||
Swal.fire({
|
||||
title: '',
|
||||
html: htmlContent,
|
||||
confirmButtonText: 'Chiudi',
|
||||
width: '1000px',
|
||||
customClass: {
|
||||
popup: 'custom-modal'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Handle details button click
|
||||
$('.details-btn').click(function(e) {
|
||||
e.stopPropagation(); // Prevent row click event
|
||||
var row = $(this).closest('tr');
|
||||
var lessons = row.data('lessons');
|
||||
var total = row.data('total');
|
||||
var orderId = row.data('order-id');
|
||||
var isExpired = row.data('is-expired');
|
||||
|
||||
// Calcolo delle date
|
||||
var now = new Date();
|
||||
|
||||
// Calcolo dei conteggi
|
||||
var completed = lessons.filter(l => {
|
||||
var lessonDate = new Date(l.bookingstart);
|
||||
return (l.status === 'completed') ||
|
||||
(l.status === 'booked' && lessonDate < now && l.lostlesson !== 'Y' && l.expirylesson !== 'Y');
|
||||
}).length;
|
||||
var lost = lessons.filter(l => l.lostlesson === 'Y').length;
|
||||
var expired = lessons.filter(l => l.expirylesson === 'Y').length;
|
||||
var booked = lessons.filter(l => {
|
||||
var lessonDate = new Date(l.bookingstart);
|
||||
return (l.status === 'booked' && lessonDate >= now && l.lostlesson !== 'Y' && l.expirylesson !== 'Y');
|
||||
}).length;
|
||||
var toSchedule = total - (booked + completed + lost + expired);
|
||||
|
||||
var htmlContent = `
|
||||
<h4 style="margin-bottom: 20px; color: #333; font-weight: 600;">
|
||||
Dettagli Ordine #${orderId}
|
||||
<span class="badge ${isExpired ? 'bg-danger' : 'bg-primary'}" style="margin-left: 10px; color: white;">
|
||||
${isExpired ? 'Scaduto' : 'Attivo'}
|
||||
</span>
|
||||
</h4>
|
||||
<div style="display: flex; justify-content: space-around; margin-bottom: 30px; gap: 10px;">
|
||||
<div class="stat-box" style="background-color: #d1e7dd; border: 1px solid #a3cfbb;">
|
||||
<h5 style="margin: 0; color: #0f5132; font-size: 14px;">Totale</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #0f5132;">${total}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #d4edda; border: 1px solid #b1d4b6;">
|
||||
<h5 style="margin: 0; color: #155724; font-size: 14px;">Fatte</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #155724;">${completed}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #f8d7da; border: 1px solid #f1aeb5;">
|
||||
<h5 style="margin: 0; color: #721c24; font-size: 14px;">Perse</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #721c24;">${lost}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #fff3cd; border: 1px solid #ffecb5;">
|
||||
<h5 style="margin: 0; color: #856404; font-size: 14px;">Scadute</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #856404;">${expired}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #e2d3f5; border: 1px solid #c3b2d6;">
|
||||
<h5 style="margin: 0; color: #4c2c92; font-size: 14px;">Da Programmare</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #4c2c92;">${toSchedule}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 8px;">
|
||||
<table class="lesson-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Data e Ora</th>
|
||||
<th>Lezione</th>
|
||||
<th>Stato</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
`;
|
||||
|
||||
if (lessons.length === 0) {
|
||||
htmlContent += `
|
||||
<tr>
|
||||
<td colspan="3" style="text-align: center; padding: 10px; color: #666; font-size: 13px;">
|
||||
Nessuna lezione trovata per questo ordine.
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
} else {
|
||||
lessons.forEach(function(lesson, index) {
|
||||
var lessonDate = new Date(lesson.bookingstart);
|
||||
var statusText = lesson.status;
|
||||
var badgeClass = 'bg-primary';
|
||||
var badgeTextColor = '#fff';
|
||||
if (lesson.status === 'completed') {
|
||||
badgeClass = 'bg-success';
|
||||
badgeTextColor = '#fff';
|
||||
statusText = 'Completata';
|
||||
} else if (lesson.lostlesson === 'Y') {
|
||||
badgeClass = 'bg-danger';
|
||||
badgeTextColor = '#fff';
|
||||
statusText = 'Persa';
|
||||
} else if (lesson.expirylesson === 'Y') {
|
||||
badgeClass = 'bg-warning';
|
||||
badgeTextColor = '#000';
|
||||
statusText = 'Scaduta';
|
||||
} else if (lesson.status === 'booked') {
|
||||
if (lessonDate < now && lesson.lostlesson !== 'Y' && lesson.expirylesson !== 'Y') {
|
||||
statusText = 'Completata';
|
||||
badgeClass = 'bg-success';
|
||||
badgeTextColor = '#fff';
|
||||
} else {
|
||||
statusText = 'Programmata';
|
||||
}
|
||||
}
|
||||
|
||||
htmlContent += `
|
||||
<tr class="${index % 2 === 0 ? 'even-row' : 'odd-row'}">
|
||||
<td style="padding: 8px; font-size: 13px;">${lessonDate.toLocaleString('it-IT', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
})}</td>
|
||||
<td style="padding: 8px; font-size: 13px;">${lesson.servicename}</td>
|
||||
<td style="padding: 8px;">
|
||||
<span class="badge ${badgeClass}" style="color: ${badgeTextColor}; padding: 6px 10px; font-size: 12px; font-weight: 500;">${statusText}</span>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
}
|
||||
|
||||
htmlContent += `
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
`;
|
||||
|
||||
Swal.fire({
|
||||
title: '',
|
||||
html: htmlContent,
|
||||
confirmButtonText: 'Chiudi',
|
||||
width: '1000px',
|
||||
customClass: {
|
||||
popup: 'custom-modal'
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
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 {
|
||||
@ -106,7 +387,7 @@ while ($row = $result->fetch_assoc()) {
|
||||
|
||||
.custom-date-box {
|
||||
flex: 1;
|
||||
background-color: red;
|
||||
background-color: #ff4d4f;
|
||||
color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@ -132,7 +413,7 @@ while ($row = $result->fetch_assoc()) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px 20px;
|
||||
background-color: lightblue;
|
||||
background-color: #e6f3ff;
|
||||
}
|
||||
|
||||
.custom-heading {
|
||||
@ -173,7 +454,8 @@ while ($row = $result->fetch_assoc()) {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.custom-date-box, .custom-event-details {
|
||||
.custom-date-box,
|
||||
.custom-event-details {
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
}
|
||||
@ -182,97 +464,128 @@ while ($row = $result->fetch_assoc()) {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.order-row {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.order-row:hover {
|
||||
background-color: #f8f9fa !important;
|
||||
}
|
||||
|
||||
.stat-box {
|
||||
padding: 12px;
|
||||
border-radius: 8px;
|
||||
text-align: center;
|
||||
width: 18%;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.stat-box:hover {
|
||||
transform: translateY(-3px);
|
||||
}
|
||||
|
||||
.custom-modal .swal2-content {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.custom-modal .lesson-table {
|
||||
width: 100% !important;
|
||||
border-collapse: collapse !important;
|
||||
font-size: 13px !important;
|
||||
color: #333 !important;
|
||||
}
|
||||
|
||||
.custom-modal .lesson-table th {
|
||||
background-color: #e9ecef !important;
|
||||
padding: 10px !important;
|
||||
text-align: left !important;
|
||||
font-weight: 600 !important;
|
||||
border-bottom: 2px solid #dee2e6 !important;
|
||||
border-right: 1px solid #dee2e6 !important;
|
||||
}
|
||||
|
||||
.custom-modal .lesson-table th:last-child {
|
||||
border-right: none !important;
|
||||
}
|
||||
|
||||
.custom-modal .lesson-table td {
|
||||
padding: 8px !important;
|
||||
line-height: 1.2 !important;
|
||||
vertical-align: middle !important;
|
||||
border-bottom: 1px solid #dee2e6 !important;
|
||||
border-right: 1px solid #dee2e6 !important;
|
||||
text-align: left !important;
|
||||
}
|
||||
|
||||
.custom-modal .lesson-table td:last-child {
|
||||
border-right: none !important;
|
||||
}
|
||||
|
||||
.custom-modal .lesson-table .even-row {
|
||||
background-color: #fff !important;
|
||||
}
|
||||
|
||||
.custom-modal .lesson-table .odd-row {
|
||||
background-color: #f8f9fa !important;
|
||||
}
|
||||
|
||||
.custom-modal .lesson-table tr:hover {
|
||||
background-color: #e9ecef !important;
|
||||
}
|
||||
|
||||
.details-btn {
|
||||
margin-left: 10px;
|
||||
padding: 5px 10px;
|
||||
font-size: 12px;
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.details-btn:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
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) {
|
||||
// Reindirizza direttamente alla pagina di cancellazione con l'ID come parametro.
|
||||
window.location.href = `deleteclass.php?id=${id}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!-- <body data-layout="horizontal"> -->
|
||||
|
||||
<!-- 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>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
</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 class="d-flex"></div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="topnav">
|
||||
<div class="container-fluid">
|
||||
<nav class="navbar navbar-light navbar-expand-lg topnav-menu">
|
||||
|
||||
|
||||
</nav>
|
||||
<nav class="navbar navbar-light navbar-expand-lg topnav-menu"></nav>
|
||||
</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">
|
||||
@ -286,61 +599,54 @@ while ($row = $result->fetch_assoc()) {
|
||||
<th>N. Ordine</th>
|
||||
<th>Data Ordine</th>
|
||||
<th>Classe</th>
|
||||
<th>Giorno/Ora</th>
|
||||
<th>N. Ticket</th>
|
||||
<th>Prima Lezione</th>
|
||||
<th>Scadenza</th>
|
||||
<th>Stato</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($documents as $document) { ?>
|
||||
<tr>
|
||||
<?php foreach ($documents as $document) {
|
||||
$is_expired = strtotime($document['expireon']) < time();
|
||||
?>
|
||||
<tr class="order-row"
|
||||
data-lessons='<?php echo json_encode($document['lessons']); ?>'
|
||||
data-total='<?php echo $document['quantityclass']; ?>'
|
||||
data-order-id='<?php echo $document['order_id']; ?>'
|
||||
data-is-expired='<?php echo $is_expired ? 'true' : 'false'; ?>'>
|
||||
<td><?php echo $document['order_id']; ?></td>
|
||||
<td><?php echo date('d-m-Y', strtotime($document['order_date_created'])); ?></td>
|
||||
<td><?php echo $document['servicename']; ?></td>
|
||||
<td><?php echo $document['day'] . ' ' . $document['time']; ?></td>
|
||||
<td><?php echo $document['quantityclass']; ?></td>
|
||||
<td><?php echo $document['first_lesson_date'] ? date('d-m-Y', strtotime($document['first_lesson_date'])) : '-'; ?></td>
|
||||
<td><?php echo date('d-m-Y', strtotime($document['expireon'])); ?></td>
|
||||
<td>
|
||||
<span class="badge <?php echo $is_expired ? 'bg-danger' : 'bg-primary'; ?>">
|
||||
<?php echo $is_expired ? 'Scaduto' : 'Attivo'; ?>
|
||||
</span>
|
||||
<button class="details-btn" data-order-id="<?php echo $document['order_id']; ?>" data-lessons='<?php echo json_encode($document['lessons']); ?>' data-total='<?php echo $document['quantityclass']; ?>' data-is-expired='<?php echo $is_expired ? 'true' : 'false'; ?>'>Dettagli</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<?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>
|
||||
<script src="assets/libs/eva-icons/eva.min.js"></script>
|
||||
|
||||
<script src="assets/js/app.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<?php $conn->close(); ?>
|
||||
@ -195,44 +195,52 @@ if ($service_schedule_result->num_rows > 0) {
|
||||
}
|
||||
$stmt_schedule->close();
|
||||
|
||||
// Recupera il numero di settimane da expiryparameter
|
||||
$expiry_class_query = "SELECT quantityclass, first_lesson_date FROM orderbook WHERE idorderbook = ?";
|
||||
$stmt_expiry = $conn->prepare($expiry_class_query);
|
||||
$stmt_expiry->bind_param("i", $order_id);
|
||||
$stmt_expiry->execute();
|
||||
$expiry_class_result = $stmt_expiry->get_result();
|
||||
// Recupera il numero di lezioni da expiryparameter (ora expirylessons)
|
||||
$expiry_lessons_query = "SELECT expirylessons FROM expiryparameter WHERE quantityclass = ?";
|
||||
$stmt_expiry_lessons = $conn->prepare($expiry_lessons_query);
|
||||
$stmt_expiry_lessons->bind_param("i", $quantity_class);
|
||||
$stmt_expiry_lessons->execute();
|
||||
$expiry_lessons_result = $stmt_expiry_lessons->get_result();
|
||||
|
||||
if ($expiry_class_result && $expiry_class_result->num_rows > 0) {
|
||||
$row = $expiry_class_result->fetch_assoc();
|
||||
$quantity_class = $row['quantityclass'];
|
||||
$first_lesson_date = $row['first_lesson_date'];
|
||||
if ($expiry_lessons_result && $expiry_lessons_result->num_rows > 0) {
|
||||
$expiry_row = $expiry_lessons_result->fetch_assoc();
|
||||
$expirylessons = $expiry_row['expirylessons'];
|
||||
|
||||
$expiry_weeks_query = "SELECT expiryweeks FROM expiryparameter WHERE quantityclass = ?";
|
||||
$stmt_expiry_weeks = $conn->prepare($expiry_weeks_query);
|
||||
$stmt_expiry_weeks->bind_param("i", $quantity_class);
|
||||
$stmt_expiry_weeks->execute();
|
||||
$expiry_weeks_result = $stmt_expiry_weeks->get_result();
|
||||
// Calcola la data della expirylessons-esima lezione disponibile
|
||||
$expiry_date_query = "SELECT dateschedule FROM serviceschedule WHERE idservice = ? AND dateschedule >= ? ORDER BY dateschedule LIMIT ?, 1";
|
||||
$stmt_expiry_date = $conn->prepare($expiry_date_query);
|
||||
$offset = $expirylessons - 1; // Per prendere la n-esima riga (0-based offset)
|
||||
$stmt_expiry_date->bind_param("isi", $service_id, $first_lesson_date, $offset);
|
||||
$stmt_expiry_date->execute();
|
||||
$expiry_date_result = $stmt_expiry_date->get_result();
|
||||
|
||||
if ($expiry_weeks_result && $expiry_weeks_result->num_rows > 0) {
|
||||
$expiry_row = $expiry_weeks_result->fetch_assoc();
|
||||
$expiry_weeks = $expiry_row['expiryweeks'];
|
||||
if ($expiry_date_result->num_rows > 0) {
|
||||
$date_row = $expiry_date_result->fetch_assoc();
|
||||
$expireon = $date_row['dateschedule'];
|
||||
|
||||
// Aggiorna la colonna expireon in orderbook basandosi su first_lesson_date
|
||||
$update_expiry_query = "UPDATE orderbook SET expireon = DATE_ADD(first_lesson_date, INTERVAL ? WEEK) WHERE idorderbook = ?";
|
||||
// Aggiorna expireon in orderbook
|
||||
$update_expiry_query = "UPDATE orderbook SET expireon = ? WHERE idorderbook = ?";
|
||||
$stmt_update_expiry = $conn->prepare($update_expiry_query);
|
||||
$stmt_update_expiry->bind_param("ii", $expiry_weeks, $order_id);
|
||||
$stmt_update_expiry->bind_param("si", $expireon, $order_id);
|
||||
$stmt_update_expiry->execute();
|
||||
$stmt_update_expiry->close();
|
||||
|
||||
echo "Aggiornata la colonna expireon per l'ordine ID: $order_id\n";
|
||||
echo "Aggiornata la colonna expireon per l'ordine ID: $order_id (scadenza alla lezione n. $expirylessons: $expireon)\n";
|
||||
} else {
|
||||
// Non abbastanza lezioni: imposta a NULL o gestisci come preferisci
|
||||
$update_expiry_query = "UPDATE orderbook SET expireon = NULL WHERE idorderbook = ?";
|
||||
$stmt_update_expiry = $conn->prepare($update_expiry_query);
|
||||
$stmt_update_expiry->bind_param("i", $order_id);
|
||||
$stmt_update_expiry->execute();
|
||||
$stmt_update_expiry->close();
|
||||
|
||||
echo "Non abbastanza lezioni disponibili per calcolare la scadenza per l'ordine ID: $order_id\n";
|
||||
}
|
||||
$stmt_expiry_date->close();
|
||||
} else {
|
||||
echo "Nessun record trovato in expiryparameter per quantityclass: $quantity_class\n";
|
||||
}
|
||||
$stmt_expiry_weeks->close();
|
||||
} else {
|
||||
echo "Nessun record trovato in orderbook per l'ordine ID: $order_id\n";
|
||||
}
|
||||
$stmt_expiry->close();
|
||||
$stmt_expiry_lessons->close();
|
||||
|
||||
// Recupera il numero da expiryparameter per maxreschedule
|
||||
$reschedule_number_query = "SELECT reschedulenumber FROM expiryparameter WHERE quantityclass = ?";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user