Fix contact number related bugs #UAT
This commit is contained in:
parent
e6dcc854f3
commit
5c18619e80
3 changed files with 44 additions and 95 deletions
|
|
@ -417,53 +417,6 @@ class CustomerController extends BaseController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public function updateNumbers($em, Customer $cust, $numbers)
|
|
||||||
{
|
|
||||||
$number_ids = [];
|
|
||||||
|
|
||||||
foreach ($numbers as $key => $number)
|
|
||||||
{
|
|
||||||
// check if number exists
|
|
||||||
$mobile_number = $em->getRepository(MobileNumber::class)->find($number->id);
|
|
||||||
|
|
||||||
// this is a new number
|
|
||||||
if (empty($mobile_number))
|
|
||||||
{
|
|
||||||
$mobile_number = new MobileNumber();
|
|
||||||
$mobile_number->setID($number->id)
|
|
||||||
->setDateRegistered(DateTime::createFromFormat("d M Y - h:i A", $number->date_registered))
|
|
||||||
->setCustomer($cust);
|
|
||||||
|
|
||||||
if (!isset($nerror_array[$key]))
|
|
||||||
{
|
|
||||||
$cust->addMobileNumber($mobile_number);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// add to list of numbers to keep
|
|
||||||
$number_ids[$mobile_number->getID()] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
error_log('cleanup');
|
|
||||||
|
|
||||||
// cleanup
|
|
||||||
// delete all not in list
|
|
||||||
$mns = $cust->getMobileNumbers();
|
|
||||||
foreach ($mns as $mn)
|
|
||||||
{
|
|
||||||
error_log($mn->getID());
|
|
||||||
error_log(print_r($number_ids, true));
|
|
||||||
if (!isset($number_ids[$mn->getID()]))
|
|
||||||
{
|
|
||||||
error_log('removing ' . $mn->getID());
|
|
||||||
$cust->removeMobileNumber($mn);
|
|
||||||
$em->remove($mn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function updateSubmit(Request $req, ValidatorInterface $validator, $id)
|
public function updateSubmit(Request $req, ValidatorInterface $validator, $id)
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('customer.update', null, 'No access.');
|
$this->denyAccessUnlessGranted('customer.update', null, 'No access.');
|
||||||
|
|
@ -591,7 +544,7 @@ class CustomerController extends BaseController
|
||||||
'c.first_name',
|
'c.first_name',
|
||||||
$qb->expr()->literal(' '),
|
$qb->expr()->literal(' '),
|
||||||
'c.last_name',
|
'c.last_name',
|
||||||
$qb->expr()->literal(' ('),
|
$qb->expr()->literal(' (+63'),
|
||||||
'c.phone_mobile',
|
'c.phone_mobile',
|
||||||
$qb->expr()->literal(')')
|
$qb->expr()->literal(')')
|
||||||
);
|
);
|
||||||
|
|
@ -681,13 +634,6 @@ class CustomerController extends BaseController
|
||||||
$vehicle = $obj->getVehicle();
|
$vehicle = $obj->getVehicle();
|
||||||
$battery = $obj->getCurrentBattery();
|
$battery = $obj->getCurrentBattery();
|
||||||
|
|
||||||
// get all mobile numbers
|
|
||||||
$mobile_numbers = [];
|
|
||||||
|
|
||||||
foreach ($customer->getMobileNumbers() as $number) {
|
|
||||||
$mobile_numbers[] = $number->getID();
|
|
||||||
}
|
|
||||||
|
|
||||||
// build response
|
// build response
|
||||||
$row = [
|
$row = [
|
||||||
'customer' => [
|
'customer' => [
|
||||||
|
|
@ -695,7 +641,10 @@ class CustomerController extends BaseController
|
||||||
'first_name' => $customer->getFirstName(),
|
'first_name' => $customer->getFirstName(),
|
||||||
'last_name' => $customer->getLastName(),
|
'last_name' => $customer->getLastName(),
|
||||||
'customer_notes' => $customer->getCustomerNotes(),
|
'customer_notes' => $customer->getCustomerNotes(),
|
||||||
'mobile_numbers' => $mobile_numbers
|
'phone_mobile' => $customer->getPhoneMobile(),
|
||||||
|
'phone_landline' => $customer->getPhoneLandline(),
|
||||||
|
'phone_office' => $customer->getPhoneOffice(),
|
||||||
|
'phone_fax' => $customer->getPhoneFax(),
|
||||||
],
|
],
|
||||||
'vehicle' => [
|
'vehicle' => [
|
||||||
'id' => $vehicle->getID(),
|
'id' => $vehicle->getID(),
|
||||||
|
|
|
||||||
|
|
@ -208,40 +208,6 @@ class Customer
|
||||||
return $this->customer_notes;
|
return $this->customer_notes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public function addMobileNumber(MobileNumber $number)
|
|
||||||
{
|
|
||||||
$this->numbers->add($number);
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function clearMobileNumbers()
|
|
||||||
{
|
|
||||||
$this->numbers->clear();
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeMobileNumber($num)
|
|
||||||
{
|
|
||||||
$this->numbers->removeElement($num);
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMobileNumbers()
|
|
||||||
{
|
|
||||||
return $this->numbers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMobileNumberList()
|
|
||||||
{
|
|
||||||
$numbers = [];
|
|
||||||
foreach ($this->numbers as $number)
|
|
||||||
$numbers[] = $number->getID();
|
|
||||||
|
|
||||||
return $numbers;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function getMobileNumberList()
|
public function getMobileNumberList()
|
||||||
{
|
{
|
||||||
$phones = [];
|
$phones = [];
|
||||||
|
|
|
||||||
|
|
@ -104,12 +104,43 @@
|
||||||
<div class="form-control-feedback hide" data-field="customer_last_name"></div>
|
<div class="form-control-feedback hide" data-field="customer_last_name"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group m-form__group row">
|
<div class="form-group m-form__group row">
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<label data-field="customer_mobile_numbers">Contact Numbers</label>
|
<label data-field="customer_phone_mobile">Mobile Phone</label>
|
||||||
<textarea name="customer_mobile_numbers" id="customer-mobile-numbers" class="form-control m-input" placeholder="Select a vehicle first" data-vehicle-field="1" rows="4" disabled>{{ obj.getCustomer ? obj.getCustomer.getMobileNumberList|join("\r\n") }}</textarea>
|
<div class="input-group m-input-group">
|
||||||
<div class="form-control-feedback hide" data-field="customer_mobile_numbers"></div>
|
<span class="input-group-addon">+63</span>
|
||||||
|
<input type="text" name="customer_phone_mobile" id="customer-phone-mobile" class="form-control m-input" value="{{ obj.getCustomer.getPhoneMobile|default('') }}" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||||
|
<div class="form-control-feedback hide" data-field="customer_phone_mobile"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<label data-field="customer_phone_landline">Landline</label>
|
||||||
|
<div class="input-group m-input-group">
|
||||||
|
<span class="input-group-addon">+63</span>
|
||||||
|
<input type="text" name="customer_phone_landline" id="customer-phone-landline" class="form-control m-input" value="{{ obj.getCustomer.getPhoneLandline|default('') }}" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||||
|
<div class="form-control-feedback hide" data-field="customer_phone_landline"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group m-form__group row">
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<label data-field="customer_phone_office">Office Phone</label>
|
||||||
|
<div class="input-group m-input-group">
|
||||||
|
<span class="input-group-addon">+63</span>
|
||||||
|
<input type="text" name="customer_phone_office" id="customer-phone-office" class="form-control m-input" value="{{ obj.getCustomer.getPhoneOffice|default('') }}" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||||
|
<div class="form-control-feedback hide" data-field="customer_phone_office"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<label data-field="customer_phone_fax">Fax</label>
|
||||||
|
<div class="input-group m-input-group">
|
||||||
|
<span class="input-group-addon">+63</span>
|
||||||
|
<input type="text" name="customer_phone_fax" id="customer-phone-fax" class="form-control m-input" value="{{ obj.getCustomer.getPhoneFax|default('') }}" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||||
|
<div class="form-control-feedback hide" data-field="customer_phone_fax"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group m-form__group row">
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<label data-field="customer_customer_notes">Customer Notes</label>
|
<label data-field="customer_customer_notes">Customer Notes</label>
|
||||||
<textarea name="customer_customer_notes" id="customer-customer-notes" class="form-control m-input" placeholder="Select a vehicle first" data-vehicle-field="1" rows="4" disabled>{{ obj.getCustomer ? obj.getCustomer.getCustomerNotes }}</textarea>
|
<textarea name="customer_customer_notes" id="customer-customer-notes" class="form-control m-input" placeholder="Select a vehicle first" data-vehicle-field="1" rows="4" disabled>{{ obj.getCustomer ? obj.getCustomer.getCustomerNotes }}</textarea>
|
||||||
|
|
@ -977,7 +1008,10 @@ $(function() {
|
||||||
$("[data-vehicle-field='1']").prop('placeholder', '');
|
$("[data-vehicle-field='1']").prop('placeholder', '');
|
||||||
$("#customer-first-name").val(vdata.customer.first_name);
|
$("#customer-first-name").val(vdata.customer.first_name);
|
||||||
$("#customer-last-name").val(vdata.customer.last_name);
|
$("#customer-last-name").val(vdata.customer.last_name);
|
||||||
$("#customer-mobile-numbers").val(vdata.customer.mobile_numbers.join("\r\n"));
|
$("#customer-phone-mobile").val(vdata.customer.phone_mobile);
|
||||||
|
$("#customer-phone-landline").val(vdata.customer.phone_landline);
|
||||||
|
$("#customer-phone-office").val(vdata.customer.phone_office);
|
||||||
|
$("#customer-phone-fax").val(vdata.customer.phone_fax);
|
||||||
$("#customer-customer-notes").val(vdata.customer.customer_notes);
|
$("#customer-customer-notes").val(vdata.customer.customer_notes);
|
||||||
$("#vmfg").val(vdata.vehicle.mfg_name);
|
$("#vmfg").val(vdata.vehicle.mfg_name);
|
||||||
$("#vehicle-make").val(vdata.vehicle.make);
|
$("#vehicle-make").val(vdata.vehicle.make);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue