Add new fields for warranty - customer contact number and address #540
This commit is contained in:
parent
095159c3fe
commit
f56d08b9cc
2 changed files with 88 additions and 2 deletions
|
|
@ -149,18 +149,38 @@ class CustomerWarrantyController extends APIController
|
|||
else
|
||||
$warr_card_url = '';
|
||||
|
||||
// vehicle
|
||||
if ($warr->getVehicle() != null)
|
||||
{
|
||||
$v = $warr->getVehicle();
|
||||
$vmfg_id = $v->getManufacturer()->getID();
|
||||
$vmake_id = $v->getID();
|
||||
}
|
||||
else
|
||||
{
|
||||
$vmfg_id = null;
|
||||
$vmake_id = null;
|
||||
}
|
||||
|
||||
$customer = [
|
||||
'first_name' => $warr->getFirstName(),
|
||||
'last_name' => $warr->getLastName(),
|
||||
'mobile_number' => $mobile_num,
|
||||
'plate_number' => $warr_plate,
|
||||
'email' => $warr->getEmail(),
|
||||
'contact_num' => $warr->getContactNumber(),
|
||||
'address' => $warr->getCustomerAddress(),
|
||||
];
|
||||
$other_data = [
|
||||
'odometer' => $warr->getOdometer(),
|
||||
'date_purchase' => $date_purchase_cust,
|
||||
'invoice' => $invoice_url,
|
||||
'warr_card' => $warr_card_url,
|
||||
'vmfg_id' => $vmfg_id,
|
||||
'vmake_id' => $vmake_id,
|
||||
'vmodel' => $warr->getVehicleModelYear(),
|
||||
'dealer_name' => $warr->getDealerName(),
|
||||
'dealer_address' => $warr->getDealerAddress(),
|
||||
];
|
||||
}
|
||||
else
|
||||
|
|
@ -171,12 +191,19 @@ class CustomerWarrantyController extends APIController
|
|||
'mobile_number' => '',
|
||||
'plate_number' => '',
|
||||
'email' => '',
|
||||
'contact_num' => '',
|
||||
'address' => '',
|
||||
];
|
||||
$other_data = [
|
||||
'odometer' => 0,
|
||||
'date_purchase' => $today->format('Y-m-d'),
|
||||
'invoice' => '',
|
||||
'warr_card' => '',
|
||||
'vmfg_id' => null,
|
||||
'vmake_id' => null,
|
||||
'vmodel' => '',
|
||||
'dealer_name' => '',
|
||||
'dealer_address' => '',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -211,6 +238,11 @@ class CustomerWarrantyController extends APIController
|
|||
'invoice' => $other_data['invoice'],
|
||||
'warr_card' => $other_data['warr_card'],
|
||||
'date_purchase' => $other_data['date_purchase'],
|
||||
'vmfg_id' => $other_data['vmfg_id'],
|
||||
'vehicle_id' => $other_data['vmake_id'],
|
||||
'vmodel' => $other_data['vmodel'],
|
||||
'dealer_name' => $other_data['dealer_name'],
|
||||
'dealer_address' => $other_data['dealer_address'],
|
||||
];
|
||||
|
||||
return new APIResponse(true, 'Warranty found.', $data);
|
||||
|
|
@ -231,12 +263,14 @@ class CustomerWarrantyController extends APIController
|
|||
return $res;
|
||||
|
||||
|
||||
/*
|
||||
$first_name = $req->request->get('first_name');
|
||||
$last_name = $req->request->get('last_name');
|
||||
$email = $req->request->get('email');
|
||||
$plate_num = $req->request->get('plate_num');
|
||||
$odometer = $req->request->get('odometer');
|
||||
$date_purchase = $req->request->get('date_purchase');
|
||||
*/
|
||||
|
||||
// file uploads
|
||||
$invoice = $req->files->get('invoice');
|
||||
|
|
@ -360,6 +394,18 @@ class CustomerWarrantyController extends APIController
|
|||
return new APIResponse(false, 'Could not find battery entry for warranty.');
|
||||
}
|
||||
|
||||
// vehicle fetch
|
||||
$vmake_id = $req->request->get('vmake_id');
|
||||
$vehicle = null;
|
||||
if ($vmake_id != null)
|
||||
{
|
||||
$vehicle = $em->getRepository(Vehicle::class)->find($vmake_id);
|
||||
if ($vehicle == null)
|
||||
{
|
||||
return new APIResponse(false, 'Could not find vehicle specified for warranty.');
|
||||
}
|
||||
}
|
||||
|
||||
error_log('date check');
|
||||
// default date purchase to today
|
||||
// NOTE: might need to change this later
|
||||
|
|
@ -398,6 +444,12 @@ class CustomerWarrantyController extends APIController
|
|||
// new fields
|
||||
->setOdometer($req->request->get('odometer', 0))
|
||||
->setDatePurchaseCustomer($date_pur_cust)
|
||||
->setContactNumber($req->request->get('contact_num'))
|
||||
->setCustomerAddress($req->request->get('cust_address'))
|
||||
->setDealerName($req->request->get('dealer_name'))
|
||||
->setDealerAddress($req->request->get('dealer_address'))
|
||||
->setVehicle($vehicle)
|
||||
->setVehicleModelYear($req->request->get('vmodel'))
|
||||
->setDealerName($req->request->get('dealer_name'))
|
||||
->setDealerAddress($req->request->get('dealer_address'))
|
||||
->setValidated(false);
|
||||
|
|
|
|||
|
|
@ -178,16 +178,28 @@ class Warranty
|
|||
|
||||
// dealer name
|
||||
/**
|
||||
* #ORM\Column(type="string", length=80, nullable=true)
|
||||
* @ORM\Column(type="string", length=80, nullable=true)
|
||||
*/
|
||||
protected $dealer_name;
|
||||
|
||||
// dealer address
|
||||
/**
|
||||
* #ORM\Column(type="string", length=180, nullable=true)
|
||||
* @ORM\Column(type="string", length=180, nullable=true)
|
||||
*/
|
||||
protected $dealer_address;
|
||||
|
||||
// customer contact number
|
||||
/**
|
||||
* @ORM\Column(type="string", length=30, nullable=true)
|
||||
*/
|
||||
protected $contact_num;
|
||||
|
||||
// customer address
|
||||
/**
|
||||
* @ORM\Column(type="string", length=280, nullable=true)
|
||||
*/
|
||||
protected $cust_address;
|
||||
|
||||
// date purchase as specified by customer
|
||||
// TODO: currently this does not affect warranty, someone will have to view this and set
|
||||
// actual purchase date
|
||||
|
|
@ -552,6 +564,28 @@ class Warranty
|
|||
return $this->dealer_address;
|
||||
}
|
||||
|
||||
public function setContactNumber($contact_num)
|
||||
{
|
||||
$this->contact_num = $contact_num;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContactNumber()
|
||||
{
|
||||
return $this->contact_num;
|
||||
}
|
||||
|
||||
public function setCustomerAddress($address)
|
||||
{
|
||||
$this->cust_address = $address;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCustomerAddress()
|
||||
{
|
||||
return $this->cust_address;
|
||||
}
|
||||
|
||||
public function setDatePurchaseCustomer($date)
|
||||
{
|
||||
$this->date_purchase_cust = $date;
|
||||
|
|
|
|||
Loading…
Reference in a new issue