From 5d6aa981b257735fa7b595a57b89436f4223afb9 Mon Sep 17 00:00:00 2001 From: Jukka Lampikoski Date: Tue, 10 Mar 2026 22:12:12 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20TO-kentt=C3=A4=20n=C3=A4kyviin=20vastau?= =?UTF-8?q?slomakkeessa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Vastaanottaja (TO) näkyy nyt Lähettäjä- ja CC-kenttien välissä - Esitäytetään tiketin alkuperäisen lähettäjän osoitteella - Muokattavissa ennen lähetystä - Backend käyttää frontendistä tullutta TO:ta tai fallbackina from_email Co-Authored-By: Claude Opus 4.6 --- api.php | 4 +++- index.html | 4 ++++ script.js | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/api.php b/api.php index 505e160..373fc48 100644 --- a/api.php +++ b/api.php @@ -2075,6 +2075,7 @@ switch ($action) { $id = $input['id'] ?? ''; $body = trim($input['body'] ?? ''); $replyMailboxId = $input['mailbox_id'] ?? ''; + $replyTo = trim($input['to'] ?? ''); $replyCc = trim($input['cc'] ?? ''); if (empty($body)) { http_response_code(400); @@ -2124,7 +2125,8 @@ switch ($action) { $ccToSend = $replyCc !== '' ? $replyCc : ($t['cc'] ?? ''); $subject = 'Re: ' . $t['subject']; - $sent = sendTicketMail($t['from_email'], $subject, $emailBody, $lastMsgId, trim($allRefs), $replyMailbox, $ccToSend); + $toAddress = $replyTo !== '' ? $replyTo : $t['from_email']; + $sent = sendTicketMail($toAddress, $subject, $emailBody, $lastMsgId, trim($allRefs), $replyMailbox, $ccToSend); if (!$sent) { http_response_code(500); diff --git a/index.html b/index.html index 813b355..28b0c79 100644 --- a/index.html +++ b/index.html @@ -452,6 +452,10 @@ +
+ + +
diff --git a/script.js b/script.js index e9a858d..b120d9c 100644 --- a/script.js +++ b/script.js @@ -1579,6 +1579,10 @@ async function showTicketDetail(id, companyId = '') { document.querySelector('.btn-reply-tab[data-reply-type="reply"]').classList.add('active'); document.getElementById('btn-send-reply').textContent = 'Lähetä vastaus'; + // TO-kenttä — tiketin alkuperäinen lähettäjä + const toField = document.getElementById('reply-to'); + if (toField) toField.value = ticket.from_email || ''; + // CC-kenttä — täytetään tiketin CC:stä const ccField = document.getElementById('reply-cc'); if (ccField) ccField.value = ticket.cc || ''; @@ -1709,9 +1713,11 @@ document.getElementById('btn-send-reply').addEventListener('click', async () => const payload = { id: currentTicketId, body }; if (ticketReplyType !== 'note') { const mbSel = document.getElementById('reply-mailbox-select'); + const toFld = document.getElementById('reply-to'); const ccFld = document.getElementById('reply-cc'); const useSig = document.getElementById('reply-use-signature'); if (mbSel) payload.mailbox_id = mbSel.value; + if (toFld && toFld.value.trim()) payload.to = toFld.value.trim(); if (ccFld) payload.cc = ccFld.value.trim(); if (useSig && !useSig.checked) payload.no_signature = true; }