From a0d611264d1812e256e6d649d50a3e3aa339ed1f Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Mon, 28 Jan 2019 01:07:45 +0800 Subject: [PATCH 1/3] Add queue ticket types #175 --- src/Ramcar/TicketType.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Ramcar/TicketType.php b/src/Ramcar/TicketType.php index 3edc9c89..400b7a55 100644 --- a/src/Ramcar/TicketType.php +++ b/src/Ramcar/TicketType.php @@ -12,6 +12,9 @@ class TicketType extends NameValue const FOR_FOLLOW_UP = 'for_follow_up'; const RESQ_INQUIRY = 'resq_inquiry'; + const BATTERY_QUEUE = 'battery_queue'; + const RESQ_QUEUE = 'resq_queue'; + const COLLECTION = [ 'complaint' => 'Complaint', 'inquiry' => 'Inquiry', @@ -20,5 +23,7 @@ class TicketType extends NameValue 'other' => 'Other', 'for_follow_up' => 'For follow-up', 'resq_inquiry' => 'RESQ Inquiry', + 'battery_queue' => 'Battery Queue (XFER)', + 'resq_queue' => 'Resq Queue (XFER)', ]; } From 4b2445454982bd5f23e214bc5d437963d801bba9 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Mon, 28 Jan 2019 02:44:05 +0800 Subject: [PATCH 2/3] Fix dispatch, so cancelled job orders cannot be assigned to a hub #175 --- src/Controller/JobOrderController.php | 27 +++++++++++++++++++++------ src/Entity/JobOrder.php | 8 ++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/Controller/JobOrderController.php b/src/Controller/JobOrderController.php index 61630861..ca3d271a 100644 --- a/src/Controller/JobOrderController.php +++ b/src/Controller/JobOrderController.php @@ -956,24 +956,38 @@ class JobOrderController extends BaseController if (empty($obj)) throw $this->createNotFoundException('The item does not exist'); + // check if cancelled already + if (!$obj->canDispatch()) + { + throw $this->createNotFoundException('Could not dispatch. Job Order is not pending.'); + // TODO: have this handled better, so UI shows the error + // $error_array['dispatch'] = 'Could not dispatch. Job Order is not pending.'; + } + // check if lat and lng are provided - if (empty($req->request->get('coord_lng')) || empty($req->request->get('coord_lat'))) { + if (empty($req->request->get('coord_lng')) || empty($req->request->get('coord_lat'))) + { $error_array['coordinates'] = 'No map coordinates provided. Please click on a location on the map.'; } // check if hub is set - if (empty($req->request->get('hub'))) { + if (empty($req->request->get('hub'))) + { $error_array['hub'] = 'No hub selected.'; - } else { + } + else + { // get hub $hub = $em->getRepository(Hub::class)->find($req->request->get('hub')); - if (empty($hub)) { + if (empty($hub)) + { $error_array['hub'] = 'Invalid hub specified.'; } } - if (empty($error_array)) { + if (empty($error_array)) + { // coordinates $point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat')); @@ -1001,7 +1015,8 @@ class JobOrderController extends BaseController } // check if any errors were found - if (!empty($error_array)) { + if (!empty($error_array)) + { // return validation failure response return $this->json([ 'success' => false, diff --git a/src/Entity/JobOrder.php b/src/Entity/JobOrder.php index cd4f14fb..d4a40373 100644 --- a/src/Entity/JobOrder.php +++ b/src/Entity/JobOrder.php @@ -726,4 +726,12 @@ class JobOrder return $this->flag_coolant; } + public function canDispatch() + { + if ($this->status == JOStatus::PENDING) + return true; + + return false; + } + } From 1bd5c308750e81e601a01effca132a27e795cae0 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Mon, 28 Jan 2019 03:16:50 +0800 Subject: [PATCH 3/3] Fix assign rider so cancelled job orders cannot be assigned #175 --- src/Controller/JobOrderController.php | 5 +++++ src/Entity/JobOrder.php | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/Controller/JobOrderController.php b/src/Controller/JobOrderController.php index ca3d271a..0e0e6d8e 100644 --- a/src/Controller/JobOrderController.php +++ b/src/Controller/JobOrderController.php @@ -1142,6 +1142,11 @@ class JobOrderController extends BaseController if (empty($obj)) throw $this->createNotFoundException('The item does not exist'); + // check if we can assign + if (!$obj->canAssign()) + throw $this->createNotFoundException('Cannot assign rider to this job order.'); + + // check if lat and lng are provided if (empty($req->request->get('coord_lng')) || empty($req->request->get('coord_lat'))) { $error_array['coordinates'] = 'No map coordinates provided. Please click on a location on the map.'; diff --git a/src/Entity/JobOrder.php b/src/Entity/JobOrder.php index d4a40373..ddc9d299 100644 --- a/src/Entity/JobOrder.php +++ b/src/Entity/JobOrder.php @@ -734,4 +734,12 @@ class JobOrder return false; } + public function canAssign() + { + if ($this->status == JOStatus::ASSIGNED) + return true; + + return false; + } + }