Auto-update ticket status to käsittelyssä on first reply
- zammad_reply endpoint now sets intra status uusi→kasittelyssa - Also updates Zammad ticket state to open - Fixed stateMap: Zammad open now maps to kasittelyssa instead of avoin Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
17
api.php
17
api.php
@@ -5379,7 +5379,7 @@ switch ($action) {
|
||||
|
||||
// Zammad state → intran status
|
||||
$stateMap = [
|
||||
'new' => 'uusi', 'open' => 'avoin', 'pending reminder' => 'odottaa',
|
||||
'new' => 'uusi', 'open' => 'kasittelyssa', 'pending reminder' => 'odottaa',
|
||||
'pending close' => 'odottaa', 'closed' => 'suljettu',
|
||||
'merged' => 'suljettu', 'removed' => 'suljettu',
|
||||
];
|
||||
@@ -5638,6 +5638,21 @@ switch ($action) {
|
||||
$attachments
|
||||
);
|
||||
|
||||
// Päivitä tila: uusi → käsittelyssä (sekä intra että Zammad)
|
||||
if ($ticket['status'] === 'uusi') {
|
||||
_dbExecute(
|
||||
"UPDATE tickets SET status = 'kasittelyssa' WHERE id = ? AND company_id = ?",
|
||||
[$ticketId, $companyId]
|
||||
);
|
||||
// Päivitä Zammadiin: state → open
|
||||
try {
|
||||
$z->updateTicket((int)$ticket['zammad_ticket_id'], ['state' => 'open']);
|
||||
} catch (\Throwable $e) {
|
||||
// Ei estä vastauksen tallennusta — logita virhe
|
||||
error_log("Zammad state update failed: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// Tallenna To/CC/BCC tiketille pysyvästi
|
||||
_dbExecute(
|
||||
"UPDATE tickets SET to_email = ?, cc = ?, bcc = ? WHERE id = ? AND company_id = ?",
|
||||
|
||||
Reference in New Issue
Block a user