This commit is contained in:
MatteoPistorello 2020-10-06 12:29:14 +02:00
parent f9aa58955f
commit f5e5ee1ce9
19 changed files with 446 additions and 297 deletions

View File

@ -16,8 +16,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
function start_datepickers() {
var icons = {
function getCalendarIcons(){
return {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
@ -28,64 +28,79 @@ function start_datepickers() {
clear: 'fa fa-trash',
close: 'fa fa-times'
};
}
var date_format = dateFormatMoment(globals.date_format);
var timestamp_format = dateFormatMoment(globals.timestamp_format);
var time_format = dateFormatMoment(globals.time_format);
function initDateInput(input) {
let date_format = dateFormatMoment(globals.date_format);
let calendar_icons = getCalendarIcons();
$('.timestamp-picker').each(function () {
$this = $(this);
$this.datetimepicker({
format: timestamp_format,
locale: globals.locale,
icons: icons,
collapse: false,
sideBySide: true,
useCurrent: false,
stepping: 5,
widgetPositioning: {
horizontal: 'left',
vertical: 'auto'
},
minDate: moment($this.attr('min-date')).isValid() ? $this.attr('min-date') : false,
maxDate: moment($this.attr('max-date')).isValid() ? $this.attr('max-date') : false,
});
$(input).datetimepicker({
format: date_format,
locale: globals.locale,
icons: calendar_icons,
useCurrent: false,
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 initTimestampInput(input) {
let $this = $(input);
let timestamp_format = dateFormatMoment(globals.timestamp_format);
let calendar_icons = getCalendarIcons();
$this.datetimepicker({
format: timestamp_format,
locale: globals.locale,
icons: calendar_icons,
collapse: false,
sideBySide: true,
useCurrent: false,
stepping: 5,
widgetPositioning: {
horizontal: 'left',
vertical: 'auto'
},
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
// fix per timestamp-picker non visibile con la classe table-responsive
$this.on("dp.show", function (e) {
$('#tecnici > div').removeClass('table-responsive');
});
$this.on("dp.hide", function (e) {
$('#tecnici > div').addClass('table-responsive');
})
}
function initTimeInput(input) {
let time_format = dateFormatMoment(globals.time_format);
let calendar_icons = getCalendarIcons();
$(input).datetimepicker({
format: time_format,
locale: globals.locale,
icons: calendar_icons,
useCurrent: false,
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_datepickers() {
$('.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');
})
initTimestampInput(this);
});
$('.datepicker').each(function () {
$this = $(this);
$this.datetimepicker({
format: date_format,
locale: globals.locale,
icons: icons,
useCurrent: false,
minDate: moment($this.attr('min-date')).isValid() ? $this.attr('min-date') : false,
maxDate: moment($this.attr('max-date')).isValid() ? $this.attr('max-date') : false,
});
initDateInput(this);
});
$('.timepicker').each(function () {
$this = $(this);
$this.datetimepicker({
format: time_format,
locale: globals.locale,
icons: icons,
useCurrent: false,
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,
});
initTimeInput(this);
});
}

View File

@ -515,7 +515,7 @@ function restart_inputs() {
start_superselect();
// Autosize per le textarea
autosize($('.autosize'));
initTextareaInput($('.autosize'));
}
/**
@ -552,7 +552,7 @@ function alertPush() {
}
/**
*
*
* @param button
* @param form
* @param data
@ -648,3 +648,7 @@ function hideTableColumn(table, column) {
}
}
}
function initTextareaInput(input){
autosize($(input));
}

View File

@ -17,21 +17,79 @@
*/
function input(name) {
return new Input(name);
let element;
// Selezione tramite jQuery
if (name instanceof jQuery) {
element = name.last();
}
// Selezione tramite JS diretto
else if (isElement(name)) {
element = $(name);
}
// Selezione per nome
else {
element = $("[name='" + name + "']").last();
// Fix per select multipli
if (element.length === 0) {
element = $("[name='" + name + "[]']").last();
}
}
if (!element.data("input-controller")) {
return new Input(element);
} else {
return element.data("input-controller");
}
}
function Input(name) {
this.element = $("[name='" + name + "']").last();
// Fix per select multipli
if (this.element.length === 0) {
this.element = $("[name='" + name + "[]']").last();
}
/**
*
* @constructor
* @param {jQuery} element
*/
function Input(element) {
this.element = element;
// Controllo sulla gestione precedente
if (!this.element.data("input-set")) {
this.element.data("input-set", 1);
this.element.data("required", this.element.attr("required"));
return;
}
this.element.data("input-set", 1);
this.element.data("required", this.element.attr("required"));
// Operazioni di inizializzazione per input specifici
// Inizializzazione per date
if (this.element.hasClass('timestamp-picker')) {
initTimestampInput(this.element);
} else if (this.element.hasClass('datepicker')) {
initDateInput(this.element);
} else if (this.element.hasClass('timepicker')) {
initTimeInput(this.element);
}
// Inizializzazione per campi numerici
else if (this.element.hasClass('decimal-number')) {
initNumberInput(this.element);
}
// Inizializzazione per textarea
else if (this.element.hasClass('autosize')) {
initTextareaInput(this.element);
}
// Inizializzazione per select
else if (this.element.hasClass('superselect') || this.element.hasClass('superselectajax')) {
initSelectInput(this.element);
}
// Inizializzazione alternativa per maschere
else {
initMaskInput(this.element);
}
}
@ -99,22 +157,46 @@ Input.prototype.getData = function () {
}
return {
value: this.element.val()
value: this.get()
};
}
/**
* Restituisce il valore corrente dell'input.
*
* @returns {string|number}
*/
Input.prototype.get = function () {
let value = this.element.val();
// Conversione del valore per le checkbox
let group = this.element.closest(".form-group");
if (group.find("input[type=checkbox]").length){
value = parseInt(value) ? 1 : 0;
if (group.find("input[type=checkbox]").length) {
return parseInt(value) ? 1 : 0;
}
// Gestione dei valori numerici
if (this.element.hasClass("decimal-number")) {
const autonumeric = this.element.data("autonumeric");
if (autonumeric) {
return parseFloat(autonumeric.rawValue);
}
// In attesa dell'inizializzazione per autonumeric, il valore registrato è interpretabile
else {
return parseFloat(value);
}
}
return value;
}
/**
* Imposta il valore per l'input.
*
* @param value
* @returns {Input}
*/
Input.prototype.set = function (value) {
this.element.val(value).trigger("change");
@ -140,3 +222,33 @@ Input.prototype.on = function (event, action) {
Input.prototype.off = function (event) {
return this.element.off(event);
}
/**
* Returns true if it is a DOM node.
*
* @param o
* @returns boolean
*
* @source https://stackoverflow.com/a/384380
*/
function isNode(o) {
return (
typeof Node === "object" ? o instanceof Node :
o && typeof o === "object" && typeof o.nodeType === "number" && typeof o.nodeName === "string"
);
}
/**
* Returns true if it is a DOM element.
*
* @param o
* @returns boolean
*
* @source https://stackoverflow.com/a/384380
*/
function isElement(o) {
return (
typeof HTMLElement === "object" ? o instanceof HTMLElement : // DOM2
o && typeof o === "object" && o.nodeType === 1 && typeof o.nodeName === "string"
);
}

View File

@ -16,82 +16,54 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// Inputmask
function initMaskInput(input) {
let $input = $(input);
if ($input.hasClass('bound')){
return;
}
$input.addClass('bound');
if ($input.hasClass('email-mask')){
$input.inputmask('Regex', {
regex: "^[a-zA-Z0-9_!#$%&'*+/=?`{|}~^-]+(?:\\.[a-zA-Z0-9_!#$%&'*+/=?`{|}~^-]+)*@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$",
});
} else if ($input.hasClass('rea-mask')){
$input.inputmask({
mask: "AA-999999{1,15}",
casing: "upper",
});
} else if ($input.hasClass('provincia-mask')){
$input.inputmask({
mask: "AA",
casing: "upper",
});
} else if ($input.hasClass('alphanumeric-mask')){
$input.inputmask('Regex', {
regex: "[A-Za-z0-9#_|\/\\-.]*",
});
} else if ($input.hasClass('math-mask')){
$input.inputmask('Regex', {
regex: "[0-9,.+\-]*",
});
}
}
/**
* Inputmask
* @param element
*/
function start_inputmask(element) {
if (element == undefined) {
if (element === undefined) {
element = '';
} else {
element = element + ' ';
}
var date = dateFormatMoment(globals.date_format).toLowerCase();
let masks = ['math-mask','alphanumeric-mask', 'provincia-mask','rea-mask', 'email-mask'];
$(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 + '.rea-mask').not('.bound').inputmask( {
mask: "AA-999999{1,15}",
casing: "upper",
}).addClass('bound');
$(element + '.provincia-mask').not('.bound').inputmask( {
mask: "AA",
casing: "upper",
}).addClass('bound');
$(element + '.alphanumeric-mask').not('.bound').inputmask('Regex', {
regex: "[A-Za-z0-9#_|\/\\-.]*",
}).addClass('bound');
$(element + '.math-mask').not('.bound').inputmask('Regex', {
regex: "[0-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');
}
let selector = element + '.' + masks.join(', ' + element + '.')
$(selector).each(function () {
initMaskInput(this);
});
}

View File

@ -23,37 +23,41 @@ function initNumbers() {
let inputs = $('.decimal-number').not('.bound');
for (const input of inputs) {
let $input = $(input);
initNumberInput(input);
if (AutoNumeric.isManagedByAutoNumeric(input)) {
continue;
}
let min = $input.attr('min-value') && $input.attr('min-value') !== "undefined" ? $input.attr('min-value') : null;
let max = $input.attr('max-value') && $input.attr('max-value') !== "undefined" ? $input.attr('max-value') : null;
let decimals = $input.attr('decimals') ? $input.attr('decimals') : globals.cifre_decimali;
let autonumeric = new AutoNumeric(input, {
caretPositionOnFocus: "decimalLeft",
allowDecimalPadding: true,
currencySymbolPlacement: "s",
negativePositiveSignPlacement: "p",
decimalCharacter: globals.decimals,
decimalCharacterAlternative: ".",
digitGroupSeparator: globals.thousands,
emptyInputBehavior: min ? min : "zero",
overrideMinMaxLimits: "ignore",
modifyValueOnWheel: false,
outputFormat: "string",
unformatOnSubmit: true,
watchExternalChanges: true,
minimumValue: min ? min : "-10000000000000",
maximumValue: max ? max : "10000000000000",
decimalPlaces: decimals,
});
$input.data("autonumeric", autonumeric)
.addClass('bound');
$(input).addClass('bound');
}
}
function initNumberInput(input){
let $input = $(input);
if (AutoNumeric.isManagedByAutoNumeric(input)) {
return;
}
let min = $input.attr('min-value') && $input.attr('min-value') !== "undefined" ? $input.attr('min-value') : null;
let max = $input.attr('max-value') && $input.attr('max-value') !== "undefined" ? $input.attr('max-value') : null;
let decimals = $input.attr('decimals') ? $input.attr('decimals') : globals.cifre_decimali;
let autonumeric = new AutoNumeric(input, {
caretPositionOnFocus: "decimalLeft",
allowDecimalPadding: true,
currencySymbolPlacement: "s",
negativePositiveSignPlacement: "p",
decimalCharacter: globals.decimals,
decimalCharacterAlternative: ".",
digitGroupSeparator: globals.thousands,
emptyInputBehavior: min ? min : "zero",
overrideMinMaxLimits: "ignore",
modifyValueOnWheel: false,
outputFormat: "string",
unformatOnSubmit: true,
watchExternalChanges: true,
minimumValue: min ? min : "-10000000000000",
maximumValue: max ? max : "10000000000000",
decimalPlaces: decimals,
});
$input.data("autonumeric", autonumeric);
}

View File

@ -16,87 +16,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// Select
/**
* Select.
*/
function start_superselect() {
// Statico
$('.superselect').each(function () {
let $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'),
escapeMarkup: function (text) {
return text;
},
templateResult: selectBackground,
});
});
// Dinamico (AJAX, per tabelle con molti record)
$('.superselectajax').each(function () {
let $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: selectBackground,
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,
options: this.data('select-options'), // Dati aggiuntivi
};
},
processResults: function (data, params) {
params.page = params.page || 0;
params.length = params.length || 100;
let results = data.results;
// Interpretazione forzata per campi optgroup
if (results && results[0] && [0]['optgroup']) {
let groups = results.reduce(function (r, a) {
r[a.optgroup] = r[a.optgroup] || [];
r[a.optgroup].push(a);
return r;
}, {});
let results_groups = [];
for (const key in groups) {
results_groups.push({
text: key,
children: groups[key],
});
}
results = results_groups;
}
return {
results: results,
pagination: {
more: (params.page + 1) * params.length < data.recordsFiltered,
}
};
},
cache: false
},
width: '100%'
});
$('.superselect, .superselectajax').each(function () {
initSelectInput(this);
});
}
@ -242,3 +167,99 @@ function updateSelectOption(name, value) {
$(this).setSelectOption(name, value);
})
}
function initSelectInput(input){
if ($(input).hasClass('superselect')){
initStaticSelectInput(input);
} else {
initDynamicSelectInput(input);
}
}
/**
* Statico.
* @param input
*/
function initStaticSelectInput(input){
let $input = $(input);
$input.select2({
theme: "bootstrap",
language: "it",
width: '100%',
maximumSelectionLength: $input.data('maximum') ? $input.data('maximum') : -1,
minimumResultsForSearch: $input.hasClass('no-search') ? -1 : 0,
allowClear: !$input.hasClass('no-search'),
escapeMarkup: function (text) {
return text;
},
templateResult: selectBackground,
});
}
/**
* Dinamico.
* @param input
*/
function initDynamicSelectInput(input){
let $input = $(input);
$input.select2({
theme: "bootstrap",
language: "it",
maximumSelectionLength: $input.data('maximum') ? $input.data('maximum') : -1,
minimumInputLength: $input.data('heavy') ? 3 : 0,
allowClear: true,
escapeMarkup: function (text) {
return text;
},
templateResult: selectBackground,
ajax: {
url: globals.rootdir + "/ajax_select.php?op=" + $input.data('source'),
dataType: 'json',
delay: 250,
data: function (params) {
return {
search: params.term,
page: params.page || 0,
length: params.length || 100,
options: this.data('select-options'), // Dati aggiuntivi
};
},
processResults: function (data, params) {
params.page = params.page || 0;
params.length = params.length || 100;
let results = data.results;
// Interpretazione forzata per campi optgroup
if (results && results[0] && [0]['optgroup']) {
let groups = results.reduce(function (r, a) {
r[a.optgroup] = r[a.optgroup] || [];
r[a.optgroup].push(a);
return r;
}, {});
let results_groups = [];
for (const key in groups) {
results_groups.push({
text: key,
children: groups[key],
});
}
results = results_groups;
}
return {
results: results,
pagination: {
more: (params.page + 1) * params.length < data.recordsFiltered,
}
};
},
cache: false
},
width: '100%'
});
}

View File

@ -130,9 +130,18 @@ switch (filter('op')) {
}
// Lettura dati intervento
$query = 'SELECT *, in_interventi.codice, idstatointervento AS parent_idstato, in_interventi.idtipointervento AS parent_idtipo, (SELECT GROUP_CONCAT(CONCAT(matricola, " - ", nome) SEPARATOR ", ") FROM my_impianti INNER JOIN my_impianti_interventi ON my_impianti.id=my_impianti_interventi.idimpianto WHERE my_impianti_interventi.idintervento='.prepare($id).' GROUP BY my_impianti_interventi.idintervento) AS impianti, (SELECT descrizione FROM in_statiintervento WHERE idstatointervento=parent_idstato) AS stato, (SELECT descrizione FROM in_tipiintervento WHERE idtipointervento=parent_idtipo) AS tipo, (SELECT nomesede FROM an_sedi WHERE id=idsede_destinazione) AS sede, (SELECT idzona FROM an_anagrafiche WHERE idanagrafica=in_interventi.idanagrafica) AS idzona FROM in_interventi LEFT JOIN in_interventi_tecnici ON in_interventi.id =in_interventi_tecnici.idintervento LEFT JOIN an_anagrafiche ON in_interventi.idanagrafica=an_anagrafiche.idanagrafica WHERE in_interventi.id='.prepare($id).' '.Modules::getAdditionalsQuery('Interventi');
$query = 'SELECT *, in_interventi.codice, idstatointervento AS parent_idstato, in_interventi.idtipointervento AS parent_idtipo, (SELECT GROUP_CONCAT(CONCAT(matricola, " - ", nome) SEPARATOR ", ") FROM my_impianti INNER JOIN my_impianti_interventi ON my_impianti.id=my_impianti_interventi.idimpianto WHERE my_impianti_interventi.idintervento='.prepare($id).' GROUP BY my_impianti_interventi.idintervento) AS impianti, (SELECT descrizione FROM in_statiintervento WHERE idstatointervento=parent_idstato) AS stato, (SELECT descrizione FROM in_tipiintervento WHERE idtipointervento=parent_idtipo) AS tipo, (SELECT idzona FROM an_anagrafiche WHERE idanagrafica=in_interventi.idanagrafica) AS idzona FROM in_interventi LEFT JOIN in_interventi_tecnici ON in_interventi.id =in_interventi_tecnici.idintervento LEFT JOIN an_anagrafiche ON in_interventi.idanagrafica=an_anagrafiche.idanagrafica WHERE in_interventi.id='.prepare($id).' '.Modules::getAdditionalsQuery('Interventi');
$rs = $dbo->fetchArray($query);
//correggo info indirizzo citta cap provincia con quelle della sede di destinazione
if (!empty($rs[0]['idsede_destinazione'])){
$sede = $database->fetchOne("SELECT * FROM an_sedi WHERE id = ".prepare($rs[0]['idsede_destinazione']));
$rs[0]['indirizzo'] = $sede['nomesede'].'<br>'.$sede['indirizzo'];
$rs[0]['cap'] = $sede['cap'];
$rs[0]['citta'] = $sede['citta'];
$rs[0]['provincia'] = $sede['provincia'];
}
$desc_tipointervento = $rs[0]['tipo'];
$tooltip = '<b>'.tr('Numero intervento').'</b>: '.$rs[0]['codice'].'<br/>';
@ -146,8 +155,8 @@ switch (filter('op')) {
$tooltip .= '<b>'.tr('Cellulare').'</b>: '.nl2br($rs[0]['cellulare']).'<br/>';
}
if (!empty($rs[0]['indirizzo']) || !empty($rs[0]['citta']) || !empty($rs[0]['provincia'])) {
$tooltip .= '<b>'.tr('Indirizzo').'</b>: '.nl2br($rs[0]['indirizzo'].' '.$rs[0]['citta'].' ('.$rs[0]['provincia'].')').'<br/>';
if (!empty($rs[0]['indirizzo']) || !empty($rs[0]['citta']) || !empty($rs[0]['provincia']) || !empty($rs[0]['cap'])) {
$tooltip .= '<b>'.tr('Indirizzo').'</b>: '.nl2br($rs[0]['indirizzo'].' - '.$rs[0]['cap'].' '.$rs[0]['citta'].' ('.$rs[0]['provincia'].')').'<br/>';
}
if (!empty($rs[0]['note'])) {

View File

@ -111,7 +111,7 @@ echo '
<div class="box-body">';
// Elenca i componenti disponibili
$componenti_disponibili = Ini::getList(base_dir().'/files/my_impianti/', $id_list);
$componenti_disponibili = Ini::getList(base_dir().'/files/impianti/', $id_list);
echo '
<div class="row">
<div class="col-md-9">

View File

@ -41,6 +41,8 @@ if (null == $orario_inizio || '00:00:00' == $orario_inizio) {
$id_tecnico = filter('id_tecnico');
if ($user['gruppo'] == 'Tecnici' && !empty($user['idanagrafica'])) {
$id_tecnico = $user['idanagrafica'];
}elseif ($user['gruppo'] == 'Clienti' && !empty($user['idanagrafica'])) {
$id_cliente = $user['idanagrafica'];
}
// Stato di default associato all'attivitò
@ -160,7 +162,7 @@ if (!empty($id_intervento)) {
echo '
<div class="row">
<div class="col-md-4">
{[ "type": "select", "label": "'.tr('Cliente').'", "name": "idanagrafica", "required": 1, "value": "'.$id_anagrafica.'", "ajax-source": "clienti", "icon-after": "add|'.$module_anagrafiche['id'].'|tipoanagrafica=Cliente&readonly_tipo=1", "readonly": "'.(empty($id_anagrafica) ? 0 : 1).'" ]}
{[ "type": "select", "label": "'.tr('Cliente').'", "name": "idanagrafica", "required": 1, "value": "'.(!$id_cliente ? $id_anagrafica : $id_cliente).'", "ajax-source": "clienti", "icon-after": "add|'.$module_anagrafiche['id'].'|tipoanagrafica=Cliente&readonly_tipo=1", "readonly": "'.( (empty($id_anagrafica) && empty($id_cliente)) ? 0 : 1).'" ]}
</div>
<div class="col-md-4">

View File

@ -44,7 +44,7 @@ echo '
<div class="row">
<div class="col-md-6">
'.Modules::link('Anagrafiche', $record['idanagrafica'], null, null, 'class="pull-right"').'
{[ "type": "select", "label": "'.tr('Cliente').'", "name": "idanagrafica", "required": 1, "value": "$idanagrafica$", "ajax-source": "clienti", "readonly": "'.$record['flag_completato'].'" ]}
{[ "type": "select", "label": "'.tr('Cliente').'", "name": "idanagrafica", "required": 1, "value": "$idanagrafica$", "ajax-source": "clienti", "readonly": "'.($user['gruppo'] == 'Clienti' ? '1' : $record['flag_completato']).'" ]}
</div>
<div class="col-md-6">

View File

@ -74,9 +74,11 @@ switch (post('op')) {
case 'update':
$data = post('data');
$descrizione = post('descrizione');
$note = post('note');
$mastrino->descrizione = $descrizione;
$mastrino->data = $data;
$mastrino->note = $note;
$mastrino->cleanup();

View File

@ -196,9 +196,9 @@ if ($numero_documenti + $numero_scadenze > 1) {
if (!empty($id_anagrafica_movimenti)) {
$an = Anagrafica::find($id_anagrafica_movimenti);
$descrizione = 'Pag. fatture '.$an->ragione_sociale.' num. '.implode(', ', $numeri);
$descrizione = ((($dir == 'entrata' && !$nota_credito && !$is_insoluto) || ($dir == 'uscita' && ($nota_credito || $is_insoluto))) ? tr('Inc.') : tr('Pag.')).' fatture '.$an->ragione_sociale.' num. '.implode(', ', $numeri);
} else {
$descrizione = 'Pag. fatture num. '.implode(', ', $numeri);
$descrizione = ((($dir == 'entrata' && !$nota_credito && !$is_insoluto) || ($dir == 'uscita' && ($nota_credito || $is_insoluto))) ? tr('Inc.') : tr('Pag.')).' fatture num. '.implode(', ', $numeri);
}
} elseif ($numero_documenti == 1) {
$numero_fattura = !empty($fattura['numero_esterno']) ? $fattura['numero_esterno'] : $fattura['numero'];
@ -208,7 +208,7 @@ if ($numero_documenti + $numero_scadenze > 1) {
if (!empty($is_insoluto)) {
$operation = tr('Registrazione insoluto');
} else {
$operation = tr('Pag.');
$operation = ((($dir == 'entrata' && !$nota_credito && !$is_insoluto) || ($dir == 'uscita' && ($nota_credito || $is_insoluto))) ? tr('Inc.') : tr('Pag.'));
}
$descrizione = tr('_OP_ _DOC_ num. _NUM_ del _DATE_ (_NAME_)', [

View File

@ -78,6 +78,14 @@ $movimenti = $mastrino->movimenti->toArray();
include $structure->filepath('movimenti.php');
?>
<!-- Note -->
<div class="row">
<div class="col-md-12">
{[ "type": "textarea", "label": "<?php echo tr('Note'); ?>", "name": "note", "required": 0, "value": "$note$" ]}
</div>
</div>
</form>
{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )}
@ -88,6 +96,9 @@ include $structure->filepath('movimenti.php');
});
</script>
<a class="btn btn-danger ask" data-backto="record-list" data-idmastrino="<?php echo $record['idmastrino']; ?>">
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
</a>

View File

@ -171,7 +171,7 @@ echo '
echo '
<script>
var formatted_zero = "'.Translator::numberToLocale(0).'";
var formatted_zero = "'.numberFormat(0).'";
var n = '.$counter.';
function addRiga(btn) {
@ -196,25 +196,25 @@ function addRiga(btn) {
* @returns {boolean}
*/
function controllaConti() {
var continuare = true;
let continuare = true;
// Controlli sullo stato dei raggruppamenti
$(".raggruppamento_primanota").each(function() {
var bilancio = calcolaBilancio(this);
let bilancio = calcolaBilancio(this);
continuare &= bilancio == 0;
continuare &= bilancio === 0;
});
// Blocco degli input con valore non impostato
$("input[id*=dare], input[id*=avere]").each(function() {
var conto_relativo = $(this).parent().parent().find("select").val();
let conto_relativo = $(this).parent().parent().find("select").val();
if (!conto_relativo) {
$(this).prop("disabled", true);
}
if ($(this).val().toEnglish()){
continuare &= conto_relativo ? true : false;
continuare &= !!conto_relativo;
}
});
@ -237,38 +237,37 @@ function controllaConti() {
* @returns {number}
*/
function calcolaBilancio(gruppo) {
var raggruppamento = $(gruppo);
let raggruppamento = $(gruppo);
var totale_dare = 0.00;
var totale_avere = 0.00;
let totale_dare = 0.00;
let totale_avere = 0.00;
// Calcolo il totale dare
raggruppamento.find("input[id*=dare]").each(function() {
valore = $(this).val() ? $(this).val().toEnglish() : 0;
totale_dare += valore;
totale_dare += input(this).get();
});
// Calcolo il totale avere
raggruppamento.find("input[id*=avere]").each(function() {
valore = $(this).val() ? $(this).val().toEnglish() : 0;
totale_avere += valore;
totale_avere += input(this).get();
});
totale_dare = parseFloat(totale_dare);
totale_avere = parseFloat(totale_avere);
// Visualizzazione dei totali
raggruppamento.find(".totale_dare").text(totale_dare.toLocale());
raggruppamento.find(".totale_avere").text(totale_avere.toLocale());
// Calcolo il bilancio
var bilancio = totale_dare.toFixed(2) - totale_avere.toFixed(2);
let bilancio = totale_dare.toFixed(2) - totale_avere.toFixed(2);
// Visualizzazione dello sbilancio eventuale
var sbilancio = raggruppamento.find(".sbilancio");
var valore_sbilancio = sbilancio.find(".money");
let sbilancio = raggruppamento.find(".sbilancio");
let valore_sbilancio = sbilancio.find(".money");
valore_sbilancio.text(bilancio.toLocale());
if (bilancio == 0) {
if (bilancio === 0) {
sbilancio.addClass("hide");
} else {
sbilancio.removeClass("hide");
@ -282,7 +281,7 @@ $(document).ready(function() {
// Fix per l\'inizializzazione degli input
$("input[id*=dare], input[id*=avere]").each(function() {
if ($(this).val() == formatted_zero) {
if (input(this).get() === 0) {
$(this).prop("disabled", true);
} else {
$(this).prop("disabled", false);
@ -298,30 +297,30 @@ $(document).ready(function() {
});
$(document).on("change", "select", function() {
var row = $(this).parent().parent();
let row = $(this).parent().parent();
if ($(this).parent().parent().find("input[disabled]").length != 1) {
row.find("input").prop("disabled", $(this).val() ? false : true);
if (row.find("input[disabled]").length > 1) {
row.find("input").prop("disabled", !$(this).val());
}
controllaConti();
});
$(document).on("keyup change", "input[id*=dare]", function() {
var row = $(this).parent().parent();
let row = $(this).parent().parent();
if (!$(this).prop("disabled")) {
row.find("input[id*=avere]").prop("disabled", $(this).val() ? true : false);
row.find("input[id*=avere]").prop("disabled", !!$(this).val());
controllaConti();
}
});
$(document).on("keyup change", "input[id*=avere]", function() {
var row = $(this).parent().parent();
let row = $(this).parent().parent();
if (!$(this).prop("disabled")) {
row.find("input[id*=dare]").prop("disabled", $(this).val() ? true : false);
row.find("input[id*=dare]").prop("disabled", !!$(this).val());
controllaConti();
}

View File

@ -44,6 +44,7 @@ class Movimento extends Model
$model->idmastrino = $mastrino->idmastrino;
$model->data = $mastrino->data;
$model->descrizione = $mastrino->descrizione;
$model->note = $mastrino->note;
$model->primanota = $mastrino->primanota;
$model->is_insoluto = $mastrino->is_insoluto;

View File

@ -31,7 +31,6 @@ include_once __DIR__.'/../../core.php';
{[ "type": "select", "label": "<?php echo tr('Tipo'); ?>", "name": "tipo", "required": 1, "ajax-source": "tipi_scadenze", "icon-after": "add|<?php echo Modules::get('Tipi scadenze')['id']; ?>" ]}
</div>
<div class="col-md-4">
{[ "type": "date", "label": "<?php echo tr('Data scadenza'); ?>", "name": "data", "required": 1, "value": "-now-" ]}
</div>
@ -52,5 +51,4 @@ include_once __DIR__.'/../../core.php';
</div>
<div class='clearfix'></div>
</form>

View File

@ -137,11 +137,11 @@ foreach ($scadenze as $i => $scadenza) {
</td>
<td class="text-right">
{[ "type": "number", "name": "da_pagare['.$i.']", "decimals": 2, "value": "'.Translator::numberToLocale($scadenza['da_pagare'], 2).'", "onchange": "controlloTotale()" ]}
{[ "type": "number", "name": "da_pagare['.$i.']", "decimals": 2, "value": "'.numberFormat($scadenza['da_pagare'], 2).'", "onchange": "controlloTotale()" ]}
</td>
<td class="text-right">
{[ "type": "number", "name": "pagato['.$i.']", "decimals": 2, "value": "'.Translator::numberToLocale($scadenza['pagato']).'" ]}
{[ "type": "number", "name": "pagato['.$i.']", "decimals": 2, "value": "'.numberFormat($scadenza['pagato']).'" ]}
</td>
<td align="center">
@ -155,7 +155,7 @@ echo '
<tfoot>
<tr>
<td class="text-right"><b>'.tr('Totale').'</b></td>
<td class="text-right" id="totale_utente">'.Translator::numberToLocale($totale_da_pagare).'</td>
<td class="text-right" id="totale_utente">'.numberFormat($totale_da_pagare).'</td>
<td class="text-right"></td>
</tr>
</tfoot>';
@ -179,7 +179,7 @@ echo '
]); ?>.
</div>
<input type="hidden" id="totale_da_pagare" value="<?php echo Translator::numberToLocale($totale_da_pagare, 2); ?>">
<input type="hidden" id="totale_da_pagare" value="<?php echo round($totale_da_pagare, 2); ?>">
</div>
</div>
</div>
@ -253,13 +253,11 @@ if (!empty($documento)) {
});
function controlloTotale() {
totale_da_pagare = $("#totale_da_pagare").val().toEnglish();
totale_utente = 0;
let totale_da_pagare = parseFloat($("#totale_da_pagare").val());
let totale_utente = 0;
$("input[name*=da_pagare]").each(function() {
totale_utente += $(this).val().toEnglish();
totale_utente += input(this).get();
});
if (isNaN(totale_utente)) {
@ -269,7 +267,7 @@ if (!empty($documento)) {
totale_utente = Math.round(totale_utente * 100) / 100;
totale_da_pagare = Math.round(totale_da_pagare * 100) / 100;
diff = Math.abs(totale_da_pagare) - Math.abs(totale_utente);
let diff = Math.abs(totale_da_pagare) - Math.abs(totale_utente);
if (diff == 0) {
$("#save").removeClass("hide");

View File

@ -112,7 +112,6 @@ class DateHandler implements HandlerInterface
{
$values['class'][] = 'text-center';
$values['class'][] = 'timestamp-picker';
$values['class'][] = 'timestamp-mask';
}
/**
@ -128,7 +127,6 @@ class DateHandler implements HandlerInterface
{
$values['class'][] = 'text-center';
$values['class'][] = 'datepicker';
$values['class'][] = 'date-mask';
}
/**

View File

@ -228,4 +228,7 @@ ALTER TABLE `or_righe_ordini` ADD `confermato` BOOLEAN NOT NULL AFTER `id_dettag
UPDATE `or_righe_ordini` SET `confermato`=1;
UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `mg_articoli` LEFT JOIN an_anagrafiche ON mg_articoli.id_fornitore=an_anagrafiche.idanagrafica LEFT JOIN co_iva ON mg_articoli.idiva_vendita=co_iva.id LEFT JOIN (SELECT SUM(qta-qta_evasa) AS qta_impegnata, idarticolo FROM or_righe_ordini INNER JOIN or_ordini ON or_righe_ordini.idordine=or_ordini.id INNER JOIN or_tipiordine ON or_ordini.idtipoordine=or_tipiordine.id WHERE idstatoordine IN(SELECT id FROM or_statiordine WHERE completato=0) AND or_tipiordine.dir=\'entrata\' AND or_righe_ordini.confermato = 1 GROUP BY idarticolo) a ON a.idarticolo=mg_articoli.id LEFT JOIN mg_categorie ON mg_articoli.id_categoria=mg_categorie.id LEFT JOIN mg_categorie AS sottocategorie ON mg_articoli.id_sottocategoria=sottocategorie.id WHERE 1=1 AND (`mg_articoli`.`deleted_at`) IS NULL HAVING 2=2 ORDER BY `mg_articoli`.`descrizione`' WHERE `zz_modules`.`name` = 'Articoli';
UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `mg_articoli` LEFT JOIN an_anagrafiche ON mg_articoli.id_fornitore=an_anagrafiche.idanagrafica LEFT JOIN co_iva ON mg_articoli.idiva_vendita=co_iva.id LEFT JOIN (SELECT SUM(qta-qta_evasa) AS qta_impegnata, idarticolo FROM or_righe_ordini INNER JOIN or_ordini ON or_righe_ordini.idordine=or_ordini.id INNER JOIN or_tipiordine ON or_ordini.idtipoordine=or_tipiordine.id WHERE idstatoordine IN(SELECT id FROM or_statiordine WHERE completato=0) AND or_tipiordine.dir=\'entrata\' AND or_righe_ordini.confermato = 1 GROUP BY idarticolo) a ON a.idarticolo=mg_articoli.id LEFT JOIN mg_categorie ON mg_articoli.id_categoria=mg_categorie.id LEFT JOIN mg_categorie AS sottocategorie ON mg_articoli.id_sottocategoria=sottocategorie.id WHERE 1=1 AND (`mg_articoli`.`deleted_at`) IS NULL HAVING 2=2 ORDER BY `mg_articoli`.`descrizione`' WHERE `zz_modules`.`name` = 'Articoli';
-- Aggiunte note prima nota
ALTER TABLE `co_movimenti` ADD `note` TEXT NOT NULL AFTER `descrizione`;