From b41b5ea29bdfda474e487e4d44fa63f0c8293fa1 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 4 Jun 2020 06:02:53 +0000 Subject: [PATCH] Modify getJobOrderHistory. #421 --- config/routes/cmb_rider_api.yaml | 6 +++--- src/Controller/CMBRAPIController.php | 4 ++-- src/Service/RiderAPIHandler/CMBRiderAPIHandler.php | 13 +++++++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/config/routes/cmb_rider_api.yaml b/config/routes/cmb_rider_api.yaml index 8ea54898..e044872a 100644 --- a/config/routes/cmb_rider_api.yaml +++ b/config/routes/cmb_rider_api.yaml @@ -65,9 +65,9 @@ cmb_rapi_available: controller: App\Controller\CMBRAPIController::available methods: [POST] -cmb_rapi_jo_history_view: - path: /cmbrapi/johistory - controller: App\Controller\CMBRAPIController::viewJobOrderHistory +cmb_rapi_jo_history: + path: /cmbrapi/johistory/{period} + controller: App\Controller\CMBRAPIController::getJobOrderHistory methods: [GET] cmb_rapi_assigned_jo_get: diff --git a/src/Controller/CMBRAPIController.php b/src/Controller/CMBRAPIController.php index d9286ad9..4d9ab33b 100644 --- a/src/Controller/CMBRAPIController.php +++ b/src/Controller/CMBRAPIController.php @@ -301,11 +301,11 @@ class CMBRAPIController extends Controller return $res->getReturnResponse(); } - public function viewJobOrderHistory(Request $req, RiderAPIHandlerInterface $rapi_handler) + public function getJobOrderHistory(Request $req, $period, RiderAPIHandlerInterface $rapi_handler) { $res = new APIResult(); - $data = $rapi_handler->getJobOrderHistory($req); + $data = $rapi_handler->getJobOrderHistory($req, $period); if (isset($data['error'])) { diff --git a/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php b/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php index 4ef3557c..82ec5c4e 100644 --- a/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php +++ b/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php @@ -284,8 +284,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface } - // TODO: this needs to be changed to get the JOs for this month and last month - public function getJobOrderHistory(Request $req) + public function getJobOrderHistory(Request $req, $period) { $required_params = []; $data = $this->checkParamsAndKey($req, $required_params); @@ -304,8 +303,6 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface $rider = $this->session->getRider(); // get JOs assigned to rider for the month given - // TODO: what date to use - // for now, using date_schedule // setup start date and end dates // get current year $month = $req->query->get('month'); @@ -314,6 +311,14 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface $current_date = new DateTime(); $current_year = $current_date->format('Y'); + if ($period == 'thismonth') + { + $month = $current_date->format('m'); + } + else + { + } + // get number of days in month requested $last_day = cal_days_in_month(CAL_GREGORIAN, $month, $current_year);