mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-16 11:30:55 +01:00
Merge branch 'autonumeric'
This commit is contained in:
commit
099cda6fcb
@ -1041,6 +1041,10 @@ div.tip {
|
||||
background: #222222;
|
||||
}
|
||||
|
||||
.decimal-number {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* Loading specificato per un div */
|
||||
.local-loader {
|
||||
position: relative;
|
||||
|
@ -16,12 +16,21 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Modal
|
||||
/**
|
||||
* Modal gestito da versioni precedenti.
|
||||
* @param title
|
||||
* @param href
|
||||
* @param init_modal
|
||||
*/
|
||||
function launch_modal(title, href, init_modal) {
|
||||
openModal(title, href);
|
||||
}
|
||||
|
||||
// Modal
|
||||
/**
|
||||
* Modal.
|
||||
* @param title
|
||||
* @param href
|
||||
*/
|
||||
function openModal(title, href) {
|
||||
// Fix - Select2 does not function properly when I use it inside a Bootstrap modal.
|
||||
$.fn.modal.Constructor.prototype.enforceFocus = function () {
|
||||
@ -73,6 +82,11 @@ function openModal(title, href) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param event
|
||||
* @param link
|
||||
*/
|
||||
function openLink(event, link) {
|
||||
if (event.ctrlKey) {
|
||||
window.open(link);
|
||||
@ -103,7 +117,9 @@ function getUrlVars() {
|
||||
});
|
||||
}
|
||||
|
||||
// Data e ora (orologio)
|
||||
/**
|
||||
* Data e ora (orologio)
|
||||
*/
|
||||
function clock() {
|
||||
$('#datetime').html(moment().formatPHP(globals.timestamp_format));
|
||||
setTimeout('clock()', 1000);
|
||||
@ -143,33 +159,6 @@ 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);
|
||||
@ -237,9 +226,7 @@ function message(element) {
|
||||
confirmButtonText: button,
|
||||
confirmButtonClass: btn_class,
|
||||
onOpen: function () {
|
||||
start_superselect();
|
||||
start_inputmask();
|
||||
start_datepickers();
|
||||
restart_inputs();
|
||||
},
|
||||
preConfirm: function () {
|
||||
$form = $('#swal-form');
|
||||
@ -468,8 +455,10 @@ function prepareForm(form) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visualizzazione dei messaggi attivi tramite toastr.
|
||||
*/
|
||||
function renderMessages() {
|
||||
// Visualizzazione messaggi
|
||||
$.ajax({
|
||||
url: globals.rootdir + '/ajax.php',
|
||||
type: 'get',
|
||||
@ -522,14 +511,17 @@ function restart_inputs() {
|
||||
start_datepickers();
|
||||
start_inputmask();
|
||||
|
||||
initNumbers();
|
||||
start_superselect();
|
||||
|
||||
// Autosize per le textarea
|
||||
autosize($('.autosize'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Messaggio di avviso salvataggio a comparsa sulla destra solo nella versione a desktop intero
|
||||
*/
|
||||
function alertPush() {
|
||||
// Messaggio di avviso salvataggio a comparsa sulla destra solo nella versione a desktop intero
|
||||
if ($(window).width() > 1023) {
|
||||
var i = 0;
|
||||
|
||||
@ -559,6 +551,13 @@ function alertPush() {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param button
|
||||
* @param form
|
||||
* @param data
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
function salvaForm(button, form, data = {}) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
// Caricamento visibile nel pulsante
|
||||
|
31
assets/src/js/functions/numbers.js
Normal file
31
assets/src/js/functions/numbers.js
Normal file
@ -0,0 +1,31 @@
|
||||
function initNumbers() {
|
||||
$('.decimal-number').not('.bound').each(function () {
|
||||
let $this = $(this);
|
||||
|
||||
let min = $this.attr('min-value') && $this.attr('min-value') !== "undefined" ? $this.attr('min-value') : null;
|
||||
let max = $this.attr('max-value') && $this.attr('max-value') !== "undefined" ? $this.attr('max-value') : null;
|
||||
|
||||
let decimals = $this.attr('decimals') ? $this.attr('decimals') : globals.cifre_decimali;
|
||||
|
||||
let autonumeric = new AutoNumeric(this, {
|
||||
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,
|
||||
});
|
||||
|
||||
$this.data("autonumeric", autonumeric);
|
||||
}).addClass('bound');
|
||||
}
|
2
assets/src/js/functions/prototypes.js
vendored
2
assets/src/js/functions/prototypes.js
vendored
@ -39,6 +39,6 @@ Number.prototype.toLocale = function () {
|
||||
jQuery.fn.scrollTo = function (elem, speed) {
|
||||
$(this).animate({
|
||||
scrollTop: $(this).scrollTop() - $(this).offset().top + $(elem).offset().top
|
||||
}, speed == undefined ? 1000 : speed);
|
||||
}, speed === undefined ? 1000 : speed);
|
||||
return this;
|
||||
};
|
||||
|
0
files/impianti/componente.ini
Normal file → Executable file
0
files/impianti/componente.ini
Normal file → Executable file
@ -94,6 +94,7 @@ const JS = gulp.parallel(() => {
|
||||
'datatables.net-scroller/js/dataTables.scroller.js',
|
||||
'datatables.net-select/js/dataTables.select.js',
|
||||
'dropzone/dist/dropzone.js',
|
||||
'autonumeric/dist/autoNumeric.min.js',
|
||||
'eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js',
|
||||
'fullcalendar/dist/fullcalendar.js',
|
||||
'geocomplete/jquery.geocomplete.js',
|
||||
|
@ -33,7 +33,7 @@ echo '
|
||||
// Quantità
|
||||
echo '
|
||||
<div class="col-md-4">
|
||||
{[ "type": "number", "label": "'.tr('Q.tà').'", "name": "qta", "required": 1, "value": "'.$result['qta'].'", "decimals": "qta"'.(isset($result['max_qta']) ? ', "icon-after": "<span class=\"tip\" title=\"'.tr("L'elemento è collegato a un documento: la quantità massima ammessa è relativa allo stato di evasione dell'elemento nel documento di origine (quantità dell'elemento / quantità massima ammessa)").'\">/ '.numberFormat($result['max_qta'], 'qta').' <i class=\"fa fa-question-circle-o\"></i></span>"' : '').', "min-value": "'.Translator::numberToLocale($result['qta_evasa']).'" ]}
|
||||
{[ "type": "number", "label": "'.tr('Q.tà').'", "name": "qta", "required": 1, "value": "'.$result['qta'].'", "decimals": "qta"'.(isset($result['max_qta']) ? ', "icon-after": "<span class=\"tip\" title=\"'.tr("L'elemento è collegato a un documento: la quantità massima ammessa è relativa allo stato di evasione dell'elemento nel documento di origine (quantità dell'elemento / quantità massima ammessa)").'\">/ '.numberFormat($result['max_qta'], 'qta').' <i class=\"fa fa-question-circle-o\"></i></span>"' : '').', "min-value": "'.$result['qta_evasa'].'" ]}
|
||||
</div>';
|
||||
|
||||
// Unità di misura
|
||||
|
@ -183,8 +183,6 @@ elseif ($record['stato'] == 'Bozza') {
|
||||
{[ "type": "date", "class":"<?php echo (dateFormat($fattura->data_competenza) < dateFormat($fattura->data)) ? 'unblockable' : ''; ?>", "label": "<?php echo tr('Data competenza'); ?>", "name": "data_competenza", "required": 1, "value": "$data_competenza$", "min-date": "$data_registrazione$", "help": "<?php echo tr('Data nella quale considerare il movimento contabile, che può essere posticipato rispetto la data della fattura'); ?>" ]}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
if ($dir == 'entrata') {
|
||||
?>
|
||||
|
@ -30,8 +30,9 @@ function crea_form_componente($contenuto)
|
||||
$fields[$key] = '<div class="col-md-4">'.$value.'</div>';
|
||||
}
|
||||
|
||||
echo $title;
|
||||
echo '<div class="row">';
|
||||
echo PHP_EOL.implode(PHP_EOL, $fields).PHP_EOL.'<script>start_inputmask( "#info_componente" );</script>';
|
||||
echo '</div>';
|
||||
echo $title.'
|
||||
<div class="row">
|
||||
'.implode(PHP_EOL, $fields).'
|
||||
<script>restart_inputs()</script>
|
||||
</div>';
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
"main": "gulpfile.js",
|
||||
"dependencies": {
|
||||
"admin-lte": "^2.4.0",
|
||||
"autonumeric": "^4.6.0",
|
||||
"autosize": "^3.0.21",
|
||||
"bootstrap": "^3.3.7",
|
||||
"bootstrap-colorpicker": "2.5.1",
|
||||
|
0
src/Common/Components/Article.php
Normal file → Executable file
0
src/Common/Components/Article.php
Normal file → Executable file
0
src/Common/Components/Discount.php
Normal file → Executable file
0
src/Common/Components/Discount.php
Normal file → Executable file
0
src/Common/Components/MorphTrait.php
Normal file → Executable file
0
src/Common/Components/MorphTrait.php
Normal file → Executable file
0
src/Common/Components/Row.php
Normal file → Executable file
0
src/Common/Components/Row.php
Normal file → Executable file
0
src/Common/Document.php
Normal file → Executable file
0
src/Common/Document.php
Normal file → Executable file
0
src/Common/Model.php
Normal file → Executable file
0
src/Common/Model.php
Normal file → Executable file
0
src/Common/ReferenceInterface.php
Normal file → Executable file
0
src/Common/ReferenceInterface.php
Normal file → Executable file
@ -235,7 +235,7 @@ class DefaultHandler implements HandlerInterface
|
||||
*/
|
||||
protected function number(&$values, &$extras)
|
||||
{
|
||||
$values['class'][] = 'inputmask-decimal';
|
||||
$values['class'][] = 'decimal-number';
|
||||
|
||||
$values['value'] = !empty($values['value']) ? $values['value'] : 0;
|
||||
|
||||
@ -245,20 +245,17 @@ class DefaultHandler implements HandlerInterface
|
||||
if (is_numeric($values['decimals'])) {
|
||||
$decimals = $values['decimals'];
|
||||
} elseif (starts_with($values['decimals'], 'qta')) {
|
||||
// Se non è previsto un valore minimo, lo imposta a 1
|
||||
$values['min-value'] = isset($values['min-value']) ? $values['min-value'] : 0;
|
||||
|
||||
$decimals = setting('Cifre decimali per quantità');
|
||||
$values['decimals'] = $decimals;
|
||||
|
||||
// Se non è previsto un valore minimo, lo imposta a 1
|
||||
$values['min-value'] = isset($values['min-value']) ? $values['min-value'] : '0.'.str_repeat('0', $decimals - 1).'1';
|
||||
}
|
||||
}
|
||||
|
||||
// Controllo sulla correttezza sintattica del valore impostato
|
||||
$values['value'] = (formatter()->isStandardNumber($values['value'])) ? \Translator::numberToLocale($values['value'], $decimals) : $values['value'];
|
||||
|
||||
// Delega al metodo "text", per la generazione del codice HTML
|
||||
$values['type'] = 'text';
|
||||
|
||||
// Delega al metodo "text", per la generazione del codice HTML
|
||||
return $this->text($values, $extras);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user