Add "Licenze" and "Log Licenze" sections to admin panel

Introduced two new sections - "Licenze" and "Log Licenze" - to the admin sidebar and created corresponding controllers, views, modals, and scripts to support their functionality. These sections include filtering, listing, and basic interactions such as editing and deletion support.
This commit is contained in:
2025-04-30 09:29:59 +02:00
parent 86eb77de30
commit 0fdb2e1265
17 changed files with 1350 additions and 0 deletions
@@ -0,0 +1,179 @@
'use strict';
function beforeSubmit() {
modalLoader.removeClass('d-none').addClass('d-flex');
}
function errorOnSubmit() {
modalLoader.removeClass('d-flex').addClass('d-none');
}
function afterSubmit(resp) {
if (resp.success === 'invalid') {
showErrors(form_id, resp);
} else if (resp.success === true) {
let id;
let mex = '';
if (resp.op === 'insert') {
$('#tablebody').prepend(resp.text);
$('input#id').val(resp.data.id);
mex = 'Inserimento effettuato con successo';
id = resp.data.id;
} else {
$('tr[data-id=' + resp.id + ']').replaceWith(resp.text);
mex = 'Modifca effettuata con successo';
id = resp.id;
}
refreshFormComponents();
$('#norows').remove();
$(modal_id).modal('hide');
$('#save').attr('op', 'insert');
myResetForm('', form_id);
toastr.success(mex);
} else {
toastr.error(resp.shortMessage);
console.error(resp.message);
}
modalLoader.removeClass('d-flex').addClass('d-none');
}
//Specializzo la funzione resetForm nel caso ci sia bisogno di campi TEXTAREA o immagini da resettare
function myResetForm(tipo, formid) {
resetForm(tipo, formid);
$('textarea#Testo').summernote('code', '');
}
function edit(id) {
$('#save').attr('op', 'edit');
var dati = 'id=' + id;
var url = $(form_id).attr('data-get');
myResetForm('all', form_id);
$.getJSON(url, dati, function (resp) {
if (resp.success) {
populateForm(resp, form);
$('textarea#Testo').summernote('code', resp.Testo);
$(modal_id).modal('show');
} else {
toastr.error(resp.message);
}
});
}
$(document).ready(function () {
initFormComponents();
initTableFlotHeader();
}).delegate('#new', 'click', function (link) {
link.preventDefault();
myResetForm('tutto', form_id);
$('#save').attr('op', 'insert');
$(modal_id).modal('show');
})
.delegate('#save', 'click', function (link) {
link.preventDefault();
var operation = $(this).attr('op');
var options = {
target: '#ErrorDescription',
beforeSubmit: beforeSubmit,
success: afterSubmit,
error: errorOnSubmit,
data: {
op: operation
},
dataType: 'json',
resetForm: false
};
$(form_id).ajaxSubmit(options);
})
.delegate('#edit,#editLink', 'click', function (link) {
link.preventDefault();
const id = $(this).parents('tr').attr('data-id');
edit(id);
})
.delegate('#delete', 'click', function (link) {
link.preventDefault();
const url = $(form_id).attr('data-delete');
let tr = $(this).parents('tr');
const cod = tr.attr('data-cod');
let id = tr.attr('data-id');
let message = 'Sei sicuro di voler eliminare definitivamente l\'elemento?';
if (confirm(message)) {
$.ajax({
type: 'POST',
url: url,
data: 'id=' + id + "&cod=" + cod,
dataType: 'json',
complete: function (resp) {
resp = jQuery.parseJSON(resp.responseText);
if (resp.success) {
tr.animate({
'opacity': 'hide'
}, 500, function () {
tr.remove();
});
toastr.success('Eliminazione effettuata con successo');
} else {
toastr.error(resp.message);
}
}
});
}
})
.delegate('#delete_select', 'click', function (link) {
link.preventDefault();
let message = 'Sei sicuro di voler eliminare definitivamente gli elementi selezionati?';
if (confirm(message)) {
let data = [];
$('#tablebody').find(':checkbox').each(function () {
if (this.checked) {
data.push($(this).val());
}
});
let url = $(this).attr('href');
$.ajax({
type: 'POST',
url: url,
data: {
data: data
},
dataType: 'json',
complete: function (resp) {
resp = jQuery.parseJSON(resp.responseText);
if (resp.success) {
var ids = resp.id;
for (var i = 0; i < ids.length; i++) {
var tr = $('#tablebody tr[data-id=' + ids[i] + ']');
tr.animate({
'opacity': 'hide'
}, 500, function () {
tr.remove();
});
}
} else {
toastr.error(resp.message);
}
$('#tablebody').find(':checkbox').iCheck('uncheck');
}
});
}
})
.delegate(modal_id,'hidden.bs.modal',function(link){
link.preventDefault();
myResetForm('tutto', form_id);
$('#save').attr('op', 'insert');
});
@@ -0,0 +1,179 @@
'use strict';
function beforeSubmit() {
modalLoader.removeClass('d-none').addClass('d-flex');
}
function errorOnSubmit() {
modalLoader.removeClass('d-flex').addClass('d-none');
}
function afterSubmit(resp) {
if (resp.success === 'invalid') {
showErrors(form_id, resp);
} else if (resp.success === true) {
let id;
let mex = '';
if (resp.op === 'insert') {
$('#tablebody').prepend(resp.text);
$('input#id').val(resp.data.id);
mex = 'Inserimento effettuato con successo';
id = resp.data.id;
} else {
$('tr[data-id=' + resp.id + ']').replaceWith(resp.text);
mex = 'Modifca effettuata con successo';
id = resp.id;
}
refreshFormComponents();
$('#norows').remove();
$(modal_id).modal('hide');
$('#save').attr('op', 'insert');
myResetForm('', form_id);
toastr.success(mex);
} else {
toastr.error(resp.shortMessage);
console.error(resp.message);
}
modalLoader.removeClass('d-flex').addClass('d-none');
}
//Specializzo la funzione resetForm nel caso ci sia bisogno di campi TEXTAREA o immagini da resettare
function myResetForm(tipo, formid) {
resetForm(tipo, formid);
$('textarea#Testo').summernote('code', '');
}
function edit(id) {
$('#save').attr('op', 'edit');
var dati = 'id=' + id;
var url = $(form_id).attr('data-get');
myResetForm('all', form_id);
$.getJSON(url, dati, function (resp) {
if (resp.success) {
populateForm(resp, form);
$('textarea#Testo').summernote('code', resp.Testo);
$(modal_id).modal('show');
} else {
toastr.error(resp.message);
}
});
}
$(document).ready(function () {
initFormComponents();
initTableFlotHeader();
}).delegate('#new', 'click', function (link) {
link.preventDefault();
myResetForm('tutto', form_id);
$('#save').attr('op', 'insert');
$(modal_id).modal('show');
})
.delegate('#save', 'click', function (link) {
link.preventDefault();
var operation = $(this).attr('op');
var options = {
target: '#ErrorDescription',
beforeSubmit: beforeSubmit,
success: afterSubmit,
error: errorOnSubmit,
data: {
op: operation
},
dataType: 'json',
resetForm: false
};
$(form_id).ajaxSubmit(options);
})
.delegate('#edit,#editLink', 'click', function (link) {
link.preventDefault();
const id = $(this).parents('tr').attr('data-id');
edit(id);
})
.delegate('#delete', 'click', function (link) {
link.preventDefault();
const url = $(form_id).attr('data-delete');
let tr = $(this).parents('tr');
const cod = tr.attr('data-cod');
let id = tr.attr('data-id');
let message = 'Sei sicuro di voler eliminare definitivamente l\'elemento?';
if (confirm(message)) {
$.ajax({
type: 'POST',
url: url,
data: 'id=' + id + "&cod=" + cod,
dataType: 'json',
complete: function (resp) {
resp = jQuery.parseJSON(resp.responseText);
if (resp.success) {
tr.animate({
'opacity': 'hide'
}, 500, function () {
tr.remove();
});
toastr.success('Eliminazione effettuata con successo');
} else {
toastr.error(resp.message);
}
}
});
}
})
.delegate('#delete_select', 'click', function (link) {
link.preventDefault();
let message = 'Sei sicuro di voler eliminare definitivamente gli elementi selezionati?';
if (confirm(message)) {
let data = [];
$('#tablebody').find(':checkbox').each(function () {
if (this.checked) {
data.push($(this).val());
}
});
let url = $(this).attr('href');
$.ajax({
type: 'POST',
url: url,
data: {
data: data
},
dataType: 'json',
complete: function (resp) {
resp = jQuery.parseJSON(resp.responseText);
if (resp.success) {
var ids = resp.id;
for (var i = 0; i < ids.length; i++) {
var tr = $('#tablebody tr[data-id=' + ids[i] + ']');
tr.animate({
'opacity': 'hide'
}, 500, function () {
tr.remove();
});
}
} else {
toastr.error(resp.message);
}
$('#tablebody').find(':checkbox').iCheck('uncheck');
}
});
}
})
.delegate(modal_id,'hidden.bs.modal',function(link){
link.preventDefault();
myResetForm('tutto', form_id);
$('#save').attr('op', 'insert');
});