diff --git a/public/dev.html b/public/dev.html index 3af04c5..f4ec429 100644 --- a/public/dev.html +++ b/public/dev.html @@ -234,6 +234,18 @@ color: #333; word-break: break-word; white-space: pre-line; + margin-left: 16px; + } + + .price-age { + margin-left: 6px; + font-size: 0.9em; + color: #555; + } + + .price-age--old { + color: #c62828; + font-weight: 600; } .field-value .part-link { @@ -474,10 +486,11 @@ { key: 'Bez', label: 'Bezeichnung' }, { key: 'Bez2', label: 'Bezeichnung 2' }, { key: 'Ben8', label: 'Bezeichnung 3' }, - { key: 'Ben7', label: 'Eng 3' }, + { key: 'Ben7', label: 'Englischer Text' }, { key: 'Hersteller', label: 'Hersteller' }, { key: 'Text', label: 'Zusatztext' }, { key: 'PrsVK', label: 'Verkaufspreis in €' }, + { key: 'Ben43', label: 'Zeichnungsnummer' }, { key: 'Ersatz', label: 'Ersetzt durch' } ]; @@ -527,9 +540,26 @@ displayValue = `${safePart}`; } else if (key === 'PrsVK') { const isVkTeil = record.VkTeil != null && Number(record.VkTeil) !== 0; - displayValue = isVkTeil && value != null && String(value).trim() !== '' - ? highlightSearchTerm(String(value)) - : escapeHtml('kein Verkaufsteil'); + if (isVkTeil && value != null && String(value).trim() !== '') { + const priceText = highlightSearchTerm(String(value)); + const priceTermStr = record.PrsVkTerm || record.PrsVKTerm; + let ageHtml = ''; + if (priceTermStr) { + const priceDate = new Date(priceTermStr); + if (!isNaN(priceDate)) { + const now = new Date(); + const diffMs = now.getTime() - priceDate.getTime(); + const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24)); + const ageText = `${diffDays} Tage alt`; + const isOld = diffDays > 182; // > ca. 6 Monate + const ageClass = isOld ? 'price-age price-age--old' : 'price-age'; + ageHtml = ` (${escapeHtml(ageText)})`; + } + } + displayValue = `${priceText}${ageHtml}`; + } else { + displayValue = escapeHtml('kein Verkaufsteil'); + } } else { displayValue = value === null || value === undefined ? '' : highlightSearchTerm(String(value)); } diff --git a/services/searchService.js b/services/searchService.js index e3bbc7d..1ed8b2b 100644 --- a/services/searchService.js +++ b/services/searchService.js @@ -17,6 +17,7 @@ const TEILE_SEARCH_COLUMNS = [ 'Bez2', 'Ben7', 'Ben8', + 'Ben43', 'Hersteller' ]; @@ -117,12 +118,14 @@ const fullTextSearch = async (searchTerm, statusFilter) => { t.Bez2, t.Ben7, t.Ben8, + t.Ben43, t.Hersteller, t.Stat, t.VkTeil, txt.Text AS [Text], ts.PrsVk AS PrsVK, - ts.Ersatz AS Ersatz + ts.Ersatz AS Ersatz, + ts.PrsVkTerm FROM [${tableConfig.tableName}] t WITH (NOLOCK) OUTER APPLY ( SELECT TOP 1 MemoID @@ -137,7 +140,10 @@ const fullTextSearch = async (searchTerm, statusFilter) => { WHERE tx.TextId = ek.MemoID ) txt OUTER APPLY ( - SELECT TOP 1 PrsVk, Ersatz + SELECT TOP 1 + PrsVk, + Ersatz, + PrsVkTerm FROM TSSAEF WITH (NOLOCK) WHERE Teil = t.Teil ORDER BY ISN