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
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:

View file

@ -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']))
{

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)
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);