From a1aa642849f3bcb998d1371eca9978ebe69881aa Mon Sep 17 00:00:00 2001 From: Xenomporio <> Date: Fri, 5 Aug 2022 17:08:41 +0200 Subject: [PATCH] Bugfix incoming tickets select warteschlange and adresse --- .../Ticket/Task/TicketImportHelper.php | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/classes/Modules/Ticket/Task/TicketImportHelper.php b/classes/Modules/Ticket/Task/TicketImportHelper.php index 53677a09..cd641bda 100644 --- a/classes/Modules/Ticket/Task/TicketImportHelper.php +++ b/classes/Modules/Ticket/Task/TicketImportHelper.php @@ -91,7 +91,7 @@ class TicketImportHelper $id = $this->db->Select($searchByEmail); if ($id !== null && $id > 0) { - return $id; + return (int) $id; } $searchByResponsePerson = 'SELECT ap.adresse FROM `ansprechpartner` AS `ap` @@ -99,14 +99,14 @@ class TicketImportHelper ORDER BY ap.id DESC'; $id = $this->db->Select($searchByResponsePerson); if ($id !== null && $id > 0) { - return $id; + return (int) $id; } $searchByContactInfo = 'SELECT ak.adresse FROM `adresse_kontakte` AS `ak` WHERE ak.kontakt LIKE \''.$emailAddress.'\' ORDER BY ak.id DESC'; $id = $this->db->Select($searchByContactInfo); - return $id; + return (int) $id; } /* Some functions taken from TicketService (sorry...) */ @@ -244,12 +244,8 @@ class TicketImportHelper string $replyToAddress ): string { - $assigneeAddressId = $this->mailAccount->getAddressId(); - if ($assigneeAddressId < 1) { - $assigneeAddressId = $this->tryGetAddressIdByEmailAddress( - $this->mailAccount->getEmailAddress() - ); - } + $AddressId = $this->tryGetAddressIdByEmailAddress($senderAddress); + $ticketNumber = $this->generateRandomTicketNumber(); if($projectId < 1) { @@ -261,6 +257,12 @@ class TicketImportHelper $status = 'neu'; //TicketGateway::STATUS_NEW; } + $queue_id = $this->mailAccount->getTicketQueueId(); + + if (!empty($queue_id)) { + $queue_label = $this->db->Select("SELECT label FROM warteschlangen WHERE id = ".$queue_id." LIMIT 1"); + } + $insertTicket = "INSERT INTO `ticket` ( `schluessel`, `zeit`, `projekt`, `quelle`, `status`, `kunde`, `mailadresse`, `prio`, `betreff`,`warteschlange`,`adresse` @@ -274,13 +276,13 @@ class TicketImportHelper '".$senderAddress."', '".'3'."', '".$subject."', - '".$this->mailAccount->getTicketQueueId()."', - '".$assigneeAddressId."');"; + '".$queue_label."', + '".$AddressId."');"; $this->db->Insert($insertTicket); $ticketId = $this->db->GetInsertID(); - $this->logger->debug('inserted ticket',['id' => $ticketId,'ticketnr' => $ticketNumber]); + $this->logger->debug('inserted ticket',['id' => $ticketId,'ticketnr' => $ticketNumber, 'projekt' => $projectId, 'warteschlange' => $this->mailAccount->getTicketQueueId(), 'adresse' => $AddressId]); // todo als rueckgabe ticketnachricht return $ticketNumber;