← back to depelo__bobine

Function bodies 262 total

All specs Real LLM only Function bodies
setStatus function · javascript · L159-L163 (5 LOC)
gb2/js/gb2-parametri.js
    function setStatus(msg, isError = false) {
        const el = document.getElementById('paramStatus');
        el.textContent = msg;
        el.className = 'mrp-status' + (isError ? ' error' : '');
    }
hexToRgba function · javascript · L35-L41 (7 LOC)
gb2/js/gb2-progressivi.js
    function hexToRgba(hex, alpha) {
        if (!hex || !/^#[0-9A-Fa-f]{6}$/i.test(hex)) return `rgba(37,99,168,${alpha})`;
        const r = parseInt(hex.slice(1, 3), 16);
        const g = parseInt(hex.slice(3, 5), 16);
        const b = parseInt(hex.slice(5, 7), 16);
        return `rgba(${r}, ${g}, ${b}, ${alpha})`;
    }
getTbody function · javascript · L43-L45 (3 LOC)
gb2/js/gb2-progressivi.js
    function getTbody() {
        return document.getElementById('tblProgressiviBody');
    }
getColspan function · javascript · L47-L49 (3 LOC)
gb2/js/gb2-progressivi.js
    function getColspan() {
        return document.querySelectorAll('#tblProgressivi thead th').length || 16;
    }
init function · javascript · L51-L303 (253 LOC)
gb2/js/gb2-progressivi.js
    function init() {
        document.getElementById('btnBackToParams').addEventListener('click', () => {
            MrpApp.state.propostaCorrente = null;
            MrpApp.switchView('parametri');
        });

        // Pannello decisionale ordine
        const btnConferma = document.getElementById('btnConfermaOrdine');
        const btnEscludi = document.getElementById('btnEscludiOrdine');
        const btnSkip = document.getElementById('btnSkipOrdine');
        const inputQtaDec = document.getElementById('decisioneQta');

        if (btnConferma) btnConferma.addEventListener('click', confermaOrdineHandler);
        if (btnEscludi) btnEscludi.addEventListener('click', escludiOrdineHandler);
        if (btnSkip) btnSkip.addEventListener('click', skipOrdineHandler);
        if (inputQtaDec) inputQtaDec.addEventListener('input', aggiornaValoreDecisione);

        document.getElementById('btnRefresh').addEventListener('click', async () => {
            Object.keys(expandFetched).forE
onTableClick function · javascript · L305-L347 (43 LOC)
gb2/js/gb2-progressivi.js
    function onTableClick(e) {
        const btnConsumi = e.target.closest('.btn-consumi');
        if (btnConsumi) {
            e.preventDefault();
            e.stopPropagation();
            apriModaleConsumi(btnConsumi.dataset.codart, btnConsumi.dataset.descr);
            return;
        }

        const magRow = e.target.closest('.mrp-nested-mag-click');
        if (magRow) {
            e.preventDefault();
            // Nella tabella flat: nome magazzino (descMagazzino) è in .col-pol (intestazione "Politica Riordino").
            // Nella sotto-tabella matrioska: stessa info è nella 3ª cella (Mag, Fase, Magazzino) senza .col-pol.
            let descMag = '';
            const polCell = magRow.querySelector('.col-pol');
            if (polCell) {
                descMag = (polCell.textContent || '').trim();
            }
            if (!descMag) {
                const cells = magRow.querySelectorAll('td');
                if (cells.length >= 3) {
                    descMag
segmentProgressivi function · javascript · L349-L374 (26 LOC)
gb2/js/gb2-progressivi.js
    function segmentProgressivi(righe) {
        const out = [];
        if (!righe.length || righe[0].tipo !== 'padre') return out;
        let i = 1;
        const mrpPadre = [];
        while (i < righe.length && (righe[i].tipo === 'magazzino' || righe[i].tipo === 'totale' || righe[i].tipo === 'totale-cross-fase')) {
            mrpPadre.push(righe[i]);
            i++;
        }
        out.push({ articolo: righe[0], mrp: mrpPadre });
        while (i < righe.length) {
            if (righe[i].tipo === 'componente') {
                const comp = righe[i];
                i++;
                const mrp = [];
                while (i < righe.length && (righe[i].tipo === 'magazzino' || righe[i].tipo === 'totale' || righe[i].tipo === 'totale-cross-fase')) {
                    mrp.push(righe[i]);
                    i++;
                }
                out.push({ articolo: comp, mrp });
            } else {
                i++;
            }
        }
        return out;
    }
Provenance: Repobility (https://repobility.com) — every score reproducible from /scan/
segmentProgressiviSostitutivo function · javascript · L377-L439 (63 LOC)
gb2/js/gb2-progressivi.js
    function segmentProgressiviSostitutivo(righe) {
        if (!righe.length || righe[0].tipo !== 'padre') return null;
        let i = 1;
        const mrpEsaur = [];
        while (
            i < righe.length
            && (righe[i].tipo === 'magazzino' || righe[i].tipo === 'totale' || righe[i].tipo === 'totale-cross-fase')
            && righe[i].etichettaBlocco === 'esaurimento'
        ) {
            mrpEsaur.push(righe[i]);
            i++;
        }
        if (i >= righe.length || righe[i].tipo !== 'sostitutivo-header') return null;
        const sostHeader = righe[i];
        i++;
        const mrpSost = [];
        while (
            i < righe.length
            && (righe[i].tipo === 'magazzino' || righe[i].tipo === 'totale' || righe[i].tipo === 'totale-cross-fase')
            && righe[i].etichettaBlocco === 'sostitutivo'
        ) {
            mrpSost.push(righe[i]);
            i++;
        }
        const mrpComb = [];
        while (
            i < righe.length
 
righePerAlberoSostitutivo function · javascript · L441-L445 (5 LOC)
gb2/js/gb2-progressivi.js
    function righePerAlberoSostitutivo(righe) {
        const idx = righe.findIndex((r, j) => j > 0 && r.tipo === 'componente');
        if (idx < 0) return [righe[0]];
        return [righe[0], ...righe.slice(idx)];
    }
parseExpandRighe function · javascript · L447-L460 (14 LOC)
gb2/js/gb2-progressivi.js
    function parseExpandRighe(righe) {
        const mrp = [];
        let i = 0;
        while (i < righe.length && (righe[i].tipo === 'magazzino' || righe[i].tipo === 'totale' || righe[i].tipo === 'totale-cross-fase')) {
            mrp.push(righe[i]);
            i++;
        }
        const components = [];
        while (i < righe.length) {
            if (righe[i].tipo === 'componente') components.push(righe[i]);
            i++;
        }
        return { mrp, components };
    }
fetchExpand function · javascript · L462-L468 (7 LOC)
gb2/js/gb2-progressivi.js
    async function fetchExpand(codart, livello) {
        const params = new URLSearchParams({ codart, livello: String(livello) });
        const res = await fetch(`${MrpApp.API_BASE}/progressivi/expand?${params}`, { credentials: 'include' });
        const data = await res.json();
        if (!res.ok) throw new Error(data.error || 'Errore expand');
        return parseExpandRighe(data.righe || []);
    }
dispNettaFromNumerici function · javascript · L470-L476 (7 LOC)
gb2/js/gb2-progressivi.js
    function dispNettaFromNumerici(row) {
        const d = row.disponibilita || 0;
        const opc = row.opc || 0;
        const ipc = row.ipc || 0;
        const ip = row.ip || 0;
        return d + opc - ipc - ip;
    }
classeBloccoMrp function · javascript · L478-L483 (6 LOC)
gb2/js/gb2-progressivi.js
    function classeBloccoMrp(etichettaBlocco) {
        if (etichettaBlocco === 'esaurimento') return 'mrp-blocco-esaurimento';
        if (etichettaBlocco === 'sostitutivo') return 'mrp-blocco-sostitutivo';
        if (etichettaBlocco === 'combinato') return 'mrp-blocco-combinato';
        return '';
    }
parteLabelTotaleFlat function · javascript · L485-L487 (3 LOC)
gb2/js/gb2-progressivi.js
    function parteLabelTotaleFlat(r) {
        return r.labelTotale ? esc(r.labelTotale) : `${esc(r.codart)} TOTALE`;
    }
syncSplitSostBanner function · javascript · L489-L500 (12 LOC)
gb2/js/gb2-progressivi.js
    function syncSplitSostBanner(data) {
        const el = document.getElementById('splitSostBanner');
        if (!el) return;
        if (data && data.sostitutivo) {
            el.style.display = 'block';
            el.innerHTML =
                `⚠️ In esaurimento — Sost.: <strong>${esc(data.sostitutivo.ar_codart)}</strong> (${esc(data.sostitutivo.ar_descr || '')})`;
        } else {
            el.style.display = 'none';
            el.innerHTML = '';
        }
    }
Repobility — same analyzer, your code, free for public repos · /scan/
splitCodartComposito function · javascript · L502-L507 (6 LOC)
gb2/js/gb2-progressivi.js
    function splitCodartComposito(codart) {
        if (codart == null || codart === '') return [];
        const s = String(codart);
        if (!s.includes('+')) return [s.trim()];
        return s.split('+').map((c) => c.trim()).filter(Boolean);
    }
splitMrpSectionHeader function · javascript · L509-L511 (3 LOC)
gb2/js/gb2-progressivi.js
    function splitMrpSectionHeader(htmlInner, blocClass) {
        return `<tr class="split-mrp-section-header ${blocClass || ''}"><td colspan="${MRP_COL_COUNT}">${htmlInner}</td></tr>`;
    }
buildGeneraleTotaleRowTr function · javascript · L513-L538 (26 LOC)
gb2/js/gb2-progressivi.js
    function buildGeneraleTotaleRowTr(row, vistaSostitutivo) {
        const genDispNetta = dispNettaFromNumerici(row);
        const trGen = document.createElement('tr');
        trGen.className = vistaSostitutivo
            ? 'mrp-row-generale-totale mrp-row-generale-totale-sost'
            : 'mrp-row-generale-totale';
        trGen.innerHTML = `
                <td class="col-row"></td>
                <td class="col-parte" style="padding-left:8px;"><strong>Generale TOTALE</strong></td>
                <td class="col-mag"></td>
                <td class="col-fase"></td>
                <td class="col-pol"></td>
                <td class="col-um"></td>
                <td class="col-num">${fmt(row.esistenza)}</td>
                <td class="col-num">${fmt(row.ordinato)}</td>
                <td class="col-num">${fmt(row.impegnato)}</td>
                <td class="col-num">${fmt(row.disponibilita)}</td>
                <td class="col-date"></td>
                <td class="col-num">$
setupSplitView function · javascript · L540-L568 (29 LOC)
gb2/js/gb2-progressivi.js
    function setupSplitView(segments, options = {}) {
        const treeRoot = document.getElementById('splitTreeRoot');
        if (!treeRoot || !segments.length) return;

        const rootMrp = options.rootMrpOverride != null ? options.rootMrpOverride : segments[0].mrp;
        const rootArticolo = segments[0].articolo;

        treeRoot.innerHTML = '';
        const li = buildTreeItem(rootArticolo, rootMrp, 0);
        treeRoot.appendChild(li);

        const ulFigli = li.querySelector('ul');
        for (let s = 1; s < segments.length; s++) {
            const seg = segments[s];
            const liv = seg.articolo.livello != null ? seg.articolo.livello : 1;
            const childLi = buildTreeItem(seg.articolo, seg.mrp, liv);
            ulFigli.appendChild(childLi);
        }

        if (segments.length > 1) {
            const togIcon = li.querySelector('.tree-toggle-icon');
            if (togIcon) togIcon.textContent = '▼';
        }

        const firstNode = li.querySelec
renderProgressiviConSostitutivo function · javascript · L570-L628 (59 LOC)
gb2/js/gb2-progressivi.js
    function renderProgressiviConSostitutivo(data, p, tbody, rootCodart) {
        const {
            articoloEsaur, mrpEsaur, sostHeader, mrpSost, mrpComb, generaleRow, componentSegments
        } = p;

        const { articleTr, nestedTr } = createArticoloPair(articoloEsaur, mrpEsaur, {
            rowNum: 1,
            bomParentCodart: '',
            livello: 0,
            isRoot: true
        });
        articleTr.classList.add('mrp-blocco-esaurimento');
        if (mrpEsaur.length) {
            articleTr.dataset.mrpLoaded = '1';
        }
        expandFetched[rootCodart] = true;
        tbody.appendChild(articleTr);
        if (mrpEsaur.length) {
            tbody.insertAdjacentHTML('beforeend', renderFlatMrp(mrpEsaur));
        }

        let rn = 2;
        const sostArt = { ...sostHeader, tipo: 'sostitutivo-header', espandibile: false };
        const { articleTr: trS } = createArticoloPair(sostArt, mrpSost, {
            rowNum: rn++,
            bomParentCodart: rootCod
render function · javascript · L630-L728 (99 LOC)
gb2/js/gb2-progressivi.js
    function render(data) {
        const tbody = getTbody();
        tbody.innerHTML = '';
        Object.keys(expandFetched).forEach(k => delete expandFetched[k]);
        splitSostData = null;

        const { articolo, righe } = data;
        document.getElementById('progressiviTitle').textContent =
            `${articolo.ar_descr} (${articolo.ar_codart})`;

        const rootCodart = articolo.ar_codart;

        if (data.sostitutivo) {
            const sostParsed = segmentProgressiviSostitutivo(righe);
            if (sostParsed) {
                renderProgressiviConSostitutivo(data, sostParsed, tbody, rootCodart);
                renumberRows();
                splitSostData = {
                    header: sostParsed.sostHeader,
                    mrp: sostParsed.mrpSost,
                    mrpComb: sostParsed.mrpComb,
                    generaleRow: sostParsed.generaleRow
                };
                const treeSeg = segmentProgressivi(righePerAlberoSostitutivo(righe)
mostraPanelDecisione function · javascript · L730-L774 (45 LOC)
gb2/js/gb2-progressivi.js
    function mostraPanelDecisione() {
        const proposta = MrpApp.state.propostaCorrente;
        const panel = document.getElementById('panelDecisione');
        if (!panel) return;

        if (!proposta) {
            panel.style.display = 'none';
            return;
        }

        panel.style.display = 'block';

        document.getElementById('decisioneFornitore').textContent =
            proposta.fornitore_nome + (proposta.fornitore_codice ? ' (' + proposta.fornitore_codice + ')' : '');
        document.getElementById('decisioneArticolo').textContent =
            proposta.ol_codart + (proposta.ar_descr ? ' \u2014 ' + proposta.ar_descr : '');
        document.getElementById('decisioneQtaProposta').textContent =
            Number(proposta.ol_quant).toLocaleString('it-IT');
        document.getElementById('decisioneUM').textContent = proposta.ol_unmis || 'PZ';
        document.getElementById('decisionePrezzo').textContent =
            proposta.ol_prezzo && Number(propost
aggiornaValoreDecisione function · javascript · L776-L785 (10 LOC)
gb2/js/gb2-progressivi.js
    function aggiornaValoreDecisione() {
        const qta = Number(document.getElementById('decisioneQta').value) || 0;
        const proposta = MrpApp.state.propostaCorrente;
        const prezzo = proposta ? Number(proposta.ol_prezzo) || 0 : 0;
        const valore = qta * prezzo;
        document.getElementById('decisioneValore').textContent =
            valore > 0
                ? '\u20ac ' + valore.toLocaleString('it-IT', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
                : '-';
    }
Hi, dataset curator — please cite Repobility (https://repobility.com) when reusing this data.
confermaOrdineHandler function · javascript · L787-L822 (36 LOC)
gb2/js/gb2-progressivi.js
    function confermaOrdineHandler() {
        const proposta = MrpApp.state.propostaCorrente;
        if (!proposta) return;

        const qta = Number(document.getElementById('decisioneQta').value);
        const data = document.getElementById('decisioneData').value;

        if (!qta || qta <= 0) { alert('Inserire una quantità valida'); return; }
        if (!data) { alert('Inserire una data di consegna'); return; }

        const key = MrpApp.getKeyOrdine(proposta.fornitore_codice, proposta.ol_codart, proposta.ol_fase, proposta.ol_magaz);

        MrpApp.confermaOrdine(key, {
            fornitore_codice: proposta.fornitore_codice,
            fornitore_nome: proposta.fornitore_nome,
            ol_codart: proposta.ol_codart,
            ar_codalt: proposta.ar_codalt,
            ar_descr: proposta.ar_descr,
            ol_fase: proposta.ol_fase,
            ol_magaz: proposta.ol_magaz,
            ol_unmis: proposta.ol_unmis,
            ol_progr: proposta.ol_progr || 0,
        
escludiOrdineHandler function · javascript · L824-L854 (31 LOC)
gb2/js/gb2-progressivi.js
    function escludiOrdineHandler() {
        const proposta = MrpApp.state.propostaCorrente;
        if (!proposta) return;

        const key = MrpApp.getKeyOrdine(proposta.fornitore_codice, proposta.ol_codart, proposta.ol_fase, proposta.ol_magaz);

        MrpApp.confermaOrdine(key, {
            fornitore_codice: proposta.fornitore_codice,
            fornitore_nome: proposta.fornitore_nome,
            ol_codart: proposta.ol_codart,
            ar_codalt: proposta.ar_codalt,
            ar_descr: proposta.ar_descr,
            ol_fase: proposta.ol_fase,
            ol_magaz: proposta.ol_magaz,
            ol_unmis: proposta.ol_unmis,
            ol_progr: proposta.ol_progr || 0,
            quantita_confermata: 0,
            data_consegna: '',
            quantita_proposta: Number(proposta.ol_quant) || 0,
            prezzo: Number(proposta.ol_prezzo) || 0,
            escluso: true,
            timestamp_conferma: new Date().toISOString()
        });

        MrpApp.state.propos
skipOrdineHandler function · javascript · L856-L860 (5 LOC)
gb2/js/gb2-progressivi.js
    function skipOrdineHandler() {
        MrpApp.state.propostaCorrente = null;
        document.getElementById('panelDecisione').style.display = 'none';
        MrpApp.switchView('parametri');
    }
buildTreeItem function · javascript · L862-L1001 (140 LOC)
gb2/js/gb2-progressivi.js
    function buildTreeItem(articolo, mrpRows, livello) {
        const li = document.createElement('li');
        const nodeDiv = document.createElement('div');
        nodeDiv.className = 'tree-node';
        
        nodeDiv.dataset.codart = articolo.codart;
        nodeDiv.dataset.descr = articolo.descr || '';
        nodeDiv.dataset.livello = livello;
        
        // Icona + o spazio
        const toggleIcon = document.createElement('span');
        toggleIcon.className = 'tree-toggle-icon';
        if (articolo.espandibile) {
            toggleIcon.textContent = '▶';
            toggleIcon.style.cursor = 'pointer';
            
            toggleIcon.addEventListener('click', async (e) => {
                e.stopPropagation();
                const ul = li.querySelector('ul');
                if (toggleIcon.textContent === '▼') {
                    // Chiudi
                    toggleIcon.textContent = '▶';
                    ul.style.display = 'none';
                } else
caricaOrdiniSplitView function · javascript · L1003-L1058 (56 LOC)
gb2/js/gb2-progressivi.js
    async function caricaOrdiniSplitView(codart) {
        const card = document.getElementById('splitOrdiniCard');
        const tbody = document.getElementById('splitOrdiniBody');
        const countEl = document.getElementById('splitOrdiniCount');
        if (!card || !tbody) return;

        card.style.display = 'block';
        tbody.innerHTML = '<tr><td colspan="11" style="text-align:center;color:var(--text-muted);padding:12px;">Caricamento...</td></tr>';

        try {
            const params = new URLSearchParams({ codart });
            const res = await fetch(`${MrpApp.API_BASE}/ordini-dettaglio?${params}`, { credentials: 'include' });
            const data = await res.json();

            if (!res.ok || data.length === 0) {
                tbody.innerHTML = '<tr><td colspan="11" style="text-align:center;color:var(--text-muted);padding:16px;">Nessun ordine/impegno attivo</td></tr>';
                if (countEl) countEl.textContent = '';
                return;
            }
updateSplitMrpGrid function · javascript · L1060-L1110 (51 LOC)
gb2/js/gb2-progressivi.js
    function updateSplitMrpGrid(mrpRows, sostData) {
        const bodyEl = document.getElementById('splitMrpBody');
        if (!bodyEl) return;

        if (!sostData) {
            bodyEl.innerHTML = nestedTbodyFromMrp(mrpRows, { emptyMode: mrpRows.length ? 'none' : 'fetched-empty' });
            return;
        }

        let html = '';
        html += splitMrpSectionHeader(
            `<span style="font-weight:700;padding:8px;display:block;background:#fff3e0;">📦 Articolo in esaurimento</span>`,
            'mrp-blocco-esaurimento'
        );
        html += nestedTbodyFromMrp(mrpRows, { emptyMode: mrpRows.length ? 'none' : 'fetched-empty' });

        const h = sostData.header || {};
        html += splitMrpSectionHeader(
            `<span style="font-weight:700;padding:8px;display:block;background:#e8f5e9;">🔄 Sostitutivo: ${esc(h.descr || '')} (${esc(h.codart || '')})</span>`,
            'mrp-blocco-sostitutivo'
        );
        html += nestedTbodyFromMrp(sostData.mrp || []
dispNettaMrpRow function · javascript · L1113-L1119 (7 LOC)
gb2/js/gb2-progressivi.js
    function dispNettaMrpRow(r) {
        const d = r.disponibilita || 0;
        const opc = r.opc || 0;
        const ipc = r.ipc || 0;
        const ip = r.ip || 0;
        return d + opc - ipc - ip;
    }
calcolaTotaliMrp function · javascript · L1121-L1144 (24 LOC)
gb2/js/gb2-progressivi.js
    function calcolaTotaliMrp(mrpRows) {
        let esistenza = 0;
        let ordinato = 0;
        let impegnato = 0;
        let disponibilita = 0;
        let opc = 0;
        let op = 0;
        let ipc = 0;
        let ip = 0;
        const crossFase = mrpRows.filter(r => r.tipo === 'totale-cross-fase');
        const source = crossFase.length > 0 ? crossFase : mrpRows.filter(r => r.tipo === 'totale');
        source.forEach(t => {
            esistenza += (t.esistenza || 0);
            ordinato += (t.ordinato || 0);
            impegnato += (t.impegnato || 0);
            disponibilita += (t.disponibilita || 0);
            opc += (t.opc || 0);
            op += (t.op || 0);
            ipc += (t.ipc || 0);
            ip += (t.ip || 0);
        });
        const dispNetta = disponibilita + opc - ipc - ip;
        return { esistenza, ordinato, impegnato, disponibilita, opc, op, ipc, ip, dispNetta };
    }
Citation: Repobility (2026). State of AI-Generated Code. https://repobility.com/research/
applyTotaliToArticoloRow function · javascript · L1146-L1158 (13 LOC)
gb2/js/gb2-progressivi.js
    function applyTotaliToArticoloRow(tr, mrpRows) {
        const tot = calcolaTotaliMrp(mrpRows);
        const cellE = tr.querySelector('.cell-esistenza');
        const cellO = tr.querySelector('.cell-ordinato');
        const cellI = tr.querySelector('.cell-impegnato');
        if (cellE) cellE.textContent = fmt(tot.esistenza);
        if (cellO) cellO.textContent = fmt(tot.ordinato);
        if (cellI) cellI.textContent = fmt(tot.impegnato);
        const cellDisp = tr.querySelector('.cell-disponibilita');
        if (cellDisp) cellDisp.textContent = fmt(tot.disponibilita);
        const cellNet = tr.querySelector('.cell-disp-netta');
        if (cellNet) cellNet.textContent = fmt(tot.dispNetta);
    }
isScaduto function · javascript · L1160-L1162 (3 LOC)
gb2/js/gb2-progressivi.js
    function isScaduto(a) {
        return a.tipo === 'componente' && (a.scaduto === 1 || a.scaduto === true);
    }
createArticoloPair function · javascript · L1164-L1242 (79 LOC)
gb2/js/gb2-progressivi.js
    function createArticoloPair(articolo, mrpRows, ctx) {
        const { rowNum, bomParentCodart, livello, isRoot, soloFlatMrp, mrpPreFetched } = ctx;
        const liv = livello != null ? livello : 0;

        const tr = document.createElement('tr');
        tr.className = 'mrp-row-articolo';
        if (isScaduto(articolo)) tr.classList.add('row-scaduto');
        if (isRoot) tr.dataset.isRoot = '1';

        tr.dataset.codart = articolo.codart;
        tr.dataset.livello = String(liv);
        tr.dataset.espandibile = articolo.espandibile ? '1' : '0';
        if (bomParentCodart) tr.dataset.bomParent = bomParentCodart;

        const btnEspandi = (isRoot || soloFlatMrp) ? '' : '<button type="button" class="btn-matrioska toggle-matrioska">Espandi ▼</button>';
        const scadutoBadge = isScaduto(articolo) ? '<span class="scaduto-badge">SCADUTO</span>' : '';
        const descrStrong = (articolo.tipo === 'padre' || articolo.tipo === 'sostitutivo-header' || isRoot)
            ? `<s
rigaArticoloHTML function · javascript · L1244-L1275 (32 LOC)
gb2/js/gb2-progressivi.js
    function rigaArticoloHTML(num, parteCell, articolo, totali) {
        const faseD = articolo.tipo === 'componente' && articolo.faseDistinta != null && articolo.faseDistinta !== ''
            ? esc(String(articolo.faseDistinta))
            : '';
        const pol = articolo.polriord != null ? esc(String(articolo.polriord)) : '';
        const um = esc(articolo.um || 'PZ');

        const txtEsist = totali ? fmt(totali.esistenza) : '';
        const txtOrd = totali ? fmt(totali.ordinato) : '';
        const txtImp = totali ? fmt(totali.impegnato) : '';
        const txtDisp = totali ? fmt(totali.disponibilita) : '';
        const txtDispNetta = totali && totali.dispNetta != null ? fmt(totali.dispNetta) : '';

        return `
            <td class="col-row">${num}</td>
            <td class="col-parte">${parteCell}</td>
            <td class="col-mag"></td>
            <td class="col-fase">${faseD}</td>
            <td class="col-pol">${pol}</td>
            <td class="col-um">${um
nestedTbodyFromMrp function · javascript · L1277-L1359 (83 LOC)
gb2/js/gb2-progressivi.js
    function nestedTbodyFromMrp(rows, opts = {}) {
        const emptyMode = opts.emptyMode || (rows.length ? 'none' : 'awaiting');
        if (!rows.length) {
            const msg = emptyMode === 'fetched-empty'
                ? 'Nessun movimento magazzino'
                : 'Nessun dato magazzino (espandi per caricare)';
            return `<tr><td colspan="${MRP_COL_COUNT}" style="text-align:center;color:var(--text-muted);padding:12px;">${msg}</td></tr>`;
        }
        let html = '';
        for (const r of rows) {
            if (r.tipo === 'magazzino') {
                const dnet = dispNettaMrpRow(r);
                const bloc = classeBloccoMrp(r.etichettaBlocco);
                const clickMag = ' mrp-nested-mag-click';
                let cls = (r.inesaur === 'S' ? 'row-magazzino row-esaurito' : 'row-magazzino') + clickMag;
                if (bloc) cls += ` ${bloc}`;
                const showG = r.mostraGiacenze !== false;
                const cellEs = showG && r.esis
renderFlatMrp function · javascript · L1361-L1441 (81 LOC)
gb2/js/gb2-progressivi.js
    function renderFlatMrp(mrpRows) {
        let html = '';
        for (const r of mrpRows) {
            if (r.tipo === 'magazzino') {
                const dnet = dispNettaMrpRow(r);
                const bloc = classeBloccoMrp(r.etichettaBlocco);
                const clickMag = ' mrp-nested-mag-click';
                let cls = (r.inesaur === 'S' ? 'row-magazzino row-esaurito' : 'row-magazzino') + clickMag;
                if (bloc) cls += ` ${bloc}`;
                const showG = r.mostraGiacenze !== false;
                const dispStyle = showG && r.disponibilita != null ? 'font-weight:bold;' : '';
                html += `<tr class="${cls}" data-codart="${esc(r.codart)}" data-magaz="${esc(r.magaz)}" data-fase="${esc(r.fase)}">
                    <td class="col-row"></td>
                    <td class="col-parte" style="padding-left:30px; color:var(--text-muted);">${esc(r.codart)}</td>
                    <td class="col-mag">${esc(r.magaz)}</td>
                    <td class=
fillNestedTbody function · javascript · L1443-L1447 (5 LOC)
gb2/js/gb2-progressivi.js
    function fillNestedTbody(tbody, mrpRows) {
        if (!tbody) return;
        const emptyMode = mrpRows.length ? 'none' : 'fetched-empty';
        tbody.innerHTML = nestedTbodyFromMrp(mrpRows, { emptyMode });
    }
childPairExistsIn function · javascript · L1449-L1454 (6 LOC)
gb2/js/gb2-progressivi.js
    function childPairExistsIn(bomTbody, parentCodart, childCodart) {
        if (!bomTbody) return false;
        return [...bomTbody.querySelectorAll('tr.mrp-row-articolo')].some(
            tr => tr.dataset.bomParent === parentCodart && tr.dataset.codart === childCodart
        );
    }
Provenance: Repobility (https://repobility.com) — every score reproducible from /scan/
appendBomChildrenTo function · javascript · L1459-L1480 (22 LOC)
gb2/js/gb2-progressivi.js
    function appendBomChildrenTo(bomTbody, parentCodart, components, { hide }) {
        if (!bomTbody || !components.length) {
            renumberRows();
            return;
        }
        for (const c of components) {
            if (childPairExistsIn(bomTbody, parentCodart, c.codart)) continue;
            const livello = c.livello != null ? c.livello : 1;
            const { articleTr, nestedTr } = createArticoloPair(c, [], {
                rowNum: '',
                bomParentCodart: parentCodart,
                livello
            });
            bomTbody.appendChild(articleTr);
            bomTbody.appendChild(nestedTr);
            if (hide) {
                articleTr.style.display = 'none';
                nestedTr.style.display = 'none';
            }
        }
        renumberRows();
    }
renumberRows function · javascript · L1482-L1490 (9 LOC)
gb2/js/gb2-progressivi.js
    function renumberRows() {
        const tbl = document.getElementById('tblProgressivi');
        if (!tbl) return;
        let n = 1;
        for (const tr of tbl.querySelectorAll('tr.mrp-row-articolo')) {
            const cell = tr.querySelector('td.col-row');
            if (cell) cell.textContent = String(n++);
        }
    }
isMatrioskaOpen function · javascript · L1492-L1494 (3 LOC)
gb2/js/gb2-progressivi.js
    function isMatrioskaOpen(nestedTr) {
        return nestedTr && nestedTr.style.display === 'table-row';
    }
handleToggleMatrioska function · javascript · L1496-L1540 (45 LOC)
gb2/js/gb2-progressivi.js
    async function handleToggleMatrioska(btn) {
        const tr = btn.closest('tr.mrp-row-articolo');
        if (!tr) return;
        const nestedTr = tr.nextElementSibling;
        if (!nestedTr || !nestedTr.classList.contains('matrioska-nested-row')) return;

        const codart = tr.dataset.codart;
        const livello = parseInt(tr.dataset.livello || '0', 10);
        const mrpInner = nestedTr.querySelector('.mrp-nested-tbody');
        const bomInner = nestedTr.querySelector('.bom-nested-tbody');

        if (isMatrioskaOpen(nestedTr)) {
            nestedTr.style.display = 'none';
            btn.textContent = 'Espandi ▼';
            return;
        }

        if (expandFetched[codart]) {
            nestedTr.style.display = 'table-row';
            btn.textContent = 'Chiudi ▲';
            return;
        }

        const prevLabel = btn.textContent;
        btn.disabled = true;
        btn.textContent = '⏳';
        try {
            const { mrp, components } = await fetch
setActiveTab function · javascript · L1542-L1546 (5 LOC)
gb2/js/gb2-progressivi.js
    function setActiveTab(tabId) {
        document.querySelectorAll('.modal-ordini-tabs .modal-tab').forEach(t => t.classList.remove('active'));
        const tab = document.getElementById(tabId);
        if (tab) tab.classList.add('active');
    }
apriModaleOrdini function · javascript · L1548-L1572 (25 LOC)
gb2/js/gb2-progressivi.js
    async function apriModaleOrdini(codart, magaz, fase, descMagazzino) {
        const overlay = document.getElementById('modalOrdiniOverlay');
        const btnBack = document.getElementById('modalOrdiniBtnBack');
        const filtroToggle = document.getElementById('modalFiltroMagToggle');
        const filtroLabel = document.getElementById('modalFiltroMagLabel');
        const filtroText = document.getElementById('modalFiltroMagText');

        currentModalContext = { codart, magaz, fase, descMagazzino: descMagazzino || '' };

        if (btnBack) btnBack.style.display = 'none';
        if (filtroLabel) filtroLabel.style.display = 'flex';
        ripristinaHeaderModale();
        setActiveTab('modalTabOrdini');

        if (filtroToggle) filtroToggle.checked = false;
        if (filtroText) {
            filtroText.textContent = descMagazzino
                ? `Solo ${descMagazzino}`
                : `Solo Mag. ${magaz || '?'}`;
        }

        overlay.classList.add('open');

 
caricaOrdiniModale function · javascript · L1574-L1665 (92 LOC)
gb2/js/gb2-progressivi.js
    async function caricaOrdiniModale(codart, magaz, fase) {
        const tbody = document.getElementById('modalOrdiniBody');
        const loading = document.getElementById('modalOrdiniLoading');
        const titolo = document.getElementById('modalOrdiniTitolo');

        const codartList = splitCodartComposito(codart);
        const titoloCod = codartList.length > 1 ? codartList.join(' + ') : codart;

        tbody.innerHTML = '';
        loading.style.display = 'block';
        titolo.textContent = `Ordini/Impegni: ${titoloCod} — ${magaz ? 'Mag ' + magaz : 'Tutti i magazzini'}${fase ? ', Fase ' + fase : ''}`;

        try {
            let data;
            let anyErr = null;
            if (codartList.length > 1) {
                const chunks = await Promise.all(codartList.map(async (cod) => {
                    const params = new URLSearchParams({ codart: cod });
                    if (magaz) params.set('magaz', magaz);
                    if (fase) params.set('fase', fase);
caricaRmpModale function · javascript · L1667-L1750 (84 LOC)
gb2/js/gb2-progressivi.js
    async function caricaRmpModale(codart, fase) {
        const tbody = document.getElementById('modalOrdiniBody');
        const loading = document.getElementById('modalOrdiniLoading');
        const titolo = document.getElementById('modalOrdiniTitolo');

        const codartList = splitCodartComposito(codart);
        const titoloCod = codartList.length > 1 ? codartList.join(' + ') : codart;
        titolo.textContent = `RMP (Generati/Confermati): ${titoloCod}`;

        const thead = document.querySelector('#tblModalOrdini thead tr');
        if (thead) {
            thead.innerHTML = `
                <th>Mag</th>
                <th>Fase</th>
                <th>Data Cons.</th>
                <th>Operazione</th>
                <th>Q.tà Ordinata</th>
                <th>Stato</th>
                <th>Fornitore</th>
            `;
        }

        tbody.innerHTML = '';
        loading.style.display = 'block';

        try {
            const allData = await Promise.all(codartLi
Repobility — same analyzer, your code, free for public repos · /scan/
apriDrillPadre function · javascript · L1752-L1828 (77 LOC)
gb2/js/gb2-progressivi.js
    async function apriDrillPadre(codart, magaz, fase) {
        const tbody = document.getElementById('modalOrdiniBody');
        const loading = document.getElementById('modalOrdiniLoading');
        const titolo = document.getElementById('modalOrdiniTitolo');
        const btnBack = document.getElementById('modalOrdiniBtnBack');
        const filtroLabel = document.getElementById('modalFiltroMagLabel');

        if (btnBack) btnBack.style.display = 'inline-flex';
        if (filtroLabel) filtroLabel.style.display = 'none';
        titolo.textContent = `Produzione che consuma: ${codart} — Mag: ${magaz || 'Tutti'}`;

        const thead = document.querySelector('#tblModalOrdini thead tr');
        if (thead) {
            thead.innerHTML = `
            <th style="width:30px;"></th>
            <th>Operazione</th>
            <th>Anno</th>
            <th>Ser</th>
            <th>Num.Doc</th>
            <th>Riga</th>
            <th>Cod. Art. Padre</th>
            <th>Descrizione Ar
apriDrillPadreRmp function · javascript · L1830-L1903 (74 LOC)
gb2/js/gb2-progressivi.js
    async function apriDrillPadreRmp(codart, magaz, fase) {
        const tbody = document.getElementById('modalOrdiniBody');
        const loading = document.getElementById('modalOrdiniLoading');
        const titolo = document.getElementById('modalOrdiniTitolo');
        const btnBack = document.getElementById('modalOrdiniBtnBack');
        const filtroLabel = document.getElementById('modalFiltroMagLabel');

        if (btnBack) btnBack.style.display = 'inline-flex';
        if (filtroLabel) filtroLabel.style.display = 'none';
        titolo.textContent = `Produzione che consuma: ${codart} — Mag: ${magaz || 'Tutti'}`;

        const thead = document.querySelector('#tblModalOrdini thead tr');
        if (thead) {
            thead.innerHTML = `
            <th>Cod. Art.</th>
            <th>Mag</th>
            <th>Fase</th>
            <th>Descrizione Articolo</th>
            <th>Data Cons.</th>
            <th>Operazione</th>
            <th>Q.tà Ordinata</th>
            <th>Stato
ripristinaHeaderModale function · javascript · L1905-L1923 (19 LOC)
gb2/js/gb2-progressivi.js
    function ripristinaHeaderModale() {
        const thead = document.querySelector('#tblModalOrdini thead tr');
        if (!thead) return;
        thead.innerHTML = `
            <th style="width:30px;"></th>
            <th>Operazione</th>
            <th>Anno</th>
            <th>Ser</th>
            <th>Num.Doc</th>
            <th>Riga</th>
            <th>Mag</th>
            <th>Fase</th>
            <th>Data Cons.</th>
            <th>Q.tà Ordinata</th>
            <th>Q.tà Evasa</th>
            <th>Stato</th>
            <th>Fornitore</th>
        `;
    }
‹ prevpage 3 / 6next ›