Add mobile phone validation for JO when new customer is created. #340
This commit is contained in:
parent
6a944eeb16
commit
ac91960bd7
2 changed files with 31 additions and 10 deletions
|
|
@ -687,7 +687,7 @@ class CMBCustomerHandler implements CustomerHandlerInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function validateMobileNumber($mobile_number)
|
public function validateMobileNumber($mobile_number)
|
||||||
{
|
{
|
||||||
if (empty($mobile_number))
|
if (empty($mobile_number))
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ use App\Ramcar\JORejectionReason;
|
||||||
use App\Service\InvoiceGeneratorInterface;
|
use App\Service\InvoiceGeneratorInterface;
|
||||||
use App\Service\JobOrderHandlerInterface;
|
use App\Service\JobOrderHandlerInterface;
|
||||||
use App\Service\RiderAssignmentHandlerInterface;
|
use App\Service\RiderAssignmentHandlerInterface;
|
||||||
|
use App\Service\CustomerHandlerInterface;
|
||||||
use App\Service\WarrantyHandler;
|
use App\Service\WarrantyHandler;
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
use App\Service\APNSClient;
|
use App\Service\APNSClient;
|
||||||
|
|
@ -66,13 +67,15 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
protected $rah;
|
protected $rah;
|
||||||
protected $country_code;
|
protected $country_code;
|
||||||
protected $wh;
|
protected $wh;
|
||||||
|
protected $cust_handler;
|
||||||
|
|
||||||
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,
|
||||||
|
CustomerHandlerInterface $cust_handler)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->ic = $ic;
|
$this->ic = $ic;
|
||||||
|
|
@ -82,6 +85,7 @@ class CMBJobOrderHandler 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->cust_handler = $cust_handler;
|
||||||
|
|
||||||
$this->loadTemplates();
|
$this->loadTemplates();
|
||||||
}
|
}
|
||||||
|
|
@ -416,8 +420,10 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$error_array['customer_customer_notes'] = 'Customer notes cannot be null.';
|
$error_array['customer_customer_notes'] = 'Customer notes cannot be null.';
|
||||||
}
|
}
|
||||||
|
|
||||||
$new_cust = new Customer();
|
// validate mobile phone
|
||||||
$new_cv = new CustomerVehicle();
|
$valid_mobile = $this->cust_handler->validateMobileNumber($req->request->get('customer_phone_mobile'));
|
||||||
|
if (!($valid_mobile))
|
||||||
|
$error_array['customer_phone_mobile'] = 'Invalid mobile phone number.';
|
||||||
|
|
||||||
// find the vehicle using vid
|
// find the vehicle using vid
|
||||||
$new_vehicle = $em->getRepository(Vehicle::class)->find($req->request->get('vid'));
|
$new_vehicle = $em->getRepository(Vehicle::class)->find($req->request->get('vid'));
|
||||||
|
|
@ -426,8 +432,10 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$error_array['cv_mfg'] = 'Invalid manufacturer specified.';
|
$error_array['cv_mfg'] = 'Invalid manufacturer specified.';
|
||||||
$error_array['cv_make'] = 'Invalid make specified.';
|
$error_array['cv_make'] = 'Invalid make specified.';
|
||||||
}
|
}
|
||||||
else
|
if (empty($error_array))
|
||||||
{
|
{
|
||||||
|
$new_cust = new Customer();
|
||||||
|
$new_cv = new CustomerVehicle();
|
||||||
|
|
||||||
$new_cust->setLastName($req->request->get('customer_last_name'))
|
$new_cust->setLastName($req->request->get('customer_last_name'))
|
||||||
->setFirstName($req->request->get('customer_first_name'))
|
->setFirstName($req->request->get('customer_first_name'))
|
||||||
|
|
@ -918,7 +926,11 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
// create the warranty if new battery only
|
// create the warranty if new battery only
|
||||||
if ($this->checkIfNewBattery($obj))
|
if ($this->checkIfNewBattery($obj))
|
||||||
{
|
{
|
||||||
|
if (empty($req->request->get('warranty_code')))
|
||||||
|
$serial = null;
|
||||||
|
else
|
||||||
$serial = $req->request->get('warranty_code');
|
$serial = $req->request->get('warranty_code');
|
||||||
|
|
||||||
$warranty_class = $obj->getWarrantyClass();
|
$warranty_class = $obj->getWarrantyClass();
|
||||||
$first_name = $obj->getCustomer()->getFirstName();
|
$first_name = $obj->getCustomer()->getFirstName();
|
||||||
$last_name = $obj->getCustomer()->getLastName();
|
$last_name = $obj->getCustomer()->getLastName();
|
||||||
|
|
@ -2382,8 +2394,10 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$error_array['customer_customer_notes'] = 'Customer notes cannot be null.';
|
$error_array['customer_customer_notes'] = 'Customer notes cannot be null.';
|
||||||
}
|
}
|
||||||
|
|
||||||
$new_cust = new Customer();
|
// validate mobile phone
|
||||||
$new_cv = new CustomerVehicle();
|
$valid_mobile = $this->cust_handler->validateMobileNumber($req->request->get('customer_phone_mobile'));
|
||||||
|
if (!($valid_mobile))
|
||||||
|
$error_array['customer_phone_mobile'] = 'Invalid mobile phone number.';
|
||||||
|
|
||||||
// find the vehicle using vid
|
// find the vehicle using vid
|
||||||
$new_vehicle = $em->getRepository(Vehicle::class)->find($req->request->get('vid'));
|
$new_vehicle = $em->getRepository(Vehicle::class)->find($req->request->get('vid'));
|
||||||
|
|
@ -2392,8 +2406,11 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$error_array['cv_mfg'] = 'Invalid manufacturer specified.';
|
$error_array['cv_mfg'] = 'Invalid manufacturer specified.';
|
||||||
$error_array['cv_make'] = 'Invalid make specified.';
|
$error_array['cv_make'] = 'Invalid make specified.';
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (empty($error_array))
|
||||||
{
|
{
|
||||||
|
$new_cust = new Customer();
|
||||||
|
$new_cv = new CustomerVehicle();
|
||||||
|
|
||||||
$new_cust->setLastName($req->request->get('customer_last_name'))
|
$new_cust->setLastName($req->request->get('customer_last_name'))
|
||||||
->setFirstName($req->request->get('customer_first_name'))
|
->setFirstName($req->request->get('customer_first_name'))
|
||||||
|
|
@ -2564,7 +2581,11 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
// create the warranty if new battery only
|
// create the warranty if new battery only
|
||||||
if ($this->checkIfNewBattery($jo))
|
if ($this->checkIfNewBattery($jo))
|
||||||
{
|
{
|
||||||
|
if (empty($req->request->get('warranty_code')))
|
||||||
|
$serial = null;
|
||||||
|
else
|
||||||
$serial = $req->request->get('warranty_code');
|
$serial = $req->request->get('warranty_code');
|
||||||
|
|
||||||
$warranty_class = $jo->getWarrantyClass();
|
$warranty_class = $jo->getWarrantyClass();
|
||||||
$first_name = $jo->getCustomer()->getFirstName();
|
$first_name = $jo->getCustomer()->getFirstName();
|
||||||
$last_name = $jo->getCustomer()->getLastName();
|
$last_name = $jo->getCustomer()->getLastName();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue