added main field functionality
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 54 KiB |
BIN
public/photostrf/647-20250817135743-images.jpg
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
public/photostrf/647-20250817135749-images (1).jpg
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
public/photostrf/648-20250817140119-images.jpg
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
public/photostrf/648-20250817140126-images (1).jpg
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
public/photostrf/649-20250817140320-images.jpg
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
public/photostrf/649-20250817140433-images (1).jpg
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
public/photostrf/666-20250819070024-images.jpg
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
public/photostrf/666-20250819070034-images (1).jpg
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
public/photostrf/667-20250819070340-images.jpg
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
public/photostrf/667-20250819070347-images (1).jpg
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
public/photostrf/669-20250819085746-images.jpg
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
public/photostrf/669-20250819085753-images (1).jpg
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
public/photostrf/670-20250819090251-images.jpg
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
public/photostrf/670-20250819090257-images (1).jpg
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
public/photostrf/671-20250819090924-images.jpg
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
public/photostrf/671-20250819090931-images (1).jpg
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
public/photostrf/672-20250819091301-images.jpg
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 92 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 54 KiB |
BIN
public/photostrf/qrcodes/qrcode_646.png
Normal file
|
After Width: | Height: | Size: 451 B |
BIN
public/photostrf/qrcodes/qrcode_647.png
Normal file
|
After Width: | Height: | Size: 510 B |
BIN
public/photostrf/qrcodes/qrcode_648.png
Normal file
|
After Width: | Height: | Size: 462 B |
BIN
public/photostrf/qrcodes/qrcode_649.png
Normal file
|
After Width: | Height: | Size: 443 B |
BIN
public/photostrf/qrcodes/qrcode_666.png
Normal file
|
After Width: | Height: | Size: 460 B |
BIN
public/photostrf/qrcodes/qrcode_667.png
Normal file
|
After Width: | Height: | Size: 454 B |
BIN
public/photostrf/qrcodes/qrcode_669.png
Normal file
|
After Width: | Height: | Size: 456 B |
BIN
public/photostrf/qrcodes/qrcode_670.png
Normal file
|
After Width: | Height: | Size: 460 B |
BIN
public/photostrf/qrcodes/qrcode_671.png
Normal file
|
After Width: | Height: | Size: 457 B |
BIN
public/photostrf/qrcodes/qrcode_672.png
Normal file
|
After Width: | Height: | Size: 454 B |
BIN
public/photostrf/qrcodes/qrcode_699.png
Normal file
|
After Width: | Height: | Size: 455 B |
@ -31,6 +31,6 @@ Content-Length: 51
|
|||||||
< strict-transport-security: max-age=2592000
|
< strict-transport-security: max-age=2592000
|
||||||
< x-powered-by: ASP.NET
|
< x-powered-by: ASP.NET
|
||||||
< x-content-type-options: nosniff
|
< x-content-type-options: nosniff
|
||||||
< date: Wed, 30 Jul 2025 13:38:07 GMT
|
< date: Thu, 21 Aug 2025 07:25:06 GMT
|
||||||
<
|
<
|
||||||
* Connection #0 to host 93.43.5.102 left intact
|
* Connection #0 to host 93.43.5.102 left intact
|
||||||
|
|||||||
@ -15,11 +15,11 @@
|
|||||||
* [HTTP/2] [1] [:scheme: https]
|
* [HTTP/2] [1] [:scheme: https]
|
||||||
* [HTTP/2] [1] [:authority: 93.43.5.102]
|
* [HTTP/2] [1] [:authority: 93.43.5.102]
|
||||||
* [HTTP/2] [1] [:path: /limsapi/api/odata/CustomField(1083)?$expand=CustomFieldsValues]
|
* [HTTP/2] [1] [:path: /limsapi/api/odata/CustomField(1083)?$expand=CustomFieldsValues]
|
||||||
* [HTTP/2] [1] [authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjQ5MiIsIlhhZlNlY3VyaXR5QXV0aFBhc3NlZCI6IlhhZlNlY3VyaXR5QXV0aFBhc3NlZCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJXZWJBcGlVc2VyIiwiWGFmU2VjdXJpdHkiOiJYYWZTZWN1cml0eSIsIlhhZkxvZ29uUGFyYW1zIjoicTFZS0xVNHQ4a3ZNVFZXeVVncFBUWElzeUFRSktPa29CU1FXRjVmbkY2VUF4Y3RUa3hJTE1rdUI0Z2FHU3JVQSIsImV4cCI6MTc1Mzg4OTg4NywiaXNzIjoiTXkiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.fka4MClGYcSJycwopdVtHtp-59VPTCgT_waRi8qdLmE]
|
* [HTTP/2] [1] [authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjQ5MiIsIlhhZlNlY3VyaXR5QXV0aFBhc3NlZCI6IlhhZlNlY3VyaXR5QXV0aFBhc3NlZCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJXZWJBcGlVc2VyIiwiWGFmU2VjdXJpdHkiOiJYYWZTZWN1cml0eSIsIlhhZkxvZ29uUGFyYW1zIjoicTFZS0xVNHQ4a3ZNVFZXeVVncFBUWElzeUFRSktPa29CU1FXRjVmbkY2VUF4Y3RUa3hJTE1rdUI0Z2FHU3JVQSIsImV4cCI6MTc1NTc2ODMwNiwiaXNzIjoiTXkiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.HRrfyioUsdS9STE0ZYZEXN-ioWq0ZLTIjio2khshqN8]
|
||||||
* [HTTP/2] [1] [accept: application/json]
|
* [HTTP/2] [1] [accept: application/json]
|
||||||
> GET /limsapi/api/odata/CustomField(1083)?$expand=CustomFieldsValues HTTP/2
|
> GET /limsapi/api/odata/CustomField(1083)?$expand=CustomFieldsValues HTTP/2
|
||||||
Host: 93.43.5.102
|
Host: 93.43.5.102
|
||||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjQ5MiIsIlhhZlNlY3VyaXR5QXV0aFBhc3NlZCI6IlhhZlNlY3VyaXR5QXV0aFBhc3NlZCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJXZWJBcGlVc2VyIiwiWGFmU2VjdXJpdHkiOiJYYWZTZWN1cml0eSIsIlhhZkxvZ29uUGFyYW1zIjoicTFZS0xVNHQ4a3ZNVFZXeVVncFBUWElzeUFRSktPa29CU1FXRjVmbkY2VUF4Y3RUa3hJTE1rdUI0Z2FHU3JVQSIsImV4cCI6MTc1Mzg4OTg4NywiaXNzIjoiTXkiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.fka4MClGYcSJycwopdVtHtp-59VPTCgT_waRi8qdLmE
|
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjQ5MiIsIlhhZlNlY3VyaXR5QXV0aFBhc3NlZCI6IlhhZlNlY3VyaXR5QXV0aFBhc3NlZCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJXZWJBcGlVc2VyIiwiWGFmU2VjdXJpdHkiOiJYYWZTZWN1cml0eSIsIlhhZkxvZ29uUGFyYW1zIjoicTFZS0xVNHQ4a3ZNVFZXeVVncFBUWElzeUFRSktPa29CU1FXRjVmbkY2VUF4Y3RUa3hJTE1rdUI0Z2FHU3JVQSIsImV4cCI6MTc1NTc2ODMwNiwiaXNzIjoiTXkiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.HRrfyioUsdS9STE0ZYZEXN-ioWq0ZLTIjio2khshqN8
|
||||||
Accept: application/json
|
Accept: application/json
|
||||||
|
|
||||||
< HTTP/2 200
|
< HTTP/2 200
|
||||||
@ -30,6 +30,6 @@ Accept: application/json
|
|||||||
< odata-version: 4.0
|
< odata-version: 4.0
|
||||||
< x-powered-by: ASP.NET
|
< x-powered-by: ASP.NET
|
||||||
< x-content-type-options: nosniff
|
< x-content-type-options: nosniff
|
||||||
< date: Wed, 30 Jul 2025 13:38:08 GMT
|
< date: Thu, 21 Aug 2025 07:25:06 GMT
|
||||||
<
|
<
|
||||||
* Connection #0 to host 93.43.5.102 left intact
|
* Connection #0 to host 93.43.5.102 left intact
|
||||||
|
|||||||
@ -40,7 +40,7 @@ $pdo = $db->getConnection();
|
|||||||
$importReferenceCode = date('YmdHis') . '-' . uniqid();
|
$importReferenceCode = date('YmdHis') . '-' . uniqid();
|
||||||
|
|
||||||
// Recupera tutti i mapping dal template
|
// 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]);
|
$stmt->execute([$template_id]);
|
||||||
$allMappings = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$allMappings = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
@ -49,6 +49,15 @@ if (empty($allMappings)) {
|
|||||||
exit;
|
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)
|
// Inserisci le righe selezionate in datadb (solo campi generici con templateid)
|
||||||
$insertedIds = [];
|
$insertedIds = [];
|
||||||
foreach ($selected_rows as $rowIndex) {
|
foreach ($selected_rows as $rowIndex) {
|
||||||
@ -221,7 +230,8 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
.grid-header,
|
.grid-header,
|
||||||
.grid-cell {
|
.grid-cell {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 100px;
|
min-width: 70px;
|
||||||
|
/* Ridotto da 100px per compatibilità con pulsanti */
|
||||||
padding: 12px 15px;
|
padding: 12px 15px;
|
||||||
border-right: 1px solid #dee2e6;
|
border-right: 1px solid #dee2e6;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@ -397,6 +407,25 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
border-color: #80bdff;
|
border-color: #80bdff;
|
||||||
box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
|
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>
|
</style>
|
||||||
<title>Edit Imported Data - <?= htmlspecialchars($titlewebsite, ENT_QUOTES, 'UTF-8'); ?></title>
|
<title>Edit Imported Data - <?= htmlspecialchars($titlewebsite, ENT_QUOTES, 'UTF-8'); ?></title>
|
||||||
</head>
|
</head>
|
||||||
@ -422,19 +451,46 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
<div class="grid-container">
|
<div class="grid-container">
|
||||||
<!-- Riga superiore per gli input dei campi manuali -->
|
<!-- Riga superiore per gli input dei campi manuali -->
|
||||||
<div class="grid-top">
|
<div class="grid-top">
|
||||||
<div class="grid-cell" style="flex: 0 0 100px;"></div> <!-- Save -->
|
<div class="grid-cell button-cell" style="flex: 0 0 70px;"></div> <!-- Save -->
|
||||||
<div class="grid-cell" style="flex: 0 0 100px;"></div> <!-- Photos -->
|
<div class="grid-cell button-cell" style="flex: 0 0 70px;"></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> <!-- 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 -->
|
<div class="grid-cell" style="flex: 0 0 150px;"></div> <!-- importreferencecode -->
|
||||||
<?php
|
<?php
|
||||||
$fixedColumns = ['filename_import', 'status', 'importdate'];
|
$fixedColumns = ['filename_import', 'status', 'importdate'];
|
||||||
foreach ($fixedColumns as $col) {
|
foreach ($fixedColumns as $col) {
|
||||||
echo "<div class='grid-cell' style='flex: 0 0 150px;'></div>";
|
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;
|
$autoIndex = 0;
|
||||||
foreach ($allMappings as $mapping) {
|
foreach ($allMappings as $mapping) {
|
||||||
if (!$mapping['is_manual']) {
|
if (!$mapping['is_manual'] && $mapping['main_field'] != 1) {
|
||||||
$inputClass = 'auto-input';
|
$inputClass = 'auto-input';
|
||||||
if ($mapping['is_required']) $inputClass .= ' required-input';
|
if ($mapping['is_required']) $inputClass .= ' required-input';
|
||||||
if ($mapping['data_type'] === 'SceltaMultipla') {
|
if ($mapping['data_type'] === 'SceltaMultipla') {
|
||||||
@ -445,15 +501,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 "<button type='button' class='propagate-btn' data-column='auto_$autoIndex'><i class='fas fa-arrow-down'></i></button>";
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
} else {
|
} 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++;
|
$autoIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Campi manuali (is_manual = 1) con propagate-btn - Rimane invariato
|
// Campi manuali (is_manual = 1) escluso main_field
|
||||||
$manualIndex = 0;
|
$manualIndex = 0;
|
||||||
foreach ($allMappings as $mapping) {
|
foreach ($allMappings as $mapping) {
|
||||||
if ($mapping['is_manual']) {
|
if ($mapping['is_manual'] && $mapping['main_field'] != 1) {
|
||||||
$fieldValue = $mapping['manual_default'] ?? '';
|
$fieldValue = $mapping['manual_default'] ?? '';
|
||||||
if ($mapping['data_type'] === 'DATE' && $mapping['manual_default'] === 'today') {
|
if ($mapping['data_type'] === 'DATE' && $mapping['manual_default'] === 'today') {
|
||||||
$fieldValue = date('Y-m-d');
|
$fieldValue = date('Y-m-d');
|
||||||
@ -465,7 +521,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 "<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 "<option value=''>Seleziona...</option>";
|
||||||
echo "</select>";
|
echo "</select>";
|
||||||
// Removed the duplicate button here
|
|
||||||
} elseif ($mapping['data_type'] === 'DATE') {
|
} elseif ($mapping['data_type'] === 'DATE') {
|
||||||
echo "<input type='date' class='custom-field $inputClass' data-column='manual_$manualIndex' value='" . htmlspecialchars($fieldValue) . "' " . ($mapping['is_required'] ? 'required' : '') . ">";
|
echo "<input type='date' class='custom-field $inputClass' data-column='manual_$manualIndex' value='" . htmlspecialchars($fieldValue) . "' " . ($mapping['is_required'] ? 'required' : '') . ">";
|
||||||
} elseif ($mapping['data_type'] === 'INT') {
|
} elseif ($mapping['data_type'] === 'INT') {
|
||||||
@ -485,26 +540,32 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
|
|
||||||
<!-- Header della tabella -->
|
<!-- Header della tabella -->
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
<div class="grid-header" style="flex: 0 0 100px;">Save</div>
|
<div class="grid-header button-header" style="flex: 0 0 70px;"></div> <!-- Save -->
|
||||||
<div class="grid-header" style="flex: 0 0 100px;">Photos</div>
|
<div class="grid-header button-header" style="flex: 0 0 70px;"></div> <!-- Photos -->
|
||||||
<div class="grid-header" style="flex: 0 0 100px;">Parts</div>
|
<div class="grid-header button-header" style="flex: 0 0 70px;"></div> <!-- Parts -->
|
||||||
<div class="grid-header" data-index="3" style="flex: 0 0 150px; position: relative;">Import Reference Code<div class="resizer"></div>
|
<?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>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
$headerIndex = 4;
|
$headerIndex = $mainFieldMapping ? 5 : 4;
|
||||||
foreach ($fixedColumns as $col) {
|
foreach ($fixedColumns as $col) {
|
||||||
$displayName = $slugMapping[$col] ?? $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>";
|
echo "<div class='grid-header' data-index='$headerIndex' style='flex: 0 0 150px; position: relative;'>$displayName<div class='resizer'></div></div>";
|
||||||
$headerIndex++;
|
$headerIndex++;
|
||||||
}
|
}
|
||||||
foreach ($allMappings as $mapping) {
|
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>";
|
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++;
|
$headerIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($allMappings as $mapping) {
|
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>";
|
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++;
|
$headerIndex++;
|
||||||
}
|
}
|
||||||
@ -517,22 +578,47 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
<!-- Righe della tabella -->
|
<!-- Righe della tabella -->
|
||||||
<?php foreach ($importedData as $index => $row): ?>
|
<?php foreach ($importedData as $index => $row): ?>
|
||||||
<div class="grid-row" data-id="<?= $row['iddatadb'] ?>">
|
<div class="grid-row" data-id="<?= $row['iddatadb'] ?>">
|
||||||
<div class="grid-cell" style="flex: 0 0 100px; position: relative;">
|
<div class="grid-cell button-cell" style="flex: 0 0 70px; 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>
|
<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>
|
||||||
<div class="grid-cell" style="flex: 0 0 100px; position: relative;">
|
<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'] ?>" 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>
|
<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>
|
||||||
<div class="grid-cell" style="flex: 0 0 100px; position: relative;">
|
<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'] ?>" 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>
|
<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>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
$cellIndex = 3; // Inizia dopo importreferencecode
|
$cellIndex = $mainFieldMapping ? 5 : 4;
|
||||||
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++;
|
|
||||||
foreach ($fixedColumns as $col) {
|
foreach ($fixedColumns as $col) {
|
||||||
$value = $row[$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;'>";
|
echo "<div class='grid-cell editable-cell' data-col='$col' data-row='$index' data-index='$cellIndex' style='flex: 0 0 150px;'>";
|
||||||
@ -552,7 +638,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
$rowDetails = array_filter($manualDetails, fn($d) => $d['datadb_id'] == $row['iddatadb']);
|
$rowDetails = array_filter($manualDetails, fn($d) => $d['datadb_id'] == $row['iddatadb']);
|
||||||
$autoIndex = 0;
|
$autoIndex = 0;
|
||||||
foreach ($allMappings as $mapping) {
|
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 = array_filter($rowDetails, fn($d) => $d['mapping_id'] == $mapping['id']);
|
||||||
$detail = reset($detail) ?: ['field_value' => $mapping['manual_default']];
|
$detail = reset($detail) ?: ['field_value' => $mapping['manual_default']];
|
||||||
$fieldValue = $detail['field_value'] ?? $mapping['manual_default'] ?? '';
|
$fieldValue = $detail['field_value'] ?? $mapping['manual_default'] ?? '';
|
||||||
@ -578,7 +664,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
}
|
}
|
||||||
$manualIndex = 0;
|
$manualIndex = 0;
|
||||||
foreach ($allMappings as $mapping) {
|
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 = array_filter($rowDetails, fn($d) => $d['mapping_id'] == $mapping['id']);
|
||||||
$detail = reset($detail) ?: ['field_value' => $mapping['manual_default']];
|
$detail = reset($detail) ?: ['field_value' => $mapping['manual_default']];
|
||||||
$fieldValue = $detail['field_value'] ?? $mapping['manual_default'] ?? '';
|
$fieldValue = $detail['field_value'] ?? $mapping['manual_default'] ?? '';
|
||||||
@ -692,14 +778,14 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
const propagateButtons = document.querySelectorAll('.propagate-btn');
|
const propagateButtons = document.querySelectorAll('.propagate-btn');
|
||||||
propagateButtons.forEach(button => {
|
propagateButtons.forEach(button => {
|
||||||
button.addEventListener('click', function() {
|
button.addEventListener('click', function() {
|
||||||
const columnIndex = this.getAttribute('data-column').replace('manual_', '');
|
const column = this.getAttribute('data-column');
|
||||||
const input = this.previousElementSibling;
|
const input = this.previousElementSibling;
|
||||||
const value = input.value;
|
const value = input.value;
|
||||||
|
|
||||||
// Trova la colonna target nella griglia superiore e propaga solo verticalmente
|
// Trova la colonna target nella griglia superiore e propaga solo verticalmente
|
||||||
const gridTopCells = document.querySelector('.grid-top').querySelectorAll('.grid-cell');
|
const gridTopCells = document.querySelector('.grid-top').querySelectorAll('.grid-cell');
|
||||||
const targetTopIndex = Array.from(gridTopCells).findIndex(cell =>
|
const targetTopIndex = Array.from(gridTopCells).findIndex(cell =>
|
||||||
cell.querySelector('.propagate-btn') === button
|
cell.querySelector('.propagate-btn[data-column="' + column + '"]')
|
||||||
);
|
);
|
||||||
|
|
||||||
if (targetTopIndex !== -1) {
|
if (targetTopIndex !== -1) {
|
||||||
@ -756,7 +842,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<!-- script dropdonw senza overlay -->
|
<!-- script dropdown senza overlay -->
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
// Oggetto per memorizzare i dati delle tendine recuperati
|
// Oggetto per memorizzare i dati delle tendine recuperati
|
||||||
@ -816,6 +902,134 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
|
|
||||||
// Gestione della propagazione per mantenere i valori sincronizzati
|
// Gestione della propagazione per mantenere i valori sincronizzati
|
||||||
const propagateButtons = document.querySelectorAll('.propagate-btn');
|
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 => {
|
propagateButtons.forEach(button => {
|
||||||
button.addEventListener('click', function() {
|
button.addEventListener('click', function() {
|
||||||
const columnIndex = this.getAttribute('data-column').replace('manual_', '');
|
const columnIndex = this.getAttribute('data-column').replace('manual_', '');
|
||||||
@ -835,7 +1049,6 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
const targetInput = cells[targetTopIndex].querySelector('select.dropdown-select');
|
const targetInput = cells[targetTopIndex].querySelector('select.dropdown-select');
|
||||||
if (targetInput) {
|
if (targetInput) {
|
||||||
targetInput.value = value;
|
targetInput.value = value;
|
||||||
// Aggiorna visivamente il dropdown
|
|
||||||
const event = new Event('change');
|
const event = new Event('change');
|
||||||
targetInput.dispatchEvent(event);
|
targetInput.dispatchEvent(event);
|
||||||
}
|
}
|
||||||
@ -845,135 +1058,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</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>
|
|
||||||
-->
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||