Send SMS message to customer when JO is fulfilled from admin panel. #464
This commit is contained in:
parent
cf684c21a0
commit
2c48c619b8
1 changed files with 17 additions and 14 deletions
|
|
@ -47,6 +47,7 @@ use App\Service\WarrantyHandler;
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
use App\Service\APNSClient;
|
use App\Service\APNSClient;
|
||||||
use App\Service\MapTools;
|
use App\Service\MapTools;
|
||||||
|
use App\Service\RisingTideGateway;
|
||||||
|
|
||||||
use CrEOF\Spatial\PHP\Types\Geometry\Point;
|
use CrEOF\Spatial\PHP\Types\Geometry\Point;
|
||||||
|
|
||||||
|
|
@ -67,13 +68,14 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
protected $rah;
|
protected $rah;
|
||||||
protected $country_code;
|
protected $country_code;
|
||||||
protected $wh;
|
protected $wh;
|
||||||
|
protected $rt;
|
||||||
|
|
||||||
protected $template_hash;
|
protected $template_hash;
|
||||||
|
|
||||||
public function __construct(Security $security, EntityManagerInterface $em,
|
public function __construct(Security $security, EntityManagerInterface $em,
|
||||||
InvoiceGeneratorInterface $ic, ValidatorInterface $validator,
|
InvoiceGeneratorInterface $ic, ValidatorInterface $validator,
|
||||||
TranslatorInterface $translator, RiderAssignmentHandlerInterface $rah,
|
TranslatorInterface $translator, RiderAssignmentHandlerInterface $rah,
|
||||||
string $country_code, WarrantyHandler $wh)
|
string $country_code, WarrantyHandler $wh, RisingTideGateway $rt)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->ic = $ic;
|
$this->ic = $ic;
|
||||||
|
|
@ -83,6 +85,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$this->rah = $rah;
|
$this->rah = $rah;
|
||||||
$this->country_code = $country_code;
|
$this->country_code = $country_code;
|
||||||
$this->wh = $wh;
|
$this->wh = $wh;
|
||||||
|
$this->rt = $rt;
|
||||||
|
|
||||||
$this->loadTemplates();
|
$this->loadTemplates();
|
||||||
}
|
}
|
||||||
|
|
@ -862,17 +865,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
else
|
else
|
||||||
$reason = $req->request->get('no_wait_reason');
|
$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)) {
|
if (empty($error_array)) {
|
||||||
// coordinates
|
// coordinates
|
||||||
$point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat'));
|
$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'))
|
->setDeliveryAddress($req->request->get('delivery_address'))
|
||||||
->setLandmark($req->request->get('landmark'))
|
->setLandmark($req->request->get('landmark'))
|
||||||
->setWillingToWait($req->request->get('flag_will_wait', false))
|
->setWillingToWait($req->request->get('flag_will_wait', false))
|
||||||
->setReasonsNotWait($reason)
|
->setReasonsNotWait($reason);
|
||||||
->setNoTradeInReason($no_trade_in_reason);
|
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
$errors = $this->validator->validate($obj);
|
$errors = $this->validator->validate($obj);
|
||||||
|
|
@ -982,6 +973,11 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
else
|
else
|
||||||
error_log('Invalid plate number for warranty. Plate number = ' . $obj->getCustomerVehicle()->getPlateNumber());
|
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();
|
$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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue