theloftstore/public/userarea/insert_template_xls.php
2025-02-26 08:57:46 +01:00

135 lines
5.5 KiB
PHP

<?php include('include/headscript.php'); ?>
<!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>Edmate Learning Dashboard - New 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 Overlay -->
<div class="side-overlay"></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 il form -->
<div class="card mt-24">
<div class="card-body">
<div class="mb-20 flex-between flex-wrap gap-8">
<h4 class="mb-0">Insert New XLS Template</h4>
</div>
<div class="row gy-4">
<div class="col-12">
<!-- Form per inserimento nuovo template -->
<form id="insertTemplateForm" method="POST">
<div class="mb-3">
<label class="form-label"><?= htmlspecialchars($templatename, ENT_QUOTES, 'UTF-8'); ?> *</label>
<input type="text" name="name" class="form-control" 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" 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" required>
</div>
<div class="mb-3">
<label class="form-label"><?= htmlspecialchars($desctemplate, ENT_QUOTES, 'UTF-8'); ?></label>
<textarea name="description" class="form-control"></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" required>
</div>
<br>
<button type="submit" class="btn btn-primary">Create Template</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 form -->
<script>
document.getElementById("insertTemplateForm").addEventListener("submit", function(e) {
e.preventDefault(); // Previene il reload della pagina
let formData = new FormData(this);
fetch("process_insert_template_xls.php", {
method: "POST",
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
Swal.fire({
title: "Success!",
text: "Template created successfully!",
icon: "success",
confirmButtonText: "OK"
}).then(() => {
window.location.href = "list_templates.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>