Return warranty information with customer vehicle information for job order history. #227
This commit is contained in:
parent
1573ec0aa4
commit
48b509ad43
1 changed files with 54 additions and 4 deletions
|
|
@ -1691,16 +1691,66 @@ class APIController extends Controller
|
|||
'status' => $status,
|
||||
];
|
||||
|
||||
// customer vehicle
|
||||
// customer vehicle and warranty
|
||||
$cv = $jo->getCustomerVehicle();
|
||||
|
||||
// NOTE: Modify the search for the latest warranty
|
||||
// get latest warranty using plate number
|
||||
$warranty_results = $em->getRepository(Warranty::class)->findBy(['plate_number' => $cv->getPlateNumber()],
|
||||
['date_create' => 'desc']);
|
||||
|
||||
$warranty = current($warranty_results);
|
||||
|
||||
// check for null values for battery and date claim and date expire
|
||||
$batt_model = '';
|
||||
$batt_size = '';
|
||||
$sap_batt = '';
|
||||
$claim_date = '';
|
||||
$expiry_date = '';
|
||||
|
||||
if (!(is_null($warranty->getBatteryModel()))) {
|
||||
$batt_model = $warranty->getBatteryModel()->getName();
|
||||
}
|
||||
if (!(is_null($warranty->getBatterySize()))) {
|
||||
$batt_size = $warranty->getBattyerSize()->getName();
|
||||
}
|
||||
if (!(is_null($warranty->getSAPBattery()))) {
|
||||
$sap_batt = $warranty->getSAPBattery()->getID();
|
||||
}
|
||||
if (!(is_null($warranty->getDateClaim()))) {
|
||||
$claim_date = $warranty->getDateClaim()->format("d M Y g:i A");
|
||||
}
|
||||
if (!(is_null($warranty->getDateExpire()))) {
|
||||
$expiry_date = $warranty->getDateExpire()->format("d M Y g:i A");
|
||||
}
|
||||
|
||||
$warr = [];
|
||||
$warr[] = [
|
||||
'id' => $warranty->getID(),
|
||||
'serial' => $warranty->getSerial(),
|
||||
'warranty_class' => $warranty->getWarrantyClass(),
|
||||
'plate_number' => $warranty->getPlateNumber(),
|
||||
'first_name' => $warranty->getFirstName(),
|
||||
'last_name' => $warranty->getLastName(),
|
||||
'mobile_number' => $warranty->getMobileNumber(),
|
||||
'battery_model' => $batt_model,
|
||||
'battery_size' => $batt_size,
|
||||
'sap_battery' => $sap_batt,
|
||||
'status' => $warranty->getStatus(),
|
||||
'date_create' => $warranty->getDateCreate()->format("d M Y g:i A"),
|
||||
'date_purchase' => $warranty->getDatePurchase()->format("d M Y g:i A"),
|
||||
'date_expire' => $expiry_date,
|
||||
'date_claim' => $claim_date,
|
||||
'claim_from' => $warranty->getClaimedFrom(),
|
||||
'is_activated' => $warranty->isActivated() ? 1 : 0,
|
||||
];
|
||||
|
||||
$jo_data['customer_vehicle'] = [
|
||||
'id' => $cv->getID(),
|
||||
'plate_number' => $cv->getPlateNumber(),
|
||||
'warranty' => $warr,
|
||||
];
|
||||
|
||||
// TODO: mogol get warranty object for the plate number. Return only
|
||||
// latest warranty.
|
||||
|
||||
// rider
|
||||
$rider = $jo->getRider();
|
||||
if ($rider != null)
|
||||
|
|
|
|||
Loading…
Reference in a new issue