Add checking if hub_id is -1. Add call to get all ongoing job orders. #632
This commit is contained in:
parent
b9fdcbbbbb
commit
9c31a573c6
2 changed files with 65 additions and 0 deletions
|
|
@ -185,3 +185,23 @@ api_jo_info:
|
|||
path: /api/job_order/{id}/info
|
||||
controller: App\Controller\APIController::getJobOrderInfo
|
||||
methods: [GET]
|
||||
|
||||
api_ongoing_job_orders:
|
||||
path: /api/job_orders/ongoing
|
||||
controller: App\Controller\APIController::getAllOngoingJobOrders
|
||||
methods: [GET]
|
||||
|
||||
api_ongoing_jo_count:
|
||||
path: /api/job_orders/ongoing/count
|
||||
controller: App\Controller\APIController::getOngoingJobOrderCount
|
||||
methods: [GET]
|
||||
|
||||
api_new_location:
|
||||
path: /api/new_location
|
||||
controller: App\Controller\APIController::addLocation
|
||||
methods: [POST]
|
||||
|
||||
api_locations:
|
||||
path: /api/locations
|
||||
controller: App\Controller\APIController::getLocations
|
||||
methods: [GET]
|
||||
|
|
|
|||
|
|
@ -2711,6 +2711,14 @@ class APIController extends Controller implements LoggedController
|
|||
|
||||
$hub = null;
|
||||
$hub_id = $req->request->get('hub_id');
|
||||
// check if hub_id is -1 which means user clicked Book Now before 5 PM
|
||||
// but confirmed the order after 5 PM
|
||||
if ($hub_id == -1)
|
||||
{
|
||||
$res->setError(true)
|
||||
->setErrorMessage('Book Now no longer available.');
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
if (strlen($hub_id) > 0)
|
||||
$hub = $em->getRepository(Hub::class)->find($hub_id);
|
||||
|
||||
|
|
@ -3529,6 +3537,43 @@ class APIController extends Controller implements LoggedController
|
|||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function getAllOngoingJobOrders(Request $req, RiderTracker $rt)
|
||||
{
|
||||
$required_params = [];
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$res = $this->checkParamsAndKey($req, $em, $required_params);
|
||||
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();
|
||||
}
|
||||
|
||||
$ongoing_jos = $this->getOngoingJobOrders($cust);
|
||||
|
||||
error_log('ongoing jos ' . count($ongoing_jos));
|
||||
|
||||
// initialize data
|
||||
$jo_data = [];
|
||||
foreach ($ongoing_jos as $jo)
|
||||
{
|
||||
$jo_data[] = $this->generateJobOrderData($req, $jo, $rt);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'ongoing_job_orders' => $jo_data,
|
||||
];
|
||||
|
||||
$res->setData($data);
|
||||
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
protected function updateWarranty($res, $em, $rt, $trans, $req, $serial, $inv_filename = null, $wcard_filename = null,
|
||||
$logger, $log_data, $user_id, $action, $source)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue