tested component fixed
This commit is contained in:
parent
66be442eb6
commit
fa7997c980
@ -395,7 +395,12 @@
|
||||
|
||||
case "tested_component":
|
||||
div.style.overflow = "visible";
|
||||
div.innerHTML = `<div style="display:flex; align-items:center; gap:4px; width:100%; height:100%;"><input type="text" class="cell-input manual-input" style="flex:1; min-width:0; height:28px;"><button type="button" class="add-part-btn btn btn-sm btn-primary" data-row="${rowIndex}" data-iddatadb="${row.iddatadb}" style="display:inline-flex; align-items:center; justify-content:center; min-width:28px; width:28px; height:28px; padding:0; font-size:12px; flex-shrink:0; text-align:center;"><i class="fas fa-plus" style="margin:0; padding:0;"></i></button></div>`;
|
||||
div.innerHTML = `<div style="display:flex; align-items:center; gap:4px; width:100%; height:100%;">
|
||||
<input type="text" class="cell-input manual-input tested-component-input" value="${esc(row.tested_component || "")}" style="flex:1; min-width:0; height:28px;">
|
||||
<button type="button" class="add-part-btn btn btn-sm btn-primary" data-row="${rowIndex}" data-iddatadb="${row.iddatadb}" style="display:inline-flex; align-items:center; justify-content:center; min-width:28px; width:28px; height:28px; padding:0; font-size:12px; flex-shrink:0; text-align:center;">
|
||||
<i class="fas fa-plus" style="margin:0; padding:0;"></i>
|
||||
</button>
|
||||
</div>`;
|
||||
break;
|
||||
|
||||
case "awb":
|
||||
@ -890,6 +895,9 @@
|
||||
rowIndex,
|
||||
value,
|
||||
);
|
||||
} else if (colType === "tested_component") {
|
||||
data[rowIndex].tested_component = value;
|
||||
data[rowIndex]._dirty = true;
|
||||
}
|
||||
|
||||
// Visual feedback
|
||||
@ -897,6 +905,44 @@
|
||||
updateDirtyIndicator();
|
||||
});
|
||||
|
||||
rowContainer.addEventListener("input", function (e) {
|
||||
const cell = e.target.closest(".grid-cell");
|
||||
if (!cell || !cell.dataset.row) return;
|
||||
|
||||
const rowIndex = parseInt(cell.dataset.row, 10);
|
||||
const colType = cell.dataset.colType;
|
||||
|
||||
if (colType === "tested_component") {
|
||||
data[rowIndex].tested_component = e.target.value;
|
||||
data[rowIndex]._dirty = true;
|
||||
cell.classList.add("cell-changed");
|
||||
updateDirtyIndicator();
|
||||
}
|
||||
});
|
||||
|
||||
// Persist tested_component before clicking +
|
||||
document.addEventListener("mousedown", function (e) {
|
||||
const btn = e.target.closest(".add-part-btn");
|
||||
if (!btn) return;
|
||||
|
||||
const rowIndex = parseInt(btn.dataset.row, 10);
|
||||
if (isNaN(rowIndex) || !data[rowIndex]) return;
|
||||
|
||||
const rowEl = btn.closest(".grid-row");
|
||||
if (!rowEl) return;
|
||||
|
||||
const testedInput = rowEl.querySelector(".tested-component-input");
|
||||
if (!testedInput) return;
|
||||
|
||||
data[rowIndex].tested_component = testedInput.value || "";
|
||||
data[rowIndex]._dirty = true;
|
||||
|
||||
const cell = testedInput.closest(".grid-cell");
|
||||
if (cell) cell.classList.add("cell-changed");
|
||||
|
||||
updateDirtyIndicator();
|
||||
});
|
||||
|
||||
// Propagate buttons
|
||||
document.addEventListener("click", function (e) {
|
||||
const btn = e.target.closest(".propagate-btn");
|
||||
@ -1045,6 +1091,7 @@
|
||||
// Client
|
||||
if (row.idclient) formData.append("idclient", row.idclient);
|
||||
formData.append("cliente_fornitore_id", row.cliente_fornitore_id || "");
|
||||
formData.append("tested_component", row.tested_component || "");
|
||||
|
||||
// Fixed fields → real column names
|
||||
const aliasMap = meta.fixedAliasMap || {};
|
||||
|
||||
@ -202,13 +202,13 @@ foreach ($importedData as $index => $row) {
|
||||
'status' => $row['status'] ?? 'i',
|
||||
'idclient' => $row['idclient'] ?? $default_idclient,
|
||||
'cliente_fornitore_id' => $row['cliente_fornitore_id'] ?? null,
|
||||
'tested_component' => $row['tested_component'] ?? '',
|
||||
'commessaweb' => $row['commessaweb'] ?? null,
|
||||
'user_name' => $row['user_name'] ?? '',
|
||||
'importreferencecode' => $row['importreferencecode'] ?? '',
|
||||
'filename_import' => $row['filename_import'] ?? '',
|
||||
'importdate' => $row['importdate'] ?? '',
|
||||
];
|
||||
|
||||
// Fixed fields
|
||||
$rowObj['fixedFields'] = [];
|
||||
foreach ($fixedFields as $f) {
|
||||
@ -267,7 +267,12 @@ $gridColumns[] = ['type' => 'cliente_fornitore_id', 'key' => 'cliente_fornitore_
|
||||
|
||||
// 5. Auto fields
|
||||
foreach ($allMappings as $mapping) {
|
||||
if (!$mapping['is_manual'] && $mapping['main_field'] != 1 && $mapping['is_visible_import'] == 1) {
|
||||
if (
|
||||
!$mapping['is_manual']
|
||||
&& $mapping['main_field'] != 1
|
||||
&& $mapping['is_visible_import'] == 1
|
||||
&& trim((string)$mapping['field_label']) !== 'Tested Component:'
|
||||
) {
|
||||
$gridColumns[] = [
|
||||
'type' => 'detail',
|
||||
'key' => (string)$mapping['id'],
|
||||
@ -284,7 +289,12 @@ foreach ($allMappings as $mapping) {
|
||||
|
||||
// 6. Manual fields
|
||||
foreach ($allMappings as $mapping) {
|
||||
if ($mapping['is_manual'] && $mapping['main_field'] != 1 && $mapping['is_visible_import'] == 1) {
|
||||
if (
|
||||
$mapping['is_manual']
|
||||
&& $mapping['main_field'] != 1
|
||||
&& $mapping['is_visible_import'] == 1
|
||||
&& trim((string)$mapping['field_label']) !== 'Tested Component:'
|
||||
) {
|
||||
$gridColumns[] = [
|
||||
'type' => 'detail',
|
||||
'key' => (string)$mapping['id'],
|
||||
|
||||
@ -121,8 +121,14 @@
|
||||
body: formData,
|
||||
});
|
||||
}
|
||||
|
||||
if (row) {
|
||||
row.tested_component = raw;
|
||||
row._dirty = true;
|
||||
}
|
||||
|
||||
alert(`Added ${uniqueParts.length} part(s).`);
|
||||
$input.val("");
|
||||
$input.val(raw);
|
||||
} catch (e) {
|
||||
alert("Error: " + e.message);
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ try {
|
||||
$iddatadb = intval($_POST['iddatadb']);
|
||||
$idclient = isset($_POST['idclient']) ? (is_numeric($_POST['idclient']) ? intval($_POST['idclient']) : null) : null;
|
||||
$clienteFornitoreId = isset($_POST['cliente_fornitore_id']) ? (is_numeric($_POST['cliente_fornitore_id']) ? intval($_POST['cliente_fornitore_id']) : null) : null;
|
||||
|
||||
$testedComponent = isset($_POST['tested_component']) ? trim((string)$_POST['tested_component']) : null;
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
$pdo = $db->getConnection();
|
||||
|
||||
@ -144,7 +144,11 @@ try {
|
||||
$setParts[] = "cliente_fornitore_id = ?";
|
||||
$params[] = $clienteFornitoreId;
|
||||
}
|
||||
|
||||
// 5a3) tested_component (se presente)
|
||||
if (isset($testedComponent)) {
|
||||
$setParts[] = "tested_component = ?";
|
||||
$params[] = ($testedComponent === '') ? null : $testedComponent;
|
||||
}
|
||||
// 5b) fixed fields dal POST
|
||||
// QUI è il punto chiave: accettiamo SOLO colonne reali (realWhitelist),
|
||||
// ma se dal JS arrivassero ancora key logiche, funzionerebbe uguale
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user