diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index cf556136..52e67507 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -47,6 +47,7 @@ use App\Service\WarrantyHandler; use App\Service\MQTTClient; use App\Service\APNSClient; use App\Service\MapTools; +use App\Service\RisingTideGateway; use CrEOF\Spatial\PHP\Types\Geometry\Point; @@ -67,13 +68,14 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface protected $rah; protected $country_code; protected $wh; + protected $rt; protected $template_hash; public function __construct(Security $security, EntityManagerInterface $em, InvoiceGeneratorInterface $ic, ValidatorInterface $validator, TranslatorInterface $translator, RiderAssignmentHandlerInterface $rah, - string $country_code, WarrantyHandler $wh) + string $country_code, WarrantyHandler $wh, RisingTideGateway $rt) { $this->em = $em; $this->ic = $ic; @@ -83,6 +85,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $this->rah = $rah; $this->country_code = $country_code; $this->wh = $wh; + $this->rt = $rt; $this->loadTemplates(); } @@ -862,17 +865,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface else $reason = $req->request->get('no_wait_reason'); - // check if trade in - $is_trade_in = $req->request->get('invoice_trade_in_type'); - $no_trade_in_reason = ''; - if (empty($is_trade_in)) - { - $no_trade_in_reason = $req->request->get('no_trade_in_reason'); - - if (empty($no_trade_in_reason)) - $error_array['no_trade_in_reason'] = 'No trade in reason required.'; - } - if (empty($error_array)) { // coordinates $point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat')); @@ -890,8 +882,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setDeliveryAddress($req->request->get('delivery_address')) ->setLandmark($req->request->get('landmark')) ->setWillingToWait($req->request->get('flag_will_wait', false)) - ->setReasonsNotWait($reason) - ->setNoTradeInReason($no_trade_in_reason); + ->setReasonsNotWait($reason); // validate $errors = $this->validator->validate($obj); @@ -982,6 +973,11 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface else error_log('Invalid plate number for warranty. Plate number = ' . $obj->getCustomerVehicle()->getPlateNumber()); } + + // send SMS to customer + $phone_number = $obj->getCustomer()->getPhoneMobile(); + if (!empty($phone_number)) + $this->sendSMSToCustomer($phone_number); } } @@ -3161,4 +3157,11 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $em->flush(); } + public function sendSMSToCustomer($phone_number) + { + // TODO: put this in config file or somewhere + $message = "Your Resq job order has been completed."; + $this->rt->sendSMS($phone_number, 'MOTOLITE', $message); + } + }