ppeasy/public/change_certificate.php
2025-05-16 18:46:16 +02:00

225 lines
12 KiB
PHP

<?php
include('include/headscript.php');
include('db-connect.php');
// Inizializzazione variabili
$idtrfdetails = 0;
$idcertificate = 0;
if (isset($_GET['idtrfdetails'])) {
$idtrfdetails = $_GET['idtrfdetails'];
} elseif (isset($_POST['idtrfdetails'])) {
$idtrfdetails = $_POST['idtrfdetails'];
}
// Recupera l'idcertificate corrente da trf-details
if ($idtrfdetails > 0) {
$query = "SELECT `idcertification` FROM `trf-details` WHERE `idtrfdetails` = '$idtrfdetails'";
$result = mysqli_query($con, $query);
if ($result && mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
$idcertificate = $row['idcertification'];
}
}
// Mappa dei certificati per mostrare il nome corrente
$certificate_names = [
1 => "M16 + M30S Initial",
3 => "M15B + M30S Revision",
4 => "M15A + M30S Extension",
5 => "M18A Surveillance Module C",
6 => "M18B Surveillance Module D",
8 => "M15D + M30S"
];
$current_certificate_name = isset($certificate_names[$idcertificate]) ? $certificate_names[$idcertificate] : "Not specified";
// Aggiornamento dell'idcertificate se il form è stato inviato
if (isset($_POST['new_idcertificate']) && $idtrfdetails > 0) {
$new_idcertificate = $_POST['new_idcertificate'];
// Aggiorna il database
$updateQuery = "UPDATE `trf-details` SET `idcertification` = '$new_idcertificate' WHERE `idtrfdetails` = '$idtrfdetails'";
mysqli_query($con, $updateQuery);
// Reindirizzamenti specifici basati sul nuovo idcertificate
switch ($new_idcertificate) {
case 1: // M16 + M30S Initial Mod B (1)
header("Location: trfdetails.php?idcertificate=1&idtrf=$idtrfdetails");
break;
case 3: // M15B + M30S Revision (3)
header("Location: trfdetails.php?idcertificate=3&idtrfdetails=$idtrfdetails");
break;
case 4: // M15A + M30S Extension (4)
header("Location: typeofcertificate4.php?idcertificate=4&idtrf=$idtrfdetails");
break;
case 5: // M18A Surveillance Module C2 (5)
header("Location: typeofcertificate5.php?idcertificate=5&idtrf=$idtrfdetails&proc=confirmed");
break;
case 6: // M18B Surveillance Module D (6)
header("Location: typeofcertificate6.php?idcertificate=6&idtrf=$idtrfdetails");
break;
case 8: // M15D + M30S Rinnovo (8)
header("Location: typeofcertificate3.php?idcertificate=8&idtrf=$idtrfdetails");
break;
}
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title><?php echo $titlepage; ?> - Change Certificate</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta content="CIMAC TRF Portal" name="description" />
<meta content="" name="author" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- App favicon -->
<link rel="shortcut icon" href="../images/favicon.ico">
<!--Form Wizard-->
<link href="../plugins/jquery-steps/jquery.steps.css" rel="stylesheet" type="text/css">
<!-- App css -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="assets/css/jquery-ui.min.css" rel="stylesheet">
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
<link href="assets/css/metisMenu.min.css" rel="stylesheet" type="text/css" />
<link href="assets/css/app.min.css" rel="stylesheet" type="text/css" />
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="../webassist/jq_validation/Serene.css" />
</head>
<body>
<!-- Top Bar Start -->
<?php include('include/topbar.php'); ?>
<!-- Top Bar End -->
<!-- Left Sidenav -->
<?php include('include/leftsidenav.php'); ?>
<!-- end left-sidenav-->
<div class="page-wrapper">
<!-- Page Content-->
<div class="page-content">
<div class="container-fluid">
<!-- Page-Title -->
<div class="row">
<div class="col-sm-12">
<div class="page-title-box">
<div class="float-right">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="javascript:void(0);">Certificate Management</a></li>
<li class="breadcrumb-item active">Change Certificate</li>
</ol>
</div>
<h3 class="page-title">Change Certificate Type</h3>
</div><!--end page-title-box-->
</div><!--end col-->
</div>
<div class="row">
<div class="col-sm-12">
<div class="card">
<div class="card-body">
<button type="button" class="btn btn-purple btn-square btn-outline-dashed waves-effect waves-light">
<i class="mdi mdi-arrow-right-bold"></i> Certificate Modification
</button><br><br>
<!-- Mostra il certificato corrente -->
<div class="alert alert-info" role="alert">
<h4 class="alert-heading">Current Certificate</h4>
<p>ID: <?php echo $idcertificate; ?> - <?php echo $current_certificate_name; ?></p>
<p>TRF Details ID: <?php echo $idtrfdetails; ?></p>
</div>
<h4 class="mt-0 header-title">Select New Certificate Type</h4>
<p class="text-muted mb-3">Please select the new certificate type you want to assign.</p>
<div class="progress mb-4">
<div class="progress-bar" role="progressbar" style="width: 50%;" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100">50%</div>
</div>
<?php if ($idtrfdetails > 0) { ?>
<div class="alert alert-light text-muted mb-0" role="alert">
<form action="change_certificate.php" method="post" name="changeCertForm">
<input type="hidden" name="idtrfdetails" value="<?php echo $idtrfdetails; ?>">
<div class="form-group row">
<label class="col-md-3 my-2 control-label">New Certificate Type</label>
<div class="col-md-9">
<div class="custom-control custom-radio my-2">
<input type="radio" id="cert1" name="new_idcertificate" value="1" class="custom-control-input" <?php echo $idcertificate == 1 ? 'checked' : ''; ?>>
<label class="custom-control-label" for="cert1">M16 + M30S Initial</label>
</div>
<div class="custom-control custom-radio my-2">
<input type="radio" id="cert3" name="new_idcertificate" value="3" class="custom-control-input" <?php echo $idcertificate == 3 ? 'checked' : ''; ?>>
<label class="custom-control-label" for="cert3">M15B + M30S Revision</label>
</div>
<div class="custom-control custom-radio my-2">
<input type="radio" id="cert4" name="new_idcertificate" value="4" class="custom-control-input" <?php echo $idcertificate == 4 ? 'checked' : ''; ?>>
<label class="custom-control-label" for="cert4">M15A + M30S Extension</label>
</div>
<div class="custom-control custom-radio my-2">
<input type="radio" id="cert5" name="new_idcertificate" value="5" class="custom-control-input" <?php echo $idcertificate == 5 ? 'checked' : ''; ?>>
<label class="custom-control-label" for="cert5">M18A Surveillance Module C</label>
</div>
<div class="custom-control custom-radio my-2">
<input type="radio" id="cert6" name="new_idcertificate" value="6" class="custom-control-input" <?php echo $idcertificate == 6 ? 'checked' : ''; ?>>
<label class="custom-control-label" for="cert6">M18B Surveillance Module D</label>
</div>
<div class="custom-control custom-radio my-2">
<input type="radio" id="cert8" name="new_idcertificate" value="8" class="custom-control-input" <?php echo $idcertificate == 8 ? 'checked' : ''; ?>>
<label class="custom-control-label" for="cert8">M15D + M30S</label>
</div>
</div>
</div>
<div class="form-group row">
<div class="col-md-12">
<button type="submit" class="btn btn-gradient-success waves-effect waves-light">Confirm Change</button>
<a href="typeofcertificate.php?idtrfdetails=<?php echo $idtrfdetails; ?>" class="btn btn-danger waves-effect waves-light">Cancel</a>
</div>
</div>
</form>
</div>
<?php } else { ?>
<div class="alert alert-danger" role="alert">
Error: No TRF Details ID provided. Please access this page with a valid idtrfdetails parameter.
</div>
<?php } ?>
</div><!--end card-body-->
</div><!--end card-->
</div><!--end col-->
</div>
</div><!-- container -->
<!-- footer start -->
<?php include('include/footer.php'); ?>
</footer><!--end footer-->
</div>
<!-- end page content -->
</div>
<!-- end page-wrapper -->
<!-- jQuery -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/metismenu.min.js"></script>
<script src="assets/js/waves.js"></script>
<script src="assets/js/feather.min.js"></script>
<script src="assets/js/jquery.slimscroll.min.js"></script>
<script src="assets/js/jquery-ui.min.js"></script>
<script src="../plugins/jquery-steps/jquery.steps.min.js"></script>
<script src="assets/pages/jquery.form-wizard.init.js"></script>
<!-- App js -->
<script src="assets/js/app.js"></script>
<!-- Parsley js -->
<script src="../../plugins/parsleyjs/parsley.min.js"></script>
<script src="../assets/pages/jquery.validation.init.js"></script>
</body>
</html>