final fixing order
This commit is contained in:
parent
3c8d8b9fab
commit
edc6bda47f
@ -1,20 +1,97 @@
|
||||
<?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 - Riepilogo Ordini</title>
|
||||
<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>
|
||||
@ -23,7 +100,13 @@
|
||||
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
// Inizializzazione del Datepicker per i campi che verranno creati dinamicamente
|
||||
// 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",
|
||||
@ -35,15 +118,15 @@
|
||||
});
|
||||
});
|
||||
|
||||
// Funzione per rendere il campo modificabile
|
||||
// Rendere il campo scadenza editabile al click
|
||||
$(document).on('click', '.expiry-date', function() {
|
||||
let orderId = $(this).data('order-id');
|
||||
let currentDate = $(this).text();
|
||||
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
|
||||
// Funzione per confermare l'aggiornamento della scadenza
|
||||
function confirmUpdate(orderId, newExpiry) {
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
@ -56,7 +139,6 @@
|
||||
cancelButtonText: "Annulla"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// Crea un form nascosto per inviare i dati
|
||||
let form = $('<form>', {
|
||||
'method': 'POST',
|
||||
'action': ''
|
||||
@ -80,13 +162,12 @@
|
||||
$('body').append(form);
|
||||
form.submit();
|
||||
} else {
|
||||
// Ricarica la pagina per ripristinare il testo originale
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Funzione per confermare la cancellazione (mantenuta dal template originale)
|
||||
function confirmDelete(id, deletePageUrl) {
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
@ -103,6 +184,7 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.custom-card {
|
||||
@ -213,30 +295,20 @@
|
||||
</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">Riepilogo Ordini</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>
|
||||
@ -252,13 +324,11 @@
|
||||
</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>
|
||||
@ -270,7 +340,6 @@
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Start right Content here -->
|
||||
<div class="main-content">
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
@ -286,18 +355,85 @@
|
||||
<div class="alert alert-danger" role="alert">
|
||||
Errore durante l'aggiornamento
|
||||
</div>
|
||||
<?php } elseif ($message == 'success_dayoff') { ?>
|
||||
<div class="alert alert-success" role="alert">
|
||||
DayOff inserito con successo
|
||||
</div>
|
||||
<?php } elseif ($message == 'error_dayoff') { ?>
|
||||
<div class="alert alert-danger" role="alert">
|
||||
Errore durante l'inserimento del DayOff
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<h5>Benvenuta/o <?php echo $firstname; ?></h5>
|
||||
<p>Giorni DayOff</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Giorno Day Off</th>
|
||||
<th>ACTION</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($documents as $document) { ?>
|
||||
<tr>
|
||||
<td><?php echo $document["dayoffdate"]; ?></td>
|
||||
<td>
|
||||
<form method="post" action="removedayoff.php?iddayoff=<?php echo $document["iddayoff"]; ?>">
|
||||
<input type="hidden" name="date" value="<?php echo $document["dayoffdate"]; ?>">
|
||||
<button type="submit" class="btn btn-danger">Rimuovi</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</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">
|
||||
<div class="pb-3 pb-xl-0">
|
||||
<div class="position-relative">
|
||||
<h3>Inserisci Dayoff</h3>
|
||||
</div>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<label for="dayoff">Data di Scadenza:</label>
|
||||
<input type="text" id="dayoff" class="form-control datepicker" name="dayoff" required><br>
|
||||
<input type="submit" class="btn btn-primary w-md" value="Inserisci" name="submit">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl-9 col-md-12"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
|
||||
<!-- Filtri -->
|
||||
<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>
|
||||
@ -336,17 +472,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
</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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user