Add list of job orders behind schedule. #436

This commit is contained in:
Korina Cordero 2020-07-15 08:40:30 +00:00
parent 340344729d
commit 4c8ea2f69b
6 changed files with 97 additions and 0 deletions

View file

@ -270,6 +270,8 @@ access_keys:
label: Autoassign Test
- id: jo_hub.list
label: Hub View
- id: jo_behind_schedule.list
label: View Behind Schedule
- id: support
label: Customer Support Access

View file

@ -118,6 +118,10 @@ main_menu:
acl: jo_all.list
label: View All
parent: joborder
- id: jo_behind_schedule
acl: jo_behind_schedule.list
label: View Behind Schedule
parent: joborder
- id: support
acl: support.menu

View file

@ -118,6 +118,10 @@ main_menu:
acl: jo_all.list
label: View All
parent: joborder
- id: jo_behind_schedule
acl: jo_behind_schedule.list
label: View Behind Schedule
parent: joborder
- id: support
acl: support.menu

View file

@ -253,3 +253,14 @@ jo_hub_view_form:
controller: App\Controller\JobOrderController::hubViewForm
methods: [GET]
jo_behind_schedule:
path: /job-order/behind-schedule
controller: App\Controller\JobOrderController::listBehindSchedule
methods: [GET]
jo_behind_schedule_rows:
path: /job-order/behind-schedule-rows
controller: App\Controller\JobOrderController::getRows
methods: [POST]
defaults:
tier: "behind_schedule"

View file

@ -286,6 +286,11 @@ class JobOrderController extends Controller
$rows[$key]['meta']['edit_url'] = $this->generateUrl($jo_handler->getEditRoute($jo_id, $tier_params['edit_route']), ['id' => $jo_id]);
$rows[$key]['meta']['onestep_edit_url'] = $this->generateUrl('jo_onestep_edit_form', ['id' => $jo_id]);
}
else if ($tier == 'behind_schedule')
{
$rows[$key]['meta']['edit_url'] = $this->generateUrl($jo_handler->getEditRoute($jo_id, $tier_params['edit_route']), ['id' => $jo_id]);
$rows[$key]['meta']['onestep_edit_url'] = $this->generateUrl('jo_onestep_edit_form', ['id' => $jo_id]);
}
else
{
// $rows[$key]['meta']['update_url'] = $this->generateUrl($tier_params['edit_route'], ['id' => $jo_id]);
@ -1212,6 +1217,21 @@ class JobOrderController extends Controller
}
/**
* @Menu(selected="jo_behind_schedule")
*/
public function listBehindSchedule(JobOrderHandlerInterface $jo_handler)
{
$this->denyAccessUnlessGranted('jo_behind_schedule.list', null, 'No access.');
$template = $jo_handler->getTwigTemplate('jo_behind_schedule');
$params = $jo_handler->getOtherParameters();
$params['table_refresh_rate'] = $this->container->getParameter('job_order_refresh_interval');
return $this->render($template, $params);
}
protected function autoAssignHubAndRider($jo, EntityManagerInterface $em,
MapTools $map_tools, InventoryManager $im)
{

View file

@ -2926,6 +2926,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
$this->template_hash['jo_walkin_form'] = 'job-order/cmb.form.walkin.html.twig';
$this->template_hash['jo_walkin_edit_form'] = 'job-order/cmb.form.walkin.html.twig';
$this->template_hash['jo_popup'] = 'job-order/cmb.popup.html.twig';
$this->template_hash['jo_behind_schedule'] = 'job-order/cmb.list.behindschedule.html.twig';
}
protected function checkTier($tier)
@ -2981,6 +2982,14 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
$unlock_route = '';
$jo_status = '';
break;
case 'behind_schedule':
$tier_key = 'jo_behind_schedule';
$tier_name = 'Behind Schedule';
$rows_route = 'jo_behind_schedule_rows';
$edit_route = '';
$unlock_route = '';
$jo_status = JOStatus::ASSIGNED;
break;
default:
throw new AccessDeniedHttpException('No access.');
}
@ -3111,6 +3120,53 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
->setParameter('date_start', $date_start)
->setParameter('date_end', $date_end);
}
break;
case 'behind_schedule':
if (isset($datatable['query']['data-rows-search']))
{
$query->innerJoin('q.cus_vehicle', 'cv')
->innerJoin('q.customer', 'c')
->where('cv.plate_number like :filter')
->orWhere('c.phone_mobile like :filter')
->orWhere('c.first_name like :filter or c.last_name like :filter')
->setParameter('filter', $datatable['query']['data-rows-search'] . '%');
}
if (isset($datatable['query']['rider']))
{
$query->innerJoin('q.rider', 'r')
->andWhere('r.id = :rider_id')
->setParameter('rider_id', $datatable['query']['rider']);
}
if (isset($datatable['query']['schedule_date']))
{
$start = $datatable['query']['schedule_date'][0] . ' ' . '00:00:00';
$end = $datatable['query']['schedule_date'][1] . ' ' . '23:59:00';
$date_start = DateTime::createFromFormat('m/d/Y H:i:s', $start);
$date_end = DateTime::createFromFormat('m/d/Y H:i:s', $end);
$query->andWhere('q.date_schedule >= :date_start')
->andWhere('q.date_schedule <= :date_end')
->setParameter('date_start', $date_start)
->setParameter('date_end', $date_end);
}
// status should be assigned
$query->andWhere('q.status = :status')
->setParameter('status', $status);
$current_datetime = new DateTime();
$other_date = new DateTime();
$interval = new DateInterval('PT15M');
$other_date->add($interval);
//error_log('current datetime ' . $current_datetime->format('Y-m-d H:i:s'));
//error_log('other_date ' . $other_date->format('Y-m-d H:i:s'));
$query->andWhere('q.date_schedule < :current_datetime OR q.date_schedule <= :other_date')
->setParameter('current_datetime', $current_datetime)
->setParameter('other_date', $other_date);
break;
default:
$query->where('q.status = :status')