Change hardcoded messages into entries in messages file. #649
This commit is contained in:
parent
ae477ea440
commit
a5a30ec7f9
11 changed files with 49 additions and 26 deletions
|
|
@ -7,11 +7,14 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
use App\Service\RisingTideGateway;
|
use App\Service\RisingTideGateway;
|
||||||
|
|
||||||
class TestSMSCommand extends Command
|
class TestSMSCommand extends Command
|
||||||
{
|
{
|
||||||
protected $gateway;
|
protected $gateway;
|
||||||
|
protected $translator;
|
||||||
|
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
|
|
@ -21,9 +24,10 @@ class TestSMSCommand extends Command
|
||||||
->addArgument('destination', InputArgument::REQUIRED, 'Destination number to send to');
|
->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->gateway = $gateway;
|
||||||
|
$this->translator = $translator;
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
@ -34,7 +38,7 @@ class TestSMSCommand extends Command
|
||||||
|
|
||||||
error_log('sending sms to ' . $number);
|
error_log('sending sms to ' . $number);
|
||||||
$msg = 'This is a test.';
|
$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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
use App\Service\RisingTideGateway;
|
use App\Service\RisingTideGateway;
|
||||||
|
|
@ -18,6 +20,7 @@ class WarrantySMSCommand extends Command
|
||||||
{
|
{
|
||||||
protected $gateway;
|
protected $gateway;
|
||||||
protected $em;
|
protected $em;
|
||||||
|
protected $translator;
|
||||||
|
|
||||||
protected function configure()
|
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.');
|
->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->em = $em;
|
||||||
$this->gateway = $gateway;
|
$this->gateway = $gateway;
|
||||||
|
$this->translator = $translator;
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
@ -97,10 +101,10 @@ class WarrantySMSCommand extends Command
|
||||||
error_log(print_r($valid_numbers, true));
|
error_log(print_r($valid_numbers, true));
|
||||||
foreach ($valid_numbers as $wdata)
|
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);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -242,11 +242,11 @@ class APIController extends Controller implements LoggedController
|
||||||
return sprintf("%06d", mt_rand(100000, 999999));
|
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
|
// send sms to number
|
||||||
$message = "Your Resq confirmation code is $code.";
|
$message = $translator->trans('message.confirmation_code') . ' ' . $code;
|
||||||
$rt->sendSMS($phone_number, 'MOTOLITE', $message);
|
$rt->sendSMS($phone_number, $translator->trans('message.battery_brand_allcaps'), $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function confirmNumber(RisingTideGateway $rt, Request $req)
|
public function confirmNumber(RisingTideGateway $rt, Request $req)
|
||||||
|
|
@ -4078,7 +4078,7 @@ class APIController extends Controller implements LoggedController
|
||||||
|
|
||||||
// send sms
|
// send sms
|
||||||
error_log('sending sms to - ' . $this->session->getPhoneNumber());
|
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;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -578,12 +578,12 @@ class CustomerWarrantyController extends APIController
|
||||||
|
|
||||||
|
|
||||||
// send sms confirmation
|
// 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);
|
return new APIResponse(true, 'Warranty registered.', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function sendSMSConfirmation($rt, $num, $message)
|
protected function sendSMSConfirmation($rt, $num, $message, $trans)
|
||||||
{
|
{
|
||||||
$clean_num = trim($num);
|
$clean_num = trim($num);
|
||||||
|
|
||||||
|
|
@ -602,6 +602,6 @@ class CustomerWarrantyController extends APIController
|
||||||
|
|
||||||
error_log('sending sms to - ' . $clean_num);
|
error_log('sending sms to - ' . $clean_num);
|
||||||
|
|
||||||
$rt->sendSMS($clean_num, 'MOTOLITE', $message);
|
$rt->sendSMS($clean_num, $trans->trans('message.battery_brand_allcaps'), $message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
|
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
|
||||||
|
|
||||||
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
use Doctrine\ORM\Query;
|
use Doctrine\ORM\Query;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
|
@ -747,7 +749,7 @@ class RiderAppController extends APIController
|
||||||
}
|
}
|
||||||
|
|
||||||
public function payment(Request $req, EntityManagerInterface $em, JobOrderHandlerInterface $jo_handler,
|
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'];
|
$required_params = ['jo_id'];
|
||||||
|
|
||||||
|
|
@ -807,9 +809,8 @@ class RiderAppController extends APIController
|
||||||
$phone_number = $jo->getCustomer()->getPhoneMobile();
|
$phone_number = $jo->getCustomer()->getPhoneMobile();
|
||||||
if (!empty($phone_number))
|
if (!empty($phone_number))
|
||||||
{
|
{
|
||||||
// TODO: put this in config file or somewhere
|
$message = $translator->trans('message.joborder_completed');
|
||||||
$message = "Your Resq job order has been completed.";
|
$rt->sendSMS($phone_number, $translator->trans('message.battery_brand_allcaps'), $message);
|
||||||
$rt->sendSMS($phone_number, 'MOTOLITE', $message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
|
||||||
|
|
@ -458,7 +458,7 @@ class HubSelector
|
||||||
{
|
{
|
||||||
// send SMS message
|
// send SMS message
|
||||||
error_log('sending sms to - ' . $mobile_number);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3540,8 +3540,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
public function sendSMSToCustomer($phone_number)
|
public function sendSMSToCustomer($phone_number)
|
||||||
{
|
{
|
||||||
// TODO: put this in config file or somewhere
|
// TODO: put this in config file or somewhere
|
||||||
$message = "Your Resq job order has been completed.";
|
$message = $this->translator->trans('message.joborder_completed');
|
||||||
$this->rt->sendSMS($phone_number, 'MOTOLITE', $message);
|
$this->rt->sendSMS($phone_number, $this->translator->trans('message.battery_brand_allcaps'), $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
|
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
|
||||||
|
|
||||||
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
use App\Ramcar\ServiceType;
|
use App\Ramcar\ServiceType;
|
||||||
use App\Ramcar\TradeInType;
|
use App\Ramcar\TradeInType;
|
||||||
use App\Ramcar\JOStatus;
|
use App\Ramcar\JOStatus;
|
||||||
|
|
@ -57,7 +59,7 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
string $country_code, MQTTClient $mclient,
|
string $country_code, MQTTClient $mclient,
|
||||||
WarrantyHandler $wh, JobOrderHandlerInterface $jo_handler,
|
WarrantyHandler $wh, JobOrderHandlerInterface $jo_handler,
|
||||||
InvoiceGeneratorInterface $ic, RisingTideGateway $rt,
|
InvoiceGeneratorInterface $ic, RisingTideGateway $rt,
|
||||||
RiderTracker $rider_tracker)
|
RiderTracker $rider_tracker, TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->redis = $redis;
|
$this->redis = $redis;
|
||||||
|
|
@ -70,6 +72,7 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
$this->ic = $ic;
|
$this->ic = $ic;
|
||||||
$this->rt = $rt;
|
$this->rt = $rt;
|
||||||
$this->rider_tracker = $rider_tracker;
|
$this->rider_tracker = $rider_tracker;
|
||||||
|
$this->translator = $translator;
|
||||||
|
|
||||||
// one device = one session, since we have control over the devices
|
// 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
|
// 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();
|
$phone_number = $jo->getCustomer()->getPhoneMobile();
|
||||||
if (!empty($phone_number))
|
if (!empty($phone_number))
|
||||||
{
|
{
|
||||||
// TODO: put this in config file or somewhere
|
$message = $this->translator->trans('message.joborder_completed');
|
||||||
$message = "Your Resq job order has been completed.";
|
$this->rt->sendSMS($phone_number, $this->translator->trans('message.battery_brand_allcaps'), $message);
|
||||||
$this->rt->sendSMS($phone_number, 'MOTOLITE', $message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ namespace App\Service\RiderAssignmentHandler;
|
||||||
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
use App\Service\RiderAssignmentHandlerInterface;
|
use App\Service\RiderAssignmentHandlerInterface;
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
use App\Service\APNSClient;
|
use App\Service\APNSClient;
|
||||||
|
|
@ -18,13 +20,15 @@ class ResqRiderAssignmentHandler implements RiderAssignmentHandlerInterface
|
||||||
protected $em;
|
protected $em;
|
||||||
protected $aclient;
|
protected $aclient;
|
||||||
protected $mclient;
|
protected $mclient;
|
||||||
|
protected $translator;
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $em, MQTTClient $mclient,
|
public function __construct(EntityManagerInterface $em, MQTTClient $mclient,
|
||||||
APNSClient $aclient)
|
APNSClient $aclient, TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->mclient = $mclient;
|
$this->mclient = $mclient;
|
||||||
$this->aclient = $aclient;
|
$this->aclient = $aclient;
|
||||||
|
$this->translator = $translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign job order to rider
|
// assign job order to rider
|
||||||
|
|
@ -49,7 +53,7 @@ class ResqRiderAssignmentHandler implements RiderAssignmentHandlerInterface
|
||||||
$this->mclient->sendRiderEvent($obj, $payload);
|
$this->mclient->sendRiderEvent($obj, $payload);
|
||||||
|
|
||||||
// send push notification
|
// 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();
|
$this->em->flush();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -288,7 +288,7 @@
|
||||||
<span class="m-switch m-switch--icon block-switch">
|
<span class="m-switch m-switch--icon block-switch">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" name="flag_motolite_battery" id="flag-motolite-battery" value="1" {{ obj.getCustomerVehicle.getCurrentBattery|default(false) ? obj.getCustomerVehicle.hasMotoliteBattery ? ' checked' }} disabled>
|
<input type="checkbox" name="flag_motolite_battery" id="flag-motolite-battery" value="1" {{ obj.getCustomerVehicle.getCurrentBattery|default(false) ? obj.getCustomerVehicle.hasMotoliteBattery ? ' checked' }} disabled>
|
||||||
<label class="switch-label">This vehicle is using a Motolite battery</label>
|
<label class="switch-label">{% trans %}label.jo.vehicle_battery{% endtrans %}</label>
|
||||||
<span></span>
|
<span></span>
|
||||||
</label>
|
</label>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
||||||
|
|
@ -71,3 +71,11 @@ label.pdf.emp_id_ref: 'Emp. ID/Card No./Ref. By:'
|
||||||
label.pdf.discount: 'DISCOUNT:'
|
label.pdf.discount: 'DISCOUNT:'
|
||||||
label.pdf.discount_type: 'Discount Type:'
|
label.pdf.discount_type: 'Discount Type:'
|
||||||
label.pdf.final_amount: 'FINAL AMOUNT:'
|
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.'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue