diff --git a/web/static/js/ntech.js b/web/static/js/ntech.js index 2e936e5..2c27170 100644 --- a/web/static/js/ntech.js +++ b/web/static/js/ntech.js @@ -181,6 +181,13 @@ document.addEventListener('alpine:init', () => { }, ukupnoSvega() { return this.stavke.reduce((z, s) => z + (parseFloat(s.kolicina) * parseFloat(s.cena) || 0), 0).toFixed(2) + }, + // fmtDin formatira broj sa separatorom hiljada (tačka) i 2 decimale (zarez): 1234567.5 → "1.234.567,50" + fmtDin(v) { + const n = parseFloat(v) || 0 + const [ceo, dec] = Math.abs(n).toFixed(2).split('.') + const saTackama = ceo.replace(/\B(?=(\d{3})+(?!\d))/g, '.') + return (n < 0 ? '-' : '') + saTackama + ',' + dec } })) @@ -327,6 +334,13 @@ document.addEventListener('alpine:init', () => { ukupnoSvega() { return this.stavke.reduce((z, s) => z + (parseFloat(s.kolicina) * parseFloat(s.cena) || 0), 0).toFixed(2) }, + // fmtDin formatira broj sa separatorom hiljada (tačka) i 2 decimale (zarez): 1234567.5 → "1.234.567,50" + fmtDin(v) { + const n = parseFloat(v) || 0 + const [ceo, dec] = Math.abs(n).toFixed(2).split('.') + const saTackama = ceo.replace(/\B(?=(\d{3})+(?!\d))/g, '.') + return (n < 0 ? '-' : '') + saTackama + ',' + dec + }, otvoriModal() { this.modal = true this.modalGreska = '' diff --git a/web/templates/stranice/nabavka_forma.html b/web/templates/stranice/nabavka_forma.html index a594cfb..04da5be 100644 --- a/web/templates/stranice/nabavka_forma.html +++ b/web/templates/stranice/nabavka_forma.html @@ -130,7 +130,7 @@ min="0" step="0.01" :disabled="isMobile" style="width:100%;text-align:right;">