diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index 880fb1c1..9c4b700e 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -426,14 +426,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface } // check if customer location is set - // since we didn't provide a blank option in the dropdown, there is - // always a customer location set. - $cust_location_id = $req->request->get('cust_location'); + $cust_location_id = $req->request->get('cust_location', 0); + if ($cust_location_id == 0) + $error_array['cust_location'] = 'Customer location is required.'; + else + { + // get customer location + $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - // get customer location - $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - if ($cust_location == null) - $error_array['cust_location'] = 'Invalid customer location'; + if ($cust_location == null) + $error_array['cust_location'] = 'Invalid customer location'; + } // get source of awareness if any $soa_type = $req->request->get('source_of_awareness', ''); @@ -723,14 +726,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); // check if customer location is set - // since we didn't provide a blank option in the dropdown, there is - // always a customer location set. - $cust_location_id = $req->request->get('cust_location'); + $cust_location_id = $req->request->get('cust_location', 0); + if ($cust_location_id == 0) + $error_array['cust_location'] = 'Customer location is required.'; + else + { + // get customer location + $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - // get customer location - $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - if ($cust_location == null) - $error_array['cust_location'] = 'Invalid customer location'; + if ($cust_location == null) + $error_array['cust_location'] = 'Invalid customer location'; + } if (empty($error_array)) { @@ -940,14 +946,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); // check if customer location is set - // since we didn't provide a blank option in the dropdown, there is - // always a customer location set. - $cust_location_id = $req->request->get('cust_location'); + $cust_location_id = $req->request->get('cust_location', 0); + if ($cust_location_id == 0) + $error_array['cust_location'] = 'Customer location is required.'; + else + { + // get customer location + $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - // get customer location - $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - if ($cust_location == null) - $error_array['cust_location'] = 'Invalid customer location'; + if ($cust_location == null) + $error_array['cust_location'] = 'Invalid customer location'; + } if (empty($error_array)) { @@ -1100,14 +1109,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); // check if customer location is set - // since we didn't provide a blank option in the dropdown, there is - // always a customer location set. - $cust_location_id = $req->request->get('cust_location'); + $cust_location_id = $req->request->get('cust_location', 0); + if ($cust_location_id == 0) + $error_array['cust_location'] = 'Customer location is required.'; + else + { + // get customer location + $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - // get customer location - $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - if ($cust_location == null) - $error_array['cust_location'] = 'Invalid customer location'; + if ($cust_location == null) + $error_array['cust_location'] = 'Invalid customer location'; + } // get current user $user = $this->security->getUser(); @@ -1251,14 +1263,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); // check if customer location is set - // since we didn't provide a blank option in the dropdown, there is - // always a customer location set. - $cust_location_id = $req->request->get('cust_location'); + $cust_location_id = $req->request->get('cust_location', 0); + if ($cust_location_id == 0) + $error_array['cust_location'] = 'Customer location is required.'; + else + { + // get customer location + $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - // get customer location - $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - if ($cust_location == null) - $error_array['cust_location'] = 'Invalid customer location'; + if ($cust_location == null) + $error_array['cust_location'] = 'Invalid customer location'; + } if (empty($error_array)) { // coordinates @@ -1516,14 +1531,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); // check if customer location is set - // since we didn't provide a blank option in the dropdown, there is - // always a customer location set. - $cust_location_id = $req->request->get('cust_location'); + $cust_location_id = $req->request->get('cust_location', 0); + if ($cust_location_id == 0) + $error_array['cust_location'] = 'Customer location is required.'; + else + { + // get customer location + $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - // get customer location - $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - if ($cust_location == null) - $error_array['cust_location'] = 'Invalid customer location'; + if ($cust_location == null) + $error_array['cust_location'] = 'Invalid customer location'; + } // get previously assigned hub, if any $old_hub = $obj->getHub(); @@ -1812,14 +1830,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); // check if customer location is set - // since we didn't provide a blank option in the dropdown, there is - // always a customer location set. - $cust_location_id = $req->request->get('cust_location'); + $cust_location_id = $req->request->get('cust_location', 0); + if ($cust_location_id == 0) + $error_array['cust_location'] = 'Customer location is required.'; + else + { + // get customer location + $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - // get customer location - $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - if ($cust_location == null) - $error_array['cust_location'] = 'Invalid customer location'; + if ($cust_location == null) + $error_array['cust_location'] = 'Invalid customer location'; + } if (empty($error_array)) { // rider mqtt event diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig index 18ae6d27..9a8387b5 100644 --- a/templates/job-order/form.html.twig +++ b/templates/job-order/form.html.twig @@ -564,6 +564,7 @@