TRF Certest first commit
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
include('include/headscript.php');
|
||||
require_once 'class/db-functions.php';
|
||||
|
||||
// Controlla se è stato passato un ID valido
|
||||
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
|
||||
header("Location: xlstemplates_grid.php?status=error&message=" . urlencode("Invalid ID"));
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = intval($_GET['id']); // Sanifica l'ID
|
||||
|
||||
// Recupera il template dal database
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
$pdo = $db->getConnection();
|
||||
$stmt = $pdo->prepare("SELECT * FROM excel_templates WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
$template = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$template) {
|
||||
header("Location: xlstemplates_grid.php?status=error&message=" . urlencode("Template not found"));
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Edit XLS Template</title>
|
||||
<link rel="shortcut icon" href="assets/images/logo/favicon.png">
|
||||
<?php include('cssinclude.php'); ?>
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!-- Preloader -->
|
||||
<div class="preloader">
|
||||
<div class="loader"></div>
|
||||
</div>
|
||||
|
||||
<!-- Sidebar -->
|
||||
<?php include('include/navbar.php'); ?>
|
||||
|
||||
<div class="dashboard-main-wrapper">
|
||||
<?php include('include/topbar.php'); ?>
|
||||
|
||||
<div class="dashboard-body">
|
||||
<div class="row gy-4">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<!-- Card per l'edit -->
|
||||
<div class="card mt-24">
|
||||
<div class="card-body">
|
||||
<div class="mb-20 flex-between flex-wrap gap-8">
|
||||
<h4 class="mb-0">Edit XLS Template</h4>
|
||||
</div>
|
||||
|
||||
<div class="row gy-4">
|
||||
<div class="col-12">
|
||||
<!-- Form di modifica -->
|
||||
<form id="editTemplateForm" method="POST">
|
||||
<input type="hidden" name="id" value="<?php echo $template['id']; ?>">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label"><?= htmlspecialchars($templatename, ENT_QUOTES, 'UTF-8'); ?> *</label>
|
||||
<input type="text" name="name" class="form-control" value="<?php echo htmlspecialchars($template['name']); ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label"><?= htmlspecialchars($rowheader, ENT_QUOTES, 'UTF-8'); ?> *</label>
|
||||
<input type="number" name="header_row" class="form-control" value="<?php echo $template['header_row']; ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label"><?= htmlspecialchars($columnheader, ENT_QUOTES, 'UTF-8'); ?>*</label>
|
||||
<input type="text" name="start_column" class="form-control" value="<?php echo htmlspecialchars($template['start_column']); ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label"><?= htmlspecialchars($desctemplate, ENT_QUOTES, 'UTF-8'); ?></label>
|
||||
<textarea name="description" class="form-control"><?php echo htmlspecialchars($template['description']); ?></textarea>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label"><?= htmlspecialchars($desttable, ENT_QUOTES, 'UTF-8'); ?>*</label>
|
||||
<input type="text" name="target_table" class="form-control" value="<?php echo htmlspecialchars($template['target_table']); ?>" required>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary"><?= htmlspecialchars($savechanges, ENT_QUOTES, 'UTF-8'); ?></button>
|
||||
<a href="xlstemplates_grid.php" class="btn btn-secondary">Cancel</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- Card End -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
|
||||
<?php include('jsinclude.php'); ?>
|
||||
|
||||
<!-- Script per gestire il salvataggio con AJAX -->
|
||||
<script>
|
||||
document.getElementById("editTemplateForm").addEventListener("submit", function(e) {
|
||||
e.preventDefault(); // Previene il reload della pagina
|
||||
|
||||
let formData = new FormData(this);
|
||||
|
||||
fetch("process_edit_template_xls.php", {
|
||||
method: "POST",
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
Swal.fire({
|
||||
title: "Success!",
|
||||
text: "Template updated successfully!",
|
||||
icon: "success",
|
||||
confirmButtonText: "OK"
|
||||
}).then(() => {
|
||||
window.location.href = "xlstemplates_grid.php";
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: "Error!",
|
||||
text: data.message,
|
||||
icon: "error",
|
||||
confirmButtonText: "OK"
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
Swal.fire({
|
||||
title: "Error!",
|
||||
text: "An unexpected error occurred.",
|
||||
icon: "error",
|
||||
confirmButtonText: "OK"
|
||||
});
|
||||
console.error(error);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user