mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-01 16:36:45 +01:00
Miglioramento organizzazione JS
This commit is contained in:
parent
4d6b15a217
commit
dea2d1dbdc
@ -2,8 +2,8 @@
|
||||
|
||||
include_once __DIR__.'/core.php';
|
||||
|
||||
use Models\Note;
|
||||
use Models\Checklist;
|
||||
use Models\Note;
|
||||
use Models\User;
|
||||
|
||||
if (empty($structure) || empty($structure['enabled'])) {
|
||||
|
21
add.php
21
add.php
@ -36,17 +36,10 @@ echo '
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
cleanup_inputs();
|
||||
|
||||
var form = $("#custom_fields_top-add").parent().find("form").first();
|
||||
|
||||
// Rimozione select inizializzati
|
||||
$("#custom_fields_bottom-add").find("select").each(function () {
|
||||
$(this).select2().select2("destroy");
|
||||
});
|
||||
|
||||
$("#custom_fields_bottom-add").find("select").each(function () {
|
||||
$(this).select2().select2("destroy");
|
||||
});
|
||||
|
||||
|
||||
// Campi a inizio form
|
||||
form.prepend($("#custom_fields_top-add").html());
|
||||
|
||||
@ -60,11 +53,9 @@ $(document).ready(function(){
|
||||
if (!last.length) {
|
||||
last = form.find(".row").eq(-2);
|
||||
}
|
||||
|
||||
last.after($("#custom_fields_bottom-add").html());
|
||||
|
||||
start_superselect();
|
||||
start_datepickers();
|
||||
last.after($("#custom_fields_bottom-add").html());
|
||||
restart_inputs();
|
||||
});
|
||||
</script>';
|
||||
|
||||
@ -99,4 +90,4 @@ $(document).ready(function(){
|
||||
}
|
||||
|
||||
echo '
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>';
|
||||
<script>$(document).ready(init)</script>';
|
||||
|
30
assets/src/js/alert.js
Normal file
30
assets/src/js/alert.js
Normal file
@ -0,0 +1,30 @@
|
||||
$(document).ready(function () {
|
||||
// Messaggio di avviso salvataggio a comparsa sulla destra solo nella versione a desktop intero
|
||||
if ($(window).width() > 1023) {
|
||||
var i = 0;
|
||||
|
||||
$('.alert-success.push').each(function () {
|
||||
i++;
|
||||
tops = 60 * i + 95;
|
||||
|
||||
$(this).css({
|
||||
'position': 'fixed',
|
||||
'z-index': 3,
|
||||
'right': '10px',
|
||||
'top': -100,
|
||||
}).delay(1000).animate({
|
||||
'top': tops,
|
||||
}).delay(3000).animate({
|
||||
'top': -100,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Nascondo la notifica se passo sopra col mouse
|
||||
$('.alert-success.push').on('mouseover', function () {
|
||||
$(this).stop().animate({
|
||||
'top': -100,
|
||||
'opacity': 0
|
||||
});
|
||||
});
|
||||
});
|
@ -1,61 +1,83 @@
|
||||
|
||||
// Aggiunta dell'ingranaggio all'unload della pagina
|
||||
$(window).on("beforeunload", function () {
|
||||
$("#main_loading").show();
|
||||
});
|
||||
|
||||
// Rimozione dell'ingranaggio al caricamento completo della pagina
|
||||
$(window).on("load", function () {
|
||||
$("#main_loading").fadeOut();
|
||||
});
|
||||
|
||||
// Fix multi-modal
|
||||
$(document).on('hidden.bs.modal', '.modal', function () {
|
||||
$('.modal:visible').length && $(document.body).addClass('modal-open');
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
// Fix per il menu principale
|
||||
$('.sidebar-menu').tree({
|
||||
followLink: true,
|
||||
});
|
||||
// Imposta la lingua per la gestione automatica delle date dei diversi plugin
|
||||
moment.locale(globals.locale);
|
||||
globals.timestampFormat = moment.localeData().longDateFormat('L') + ' ' + moment.localeData().longDateFormat('LT');
|
||||
|
||||
// Pulsante per il ritorno a inizio pagina
|
||||
var slideToTop = $("<div />");
|
||||
slideToTop.html('<i class="fa fa-chevron-up"></i>');
|
||||
slideToTop.css({
|
||||
position: 'fixed',
|
||||
bottom: '20px',
|
||||
right: '25px',
|
||||
width: '40px',
|
||||
height: '40px',
|
||||
color: '#eee',
|
||||
'font-size': '',
|
||||
'line-height': '40px',
|
||||
'text-align': 'center',
|
||||
'background-color': 'rgba(255, 78, 0)',
|
||||
'box-shadow': '0 0 10px rgba(0, 0, 0, 0.05)',
|
||||
cursor: 'pointer',
|
||||
'z-index': '99999',
|
||||
opacity: '.7',
|
||||
'display': 'none'
|
||||
});
|
||||
// Standard per i popup
|
||||
toastr.options = {
|
||||
"closeButton": true,
|
||||
"debug": false,
|
||||
"newestOnTop": false,
|
||||
"progressBar": true,
|
||||
"positionClass": "toast-top-right",
|
||||
"preventDuplicates": true,
|
||||
"onclick": null,
|
||||
"showDuration": "300",
|
||||
"hideDuration": "1000",
|
||||
"timeOut": "12000",
|
||||
"extendedTimeOut": "8000",
|
||||
"showEasing": "swing",
|
||||
"hideEasing": "linear",
|
||||
"showMethod": "fadeIn",
|
||||
"hideMethod": "fadeOut"
|
||||
};
|
||||
|
||||
slideToTop.on('mouseenter', function () {
|
||||
$(this).css('opacity', '1');
|
||||
});
|
||||
|
||||
slideToTop.on('mouseout', function () {
|
||||
$(this).css('opacity', '.7');
|
||||
});
|
||||
|
||||
$('.wrapper').append(slideToTop);
|
||||
$(window).scroll(function () {
|
||||
if ($(window).scrollTop() >= 150) {
|
||||
if (!$(slideToTop).is(':visible')) {
|
||||
$(slideToTop).fadeIn(500);
|
||||
}
|
||||
} else {
|
||||
$(slideToTop).fadeOut(500);
|
||||
// Imposta lo standard per la conversione dei numeri
|
||||
numeral.register('locale', 'it', {
|
||||
delimiters: {
|
||||
thousands: globals.thousands,
|
||||
decimal: globals.decimals,
|
||||
},
|
||||
abbreviations: {
|
||||
thousand: 'k',
|
||||
million: 'm',
|
||||
billion: 'b',
|
||||
trillion: 't'
|
||||
},
|
||||
currency: {
|
||||
symbol: '€'
|
||||
}
|
||||
});
|
||||
numeral.locale('it');
|
||||
numeral.defaultFormat('0,0.' + ('0').repeat(globals.cifre_decimali));
|
||||
|
||||
$(slideToTop).click(function () {
|
||||
$("html, body").animate({
|
||||
scrollTop: 0
|
||||
}, 500);
|
||||
// Orologio
|
||||
clock();
|
||||
|
||||
// Richiamo alla generazione di Datatables
|
||||
start_datatables();
|
||||
|
||||
init();
|
||||
|
||||
// Calendario principale
|
||||
start_complete_calendar("#daterange", function (start, end) {
|
||||
// Esegue il submit del periodo selezionato e ricarica la pagina
|
||||
$.get(globals.rootdir + '/core.php?period_start=' + start.format('YYYY-MM-DD') + '&period_end=' + end.format('YYYY-MM-DD'), function (data) {
|
||||
location.reload();
|
||||
});
|
||||
});
|
||||
|
||||
$(".sidebar-toggle").click(function(){
|
||||
setTimeout(function(){
|
||||
window.dispatchEvent(new Event('resize'));
|
||||
}, 350);
|
||||
|
||||
// Messaggi automatici di eliminazione
|
||||
$(document).on('click', '.ask', function () {
|
||||
message(this);
|
||||
});
|
||||
|
||||
|
||||
// Forza l'evento "blur" nei campi di testo per formattare i numeri con
|
||||
// jquery inputmask prima del submit
|
||||
setTimeout( function(){
|
||||
|
89
assets/src/js/datatables-buttons.js
Normal file
89
assets/src/js/datatables-buttons.js
Normal file
@ -0,0 +1,89 @@
|
||||
$(document).ready(function () {
|
||||
// Pulsanti di Datatables
|
||||
$(".btn-csv").click(function (e) {
|
||||
var table = $(document).find("#" + $(this).closest("[data-target]").data("target")).DataTable();
|
||||
|
||||
table.buttons(0).trigger();
|
||||
});
|
||||
|
||||
$(".btn-excel").click(function (e) {
|
||||
var table = $(document).find("#" + $(this).closest("[data-target]").data("target")).DataTable();
|
||||
|
||||
table.buttons(3).trigger();
|
||||
});
|
||||
|
||||
$(".btn-pdf").click(function (e) {
|
||||
var table = $(document).find("#" + $(this).closest("[data-target]").data("target")).DataTable();
|
||||
|
||||
table.buttons(4).trigger();
|
||||
});
|
||||
|
||||
$(".btn-copy").click(function (e) {
|
||||
var table = $(document).find("#" + $(this).closest("[data-target]").data("target")).DataTable();
|
||||
|
||||
table.buttons(1).trigger();
|
||||
});
|
||||
|
||||
$(".btn-print").click(function (e) {
|
||||
var table = $(document).find("#" + $(this).closest("[data-target]").data("target")).DataTable();
|
||||
|
||||
table.buttons(2).trigger();
|
||||
});
|
||||
|
||||
$(".btn-select-all").click(function () {
|
||||
var id = $(document).find("#" + $(this).parent().parent().parent().data("target"));
|
||||
var table = id.DataTable();
|
||||
|
||||
$("#main_loading").show();
|
||||
table.clear().draw();
|
||||
|
||||
$(id).data('page-length', table.page.len());
|
||||
|
||||
table.page.len(-1).draw();
|
||||
});
|
||||
|
||||
$(".btn-select-none").click(function () {
|
||||
var id = $(document).find("#" + $(this).parent().parent().parent().data("target"));
|
||||
var table = id.DataTable();
|
||||
|
||||
table.rows().deselect();
|
||||
|
||||
table.page.len($(id).data('page-length'));
|
||||
});
|
||||
|
||||
$(".bulk-action").click(function () {
|
||||
var table = $(document).find("#" + $(this).parent().parent().parent().parent().data("target"));
|
||||
|
||||
if (table.data('selected')) {
|
||||
$(this).attr("data-id_records", table.data('selected'));
|
||||
$(this).data("id_records", table.data('selected'));
|
||||
|
||||
if ($(this).data("type") == "modal") {
|
||||
var data = JSON.parse(JSON.stringify($(this).data()));
|
||||
var href = data.url;
|
||||
|
||||
delete data.url;
|
||||
delete data.title;
|
||||
delete data.op;
|
||||
delete data.backto;
|
||||
delete data.blank;
|
||||
|
||||
var values = [];
|
||||
for (var name in data) {
|
||||
values.push(name + '=' + data[name]);
|
||||
}
|
||||
|
||||
var link = href + (href.indexOf('?') !== -1 ? '&' : '?') + values.join('&');
|
||||
|
||||
launch_modal($(this).data("title"), link);
|
||||
} else {
|
||||
message(this);
|
||||
}
|
||||
|
||||
$(this).attr("data-id_records", "");
|
||||
$(this).data("id_records", "");
|
||||
} else {
|
||||
swal(globals.translations.waiting, globals.translations.waiting_msg, "error");
|
||||
}
|
||||
});
|
||||
});
|
429
assets/src/js/functions/datatables.js
Normal file
429
assets/src/js/functions/datatables.js
Normal file
@ -0,0 +1,429 @@
|
||||
|
||||
function start_local_datatables(){
|
||||
$('.datatables').each(function () {
|
||||
if (!$.fn.DataTable.isDataTable($(this))) {
|
||||
$(this).DataTable({
|
||||
language: {
|
||||
url: globals.js + "/i18n/datatables/" + globals.locale + ".min.json"
|
||||
},
|
||||
retrieve: true,
|
||||
ordering: true,
|
||||
searching: true,
|
||||
paging: false,
|
||||
order: [],
|
||||
lengthChange: false,
|
||||
scrollY: "70vh",
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Datatable
|
||||
function start_datatables() {
|
||||
start_local_datatables();
|
||||
|
||||
$('.main-records').each(function () {
|
||||
var $this = $(this);
|
||||
|
||||
$this.data('selected', '');
|
||||
|
||||
// Controlla che la tabella non sia già inizializzata
|
||||
if (!$.fn.DataTable.isDataTable('#' + $this.attr('id'))) {
|
||||
var id_module = $this.data('idmodule');
|
||||
var id_plugin = $this.data('idplugin');
|
||||
var id_parent = $this.data('idparent');
|
||||
|
||||
// Parametri di ricerca da url o sessione
|
||||
var search = getUrlVars();
|
||||
|
||||
globals.search.forEach(function (value, index, array) {
|
||||
if (search[array[index]] == undefined) {
|
||||
search.push(array[index]);
|
||||
search[array[index]] = array[value];
|
||||
}
|
||||
});
|
||||
|
||||
// Fix per l'URL encoding
|
||||
search.forEach(function (value, index, array) {
|
||||
search[array[index]] = decodeURIComponent(array[value]);
|
||||
});
|
||||
|
||||
var res = [];
|
||||
$this.find("th").each(function () {
|
||||
var id = $(this).attr('id').replace("th_", "");
|
||||
|
||||
sear = search["search_" + id] ? search["search_" + id] : "";
|
||||
|
||||
res.push({
|
||||
"sSearch": sear
|
||||
});
|
||||
});
|
||||
|
||||
var sum;
|
||||
var tempo;
|
||||
var tempo_attesa_ricerche = (globals.tempo_attesa_ricerche * 1000);
|
||||
|
||||
var table = $this.DataTable({
|
||||
language: {
|
||||
url: globals.js + '/i18n/datatables/' + globals.locale + '.min.json'
|
||||
},
|
||||
autoWidth: true,
|
||||
dom: "ti",
|
||||
serverSide: true,
|
||||
deferRender: true,
|
||||
ordering: true,
|
||||
searching: true,
|
||||
aaSorting: [],
|
||||
aoSearchCols: res,
|
||||
scrollY: "60vh",
|
||||
scrollX: '100%',
|
||||
retrieve: true,
|
||||
stateSave: true,
|
||||
stateSaveCallback: function (settings, data) {
|
||||
sessionStorage.setItem('DataTables_' + id_module + '-' + id_plugin + '-' + id_parent, JSON.stringify(data));
|
||||
},
|
||||
stateLoadCallback: function (settings) {
|
||||
return JSON.parse(sessionStorage.getItem('DataTables_' + id_module + '-' + id_plugin + '-' + id_parent));
|
||||
},
|
||||
columnDefs: [{
|
||||
searchable: false,
|
||||
orderable: false,
|
||||
width: '1%',
|
||||
className: 'select-checkbox',
|
||||
targets: 0
|
||||
}],
|
||||
select: {
|
||||
style: 'multi',
|
||||
selector: 'td:first-child'
|
||||
},
|
||||
buttons: [{
|
||||
extend: 'csv',
|
||||
fieldSeparator: ";",
|
||||
exportOptions: {
|
||||
modifier: {
|
||||
selected: true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'copy',
|
||||
exportOptions: {
|
||||
modifier: {
|
||||
selected: true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'print',
|
||||
autoPrint: true,
|
||||
customize: function (win) {
|
||||
$(win.document.body)
|
||||
.css('font-size', '10pt')
|
||||
.append(
|
||||
'<table class="main-records table table-condensed table-bordered dataTable"><tfoot><tr><td></td><td class="pull-right">' + $('#summable').text() + '</td><td></td></tr></tfoot></table>'
|
||||
);
|
||||
$(win.document.body).find('table')
|
||||
.addClass('compact')
|
||||
.css('font-size', 'inherit');
|
||||
$(win.document.body).find('td:first-child')
|
||||
.addClass('hide');
|
||||
$(win.document.body).find('th:first-child')
|
||||
.addClass('hide');
|
||||
},
|
||||
exportOptions: {
|
||||
modifier: {
|
||||
selected: true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'excel',
|
||||
exportOptions: {
|
||||
modifier: {
|
||||
selected: true
|
||||
},
|
||||
format: {
|
||||
body: function(data, row, column, node) {
|
||||
data = $('<p>' + data + '</p>').text();
|
||||
data_edit = data.replace('.', '');
|
||||
data_edit = data_edit.replace(',', '.');
|
||||
|
||||
return data_edit.match(/^[0-9\.]+$/) ? data_edit : data;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'pdf',
|
||||
exportOptions: {
|
||||
modifier: {
|
||||
selected: true
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
scroller: {
|
||||
loadingIndicator: true,
|
||||
displayBuffer: globals.dataload_page_buffer,
|
||||
},
|
||||
ajax: {
|
||||
url: "ajax_dataload.php?id_module=" + id_module + "&id_plugin=" + id_plugin + "&id_parent=" + id_parent,
|
||||
type: 'GET',
|
||||
dataSrc: function (data) {
|
||||
sum = data;
|
||||
return data.data;
|
||||
}
|
||||
},
|
||||
initComplete: function (settings) {
|
||||
var api = this.api();
|
||||
|
||||
api.columns('.search').every(function () {
|
||||
var column = this;
|
||||
$('<br><input type="text" style="width:100%" class="form-control" placeholder="' + globals.translations.filter + '..."><i class="deleteicon fa fa-times fa-2x hide"></i>')
|
||||
.appendTo(column.header())
|
||||
.on('keyup', function (e) {
|
||||
|
||||
clearInterval(tempo);
|
||||
|
||||
// Fix del pulsante di pulizia ricerca e del messaggio sulla ricerca lenta
|
||||
if (e.which != 9) {
|
||||
if (!$(this).val()) {
|
||||
if ($(this).parent().data("slow") != undefined) $("#slow").remove();
|
||||
$(this).removeClass('input-searching');
|
||||
$(this).next('.deleteicon').addClass('hide');
|
||||
} else {
|
||||
if ($(this).parent().data("slow") != undefined && $("#slow").length == 0) {
|
||||
$("#" + $this.attr('id') + "_info").parent().append('<span class="text-danger" id="slow"><i class="fa fa-refresh fa-spin"></i> ' + globals.translations.long + '</span>');
|
||||
}
|
||||
$(this).addClass('input-searching');
|
||||
$(this).next('.deleteicon').removeClass('hide');
|
||||
}
|
||||
}
|
||||
|
||||
function start_search(module_id, field, search_value) {
|
||||
searchTable(module_id, field, search_value);
|
||||
column.search(search_value).draw();
|
||||
}
|
||||
|
||||
// Impostazione delle sessioni per le ricerche del modulo e del campo specificati
|
||||
var module_id = $this.data('idmodule'); //+ "-" + $this.data('idplugin');
|
||||
var field = $(this).parent().attr('id').replace('th_', '');
|
||||
var value = $(this).val();
|
||||
if (e.keyCode == 13 || $(this).val() == '') {
|
||||
start_search(module_id, field, value);
|
||||
} else {
|
||||
tempo = window.setTimeout(start_search, tempo_attesa_ricerche, module_id, field, value);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Disabilito l'ordinamento alla pressione del tasto invio sull'<input>
|
||||
$("thead input, .search").on('keypress', function (e) {
|
||||
stopTableSorting(e);
|
||||
});
|
||||
|
||||
// Disabilito l'ordinamento al click sull'<input>
|
||||
$("thead input, .deleteicon").click(function (e) {
|
||||
stopTableSorting(e);
|
||||
});
|
||||
|
||||
$('.deleteicon').on("click", function (e) {
|
||||
resetTableSearch($(this).parent().attr("id").replace("th_", ""));
|
||||
|
||||
if (api.page.len() == -1){
|
||||
api.page.len($(id).data('page-length'));
|
||||
}
|
||||
});
|
||||
|
||||
// Ricerca di base ereditata dalla sessione
|
||||
search.forEach(function (value, index, array) {
|
||||
var exists = setInterval(function () {
|
||||
input = $('#th_' + array[index].replace('search_', '') + ' input');
|
||||
if (input.length || array[index] == 'id_module' || array[index] == 'id_record') {
|
||||
clearInterval(exists);
|
||||
if (input.val() == '') input.val(array[value]).trigger('keyup');
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
},
|
||||
rowCallback: function (row, data, index) {
|
||||
if ($(data[0]).data('id') && $.inArray($(data[0]).data('id'), $this.data('selected').split(';')) !== -1) {
|
||||
table.row(index).select();
|
||||
}
|
||||
},
|
||||
drawCallback: function (settings) {
|
||||
var api = new $.fn.dataTable.Api(settings);
|
||||
|
||||
$(".dataTables_sizing .deleteicon").addClass('hide');
|
||||
|
||||
$("[data-background]").each(function () {
|
||||
$(this).parent().css("background", $(this).data("background"));
|
||||
});
|
||||
|
||||
$("[data-color]").each(function () {
|
||||
$(this).parent().css("color", $(this).data("color"));
|
||||
});
|
||||
|
||||
$("[data-link]").each(function () {
|
||||
var $link = $(this);
|
||||
$(this).parent().not('.bound').addClass('bound').click(function (event) {
|
||||
if ($link.data('type') == 'dialog') {
|
||||
launch_modal(globals.translations.details, $link.data('link'));
|
||||
} else {
|
||||
openLink(event, $link.data('link'))
|
||||
}
|
||||
});
|
||||
$(this).parent().addClass("clickable");
|
||||
});
|
||||
|
||||
var container = $(document).find('[data-target=' + $this.attr('id') + ']');
|
||||
|
||||
if (api.rows({
|
||||
selected: true
|
||||
}).count() > 0) {
|
||||
container.find('.table-btn').removeClass('disabled').attr('disabled', false);
|
||||
} else {
|
||||
container.find('.table-btn').addClass('disabled').attr('disabled', true);
|
||||
}
|
||||
|
||||
// Seleziona tutto
|
||||
if (api.page.len() == -1) {
|
||||
api.rows({
|
||||
search: "applied"
|
||||
}).select();
|
||||
|
||||
if (this.fnSettings().fnRecordsDisplay() == api.rows({
|
||||
selected: true
|
||||
}).count()) {
|
||||
$("#main_loading").fadeOut();
|
||||
}
|
||||
}
|
||||
},
|
||||
footerCallback: function (row, data, start, end, display) {
|
||||
var i = -1;
|
||||
this.api().columns().every(function () {
|
||||
if (sum.summable[i] != undefined) {
|
||||
$(this.footer()).addClass("text-right");
|
||||
$(this.footer()).attr("id", "summable");
|
||||
$(this.footer()).html(sum.summable[i]);
|
||||
}
|
||||
i++;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
table.on('select deselect', function (e, dt, type, indexes) {
|
||||
if (type === 'row') {
|
||||
var selected = $this.data('selected').split(';');
|
||||
|
||||
selected = selected.filter(function (value, index, self) {
|
||||
return value != '' && self.indexOf(value) === index;
|
||||
});
|
||||
|
||||
var data = table.rows(indexes).data();
|
||||
|
||||
data.each(function (item) {
|
||||
var id = $(item[0]).data('id');
|
||||
|
||||
if (id) {
|
||||
if (e.type == 'select') {
|
||||
selected.push(id);
|
||||
} else {
|
||||
var index = selected.indexOf("" + id);
|
||||
if (index > -1) {
|
||||
delete selected[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
selected = selected.filter(function (value, index, self) {
|
||||
return value != '' && self.indexOf(value) === index;
|
||||
});
|
||||
|
||||
$this.data('selected', selected.join(';'));
|
||||
|
||||
var container = $(document).find('[data-target=' + $this.attr('id') + ']');
|
||||
|
||||
if (selected.length > 0) {
|
||||
container.find('.bulk-container').removeClass('disabled');
|
||||
container.find('.bulk-container').attr('disabled', false);
|
||||
} else {
|
||||
container.find('.bulk-container').addClass('disabled');
|
||||
container.find('.bulk-container').attr('disabled', true);
|
||||
}
|
||||
|
||||
if (table.rows({
|
||||
selected: true
|
||||
}).count() > 0) {
|
||||
container.find('.table-btn').removeClass('disabled').attr('disabled', false);
|
||||
} else {
|
||||
container.find('.table-btn').addClass('disabled').attr('disabled', true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
table.on('processing.dt', function (e, settings, processing) {
|
||||
if (processing) {
|
||||
$('#mini-loader').show();
|
||||
} else {
|
||||
$('#mini-loader').hide();
|
||||
|
||||
//Reimposto il flag sulle righe ricaricate selezionate in precedenza
|
||||
var selected = $this.data('selected').split(';');
|
||||
|
||||
table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
var object_span = $.parseHTML(this.data()[0])[0];
|
||||
var id = $(object_span).data('id');
|
||||
|
||||
for (i = 0; i < selected.length; i++) {
|
||||
var value = selected[i];
|
||||
if (value == id) {
|
||||
table.row(':eq(' + rowIdx + ')', {
|
||||
page: 'current'
|
||||
}).select();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function stopTableSorting(e) {
|
||||
if (!e) var e = window.event;
|
||||
e.cancelBubble = true;
|
||||
if (e.stopPropagation) e.stopPropagation();
|
||||
}
|
||||
|
||||
function resetTableSearch(type) {
|
||||
if (type == null) $('[id^=th_] input').val('').trigger('keyup');
|
||||
else $('[id^=th_' + type + '] input').val('').trigger('keyup');
|
||||
}
|
||||
|
||||
function reset(type) {
|
||||
return resetTableSearch(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sostituisce i caratteri speciali per la ricerca attraverso le tabelle Datatables.
|
||||
*
|
||||
* @param string field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function searchFieldName(field) {
|
||||
return field.replace(' ', '-').replace('.', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Salva nella sessione la ricerca per le tabelle Datatables.
|
||||
*
|
||||
* @param int module_id
|
||||
* @param string field
|
||||
* @param mixed value
|
||||
*/
|
||||
function searchTable(module_id, field, value) {
|
||||
session_set('module_' + module_id + ',' + 'search_' + searchFieldName(field), value, 0);
|
||||
}
|
101
assets/src/js/functions/dates.js
Normal file
101
assets/src/js/functions/dates.js
Normal file
@ -0,0 +1,101 @@
|
||||
|
||||
function start_datepickers() {
|
||||
var icons = {
|
||||
time: 'fa fa-clock-o',
|
||||
date: 'fa fa-calendar',
|
||||
up: 'fa fa-chevron-up',
|
||||
down: 'fa fa-chevron-down',
|
||||
previous: 'fa fa-chevron-left',
|
||||
next: 'fa fa-chevron-right',
|
||||
today: 'fa fa-street-view',
|
||||
clear: 'fa fa-trash',
|
||||
close: 'fa fa-times'
|
||||
};
|
||||
|
||||
$('.timestamp-picker').each(function () {
|
||||
$this = $(this);
|
||||
$this.datetimepicker({
|
||||
locale: globals.locale,
|
||||
icons: icons,
|
||||
collapse: false,
|
||||
sideBySide: true,
|
||||
useCurrent: false,
|
||||
stepping: 5,
|
||||
widgetPositioning: {
|
||||
horizontal: 'left',
|
||||
vertical: 'bottom'
|
||||
},
|
||||
minDate: moment($this.attr('min-date')).isValid() ? $this.attr('min-date') : false,
|
||||
maxDate: moment($this.attr('max-date')).isValid() ? $this.attr('max-date') : false,
|
||||
});
|
||||
});
|
||||
|
||||
//fix per timestamp-picker non visibile con la classe table-responsive
|
||||
$('.timestamp-picker').each(function () {
|
||||
$this = $(this);
|
||||
$this.on("dp.show", function (e) {
|
||||
$('#tecnici > div').removeClass('table-responsive');
|
||||
});
|
||||
$this.on("dp.hide", function (e) {
|
||||
$('#tecnici > div').addClass('table-responsive');
|
||||
})
|
||||
});
|
||||
|
||||
$('.datepicker').each(function () {
|
||||
$this = $(this);
|
||||
$this.datetimepicker({
|
||||
locale: globals.locale,
|
||||
icons: icons,
|
||||
useCurrent: false,
|
||||
format: 'L',
|
||||
minDate: moment($this.attr('min-date')).isValid() ? $this.attr('min-date') : false,
|
||||
maxDate: moment($this.attr('max-date')).isValid() ? $this.attr('max-date') : false,
|
||||
});
|
||||
});
|
||||
|
||||
$('.timepicker').each(function () {
|
||||
$this = $(this);
|
||||
$this.datetimepicker({
|
||||
locale: globals.locale,
|
||||
icons: icons,
|
||||
useCurrent: false,
|
||||
format: 'LT',
|
||||
stepping: 5,
|
||||
minDate: moment($this.attr('min-date')).isValid() ? $this.attr('min-date') : false,
|
||||
maxDate: moment($this.attr('max-date')).isValid() ? $this.attr('max-date') : false,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function start_complete_calendar(id, callback) {
|
||||
var ranges = {};
|
||||
ranges[globals.translations.today] = [moment(), moment()];
|
||||
ranges[globals.translations.firstThreemester] = [moment("01", "MM"), moment("03", "MM").endOf('month')];
|
||||
ranges[globals.translations.secondThreemester] = [moment("04", "MM"), moment("06", "MM").endOf('month')];
|
||||
ranges[globals.translations.thirdThreemester] = [moment("07", "MM"), moment("09", "MM").endOf('month')];
|
||||
ranges[globals.translations.fourthThreemester] = [moment("10", "MM"), moment("12", "MM").endOf('month')];
|
||||
ranges[globals.translations.firstSemester] = [moment("01", "MM"), moment("06", "MM").endOf('month')];
|
||||
ranges[globals.translations.secondSemester] = [moment("06", "MM"), moment("12", "MM").endOf('month')];
|
||||
ranges[globals.translations.thisMonth] = [moment().startOf('month'), moment().endOf('month')];
|
||||
ranges[globals.translations.lastMonth] = [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')];
|
||||
ranges[globals.translations.thisYear] = [moment().startOf('year'), moment().endOf('year')];
|
||||
ranges[globals.translations.lastYear] = [moment().subtract(1, 'year').startOf('year'), moment().subtract(1, 'year').endOf('year')];
|
||||
|
||||
$(id).daterangepicker({
|
||||
locale: {
|
||||
customRangeLabel: globals.translations.custom,
|
||||
applyLabel: globals.translations.apply,
|
||||
cancelLabel: globals.translations.cancel,
|
||||
fromLabel: globals.translations.from,
|
||||
toLabel: globals.translations.to,
|
||||
},
|
||||
ranges: ranges,
|
||||
startDate: globals.start_date_formatted,
|
||||
endDate: globals.end_date_formatted,
|
||||
applyClass: 'btn btn-success btn-sm',
|
||||
cancelClass: 'btn btn-danger btn-sm',
|
||||
linkedCalendars: false
|
||||
},
|
||||
callback
|
||||
);
|
||||
}
|
488
assets/src/js/functions/functions.js
Normal file
488
assets/src/js/functions/functions.js
Normal file
@ -0,0 +1,488 @@
|
||||
// Modal
|
||||
function launch_modal(title, href, init_modal, id) {
|
||||
// Fix - Select2 does not function properly when I use it inside a Bootstrap modal.
|
||||
$.fn.modal.Constructor.prototype.enforceFocus = function () {
|
||||
};
|
||||
|
||||
if (id == null) {
|
||||
id = '#bs-popup';
|
||||
|
||||
// Generazione dinamica modal
|
||||
/*
|
||||
id = 'bs-popup-' + Math.floor(Math.random() * 100);
|
||||
$('#modals').append('<div class="modal fade" id="' + id + '" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="true"></div>');
|
||||
|
||||
id = '#' + id;
|
||||
*/
|
||||
}
|
||||
|
||||
if (init_modal == null) {
|
||||
init_modal = 1;
|
||||
}
|
||||
|
||||
$(id).on('hidden.bs.modal', function () {
|
||||
if ($('.modal-backdrop').length < 1) {
|
||||
$(this).html('');
|
||||
$(this).data('modal', null);
|
||||
}
|
||||
});
|
||||
|
||||
// Lettura contenuto div
|
||||
if (href.substr(0, 1) == '#') {
|
||||
data = $(href).html();
|
||||
|
||||
$(id).html(
|
||||
'<div class="modal-dialog modal-lg">' +
|
||||
' <div class="modal-content">' +
|
||||
' <div class="modal-header bg-light-blue">' +
|
||||
' <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">' + globals.translations.close + '</span></button>' +
|
||||
' <h4 class="modal-title"><i class="fa fa-pencil"></i> ' + title + '</h4>' +
|
||||
' </div>' +
|
||||
' <div class="modal-body">' + data + '</div>'
|
||||
);
|
||||
if (init_modal == 1) {
|
||||
$(id).modal('show');
|
||||
}
|
||||
} else {
|
||||
$.get(href, function (data, response) {
|
||||
if (response == 'success') {
|
||||
$(id).html(
|
||||
'<div class="modal-dialog modal-lg">' +
|
||||
' <div class="modal-content">' +
|
||||
' <div class="modal-header bg-light-blue">' +
|
||||
' <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">' + globals.translations.close + '</span></button>' +
|
||||
' <h4 class="modal-title"><i class="fa fa-pencil"></i> ' + title + '</h4>' +
|
||||
' </div>' +
|
||||
' <div class="modal-body">' + data + '</div>'
|
||||
);
|
||||
if (init_modal == 1) {
|
||||
$(id).modal('show');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function openLink(event, link) {
|
||||
if (event.ctrlKey) {
|
||||
window.open(link);
|
||||
} else {
|
||||
location.href = link;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Funzione per far scrollare la pagina fino a un id + focus e offset
|
||||
* @param integer offset
|
||||
* @param string id
|
||||
*/
|
||||
function scrollToAndFocus(offset, id) {
|
||||
if (id) {
|
||||
offset += $('#' + id).offset().top;
|
||||
}
|
||||
|
||||
$('html,body').animate({
|
||||
scrollTop: offset
|
||||
}, 'slow');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna un array associativo con i parametri passati via GET
|
||||
*/
|
||||
function getUrlVars(url) {
|
||||
var vars = [],
|
||||
hash;
|
||||
if (url == null)
|
||||
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
||||
else
|
||||
var hashes = url.slice(url.indexOf('?') + 1).split('&');
|
||||
for (var i = 0; i < hashes.length; i++) {
|
||||
hash = hashes[i].split('=');
|
||||
vars.push(hash[0]);
|
||||
vars[hash[0]] = hash[1];
|
||||
}
|
||||
|
||||
return vars;
|
||||
}
|
||||
|
||||
// Data e ora (orologio)
|
||||
function clock() {
|
||||
$('#datetime').html(moment().format(globals.timestampFormat));
|
||||
setTimeout('clock()', 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Funzione per impostare un valore ad un array in $_SESSION
|
||||
*/
|
||||
function session_set_array(session_array, value, inversed) {
|
||||
if (inversed == undefined) {
|
||||
inversed = 1;
|
||||
}
|
||||
|
||||
return $.get(globals.rootdir + "/ajax.php?op=session_set_array&session=" + session_array + "&value=" + value + "&inversed=" + inversed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Funzione per impostare un valore ad una sessione
|
||||
*/
|
||||
function session_set(session_array, value, clear, reload) {
|
||||
if (clear == undefined) {
|
||||
clear = 1;
|
||||
}
|
||||
|
||||
if (reload == undefined) {
|
||||
reload = 0;
|
||||
}
|
||||
|
||||
return $.get(globals.rootdir + "/ajax.php?op=session_set&session=" + session_array + "&value=" + value + "&clear=" + clear, function (data, status) {
|
||||
|
||||
if (reload == 1)
|
||||
location.reload();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function session_keep_alive() {
|
||||
$.get(globals.rootdir + '/core.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Funzione per gestire i contatori testuali nel formato x/total.
|
||||
* Viene dato un id del campo da verificare come input, viene letto il testo nella forma [0-9]/[0-9] e viene fatto
|
||||
* il replate del primo numero in base a quanti elementi sono stati trovati (valore passato per parametro)
|
||||
*/
|
||||
function update_counter(id, new_value) {
|
||||
new_text = $('#' + id).html();
|
||||
|
||||
// Estraggo parte numerica (formato x/total)
|
||||
pattern = /([^0-9]+)([0-9]+)\/([0-9]+)([^0-9]+)/;
|
||||
new_text = new_text.replace(pattern, "$1" + new_value + "/$3$4");
|
||||
|
||||
// Estraggo totale (parte numerica dopo lo slash /)
|
||||
matches = pattern.exec(new_text);
|
||||
total = matches[3];
|
||||
|
||||
$('#' + id).html(new_text);
|
||||
|
||||
if (new_value == total) {
|
||||
$('#' + id).removeClass('btn-warning').removeClass('btn-danger').addClass('btn-success');
|
||||
} else if (new_value == 0) {
|
||||
$('#' + id).removeClass('btn-warning').removeClass('btn-success').addClass('btn-danger');
|
||||
} else {
|
||||
$('#' + id).removeClass('btn-success').removeClass('btn-danger').addClass('btn-warning');
|
||||
}
|
||||
}
|
||||
|
||||
function setContrast(backgroundcolor) {
|
||||
var rgb = [];
|
||||
var bg = String(backgroundcolor);
|
||||
|
||||
// ex. backgroundcolor = #ffc400
|
||||
rgb[0] = bg.substr(1, 2);
|
||||
rgb[1] = bg.substr(2, 2);
|
||||
rgb[2] = bg.substr(5, 2);
|
||||
|
||||
var R1 = parseInt(rgb[0], 16);
|
||||
var G1 = parseInt(rgb[1], 16);
|
||||
var B1 = parseInt(rgb[2], 16);
|
||||
|
||||
var R2 = 255;
|
||||
var G2 = 255;
|
||||
var B2 = 255;
|
||||
|
||||
var L1 = 0.2126 * Math.pow(R1 / 255, 2.2) + 0.7152 * Math.pow(G1 / 255, 2.2) + 0.0722 * Math.pow(B1 / 255, 2.2);
|
||||
var L2 = 0.2126 * Math.pow(R2 / 255, 2.2) + 0.7152 * Math.pow(G2 / 255, 2.2) + 0.0722 * Math.pow(B2 / 255, 2.2);
|
||||
|
||||
if (L1 > L2) {
|
||||
var lum = (L1 + 0.05) / (L2 + 0.05);
|
||||
} else {
|
||||
var lum = (L2 + 0.05) / (L1 + 0.05);
|
||||
}
|
||||
|
||||
if (lum >= 9) {
|
||||
return "#ffffff";
|
||||
} else {
|
||||
return "#000000";
|
||||
}
|
||||
}
|
||||
|
||||
function message(element) {
|
||||
data = $.extend({}, $(element).data());
|
||||
|
||||
var title = globals.translations.deleteTitle;
|
||||
if (data["title"] != undefined) title = data["title"];
|
||||
|
||||
var msg = globals.translations.deleteMessage;
|
||||
if (data["msg"] != undefined) msg = data["msg"];
|
||||
|
||||
var button = globals.translations.delete;
|
||||
if (data["button"] != undefined) button = data["button"];
|
||||
|
||||
var btn_class = "btn btn-lg btn-danger";
|
||||
if (data["class"] != undefined) btn_class = data["class"];
|
||||
|
||||
swal({
|
||||
title: title,
|
||||
html: '<div id="swal-form" data-parsley-validate>' + msg + '</div>',
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonText: button,
|
||||
confirmButtonClass: btn_class,
|
||||
onOpen: function () {
|
||||
start_superselect();
|
||||
start_inputmask();
|
||||
},
|
||||
preConfirm: function () {
|
||||
$form = $('#swal-form');
|
||||
$form.find(':input').each(function () {
|
||||
data[$(this).attr('name')] = $(this).val();
|
||||
});
|
||||
|
||||
if ($form.parsley().validate()) {
|
||||
return new Promise(function (resolve) {
|
||||
resolve();
|
||||
});
|
||||
} else {
|
||||
$('.swal2-buttonswrapper button').each(function () {
|
||||
$(this).prop('disabled', false);
|
||||
});
|
||||
}
|
||||
}
|
||||
}).then(
|
||||
function () {
|
||||
if (data["op"] == undefined) data["op"] = "delete";
|
||||
|
||||
var href = window.location.href.split("#")[0];
|
||||
if (data["href"] != undefined) {
|
||||
href = data["href"];
|
||||
delete data.href;
|
||||
}
|
||||
|
||||
var hash = window.location.href.split("#")[1];
|
||||
if (hash) {
|
||||
data["hash"] = hash;
|
||||
}
|
||||
|
||||
method = "post";
|
||||
if (data["method"] != undefined) {
|
||||
if (data["method"] == "post" || data["method"] == "get") {
|
||||
method = data["method"];
|
||||
}
|
||||
delete data.method;
|
||||
}
|
||||
|
||||
blank = data.blank != undefined && data.blank;
|
||||
delete data.blank;
|
||||
|
||||
if (data.callback) {
|
||||
$.ajax({
|
||||
type: method,
|
||||
crossDomain: true,
|
||||
url: href,
|
||||
data: data,
|
||||
beforeSend: function (response) {
|
||||
var before = window[data.before];
|
||||
|
||||
if (typeof before === 'function') {
|
||||
before(response);
|
||||
}
|
||||
},
|
||||
success: function (response) {
|
||||
var callback = window[data.callback];
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
callback(response);
|
||||
}
|
||||
},
|
||||
error: function (xhr, ajaxOptions, error) {
|
||||
swal({
|
||||
title: globals.translations.errorTitle,
|
||||
html: globals.translations.errorMessage,
|
||||
type: "error",
|
||||
})
|
||||
},
|
||||
});
|
||||
} else {
|
||||
redirect(href, data, method, blank);
|
||||
}
|
||||
},
|
||||
function (dismiss) {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function redirect(href, data, method, blank) {
|
||||
method = method ? method : "get";
|
||||
blank = blank ? blank : false;
|
||||
|
||||
if (method == "post") {
|
||||
var text = '<form action="' + href + window.location.hash + '" method="post"' + (blank ? ' target="_blank"' : '') + '>';
|
||||
|
||||
for (var name in data) {
|
||||
text += '<input type="hidden" name="' + name + '" value="' + data[name] + '"/>';
|
||||
}
|
||||
|
||||
text += '</form>';
|
||||
|
||||
var form = $(text);
|
||||
$('body').append(form);
|
||||
|
||||
form.submit();
|
||||
} else {
|
||||
var values = [];
|
||||
|
||||
for (var name in data) {
|
||||
values.push(name + '=' + data[name]);
|
||||
}
|
||||
|
||||
var link = href + (href.indexOf('?') !== -1 ? '&' : '?') + values.join('&') + window.location.hash;
|
||||
|
||||
if (!blank) {
|
||||
location.href = link;
|
||||
} else {
|
||||
window.open(link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setCookie(cname, cvalue, exdays) {
|
||||
var d = new Date();
|
||||
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
|
||||
var expires = "expires=" + d.toUTCString();
|
||||
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
|
||||
}
|
||||
|
||||
function getCookie(cname) {
|
||||
var name = cname + "=";
|
||||
var decodedCookie = decodeURIComponent(document.cookie);
|
||||
var ca = decodedCookie.split(';');
|
||||
for (var i = 0; i < ca.length; i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0) == ' ') {
|
||||
c = c.substring(1);
|
||||
}
|
||||
if (c.indexOf(name) == 0) {
|
||||
return c.substring(name.length, c.length);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function buttonLoading(button) {
|
||||
var $this = $(button);
|
||||
|
||||
var result = [
|
||||
$this.html(),
|
||||
$this.attr("class")
|
||||
];
|
||||
|
||||
$this.html('<i class="fa fa-spinner fa-pulse fa-fw"></i> Attendere...');
|
||||
$this.addClass("btn-warning");
|
||||
$this.prop("disabled", true);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function buttonRestore(button, loadingResult) {
|
||||
var $this = $(button);
|
||||
|
||||
$this.html(loadingResult[0]);
|
||||
|
||||
$this.attr("class", "");
|
||||
$this.addClass(loadingResult[1]);
|
||||
$this.prop("disabled", false);
|
||||
}
|
||||
|
||||
function submitAjax(form, data, callback, errorCallback) {
|
||||
var valid = $(form).parsley().validate();
|
||||
|
||||
if (!data) data = {};
|
||||
|
||||
if(valid) {
|
||||
$("#main_loading").show();
|
||||
|
||||
content_was_modified = false;
|
||||
|
||||
// Fix per gli id di default
|
||||
data.id_module = data.id_module ? data.id_module : globals.id_module;
|
||||
data.id_record = data.id_record ? data.id_record : globals.id_record;
|
||||
data.id_plugin = data.id_plugin ? data.id_plugin : globals.id_plugin;
|
||||
data.ajax = 1;
|
||||
|
||||
// Invio dei dati
|
||||
$(form).ajaxSubmit({
|
||||
url: globals.rootdir + "/actions.php",
|
||||
data: data,
|
||||
type: "post",
|
||||
success: function (data) {
|
||||
data = data.trim();
|
||||
|
||||
if (data) {
|
||||
response = JSON.parse(data);
|
||||
if (callback) callback(response);
|
||||
}
|
||||
|
||||
$("#main_loading").fadeOut();
|
||||
|
||||
// Visualizzazione messaggi
|
||||
$.ajax({
|
||||
url: globals.rootdir + '/ajax.php',
|
||||
type: 'get',
|
||||
data: {
|
||||
op: 'flash',
|
||||
},
|
||||
success: function (flash) {
|
||||
messages = JSON.parse(flash);
|
||||
|
||||
info = messages.info ? messages.info : {};
|
||||
Object.keys(info).forEach(function (element) {
|
||||
toastr["success"](info[element]);
|
||||
});
|
||||
|
||||
warning = messages.warning ? messages.warning : {};
|
||||
Object.keys(warning).forEach(function (element) {
|
||||
toastr["warning"](warning[element]);
|
||||
});
|
||||
|
||||
error = messages.error ? messages.error : {};
|
||||
Object.keys(error).forEach(function (element) {
|
||||
toastr["error"](error[element]);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function (data) {
|
||||
$("#main_loading").fadeOut();
|
||||
|
||||
toastr["error"](data);
|
||||
|
||||
if (errorCallback) errorCallback(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
function removeHash() {
|
||||
history.replaceState(null, null, ' ');
|
||||
}
|
||||
|
||||
function replaceAll(str, find, replace) {
|
||||
return str.replace(new RegExp(find, "g"), replace);
|
||||
}
|
||||
|
||||
function cleanup_inputs() {
|
||||
$('.superselect, .superselectajax').select2().select2("destroy");
|
||||
}
|
||||
|
||||
function restart_inputs() {
|
||||
start_datepickers();
|
||||
start_inputmask();
|
||||
|
||||
start_superselect();
|
||||
|
||||
// Autosize per le textarea
|
||||
autosize($('.autosize'));
|
||||
}
|
||||
|
56
assets/src/js/functions/hooks.js
Normal file
56
assets/src/js/functions/hooks.js
Normal file
@ -0,0 +1,56 @@
|
||||
|
||||
function executeHook(hook, length){
|
||||
$("#hooks").append('<li id="hook-loader-' + hook.id + '"><a href="#">' + globals.translations.hookExecuting.replace('_NAME_', hook.name) + '</a></li>');
|
||||
|
||||
$.ajax({
|
||||
url: globals.rootdir + "/ajax.php",
|
||||
type: "get",
|
||||
data: {
|
||||
op: "hook",
|
||||
id: hook.id,
|
||||
},
|
||||
success: function(data) {
|
||||
result = JSON.parse(data);
|
||||
|
||||
$("#hook-loader-" + hook.id).remove();
|
||||
|
||||
notification = '<li class="hook-element"><a href="' + (result.link ? result.link : "#") + '"><i class="' + result.icon + '"></i><span class="small" > ' + result.message + '</span></a></li>';
|
||||
|
||||
// Inserimento della notifica
|
||||
hooks_number = $("#hooks-number");
|
||||
number = parseInt(hooks_number.text());
|
||||
number = isNaN(number) ? 0 : number;
|
||||
|
||||
if(result.notify) {
|
||||
number++;
|
||||
|
||||
$("#hooks").prepend(notification);
|
||||
} else {
|
||||
//$("#hooks").append(notification);
|
||||
}
|
||||
|
||||
hooks_number.text(number);
|
||||
|
||||
// Contatore dell'esecuzione degli hook
|
||||
hooks_counter = $("#hooks-counter");
|
||||
counter = parseInt(hooks_counter.text());
|
||||
counter++;
|
||||
hooks_counter.text(counter);
|
||||
|
||||
// Rimozione eventuale della rotella di caricamento
|
||||
if(counter == hooks.length) {
|
||||
$("#hooks-loading").hide();
|
||||
|
||||
if (number > 1){
|
||||
hookMessage = globals.translations.hookMultiple.replace('_NUM_', number);
|
||||
}else if(number == 1){
|
||||
hookMessage = globals.translations.hookSingle;
|
||||
}else {
|
||||
hookMessage = globals.translations.hookNone;
|
||||
}
|
||||
|
||||
$("#hooks-header").text(hookMessage);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
$(document).ready(function () {
|
||||
function init() {
|
||||
// Inizializzazzione dei box AdminLTE
|
||||
$('.box').boxWidget();
|
||||
|
||||
@ -60,5 +60,5 @@ $(document).ready(function () {
|
||||
return false;
|
||||
});
|
||||
|
||||
restart_input();
|
||||
});
|
||||
restart_inputs();
|
||||
}
|
66
assets/src/js/functions/input.js
Normal file
66
assets/src/js/functions/input.js
Normal file
@ -0,0 +1,66 @@
|
||||
|
||||
// Inputmask
|
||||
function start_inputmask(element) {
|
||||
if (element == undefined) {
|
||||
element = '';
|
||||
} else {
|
||||
element = element + ' ';
|
||||
}
|
||||
|
||||
var date = moment.localeData().longDateFormat('L').toLowerCase();
|
||||
|
||||
$(element + ".date-mask").not('.bound').inputmask(date, {
|
||||
"placeholder": date
|
||||
}).addClass('bound');
|
||||
|
||||
$(element + '.email-mask').not('.bound').inputmask('Regex', {
|
||||
regex: "^[a-zA-Z0-9_!#$%&'*+/=?`{|}~^-]+(?:\\.[a-zA-Z0-9_!#$%&'*+/=?`{|}~^-]+)*@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$",
|
||||
}).addClass('bound');
|
||||
|
||||
$(element + '.alphanumeric-mask').not('.bound').inputmask('Regex', {
|
||||
regex: "[A-Za-z0-9#_|\/\\-.]*",
|
||||
}).addClass('bound');
|
||||
|
||||
if (globals.is_mobile) {
|
||||
$(element + '.inputmask-decimal, ' + element + '.date-mask, ' + element + '.timestamp-mask').each(function () {
|
||||
$(this).attr('type', 'tel');
|
||||
}).addClass('bound');
|
||||
} else {
|
||||
$(element + '.inputmask-decimal').not('.bound').each(function () {
|
||||
var $this = $(this);
|
||||
|
||||
var min = $this.attr('min-value');
|
||||
if (min == 'undefined') {
|
||||
min = false;
|
||||
}
|
||||
|
||||
var max = $this.attr('max-value');
|
||||
if (max == 'undefined') {
|
||||
max = false;
|
||||
}
|
||||
|
||||
$this.inputmask("decimal", {
|
||||
min: min ? min : undefined,
|
||||
allowMinus: !min || min < 0 ? true : false,
|
||||
max: max ? max : undefined,
|
||||
allowPlus: !max || max < 0 ? true : false,
|
||||
digits: $this.attr('decimals') ? $this.attr('decimals') : globals.cifre_decimali,
|
||||
digitsOptional: true, // Necessario per un problema di inputmask con i numeri negativi durante l'init
|
||||
enforceDigitsOnBlur: true,
|
||||
rightAlign: true,
|
||||
autoGroup: true,
|
||||
radixPoint: globals.decimals,
|
||||
groupSeparator: globals.thousands,
|
||||
onUnMask: function (maskedValue, unmaskedValue) {
|
||||
return maskedValue.toEnglish();
|
||||
},
|
||||
});
|
||||
|
||||
$this.on('keyup', function () {
|
||||
if (min && $(this).val().toEnglish() < min) {
|
||||
$(this).val(min);
|
||||
}
|
||||
});
|
||||
}).addClass('bound');
|
||||
}
|
||||
}
|
19
assets/src/js/functions/prototypes.js
vendored
Normal file
19
assets/src/js/functions/prototypes.js
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Number.prototype.formatMoney = function (c, d, t) {
|
||||
var n = this,
|
||||
c = isNaN(c = Math.abs(c)) ? 2 : c,
|
||||
d = d == undefined ? "." : d,
|
||||
t = t == undefined ? "," : t,
|
||||
s = n < 0 ? "-" : "",
|
||||
i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
|
||||
j = (j = i.length) > 3 ? j % 3 : 0;
|
||||
|
||||
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
|
||||
};
|
||||
|
||||
String.prototype.toEnglish = function () {
|
||||
return numeral(this.toString()).value();
|
||||
};
|
||||
|
||||
Number.prototype.toLocale = function () {
|
||||
return numeral(this).format();
|
||||
};
|
183
assets/src/js/functions/select.js
Normal file
183
assets/src/js/functions/select.js
Normal file
@ -0,0 +1,183 @@
|
||||
|
||||
// Select
|
||||
function start_superselect() {
|
||||
// Statico
|
||||
$('.superselect').each(function () {
|
||||
$this = $(this);
|
||||
$(this).select2({
|
||||
theme: "bootstrap",
|
||||
language: "it",
|
||||
width: '100%',
|
||||
maximumSelectionLength: $this.data('maximum') ? $this.data('maximum') : -1,
|
||||
minimumResultsForSearch: $this.hasClass('no-search') ? -1 : 0,
|
||||
allowClear: $this.hasClass('no-search') ? false : true,
|
||||
templateResult: function (data, container) {
|
||||
var bg; // templateSelection
|
||||
|
||||
if (data._bgcolor_) {
|
||||
bg = data._bgcolor_;
|
||||
} else if ($(data.element).attr("_bgcolor_")) {
|
||||
bg = $(data.element).attr("_bgcolor_");
|
||||
} else if ($(data.element).data("_bgcolor_")) {
|
||||
bg = $(data.element).data("_bgcolor_");
|
||||
}
|
||||
|
||||
if (bg) {
|
||||
$(container).css("background-color", bg);
|
||||
$(container).css("color", setContrast(bg));
|
||||
}
|
||||
|
||||
return data.text;
|
||||
},
|
||||
escapeMarkup: function (text) {
|
||||
return text;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Dinamico (AJAX, per tabelle con molti record)
|
||||
$('.superselectajax').each(function () {
|
||||
$this = $(this);
|
||||
|
||||
$(this).select2({
|
||||
theme: "bootstrap",
|
||||
language: "it",
|
||||
maximumSelectionLength: $this.data('maximum') ? $this.data('maximum') : -1,
|
||||
minimumInputLength: $this.data('heavy') ? 3 : 0,
|
||||
allowClear: true,
|
||||
escapeMarkup: function (text) {
|
||||
return text;
|
||||
},
|
||||
templateResult: function (data, container) {
|
||||
var bg; // templateSelection
|
||||
|
||||
if (data._bgcolor_) {
|
||||
bg = data._bgcolor_;
|
||||
} else if ($(data.element).attr("_bgcolor_")) {
|
||||
bg = $(data.element).attr("_bgcolor_");
|
||||
} else if ($(data.element).data("_bgcolor_")) {
|
||||
bg = $(data.element).data("_bgcolor_");
|
||||
}
|
||||
|
||||
if (bg && !$("head").find('#' + data._resultId + '_style').length) {
|
||||
$(container).css("background-color", bg);
|
||||
$(container).css("color", setContrast(bg));
|
||||
}
|
||||
|
||||
return data.text;
|
||||
},
|
||||
ajax: {
|
||||
url: globals.rootdir + "/ajax_select.php?op=" + $this.data('source'),
|
||||
dataType: 'json',
|
||||
delay: 250,
|
||||
data: function (params) {
|
||||
return {
|
||||
search: params.term,
|
||||
page: params.page || 0,
|
||||
length: params.length || 100,
|
||||
}
|
||||
},
|
||||
processResults: function (data, params) {
|
||||
params.page = params.page || 0;
|
||||
params.length = params.length || 100;
|
||||
|
||||
var response = {
|
||||
results: data.results,
|
||||
pagination: {
|
||||
more: (params.page + 1) * params.length < data.recordsFiltered,
|
||||
}
|
||||
};
|
||||
|
||||
return response;
|
||||
},
|
||||
cache: false
|
||||
},
|
||||
width: '100%'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reimposta i contenuti di un <select> creato con select2.
|
||||
*/
|
||||
jQuery.fn.selectClear = function () {
|
||||
this.val([]).trigger("change");
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Resetta i contenuti di un <select> creato con select2.
|
||||
*/
|
||||
jQuery.fn.selectReset = function (placeholder) {
|
||||
this.selectClear();
|
||||
this.empty();
|
||||
|
||||
if (placeholder != undefined) {
|
||||
this.next().find('.select2-selection__placeholder').text(placeholder);
|
||||
this.next().find('input.select2-search__field').attr('placeholder', placeholder);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Aggiorna un <select> creato con select2 impostando un valore di default.
|
||||
* Da utilizzare per l'impostazione dei select basati su richieste AJAX.
|
||||
*/
|
||||
jQuery.fn.selectSetNew = function (value, label) {
|
||||
this.selectReset();
|
||||
|
||||
this.selectAdd([{
|
||||
'value': value,
|
||||
'text': label,
|
||||
}]);
|
||||
|
||||
this.selectSet(value);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Aggiorna un <select> creato con select2 impostando un valore di default.
|
||||
* Da utilizzare per l'impostazione dei select statici.
|
||||
*/
|
||||
jQuery.fn.selectSet = function (value) {
|
||||
this.val(value).trigger("change");
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Aggiorna un <select> creato con select2 impostando un valore di default
|
||||
*/
|
||||
jQuery.fn.selectAdd = function (values) {
|
||||
$this = this;
|
||||
|
||||
values.forEach(function (item, index, array) {
|
||||
var option = $('<option/>', item);
|
||||
|
||||
$this.append(option);
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Restituisce l'oggetto contenente gli attributi di una <option> generata da select2.
|
||||
*/
|
||||
jQuery.fn.selectData = function () {
|
||||
var obj = $(this[0]);
|
||||
|
||||
$select_obj = obj.select2('data');
|
||||
|
||||
if ($select_obj[0] == undefined) {
|
||||
return undefined;
|
||||
} else {
|
||||
if ($select_obj[0].selected == false) {
|
||||
return $select_obj[0];
|
||||
} else {
|
||||
return $select_obj[0].element.dataset;
|
||||
}
|
||||
}
|
||||
};
|
51
assets/src/js/navigation.js
Normal file
51
assets/src/js/navigation.js
Normal file
@ -0,0 +1,51 @@
|
||||
$(document).ready(function () {
|
||||
// Tabs
|
||||
$('.nav-tabs').tabs();
|
||||
|
||||
// Entra nel tab indicato al caricamento della pagina
|
||||
var hash = location.hash ? location.hash : getUrlVars().hash;
|
||||
if (hash && hash != '#tab_0') {
|
||||
$('ul.nav-tabs a[href="' + hash + '"]').tab('show').trigger('shown.bs.tab');
|
||||
} else {
|
||||
removeHash();
|
||||
}
|
||||
|
||||
$(window).bind('beforeunload', function(){
|
||||
if (location.hash == '#tab_0') {
|
||||
removeHash();
|
||||
}
|
||||
});
|
||||
|
||||
// Nel caso la navigazione sia da mobile, disabilito il ritorno al punto precedente
|
||||
if (!globals.is_mobile) {
|
||||
// Salvo lo scroll per riportare qui l'utente al reload
|
||||
$(window).on('scroll', function () {
|
||||
if (sessionStorage != undefined) {
|
||||
sessionStorage.setItem('scrollTop_' + globals.id_module + '_' + globals.id_record, $(document).scrollTop());
|
||||
}
|
||||
});
|
||||
|
||||
// Riporto l'utente allo scroll precedente
|
||||
if (sessionStorage['scrollTop_' + globals.id_module + '_' + globals.id_record] != undefined) {
|
||||
setTimeout(function () {
|
||||
scrollToAndFocus(sessionStorage['scrollTop_' + globals.id_module + '_' + globals.id_record]);
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
|
||||
$('.nav-tabs a').click(function (e) {
|
||||
$(this).tab('show');
|
||||
|
||||
var scrollmem = $('body').scrollTop() || $('html').scrollTop();
|
||||
|
||||
window.location.hash = this.hash;
|
||||
|
||||
$('html,body').scrollTop(scrollmem);
|
||||
});
|
||||
|
||||
// Fix per la visualizzazione di Datatables all'interno dei tab Bootstrap
|
||||
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||
$($.fn.dataTable.tables(true)).DataTable().columns.adjust();
|
||||
$($.fn.dataTable.tables(true)).DataTable().scroller.measure();
|
||||
});
|
||||
});
|
47
assets/src/js/sidebar.js
Normal file
47
assets/src/js/sidebar.js
Normal file
@ -0,0 +1,47 @@
|
||||
$(document).ready(function () {
|
||||
// Fix per il menu principale
|
||||
$('.sidebar-menu').tree({
|
||||
followLink: true,
|
||||
});
|
||||
|
||||
$('.sidebar-menu > li.treeview i.fa-angle-left').click(function (e) {
|
||||
e.preventDefault();
|
||||
$(this).find('ul').stop().slideDown();
|
||||
});
|
||||
|
||||
$('.sidebar-menu > li.treeview i.fa-angle-down').click(function (e) {
|
||||
e.preventDefault();
|
||||
$(this).find('ul').stop().slideUp();
|
||||
});
|
||||
|
||||
$menulist = $('.treeview-menu > li.active');
|
||||
for (i = 0; i < $menulist.length; i++) {
|
||||
$list = $($menulist[i]);
|
||||
$list.parent().show().parent().addClass('active');
|
||||
$list.parent().parent().find('i.fa-angle-left').removeClass('fa-angle-left').addClass('fa-angle-down');
|
||||
}
|
||||
|
||||
// Menu ordinabile
|
||||
$(".sidebar-menu").sortable({
|
||||
cursor: 'move',
|
||||
|
||||
stop: function (event, ui) {
|
||||
var order = $(this).sortable('toArray').toString();
|
||||
|
||||
$.post(globals.rootdir + "/actions.php?id_module=" + globals.order_manager_id, {
|
||||
op: 'sort_modules',
|
||||
ids: order
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (globals.is_mobile) {
|
||||
$(".sidebar-menu").sortable("disable");
|
||||
}
|
||||
|
||||
$(".sidebar-toggle").click(function(){
|
||||
setTimeout(function(){
|
||||
window.dispatchEvent(new Event('resize'));
|
||||
}, 350);
|
||||
});
|
||||
});
|
47
assets/src/js/slider.js
Normal file
47
assets/src/js/slider.js
Normal file
@ -0,0 +1,47 @@
|
||||
$(document).ready(function () {
|
||||
// Pulsante per il ritorno a inizio pagina
|
||||
var slideToTop = $("<div />");
|
||||
slideToTop.html('<i class="fa fa-chevron-up"></i>');
|
||||
slideToTop.css({
|
||||
position: 'fixed',
|
||||
bottom: '20px',
|
||||
right: '25px',
|
||||
width: '40px',
|
||||
height: '40px',
|
||||
color: '#eee',
|
||||
'font-size': '',
|
||||
'line-height': '40px',
|
||||
'text-align': 'center',
|
||||
'background-color': 'rgba(255, 78, 0)',
|
||||
'box-shadow': '0 0 10px rgba(0, 0, 0, 0.05)',
|
||||
cursor: 'pointer',
|
||||
'z-index': '99999',
|
||||
opacity: '.7',
|
||||
'display': 'none'
|
||||
});
|
||||
|
||||
slideToTop.on('mouseenter', function () {
|
||||
$(this).css('opacity', '1');
|
||||
});
|
||||
|
||||
slideToTop.on('mouseout', function () {
|
||||
$(this).css('opacity', '.7');
|
||||
});
|
||||
|
||||
$('.wrapper').append(slideToTop);
|
||||
$(window).scroll(function () {
|
||||
if ($(window).scrollTop() >= 150) {
|
||||
if (!$(slideToTop).is(':visible')) {
|
||||
$(slideToTop).fadeIn(500);
|
||||
}
|
||||
} else {
|
||||
$(slideToTop).fadeOut(500);
|
||||
}
|
||||
});
|
||||
|
||||
$(slideToTop).click(function () {
|
||||
$("html, body").animate({
|
||||
scrollTop: 0
|
||||
}, 500);
|
||||
});
|
||||
});
|
33
assets/src/js/widgets.js
Normal file
33
assets/src/js/widgets.js
Normal file
@ -0,0 +1,33 @@
|
||||
$(document).ready(function () {
|
||||
$("#widget-top, #widget-right").sortable({
|
||||
items: 'li',
|
||||
cursor: 'move',
|
||||
dropOnEmpty: true,
|
||||
connectWith: '.widget',
|
||||
scroll: true,
|
||||
helper: 'clone',
|
||||
start: function (event, ui) {
|
||||
// Salvo la lista da cui proviene il drag
|
||||
src_list = ($(this).attr('id')).replace('widget-', '');
|
||||
|
||||
// Evidenzio le aree dei widget
|
||||
$('.widget').addClass('bordered').sortable('refreshPositions');
|
||||
},
|
||||
stop: function (event, ui) {
|
||||
// Rimuovo l'evidenziazione dell'area widget
|
||||
$('.widget').removeClass('bordered');
|
||||
|
||||
// Salvo la lista su cui ho eseguito il drop
|
||||
dst_list = (ui.item.parent().attr('id')).replace('widget-', '');
|
||||
|
||||
var order = $(this).sortable('toArray').toString();
|
||||
$.post(globals.rootdir + "/actions.php?id_module=" + globals.order_manager_id, {
|
||||
op: 'sort_widgets',
|
||||
location: dst_list,
|
||||
ids: order,
|
||||
id_module_widget: globals.id_module,
|
||||
id_record: globals.id_record,
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
19
editor.php
19
editor.php
@ -250,17 +250,10 @@ if (empty($record) || !$has_access) {
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
cleanup_inputs();
|
||||
|
||||
var form = $("#module-edit").find("form").first();
|
||||
|
||||
// Rimozione select inizializzati
|
||||
$("#custom_fields_bottom-edit").find("select").each(function () {
|
||||
$(this).select2().select2("destroy");
|
||||
});
|
||||
|
||||
$("#custom_fields_bottom-edit").find("select").each(function () {
|
||||
$(this).select2().select2("destroy");
|
||||
});
|
||||
|
||||
|
||||
// Campi a inizio form
|
||||
form.prepend($("#custom_fields_top-edit").html());
|
||||
|
||||
@ -274,11 +267,9 @@ if (empty($record) || !$has_access) {
|
||||
if (!last.length) {
|
||||
last = form.find(".row").eq(-2);
|
||||
}
|
||||
|
||||
last.after($("#custom_fields_bottom-edit").html());
|
||||
|
||||
start_superselect();
|
||||
start_datepickers();
|
||||
last.after($("#custom_fields_bottom-edit").html());
|
||||
restart_inputs();
|
||||
});
|
||||
</script>';
|
||||
|
||||
|
@ -65,6 +65,13 @@ gulp.task('srcJS', function () {
|
||||
.pipe(concat('custom.min.js'))
|
||||
.pipe(minifyJS())
|
||||
.pipe(gulp.dest(config.production + '/' + config.paths.js));
|
||||
|
||||
gulp.src([
|
||||
config.development + '/' + config.paths.js + '/functions/*.js',
|
||||
])
|
||||
.pipe(concat('functions.min.js'))
|
||||
.pipe(minifyJS())
|
||||
.pipe(gulp.dest(config.production + '/' + config.paths.js));
|
||||
});
|
||||
|
||||
|
||||
|
@ -30,4 +30,4 @@ echo '
|
||||
</form>';
|
||||
|
||||
echo '
|
||||
<script src="'.ROOTDIR.'/lib/init.js"></script>';
|
||||
<script>$(document).ready(init)</script>';
|
||||
|
@ -277,7 +277,7 @@ echo '
|
||||
</form>';
|
||||
|
||||
echo '
|
||||
<script src="'.ROOTDIR.'/lib/init.js"></script>';
|
||||
<script>$(document).ready(init)</script>';
|
||||
|
||||
?>
|
||||
|
||||
|
@ -234,7 +234,7 @@ echo '
|
||||
});
|
||||
</script>
|
||||
<script src="'.$rootdir.'/lib/functions.js"></script>
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>';
|
||||
<<script>$(document).ready(init)</script>';
|
||||
|
||||
include_once App::filepath('include|custom|', 'bottom.php');
|
||||
|
||||
|
@ -122,6 +122,8 @@ if (Auth::check()) {
|
||||
|
||||
id_module: "'.$id_module.'",
|
||||
id_record: "'.$id_record.'",
|
||||
|
||||
is_mobile: '.isMobile().',
|
||||
|
||||
cifre_decimali: '.setting('Cifre decimali per importi').',
|
||||
|
||||
@ -317,7 +319,6 @@ if (Auth::check()) {
|
||||
</div>
|
||||
|
||||
</nav>
|
||||
|
||||
</header>
|
||||
|
||||
<aside class="main-sidebar">
|
||||
|
1804
lib/functions.js
1804
lib/functions.js
File diff suppressed because it is too large
Load Diff
8
mail.php
8
mail.php
@ -166,8 +166,8 @@ echo '
|
||||
function aggiungi_destinatario(){
|
||||
var last = $("#lista-destinatari input").last();
|
||||
|
||||
if(last.val()){
|
||||
$("#destinatari_input").find(".select2").remove()
|
||||
if (last.val()) {
|
||||
cleanup_inputs();
|
||||
|
||||
$("#lista-destinatari").append($("#destinatari_input").html());
|
||||
|
||||
@ -175,10 +175,10 @@ echo '
|
||||
$(this).autocomplete({source: emails});
|
||||
});
|
||||
|
||||
start_superselect();
|
||||
restart_inputs();
|
||||
}
|
||||
}
|
||||
</script>';
|
||||
|
||||
echo '
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>';
|
||||
<script>$(document).ready(init)</script>';
|
||||
|
@ -32,7 +32,7 @@ echo '
|
||||
|
||||
</form>';
|
||||
|
||||
echo '<script src="'.$rootdir.'/lib/init.js"></script>';
|
||||
echo '<<script>$(document).ready(init)</script>';
|
||||
echo '<link rel="stylesheet" type="text/css" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css">';
|
||||
|
||||
?>
|
||||
|
@ -44,7 +44,7 @@ echo '
|
||||
|
||||
$file = basename(__FILE__);
|
||||
echo '
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>
|
||||
<<script>$(document).ready(init)</script>
|
||||
|
||||
<script>
|
||||
var content = $("#righe_documento");
|
||||
|
@ -47,7 +47,7 @@ echo '
|
||||
|
||||
$file = basename(__FILE__);
|
||||
echo '
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>
|
||||
<<script>$(document).ready(init)</script>
|
||||
|
||||
<script>
|
||||
var content = $("#righe_documento");
|
||||
|
@ -45,7 +45,7 @@ echo '
|
||||
|
||||
$file = basename(__FILE__);
|
||||
echo '
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>
|
||||
<<script>$(document).ready(init)</script>
|
||||
|
||||
<script>
|
||||
var content = $("#righe_documento");
|
||||
|
@ -125,4 +125,4 @@ echo '
|
||||
</form>';
|
||||
|
||||
echo '
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>';
|
||||
<script>$(document).ready(init)</script>';
|
||||
|
@ -45,7 +45,7 @@ echo '
|
||||
|
||||
$file = basename(__FILE__);
|
||||
echo '
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>
|
||||
<<script>$(document).ready(init)</script>
|
||||
|
||||
<script>
|
||||
var content = $("#righe_documento");
|
||||
|
@ -46,7 +46,7 @@ echo '
|
||||
|
||||
$file = basename(__FILE__);
|
||||
echo '
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>
|
||||
<<script>$(document).ready(init)</script>
|
||||
|
||||
<script>
|
||||
var content = $("#righe_documento");
|
||||
|
@ -145,4 +145,4 @@ echo '
|
||||
</form>';
|
||||
|
||||
echo '
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>';
|
||||
<script>$(document).ready(init)</script>';
|
||||
|
@ -146,7 +146,8 @@ echo '
|
||||
echo '
|
||||
<script>
|
||||
function add_blocco(btn, nome){
|
||||
$("#template .superselect, #template .superselectajax").select2().select2("destroy");
|
||||
cleanup_inputs();
|
||||
|
||||
var last = $(btn).closest("table").find("tr[id^=last-" + nome + "]").parent().last();
|
||||
|
||||
keys[nome]++;
|
||||
@ -155,13 +156,12 @@ function add_blocco(btn, nome){
|
||||
ref_keys[nome + keys[nome]] = 1;
|
||||
|
||||
last.after(text);
|
||||
|
||||
start_superselect();
|
||||
start_datepickers();
|
||||
restart_inputs();
|
||||
}
|
||||
|
||||
function add_riferimento(btn, nome, key) {
|
||||
$("#template .superselect, #template .superselectajax").select2().select2("destroy");
|
||||
cleanup_inputs();
|
||||
|
||||
var last = $(btn).closest("table").find("tr[title=RiferimentoNumeroLinea-" + nome + "-" + key + "]").last();
|
||||
|
||||
ref_keys[nome + key]++;
|
||||
@ -169,10 +169,8 @@ function add_riferimento(btn, nome, key) {
|
||||
text = replaceAll(text, "-num-", "" + ref_keys[nome + key]);
|
||||
|
||||
last.after(text);
|
||||
|
||||
start_superselect();
|
||||
start_datepickers();
|
||||
restart_inputs();
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="'.ROOTDIR.'/lib/init.js"></script>';
|
||||
<script>$(document).ready(init)</script>';
|
||||
|
@ -119,15 +119,15 @@ echo '
|
||||
<script>
|
||||
var n = '.($key - 1).';
|
||||
function add_altri_dati(btn){
|
||||
$("#template .superselect, #template .superselectajax").select2().select2("destroy");
|
||||
cleanup_inputs();
|
||||
|
||||
var last = $(btn).closest("table").find("tr[id^=last-altri_dati]").parent().last();
|
||||
|
||||
n++;
|
||||
var text = replaceAll($("#altri_dati-templace").html(), "-id-", "" + n);
|
||||
|
||||
last.after(text);
|
||||
|
||||
start_superselect();
|
||||
restart_inputs();
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -154,4 +154,4 @@ echo '
|
||||
</form>';
|
||||
|
||||
echo '
|
||||
<script src="'.ROOTDIR.'/lib/init.js"></script>';
|
||||
<script>$(document).ready(init)</script>';
|
||||
|
@ -230,7 +230,7 @@ if (!empty($id_intervento)) {
|
||||
<div class="col-md-3">
|
||||
{[ "type": "timestamp", "label": "<?php echo tr('Data/ora richiesta'); ?>", "name": "data_richiesta", "required": 1, "value": "<?php echo $data_richiesta ?: '-now-'; ?>" ]}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-3">
|
||||
{[ "type": "timestamp", "label": "<?php echo tr('Data/ora scadenza'); ?>", "name": "data_scadenza", "required": 0, "value": "<?php echo $data_scadenza; ?>" ]}
|
||||
</div>
|
||||
@ -292,7 +292,7 @@ if (!empty($id_intervento)) {
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script src="<?php echo $rootdir; ?>/lib/init.js"></script>
|
||||
<script>$(document).ready(init)</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
|
@ -209,7 +209,7 @@ echo '
|
||||
</form>';
|
||||
|
||||
echo '
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>';
|
||||
<script>$(document).ready(init)</script>';
|
||||
|
||||
?>
|
||||
|
||||
|
@ -109,7 +109,7 @@ echo '
|
||||
</form>';
|
||||
|
||||
echo '
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>';
|
||||
<<script>$(document).ready(init)</script>';
|
||||
|
||||
?>
|
||||
|
||||
|
@ -133,4 +133,4 @@ if ($show_prezzi) {
|
||||
}
|
||||
|
||||
echo '
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>';
|
||||
<<script>$(document).ready(init)</script>';
|
||||
|
@ -221,7 +221,7 @@ if (!$is_completato) {
|
||||
}
|
||||
|
||||
echo '
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>
|
||||
<<script>$(document).ready(init)</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){';
|
||||
|
@ -96,7 +96,7 @@ echo '
|
||||
</form>';
|
||||
|
||||
echo '
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>';
|
||||
<<script>$(document).ready(init)</script>';
|
||||
|
||||
echo '
|
||||
<script>
|
||||
|
@ -175,11 +175,11 @@ echo '
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$(document).on('click', '#add', function(){
|
||||
$("#template .superselect, #template_filter .superselectajax").select2().select2("destroy");
|
||||
cleanup_inputs();
|
||||
|
||||
$(this).parent().parent().find('.data').append($('#template').html());
|
||||
$(this).parent().parent().find('.data').append($('#template').html());
|
||||
|
||||
start_superselect();
|
||||
restart_inputs();
|
||||
});
|
||||
|
||||
$(document).on('change', '[id*=scadenza]', function(){
|
||||
|
@ -156,7 +156,7 @@ echo '
|
||||
<div class='pull-right'>
|
||||
<a onclick="launch_modal( 'Registra contabile pagamento', '<?php echo $rootdir; ?>/add.php?id_module=<?php echo Modules::get('Prima nota')['id']; ?>&dir=<?php echo $dir; ?>&id_scadenze=<?php echo $id_record; ?>', 1 );" class="btn btn-sm btn-primary"><i class="fa fa-euro"></i> <?php echo tr('Registra contabile pagamento...'); ?></a>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="clearfix"></div>
|
||||
|
||||
<div class="alert alert-error hide" id="totale"><?php echo tr('Il totale da pagare deve essere pari a _MONEY_', [
|
||||
@ -213,11 +213,13 @@ echo '
|
||||
<script>
|
||||
var i = '.$i.';
|
||||
$(document).on("click", "#add-scadenza", function(){
|
||||
i++;
|
||||
cleanup_inputs();
|
||||
|
||||
i++;
|
||||
var text = replaceAll($("#scadenza-template").html(), "-id-", "" + i);
|
||||
|
||||
$("#scadenze").append(text);
|
||||
start_datepickers();
|
||||
restart_inputs();
|
||||
});
|
||||
</script>';
|
||||
|
||||
@ -225,10 +227,10 @@ echo '
|
||||
|
||||
<script>
|
||||
globals.cifre_decimali = 2;
|
||||
|
||||
|
||||
$(document).ready(function(){
|
||||
controlloTotale();
|
||||
|
||||
|
||||
<?php
|
||||
if ($dir == 'uscita') {
|
||||
echo '
|
||||
|
@ -31,36 +31,7 @@ function add_calendar() {
|
||||
<br>
|
||||
</div>`);
|
||||
|
||||
// Calendario principale
|
||||
ranges = {};
|
||||
ranges[globals.translations.today] = [moment(), moment()];
|
||||
ranges[globals.translations.firstThreemester] = [moment("01", "MM"), moment("03", "MM").endOf('month')];
|
||||
ranges[globals.translations.secondThreemester] = [moment("04", "MM"), moment("06", "MM").endOf('month')];
|
||||
ranges[globals.translations.thirdThreemester] = [moment("07", "MM"), moment("09", "MM").endOf('month')];
|
||||
ranges[globals.translations.fourthThreemester] = [moment("10", "MM"), moment("12", "MM").endOf('month')];
|
||||
ranges[globals.translations.firstSemester] = [moment("01", "MM"), moment("06", "MM").endOf('month')];
|
||||
ranges[globals.translations.secondSemester] = [moment("06", "MM"), moment("12", "MM").endOf('month')];
|
||||
ranges[globals.translations.thisMonth] = [moment().startOf('month'), moment().endOf('month')];
|
||||
ranges[globals.translations.lastMonth] = [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')];
|
||||
ranges[globals.translations.thisYear] = [moment().startOf('year'), moment().endOf('year')];
|
||||
ranges[globals.translations.lastYear] = [moment().subtract(1, 'year').startOf('year'), moment().subtract(1, 'year').endOf('year')];
|
||||
|
||||
|
||||
$("#" + name).daterangepicker({
|
||||
locale: {
|
||||
customRangeLabel: globals.translations.custom,
|
||||
applyLabel: globals.translations.apply,
|
||||
cancelLabel: globals.translations.cancel,
|
||||
fromLabel: globals.translations.from,
|
||||
toLabel: globals.translations.to,
|
||||
},
|
||||
startDate: globals.start_date_formatted,
|
||||
endDate: globals.end_date_formatted,
|
||||
applyClass: "btn btn-success btn-sm",
|
||||
cancelClass: "btn btn-danger btn-sm",
|
||||
ranges: ranges,
|
||||
linkedCalendars: false
|
||||
}, function (start, end) {
|
||||
start_complete_calendar("#" + name, function (start, end) {
|
||||
var name = $(this.element).attr("id");
|
||||
var start = start.format("YYYY-MM-DD");
|
||||
var end = end.format("YYYY-MM-DD");
|
||||
|
@ -101,7 +101,7 @@ switch (filter('op')) {
|
||||
break;
|
||||
|
||||
// Ordinamento moduli di primo livello
|
||||
case 'sortmodules':
|
||||
case 'sort_modules':
|
||||
$rs = $dbo->fetchArray('SELECT id FROM zz_modules WHERE enabled = 1 AND parent IS NULL ORDER BY `order` ASC');
|
||||
|
||||
if ($_POST['ids'] != implode(',', array_column($rs, 'id'))) {
|
||||
@ -116,12 +116,13 @@ switch (filter('op')) {
|
||||
|
||||
break;
|
||||
|
||||
case 'sortwidget':
|
||||
case 'sort_widgets':
|
||||
$location = post('location');
|
||||
$id_module_widget = post('id_module_widget');
|
||||
|
||||
$location = empty($id_record) ? 'controller_'.$location : 'editor_'.$location;
|
||||
|
||||
$rs = $dbo->fetchArray("SELECT CONCAT('widget_', id) AS id FROM zz_widgets WHERE enabled = 1 AND location = ".prepare($location).' AND id_module = '.prepare($id_module).' ORDER BY `order` ASC');
|
||||
$rs = $dbo->fetchArray("SELECT CONCAT('widget_', id) AS id FROM zz_widgets WHERE enabled = 1 AND location = ".prepare($location).' AND id_module = '.prepare($id_module_widget).' ORDER BY `order` ASC');
|
||||
|
||||
if ($_POST['ids'] != implode(',', array_column($rs, 'id'))) {
|
||||
$ids = explode(',', $_POST['ids']);
|
||||
@ -135,19 +136,6 @@ switch (filter('op')) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'updatewidget':
|
||||
$location = post('location');
|
||||
$class = post('class');
|
||||
$id = explode('_', post('id'));
|
||||
|
||||
$location = empty($id_record) ? 'controller_'.$location : 'editor_'.$location;
|
||||
|
||||
if (!empty($class)) {
|
||||
$dbo->query('UPDATE zz_widgets SET class='.prepare($class).' WHERE id='.prepare($id[1]));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'sizes':
|
||||
$results = [];
|
||||
|
||||
|
@ -28,4 +28,4 @@ echo '
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>';
|
||||
<<script>$(document).ready(init)</script>';
|
||||
|
@ -91,4 +91,4 @@ function submitCheck() {
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>';
|
||||
<<script>$(document).ready(init)</script>';
|
||||
|
@ -208,17 +208,19 @@ echo '
|
||||
<script>
|
||||
var n = '.$key.';
|
||||
$(document).on("click", "#add", function(){
|
||||
$("#template .superselect, #template .superselectajax").select2().select2("destroy");
|
||||
cleanup_inputs();
|
||||
|
||||
n++;
|
||||
var text = replaceAll($("#template").html(), "-id-", "" + n);
|
||||
|
||||
$(this).parent().parent().parent().find(".data").append(text);
|
||||
start_superselect();
|
||||
restart_inputs();
|
||||
});
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#save").addClass("hide");
|
||||
|
||||
$( ".sortable" ).disableSelection();
|
||||
$(".sortable" ).disableSelection();
|
||||
$(".sortable").each(function() {
|
||||
$(this).sortable({
|
||||
axis: "y",
|
||||
|
@ -119,10 +119,12 @@ echo '
|
||||
<script>
|
||||
var i = '.$num.';
|
||||
$(document).on("click", "#add_filter", function(){
|
||||
$("#template_filter .superselect, #template_filter .superselectajax").select2().select2("destroy");
|
||||
cleanup_inputs();
|
||||
|
||||
i++;
|
||||
var text = replaceAll($("#template_filter").html(), "-id-", "" + i);
|
||||
$(this).parent().parent().parent().find(".data").append(text);
|
||||
start_superselect();
|
||||
|
||||
restart_inputs();
|
||||
});
|
||||
</script>';
|
||||
|
@ -170,7 +170,7 @@ echo '
|
||||
</form>';
|
||||
|
||||
echo '
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>';
|
||||
<script>$(document).ready(init)</script>';
|
||||
|
||||
echo '
|
||||
<script type="text/javascript">
|
||||
|
@ -107,7 +107,7 @@ echo '
|
||||
</form>';
|
||||
|
||||
echo '
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>';
|
||||
<<script>$(document).ready(init)</script>';
|
||||
|
||||
echo '
|
||||
<script type="text/javascript">
|
||||
|
@ -233,7 +233,7 @@ echo '
|
||||
</form>';
|
||||
|
||||
echo '
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>';
|
||||
<<script>$(document).ready(init)</script>';
|
||||
|
||||
echo '
|
||||
<script>
|
||||
|
@ -35,6 +35,7 @@ class App
|
||||
// JS
|
||||
'js' => [
|
||||
'app.min.js',
|
||||
'functions.min.js',
|
||||
'custom.min.js',
|
||||
'i18n/parsleyjs/|lang|.min.js',
|
||||
'i18n/select2/|lang|.min.js',
|
||||
@ -190,10 +191,10 @@ class App
|
||||
}
|
||||
|
||||
// JS aggiuntivi per gli utenti connessi
|
||||
if (Auth::check()) {
|
||||
$assets['js'][] = ROOTDIR.'/lib/functions.js';
|
||||
$assets['js'][] = ROOTDIR.'/lib/init.js';
|
||||
}
|
||||
//if (Auth::check()) {
|
||||
//$assets['js'][] = ROOTDIR.'/lib/functions.js';
|
||||
//$assets['js'][] = ROOTDIR.'/lib/init.js';
|
||||
//}
|
||||
|
||||
return $assets;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class ChecklistManager implements ManagerInterface
|
||||
|
||||
$list = [];
|
||||
foreach ($checklists as $checklist) {
|
||||
$list [] = [
|
||||
$list[] = [
|
||||
'id' => $checklist->id,
|
||||
'text' => $checklist->content,
|
||||
];
|
||||
@ -87,7 +87,7 @@ class ChecklistManager implements ManagerInterface
|
||||
</div>';
|
||||
|
||||
$result .= '
|
||||
<script src="'.ROOTDIR.'/lib/init.js"></script>
|
||||
<script>$(document).ready(init)</script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
@ -175,7 +175,7 @@ class FileManager implements ManagerInterface
|
||||
$source = array_clean(array_column($categories, 'category'));
|
||||
|
||||
$result .= '
|
||||
<script src="'.ROOTDIR.'/lib/init.js"></script>
|
||||
<script>$(document).ready(init)</script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user