Resolve "Sprint 20180129" #1019

Merged
jankstudio merged 3 commits from 175-sprint-20180129 into master 2019-01-27 19:17:35 +00:00
3 changed files with 47 additions and 6 deletions

View file

@ -956,24 +956,38 @@ class JobOrderController extends BaseController
if (empty($obj)) if (empty($obj))
throw $this->createNotFoundException('The item does not exist'); 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 // 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.'; $error_array['coordinates'] = 'No map coordinates provided. Please click on a location on the map.';
} }
// check if hub is set // check if hub is set
if (empty($req->request->get('hub'))) { if (empty($req->request->get('hub')))
{
$error_array['hub'] = 'No hub selected.'; $error_array['hub'] = 'No hub selected.';
} else { }
else
{
// get hub // get hub
$hub = $em->getRepository(Hub::class)->find($req->request->get('hub')); $hub = $em->getRepository(Hub::class)->find($req->request->get('hub'));
if (empty($hub)) { if (empty($hub))
{
$error_array['hub'] = 'Invalid hub specified.'; $error_array['hub'] = 'Invalid hub specified.';
} }
} }
if (empty($error_array)) { if (empty($error_array))
{
// coordinates // coordinates
$point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat')); $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 // check if any errors were found
if (!empty($error_array)) { if (!empty($error_array))
{
// return validation failure response // return validation failure response
return $this->json([ return $this->json([
'success' => false, 'success' => false,
@ -1127,6 +1142,11 @@ class JobOrderController extends BaseController
if (empty($obj)) if (empty($obj))
throw $this->createNotFoundException('The item does not exist'); 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 // 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.'; $error_array['coordinates'] = 'No map coordinates provided. Please click on a location on the map.';

View file

@ -726,4 +726,20 @@ class JobOrder
return $this->flag_coolant; return $this->flag_coolant;
} }
public function canDispatch()
{
if ($this->status == JOStatus::PENDING)
return true;
return false;
}
public function canAssign()
{
if ($this->status == JOStatus::ASSIGNED)
return true;
return false;
}
} }

View file

@ -12,6 +12,9 @@ class TicketType extends NameValue
const FOR_FOLLOW_UP = 'for_follow_up'; const FOR_FOLLOW_UP = 'for_follow_up';
const RESQ_INQUIRY = 'resq_inquiry'; const RESQ_INQUIRY = 'resq_inquiry';
const BATTERY_QUEUE = 'battery_queue';
const RESQ_QUEUE = 'resq_queue';
const COLLECTION = [ const COLLECTION = [
'complaint' => 'Complaint', 'complaint' => 'Complaint',
'inquiry' => 'Inquiry', 'inquiry' => 'Inquiry',
@ -20,5 +23,7 @@ class TicketType extends NameValue
'other' => 'Other', 'other' => 'Other',
'for_follow_up' => 'For follow-up', 'for_follow_up' => 'For follow-up',
'resq_inquiry' => 'RESQ Inquiry', 'resq_inquiry' => 'RESQ Inquiry',
'battery_queue' => 'Battery Queue (XFER)',
'resq_queue' => 'Resq Queue (XFER)',
]; ];
} }