import edit update
This commit is contained in:
parent
d8eca66747
commit
22e4e652b5
@ -31,6 +31,6 @@ Content-Length: 51
|
||||
< strict-transport-security: max-age=2592000
|
||||
< x-powered-by: ASP.NET
|
||||
< x-content-type-options: nosniff
|
||||
< date: Mon, 18 Aug 2025 13:57:11 GMT
|
||||
< date: Thu, 21 Aug 2025 10:23:44 GMT
|
||||
<
|
||||
* Connection #0 to host 93.43.5.102 left intact
|
||||
|
||||
@ -15,11 +15,11 @@
|
||||
* [HTTP/2] [1] [:scheme: https]
|
||||
* [HTTP/2] [1] [:authority: 93.43.5.102]
|
||||
* [HTTP/2] [1] [:path: /limsapi/api/odata/CustomField(1083)?$expand=CustomFieldsValues]
|
||||
* [HTTP/2] [1] [authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjQ5MiIsIlhhZlNlY3VyaXR5QXV0aFBhc3NlZCI6IlhhZlNlY3VyaXR5QXV0aFBhc3NlZCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJXZWJBcGlVc2VyIiwiWGFmU2VjdXJpdHkiOiJYYWZTZWN1cml0eSIsIlhhZkxvZ29uUGFyYW1zIjoicTFZS0xVNHQ4a3ZNVFZXeVVncFBUWElzeUFRSktPa29CU1FXRjVmbkY2VUF4Y3RUa3hJTE1rdUI0Z2FHU3JVQSIsImV4cCI6MTc1NTUzMjYzMiwiaXNzIjoiTXkiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.IaUi3N2ilMGCibN3wnBLWVut_PxznC6t9EfgCnLBJyI]
|
||||
* [HTTP/2] [1] [authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjQ5MiIsIlhhZlNlY3VyaXR5QXV0aFBhc3NlZCI6IlhhZlNlY3VyaXR5QXV0aFBhc3NlZCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJXZWJBcGlVc2VyIiwiWGFmU2VjdXJpdHkiOiJYYWZTZWN1cml0eSIsIlhhZkxvZ29uUGFyYW1zIjoicTFZS0xVNHQ4a3ZNVFZXeVVncFBUWElzeUFRSktPa29CU1FXRjVmbkY2VUF4Y3RUa3hJTE1rdUI0Z2FHU3JVQSIsImV4cCI6MTc1NTc3OTAyNSwiaXNzIjoiTXkiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.bBV1z1uaxZeUuw-2YS2gLGaxTCQJAHTieM82KVJb5nw]
|
||||
* [HTTP/2] [1] [accept: application/json]
|
||||
> GET /limsapi/api/odata/CustomField(1083)?$expand=CustomFieldsValues HTTP/2
|
||||
Host: 93.43.5.102
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjQ5MiIsIlhhZlNlY3VyaXR5QXV0aFBhc3NlZCI6IlhhZlNlY3VyaXR5QXV0aFBhc3NlZCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJXZWJBcGlVc2VyIiwiWGFmU2VjdXJpdHkiOiJYYWZTZWN1cml0eSIsIlhhZkxvZ29uUGFyYW1zIjoicTFZS0xVNHQ4a3ZNVFZXeVVncFBUWElzeUFRSktPa29CU1FXRjVmbkY2VUF4Y3RUa3hJTE1rdUI0Z2FHU3JVQSIsImV4cCI6MTc1NTUzMjYzMiwiaXNzIjoiTXkiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.IaUi3N2ilMGCibN3wnBLWVut_PxznC6t9EfgCnLBJyI
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjQ5MiIsIlhhZlNlY3VyaXR5QXV0aFBhc3NlZCI6IlhhZlNlY3VyaXR5QXV0aFBhc3NlZCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJXZWJBcGlVc2VyIiwiWGFmU2VjdXJpdHkiOiJYYWZTZWN1cml0eSIsIlhhZkxvZ29uUGFyYW1zIjoicTFZS0xVNHQ4a3ZNVFZXeVVncFBUWElzeUFRSktPa29CU1FXRjVmbkY2VUF4Y3RUa3hJTE1rdUI0Z2FHU3JVQSIsImV4cCI6MTc1NTc3OTAyNSwiaXNzIjoiTXkiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.bBV1z1uaxZeUuw-2YS2gLGaxTCQJAHTieM82KVJb5nw
|
||||
Accept: application/json
|
||||
|
||||
< HTTP/2 200
|
||||
@ -30,6 +30,6 @@ Accept: application/json
|
||||
< odata-version: 4.0
|
||||
< x-powered-by: ASP.NET
|
||||
< x-content-type-options: nosniff
|
||||
< date: Mon, 18 Aug 2025 13:57:11 GMT
|
||||
< date: Thu, 21 Aug 2025 10:23:44 GMT
|
||||
<
|
||||
* Connection #0 to host 93.43.5.102 left intact
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -40,7 +40,7 @@ $pdo = $db->getConnection();
|
||||
$importReferenceCode = date('YmdHis') . '-' . uniqid();
|
||||
|
||||
// Recupera tutti i mapping dal template
|
||||
$stmt = $pdo->prepare("SELECT id, excel_column, data_type, is_required, manual_default, is_manual, field_label, field_id FROM template_mapping WHERE template_id = ?");
|
||||
$stmt = $pdo->prepare("SELECT id, excel_column, data_type, is_required, manual_default, is_manual, field_label, field_id, main_field FROM template_mapping WHERE template_id = ?");
|
||||
$stmt->execute([$template_id]);
|
||||
$allMappings = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
@ -49,6 +49,15 @@ if (empty($allMappings)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Trova il campo main_field
|
||||
$mainFieldMapping = null;
|
||||
foreach ($allMappings as $mapping) {
|
||||
if ($mapping['main_field'] == 1) {
|
||||
$mainFieldMapping = $mapping;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Inserisci le righe selezionate in datadb (solo campi generici con templateid)
|
||||
$insertedIds = [];
|
||||
foreach ($selected_rows as $rowIndex) {
|
||||
@ -221,7 +230,8 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
.grid-header,
|
||||
.grid-cell {
|
||||
flex: 1;
|
||||
min-width: 100px;
|
||||
min-width: 70px;
|
||||
/* Ridotto da 100px per compatibilità con pulsanti */
|
||||
padding: 12px 15px;
|
||||
border-right: 1px solid #dee2e6;
|
||||
overflow: hidden;
|
||||
@ -397,6 +407,25 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
border-color: #80bdff;
|
||||
box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
|
||||
}
|
||||
|
||||
/* Sovrascrivi min-width per le celle dei pulsanti */
|
||||
.grid-cell.button-cell,
|
||||
.grid-header.button-header {
|
||||
min-width: 70px !important;
|
||||
flex: 0 0 70px !important;
|
||||
}
|
||||
|
||||
/* Stile per l'header dei pulsanti */
|
||||
.button-header {
|
||||
min-height: 48px;
|
||||
/* Altezza minima per uniformare */
|
||||
padding: 12px 0;
|
||||
/* Centra verticalmente, no padding orizzontale */
|
||||
background-color: #e9ecef !important;
|
||||
/* Grigio uniforme */
|
||||
border-right: 1px solid #dee2e6 !important;
|
||||
/* Bordo destro coerente */
|
||||
}
|
||||
</style>
|
||||
<title>Edit Imported Data - <?= htmlspecialchars($titlewebsite, ENT_QUOTES, 'UTF-8'); ?></title>
|
||||
</head>
|
||||
@ -427,19 +456,46 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
<div class="grid-container">
|
||||
<!-- Riga superiore per gli input dei campi manuali -->
|
||||
<div class="grid-top">
|
||||
<div class="grid-cell" style="flex: 0 0 100px;"></div> <!-- Save -->
|
||||
<div class="grid-cell" style="flex: 0 0 100px;"></div> <!-- Photos -->
|
||||
<div class="grid-cell" style="flex: 0 0 100px;"></div> <!-- Parts -->
|
||||
<div class="grid-cell button-cell" style="flex: 0 0 70px;"></div> <!-- Save -->
|
||||
<div class="grid-cell button-cell" style="flex: 0 0 70px;"></div> <!-- Photos -->
|
||||
<div class="grid-cell button-cell" style="flex: 0 0 70px;"></div> <!-- Parts -->
|
||||
<?php if ($mainFieldMapping): ?>
|
||||
<div class="grid-cell" style="flex: 0 0 150px;">
|
||||
<?php
|
||||
$fieldValue = $mainFieldMapping['manual_default'] ?? '';
|
||||
if ($mainFieldMapping['data_type'] === 'DATE' && $mainFieldMapping['manual_default'] === 'today') {
|
||||
$fieldValue = date('Y-m-d');
|
||||
}
|
||||
$inputClass = $mainFieldMapping['is_manual'] ? 'manual-input' : 'auto-input';
|
||||
if ($mainFieldMapping['is_required']) $inputClass .= ' required-input';
|
||||
if ($mainFieldMapping['data_type'] === 'SceltaMultipla') {
|
||||
echo "<select class='custom-field dropdown-select $inputClass' data-column='main_field' data-field-id='{$mainFieldMapping['field_id']}' " . ($mainFieldMapping['is_required'] ? 'required' : '') . ">";
|
||||
echo "<option value=''>Seleziona...</option>";
|
||||
echo "</select>";
|
||||
echo "<button type='button' class='propagate-btn' data-column='main_field'><i class='fas fa-arrow-down'></i></button>";
|
||||
} elseif ($mainFieldMapping['data_type'] === 'DATE') {
|
||||
echo "<input type='date' class='custom-field $inputClass' data-column='main_field' value='" . htmlspecialchars($fieldValue) . "' " . ($mainFieldMapping['is_required'] ? 'required' : '') . ">";
|
||||
echo "<button type='button' class='propagate-btn' data-column='main_field'><i class='fas fa-arrow-down'></i></button>";
|
||||
} elseif ($mainFieldMapping['data_type'] === 'INT') {
|
||||
echo "<input type='number' class='custom-field $inputClass' data-column='main_field' value='" . htmlspecialchars($fieldValue) . "' " . ($mainFieldMapping['is_required'] ? 'required' : '') . ">";
|
||||
echo "<button type='button' class='propagate-btn' data-column='main_field'><i class='fas fa-arrow-down'></i></button>";
|
||||
} else {
|
||||
echo "<input type='text' class='custom-field $inputClass' data-column='main_field' value='" . htmlspecialchars($fieldValue) . "' " . ($mainFieldMapping['is_required'] ? 'required' : '') . ">";
|
||||
echo "<button type='button' class='propagate-btn' data-column='main_field'><i class='fas fa-arrow-down'></i></button>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="grid-cell" style="flex: 0 0 150px;"></div> <!-- importreferencecode -->
|
||||
<?php
|
||||
$fixedColumns = ['filename_import', 'status', 'importdate'];
|
||||
foreach ($fixedColumns as $col) {
|
||||
echo "<div class='grid-cell' style='flex: 0 0 150px;'></div>";
|
||||
}
|
||||
// Campi automatici (is_manual = 0) - Solo SceltaMultipla ha campo e propagazione
|
||||
// Campi automatici (is_manual = 0) escluso main_field
|
||||
$autoIndex = 0;
|
||||
foreach ($allMappings as $mapping) {
|
||||
if (!$mapping['is_manual']) {
|
||||
if (!$mapping['is_manual'] && $mapping['main_field'] != 1) {
|
||||
$inputClass = 'auto-input';
|
||||
if ($mapping['is_required']) $inputClass .= ' required-input';
|
||||
if ($mapping['data_type'] === 'SceltaMultipla') {
|
||||
@ -450,15 +506,15 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
echo "<button type='button' class='propagate-btn' data-column='auto_$autoIndex'><i class='fas fa-arrow-down'></i></button>";
|
||||
echo "</div>";
|
||||
} else {
|
||||
echo "<div class='grid-cell' style='flex: 0 0 150px;'></div>"; // Nessun input per altri tipi
|
||||
echo "<div class='grid-cell' style='flex: 0 0 150px;'></div>";
|
||||
}
|
||||
$autoIndex++;
|
||||
}
|
||||
}
|
||||
// Campi manuali (is_manual = 1) con propagate-btn - Rimane invariato
|
||||
// Campi manuali (is_manual = 1) escluso main_field
|
||||
$manualIndex = 0;
|
||||
foreach ($allMappings as $mapping) {
|
||||
if ($mapping['is_manual']) {
|
||||
if ($mapping['is_manual'] && $mapping['main_field'] != 1) {
|
||||
$fieldValue = $mapping['manual_default'] ?? '';
|
||||
if ($mapping['data_type'] === 'DATE' && $mapping['manual_default'] === 'today') {
|
||||
$fieldValue = date('Y-m-d');
|
||||
@ -470,7 +526,6 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
echo "<select class='custom-field dropdown-select $inputClass' data-column='manual_$manualIndex' data-field-id='{$mapping['field_id']}' " . ($mapping['is_required'] ? 'required' : '') . ">";
|
||||
echo "<option value=''>Seleziona...</option>";
|
||||
echo "</select>";
|
||||
echo "<button type='button' class='propagate-btn' data-column='manual_$manualIndex'><i class='fas fa-arrow-down'></i></button>";
|
||||
} elseif ($mapping['data_type'] === 'DATE') {
|
||||
echo "<input type='date' class='custom-field $inputClass' data-column='manual_$manualIndex' value='" . htmlspecialchars($fieldValue) . "' " . ($mapping['is_required'] ? 'required' : '') . ">";
|
||||
} elseif ($mapping['data_type'] === 'INT') {
|
||||
@ -490,26 +545,32 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
|
||||
<!-- Header della tabella -->
|
||||
<div class="grid-row">
|
||||
<div class="grid-header" style="flex: 0 0 100px;">Save</div>
|
||||
<div class="grid-header" style="flex: 0 0 100px;">Photos</div>
|
||||
<div class="grid-header" style="flex: 0 0 100px;">Parts</div>
|
||||
<div class="grid-header" data-index="3" style="flex: 0 0 150px; position: relative;">Import Reference Code<div class="resizer"></div>
|
||||
<div class="grid-header button-header" style="flex: 0 0 70px;"></div> <!-- Save -->
|
||||
<div class="grid-header button-header" style="flex: 0 0 70px;"></div> <!-- Photos -->
|
||||
<div class="grid-header button-header" style="flex: 0 0 70px;"></div> <!-- Parts -->
|
||||
<?php if ($mainFieldMapping): ?>
|
||||
<div class="grid-header" data-index="3" style="flex: 0 0 150px; position: relative;">
|
||||
<?= htmlspecialchars($mainFieldMapping['field_label']) ?>
|
||||
<div class="resizer"></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="grid-header" data-index="<?= $mainFieldMapping ? 4 : 3 ?>" style="flex: 0 0 150px; position: relative;">Import Reference Code<div class="resizer"></div>
|
||||
</div>
|
||||
<?php
|
||||
$headerIndex = 4;
|
||||
$headerIndex = $mainFieldMapping ? 5 : 4;
|
||||
foreach ($fixedColumns as $col) {
|
||||
$displayName = $slugMapping[$col] ?? $col;
|
||||
echo "<div class='grid-header' data-index='$headerIndex' style='flex: 0 0 150px; position: relative;'>$displayName<div class='resizer'></div></div>";
|
||||
$headerIndex++;
|
||||
}
|
||||
foreach ($allMappings as $mapping) {
|
||||
if (!$mapping['is_manual']) {
|
||||
if (!$mapping['is_manual'] && $mapping['main_field'] != 1) {
|
||||
echo "<div class='grid-header' data-index='$headerIndex' style='flex: 0 0 150px; position: relative;'>" . htmlspecialchars($mapping['field_label']) . "<div class='resizer'></div></div>";
|
||||
$headerIndex++;
|
||||
}
|
||||
}
|
||||
foreach ($allMappings as $mapping) {
|
||||
if ($mapping['is_manual']) {
|
||||
if ($mapping['is_manual'] && $mapping['main_field'] != 1) {
|
||||
echo "<div class='grid-header' data-index='$headerIndex' style='flex: 0 0 150px; position: relative;'>" . htmlspecialchars($mapping['field_label']) . "<div class='resizer'></div></div>";
|
||||
$headerIndex++;
|
||||
}
|
||||
@ -522,22 +583,47 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
<!-- Righe della tabella -->
|
||||
<?php foreach ($importedData as $index => $row): ?>
|
||||
<div class="grid-row" data-id="<?= $row['iddatadb'] ?>">
|
||||
<div class="grid-cell" style="flex: 0 0 100px; position: relative;">
|
||||
<button type="button" class="save-btn action-btn" data-row="<?= $index ?>" style="background: #28a745; color: white; border: none; padding: 8px 12px; border-radius: 5px; cursor: pointer; width: 100%; box-sizing: border-box;"><i class="fas fa-save"></i></button>
|
||||
<div class="grid-cell button-cell" style="flex: 0 0 70px; position: relative;">
|
||||
<button type="button" class="save-btn action-btn" data-row="<?= $index ?>" title="Save" style="background: #28a745; color: white; border: none; padding: 6px 8px; border-radius: 5px; cursor: pointer; width: 100%; box-sizing: border-box;"><i class="fas fa-save"></i></button>
|
||||
</div>
|
||||
<div class="grid-cell" style="flex: 0 0 100px; position: relative;">
|
||||
<button type="button" class="photos-btn action-btn" data-row="<?= $index ?>" data-iddatadb="<?= $row['iddatadb'] ?>" style="background: #007bff; color: white; border: none; padding: 8px 12px; border-radius: 5px; cursor: pointer; width: 100%; box-sizing: border-box;"><i class="fas fa-camera"></i></button>
|
||||
<div class="grid-cell button-cell" style="flex: 0 0 70px; position: relative;">
|
||||
<button type="button" class="photos-btn action-btn" data-row="<?= $index ?>" data-iddatadb="<?= $row['iddatadb'] ?>" title="Photos" style="background: #007bff; color: white; border: none; padding: 6px 8px; border-radius: 5px; cursor: pointer; width: 100%; box-sizing: border-box;"><i class="fas fa-camera"></i></button>
|
||||
</div>
|
||||
<div class="grid-cell" style="flex: 0 0 100px; position: relative;">
|
||||
<button type="button" class="parts-btn action-btn" data-row="<?= $index ?>" data-iddatadb="<?= $row['iddatadb'] ?>" style="background: #ffc107; color: white; border: none; padding: 8px 12px; border-radius: 5px; cursor: pointer; width: 100%; box-sizing: border-box;"><i class="fas fa-puzzle-piece"></i></button>
|
||||
<div class="grid-cell button-cell" style="flex: 0 0 70px; position: relative;">
|
||||
<button type="button" class="parts-btn action-btn" data-row="<?= $index ?>" data-iddatadb="<?= $row['iddatadb'] ?>" title="Parts" style="background: #ffc107; color: white; border: none; padding: 6px 8px; border-radius: 5px; cursor: pointer; width: 100%; box-sizing: border-box;"><i class="fas fa-puzzle-piece"></i></button>
|
||||
</div>
|
||||
<?php if ($mainFieldMapping): ?>
|
||||
<?php
|
||||
$detail = array_filter($manualDetails, fn($d) => $d['mapping_id'] == $mainFieldMapping['id'] && $d['datadb_id'] == $row['iddatadb']);
|
||||
$detail = reset($detail) ?: ['field_value' => $mainFieldMapping['manual_default']];
|
||||
$fieldValue = $detail['field_value'] ?? $mainFieldMapping['manual_default'] ?? '';
|
||||
if ($mainFieldMapping['data_type'] === 'DATE' && $mainFieldMapping['manual_default'] === 'today' && empty($fieldValue)) {
|
||||
$fieldValue = date('Y-m-d');
|
||||
}
|
||||
$requiredClass = ($mainFieldMapping['is_required'] && (is_null($fieldValue) || $fieldValue === '')) ? 'missing-required' : '';
|
||||
$inputClass = $mainFieldMapping['is_manual'] ? 'manual-input' : 'auto-input';
|
||||
if ($mainFieldMapping['is_required']) $inputClass .= ' required-input';
|
||||
?>
|
||||
<div class="grid-cell editable-cell <?= $requiredClass ?>" data-col="main_field" data-row="<?= $index ?>" data-index="3" style="flex: 0 0 150px;">
|
||||
<?php if ($mainFieldMapping['data_type'] === 'SceltaMultipla'): ?>
|
||||
<select name="rows[<?= $index ?>][details][<?= $mainFieldMapping['id'] ?>][field_value]" class="cell-input dropdown-select <?= $inputClass ?>" data-mapping-id="<?= $mainFieldMapping['id'] ?>" data-field-id="<?= $mainFieldMapping['field_id'] ?>" <?= $mainFieldMapping['is_required'] ? 'required' : '' ?>>
|
||||
<option value="">Seleziona...</option>
|
||||
</select>
|
||||
<?php elseif ($mainFieldMapping['data_type'] === 'DATE'): ?>
|
||||
<input type="date" name="rows[<?= $index ?>][details][<?= $mainFieldMapping['id'] ?>][field_value]" value="<?= htmlspecialchars($fieldValue) ?>" class="cell-input <?= $inputClass ?>" <?= $mainFieldMapping['is_required'] ? 'required' : '' ?>>
|
||||
<?php elseif ($mainFieldMapping['data_type'] === 'INT'): ?>
|
||||
<input type="number" name="rows[<?= $index ?>][details][<?= $mainFieldMapping['id'] ?>][field_value]" value="<?= htmlspecialchars($fieldValue) ?>" class="cell-input <?= $inputClass ?>" <?= $mainFieldMapping['is_required'] ? 'required' : '' ?>>
|
||||
<?php else: ?>
|
||||
<input type="text" name="rows[<?= $index ?>][details][<?= $mainFieldMapping['id'] ?>][field_value]" value="<?= htmlspecialchars($fieldValue) ?>" class="cell-input <?= $inputClass ?>" <?= $mainFieldMapping['is_required'] ? 'required' : '' ?>>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="grid-cell" data-col="importreferencecode" data-row="<?= $index ?>" data-index="<?= $mainFieldMapping ? 4 : 3 ?>" style="flex: 0 0 150px;">
|
||||
<span><?= htmlspecialchars($row['importreferencecode']) ?></span>
|
||||
<input type="hidden" name="rows[<?= $index ?>][importreferencecode]" value="<?= htmlspecialchars($row['importreferencecode']) ?>">
|
||||
</div>
|
||||
<?php
|
||||
$cellIndex = 3; // Inizia dopo importreferencecode
|
||||
echo "<div class='grid-cell' data-col='importreferencecode' data-row='$index' data-index='$cellIndex' style='flex: 0 0 150px;'>";
|
||||
echo "<span>" . htmlspecialchars($row['importreferencecode']) . "</span>";
|
||||
echo "<input type='hidden' name='rows[$index][importreferencecode]' value='" . htmlspecialchars($row['importreferencecode']) . "'>";
|
||||
echo "</div>";
|
||||
$cellIndex++;
|
||||
$cellIndex = $mainFieldMapping ? 5 : 4;
|
||||
foreach ($fixedColumns as $col) {
|
||||
$value = $row[$col] ?? '';
|
||||
echo "<div class='grid-cell editable-cell' data-col='$col' data-row='$index' data-index='$cellIndex' style='flex: 0 0 150px;'>";
|
||||
@ -557,7 +643,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
$rowDetails = array_filter($manualDetails, fn($d) => $d['datadb_id'] == $row['iddatadb']);
|
||||
$autoIndex = 0;
|
||||
foreach ($allMappings as $mapping) {
|
||||
if (!$mapping['is_manual']) {
|
||||
if (!$mapping['is_manual'] && $mapping['main_field'] != 1) {
|
||||
$detail = array_filter($rowDetails, fn($d) => $d['mapping_id'] == $mapping['id']);
|
||||
$detail = reset($detail) ?: ['field_value' => $mapping['manual_default']];
|
||||
$fieldValue = $detail['field_value'] ?? $mapping['manual_default'] ?? '';
|
||||
@ -583,7 +669,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
}
|
||||
$manualIndex = 0;
|
||||
foreach ($allMappings as $mapping) {
|
||||
if ($mapping['is_manual']) {
|
||||
if ($mapping['is_manual'] && $mapping['main_field'] != 1) {
|
||||
$detail = array_filter($rowDetails, fn($d) => $d['mapping_id'] == $mapping['id']);
|
||||
$detail = reset($detail) ?: ['field_value' => $mapping['manual_default']];
|
||||
$fieldValue = $detail['field_value'] ?? $mapping['manual_default'] ?? '';
|
||||
@ -697,14 +783,14 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
const propagateButtons = document.querySelectorAll('.propagate-btn');
|
||||
propagateButtons.forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
const columnIndex = this.getAttribute('data-column').replace('manual_', '');
|
||||
const column = this.getAttribute('data-column');
|
||||
const input = this.previousElementSibling;
|
||||
const value = input.value;
|
||||
|
||||
// Trova la colonna target nella griglia superiore e propaga solo verticalmente
|
||||
const gridTopCells = document.querySelector('.grid-top').querySelectorAll('.grid-cell');
|
||||
const targetTopIndex = Array.from(gridTopCells).findIndex(cell =>
|
||||
cell.querySelector('.propagate-btn') === button
|
||||
cell.querySelector('.propagate-btn[data-column="' + column + '"]')
|
||||
);
|
||||
|
||||
if (targetTopIndex !== -1) {
|
||||
@ -761,7 +847,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!-- script dropdonw senza overlay -->
|
||||
<!-- script dropdown senza overlay -->
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
// Oggetto per memorizzare i dati delle tendine recuperati
|
||||
@ -821,6 +907,134 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
|
||||
// Gestione della propagazione per mantenere i valori sincronizzati
|
||||
const propagateButtons = document.querySelectorAll('.propagate-btn');
|
||||
propagateButtons.forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
const column = this.getAttribute('data-column');
|
||||
const input = this.previousElementSibling;
|
||||
const value = input.value;
|
||||
|
||||
const gridTopCells = document.querySelector('.grid-top').querySelectorAll('.grid-cell');
|
||||
const targetTopIndex = Array.from(gridTopCells).findIndex(cell =>
|
||||
cell.querySelector('.propagate-btn[data-column="' + column + '"]')
|
||||
);
|
||||
|
||||
if (targetTopIndex !== -1) {
|
||||
const rows = document.querySelectorAll('.grid-row');
|
||||
rows.forEach(row => {
|
||||
const cells = row.querySelectorAll('.grid-cell');
|
||||
if (cells.length > targetTopIndex) {
|
||||
const targetInput = cells[targetTopIndex].querySelector('select.dropdown-select, input');
|
||||
if (targetInput) {
|
||||
targetInput.value = value;
|
||||
if (targetInput.tagName === 'SELECT') {
|
||||
const event = new Event('change');
|
||||
targetInput.dispatchEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!-- dropdown with overlay -->
|
||||
<!-- <script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
// Crea un overlay di caricamento
|
||||
const loadingOverlay = document.createElement('div');
|
||||
loadingOverlay.id = 'loading-overlay';
|
||||
loadingOverlay.style.cssText = `
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
z-index: 9999;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
`;
|
||||
const loadingMessage = document.createElement('div');
|
||||
loadingMessage.style.cssText = `
|
||||
color: white;
|
||||
font-size: 24px;
|
||||
padding: 20px;
|
||||
background: #333;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
|
||||
`;
|
||||
loadingMessage.textContent = 'Loading Dropdown Options...';
|
||||
loadingOverlay.appendChild(loadingMessage);
|
||||
document.body.appendChild(loadingOverlay);
|
||||
|
||||
// Funzione originale populateDropdowns
|
||||
async function populateDropdowns() {
|
||||
const dropdowns = document.querySelectorAll('.dropdown-select');
|
||||
if (dropdowns.length === 0) return;
|
||||
|
||||
const dropdownData = {};
|
||||
|
||||
// Recupera i dati solo per i field_id univoci
|
||||
const uniqueFieldIds = [...new Set(Array.from(dropdowns).map(d => d.getAttribute('data-field-id')))].filter(fieldId => fieldId);
|
||||
for (const fieldId of uniqueFieldIds) {
|
||||
if (!dropdownData[fieldId]) {
|
||||
try {
|
||||
const response = await fetch(`get_customfield_values.php?field_id=${fieldId}`);
|
||||
const data = await response.json();
|
||||
if (data.error) {
|
||||
console.error('Errore per field_id', fieldId, ':', data.error);
|
||||
continue;
|
||||
}
|
||||
dropdownData[fieldId] = data.CustomFieldsValues || [];
|
||||
} catch (error) {
|
||||
console.error('Errore nel fetch per field_id', fieldId, ':', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Popola tutti i dropdown con i dati recuperati
|
||||
dropdowns.forEach(dropdown => {
|
||||
const fieldId = dropdown.getAttribute('data-field-id');
|
||||
if (!fieldId || !dropdownData[fieldId]) {
|
||||
dropdown.innerHTML = '<option value="">Errore nel caricamento</option>';
|
||||
return;
|
||||
}
|
||||
|
||||
dropdown.innerHTML = '<option value="">Seleziona...</option>';
|
||||
dropdownData[fieldId].forEach(value => {
|
||||
const option = document.createElement('option');
|
||||
option.value = value.IdCustomFieldsValue;
|
||||
option.textContent = value.Valore;
|
||||
if (dropdown.value === option.value) option.selected = true;
|
||||
dropdown.appendChild(option);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Esegui al caricamento della pagina con l'overlay
|
||||
async function loadDropdownsWithOverlay() {
|
||||
console.log('Inizio caricamento tendine');
|
||||
loadingOverlay.style.display = 'flex';
|
||||
await new Promise(resolve => setTimeout(resolve, 500)); // Minimo 500ms di visibilità
|
||||
await populateDropdowns();
|
||||
console.log('Caricamento tendine completato');
|
||||
loadingOverlay.style.display = 'none';
|
||||
}
|
||||
|
||||
// Esegui il caricamento iniziale
|
||||
loadDropdownsWithOverlay();
|
||||
|
||||
// Rielabora i dropdown quando si aggiunge una nuova riga
|
||||
document.querySelectorAll('.save-btn').forEach(btn => {
|
||||
btn.addEventListener('click', function() {
|
||||
setTimeout(loadDropdownsWithOverlay, 100);
|
||||
});
|
||||
});
|
||||
|
||||
// Gestione della propagazione
|
||||
const propagateButtons = document.querySelectorAll('.propagate-btn');
|
||||
propagateButtons.forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
const columnIndex = this.getAttribute('data-column').replace('manual_', '');
|
||||
@ -840,7 +1054,6 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
const targetInput = cells[targetTopIndex].querySelector('select.dropdown-select');
|
||||
if (targetInput) {
|
||||
targetInput.value = value;
|
||||
// Aggiorna visivamente il dropdown
|
||||
const event = new Event('change');
|
||||
targetInput.dispatchEvent(event);
|
||||
}
|
||||
@ -850,135 +1063,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!-- dropdown with overlay -->
|
||||
<!--
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
// Crea un overlay di caricamento
|
||||
const loadingOverlay = document.createElement('div');
|
||||
loadingOverlay.id = 'loading-overlay';
|
||||
loadingOverlay.style.cssText = `
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
z-index: 9999;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
`;
|
||||
const loadingMessage = document.createElement('div');
|
||||
loadingMessage.style.cssText = `
|
||||
color: white;
|
||||
font-size: 24px;
|
||||
padding: 20px;
|
||||
background: #333;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
|
||||
`;
|
||||
loadingMessage.textContent = 'Loading Dropdown Options...';
|
||||
loadingOverlay.appendChild(loadingMessage);
|
||||
document.body.appendChild(loadingOverlay);
|
||||
|
||||
// Funzione originale populateDropdowns
|
||||
async function populateDropdowns() {
|
||||
const dropdowns = document.querySelectorAll('.dropdown-select');
|
||||
if (dropdowns.length === 0) return;
|
||||
|
||||
const dropdownData = {};
|
||||
|
||||
// Recupera i dati solo per i field_id univoci
|
||||
const uniqueFieldIds = [...new Set(Array.from(dropdowns).map(d => d.getAttribute('data-field-id')))].filter(fieldId => fieldId);
|
||||
for (const fieldId of uniqueFieldIds) {
|
||||
if (!dropdownData[fieldId]) {
|
||||
try {
|
||||
const response = await fetch(`get_customfield_values.php?field_id=${fieldId}`);
|
||||
const data = await response.json();
|
||||
if (data.error) {
|
||||
console.error('Errore per field_id', fieldId, ':', data.error);
|
||||
continue;
|
||||
}
|
||||
dropdownData[fieldId] = data.CustomFieldsValues || [];
|
||||
} catch (error) {
|
||||
console.error('Errore nel fetch per field_id', fieldId, ':', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Popola tutti i dropdown con i dati recuperati
|
||||
dropdowns.forEach(dropdown => {
|
||||
const fieldId = dropdown.getAttribute('data-field-id');
|
||||
if (!fieldId || !dropdownData[fieldId]) {
|
||||
dropdown.innerHTML = '<option value="">Errore nel caricamento</option>';
|
||||
return;
|
||||
}
|
||||
|
||||
dropdown.innerHTML = '<option value="">Seleziona...</option>';
|
||||
dropdownData[fieldId].forEach(value => {
|
||||
const option = document.createElement('option');
|
||||
option.value = value.IdCustomFieldsValue;
|
||||
option.textContent = value.Valore;
|
||||
if (dropdown.value === option.value) option.selected = true;
|
||||
dropdown.appendChild(option);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Esegui al caricamento della pagina con l'overlay
|
||||
async function loadDropdownsWithOverlay() {
|
||||
console.log('Inizio caricamento tendine');
|
||||
loadingOverlay.style.display = 'flex';
|
||||
await new Promise(resolve => setTimeout(resolve, 500)); // Minimo 500ms di visibilità
|
||||
await populateDropdowns();
|
||||
console.log('Caricamento tendine completato');
|
||||
loadingOverlay.style.display = 'none';
|
||||
}
|
||||
|
||||
// Esegui il caricamento iniziale
|
||||
loadDropdownsWithOverlay();
|
||||
|
||||
// Rielabora i dropdown quando si aggiunge una nuova riga
|
||||
document.querySelectorAll('.save-btn').forEach(btn => {
|
||||
btn.addEventListener('click', function() {
|
||||
setTimeout(loadDropdownsWithOverlay, 100);
|
||||
});
|
||||
});
|
||||
|
||||
// Gestione della propagazione
|
||||
const propagateButtons = document.querySelectorAll('.propagate-btn');
|
||||
propagateButtons.forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
const columnIndex = this.getAttribute('data-column').replace('manual_', '');
|
||||
const input = this.previousElementSibling;
|
||||
const value = input.value;
|
||||
|
||||
const gridTopCells = document.querySelector('.grid-top').querySelectorAll('.grid-cell');
|
||||
const targetTopIndex = Array.from(gridTopCells).findIndex(cell =>
|
||||
cell.querySelector('.propagate-btn') === button
|
||||
);
|
||||
|
||||
if (targetTopIndex !== -1) {
|
||||
const rows = document.querySelectorAll('.grid-row');
|
||||
rows.forEach(row => {
|
||||
const cells = row.querySelectorAll('.grid-cell');
|
||||
if (cells.length > targetTopIndex) {
|
||||
const targetInput = cells[targetTopIndex].querySelector('select.dropdown-select');
|
||||
if (targetInput) {
|
||||
targetInput.value = value;
|
||||
const event = new Event('change');
|
||||
targetInput.dispatchEvent(event);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
-->
|
||||
</script> -->
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user