function loadSettings() { ShowPageLoader(); var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { document.querySelector("#settings_content").innerHTML = this.responseText; HidePageLoader(); } }; xmlhttp.open("GET", "public/settings/settings_list.php"); xmlhttp.send(); } function saveStampSettings() { document.getElementById("save_stamps_button").style.display = 'none'; document.getElementById("stamps_settings_loader").style.display = 'block'; var errors = 0; var table = document.getElementById("stamp_settings"); for (var i = 1, row; row = table.rows[i]; i++) { var id = document.getElementById("stamp_settings").rows[i].cells.item(0).innerHTML; var approve = document.getElementById("stamps_approve_"+i).checked; $.ajax({ type: "POST", url: "php/settings/update_user_settings.php", data: { type : "stamps", id: id, notify: 0, approve: approve }, success: function (res) { if (res === 'error') { errors++; } setTimeout(() => { loadSettings(); }, 1000); document.getElementById("save_stamps_button").style.display = 'block'; document.getElementById("stamps_settings_loader").style.display = 'none'; } }); } if(errors == 0) { SuccessAlert('Permessi aggiornati con successo'); } else { ErrorAlert('Si sono verificati degli errori'); } } function savePermissionsSettings() { document.getElementById("save_permissions_button").style.display = 'none'; document.getElementById("permissions_settings_loader").style.display = 'block'; var errors = 0; var table = document.getElementById("permissions_settings"); for (var i = 1, row; row = table.rows[i]; i++) { var id = document.getElementById("permissions_settings").rows[i].cells.item(0).innerHTML; var approve = document.getElementById("permissions_approve_"+i).checked; var notify = document.getElementById("permissions_notify_"+i).checked; $.ajax({ type: "POST", url: "php/settings/update_user_settings.php", data: { type : "permissions", id: id, notify: notify, approve: approve }, success: function (res) { if (res === 'error') { errors++; } setTimeout(() => { loadSettings(); }, 1000); document.getElementById("save_stamps_button").style.display = 'block'; document.getElementById("stamps_settings_loader").style.display = 'none'; } }); } if(errors == 0) { SuccessAlert('Permessi aggiornati con successo'); } else { ErrorAlert('Si sono verificati degli errori'); } } function saveTransfersSettings() { document.getElementById("save_transfers_button").style.display = 'none'; document.getElementById("transfers_settings_loader").style.display = 'block'; var errors = 0; var table = document.getElementById("transfers_settings"); for (var i = 1, row; row = table.rows[i]; i++) { var id = document.getElementById("transfers_settings").rows[i].cells.item(0).innerHTML; var approve = document.getElementById("transfers_approve_"+i).checked; var notify = document.getElementById("transfers_notify_"+i).checked; $.ajax({ type: "POST", url: "php/settings/update_user_settings.php", data: { type : "transfers", id: id, notify: notify, approve: approve }, success: function (res) { if (res === 'error') { errors++; } setTimeout(() => { loadSettings(); }, 1000); document.getElementById("save_stamps_button").style.display = 'block'; document.getElementById("stamps_settings_loader").style.display = 'none'; } }); } if(errors == 0) { SuccessAlert('Permessi aggiornati con successo'); } else { ErrorAlert('Si sono verificati degli errori'); } } function loadStampers() { ShowPageLoader(); var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { document.querySelector("#stampers_list_content").innerHTML = this.responseText; $(document).ready( function () { new DataTable('#stempers_list_table', { pageLength: 15, layout: { topStart: { buttons: [ { extend: 'colvis', postfixButtons: ['colvisRestore'], popoverTitle: 'Visibilità colonne' }, { extend: 'print', split: ['print','excel','pdf', 'csv'] }, { text: 'Nuovo timbratore', action: function (e, dt, node, config) { newStamper(); } } ] } }, language: { emptyTable: "Nessun dato presente nella tabella", search: "Cerca:", infoEmpty: "Visualizzati da 0 a 0 di 0 risultati", info: "Visualizzati da _START_ a _END_ di _TOTAL_ risultati", buttons: { print: "Stampa", colvis: "Visualizza", colvisRestore: "Ripristina visualizzazione" } }, order: { idx: 0, dir: 'asc' } }); }); HidePageLoader(); } }; xmlhttp.open("GET", "public/settings/stampers_list.php"); xmlhttp.send(); } function deleteStamper(stamper_id) { Swal.fire({ title: "Confermi eliminazione?", text: "Il timbratore verrà eliminato e non verranno più importate le timbrature", icon: "warning", showCancelButton: true, confirmButtonColor: "#d33", cancelButtonColor: "#3085d6", confirmButtonText: "Sì, elimina!", cancelButtonText: "Annulla" }).then((result) => { if (result.isConfirmed) { ShowPageLoader(); $.ajax({ type: "POST", url: "php/settings/delete_stamper.php", data: { stamper_id: stamper_id }, success: function (res) { if (res === 'error') { ErrorAlert("Errore: "+res) } else { SuccessAlert('Timbratore eliminato'); setTimeout(() => { loadStampers(); }, 1000); } HidePageLoader(); } }); } }); } function editStamper(stamper_id) { document.getElementById("open_edit_stamper").click(); ShowPageLoader(); var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { document.querySelector("#edit_stamper_content").innerHTML = this.responseText; HidePageLoader(); } }; xmlhttp.open("GET", "public/settings/edit_stamper_content.php?stamper_id="+stamper_id); xmlhttp.send(); } function updateStamper(stamper_id) { document.getElementById("update_stamper_button").style.display = 'none'; document.getElementById("update_stamper_loader").style.display = 'block'; var name = document.getElementById("name").value; var ip_address = document.getElementById("ip_address").value; var description = document.getElementById("description").value; var location = document.getElementById("location").value; var file_name = document.getElementById("file_name").value; $.ajax({ type: "POST", url: "php/settings/update_stamper.php", data: { stamper_id:stamper_id, name:name, ip_address:ip_address, description:description, location:location, file_name: file_name }, success: function (res) { if (res === 'error') { ErrorAlert("Errore: "+res) } else { SuccessAlert('Timbratore aggiornato'); document.getElementById("close_edit_stamper").click(); setTimeout(() => { loadStampers(); }, 1000); } document.getElementById("update_stamper_button").style.display = 'block'; document.getElementById("update_stamper_loader").style.display = 'none'; } }); } function newStamper() { document.getElementById("open_new_stamper").click(); var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { document.querySelector("#new_stamper_content").innerHTML = this.responseText; } }; xmlhttp.open("GET", "public/settings/new_stamper_content.php"); xmlhttp.send(); } function createStamper() { document.getElementById("create_stamper_button").style.display = 'none'; document.getElementById("create_stamper_loader").style.display = 'block'; var name = document.getElementById("name").value; var ip_address = document.getElementById("ip_address").value; var description = document.getElementById("description").value; var location = document.getElementById("location").value; var file_name = document.getElementById("file_name").value; $.ajax({ type: "POST", url: "php/settings/create_stamper.php", data: { name:name, ip_address:ip_address, description:description, location:location, file_name:file_name }, success: function (res) { if (res === 'error') { ErrorAlert("Errore: "+res) } else { SuccessAlert('Timbratore creato'); document.getElementById("close_new_stamper").click(); setTimeout(() => { loadStampers(); }, 1000); } document.getElementById("create_stamper_button").style.display = 'block'; document.getElementById("create_stamper_loader").style.display = 'none'; } }); } function loadCronJobs() { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { document.querySelector("#cron_jobs_list_content").innerHTML = this.responseText; $(document).ready( function () { new DataTable('#cron_jobs_list_table', { pageLength: 15, layout: { topStart: { buttons: [ { extend: 'colvis', postfixButtons: ['colvisRestore'], popoverTitle: 'Visibilità colonne' }, { extend: 'print', split: ['print','excel','pdf', 'csv'] }, { text: 'Nuova importazione', action: function (e, dt, node, config) { newCronJob(); } } ] } }, language: { emptyTable: "Nessun dato presente nella tabella", search: "Cerca:", infoEmpty: "Visualizzati da 0 a 0 di 0 risultati", info: "Visualizzati da _START_ a _END_ di _TOTAL_ risultati", buttons: { print: "Stampa", colvis: "Visualizza", colvisRestore: "Ripristina visualizzazione" } }, order: { idx: 0, dir: 'asc' } }); }); } }; xmlhttp.open("GET", "public/settings/cron_jobs_list.php"); xmlhttp.send(); } function deleteCronJob(cron_id) { Swal.fire({ title: "Confermi eliminazione?", text: "Le timbrature non verranno più caricate automaticamente dai timbratori", icon: "warning", showCancelButton: true, confirmButtonColor: "#d33", cancelButtonColor: "#3085d6", confirmButtonText: "Sì, elimina!", cancelButtonText: "Annulla" }).then((result) => { if (result.isConfirmed) { ShowPageLoader(); $.ajax({ type: "POST", url: "php/settings/delete_cron_job.php", data: { cron_id: cron_id }, success: function (res) { /* if (res == 200) { SuccessAlert('Task pianificato eliminato'); setTimeout(() => { loadCronJobs(); }, 1000); } else { ErrorAlert("Errore: "+res); } */ SuccessAlert('Task pianificato eliminato'); setTimeout(() => { loadCronJobs(); }, 1000); HidePageLoader(); } }); } }); } function newCronJob() { document.getElementById("open_new_cron_job").click(); var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { document.querySelector("#new_cron_job_content").innerHTML = this.responseText; } }; xmlhttp.open("GET", "public/settings/new_cron_job_content.php"); xmlhttp.send(); } function createCronJob() { document.getElementById("create_cron_job_button").style.display = 'none'; document.getElementById("create_cron_job_loader").style.display = 'block'; var command = document.getElementById("command").value; var description = document.getElementById("description").value; var email = document.getElementById("email").value; var frequency = document.getElementById("frequency").value; var language = document.getElementById("language").value; var status = document.getElementById("status").value; $.ajax({ type: "POST", url: "php/settings/create_cron_job.php", data: { command:command, description:description, email:email, frequency:frequency, language:language, status:status }, success: function (res) { /* if (res == 200) { SuccessAlert('Task pianificato creato'); document.getElementById("close_new_cron_job").click(); setTimeout(() => { loadCronJobs(); }, 1000); } else { ErrorAlert("Errore: "+res); } */ SuccessAlert('Task pianificato creato'); document.getElementById("close_new_cron_job").click(); setTimeout(() => { loadCronJobs(); }, 1000); document.getElementById("create_cron_job_button").style.display = 'block'; document.getElementById("create_cron_job_loader").style.display = 'none'; } }); } function editCronJob(cron_id) { document.getElementById("open_edit_cron_job").click(); var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { document.querySelector("#edit_cron_job_content").innerHTML = this.responseText; } }; xmlhttp.open("GET", "public/settings/edit_cron_job_content.php?cron_id="+cron_id); xmlhttp.send(); } function updateCronJob(cron_id) { document.getElementById("update_cron_job_button").style.display = 'none'; document.getElementById("update_cron_job_loader").style.display = 'block'; var command = document.getElementById("command").value; var description = document.getElementById("description").value; var email = document.getElementById("email").value; var frequency = document.getElementById("frequency").value; var language = document.getElementById("language").value; var status = document.getElementById("status").value; $.ajax({ type: "POST", url: "php/settings/update_cron_job.php", data: { cron_id:cron_id, command:command, description:description, email:email, frequency:frequency, language:language, status:status }, success: function (res) { /* if (res == 200) { SuccessAlert('Task pianificato aggiornato'); document.getElementById("close_edit_cron_job").click(); setTimeout(() => { loadCronJobs(); }, 1000); } else { ErrorAlert("Errore: "+res); } */ SuccessAlert('Task pianificato aggiornato'); document.getElementById("close_edit_cron_job").click(); setTimeout(() => { loadCronJobs(); }, 1000); document.getElementById("update_cron_job_button").style.display = 'block'; document.getElementById("update_cron_job_loader").style.display = 'none'; } }); } function loadCronLogs() { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { document.querySelector("#cron_logs_content").innerHTML = this.responseText; $(document).ready( function () { new DataTable('#cron_logs_table', { pageLength: 15, layout: { topStart: { buttons: [ { extend: 'colvis', postfixButtons: ['colvisRestore'], popoverTitle: 'Visibilità colonne' }, { extend: 'print', split: ['print','excel','pdf', 'csv'] } ] } }, language: { emptyTable: "Nessun dato presente nella tabella", search: "Cerca:", infoEmpty: "Visualizzati da 0 a 0 di 0 risultati", info: "Visualizzati da _START_ a _END_ di _TOTAL_ risultati", buttons: { print: "Stampa", colvis: "Visualizza", colvisRestore: "Ripristina visualizzazione" } }, order: { idx: 0, dir: 'desc' } }); } ); } }; xmlhttp.open("GET", "public/settings/cron_logs_list.php"); xmlhttp.send(); } function loadCheckParameters() { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { document.querySelector("#check_parameters_content").innerHTML = this.responseText; } }; xmlhttp.open("GET", "public/settings/check_parameters_content.php"); xmlhttp.send(); } function updateParameter(name) { var value = document.getElementById("parameter_value").value; $.ajax({ type: "POST", url: "php/settings/update_check_parameter.php", data: { name:name, value:value }, success: function (res) { if (res == "ok") { SuccessAlert('Parametro modificato'); } else { ErrorAlert("Errore: "+res); } } }); } function loadCompanyDatas() { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { document.querySelector("#company_datas_content").innerHTML = this.responseText; } }; xmlhttp.open("GET", "public/settings/company_datas_content.php"); xmlhttp.send(); } function updateData(id) { var value = document.getElementById("data_value_"+id).value; $.ajax({ type: "POST", url: "php/settings/update_company_data.php", data: { id:id, value:value }, success: function (res) { if (res == "ok") { SuccessAlert('Dato modificato'); } else { ErrorAlert("Errore: "+res); } } }); } function loadJustifications() { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { document.querySelector("#justifications_content").innerHTML = this.responseText; $(document).ready( function () { new DataTable('#justifications_list_tables', { pageLength: 15, layout: { topStart: { buttons: [ { extend: 'colvis', postfixButtons: ['colvisRestore'], popoverTitle: 'Visibilità colonne' }, { extend: 'print', split: ['print','excel','pdf', 'csv'] }, { text: 'Nuovo giustificativo', action: function (e, dt, node, config) { newJustification(); } } ] } }, language: { emptyTable: "Nessun dato presente nella tabella", search: "Cerca:", infoEmpty: "Visualizzati da 0 a 0 di 0 risultati", info: "Visualizzati da _START_ a _END_ di _TOTAL_ risultati", buttons: { print: "Stampa", colvis: "Visualizza", colvisRestore: "Ripristina visualizzazione" } }, order: { idx: 0, dir: 'asc' } }); }); } }; xmlhttp.open("GET", "public/settings/justifications_content.php"); xmlhttp.send(); } function newJustification() { document.getElementById("open_new_justification").click(); var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { document.querySelector("#new_justification_content").innerHTML = this.responseText; } }; xmlhttp.open("GET", "public/settings/new_justification_content.php"); xmlhttp.send(); } function createJustification() { document.getElementById("create_justification_loader").style.display = 'block'; var name = document.getElementById("name").value; var acronym = document.getElementById("acronym").value; var description = document.getElementById("description").value; var appliance = document.getElementById("appliance").value; $.ajax({ type: "POST", url: "php/settings/create_justification.php", data: { name:name, acronym:acronym, description:description, appliance:appliance }, success: function (res) { if (res === 'error') { ErrorAlert("Errore: "+res) } else { SuccessAlert('Giustificativo creato'); document.getElementById("close_new_justification").click(); setTimeout(() => { loadJustifications(); }, 1000); } document.getElementById("create_justification_loader").style.display = 'none'; } }); } function deleteJustificazion(id) { Swal.fire({ title: "Confermi eliminazione?", text: "I permessi collegati a questo giustificativo non saranno più validi", icon: "warning", showCancelButton: true, confirmButtonColor: "#d33", cancelButtonColor: "gray", confirmButtonText: "Sì, elimina!", cancelButtonText: "Annulla" }).then((result) => { if (result.isConfirmed) { ShowPageLoader(); $.ajax({ type: "POST", url: "php/settings/delete_justification.php", data: { id: id }, success: function (res) { if (res === 'error') { ErrorAlert("Errore: "+res) } else { SuccessAlert('Giustificativo eliminato'); setTimeout(() => { loadJustifications(); }, 1000); } HidePageLoader(); } }); } }); } function editJustificazion(id) { document.getElementById("open_edit_justification").click(); var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { document.querySelector("#edit_justification_content").innerHTML = this.responseText; } }; xmlhttp.open("GET", "public/settings/edit_justification_content.php?id="+id); xmlhttp.send(); } function updateJustification(id) { document.getElementById("update_justification_loader").style.display = 'block'; var name = document.getElementById("edit_name").value; var acronym = document.getElementById("edit_acronym").value; var description = document.getElementById("edit_description").value; var appliance = document.getElementById("edit_appliance").value; $.ajax({ type: "POST", url: "php/settings/update_justification.php", data: { id: id, name:name, acronym:acronym, description:description, appliance:appliance }, success: function (res) { if (res === 'error') { ErrorAlert("Errore: "+res) } else { SuccessAlert('Giustificativo modificato'); document.getElementById("close_edit_justification").click(); setTimeout(() => { loadJustifications(); }, 1000); } document.getElementById("update_justification_loader").style.display = 'none'; } }); } function loadPaymentsOffice() { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { document.querySelector("#payments_office_content").innerHTML = this.responseText; $(document).ready( function () { new DataTable('#jpayments_office_tables', { pageLength: 15, layout: { topStart: { buttons: [ { extend: 'colvis', postfixButtons: ['colvisRestore'], popoverTitle: 'Visibilità colonne' }, { extend: 'print', split: ['print','excel','pdf', 'csv'] }, { text: 'Nuovo contatto', action: function (e, dt, node, config) { newPaymentsOffice(); } } ] } }, language: { emptyTable: "Nessun dato presente nella tabella", search: "Cerca:", infoEmpty: "Visualizzati da 0 a 0 di 0 risultati", info: "Visualizzati da _START_ a _END_ di _TOTAL_ risultati", buttons: { print: "Stampa", colvis: "Visualizza", colvisRestore: "Ripristina visualizzazione" } }, order: { idx: 0, dir: 'asc' } }); }); } }; xmlhttp.open("GET", "public/settings/payments_office_content.php"); xmlhttp.send(); } function newPaymentsOffice() { document.getElementById("open_new_payments_office").click(); var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { document.querySelector("#new_payments_office_content").innerHTML = this.responseText; } }; xmlhttp.open("GET", "public/settings/new_payments_office_content.php"); xmlhttp.send(); } function createPaymentsOffice() { document.getElementById("create_payments_office_loader").style.display = 'block'; document.getElementById("create_payments_office_button").style.display = 'none'; var company = document.getElementById("company").value; var name = document.getElementById("name").value; var email = document.getElementById("email").value; var send_attendance = document.getElementById("send_attendance").checked; $.ajax({ type: "POST", url: "php/settings/create_payments_office.php", data: { company:company, name:name, email: email, send_attendance:send_attendance }, success: function (res) { if (res === 'error') { ErrorAlert("Errore: "+res) } else { SuccessAlert('Contatto creato'); document.getElementById("close_new_payments_office").click(); setTimeout(() => { loadPaymentsOffice(); }, 1000); } document.getElementById("create_payments_office_loader").style.display = 'none'; document.getElementById("create_payments_office_button").style.display = 'block'; } }); } function deletePaymentsOffice(id) { Swal.fire({ title: "Confermi eliminazione?", text: "Non saranno più inviati i cartellini al contatto", icon: "warning", showCancelButton: true, confirmButtonColor: "#d33", cancelButtonColor: "gray", confirmButtonText: "Sì, elimina!", cancelButtonText: "Annulla" }).then((result) => { if (result.isConfirmed) { ShowPageLoader(); $.ajax({ type: "POST", url: "php/settings/delete_payments_office.php", data: { id: id }, success: function (res) { if (res === 'error') { ErrorAlert("Errore: "+res) } else { SuccessAlert('Contatto eliminato'); setTimeout(() => { loadPaymentsOffice(); }, 1000); } HidePageLoader(); } }); } }); } function editPaymentsOffice(id) { document.getElementById("open_edit_payments_office").click(); var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { document.querySelector("#edit_payments_office_content").innerHTML = this.responseText; } }; xmlhttp.open("GET", "public/settings/edit_payments_office_content.php?id="+id); xmlhttp.send(); } function updatePaymentsOffice(id) { document.getElementById("update_payments_office_loader").style.display = 'block'; document.getElementById("update_payments_office_button").style.display = 'none'; var company = document.getElementById("edit_company").value; var name = document.getElementById("edit_name").value; var email = document.getElementById("edit_email").value; var send_attendance = document.getElementById("edit_send_attendance").checked; $.ajax({ type: "POST", url: "php/settings/update_payments_office.php", data: { id: id, company:company, name:name, email:email, send_attendance:send_attendance }, success: function (res) { if (res === 'error') { ErrorAlert("Errore: "+res) } else { SuccessAlert('Contatto modificato'); document.getElementById("close_edit_payments_office").click(); setTimeout(() => { loadPaymentsOffice(); }, 1000); } document.getElementById("update_payments_office_loader").style.display = 'none'; document.getElementById("update_payments_office_button").style.display = 'block'; } }); }