Merge branch '307-cmb-fix-customer-hard-coded-country-code' of gitlab.com:jankstudio/resq into 305-cmb-add-warranty-creation-when-jo-is-fulfilled-to-resqjoborderhandler

This commit is contained in:
Korina Cordero 2020-01-22 07:33:31 +00:00
commit 8727c227e4
8 changed files with 58 additions and 39 deletions

View file

@ -50,3 +50,6 @@ GEOFENCE_ENABLE=settotrueorfalse
CVU_MFG_ID=insertmfgidforunknownvehicles
CVU_BRAND_ID=insertbrandidforunknownvehicles
# country code prefix
COUNTRY_CODE=+insertcountrycodehere

View file

@ -164,14 +164,18 @@ services:
App\Service\InvoiceGeneratorInterface: "@App\\Service\\InvoiceGenerator\\ResqInvoiceGenerator"
# job order generator
App\Service\JobOrderHandler\CMBJobOrderHandler: ~
App\Service\JobOrderHandler\ResqJobOrderHandler:
arguments:
$country_code: "%env(COUNTRY_CODE)%"
#job order generator interface
#App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\CMBJobOrderHandler"
App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\ResqJobOrderHandler"
# customer generator
App\Service\CustomerHandler\CMBCustomerHandler: ~
App\Service\CustomerHandler\ResqCustomerHandler:
arguments:
$country_code: "%env(COUNTRY_CODE)%"
# customer generator interface
#App\Service\CustomerHandlerInterface: "@App\\Service\\CustomerHandler\\CMBCustomerHandler"

View file

@ -14,9 +14,6 @@ use App\Ramcar\CustomerClassification;
*/
class Customer
{
// TODO: make this a setting somewhere
const COUNTRY_CODE_PREFIX = '+60';
// unique id
/**
* @ORM\Id
@ -266,16 +263,16 @@ class Customer
$phones = [];
if (!empty($this->phone_mobile))
$phones[] = self::COUNTRY_CODE_PREFIX . $this->phone_mobile;
$phones[] = $this->phone_mobile;
if (!empty($this->phone_landline))
$phones[] = self::COUNTRY_CODE_PREFIX . $this->phone_landline;
$phones[] = $this->phone_landline;
if (!empty($this->phone_office))
$phones[] = self::COUNTRY_CODE_PREFIX . $this->phone_office;
$phones[] = $this->phone_office;
if (!empty($this->phone_fax))
$phones[] = self::COUNTRY_CODE_PREFIX . $this->phone_fax;
$phones[] = $this->phone_fax;
return $phones;
}

View file

@ -25,17 +25,17 @@ use DateTime;
class CMBCustomerHandler implements CustomerHandlerInterface
{
const COUNTRY_CODE_PREFIX = '+60';
protected $em;
protected $validator;
protected $country_code;
protected $template_hash;
public function __construct(EntityManagerInterface $em, ValidatorInterface $validator)
public function __construct(EntityManagerInterface $em, ValidatorInterface $validator,
string $country_code)
{
$this->em = $em;
$this->validator = $validator;
$this->country_code = $country_code;
$this->loadTemplates();
}
@ -121,7 +121,14 @@ class CMBCustomerHandler implements CustomerHandlerInterface
$row['flag_csat'] = $orow->isCSAT();
// TODO: properly add mobile numbers and plate numbers as searchable/sortable fields, use doctrine events
$row['mobile_numbers'] = implode("<br>", $orow->getMobileNumberList());
// prepend the country code before each mobile number
$mobile_number_list = [];
$mobile_numbers = $orow->getMobileNumberList();
foreach ($mobile_numbers as $mobile_number)
{
$mobile_number_list[] = $this->country_code . $mobile_number;
}
$row['mobile_numbers'] = implode("<br>", $mobile_number_list);
$row['plate_numbers'] = implode("<br>", $orow->getPlateNumberList());
$rows[] = $row;
@ -467,7 +474,7 @@ class CMBCustomerHandler implements CustomerHandlerInterface
$cust = $cv->getCustomer();
$vehicles[] = [
'id' => $cv->getID(),
'text' => $cv->getPlateNumber() . ' ' . $cust->getFirstName() . ' ' . $cust->getLastName() . ' ('. self::COUNTRY_CODE_PREFIX . $cust->getPhoneMobile() . ')',
'text' => $cv->getPlateNumber() . ' ' . $cust->getFirstName() . ' ' . $cust->getLastName() . ' ('. $this->country_code . $cust->getPhoneMobile() . ')',
];
}

View file

@ -27,17 +27,17 @@ use DateTime;
class ResqCustomerHandler implements CustomerHandlerInterface
{
const COUNTRY_CODE_PREFIX = '+63';
protected $em;
protected $validator;
protected $country_code;
protected $template_hash;
public function __construct(EntityManagerInterface $em, ValidatorInterface $validator)
public function __construct(EntityManagerInterface $em, ValidatorInterface $validator,
string $country_code)
{
$this->em = $em;
$this->validator = $validator;
$this->country_code = $country_code;
$this->loadTemplates();
}
@ -124,7 +124,14 @@ class ResqCustomerHandler implements CustomerHandlerInterface
$row['flag_csat'] = $orow->isCSAT();
// TODO: properly add mobile numbers and plate numbers as searchable/sortable fields, use doctrine events
$row['mobile_numbers'] = implode("<br>", $orow->getMobileNumberList());
// prepend the country code before each mobile number
$mobile_number_list = [];
$mobile_numbers = $orow->getMobileNumberList();
foreach ($mobile_numbers as $mobile_number)
{
$mobile_number_list[] = $this->country_code . $mobile_number;
}
$row['mobile_numbers'] = implode("<br>", $mobile_number_list);
$row['plate_numbers'] = implode("<br>", $orow->getPlateNumberList());
$rows[] = $row;
@ -465,7 +472,7 @@ class ResqCustomerHandler implements CustomerHandlerInterface
$cust = $cv->getCustomer();
$vehicles[] = [
'id' => $cv->getID(),
'text' => $cv->getPlateNumber() . ' ' . $cust->getFirstName() . ' ' . $cust->getLastName() . ' ('. self::COUNTRY_CODE_PREFIX . $cust->getPhoneMobile() . ')',
'text' => $cv->getPlateNumber() . ' ' . $cust->getFirstName() . ' ' . $cust->getLastName() . ' ('. $this->country_code . $cust->getPhoneMobile() . ')',
];
}

View file

@ -55,20 +55,20 @@ use FPDF;
class CMBJobOrderHandler implements JobOrderHandlerInterface
{
const COUNTRY_CODE_PREFIX = '+60';
protected $em;
protected $ic;
protected $security;
protected $validator;
protected $translator;
protected $rah;
protected $country_code;
protected $template_hash;
public function __construct(Security $security, EntityManagerInterface $em,
InvoiceGeneratorInterface $ic, ValidatorInterface $validator,
TranslatorInterface $translator, RiderAssignmentHandlerInterface $rah)
TranslatorInterface $translator, RiderAssignmentHandlerInterface $rah,
string $country_code)
{
$this->em = $em;
$this->ic = $ic;
@ -76,6 +76,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
$this->validator = $validator;
$this->translator = $translator;
$this->rah = $rah;
$this->country_code = $country_code;
$this->loadTemplates();
}
@ -1860,7 +1861,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
$pdf->SetXY($col2_x, $y);
$pdf->Cell($label_width, $line_height, 'Mobile Phone:');
$pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneMobile() ? self::COUNTRY_CODE_PREFIX . $customer->getPhoneMobile() : '', 0, 'L');
$pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneMobile() ? $this->country_code . $customer->getPhoneMobile() : '', 0, 'L');
// get Y after right cell
$y2 = $pdf->GetY();
@ -1877,7 +1878,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
$pdf->SetXY($col2_x, $y);
$pdf->Cell($label_width, $line_height, 'Landline:');
$pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneLandline() ? self::COUNTRY_CODE_PREFIX . $customer->getPhoneLandline() : '', 0, 'L');
$pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneLandline() ? $this->country_code . $customer->getPhoneLandline() : '', 0, 'L');
// get Y after right cell
$y2 = $pdf->GetY();
@ -1887,11 +1888,11 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
$pdf->SetXY($col2_x, $y);
$pdf->Cell($label_width, $line_height, 'Office Phone:');
$pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneOffice() ? self::COUNTRY_CODE_PREFIX . $customer->getPhoneOffice() : '', 0, 'L');
$pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneOffice() ? $this->country_code . $customer->getPhoneOffice() : '', 0, 'L');
$pdf->SetX($col2_x);
$pdf->Cell($label_width, $line_height, 'Fax:');
$pdf->MultiCell($val_width, $line_height, $customer && $customer->getPhoneFax() ? self::COUNTRY_CODE_PREFIX . $customer->getPhoneFax() : '', 0, 'L');
$pdf->MultiCell($val_width, $line_height, $customer && $customer->getPhoneFax() ? $this->country_code . $customer->getPhoneFax() : '', 0, 'L');
// insert vehicle info
$cv = $obj->getCustomerVehicle();

View file

@ -53,25 +53,25 @@ use FPDF;
class ResqJobOrderHandler implements JobOrderHandlerInterface
{
const COUNTRY_CODE_PREFIX = '+60';
protected $em;
protected $ic;
protected $security;
protected $validator;
protected $translator;
protected $country_code;
protected $template_hash;
public function __construct(Security $security, EntityManagerInterface $em,
InvoiceGeneratorInterface $ic, ValidatorInterface $validator,
TranslatorInterface $translator)
TranslatorInterface $translator, string $country_code)
{
$this->em = $em;
$this->ic = $ic;
$this->security = $security;
$this->validator = $validator;
$this->translator = $translator;
$this->country_code = $country_code;
$this->loadTemplates();
}
@ -1868,7 +1868,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$pdf->SetXY($col2_x, $y);
$pdf->Cell($label_width, $line_height, 'Mobile Phone:');
$pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneMobile() ? self::COUNTRY_CODE_PREFIX . $customer->getPhoneMobile() : '', 0, 'L');
$pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneMobile() ? $this->country_code . $customer->getPhoneMobile() : '', 0, 'L');
// get Y after right cell
$y2 = $pdf->GetY();
@ -1885,7 +1885,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$pdf->SetXY($col2_x, $y);
$pdf->Cell($label_width, $line_height, 'Landline:');
$pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneLandline() ? self::COUNTRY_CODE_PREFIX . $customer->getPhoneLandline() : '', 0, 'L');
$pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneLandline() ? $this->country_code . $customer->getPhoneLandline() : '', 0, 'L');
// get Y after right cell
$y2 = $pdf->GetY();
@ -1895,11 +1895,11 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$pdf->SetXY($col2_x, $y);
$pdf->Cell($label_width, $line_height, 'Office Phone:');
$pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneOffice() ? self::COUNTRY_CODE_PREFIX . $customer->getPhoneOffice() : '', 0, 'L');
$pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneOffice() ? $this->country_code . $customer->getPhoneOffice() : '', 0, 'L');
$pdf->SetX($col2_x);
$pdf->Cell($label_width, $line_height, 'Fax:');
$pdf->MultiCell($val_width, $line_height, $customer && $customer->getPhoneFax() ? self::COUNTRY_CODE_PREFIX . $customer->getPhoneFax() : '', 0, 'L');
$pdf->MultiCell($val_width, $line_height, $customer && $customer->getPhoneFax() ? $this->country_code . $customer->getPhoneFax() : '', 0, 'L');
// insert vehicle info
$cv = $obj->getCustomerVehicle();

View file

@ -131,7 +131,7 @@
Mobile Phone
</label>
<div class="input-group m-input-group">
<span class="input-group-addon">+63</span>
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
<input type="text" name="phone_mobile" class="form-control m-input" value="{{ obj.getPhoneMobile|default('') }}" data-name="phone_mobile">
<div class="form-control-feedback hide" data-field="phone_mobile"></div>
</div>
@ -141,7 +141,7 @@
Landline
</label>
<div class="input-group m-input-group">
<span class="input-group-addon">+63</span>
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
<input type="text" name="phone_landline" class="form-control m-input" value="{{ obj.getPhoneLandline|default('') }}" data-name="phone_landline">
<div class="form-control-feedback hide" data-field="phone_landline"></div>
</div>
@ -153,7 +153,7 @@
Office Phone
</label>
<div class="input-group m-input-group">
<span class="input-group-addon">+63</span>
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
<input type="text" name="phone_office" class="form-control m-input" value="{{ obj.getPhoneOffice|default('') }}" data-name="phone_office">
<div class="form-control-feedback hide" data-field="phone_office"></div>
</div>
@ -163,7 +163,7 @@
Fax
</label>
<div class="input-group m-input-group">
<span class="input-group-addon">+63</span>
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
<input type="text" name="phone_fax" class="form-control m-input" value="{{ obj.getPhoneFax|default('') }}" data-name="phone_fax">
<div class="form-control-feedback hide" data-field="phone_fax"></div>
</div>