diff --git a/api.php b/api.php index 1957565..e8037c1 100644 --- a/api.php +++ b/api.php @@ -3227,12 +3227,26 @@ switch ($action) { if (($art['content_type'] ?? '') === 'text/html') { $body = strip_tags($body, '

- + diff --git a/script.js b/script.js index 49f61cc..05d4c98 100644 --- a/script.js +++ b/script.js @@ -1816,6 +1816,21 @@ async function showTicketDetail(id, companyId = '') { const isNote = m.type === 'note'; const typeClass = (isOut || isAutoReply) ? 'ticket-msg-out' : (isNote ? 'ticket-msg-note' : 'ticket-msg-in'); const typeIcon = isAutoReply ? '⚡ Automaattinen vastaus' : (isOut ? '→ Lähetetty' : (isNote ? '📝 Muistiinpano' : '← Saapunut')); + // Liitteet + let attachmentsHtml = ''; + if (m.attachments && m.attachments.length > 0) { + const attItems = m.attachments.map(att => { + const sizeStr = att.size > 1048576 ? (att.size / 1048576).toFixed(1) + ' MB' : att.size > 1024 ? (att.size / 1024).toFixed(0) + ' KB' : att.size + ' B'; + const icon = att.type && att.type.startsWith('image/') ? '🖼️' : att.type && att.type.includes('pdf') ? '📄' : '📎'; + // Zammad-liite: lataa proxy-endpointin kautta + if (att.id && m.zammad_article_id) { + const dlUrl = `api.php?action=zammad_attachment&ticket_id=${encodeURIComponent(ticket.id)}&article_id=${m.zammad_article_id}&attachment_id=${att.id}&filename=${encodeURIComponent(att.filename)}`; + return `${icon} ${esc(att.filename)} (${sizeStr})`; + } + return `${icon} ${esc(att.filename)} (${sizeStr})`; + }).join(''); + attachmentsHtml = `
${attItems}
`; + } return `
${typeIcon} @@ -1823,6 +1838,7 @@ async function showTicketDetail(id, companyId = '') { ${esc(m.timestamp)}
${m.type === 'email_in' || m.type === 'incoming' || m.type === 'outgoing' ? sanitizeHtml(m.body) : esc(m.body).replace(/\n/g, '
')}
+ ${attachmentsHtml}
`; }).join(''); diff --git a/style.css b/style.css index 0642b4d..2c82851 100644 --- a/style.css +++ b/style.css @@ -1478,6 +1478,38 @@ span.empty { word-break: break-word; } +/* Viestien liitteet */ +.msg-attachments { + display: flex; + flex-wrap: wrap; + gap: 0.4rem; + margin-top: 0.5rem; + padding-top: 0.5rem; + border-top: 1px solid rgba(0,0,0,0.08); +} +.msg-attachment-link { + display: inline-flex; + align-items: center; + gap: 0.25rem; + padding: 0.3rem 0.6rem; + background: rgba(255,255,255,0.7); + border: 1px solid rgba(0,0,0,0.12); + border-radius: 6px; + font-size: 0.8rem; + color: #2563eb; + text-decoration: none; + cursor: pointer; + transition: background 0.15s; +} +.msg-attachment-link:hover { + background: rgba(37,99,235,0.08); + border-color: #2563eb; +} +.msg-att-size { + color: #888; + font-size: 0.75rem; +} + /* Ticket reply form */ .ticket-reply-form { padding-top: 1rem;