304 lines
15 KiB
PHP
304 lines
15 KiB
PHP
<?php
|
|
include('include/headscript.php');
|
|
|
|
$iddatadb = isset($_GET['iddatadb']) ? (int)$_GET['iddatadb'] : 0;
|
|
|
|
if ($iddatadb <= 0) {
|
|
?>
|
|
<div class="modal fade" id="analysisModal" tabindex="-1" aria-hidden="true">
|
|
<div class="modal-dialog modal-fullscreen">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">Analysis</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="alert alert-danger mb-0">Invalid iddatadb</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
exit;
|
|
}
|
|
|
|
$db = DBHandlerSelect::getInstance();
|
|
$pdo = $db->getConnection();
|
|
|
|
$stmt = $pdo->prepare("
|
|
SELECT
|
|
p.id,
|
|
p.iddatadb,
|
|
p.part_number,
|
|
p.part_description,
|
|
p.material,
|
|
p.color,
|
|
p.mix,
|
|
p.idmatrice,
|
|
p.note,
|
|
p.dateexpiry,
|
|
a.NomeMatriceTraduzione
|
|
FROM identification_parts p
|
|
LEFT JOIN auth_matrici a ON a.IdMatrice = p.idmatrice
|
|
WHERE p.iddatadb = ?
|
|
ORDER BY
|
|
CASE WHEN p.part_number IS NULL THEN 999999 ELSE p.part_number END ASC,
|
|
p.id ASC
|
|
");
|
|
$stmt->execute([$iddatadb]);
|
|
$parts = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
/**
|
|
* Build matrix groups from parts.
|
|
* No join for now: we use idmatrice only.
|
|
*/
|
|
$matrixGroups = [];
|
|
foreach ($parts as $part) {
|
|
$matrixKey = (!empty($part['idmatrice'])) ? (string)$part['idmatrice'] : 'NO_MATRIX';
|
|
|
|
if (!isset($matrixGroups[$matrixKey])) {
|
|
$matrixGroups[$matrixKey] = [
|
|
'idmatrice' => $part['idmatrice'],
|
|
'NomeMatriceTraduzione' => $part['NomeMatriceTraduzione'] ?? '',
|
|
'parts_count' => 0,
|
|
'parts' => [],
|
|
];
|
|
}
|
|
|
|
$matrixGroups[$matrixKey]['parts_count']++;
|
|
$matrixGroups[$matrixKey]['parts'][] = $part['id'];
|
|
}
|
|
|
|
$matrixGroups = array_values($matrixGroups);
|
|
?>
|
|
|
|
<div class="modal fade" id="analysisModal" tabindex="-1" aria-labelledby="analysisModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog" style="max-width: 96vw; width: 96vw; margin: 1.5vh auto;">
|
|
<div class="modal-content analysis-modal-content">
|
|
<div class="modal-header">
|
|
<div>
|
|
<h5 class="modal-title mb-0" id="analysisModalLabel">Analysis - TRF <?= htmlspecialchars((string)$iddatadb, ENT_QUOTES, 'UTF-8') ?></h5>
|
|
<small class="text-muted">
|
|
Parts: <?= count($parts) ?> |
|
|
Matrices: <?= count($matrixGroups) ?>
|
|
</small>
|
|
</div>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
|
|
<div class="modal-body analysis-modal-body">
|
|
<div class="row g-3 h-100">
|
|
<!-- MATRICES -->
|
|
<div class="col-lg-3 col-md-4">
|
|
<div class="card h-100 shadow-sm">
|
|
<div class="card-header py-2 d-flex justify-content-between align-items-center">
|
|
<strong>Matrices</strong>
|
|
<span class="badge bg-secondary"><?= count($matrixGroups) ?></span>
|
|
</div>
|
|
<div class="card-body p-2 analysis-scroll-area">
|
|
<div class="list-group analysis-matrix-list" id="analysisMatrixList">
|
|
<?php if (empty($matrixGroups)): ?>
|
|
<div class="text-muted small p-2">No matrices found</div>
|
|
<?php else: ?>
|
|
<?php foreach ($matrixGroups as $index => $group): ?>
|
|
<button type="button"
|
|
class="list-group-item list-group-item-action analysis-matrix-item <?= $index === 0 ? 'active' : '' ?>"
|
|
data-matrix-id="<?= htmlspecialchars((string)($group['idmatrice'] ?? 'NO_MATRIX'), ENT_QUOTES, 'UTF-8') ?>">
|
|
<div class="fw-semibold">
|
|
<?= htmlspecialchars(
|
|
!empty($group['NomeMatriceTraduzione'])
|
|
? $group['NomeMatriceTraduzione']
|
|
: (!empty($group['idmatrice']) ? ('Matrix without translation') : 'No Matrix'),
|
|
ENT_QUOTES,
|
|
'UTF-8'
|
|
) ?>
|
|
</div>
|
|
<div class="small text-muted">
|
|
ID: <?= !empty($group['idmatrice']) ? (int)$group['idmatrice'] : '-' ?>
|
|
</div>
|
|
<div class="small text-muted">
|
|
Parts linked: <?= (int)$group['parts_count'] ?>
|
|
</div>
|
|
</button>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- PARTS -->
|
|
<div class="col-lg-4 col-md-8">
|
|
<div class="card h-100 shadow-sm">
|
|
<div class="card-header py-2 d-flex justify-content-between align-items-center">
|
|
<strong>Parts</strong>
|
|
<div class="d-flex align-items-center gap-2">
|
|
<button type="button" class="btn btn-outline-secondary btn-sm" id="analysisClearSelectionBtn">Clear</button>
|
|
<span class="badge bg-primary" id="analysisSelectedPartsCount">0 selected</span>
|
|
</div>
|
|
</div>
|
|
<div class="card-body p-2 analysis-scroll-area">
|
|
<div class="list-group analysis-parts-list" id="analysisPartsList">
|
|
<?php if (empty($parts)): ?>
|
|
<div class="text-muted small p-2">No parts found</div>
|
|
<?php else: ?>
|
|
<?php foreach ($parts as $part): ?>
|
|
<?php
|
|
$matrixId = !empty($part['idmatrice']) ? (string)$part['idmatrice'] : 'NO_MATRIX';
|
|
$partLabel = trim(($part['part_number'] !== null ? ('Part ' . $part['part_number']) : 'Part') . ' - ' . ($part['part_description'] ?? ''));
|
|
?>
|
|
<div class="list-group-item analysis-part-item"
|
|
data-part-id="<?= (int)$part['id'] ?>"
|
|
data-matrix-id="<?= htmlspecialchars($matrixId, ENT_QUOTES, 'UTF-8') ?>">
|
|
<div class="d-flex align-items-start gap-2">
|
|
<input type="checkbox"
|
|
class="form-check-input mt-1 analysis-part-checkbox"
|
|
value="<?= (int)$part['id'] ?>">
|
|
<div class="flex-grow-1">
|
|
<div class="fw-semibold">
|
|
<?= htmlspecialchars($partLabel, ENT_QUOTES, 'UTF-8') ?>
|
|
</div>
|
|
|
|
<div class="small text-muted mt-1">
|
|
Matrix:
|
|
<strong>
|
|
<?= htmlspecialchars(
|
|
!empty($part['NomeMatriceTraduzione'])
|
|
? $part['NomeMatriceTraduzione']
|
|
: (!empty($part['idmatrice']) ? 'Matrix without translation' : 'No Matrix'),
|
|
ENT_QUOTES,
|
|
'UTF-8'
|
|
) ?>
|
|
</strong>
|
|
<?php if (!empty($part['idmatrice'])): ?>
|
|
<span class="small text-muted">(ID: <?= (int)$part['idmatrice'] ?>)</span>
|
|
<?php endif; ?>
|
|
<?php if (!empty($part['mix']) && strtoupper($part['mix']) === 'Y'): ?>
|
|
| <span class="badge bg-warning text-dark">Mix</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php if (!empty($part['material']) || !empty($part['color'])): ?>
|
|
<div class="small text-muted">
|
|
<?php if (!empty($part['material'])): ?>
|
|
Material: <?= htmlspecialchars($part['material'], ENT_QUOTES, 'UTF-8') ?>
|
|
<?php endif; ?>
|
|
<?php if (!empty($part['material']) && !empty($part['color'])): ?>
|
|
|
|
|
<?php endif; ?>
|
|
<?php if (!empty($part['color'])): ?>
|
|
Color: <?= htmlspecialchars($part['color'], ENT_QUOTES, 'UTF-8') ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($part['note'])): ?>
|
|
<div class="small text-muted mt-1">
|
|
Note: <?= htmlspecialchars($part['note'], ENT_QUOTES, 'UTF-8') ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ANALYSES PLACEHOLDER -->
|
|
<div class="col-lg-5">
|
|
<div class="card h-100 shadow-sm">
|
|
<div class="card-header py-2">
|
|
<strong>Analyses</strong>
|
|
</div>
|
|
<div class="card-body analysis-scroll-area" id="analysisRightPanel">
|
|
<div class="alert alert-info mb-3">
|
|
This area will contain analyses in the next step.
|
|
</div>
|
|
|
|
<div class="border rounded p-3 bg-light">
|
|
<div class="mb-2"><strong>Current behavior</strong></div>
|
|
<ul class="mb-0 ps-3">
|
|
<li>Click a matrix on the left</li>
|
|
<li>All parts linked to that matrix become selected</li>
|
|
<li>Analyses panel will be connected later</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="mt-3">
|
|
<div class="small text-muted">Selected matrix:</div>
|
|
<div id="analysisCurrentMatrix" class="fw-semibold">-</div>
|
|
</div>
|
|
|
|
<div class="mt-3">
|
|
<div class="small text-muted">Selected parts IDs:</div>
|
|
<div id="analysisSelectedPartsIds" class="fw-semibold">-</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<input type="hidden" id="analysisModalIddatadb" value="<?= (int)$iddatadb ?>">
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary btn-sm" data-bs-dismiss="modal">Close</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
#analysisModal {
|
|
z-index: 1080 !important;
|
|
}
|
|
|
|
#analysisModal .modal-content {
|
|
width: 100% !important;
|
|
max-width: 100% !important;
|
|
min-height: 95vh;
|
|
border-radius: 14px;
|
|
}
|
|
|
|
.analysis-modal-content {
|
|
overflow: hidden;
|
|
}
|
|
|
|
.analysis-modal-body {
|
|
height: calc(95vh - 120px);
|
|
}
|
|
|
|
.analysis-scroll-area {
|
|
overflow-y: auto;
|
|
max-height: calc(95vh - 180px);
|
|
}
|
|
|
|
.analysis-matrix-item {
|
|
text-align: left;
|
|
border-radius: 8px !important;
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.analysis-part-item {
|
|
border-radius: 8px !important;
|
|
margin-bottom: 8px;
|
|
transition: all 0.2s ease-in-out;
|
|
}
|
|
|
|
.analysis-part-item.matrix-active {
|
|
background-color: #e8f4ff !important;
|
|
border-color: #86b7fe !important;
|
|
}
|
|
|
|
.analysis-part-item.part-checked {
|
|
background-color: #eaf7ea !important;
|
|
border-color: #7ac77a !important;
|
|
}
|
|
|
|
#analysisSelectedPartsIds {
|
|
word-break: break-word;
|
|
}
|
|
</style>
|