105 lines
4.0 KiB
PHP
105 lines
4.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Questo file riceve la variabile $r dal file principale
|
|
* e stampa una singola card di produzione.
|
|
*
|
|
* Variabili già presenti in scope:
|
|
* - $statusProduzioneId
|
|
* - $statusPausaId
|
|
*/
|
|
|
|
$isInProduction = $r['id_status'] == $statusProduzioneId;
|
|
$isPaused = $r['id_status'] == $statusPausaId;
|
|
|
|
$dataZibo = ($r['data_zibo'] && $r['data_zibo'] !== '0000-00-00')
|
|
? date('d/m/Y', strtotime($r['data_zibo']))
|
|
: '-';
|
|
|
|
$dataCliente = ($r['data_cliente'] && $r['data_cliente'] !== '0000-00-00')
|
|
? date('d/m/Y', strtotime($r['data_cliente']))
|
|
: '-';
|
|
|
|
$totalSeconds = (int)($r['tempo_totale_produzione'] ?? 0);
|
|
|
|
/**
|
|
* Calcolo startTime:
|
|
* - Se in produzione: usa data_avvio
|
|
* - Se in pausa: NON incrementa timer, JS se ne accorge
|
|
* - Se programmato: usa Data (data pianificazione)
|
|
*/
|
|
$startTime = ($isInProduction || $isPaused)
|
|
&& !empty($r['data_avvio'])
|
|
&& $r['data_avvio'] !== '0000-00-00 00:00:00'
|
|
? strtotime($r['data_avvio'] . ' UTC')
|
|
: strtotime($r['Data'] . ' UTC');
|
|
|
|
$badgeColor = $r['badge_color'] ?? '#6c757d';
|
|
$lineColor = $r['line_color'] ?? '#e9ecef';
|
|
$statusNome = $r['status_nome'];
|
|
?>
|
|
|
|
<div class="record-card <?= $isInProduction || $isPaused ? 'in-production expanded' : 'programmed' ?>"
|
|
data-id="<?= $r['id'] ?>"
|
|
data-total-seconds="<?= $totalSeconds ?>"
|
|
data-kgsp="<?= htmlspecialchars($r['kg_sp']) ?>"
|
|
data-metri="<?= htmlspecialchars($r['metri']) ?>"
|
|
style="--line-bg: <?= $lineColor ?>; --badge-bg: <?= $badgeColor ?>;">
|
|
|
|
<!-- RIGA VISIBILE -->
|
|
<div class="record-summary">
|
|
<div class="summary-grid">
|
|
<div><strong>Linea</strong> <span><?= htmlspecialchars($r['linea']) ?></span></div>
|
|
<div><strong>Matrice</strong> <span><?= htmlspecialchars($r['matrice']) ?></span></div>
|
|
<div><strong>Mescola</strong> <span><?= htmlspecialchars($r['mescola']) ?></span></div>
|
|
<div><strong>Cliente</strong> <span><?= htmlspecialchars($r['cliente'] ?? '-') ?></span></div>
|
|
<div><strong>Zibo</strong> <span><?= $dataZibo ?></span></div>
|
|
<div><strong>Data Cl.</strong> <span><?= $dataCliente ?></span></div>
|
|
<div><strong>Metri</strong> <span><?= number_format($r['metri'], 2) ?></span></div>
|
|
<div><strong>Ore</strong> <span><?= number_format($r['ore_previste'], 1) ?></span></div>
|
|
</div>
|
|
|
|
<div class="status-badge" style="background: var(--badge-bg);">
|
|
<?= strtoupper($statusNome) ?>
|
|
<?php if ($isInProduction || $isPaused): ?>
|
|
<i class="bi bi-chevron-down expand-arrow"></i>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- RIGA ESPANSA -->
|
|
<div class="record-expanded">
|
|
<?php if ($isInProduction || $isPaused): ?>
|
|
|
|
<div class="timer-display" data-start="<?= $startTime ?>">
|
|
<span class="timer">00:00:00</span>
|
|
</div>
|
|
|
|
<!-- Teorici nascosti (per modale finale) -->
|
|
<span data-field="kg_sp" style="display:none;"><?= $r['kg_sp'] ?></span>
|
|
<span data-field="metri" style="display:none;"><?= $r['metri'] ?></span>
|
|
|
|
<div class="action-buttons">
|
|
<?php if ($isInProduction): ?>
|
|
<button class="action-btn pause-btn" data-id="<?= $r['id'] ?>">PAUSA</button>
|
|
<button class="action-btn stop-btn" data-id="<?= $r['id'] ?>">STOP</button>
|
|
<?php elseif ($isPaused): ?>
|
|
<button class="action-btn resume-btn" data-id="<?= $r['id'] ?>">RIPRENDI</button>
|
|
<button class="action-btn stop-btn" data-id="<?= $r['id'] ?>">STOP</button>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php if (in_array($r['id_status'], [2, 7])): // 2 produzione, 7 pausa
|
|
?>
|
|
<?php include __DIR__ . "/components/photo_buttons.php"; ?>
|
|
<?php endif; ?>
|
|
|
|
|
|
<?php else: ?>
|
|
|
|
<button class="action-btn start-btn" data-id="<?= $r['id'] ?>">AVVIA PRODUZIONE</button>
|
|
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
</div>
|