certificate fixing
This commit is contained in:
parent
a061db1e87
commit
318191cc31
@ -1,7 +1,5 @@
|
||||
<?php require_once('include/headscript.php'); ?>
|
||||
|
||||
<?php
|
||||
|
||||
// Creazione della connessione
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
@ -9,19 +7,19 @@ $conn = new mysqli($servername, $username, $password, $dbname);
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione fallita: " . $conn->connect_error);
|
||||
}
|
||||
if (isset($_GET['message'])) {
|
||||
$message = $_GET['message']; } else { $message='n'; }
|
||||
if (isset($_GET['message'])) {
|
||||
$message = $_GET['message'];
|
||||
} else {
|
||||
$message = 'n';
|
||||
}
|
||||
// ID dell'insegnante
|
||||
$idTeacher = 1;
|
||||
|
||||
|
||||
// Controlla se il form è stato inviato
|
||||
if (isset($_POST['submit'])) {
|
||||
// Recupera la data dal form
|
||||
$dayoffdate = $_POST['dayoff'];
|
||||
|
||||
|
||||
|
||||
// Query SQL per l'inserimento del day off
|
||||
$insertQuery = "INSERT INTO dayoff (idteacher, dayoffdate) VALUES ($idTeacher, '$dayoffdate')";
|
||||
|
||||
@ -33,8 +31,6 @@ if (isset($_POST['submit'])) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Query SQL
|
||||
$query = "SELECT * FROM certificateuserprofile LEFT JOIN auth_users ON certificateuserprofile.iduser=auth_users.id ORDER BY auth_users.last_name";
|
||||
|
||||
@ -50,321 +46,285 @@ if ($result->num_rows > 0) {
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<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">
|
||||
|
||||
<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">
|
||||
|
||||
<!-- 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">
|
||||
<!-- DataTables CSS -->
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/dataTables.bootstrap5.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://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", // Formato della data
|
||||
minDate: 0, // Impedisce la selezione di date passate
|
||||
// Altre opzioni del datepicker se necessario
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!-- DataTables JS -->
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/dataTables.bootstrap5.min.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
$("#dayoff").datepicker({ dateFormat: "yy-mm-dd" });
|
||||
$("#expiryDate").datepicker({
|
||||
dateFormat: "yy-mm-dd",
|
||||
minDate: 0,
|
||||
});
|
||||
$("#dayoff").datepicker({
|
||||
dateFormat: "yy-mm-dd"
|
||||
});
|
||||
// Initialize DataTables
|
||||
$('#certificateTable').DataTable({
|
||||
"language": {
|
||||
"url": "//cdn.datatables.net/plug-ins/1.11.5/i18n/it-IT.json"
|
||||
},
|
||||
"pageLength": 10,
|
||||
"order": [
|
||||
[0, "asc"]
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
function confirmDelete(id) {
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
text: "Questo certificato verrà cancellato definitivamente!",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#3085d6",
|
||||
confirmButtonText: "Sì, cancella!",
|
||||
cancelButtonText: "Annulla"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
window.location.href = `deletecertificate.php?id=${id}&source=admin`;
|
||||
}
|
||||
});
|
||||
}
|
||||
</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;
|
||||
}
|
||||
<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-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-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-day {
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.custom-month {
|
||||
font-size: 28px;
|
||||
}
|
||||
.custom-month {
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.custom-event-details {
|
||||
flex: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px 20px;
|
||||
background-color: lightblue;
|
||||
}
|
||||
.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-heading {
|
||||
margin-top: 0;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.custom-paragraph {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.custom-paragraph {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.custom-actions {
|
||||
display: none;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.custom-actions {
|
||||
display: none;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.custom-card.expanded .custom-actions {
|
||||
display: flex;
|
||||
}
|
||||
.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 {
|
||||
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;
|
||||
}
|
||||
.custom-action-button:hover {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.custom-card {
|
||||
flex-direction: column;
|
||||
}
|
||||
@media (max-width: 768px) {
|
||||
.custom-card {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.custom-date-box, .custom-event-details {
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
}
|
||||
.custom-date-box,
|
||||
.custom-event-details {
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.custom-event-time {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
</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>
|
||||
|
||||
<body>
|
||||
.custom-event-time {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<!-- <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>
|
||||
<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">Prenotazione Classi</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>
|
||||
|
||||
<!-- 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'); ?>
|
||||
|
||||
<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 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>
|
||||
</form>
|
||||
</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>
|
||||
|
||||
|
||||
<?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 class="topnav">
|
||||
<div class="container-fluid">
|
||||
<nav class="navbar navbar-light navbar-expand-lg topnav-menu"></nav>
|
||||
</div>
|
||||
|
||||
<div class="topnav">
|
||||
<div class="container-fluid">
|
||||
<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">
|
||||
<div class="card-body">
|
||||
<?php if ($message=='success') { ?>
|
||||
<div class="alert alert-success" role="alert">
|
||||
DayOff rimosso con successo
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
</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">
|
||||
<div class="card-body">
|
||||
<?php if ($message == 'success') { ?>
|
||||
<div class="alert alert-success" role="alert">
|
||||
Certificato rimosso con successo
|
||||
</div>
|
||||
<?php } ?>
|
||||
<h5>Benvenuta/o <?php echo $firstname; ?> </h5>
|
||||
<p>Certificati</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nome</th>
|
||||
<th>Scadenza</th>
|
||||
<th>Documento</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($documents as $document) { ?>
|
||||
<tr>
|
||||
<td><?php echo $document["first_name"]; ?> <?php echo $document["last_name"]; ?></td>
|
||||
<td><?php echo $document["expirydatedocument"]; ?></td>
|
||||
<td><a href="user/document/<?php echo $document["filenamedocument"]; ?>" target="_blank">DOC</a></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table id="certificateTable" class="table table-striped mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nome</th>
|
||||
<th>Scadenza</th>
|
||||
<th>Data Caricamento</th>
|
||||
<th>Documento</th>
|
||||
<th>Azione</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($documents as $document) { ?>
|
||||
<tr>
|
||||
<td><?php echo $document["first_name"]; ?> <?php echo $document["last_name"]; ?></td>
|
||||
<td><?php echo $document["expirydatedocument"]; ?></td>
|
||||
<td><?php echo $document["uploaded_at"] ?? 'N/D'; ?></td>
|
||||
<td><a href="user/document/<?php echo $document["filenamedocument"]; ?>" target="_blank">DOC</a></td>
|
||||
<td>
|
||||
<button class="btn btn-danger btn-sm" onclick="confirmDelete(<?php echo $document['idcertificateuserprofile']; ?>)">
|
||||
<i class="fas fa-trash"></i> Cancella
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
|
||||
|
||||
<!-- End Page-content -->
|
||||
|
||||
<?php include('include/footer.php'); ?>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
<!-- end main content-->
|
||||
|
||||
<!-- End Page-content -->
|
||||
<?php include('include/footer.php'); ?>
|
||||
</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>
|
||||
<!-- 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>
|
||||
41
public/deletecertificate.php
Normal file
41
public/deletecertificate.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
require_once('include/headscript.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['id'])) {
|
||||
$id = intval($_GET['id']); // Sanitize input
|
||||
// Optional: Verify user ownership for security (uncomment if needed)
|
||||
/*
|
||||
$iduserlogin = $_SESSION['iduserlogin']; // Assumes user ID is stored in session
|
||||
$deleteQuery = "DELETE FROM certificateuserprofile WHERE idcertificateuserprofile = ? AND iduser = ?";
|
||||
$stmt = $conn->prepare($deleteQuery);
|
||||
$stmt->bind_param("ii", $id, $iduserlogin);
|
||||
*/
|
||||
$deleteQuery = "DELETE FROM certificateuserprofile WHERE idcertificateuserprofile = ?";
|
||||
$stmt = $conn->prepare($deleteQuery);
|
||||
$stmt->bind_param("i", $id);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
// Determine redirect based on source
|
||||
$source = isset($_GET['source']) ? $_GET['source'] : 'user';
|
||||
if ($source === 'admin') {
|
||||
header("Location: certificati.php?message=success");
|
||||
} else {
|
||||
header("Location: userprofiledoc.php?message=success");
|
||||
}
|
||||
} else {
|
||||
echo "Errore nella cancellazione: " . $conn->error;
|
||||
}
|
||||
$stmt->close();
|
||||
} else {
|
||||
echo "ID non fornito.";
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
@ -13,8 +13,8 @@ $bookedclass->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) {
|
||||
// Verifica se tutti i campi obbligatori sono presenti
|
||||
if (isset($_FILES["fileToUpload"]) && $_FILES["fileToUpload"]["error"] === UPLOAD_ERR_OK && !empty($_POST["documentDescription"]) && !empty($_POST["expiryDate"])) {
|
||||
// Crea la connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
@ -28,10 +28,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
|
||||
// Ottieni l'ID dell'utente
|
||||
$iduserlogin = $_POST["iduserlogin"];
|
||||
|
||||
// Altre informazioni sul documento
|
||||
$documentDescription = $_POST["documentDescription"];
|
||||
$expiryDate = $_POST["expiryDate"];
|
||||
$documentDescription = $conn->real_escape_string($_POST["documentDescription"]);
|
||||
$expiryDate = $conn->real_escape_string($_POST["expiryDate"]);
|
||||
$uploadedAt = date("Y-m-d"); // Data corrente per uploaded_at
|
||||
$originalFileName = $_FILES["fileToUpload"]["name"];
|
||||
$fileExtension = pathinfo($originalFileName, PATHINFO_EXTENSION);
|
||||
$timestamp = time(); // Timestamp corrente
|
||||
@ -41,17 +40,20 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
|
||||
// Sposta il file nella cartella di destinazione
|
||||
if (move_uploaded_file($fileTmpName, $fileDestination)) {
|
||||
// Inserisci i dati nel database
|
||||
$sql = "INSERT INTO certificateuserprofile (iduser, documentdescription, filenamedocument, expirydatedocument)
|
||||
VALUES ('$iduserlogin', '$documentDescription', '$newFileName', '$expiryDate')";
|
||||
// Inserisci i dati nel database usando prepared statement
|
||||
$sql = "INSERT INTO certificateuserprofile (iduser, documentdescription, filenamedocument, expirydatedocument, uploaded_at)
|
||||
VALUES (?, ?, ?, ?, ?)";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("issss", $iduserlogin, $documentDescription, $newFileName, $expiryDate, $uploadedAt);
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
if ($stmt->execute()) {
|
||||
echo "<script>var uploadStatus = 'success';</script>";
|
||||
} else {
|
||||
$error_message = "Errore durante l'inserimento nel database: " . $conn->error;
|
||||
echo "<script>var errorMessage = '" . addslashes($error_message) . "';</script>";
|
||||
echo "<script>var uploadStatus = 'db_insert_error';</script>";
|
||||
}
|
||||
$stmt->close();
|
||||
} else {
|
||||
$error_message = "Errore nel caricamento del file.";
|
||||
echo "<script>var errorMessage = '" . addslashes($error_message) . "';</script>";
|
||||
@ -61,9 +63,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// Chiudi la connessione al database
|
||||
$conn->close();
|
||||
} else {
|
||||
$error_message = "Nessun file caricato o errore durante il caricamento.";
|
||||
$error_message = "Tutti i campi sono obbligatori: descrizione, data di scadenza e file.";
|
||||
echo "<script>var errorMessage = '" . addslashes($error_message) . "';</script>";
|
||||
echo "<script>var uploadStatus = 'no_file_error';</script>";
|
||||
echo "<script>var uploadStatus = 'validation_error';</script>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -99,7 +101,7 @@ if ($result->num_rows > 0) {
|
||||
|
||||
$conn->close();
|
||||
?>
|
||||
<?php //check tickets
|
||||
<?php
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
if ($conn->connect_error) {
|
||||
@ -150,16 +152,17 @@ while ($row = $result->fetch_assoc()) {
|
||||
$documents[] = $row;
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Starter Page | webadmin - Admin & Dashboard Template</title>
|
||||
<title>YogiBook - Carica Certificati</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta content="Premium Multipurpose Admin & Dashboard Template" name="description" />
|
||||
<meta content="Themesdesign" name="author" />
|
||||
<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">
|
||||
|
||||
@ -180,7 +183,8 @@ while ($row = $result->fetch_assoc()) {
|
||||
<script>
|
||||
$(function() {
|
||||
$("#expiryDate").datepicker({
|
||||
dateFormat: "yy-mm-dd"
|
||||
dateFormat: "yy-mm-dd",
|
||||
minDate: 0 // Impedisce la selezione di date passate
|
||||
});
|
||||
});
|
||||
|
||||
@ -202,7 +206,7 @@ while ($row = $result->fetch_assoc()) {
|
||||
}).then(() => {
|
||||
window.location.href = window.location.href; // Ricarica la pagina
|
||||
});
|
||||
} else if (uploadStatus === 'db_connection_error' || uploadStatus === 'db_insert_error' || uploadStatus === 'file_upload_error' || uploadStatus === 'no_file_error') {
|
||||
} else if (uploadStatus === 'db_connection_error' || uploadStatus === 'db_insert_error' || uploadStatus === 'file_upload_error' || uploadStatus === 'validation_error') {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Errore',
|
||||
@ -213,10 +217,10 @@ while ($row = $result->fetch_assoc()) {
|
||||
}
|
||||
});
|
||||
|
||||
function confirmDelete(id, deletePageUrl) {
|
||||
function confirmDeleteCertificate(id) {
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
text: "Questa prenotazione verrà cancellata definitivamente! Ricordati poi di riprogrammare la tua lezione!",
|
||||
text: "Questo certificato verrà cancellato definitivamente!",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#d33",
|
||||
@ -225,7 +229,7 @@ while ($row = $result->fetch_assoc()) {
|
||||
cancelButtonText: "Annulla"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
window.location.href = `deleteclass.php?id=${id}`;
|
||||
window.location.href = `deletecertificate.php?id=${id}&source=user`;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -340,18 +344,15 @@ while ($row = $result->fetch_assoc()) {
|
||||
<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'); ?>
|
||||
@ -364,7 +365,6 @@ while ($row = $result->fetch_assoc()) {
|
||||
<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>
|
||||
@ -372,9 +372,7 @@ while ($row = $result->fetch_assoc()) {
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- ============================================================== -->
|
||||
<!-- Start right Content here -->
|
||||
<!-- ============================================================== -->
|
||||
<div class="main-content">
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
@ -382,6 +380,11 @@ while ($row = $result->fetch_assoc()) {
|
||||
<div class="col-xl-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<?php if (isset($_GET['message']) && $_GET['message'] == 'success') { ?>
|
||||
<div class="alert alert-success" role="alert">
|
||||
Certificato rimosso con successo
|
||||
</div>
|
||||
<?php } ?>
|
||||
<h5>Benvenuta/o <?php echo $firstname; ?> </h5>
|
||||
<p>Di seguito puoi visualizzare o caricare i certificati medici di liberatoria alla pratica Yoga</p>
|
||||
<div class="table-responsive">
|
||||
@ -391,6 +394,7 @@ while ($row = $result->fetch_assoc()) {
|
||||
<th>Descrizione del Documento</th>
|
||||
<th>Data di Scadenza</th>
|
||||
<th>Documento</th>
|
||||
<th>Azione</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -399,6 +403,11 @@ while ($row = $result->fetch_assoc()) {
|
||||
<td><?php echo $document['documentdescription']; ?></td>
|
||||
<td><?php echo $document['expirydatedocument']; ?></td>
|
||||
<td><a href="user/document/<?php echo $document['filenamedocument']; ?>" target="_blank">Documento</a></td>
|
||||
<td>
|
||||
<button class="btn btn-danger btn-sm" onclick="confirmDeleteCertificate(<?php echo $document['idcertificateuserprofile']; ?>)">
|
||||
<i class="fas fa-trash"></i> Cancella
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
@ -426,7 +435,7 @@ while ($row = $result->fetch_assoc()) {
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="iduserlogin" class="form-control" value="<?php echo $iduserlogin; ?>">
|
||||
<label for="documentDescription">Descrizione del Documento:</label>
|
||||
<input type="text" class="form-control" name="documentDescription" required><br>
|
||||
<input type="text" class="form-control" name="documentDescription" value="Certificato Medico" required><br>
|
||||
<label for="expiryDate">Data di Scadenza:</label>
|
||||
<input type="text" id="expiryDate" class="form-control" name="expiryDate" required><br>
|
||||
<label for="fileToUpload">Seleziona un File:</label>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user