Move the setting of JO search fields to the entity. Move the sql script to the migration folder. #419

This commit is contained in:
Korina Cordero 2020-05-27 08:13:51 +00:00
parent 2a0bee8d8d
commit 7b60ec7c5f
3 changed files with 11 additions and 6 deletions

View file

@ -1 +0,0 @@
UPDATE job_order jo, customer c, customer_vehicle cv SET jo.first_name = c.first_name, jo.last_name = c.last_name, jo.phone_mobile = c.phone_mobile, jo.plate_number = cv.plate_number WHERE jo.customer_id = c.id AND jo.cvehicle_id = cv.id;

View file

@ -506,6 +506,12 @@ class JobOrder
public function setCustomer(Customer $customer)
{
$this->customer = $customer;
// set the search fields for first name, last name, and mobile
$this->setFirstName($customer->getFirstName());
$this->setLastName($customer->getLastName());
$this->setPhoneMobile($customer->getPhoneMobile());
return $this;
}
@ -517,6 +523,10 @@ class JobOrder
public function setCustomerVehicle(CustomerVehicle $cus_vehicle)
{
$this->cus_vehicle = $cus_vehicle;
// set the search field for plate number
$this->setPlateNumber($cus_vehicle->getPlateNumber());
return $this;
}

View file

@ -343,11 +343,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->setORName($req->request->get('or_name'))
->setPromoDetail($req->request->get('promo_detail'))
->setModeOfPayment($req->request->get('mode_of_payment'))
->setLandmark($req->request->get('landmark'))
->setFirstName($cust_vehicle->getCustomer()->getFirstName())
->setLastName($cust_vehicle->getCustomer()->getLastName())
->setPhoneMobile($cust_vehicle->getCustomer()->getPhoneMobile())
->setPlateNumber($cust_vehicle->getPlateNumber());
->setLandmark($req->request->get('landmark'));
// check if user is null, meaning call to create came from API
if ($user != null)