From e1027669612f67d3c7ea2562a69d765a12b129c2 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 28 Feb 2023 08:02:11 +0000 Subject: [PATCH] Move checking for phone number and rejection reason. #738 --- .../JobOrderHandler/ResqJobOrderHandler.php | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index 3fe0a7bd..dafab576 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -1661,14 +1661,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $em->persist($obj); $em->flush(); - // check the reason. if administrative, do not send SMS - if ($obj->getReason() != JORejectionReason::ADMINISTRATIVE) - { - // check if hub has valid mobile number - $phone_number = $this->country_code . $hub->getNotifNumber(); - if (!empty($phone_number)) - $this->sendSMSHubRejection($phone_number, $obj, $jo); - } + $this->sendSMSHubRejection($obj, $jo); } return $error_array; @@ -4017,8 +4010,21 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $this->rt->sendSMS($phone_number, $this->translator->trans('message.battery_brand_allcaps'), $message); } - protected function sendSMSHubRejection($phone_number, $rejection, $jo) + protected function sendSMSHubRejection($rejection, $jo) { + $hub = $rejection->getHub(); + + // check if hub has a notification number + $notif_number = $hub->getNotifNumber(); + if (empty($notif_number)) + return null; + else + $phone_number = $this->country_code . $notif_number; + + // check if reason is administrative + if ($rejection->getReason() == JORejectionReason::ADMINISTRATIVE) + return null; + // sms content // Job Order # - can get from jo // Order Date and Time - get from jo @@ -4028,7 +4034,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface // Remarks - get from rejection // Type of Service - get from jo - $hub = $rejection->getHub(); $jo_id = $jo->getID(); // convert to string format the date fields (order date and time and date and time rejected)