Modify getJobOrderHistory. #421

This commit is contained in:
Korina Cordero 2020-06-04 06:02:53 +00:00
parent a0ee7b32bc
commit b41b5ea29b
3 changed files with 14 additions and 9 deletions

View file

@ -65,9 +65,9 @@ cmb_rapi_available:
controller: App\Controller\CMBRAPIController::available controller: App\Controller\CMBRAPIController::available
methods: [POST] methods: [POST]
cmb_rapi_jo_history_view: cmb_rapi_jo_history:
path: /cmbrapi/johistory path: /cmbrapi/johistory/{period}
controller: App\Controller\CMBRAPIController::viewJobOrderHistory controller: App\Controller\CMBRAPIController::getJobOrderHistory
methods: [GET] methods: [GET]
cmb_rapi_assigned_jo_get: cmb_rapi_assigned_jo_get:

View file

@ -301,11 +301,11 @@ class CMBRAPIController extends Controller
return $res->getReturnResponse(); return $res->getReturnResponse();
} }
public function viewJobOrderHistory(Request $req, RiderAPIHandlerInterface $rapi_handler) public function getJobOrderHistory(Request $req, $period, RiderAPIHandlerInterface $rapi_handler)
{ {
$res = new APIResult(); $res = new APIResult();
$data = $rapi_handler->getJobOrderHistory($req); $data = $rapi_handler->getJobOrderHistory($req, $period);
if (isset($data['error'])) if (isset($data['error']))
{ {

View file

@ -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, $period)
public function getJobOrderHistory(Request $req)
{ {
$required_params = []; $required_params = [];
$data = $this->checkParamsAndKey($req, $required_params); $data = $this->checkParamsAndKey($req, $required_params);
@ -304,8 +303,6 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
$rider = $this->session->getRider(); $rider = $this->session->getRider();
// get JOs assigned to rider for the month given // 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 // setup start date and end dates
// get current year // get current year
$month = $req->query->get('month'); $month = $req->query->get('month');
@ -314,6 +311,14 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
$current_date = new DateTime(); $current_date = new DateTime();
$current_year = $current_date->format('Y'); $current_year = $current_date->format('Y');
if ($period == 'thismonth')
{
$month = $current_date->format('m');
}
else
{
}
// get number of days in month requested // get number of days in month requested
$last_day = cal_days_in_month(CAL_GREGORIAN, $month, $current_year); $last_day = cal_days_in_month(CAL_GREGORIAN, $month, $current_year);