import xls update

This commit is contained in:
2025-03-08 08:34:00 +01:00
parent e9bad2260f
commit 8cad59e3d6
19 changed files with 2583 additions and 209 deletions
+115 -21
View File
@@ -11,6 +11,52 @@
<?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">
<style>
.switch {
position: relative;
display: inline-block;
width: 34px;
height: 20px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
transition: .4s;
border-radius: 34px;
}
.slider:before {
position: absolute;
content: "";
height: 12px;
width: 12px;
left: 4px;
bottom: 4px;
background-color: white;
transition: .4s;
border-radius: 50%;
}
input:checked+.slider {
background-color: #4CAF50;
}
input:checked+.slider:before {
transform: translateX(14px);
}
</style>
</head>
<body>
@@ -97,49 +143,71 @@
serverSide: false,
ajax: 'load_templates.php',
columns: [{
data: 'id'
data: 'name', // Nome del template
title: "Template Name"
},
{
data: 'name'
},
{
data: 'updated_at',
data: 'updated_at', // Ultima modifica, formattata come data leggibile
title: "Last Modified",
render: function(data) {
return new Date(data).toLocaleDateString();
}
},
{
data: 'header_row'
data: 'header_row', // Riga degli header
title: "Header Row"
},
{
data: 'start_column'
data: 'start_column', // Colonna di partenza
title: "Start Column"
},
{
data: 'description',
data: 'description', // Descrizione del template
title: "Description",
defaultContent: 'No description'
},
{
data: 'target_table'
data: 'target_table', // Tabella di destinazione
title: "Target Table"
},
{
data: 'id',
data: 'status', // Stato con Toggle Switch
title: "Status",
orderable: false,
searchable: false,
render: function(status, type, row) {
let checked = (status === "active") ? "checked" : "";
return `
<label class="switch">
<input type="checkbox" class="toggle-status" data-id="${row.id}" ${checked}>
<span class="slider round"></span>
</label>
`;
}
},
{
data: 'id', // Azioni: Modifica, Mappatura e Eliminazione
orderable: false,
searchable: false,
title: "Actions",
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>`;
<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],
@@ -174,6 +242,32 @@
}
});
}
$(document).on("change", ".toggle-status", function() {
let templateId = $(this).data("id");
let newStatus = $(this).is(":checked") ? "active" : "inactive";
$.ajax({
url: "update_template_status.php",
type: "POST",
data: {
id: templateId,
status: newStatus
},
success: function(response) {
if (response.success) {
console.log("✅ Status updated successfully.");
} else {
console.error("❌ Error updating status:", response.message);
alert("Error updating status: " + response.message);
}
},
error: function() {
console.error("❌ AJAX error.");
}
});
});
</script>
</body>