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) {
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 => `
`).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');