Add customer location dropdown to JO form. #739

This commit is contained in:
Korina Cordero 2023-02-23 07:13:48 +00:00
parent f57c9f5f4f
commit 4717d7d925
2 changed files with 110 additions and 6 deletions

View file

@ -28,6 +28,7 @@ use App\Entity\Customer;
use App\Entity\CustomerTag; use App\Entity\CustomerTag;
use App\Entity\EmergencyType; use App\Entity\EmergencyType;
use App\Entity\OwnershipType; use App\Entity\OwnershipType;
use App\Entity\CustomerLocation;
use App\Ramcar\InvoiceCriteria; use App\Ramcar\InvoiceCriteria;
use App\Ramcar\ServiceType; 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 // get source of awareness if any
$soa_type = $req->request->get('source_of_awareness', ''); $soa_type = $req->request->get('source_of_awareness', '');
@ -489,7 +500,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->setCallerClassification($caller_class) ->setCallerClassification($caller_class)
->setGender($gender) ->setGender($gender)
->setEmergencyType($etype) ->setEmergencyType($etype)
->setOwnershipType($owner_type); ->setOwnershipType($owner_type)
->setCustomerLocation($cust_location);
// check if user is null, meaning call to create came from API // check if user is null, meaning call to create came from API
if ($user != null) if ($user != null)
@ -710,6 +722,16 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$ownertype_id = $req->request->get('ownership_type', 0); $ownertype_id = $req->request->get('ownership_type', 0);
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); $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)) if (empty($error_array))
{ {
// get current user // get current user
@ -744,7 +766,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->setCallerClassification($caller_class) ->setCallerClassification($caller_class)
->setGender($gender) ->setGender($gender)
->setEmergencyType($etype) ->setEmergencyType($etype)
->setOwnershipType($owner_type); ->setOwnershipType($owner_type)
->setCustomerLocation($cust_location);
// did they change invoice? // did they change invoice?
$invoice_items = $req->request->get('invoice_items', []); $invoice_items = $req->request->get('invoice_items', []);
@ -916,6 +939,16 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$ownertype_id = $req->request->get('ownership_type', 0); $ownertype_id = $req->request->get('ownership_type', 0);
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); $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)) if (empty($error_array))
{ {
// coordinates // coordinates
@ -947,7 +980,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->setGender($gender) ->setGender($gender)
->setCallerClassification($caller_class) ->setCallerClassification($caller_class)
->setEmergencyType($etype) ->setEmergencyType($etype)
->setOwnershipType($owner_type); ->setOwnershipType($owner_type)
->setCustomerLocation($cust_location);
// validate // validate
$errors = $this->validator->validate($obj); $errors = $this->validator->validate($obj);
@ -1065,6 +1099,16 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$ownertype_id = $req->request->get('ownership_type', 0); $ownertype_id = $req->request->get('ownership_type', 0);
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); $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 // get current user
$user = $this->security->getUser(); $user = $this->security->getUser();
@ -1098,7 +1142,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->setCallerClassification($caller_class) ->setCallerClassification($caller_class)
->setGender($gender) ->setGender($gender)
->setEmergencyType($etype) ->setEmergencyType($etype)
->setOwnershipType($owner_type); ->setOwnershipType($owner_type)
->setCustomerLocation($cust_location);
if ($user != null) if ($user != null)
{ {
@ -1205,6 +1250,16 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$ownertype_id = $req->request->get('ownership_type', 0); $ownertype_id = $req->request->get('ownership_type', 0);
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); $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)) { 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'));
@ -1232,7 +1287,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->setGender($gender) ->setGender($gender)
->setCallerClassification($caller_class) ->setCallerClassification($caller_class)
->setEmergencyType($etype) ->setEmergencyType($etype)
->setOwnershipType($owner_type); ->setOwnershipType($owner_type)
->setCustomerLocation($cust_location);
// validate // validate
$errors = $this->validator->validate($obj); $errors = $this->validator->validate($obj);
@ -1459,6 +1515,16 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$ownertype_id = $req->request->get('ownership_type', 0); $ownertype_id = $req->request->get('ownership_type', 0);
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); $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 // get previously assigned hub, if any
$old_hub = $obj->getHub(); $old_hub = $obj->getHub();
@ -1517,6 +1583,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->setCallerClassification($caller_class) ->setCallerClassification($caller_class)
->setEmergencyType($etype) ->setEmergencyType($etype)
->setOwnershipType($owner_type) ->setOwnershipType($owner_type)
->setCustomerLocation($cust_location)
->clearRider(); ->clearRider();
if ($user != null) if ($user != null)
@ -1744,6 +1811,16 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$ownertype_id = $req->request->get('ownership_type', 0); $ownertype_id = $req->request->get('ownership_type', 0);
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); $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)) { if (empty($error_array)) {
// rider mqtt event // rider mqtt event
// NOTE: need to send this before saving because rider will be cleared // NOTE: need to send this before saving because rider will be cleared
@ -1796,7 +1873,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->setGender($gender) ->setGender($gender)
->setCallerClassification($caller_class) ->setCallerClassification($caller_class)
->setEmergencyType($etype) ->setEmergencyType($etype)
->setOwnershipType($owner_type); ->setOwnershipType($owner_type)
->setCustomerLocation($cust_location);
if ($user != null) if ($user != null)
{ {
@ -3360,6 +3438,15 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
} }
$params['ownership_types'] = $ownership_types; $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 // list of hubs
$hubs = $em->getRepository(Hub::class)->findBy([], ['name' => 'ASC']); $hubs = $em->getRepository(Hub::class)->findBy([], ['name' => 'ASC']);
$fac_hubs = []; $fac_hubs = [];

View file

@ -560,6 +560,23 @@
Location Location
</h3> </h3>
</div> </div>
<div class="form-group m-form__group row">
<div class="col-lg-6">
<label for="cust_location" data-field="cust_location"> Customer Location </label>
<select class="form-control m-input" id="cust-location" name="cust_location">
{% for id, label in cust_locations %}
{% if obj.getCustomerLocation %}
<option value="{{ id }}"{{ obj.getCustomerLocation.getID == id ? ' selected' }}>{{ label }}</option>
{% else %}
<option value="{{ id }}">{{ label }}</option>
{% endif %}
{% endfor %}
</select>
<div class="form-control-feedback hide" data-field="cust_location"></div>
</div>
<div class="col-lg-6">
</div>
</div>
<div class="form-group m-form__group row"> <div class="form-group m-form__group row">
<div class="col-lg-6"> <div class="col-lg-6">
<label data-field="delivery_address">Delivery Address</label> <label data-field="delivery_address">Delivery Address</label>