zibo-dashboard/public/userarea/templates_dashboard.php
2025-02-26 17:29:27 +01:00

181 lines
7.2 KiB
PHP

<?php include('include/headscript.php'); ?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--favicon-->
<link rel="icon" href="assets/images/favicon-32x32.png" type="image/png" />
<?php include('cssinclude.php'); ?>
<title>TRF-Project - Template Dashboard</title>
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap5.min.css">
</head>
<body>
<!--wrapper-->
<div class="wrapper">
<!--sidebar wrapper -->
<?php include('include/navbar.php'); ?>
<!--end sidebar wrapper -->
<!--start header -->
<?php include('include/topbar.php'); ?>
<!--end header -->
<!--start page wrapper -->
<div class="page-wrapper">
<div class="page-content">
<?php include('top_stat_widget.php'); ?>
<div class="card radius-10">
<div class="card-header">
<div class="d-flex align-items-center justify-content-between">
<h6 class="mb-0">XLS Templates Dashboard</h6>
<a href="insert_template_xls.php" class="btn btn-success ms-auto">
<i class="fas fa-plus"></i> New Template
</a>
</div>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="xlsTemplatesTable" class="table table-striped table-bordered">
<thead>
<tr>
<th>ID</th>
<th><?= htmlspecialchars($nametemplate, ENT_QUOTES, 'UTF-8'); ?></th>
<th><?= htmlspecialchars($lastmodtemplate, ENT_QUOTES, 'UTF-8'); ?></th>
<th><?= htmlspecialchars($rowheader, ENT_QUOTES, 'UTF-8'); ?></th>
<th><?= htmlspecialchars($columnheader, ENT_QUOTES, 'UTF-8'); ?></th>
<th><?= htmlspecialchars($desctemplate, ENT_QUOTES, 'UTF-8'); ?></th>
<th><?= htmlspecialchars($desttable, ENT_QUOTES, 'UTF-8'); ?></th>
<th><?= htmlspecialchars($action, ENT_QUOTES, 'UTF-8'); ?></th>
</tr>
</thead>
<tbody>
<!-- DataTables riempirà questa sezione automaticamente -->
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!--end page wrapper -->
<!--start overlay-->
<div class="overlay toggle-icon"></div>
<!--end overlay-->
<!--Start Back To Top Button-->
<a href="javaScript:;" class="back-to-top"><i class='bx bxs-up-arrow-alt'></i></a>
<!--End Back To Top Button-->
<?php include('include/footer.php'); ?>
</div>
<!--end wrapper-->
<!-- search modal -->
<?php //include('include/searchmodal.php');
?>
<!-- end search modal -->
<!--start switcher-->
<?php //include('include/themeswitcher.php');
?>
<!--end switcher-->
<?php include('jsinclude.php'); ?>
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap5.min.js"></script>
<script>
$(document).ready(function() {
$('#xlsTemplatesTable').DataTable({
processing: true,
serverSide: false,
ajax: 'load_templates.php',
columns: [{
data: 'id'
},
{
data: 'name'
},
{
data: 'updated_at',
render: function(data) {
return new Date(data).toLocaleDateString();
}
},
{
data: 'header_row'
},
{
data: 'start_column'
},
{
data: 'description',
defaultContent: 'No description'
},
{
data: 'target_table'
},
{
data: 'id',
orderable: false,
searchable: false,
render: function(data) {
return `
<div class="d-flex">
<a href="edit_template_xls.php?id=${data}" class="btn btn-sm btn-primary me-1">
<i class="bx bx-edit-alt"></i>
</a>
<a href="mapping_template_xls.php?id=${data}" class="btn btn-sm btn-success me-1">
<i class="bx bx-link-alt"></i>
</a>
<button class="btn btn-sm btn-danger" onclick="confirmDelete(${data})">
<i class="bx bx-trash"></i>
</button>
</div>`;
}
}
],
dom: '<"card-header border-bottom p-3"<"d-flex align-items-center"<"card-title mb-0 flex-grow-1"f>>>rt<"card-footer border-top p-3"<"d-flex align-items-center"<"me-auto"l><"d-flex gap-2"ip>>>',
lengthMenu: [10, 25, 50, 100],
language: {
url: "//cdn.datatables.net/plug-ins/1.13.6/i18n/Italian.json",
search: "Cerca:",
lengthMenu: "Mostra _MENU_ elementi",
info: "Visualizzando da _START_ a _END_ di _TOTAL_ elementi",
paginate: {
first: "<?= $langdatatables['paginate_first'] ?>",
last: "<?= $langdatatables['paginate_last'] ?>",
next: "<?= $langdatatables['paginate_next'] ?>",
previous: "<?= $langdatatables['paginate_previous'] ?>"
}
}
});
});
function confirmDelete(id) {
Swal.fire({
title: "Are you sure?",
text: "This action cannot be undone!",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#d33",
cancelButtonColor: "#3085d6",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "Cancel"
}).then((result) => {
if (result.isConfirmed) {
window.location.href = `delete_template_xls.php?id=${id}`;
}
});
}
</script>
</body>
</html>