|
|
@@ -2149,12 +2149,27 @@
|
|
|
@this.showDetailF(id);
|
|
|
}
|
|
|
|
|
|
- function editData(id)
|
|
|
- {
|
|
|
+ function editData(id) {
|
|
|
+ if ($('#tablesaw-350').length && $.fn.DataTable.isDataTable('#tablesaw-350')) {
|
|
|
+ const dataTable = $('#tablesaw-350').DataTable();
|
|
|
+ const pageLength = dataTable.page.len();
|
|
|
+ const currentPage = dataTable.page.info().page;
|
|
|
+ const order = dataTable.order();
|
|
|
+
|
|
|
+ localStorage.setItem('dtPageLength', pageLength);
|
|
|
+ localStorage.setItem('dtCurrentPage', currentPage);
|
|
|
+
|
|
|
+ if (order && order.length > 0) {
|
|
|
+ localStorage.setItem('dtOrderColumn', order[0][0]);
|
|
|
+ localStorage.setItem('dtOrderDir', order[0][1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
window.scrollTo({
|
|
|
top: 0,
|
|
|
behavior: 'smooth'
|
|
|
});
|
|
|
+
|
|
|
@this.edit(id);
|
|
|
}
|
|
|
|
|
|
@@ -2304,22 +2319,12 @@
|
|
|
}
|
|
|
|
|
|
|
|
|
- function loadDataTable()
|
|
|
- {
|
|
|
-
|
|
|
- if ( $.fn.DataTable.isDataTable('#tablesaw-350') ) {
|
|
|
+ function loadDataTable() {
|
|
|
+ if ($.fn.DataTable.isDataTable('#tablesaw-350')) {
|
|
|
$('#tablesaw-350').DataTable().destroy();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- /*var chkCertificateNormal = $(".chkCertificateNormal").is(':checked') ? "1" : "";
|
|
|
- var chkCertificateAgonistico = $(".chkCertificateAgonistico").is(':checked') ? "1" : "";
|
|
|
- var chkCertificateScadenza = $(".chkCertificateScadenza").is(':checked') ? "1" : "";
|
|
|
- var chkCertificateScaduti = $(".chkCertificateScaduti").is(':checked') ? "1" : "";*/
|
|
|
-
|
|
|
- //var status2 = $('input[name="chkStatus2"]:checked').val();
|
|
|
-
|
|
|
+ // Get saved filters from localStorage
|
|
|
var fromYear = $('input[name="txtFromYear"]').val();
|
|
|
localStorage.setItem("fromYearMember", fromYear);
|
|
|
|
|
|
@@ -2347,17 +2352,23 @@
|
|
|
var filterCategories = $('.filterCategories').val();
|
|
|
localStorage.setItem("filterCategoriesMember", filterCategories);
|
|
|
|
|
|
- $('#tablesaw-350').DataTable({
|
|
|
- //destroy: true,
|
|
|
+ // Get saved DataTable state
|
|
|
+ const savedPageLength = localStorage.getItem('dtPageLength');
|
|
|
+ const savedCurrentPage = localStorage.getItem('dtCurrentPage');
|
|
|
+ const savedOrderColumn = localStorage.getItem('dtOrderColumn');
|
|
|
+ const savedOrderDir = localStorage.getItem('dtOrderDir');
|
|
|
+
|
|
|
+ // Default page length or use saved value
|
|
|
+ const pageLength = savedPageLength ? parseInt(savedPageLength) : 10;
|
|
|
+
|
|
|
+ // Create DataTable with restored settings
|
|
|
+ const dataTable = $('#tablesaw-350').DataTable({
|
|
|
serverSide: true,
|
|
|
ajax: '/get_members?cards=' + filterCards + "&filterCategories=" + filterCategories + "&filterCertificateType=" + filterCertificateType + "&filterScadenza=" + filterScadenza + "&filterStatus=" + filterStatus + "&fromYear=" + fromYear + "&toYear=" + toYear + "&fromYearYear=" + fromYearYear + "&toYearYear=" + toYearYear,
|
|
|
- //ajax: '/get_members?cards=' + cards + "&categories=" + categories + "&chkCertificateNormal=" + chkCertificateNormal + "&chkCertificateAgonistico=" + chkCertificateAgonistico + "&chkCertificateScadenza=" + chkCertificateScadenza + "&chkCertificateScaduti=" + chkCertificateScaduti + "&chkStatus0=" + chkStatus0 + "&chkStatus1=" + chkStatus1 + "&chkStatus2=" + chkStatus2 + "&fromYear=" + fromYear + "&toYear=" + toYear,
|
|
|
columns: [
|
|
|
- //{ data: 'id' },
|
|
|
{
|
|
|
data: "last_name",
|
|
|
render: function (data){
|
|
|
- // Split class and text
|
|
|
const d = data.split("|");
|
|
|
var ret = '<a style="cursor:pointer" onclick="showData(' + d[1] + ')">' + d[0] + '</a>';
|
|
|
return ret;
|
|
|
@@ -2366,62 +2377,38 @@
|
|
|
{
|
|
|
data: "first_name",
|
|
|
render: function (data){
|
|
|
- // Split class and text
|
|
|
const d = data.split("|");
|
|
|
var ret = '<a style="cursor:pointer" onclick="showData(' + d[1] + ')">' + d[0] + '</a>';
|
|
|
return ret;
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
{ data: "phone"},
|
|
|
{ data: "age", "type": "num"},
|
|
|
{ data: "year"},
|
|
|
{
|
|
|
data: "status",
|
|
|
- //"orderable": false,
|
|
|
render: function (data){
|
|
|
- // Split class and text
|
|
|
const d = data.split("|");
|
|
|
var ret = '<span class="tablesaw-cell-content"><span class="badge tessera-badge ' + d[0] + '">' + d[1] + '</span></span>';
|
|
|
return ret;
|
|
|
}
|
|
|
},
|
|
|
- /*{
|
|
|
- data: "state",
|
|
|
- render: function (data){
|
|
|
- // Split class and text
|
|
|
- const d = data.split("|");
|
|
|
- var ret = '<span class="tablesaw-cell-content"><span class="badge tessera-badge ' + d[0] + '">' + d[1] + '</span></span>';
|
|
|
- ret += '<b class=" tablesaw-cell-label">Scadenza tessera</b>';
|
|
|
- ret += '<span class="tablesaw-cell-content d-flex align-items-center">';
|
|
|
- d[2] + ' ' + d[3];
|
|
|
- ret += '</span>';
|
|
|
- return ret;
|
|
|
- }
|
|
|
- },*/
|
|
|
{
|
|
|
data: "certificate",
|
|
|
render: function (data){
|
|
|
- // Split class and text
|
|
|
var ret = '';
|
|
|
- if (data != "")
|
|
|
- {
|
|
|
+ if (data != "") {
|
|
|
const d = data.split("|");
|
|
|
-
|
|
|
- //ret += '<b class=" tablesaw-cell-label">Scadenza certificato</b>';
|
|
|
ret += '<span class="tablesaw-cell-content d-flex align-items-center">';
|
|
|
- if (d[0] == "0")
|
|
|
- {
|
|
|
+ if (d[0] == "0") {
|
|
|
ret += '<i class="ico--ui check suspended me-2"></i>';
|
|
|
ret += 'Scaduto : ';
|
|
|
}
|
|
|
- if (d[0] == "1")
|
|
|
- {
|
|
|
+ if (d[0] == "1") {
|
|
|
ret += '<i class="ico--ui check due me-2"></i>';
|
|
|
ret += 'In scadenza : ';
|
|
|
}
|
|
|
- if (d[0] == "2")
|
|
|
- {
|
|
|
+ if (d[0] == "2") {
|
|
|
ret += '<i class="ico--ui check active me-2"></i>';
|
|
|
ret += 'Scadenza : ';
|
|
|
}
|
|
|
@@ -2441,9 +2428,10 @@
|
|
|
},
|
|
|
],
|
|
|
fixedHeader: false,
|
|
|
- order: [[0, 'asc'], [1, 'asc']],
|
|
|
+ // Set initial order from saved state or default
|
|
|
+ order: savedOrderColumn && savedOrderDir ? [[parseInt(savedOrderColumn), savedOrderDir]] : [[0, 'asc'], [1, 'asc']],
|
|
|
thead: {
|
|
|
- 'th': {'background-color': 'blue'}
|
|
|
+ 'th': {'background-color': 'blue'}
|
|
|
},
|
|
|
layout: {
|
|
|
topStart : null,
|
|
|
@@ -2455,7 +2443,7 @@
|
|
|
text: 'Esporta',
|
|
|
buttons: [
|
|
|
{
|
|
|
- extend: 'excelHtml5',"action":newexportaction,
|
|
|
+ extend: 'excelHtml5',"action":newexportaction,
|
|
|
title: 'Utenti',
|
|
|
exportOptions: {
|
|
|
columns: ":not(':last')",
|
|
|
@@ -2491,34 +2479,33 @@
|
|
|
}
|
|
|
},
|
|
|
top1C :'search',
|
|
|
- /*bottomCenter : {
|
|
|
- info: {
|
|
|
- text: 'Table display: _START_ to _END_ of _TOTAL_ records'
|
|
|
- }
|
|
|
- },
|
|
|
- bottomRight : {
|
|
|
- paging: {
|
|
|
- numbers: true
|
|
|
- }
|
|
|
- }*/
|
|
|
},
|
|
|
- //"dom": '<"top"i>rt<"bottom"flp><"clear">',
|
|
|
pagingType: 'numbers',
|
|
|
"language": {
|
|
|
"url": "/assets/js/Italian.json"
|
|
|
},
|
|
|
"fnInitComplete": function (oSettings, json) {
|
|
|
var html = ' <a style="cursor:pointer" class="showHideFilter btn--ui"><i class="fa-solid fa-sliders"></i></a>';
|
|
|
- html += ' <a style="cursor:pointer" class="addData btn--ui"><i class="fa-solid fa-plus"></i></a>';
|
|
|
+ html += ' <a style="cursor:pointer" class="addData btn--ui"><i class="fa-solid fa-plus"></i></a>';
|
|
|
$(".dt-search").append(html);
|
|
|
+
|
|
|
+ // Set the page length after initialization
|
|
|
+ if (savedPageLength) {
|
|
|
+ this.api().page.len(pageLength).draw('page');
|
|
|
+ }
|
|
|
+
|
|
|
+ // Set the current page after initialization
|
|
|
+ if (savedCurrentPage) {
|
|
|
+ this.api().page(parseInt(savedCurrentPage)).draw('page');
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
$('#tablesaw-350 thead tr th').addClass('col');
|
|
|
$('#tablesaw-350 thead tr th').css("background-color", "#f6f8fa");
|
|
|
$('#tablesaw-350').on('draw.dt', function() {
|
|
|
$('[data-bs-toggle="popover"]').popover()
|
|
|
});
|
|
|
-
|
|
|
}
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
@@ -2645,5 +2632,18 @@
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ function setupBackButtonHandlers() {
|
|
|
+ const backButtons = document.querySelectorAll('a.btn--ui.lightGrey[href^="/"]');
|
|
|
+
|
|
|
+ backButtons.forEach(button => {
|
|
|
+ button.addEventListener('click', function(e) {
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ $(document).ready(function() {
|
|
|
+ setupBackButtonHandlers();
|
|
|
+ });
|
|
|
+
|
|
|
</script>
|
|
|
@endpush
|