fixed again
This commit is contained in:
parent
eb7c0ff531
commit
3c8d8b9fab
@ -1,62 +1,3 @@
|
|||||||
<?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';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Gestione dell'aggiornamento della data di scadenza
|
|
||||||
if (isset($_POST['update_expiry'])) {
|
|
||||||
$order_id = $_POST['order_id'];
|
|
||||||
$new_expiry = $_POST['new_expiry'];
|
|
||||||
|
|
||||||
// Query per aggiornare la data di scadenza
|
|
||||||
$updateQuery = "UPDATE orderbook SET expireon = '$new_expiry' WHERE order_id = $order_id";
|
|
||||||
if ($conn->query($updateQuery) === TRUE) {
|
|
||||||
$message = 'success';
|
|
||||||
} else {
|
|
||||||
$message = 'error';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Gestione del filtro
|
|
||||||
$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";
|
|
||||||
|
|
||||||
// Esecuzione della query
|
|
||||||
$result = $conn->query($query);
|
|
||||||
|
|
||||||
// Recupero dei records
|
|
||||||
$orders = [];
|
|
||||||
if ($result->num_rows > 0) {
|
|
||||||
while ($row = $result->fetch_assoc()) {
|
|
||||||
$orders[] = $row;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
@ -82,31 +23,83 @@ if ($result->num_rows > 0) {
|
|||||||
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
$(".expiryDateInput").datepicker({
|
// Inizializzazione del Datepicker per i campi che verranno creati dinamicamente
|
||||||
dateFormat: "yy-mm-dd",
|
$(document).on('focus', '.expiryDateInput', function() {
|
||||||
minDate: 0,
|
$(this).datepicker({
|
||||||
|
dateFormat: "yy-mm-dd",
|
||||||
|
minDate: 0,
|
||||||
|
onSelect: function(dateText) {
|
||||||
|
let orderId = $(this).data('order-id');
|
||||||
|
confirmUpdate(orderId, dateText);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Funzione per rendere il campo modificabile
|
||||||
|
$(document).on('click', '.expiry-date', function() {
|
||||||
|
let orderId = $(this).data('order-id');
|
||||||
|
let currentDate = $(this).text();
|
||||||
|
$(this).html(`<input type="text" class="form-control expiryDateInput" data-order-id="${orderId}" value="${currentDate}" />`);
|
||||||
|
$(this).find('.expiryDateInput').focus();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Funzione per confermare l'aggiornamento
|
||||||
|
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) {
|
||||||
|
// Crea un form nascosto per inviare i dati
|
||||||
|
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 {
|
||||||
|
// Ricarica la pagina per ripristinare il testo originale
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function openEditModal(orderId, currentExpiry) {
|
function confirmDelete(id, deletePageUrl) {
|
||||||
$("#editOrderId").val(orderId);
|
|
||||||
$("#newExpiry").val(currentExpiry);
|
|
||||||
$("#editExpiryModal").modal("show");
|
|
||||||
}
|
|
||||||
|
|
||||||
function confirmUpdate() {
|
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: "Sei sicuro?",
|
title: "Sei sicuro?",
|
||||||
text: "La data di scadenza verrà modificata!",
|
text: "Questa prenotazione verrà cancellata definitivamente! Ricordati poi di riprogrammare la tua lezione!",
|
||||||
icon: "warning",
|
icon: "warning",
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonColor: "#3085d6",
|
confirmButtonColor: "#d33",
|
||||||
cancelButtonColor: "#d33",
|
cancelButtonColor: "#3085d6",
|
||||||
confirmButtonText: "Sì, modifica!",
|
confirmButtonText: "Sì, cancella!",
|
||||||
cancelButtonText: "Annulla"
|
cancelButtonText: "Annulla"
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
if (result.isConfirmed) {
|
if (result.isConfirmed) {
|
||||||
$("#editExpiryForm").submit();
|
window.location.href = `deleteclass.php?id=${id}`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -193,6 +186,14 @@ if ($result->num_rows > 0) {
|
|||||||
background-color: #e0e0e0;
|
background-color: #e0e0e0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.expiry-date {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expiry-date:hover {
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.custom-card {
|
.custom-card {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -209,24 +210,6 @@ if ($result->num_rows > 0) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</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>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@ -327,7 +310,6 @@ if ($result->num_rows > 0) {
|
|||||||
<th>Numero Ticket</th>
|
<th>Numero Ticket</th>
|
||||||
<th>Scadenza</th>
|
<th>Scadenza</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
<th>Azione</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -343,13 +325,8 @@ if ($result->num_rows > 0) {
|
|||||||
<td><?php echo $order["last_name"]; ?></td>
|
<td><?php echo $order["last_name"]; ?></td>
|
||||||
<td><?php echo $order["servicename"]; ?></td>
|
<td><?php echo $order["servicename"]; ?></td>
|
||||||
<td><?php echo $order["nticket"]; ?></td>
|
<td><?php echo $order["nticket"]; ?></td>
|
||||||
<td><?php echo $order["expireon"]; ?></td>
|
<td class="expiry-date" data-order-id="<?php echo $order['order_id']; ?>"><?php echo $order["expireon"]; ?></td>
|
||||||
<td><?php echo $order["status"]; ?></td>
|
<td><?php echo $order["status"]; ?></td>
|
||||||
<td>
|
|
||||||
<button class="btn btn-primary btn-sm" onclick="openEditModal(<?php echo $order['order_id']; ?>, '<?php echo $order['expireon']; ?>')">
|
|
||||||
Modifica Scadenza
|
|
||||||
</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -362,29 +339,6 @@ if ($result->num_rows > 0) {
|
|||||||
<!-- container-fluid -->
|
<!-- container-fluid -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Modal per modifica data di scadenza -->
|
|
||||||
<div class="modal fade" id="editExpiryModal" tabindex="-1" aria-labelledby="editExpiryModalLabel" aria-hidden="true">
|
|
||||||
<div class="modal-dialog">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<h5 class="modal-title" id="editExpiryModalLabel">Modifica Data di Scadenza</h5>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<form id="editExpiryForm" method="post" action="">
|
|
||||||
<input type="hidden" id="editOrderId" name="order_id">
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="newExpiry" class="form-label">Nuova Data di Scadenza</label>
|
|
||||||
<input type="text" class="form-control expiryDateInput" id="newExpiry" name="new_expiry" required>
|
|
||||||
</div>
|
|
||||||
<button type="button" class="btn btn-primary" onclick="confirmUpdate()">Salva</button>
|
|
||||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Annulla</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- End Page-content -->
|
<!-- End Page-content -->
|
||||||
<?php include('include/footer.php'); ?>
|
<?php include('include/footer.php'); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user