Move checking for phone number and rejection reason. #738

This commit is contained in:
Korina Cordero 2023-02-28 08:02:11 +00:00
parent 5dc4d9f3f8
commit e102766961

View file

@ -1661,14 +1661,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$em->persist($obj); $em->persist($obj);
$em->flush(); $em->flush();
// check the reason. if administrative, do not send SMS $this->sendSMSHubRejection($obj, $jo);
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);
}
} }
return $error_array; return $error_array;
@ -4017,8 +4010,21 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$this->rt->sendSMS($phone_number, $this->translator->trans('message.battery_brand_allcaps'), $message); $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 // sms content
// Job Order # - can get from jo // Job Order # - can get from jo
// Order Date and Time - get from jo // Order Date and Time - get from jo
@ -4028,7 +4034,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// Remarks - get from rejection // Remarks - get from rejection
// Type of Service - get from jo // Type of Service - get from jo
$hub = $rejection->getHub();
$jo_id = $jo->getID(); $jo_id = $jo->getID();
// convert to string format the date fields (order date and time and date and time rejected) // convert to string format the date fields (order date and time and date and time rejected)