diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index 9a9a44a5..880fb1c1 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -28,6 +28,7 @@ use App\Entity\Customer; use App\Entity\CustomerTag; use App\Entity\EmergencyType; use App\Entity\OwnershipType; +use App\Entity\CustomerLocation; use App\Ramcar\InvoiceCriteria; use App\Ramcar\ServiceType; @@ -424,6 +425,16 @@ 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'); + + // get customer location + $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); + 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', ''); @@ -489,7 +500,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setCallerClassification($caller_class) ->setGender($gender) ->setEmergencyType($etype) - ->setOwnershipType($owner_type); + ->setOwnershipType($owner_type) + ->setCustomerLocation($cust_location); // check if user is null, meaning call to create came from API if ($user != null) @@ -710,6 +722,16 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $ownertype_id = $req->request->get('ownership_type', 0); $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'); + + // 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 (empty($error_array)) { // get current user @@ -744,7 +766,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setCallerClassification($caller_class) ->setGender($gender) ->setEmergencyType($etype) - ->setOwnershipType($owner_type); + ->setOwnershipType($owner_type) + ->setCustomerLocation($cust_location); // did they change invoice? $invoice_items = $req->request->get('invoice_items', []); @@ -916,6 +939,16 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $ownertype_id = $req->request->get('ownership_type', 0); $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'); + + // 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 (empty($error_array)) { // coordinates @@ -947,7 +980,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setGender($gender) ->setCallerClassification($caller_class) ->setEmergencyType($etype) - ->setOwnershipType($owner_type); + ->setOwnershipType($owner_type) + ->setCustomerLocation($cust_location); // validate $errors = $this->validator->validate($obj); @@ -1065,6 +1099,16 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $ownertype_id = $req->request->get('ownership_type', 0); $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'); + + // get customer location + $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); + if ($cust_location == null) + $error_array['cust_location'] = 'Invalid customer location'; + // get current user $user = $this->security->getUser(); @@ -1098,7 +1142,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setCallerClassification($caller_class) ->setGender($gender) ->setEmergencyType($etype) - ->setOwnershipType($owner_type); + ->setOwnershipType($owner_type) + ->setCustomerLocation($cust_location); if ($user != null) { @@ -1205,6 +1250,16 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $ownertype_id = $req->request->get('ownership_type', 0); $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'); + + // 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 (empty($error_array)) { // coordinates $point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat')); @@ -1232,7 +1287,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setGender($gender) ->setCallerClassification($caller_class) ->setEmergencyType($etype) - ->setOwnershipType($owner_type); + ->setOwnershipType($owner_type) + ->setCustomerLocation($cust_location); // validate $errors = $this->validator->validate($obj); @@ -1459,6 +1515,16 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $ownertype_id = $req->request->get('ownership_type', 0); $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'); + + // get customer location + $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); + if ($cust_location == null) + $error_array['cust_location'] = 'Invalid customer location'; + // get previously assigned hub, if any $old_hub = $obj->getHub(); @@ -1517,6 +1583,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setCallerClassification($caller_class) ->setEmergencyType($etype) ->setOwnershipType($owner_type) + ->setCustomerLocation($cust_location) ->clearRider(); if ($user != null) @@ -1744,6 +1811,16 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $ownertype_id = $req->request->get('ownership_type', 0); $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'); + + // 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 (empty($error_array)) { // rider mqtt event // NOTE: need to send this before saving because rider will be cleared @@ -1796,7 +1873,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setGender($gender) ->setCallerClassification($caller_class) ->setEmergencyType($etype) - ->setOwnershipType($owner_type); + ->setOwnershipType($owner_type) + ->setCustomerLocation($cust_location); if ($user != null) { @@ -3360,6 +3438,15 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface } $params['ownership_types'] = $ownership_types; + // list of customer locations + $cust_locations = $em->getRepository(CustomerLocation::class)->findBy([], ['name' => 'ASC']); + $c_locations = []; + foreach ($cust_locations as $cust_location) + { + $c_locations[$cust_location->getID()] = $cust_location->getName(); + } + $params['cust_locations'] = $c_locations; + // list of hubs $hubs = $em->getRepository(Hub::class)->findBy([], ['name' => 'ASC']); $fac_hubs = []; diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig index c90f863c..18ae6d27 100644 --- a/templates/job-order/form.html.twig +++ b/templates/job-order/form.html.twig @@ -560,6 +560,23 @@ Location +