diff --git a/public/userarea/mapping_template_xls_scheme2.php b/public/userarea/mapping_template_xls_scheme2.php
index b7ddbc7..78d7f9d 100644
--- a/public/userarea/mapping_template_xls_scheme2.php
+++ b/public/userarea/mapping_template_xls_scheme2.php
@@ -163,6 +163,12 @@ $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], t
width: 100% !important;
}
+ .xls-columns option.used-option {
+ background-color: #fff3cd;
+ color: #856404;
+ font-weight: 600;
+ }
+
/* Make Title column narrower + ellipsis */
#schemaFieldsTable td.title-col {
max-width: 320px;
@@ -554,21 +560,25 @@ $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], t
function updateXlsDropdowns() {
let usedColumns = Array.from(document.querySelectorAll('select.xls-columns'))
- .filter(select => select.style.display === 'block' && select.value)
- .map(select => select.value)
+ .map(select => select.value || select.dataset.currentXls || '')
+ .filter(Boolean)
.concat(usedColumnsFromDB);
+ let uniqueUsedColumns = [...new Set(usedColumns)];
+
document.querySelectorAll('select.xls-columns').forEach(select => {
let currentValue = select.value || select.dataset.currentXls || '';
+
let options = availableXlsColumns
- .filter(col => !usedColumns.includes(col) || col === currentValue)
- .map(col => ``)
+ .map(col => {
+ const isUsed = uniqueUsedColumns.includes(col) && col !== currentValue;
+ const label = isUsed ? `⚠ ${col} (already used)` : col;
+ return ``;
+ })
.join('');
+
select.innerHTML = '' + options;
select.dataset.currentXls = currentValue;
- if (currentValue && !options.includes(currentValue)) {
- select.value = '';
- }
});
}
@@ -1015,33 +1025,6 @@ $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], t
checkbox.checked = !prevChecked;
location.reload();
});
- } else if (event.target.classList.contains('visible-parts-checkbox')) {
- const checkbox = event.target;
- const mappingId = checkbox.dataset.mappingId;
- const value = checkbox.checked ? 1 : 0;
-
- fetch('update_visible_parts.php', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify({
- template_id: ,
- mapping_id: mappingId,
- value: value
- })
- })
- .then(response => response.json())
- .then(data => {
- if (!data.success) {
- console.error("❌ Error updating is_visible_parts:", data.message);
- checkbox.checked = !checkbox.checked;
- }
- })
- .catch(error => {
- console.error("❌ Fetch error:", error);
- checkbox.checked = !checkbox.checked;
- });
}
});
@@ -1081,7 +1064,7 @@ $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], t
mappedColumn = document.createElement('span');
mappedColumn.className = 'mapped-column';
mappedColumn.style.marginLeft = '5px';
- tr.querySelector('td:nth-child(5)').appendChild(mappedColumn);
+ tr.querySelector('td:nth-child(6)').appendChild(mappedColumn);
}
if (!removeBtn) {
removeBtn = document.createElement('button');
@@ -1089,7 +1072,7 @@ $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], t
removeBtn.textContent = 'X';
removeBtn.style.marginLeft = '5px';
removeBtn.setAttribute('data-id', mappingId);
- tr.querySelector('td:nth-child(5)').appendChild(removeBtn);
+ tr.querySelector('td:nth-child(6)').appendChild(removeBtn);
removeBtn.addEventListener('click', function(e) {
let tr = e.target.closest('tr');