From d9944922e913cd1c20d78127e3b23c4582bd1e86 Mon Sep 17 00:00:00 2001 From: Jukka Lampikoski Date: Thu, 12 Mar 2026 00:01:16 +0200 Subject: [PATCH] Poista vanha Tiedostot-osio asiakasprofiilista (korvattu Dokumentit-osiolla) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Poistettu Tiedostot-section, loadFiles-kutsu ja file-upload event listener - Poistettu loadFiles() ja deleteFile() funktiot (formatFileSize jää käyttöön) - Dokumentit-osio korvaa vanhan tiedostojärjestelmän versioituina dokumentteina Co-Authored-By: Claude Opus 4.6 --- script.js | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) diff --git a/script.js b/script.js index 8b653e1..04c9c0b 100644 --- a/script.js +++ b/script.js @@ -589,15 +589,6 @@ function showDetail(id) {
E-laskuvälittäjä
${detailVal(c.elaskuvalittaja)}
${c.lisatiedot ? `

Lisätiedot

${esc(c.lisatiedot)}

` : ''} -

Tiedostot

-
- - Max 20 MB / tiedosto -
-
-

Dokumentit

Ladataan...
@@ -608,22 +599,7 @@ function showDetail(id) { const pricesHidden = document.getElementById('customer-table')?.classList.contains('prices-hidden'); detailModal.querySelector('.modal-content')?.classList.toggle('prices-hidden', !!pricesHidden); detailModal.style.display = 'flex'; - loadFiles(id); loadCustomerDocuments(id); - document.getElementById('file-upload-input').addEventListener('change', async function () { - for (const file of this.files) { - const fd = new FormData(); - fd.append('customer_id', id); - fd.append('file', file); - try { - const res = await fetch(`${API}?action=file_upload`, { method: 'POST', credentials: 'include', body: fd }); - const data = await res.json(); - if (!res.ok) alert(data.error || 'Virhe'); - } catch (e) { alert('Tiedoston lähetys epäonnistui'); } - } - this.value = ''; - loadFiles(id); - }); } async function loadCustomerDocuments(customerId) { @@ -664,34 +640,12 @@ window.openDocEditForCustomer = function(customerId, forceCategory) { openDocEdit(null, forceCategory || null, customerId); }; -async function loadFiles(customerId) { - const fileList = document.getElementById('file-list'); - if (!fileList) return; - try { - const files = await apiCall(`file_list&customer_id=${customerId}`); - if (files.length === 0) { fileList.innerHTML = '

Ei tiedostoja.

'; return; } - fileList.innerHTML = files.map(f => `
-
- ${esc(f.filename)} - ${formatFileSize(f.size)} · ${f.modified} -
- -
`).join(''); - } catch (e) { fileList.innerHTML = '

Virhe ladattaessa tiedostoja.

'; } -} - function formatFileSize(bytes) { if (bytes < 1024) return bytes + ' B'; if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB'; return (bytes / (1024 * 1024)).toFixed(1) + ' MB'; } -async function deleteFile(customerId, filename) { - if (!confirm(`Poistetaanko tiedosto "${filename}"?`)) return; - await apiCall('file_delete', 'POST', { customer_id: customerId, filename }); - loadFiles(customerId); -} - // Detail modal actions document.getElementById('detail-close').addEventListener('click', () => detailModal.style.display = 'none'); document.getElementById('detail-cancel').addEventListener('click', () => detailModal.style.display = 'none');