Add call to get latest job order. #632
This commit is contained in:
parent
280a7c9c8f
commit
65c0ad1c56
2 changed files with 56 additions and 10 deletions
|
|
@ -211,6 +211,11 @@ api_cust_vehicle_remove:
|
|||
controller: App\Controller\APIController::removeVehicle
|
||||
methods: [POST]
|
||||
|
||||
api_latest_job_order:
|
||||
path: /api/job_order/latest
|
||||
controller: App\Controller\APIController::getLatestJobOrder
|
||||
methods: [GET]
|
||||
|
||||
#api_completed_job_orders:
|
||||
# path: /api/job_orders/completed
|
||||
# controller: App\Controller\APIController::getCompletedJobOrders
|
||||
|
|
|
|||
|
|
@ -1943,6 +1943,14 @@ class APIController extends Controller implements LoggedController
|
|||
'warranty' => $warranty,
|
||||
];
|
||||
|
||||
// customer information
|
||||
$customer = $jo->getCustomer();
|
||||
$jo_data['customer'] = [
|
||||
'first_name' => $customer->getFirstName(),
|
||||
'last_name' => $customer->getLastName(),
|
||||
'mobile_number' => $customer->getPhoneMobile(),
|
||||
];
|
||||
|
||||
// rider
|
||||
$rider = $jo->getRider();
|
||||
if ($rider != null)
|
||||
|
|
@ -3796,6 +3804,39 @@ class APIController extends Controller implements LoggedController
|
|||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function getLatestJobOrder(EntityManagerInterface $em, Request $req, RiderTracker $rt)
|
||||
{
|
||||
// check required parameters and api key
|
||||
$res = $this->checkParamsAndKey($req, $em, []);
|
||||
if ($res->isError())
|
||||
return $res->getReturnResponse();
|
||||
|
||||
// get customer
|
||||
$cust = $this->session->getCustomer();
|
||||
if ($cust == null)
|
||||
{
|
||||
$res->setError(true)
|
||||
->setErrorMessage('No customer information found');
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
// get the latest job order for customer
|
||||
$latest_jo = $em->getRepository(JobOrder::class)->findOneBy(['customer' => $cust], ['id' => 'DESC']);
|
||||
|
||||
$jo_data = [];
|
||||
if ($latest_jo != null)
|
||||
$jo_data = $this->generateJobOrderData($req, $latest_jo, $rt);
|
||||
|
||||
$data = [
|
||||
'latest_job_order' => $jo_data,
|
||||
];
|
||||
|
||||
$res->setData($data);
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
// commenting it out. Modify the getJOHistory instead to just get the fulfilled
|
||||
// and cancelled job orders, since ongoing is not yet part of history
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue