update historical trf
This commit is contained in:
parent
f6ef9c39d2
commit
0d2cf13524
@ -982,7 +982,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
const cells = row.querySelectorAll('td');
|
const cells = row.querySelectorAll('td');
|
||||||
let match = false;
|
let match = false;
|
||||||
cells.forEach((cell, index) => {
|
cells.forEach((cell, index) => {
|
||||||
if (index >= 1 && index <= 3) {
|
if (index >= 1 && index <= 4) { // Cerca in ID, main_field, importreferencecode, filename
|
||||||
const text = cell.textContent.toLowerCase();
|
const text = cell.textContent.toLowerCase();
|
||||||
if (text.includes(filter)) {
|
if (text.includes(filter)) {
|
||||||
match = true;
|
match = true;
|
||||||
@ -1026,6 +1026,18 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Gestione eliminazione multipla
|
||||||
|
const bulkActionForm = document.getElementById('bulkActionForm');
|
||||||
|
bulkActionForm.addEventListener('submit', function(e) {
|
||||||
|
const selectedCheckboxes = document.querySelectorAll('input[name="selected_ids[]"]:checked');
|
||||||
|
if (selectedCheckboxes.length === 0) {
|
||||||
|
e.preventDefault();
|
||||||
|
alert('Seleziona almeno un record da eliminare.');
|
||||||
|
} else if (!confirm('Sicuro di voler eliminare i record selezionati?')) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
// Gestione input e celle espandibili
|
// Gestione input e celle espandibili
|
||||||
const inputs = document.querySelectorAll('.cell-input');
|
const inputs = document.querySelectorAll('.cell-input');
|
||||||
@ -1055,6 +1067,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
formData.append(name, input.value);
|
formData.append(name, input.value);
|
||||||
});
|
});
|
||||||
formData.append('iddatadb', iddatadb);
|
formData.append('iddatadb', iddatadb);
|
||||||
|
formData.append('mapping', JSON.stringify(<?= json_encode($allMappings) ?>));
|
||||||
fetch('save_edited_row.php', {
|
fetch('save_edited_row.php', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData
|
body: formData
|
||||||
@ -1069,7 +1082,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
cell.classList.add('flash-success');
|
cell.classList.add('flash-success');
|
||||||
});
|
});
|
||||||
setTimeout(() => cells.forEach(cell => cell.classList.remove('flash-success')), 500);
|
setTimeout(() => cells.forEach(cell => cell.classList.remove('flash-success')), 500);
|
||||||
// Ricarica i dropdown dopo il salvataggio
|
alert('Salvataggio avvenuto con successo!');
|
||||||
setTimeout(populateDropdowns, 100);
|
setTimeout(populateDropdowns, 100);
|
||||||
} else {
|
} else {
|
||||||
alert('Errore durante il salvataggio: ' + data.message);
|
alert('Errore durante il salvataggio: ' + data.message);
|
||||||
@ -1084,12 +1097,12 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
propagateButtons.forEach(button => {
|
propagateButtons.forEach(button => {
|
||||||
button.addEventListener('click', function() {
|
button.addEventListener('click', function() {
|
||||||
if (this.hasAttribute('disabled')) return;
|
if (this.hasAttribute('disabled')) return;
|
||||||
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;
|
||||||
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) {
|
||||||
const rows = document.querySelectorAll('.grid-row');
|
const rows = document.querySelectorAll('.grid-row');
|
||||||
@ -1098,9 +1111,11 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
if (cells.length > targetTopIndex) {
|
if (cells.length > targetTopIndex) {
|
||||||
const targetInput = cells[targetTopIndex].querySelector('input, select');
|
const targetInput = cells[targetTopIndex].querySelector('input, select');
|
||||||
if (targetInput && !targetInput.hasAttribute('readonly')) {
|
if (targetInput && !targetInput.hasAttribute('readonly')) {
|
||||||
if (targetInput.type === 'date') targetInput.value = value;
|
targetInput.value = value;
|
||||||
else if (targetInput.tagName === 'SELECT') targetInput.value = value;
|
if (targetInput.tagName === 'SELECT') {
|
||||||
else targetInput.value = value;
|
const event = new Event('change');
|
||||||
|
targetInput.dispatchEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1213,49 +1228,71 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Gestione dropdown
|
// Gestione dropdown
|
||||||
|
const dropdownData = {};
|
||||||
async function populateDropdowns() {
|
async function populateDropdowns() {
|
||||||
if (<?= json_encode($is_readonly) ?>) return;
|
if (<?= json_encode($is_readonly) ?>) return;
|
||||||
const dropdowns = document.querySelectorAll('.dropdown-select');
|
const dropdowns = document.querySelectorAll('.dropdown-select');
|
||||||
if (dropdowns.length === 0) return;
|
console.log('Dropdown trovati:', dropdowns.length);
|
||||||
const uniqueFieldIds = [...new Set(Array.from(dropdowns).map(d => d.getAttribute('data-field-id')))].filter(fieldId => fieldId);
|
if (dropdowns.length === 0) {
|
||||||
if (uniqueFieldIds.length === 0) return;
|
console.warn('Nessun dropdown trovato con classe .dropdown-select');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
const uniqueFieldIds = [...new Set(Array.from(dropdowns).map(d => d.getAttribute('data-field-id')))].filter(fieldId => fieldId);
|
||||||
const response = await fetch(`get_customfield_values.php?field_ids=${uniqueFieldIds.join(',')}`);
|
console.log('Field IDs unici:', uniqueFieldIds);
|
||||||
const data = await response.json();
|
const missingFieldIds = uniqueFieldIds.filter(fieldId => !dropdownData[fieldId]);
|
||||||
if (data.error) {
|
|
||||||
console.error('Errore nel caricamento dei valori dei dropdown:', data.error);
|
if (missingFieldIds.length > 0) {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`get_customfield_values.php?field_ids=${missingFieldIds.join(',')}`);
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`Errore HTTP: ${response.status} ${response.statusText}`);
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
console.log('Risposta da get_customfield_values.php:', data);
|
||||||
|
|
||||||
|
if (data.error) {
|
||||||
|
console.error('Errore dal server:', data.error);
|
||||||
|
dropdowns.forEach(dropdown => {
|
||||||
|
dropdown.innerHTML = '<option value="">Errore server</option>';
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const fieldId of Object.keys(data)) {
|
||||||
|
dropdownData[fieldId] = data[fieldId] || [];
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Errore nel fetch dei valori dei dropdown:', error);
|
||||||
dropdowns.forEach(dropdown => {
|
dropdowns.forEach(dropdown => {
|
||||||
dropdown.innerHTML = '<option value="">Errore nel caricamento</option>';
|
dropdown.innerHTML = '<option value="">Errore caricamento</option>';
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dropdowns.forEach(dropdown => {
|
|
||||||
const fieldId = dropdown.getAttribute('data-field-id');
|
|
||||||
const options = data[fieldId] || [];
|
|
||||||
const currentValue = dropdown.value;
|
|
||||||
|
|
||||||
// Rimuovi opzioni esistenti (tranne il placeholder)
|
|
||||||
dropdown.innerHTML = '<option value="">Seleziona...</option>';
|
|
||||||
|
|
||||||
// Aggiungi nuove opzioni
|
|
||||||
options.forEach(option => {
|
|
||||||
const opt = document.createElement('option');
|
|
||||||
opt.value = option.Value;
|
|
||||||
opt.textContent = option.Value;
|
|
||||||
if (currentValue === option.Value) {
|
|
||||||
opt.selected = true;
|
|
||||||
}
|
|
||||||
dropdown.appendChild(opt);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Errore nel fetch dei valori dei dropdown:', error);
|
|
||||||
dropdowns.forEach(dropdown => {
|
|
||||||
dropdown.innerHTML = '<option value="">Errore nel caricamento</option>';
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dropdowns.forEach(dropdown => {
|
||||||
|
const fieldId = dropdown.getAttribute('data-field-id');
|
||||||
|
const mappingId = dropdown.getAttribute('data-mapping-id');
|
||||||
|
const currentValue = dropdown.value || '';
|
||||||
|
console.log(`Popolamento dropdown field_id=${fieldId}, mapping_id=${mappingId}, valore corrente=${currentValue}`);
|
||||||
|
|
||||||
|
if (!fieldId || !dropdownData[fieldId]) {
|
||||||
|
dropdown.innerHTML = '<option value="">Nessun dato</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 (currentValue === String(value.IdCustomFieldsValue)) {
|
||||||
|
option.selected = true;
|
||||||
|
}
|
||||||
|
dropdown.appendChild(option);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
populateDropdowns();
|
populateDropdowns();
|
||||||
saveButtons.forEach(btn => {
|
saveButtons.forEach(btn => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user