diff --git a/config/routes/resq_job_order.yaml b/config/routes/resq_job_order.yaml index 2d7f74d5..5c506621 100644 --- a/config/routes/resq_job_order.yaml +++ b/config/routes/resq_job_order.yaml @@ -7,8 +7,3 @@ jo_resq_proc_rows: path: /resq-job-order/processing-rows controller: App\Controller\ResqJobOrderController::datatableRows methods: [POST] - -jo_resq_proc_unlock: - path: /resq-job-order/{id}/unlock/processor - controller: App\Controller\ResqJobOrderController::unlockProcessor - methods: [GET] diff --git a/src/Controller/JobOrderController.php b/src/Controller/JobOrderController.php index f847a842..485709e4 100644 --- a/src/Controller/JobOrderController.php +++ b/src/Controller/JobOrderController.php @@ -316,7 +316,7 @@ class JobOrderController extends Controller /** * @Menu(selected="jo_proc") */ - public function processingForm(HubSelector $hub_selector, $id, JobOrderHandlerInterface $jo_handler, GISManagerInterface $gis, MotivConnector $motiv) + public function processingForm(HubSelector $hub_selector, $id, JobOrderHandlerInterface $jo_handler, GISManagerInterface $gis, MotivConnector $motiv, Request $req) { $this->denyAccessUnlessGranted('jo_proc.list', null, 'No access.'); @@ -337,6 +337,18 @@ class JobOrderController extends Controller $params['return_url'] = $this->generateUrl('jo_proc'); $params['map_js_file'] = $gis->getJSJOFile(); + // check for origin parameter + $origin = $req->query->get('origin', ''); + if (empty($origin)) + { + // set return url to default dispatch + $params['return_url'] = $this->generateUrl('jo_proc'); + } + else + { + // set return url to resq dispatch + $params['return_url'] = $this->generateUrl('jo_resq_proc'); + } $template = $params['template']; // response @@ -795,15 +807,25 @@ class JobOrderController extends Controller ]); } - public function unlockProcessor($id, JobOrderHandlerInterface $jo_handler) + public function unlockProcessor($id, JobOrderHandlerInterface $jo_handler, Request $req) { $this->denyAccessUnlessGranted('jo_proc.unlock', null, 'No access.'); // call unlockProcessor in job order service $jo_handler->unlockProcessor($id); - // redirect to list - return $this->redirectToRoute('jo_proc'); + // get the origin + $origin = $req->query->get('origin', ''); + if (empty($origin)) + { + // redirect to list + return $this->redirectToRoute('jo_proc'); + } + else + { + // redirect to resq list + return $this->redirectToRoute('jo_resq_proc'); + } } public function unlockAssignor($id, JobOrderHandlerInterface $jo_handler) diff --git a/src/Controller/ResqJobOrderController.php b/src/Controller/ResqJobOrderController.php index 1cbd1c8b..8295077d 100644 --- a/src/Controller/ResqJobOrderController.php +++ b/src/Controller/ResqJobOrderController.php @@ -136,7 +136,7 @@ class ResqJobOrderController extends Controller $jo_id = $orow->getID(); $row['meta']['update_url'] = $this->generateUrl('jo_proc_form', ['id' => $jo_id, 'origin' => 'resq']); - $row['meta']['unlock_url'] = $this->generateUrl('jo_resq_proc_unlock', ['id' => $jo_id, 'origin' => 'resq']); + $row['meta']['unlock_url'] = $this->generateUrl('jo_proc_unlock', ['id' => $jo_id, 'origin' => 'resq']); $rows[] = $row; } @@ -148,22 +148,6 @@ class ResqJobOrderController extends Controller ]); } - /** - * @Menu(selected="jo_resq_proc") - * @ParamConverter("job_order", class="App\Entity\JobOrder") - * @IsGranted("jo_resq_proc.list") - */ - public function unlockProcessor($id, EntityManagerInterface $em, JobOrder $jo) - { - $jo->setProcessedBy(null); - - $em->flush(); - - // redirect to list - return $this->redirectToRoute('jo_resq_proc'); - } - - protected function setQueryFilters($datatable, &$query, $qb, $status, $source) { $query->where('q.status = :status')