}
*/
function loadScript(src, async = true, defer = true) {
if (!globals.dynamicScripts) {
@@ -715,6 +757,13 @@ function loadScript(src, async = true, defer = true) {
})
}
+/**
+ * Funzione per aggiungere in un *endpoint* il contenuto di uno specifico *template*, effettuando delle sostituzioni di base e inizializzando i campi aggiunti.
+ * @param endpoint_selector
+ * @param template_selector
+ * @param replaces
+ * @returns {*|jQuery|HTMLElement}
+ */
function aggiungiContenuto(endpoint_selector, template_selector, replaces = {}) {
let template = $(template_selector);
let endpoint = $(endpoint_selector);
diff --git a/assets/src/js/functions/hooks.js b/assets/src/js/functions/hooks.js
index aca744e66..78babb238 100755
--- a/assets/src/js/functions/hooks.js
+++ b/assets/src/js/functions/hooks.js
@@ -144,7 +144,7 @@ function updateHook(hook) {
$("#hooks-notified").html('');
$("#hooks-label").removeClass();
$("#hooks-label").addClass('label').addClass('label-success');
- }else{
+ } else {
$("#hooks-notified").text(number);
$("#hooks-label").removeClass();
$("#hooks-label").addClass('label').addClass('label-danger');
diff --git a/assets/src/js/functions/input.js b/assets/src/js/functions/input.js
index 8b2908367..a7e76d96c 100644
--- a/assets/src/js/functions/input.js
+++ b/assets/src/js/functions/input.js
@@ -16,6 +16,15 @@
* along with this program. If not, see .
*/
+/**
+ * Funzione semplificata per accedere ad uno specifico input.
+ * Accetta un oggetto jQuery, oppure un elemento JS HTMLElement, oppure il nome dell'input di interesse.
+ *
+ * Attenzione: in caso di molteplici input individuati, viene restituito l'ultimo individuato.
+ *
+ * @param {string|jQuery|HTMLElement} name
+ * @returns {Input|*}
+ */
function input(name) {
let element;
@@ -66,7 +75,9 @@ function Input(element) {
this.init();
}
-
+/**
+ * Effettua le operazioni di inizializzazione sull'input in base alla relativa tipologia.
+ */
Input.prototype.init = function () {
let initCompleted = false;
let htmlElement = this.element[0];
@@ -106,13 +117,24 @@ Input.prototype.init = function () {
initCompleted = initMaskInput(htmlElement);
}
- this.element.data("input-init", initCompleted);
+ this.element.data("input-init", !!initCompleted);
}
+/**
+ * Restituisce l'elemento jQuery che rappresenta l'input.
+ *
+ * @returns {jQuery}
+ */
Input.prototype.getElement = function () {
return this.element;
}
+/**
+ * Gestisce l'abilitazione e la disibilitazione dell'input sulla base del valore indicato.
+ *
+ * @param {bool} value
+ * @returns {Input}
+ */
Input.prototype.setDisabled = function (value) {
if (value) {
return this.disable();
@@ -121,6 +143,11 @@ Input.prototype.setDisabled = function (value) {
}
}
+/**
+ * Disabilita l'input all'utilizzo grafico.
+ *
+ * @returns {Input}
+ */
Input.prototype.disable = function () {
this.element.addClass("disabled")
.attr("disabled", true)
@@ -150,6 +177,11 @@ Input.prototype.disable = function () {
return this;
}
+/**
+ * Abilita l'input all'utilizzo grafico.
+ *
+ * @returns {Input}
+ */
Input.prototype.enable = function () {
this.element.removeClass("disabled")
.attr("disabled", false)
@@ -179,6 +211,11 @@ Input.prototype.enable = function () {
return this;
}
+/**
+ * Restituisce un oggetto cotentente le caratteristiche dell'input.
+ *
+ * @returns {{value: (string|number)}|jQuery|any}
+ */
Input.prototype.getData = function () {
if (this.element.is('select')) {
return this.element.selectData();
@@ -237,6 +274,11 @@ Input.prototype.set = function (value) {
return this;
}
+/**
+ * Imposta l'input per essere obbligatorio o meno.
+ * @param {bool} value
+ * @returns {Input}
+ */
Input.prototype.setRequired = function (value) {
this.element.attr("required", value)
.data("required", value);
@@ -245,22 +287,60 @@ Input.prototype.setRequired = function (value) {
}
// Eventi permessi
+/**
+ * Gestisce gli eventi di tipologia "change".
+ *
+ * @param callable
+ * @returns {Input}
+ */
Input.prototype.change = function (callable) {
- return this.on("change", callable);
+ this.on("change", callable)
+
+ return this;
}
+/**
+ * Gestisce l'ascolto a uno specifico evento sulla base dell'oggetto jQuery.
+ *
+ * @param {string} event
+ * @param callable
+ *
+ * @returns {Input}
+ */
Input.prototype.on = function (event, callable) {
- return this.element.on(event, callable);
+ this.element.on(event, callable);
+
+ return this;
}
+/**
+ * Gestisce la rimozione degli ascoltatori attivi per uno specifico evento sulla base dell'oggetto jQuery.
+ *
+ * @param {string} event
+ *
+ * @returns {Input}
+ */
Input.prototype.off = function (event) {
- return this.element.off(event);
+ this.element.off(event);
+
+ return this;
}
+/**
+ * Effettua il trigger di uno specifico evento sull'input.
+ * @param {string} event
+ * @param callable
+ * @returns {Input}
+ */
Input.prototype.trigger = function (event, callable) {
- return this.element.trigger(event, callable);
+ this.element.trigger(event, callable);
+
+ return this;
}
+/**
+ * Distrugge il gestore attuale per l'input e ne disabilita le funzionalità previste.
+ */
Input.prototype.destroy = function () {
if (this.element.data('select2')) {
this.element.select2().select2("destroy")
@@ -273,6 +353,7 @@ Input.prototype.destroy = function () {
}
this.element.data("input-controller", null);
+ this.element.data("input-init", false);
}
/**
diff --git a/assets/src/js/functions/inputmask.js b/assets/src/js/functions/inputmask.js
index c42619150..dc5ce1b73 100644
--- a/assets/src/js/functions/inputmask.js
+++ b/assets/src/js/functions/inputmask.js
@@ -16,28 +16,32 @@
* along with this program. If not, see .
*/
+/**
+ * Funzione per l'inizializzazione delle maschere sui campi impostati.
+ * @param input
+ */
function initMaskInput(input) {
let $input = $(input);
- if ($input.hasClass('email-mask')){
+ 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')){
+ } else if ($input.hasClass('rea-mask')) {
$input.inputmask({
mask: "AA-999999{1,15}",
casing: "upper",
});
- } else if ($input.hasClass('provincia-mask')){
+ } else if ($input.hasClass('provincia-mask')) {
$input.inputmask({
mask: "AA",
casing: "upper",
});
- } else if ($input.hasClass('alphanumeric-mask')){
+ } else if ($input.hasClass('alphanumeric-mask')) {
$input.inputmask('Regex', {
regex: "[A-Za-z0-9#_|\/\\-.]*",
});
- } else if ($input.hasClass('math-mask')){
+ } else if ($input.hasClass('math-mask')) {
$input.inputmask('Regex', {
regex: "[0-9,.+\-]*",
});
@@ -47,7 +51,8 @@ function initMaskInput(input) {
}
/**
- * Inputmask
+ * Inputmask.
+ *
* @param element
*/
function start_inputmask(element) {
@@ -57,7 +62,7 @@ function start_inputmask(element) {
element = element + ' ';
}
- let masks = ['math-mask','alphanumeric-mask', 'provincia-mask','rea-mask', 'email-mask'];
+ let masks = ['math-mask', 'alphanumeric-mask', 'provincia-mask', 'rea-mask', 'email-mask'];
let selector = element + '.' + masks.join(', ' + element + '.')
$(selector).each(function () {
diff --git a/assets/src/js/functions/numbers.js b/assets/src/js/functions/numbers.js
index 6891b0a34..d687d7850 100644
--- a/assets/src/js/functions/numbers.js
+++ b/assets/src/js/functions/numbers.js
@@ -27,6 +27,10 @@ function initNumbers() {
});
}
+/**
+ * Funzione per l'inizializzazione dei campi numerici.
+ * @param input
+ */
function initNumberInput(input) {
let $input = $(input);
if (AutoNumeric.isManagedByAutoNumeric(input)) {
diff --git a/assets/src/js/functions/prototypes.js b/assets/src/js/functions/prototypes.js
index 1e91e7c97..08d176100 100755
--- a/assets/src/js/functions/prototypes.js
+++ b/assets/src/js/functions/prototypes.js
@@ -16,18 +16,6 @@
* along with this program. If not, see .
*/
-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();
};
@@ -35,10 +23,3 @@ String.prototype.toEnglish = function () {
Number.prototype.toLocale = function () {
return numeral(this).format();
};
-
-jQuery.fn.scrollTo = function (elem, speed) {
- $(this).animate({
- scrollTop: $(this).scrollTop() - $(this).offset().top + $(elem).offset().top
- }, speed === undefined ? 1000 : speed);
- return this;
-};
diff --git a/assets/src/js/functions/select.js b/assets/src/js/functions/select.js
index bbc5d8bf1..2da53863d 100755
--- a/assets/src/js/functions/select.js
+++ b/assets/src/js/functions/select.js
@@ -27,6 +27,13 @@ function start_superselect() {
});
}
+/**
+ * Gestisce le operazioni di rendering per una singola opzione del select.
+ *
+ * @param data
+ * @param container
+ * @returns {*}
+ */
function selectOptionRender(data, container) {
let bg;
@@ -179,6 +186,8 @@ function updateSelectOption(name, value) {
}
/**
+ * Funzione per l'inizializzazione automatica del select.
+ *
* @param input
*/
function initSelectInput(input) {
@@ -190,11 +199,12 @@ function initSelectInput(input) {
initDynamicSelectInput(input);
}
- return $input.data('select');
+ return $input.data('select2');
}
/**
- * Statico.
+ * Funzione per l'inizializzazione del select statico.
+ *
* @param input
*/
function initStaticSelectInput(input) {
@@ -215,7 +225,8 @@ function initStaticSelectInput(input) {
}
/**
- * Dinamico.
+ * Funzione per l'inizializzazione del select dinamico.
+ *
* @param input
*/
function initDynamicSelectInput(input) {
diff --git a/assets/src/js/functions/textarea.js b/assets/src/js/functions/textarea.js
index 8c432b45b..e2c318f46 100644
--- a/assets/src/js/functions/textarea.js
+++ b/assets/src/js/functions/textarea.js
@@ -16,12 +16,20 @@
* along with this program. If not, see .
*/
+/**
+ * Funzione per l'inizializzazione dei campi textarea.
+ * @param input
+ */
function initTextareaInput(input) {
autosize($(input));
return true;
}
+/**
+ * Funzione per l'inizializzazione dei campi editor.
+ * @param input
+ */
function initEditorInput(input) {
let $input = $(input);
let name = input.getAttribute("id");
diff --git a/modules/impianti/add.php b/modules/impianti/add.php
index 51bca16aa..eb079f077 100644
--- a/modules/impianti/add.php
+++ b/modules/impianti/add.php
@@ -35,7 +35,7 @@ $id_anagrafica = filter('id_anagrafica');
- {[ "type": "select", "label": "", "name": "idanagrafica", "required": 1, "value": "", "ajax-source": "clienti", "icon-after": "add||tipoanagrafica=Cliente&readonly_tipo=1" ]}
+ {[ "type": "select", "label": "", "name": "idanagrafica", "id": "idanagrafica_impianto", "required": 1, "value": "", "ajax-source": "clienti", "icon-after": "add||tipoanagrafica=Cliente&readonly_tipo=1" ]}
diff --git a/modules/interventi/add.php b/modules/interventi/add.php
index c72d677ba..72e35994f 100755
--- a/modules/interventi/add.php
+++ b/modules/interventi/add.php
@@ -303,9 +303,8 @@ echo '
-
+';
-';
if (!empty($id_intervento)) {
echo '