feat: TO-kenttä näkyviin vastauslomakkeessa

- 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 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 22:12:12 +02:00
parent 83509fffc5
commit 5d6aa981b2
3 changed files with 13 additions and 1 deletions

View File

@@ -2075,6 +2075,7 @@ switch ($action) {
$id = $input['id'] ?? ''; $id = $input['id'] ?? '';
$body = trim($input['body'] ?? ''); $body = trim($input['body'] ?? '');
$replyMailboxId = $input['mailbox_id'] ?? ''; $replyMailboxId = $input['mailbox_id'] ?? '';
$replyTo = trim($input['to'] ?? '');
$replyCc = trim($input['cc'] ?? ''); $replyCc = trim($input['cc'] ?? '');
if (empty($body)) { if (empty($body)) {
http_response_code(400); http_response_code(400);
@@ -2124,7 +2125,8 @@ switch ($action) {
$ccToSend = $replyCc !== '' ? $replyCc : ($t['cc'] ?? ''); $ccToSend = $replyCc !== '' ? $replyCc : ($t['cc'] ?? '');
$subject = 'Re: ' . $t['subject']; $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) { if (!$sent) {
http_response_code(500); http_response_code(500);

View File

@@ -452,6 +452,10 @@
<label style="font-size:0.8rem;color:#888;min-width:60px;">Lähettäjä:</label> <label style="font-size:0.8rem;color:#888;min-width:60px;">Lähettäjä:</label>
<select id="reply-mailbox-select" style="flex:1;padding:5px 10px;border:1px solid #ddd;border-radius:6px;font-size:0.85rem;"></select> <select id="reply-mailbox-select" style="flex:1;padding:5px 10px;border:1px solid #ddd;border-radius:6px;font-size:0.85rem;"></select>
</div> </div>
<div style="display:flex;align-items:center;gap:0.5rem;">
<label style="font-size:0.8rem;color:#888;min-width:60px;">Vast.ott.:</label>
<input type="text" id="reply-to" style="flex:1;padding:5px 10px;border:1px solid #ddd;border-radius:6px;font-size:0.85rem;">
</div>
<div style="display:flex;align-items:center;gap:0.5rem;"> <div style="display:flex;align-items:center;gap:0.5rem;">
<label style="font-size:0.8rem;color:#888;min-width:60px;">CC:</label> <label style="font-size:0.8rem;color:#888;min-width:60px;">CC:</label>
<input type="text" id="reply-cc" placeholder="email1@example.com, email2@example.com" style="flex:1;padding:5px 10px;border:1px solid #ddd;border-radius:6px;font-size:0.85rem;"> <input type="text" id="reply-cc" placeholder="email1@example.com, email2@example.com" style="flex:1;padding:5px 10px;border:1px solid #ddd;border-radius:6px;font-size:0.85rem;">

View File

@@ -1579,6 +1579,10 @@ async function showTicketDetail(id, companyId = '') {
document.querySelector('.btn-reply-tab[data-reply-type="reply"]').classList.add('active'); document.querySelector('.btn-reply-tab[data-reply-type="reply"]').classList.add('active');
document.getElementById('btn-send-reply').textContent = 'Lähetä vastaus'; 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ä // CC-kenttä — täytetään tiketin CC:stä
const ccField = document.getElementById('reply-cc'); const ccField = document.getElementById('reply-cc');
if (ccField) ccField.value = ticket.cc || ''; if (ccField) ccField.value = ticket.cc || '';
@@ -1709,9 +1713,11 @@ document.getElementById('btn-send-reply').addEventListener('click', async () =>
const payload = { id: currentTicketId, body }; const payload = { id: currentTicketId, body };
if (ticketReplyType !== 'note') { if (ticketReplyType !== 'note') {
const mbSel = document.getElementById('reply-mailbox-select'); const mbSel = document.getElementById('reply-mailbox-select');
const toFld = document.getElementById('reply-to');
const ccFld = document.getElementById('reply-cc'); const ccFld = document.getElementById('reply-cc');
const useSig = document.getElementById('reply-use-signature'); const useSig = document.getElementById('reply-use-signature');
if (mbSel) payload.mailbox_id = mbSel.value; 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 (ccFld) payload.cc = ccFld.value.trim();
if (useSig && !useSig.checked) payload.no_signature = true; if (useSig && !useSig.checked) payload.no_signature = true;
} }