diff --git a/src/Command/TestSMSCommand.php b/src/Command/TestSMSCommand.php index f431398f..99aaf36f 100644 --- a/src/Command/TestSMSCommand.php +++ b/src/Command/TestSMSCommand.php @@ -7,11 +7,14 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Contracts\Translation\TranslatorInterface; + use App\Service\RisingTideGateway; class TestSMSCommand extends Command { protected $gateway; + protected $translator; protected function configure() { @@ -21,9 +24,10 @@ class TestSMSCommand extends Command ->addArgument('destination', InputArgument::REQUIRED, 'Destination number to send to'); } - public function __construct(RisingTideGateway $gateway) + public function __construct(RisingTideGateway $gateway, TranslatorInterface $translator) { $this->gateway = $gateway; + $this->translator = $translator; parent::__construct(); } @@ -34,7 +38,7 @@ class TestSMSCommand extends Command error_log('sending sms to ' . $number); $msg = 'This is a test.'; - $this->gateway->sendSMS($number, 'MOTOLITE', $msg); + $this->gateway->sendSMS($number, $this->translator->trans('message.battery_brand_allcaps'), $msg); return 0; } diff --git a/src/Command/WarrantySMSCommand.php b/src/Command/WarrantySMSCommand.php index 14f4c531..77868a9b 100644 --- a/src/Command/WarrantySMSCommand.php +++ b/src/Command/WarrantySMSCommand.php @@ -7,6 +7,8 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Contracts\Translation\TranslatorInterface; + use Doctrine\ORM\EntityManagerInterface; use App\Service\RisingTideGateway; @@ -18,6 +20,7 @@ class WarrantySMSCommand extends Command { protected $gateway; protected $em; + protected $translator; protected function configure() { @@ -27,10 +30,11 @@ class WarrantySMSCommand extends Command ->addArgument('date', InputArgument::OPTIONAL, 'Date to use as basis of expiration. Defaults to current date.'); } - public function __construct(EntityManagerInterface $em, RisingTideGateway $gateway) + public function __construct(EntityManagerInterface $em, RisingTideGateway $gateway, TranslatorInterface $translator) { $this->em = $em; $this->gateway = $gateway; + $this->translator = $translator; parent::__construct(); } @@ -97,10 +101,10 @@ class WarrantySMSCommand extends Command error_log(print_r($valid_numbers, true)); foreach ($valid_numbers as $wdata) { - $msg = 'Hi ' . $wdata['name'] . ', the warranty for the ' . $wdata['batt'] . ' installed in your car(' . $wdata['plate'] . ') has expired already. Please call MOTOLITE EXPRESS HATID at 8370-6686 to have the status of your battery checked to avoid any inconvenience. Thank you for choosing Motolite.'; + $msg = 'Hi ' . $wdata['name'] . ', the warranty for the ' . $wdata['batt'] . ' installed in your car(' . $wdata['plate'] . $this->translator->trans('message.partial_warrantysms'); error_log($wdata['number'] . ' - sending ' . $msg); - $this->gateway->sendSMS($wdata['number'], 'MOTOLITE', $msg); + $this->gateway->sendSMS($wdata['number'], $this->translator->trans('message.battery_brand_allcaps'), $msg); } diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index c3a4bbf9..9fdd58a2 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -242,11 +242,11 @@ class APIController extends Controller implements LoggedController return sprintf("%06d", mt_rand(100000, 999999)); } - protected function sendConfirmationCode(RisingTideGateway $rt, $phone_number, $code) + protected function sendConfirmationCode(RisingTideGateway $rt, $phone_number, $code, TranslatorInterface $translator) { // send sms to number - $message = "Your Resq confirmation code is $code."; - $rt->sendSMS($phone_number, 'MOTOLITE', $message); + $message = $translator->trans('message.confirmation_code') . ' ' . $code; + $rt->sendSMS($phone_number, $translator->trans('message.battery_brand_allcaps'), $message); } public function confirmNumber(RisingTideGateway $rt, Request $req) @@ -4078,7 +4078,7 @@ class APIController extends Controller implements LoggedController // send sms error_log('sending sms to - ' . $this->session->getPhoneNumber()); - $rt->sendSMS($this->session->getPhoneNumber(), 'MOTOLITE', $sms_msg); + $rt->sendSMS($this->session->getPhoneNumber(), $trans->trans('message.battery_brand_allcaps'), $sms_msg); return $res; } diff --git a/src/Controller/CAPI/CustomerWarrantyController.php b/src/Controller/CAPI/CustomerWarrantyController.php index bd75997b..0db793b5 100644 --- a/src/Controller/CAPI/CustomerWarrantyController.php +++ b/src/Controller/CAPI/CustomerWarrantyController.php @@ -578,12 +578,12 @@ class CustomerWarrantyController extends APIController // send sms confirmation - $this->sendSMSConfirmation($rt, $req->request->get('contact_num'), $sms_message); + $this->sendSMSConfirmation($rt, $req->request->get('contact_num'), $sms_message, $trans); return new APIResponse(true, 'Warranty registered.', $data); } - protected function sendSMSConfirmation($rt, $num, $message) + protected function sendSMSConfirmation($rt, $num, $message, $trans) { $clean_num = trim($num); @@ -602,6 +602,6 @@ class CustomerWarrantyController extends APIController error_log('sending sms to - ' . $clean_num); - $rt->sendSMS($clean_num, 'MOTOLITE', $message); + $rt->sendSMS($clean_num, $trans->trans('message.battery_brand_allcaps'), $message); } } diff --git a/src/Controller/CAPI/RiderAppController.php b/src/Controller/CAPI/RiderAppController.php index 0136b0b8..6b56e83e 100644 --- a/src/Controller/CAPI/RiderAppController.php +++ b/src/Controller/CAPI/RiderAppController.php @@ -6,6 +6,8 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface; +use Symfony\Contracts\Translation\TranslatorInterface; + use Doctrine\ORM\Query; use Doctrine\ORM\EntityManagerInterface; @@ -747,7 +749,7 @@ class RiderAppController extends APIController } public function payment(Request $req, EntityManagerInterface $em, JobOrderHandlerInterface $jo_handler, - RisingTideGateway $rt, WarrantyHandler $wh, MQTTClient $mclient) + RisingTideGateway $rt, WarrantyHandler $wh, MQTTClient $mclient, TranslatorInterface $translator) { $required_params = ['jo_id']; @@ -807,9 +809,8 @@ class RiderAppController extends APIController $phone_number = $jo->getCustomer()->getPhoneMobile(); if (!empty($phone_number)) { - // TODO: put this in config file or somewhere - $message = "Your Resq job order has been completed."; - $rt->sendSMS($phone_number, 'MOTOLITE', $message); + $message = $translator->trans('message.joborder_completed'); + $rt->sendSMS($phone_number, $translator->trans('message.battery_brand_allcaps'), $message); } $em->flush(); diff --git a/src/Service/HubSelector.php b/src/Service/HubSelector.php index 826a45d2..cf6cdd28 100644 --- a/src/Service/HubSelector.php +++ b/src/Service/HubSelector.php @@ -458,7 +458,7 @@ class HubSelector { // send SMS message error_log('sending sms to - ' . $mobile_number); - $this->rt->sendSMS($mobile_number, 'MOTOLITE', $message); + $this->rt->sendSMS($mobile_number, $this->trans->trans('message.battery_brand_allcaps'), $message); } } } diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index fcfd5201..a5ce340a 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -3540,8 +3540,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface 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); + $message = $this->translator->trans('message.joborder_completed'); + $this->rt->sendSMS($phone_number, $this->translator->trans('message.battery_brand_allcaps'), $message); } } diff --git a/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php b/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php index db83076b..3f10c763 100644 --- a/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php +++ b/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php @@ -6,6 +6,8 @@ use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface; +use Symfony\Contracts\Translation\TranslatorInterface; + use App\Ramcar\ServiceType; use App\Ramcar\TradeInType; use App\Ramcar\JOStatus; @@ -57,7 +59,7 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface string $country_code, MQTTClient $mclient, WarrantyHandler $wh, JobOrderHandlerInterface $jo_handler, InvoiceGeneratorInterface $ic, RisingTideGateway $rt, - RiderTracker $rider_tracker) + RiderTracker $rider_tracker, TranslatorInterface $translator) { $this->em = $em; $this->redis = $redis; @@ -70,6 +72,7 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface $this->ic = $ic; $this->rt = $rt; $this->rider_tracker = $rider_tracker; + $this->translator = $translator; // one device = one session, since we have control over the devices // when a rider logs in, we just change the rider assigned to the device @@ -595,9 +598,8 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface $phone_number = $jo->getCustomer()->getPhoneMobile(); if (!empty($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); + $message = $this->translator->trans('message.joborder_completed'); + $this->rt->sendSMS($phone_number, $this->translator->trans('message.battery_brand_allcaps'), $message); } $this->em->flush(); diff --git a/src/Service/RiderAssignmentHandler/ResqRiderAssignmentHandler.php b/src/Service/RiderAssignmentHandler/ResqRiderAssignmentHandler.php index ddaf985e..6592734a 100644 --- a/src/Service/RiderAssignmentHandler/ResqRiderAssignmentHandler.php +++ b/src/Service/RiderAssignmentHandler/ResqRiderAssignmentHandler.php @@ -4,6 +4,8 @@ namespace App\Service\RiderAssignmentHandler; use Doctrine\ORM\EntityManagerInterface; +use Symfony\Contracts\Translation\TranslatorInterface; + use App\Service\RiderAssignmentHandlerInterface; use App\Service\MQTTClient; use App\Service\APNSClient; @@ -18,13 +20,15 @@ class ResqRiderAssignmentHandler implements RiderAssignmentHandlerInterface protected $em; protected $aclient; protected $mclient; + protected $translator; public function __construct(EntityManagerInterface $em, MQTTClient $mclient, - APNSClient $aclient) + APNSClient $aclient, TranslatorInterface $translator) { $this->em = $em; $this->mclient = $mclient; $this->aclient = $aclient; + $this->translator = $translator; } // assign job order to rider @@ -49,7 +53,7 @@ class ResqRiderAssignmentHandler implements RiderAssignmentHandlerInterface $this->mclient->sendRiderEvent($obj, $payload); // send push notification - $this->aclient->sendPush($obj, "A RESQ rider is on his way to you."); + $this->aclient->sendPush($obj, $this->translator->trans('message.rider_otw')); $this->em->flush(); } diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig index e85a89f3..4fff73e0 100644 --- a/templates/job-order/form.html.twig +++ b/templates/job-order/form.html.twig @@ -288,7 +288,7 @@ diff --git a/translations/messages.en.yaml b/translations/messages.en.yaml index 75f17ce6..78f1b0d4 100644 --- a/translations/messages.en.yaml +++ b/translations/messages.en.yaml @@ -71,3 +71,11 @@ label.pdf.emp_id_ref: 'Emp. ID/Card No./Ref. By:' label.pdf.discount: 'DISCOUNT:' label.pdf.discount_type: 'Discount Type:' label.pdf.final_amount: 'FINAL AMOUNT:' +label.jo.vehicle_battery: 'This vehicle is using a Motolite battery' + +# messages +message.partial_warrantysms: ') has expired already. Please call MOTOLITE EXPRESS HATID at 8370-6686 to have the status of your battery checked to avoid any inconvenience. Thank you for choosing Motolite.' +message.battery_brand_allcaps: 'MOTOLITE' +message.confirmation_code: 'Your Resq confirmation code is' +message.joborder_completed: 'Your Resq job order has been completed.' +message.rider_otw: 'A RESQ rider is on his way to you.'