Add blank option for customer location dropdown. Add checking for blank option. #739

This commit is contained in:
Korina Cordero 2023-02-23 08:02:37 +00:00
parent 4717d7d925
commit 2aef8e64e7
2 changed files with 71 additions and 49 deletions

View file

@ -426,14 +426,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
} }
// check if customer location is set // check if customer location is set
// since we didn't provide a blank option in the dropdown, there is $cust_location_id = $req->request->get('cust_location', 0);
// always a customer location set. if ($cust_location_id == 0)
$cust_location_id = $req->request->get('cust_location'); $error_array['cust_location'] = 'Customer location is required.';
else
{
// get customer location // get customer location
$cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id);
if ($cust_location == null) if ($cust_location == null)
$error_array['cust_location'] = 'Invalid customer location'; $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', '');
@ -723,14 +726,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
// check if customer location is set // check if customer location is set
// since we didn't provide a blank option in the dropdown, there is $cust_location_id = $req->request->get('cust_location', 0);
// always a customer location set. if ($cust_location_id == 0)
$cust_location_id = $req->request->get('cust_location'); $error_array['cust_location'] = 'Customer location is required.';
else
{
// get customer location // get customer location
$cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id);
if ($cust_location == null) if ($cust_location == null)
$error_array['cust_location'] = 'Invalid customer location'; $error_array['cust_location'] = 'Invalid customer location';
}
if (empty($error_array)) if (empty($error_array))
{ {
@ -940,14 +946,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
// check if customer location is set // check if customer location is set
// since we didn't provide a blank option in the dropdown, there is $cust_location_id = $req->request->get('cust_location', 0);
// always a customer location set. if ($cust_location_id == 0)
$cust_location_id = $req->request->get('cust_location'); $error_array['cust_location'] = 'Customer location is required.';
else
{
// get customer location // get customer location
$cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id);
if ($cust_location == null) if ($cust_location == null)
$error_array['cust_location'] = 'Invalid customer location'; $error_array['cust_location'] = 'Invalid customer location';
}
if (empty($error_array)) if (empty($error_array))
{ {
@ -1100,14 +1109,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
// check if customer location is set // check if customer location is set
// since we didn't provide a blank option in the dropdown, there is $cust_location_id = $req->request->get('cust_location', 0);
// always a customer location set. if ($cust_location_id == 0)
$cust_location_id = $req->request->get('cust_location'); $error_array['cust_location'] = 'Customer location is required.';
else
{
// get customer location // get customer location
$cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id);
if ($cust_location == null) if ($cust_location == null)
$error_array['cust_location'] = 'Invalid customer location'; $error_array['cust_location'] = 'Invalid customer location';
}
// get current user // get current user
$user = $this->security->getUser(); $user = $this->security->getUser();
@ -1251,14 +1263,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
// check if customer location is set // check if customer location is set
// since we didn't provide a blank option in the dropdown, there is $cust_location_id = $req->request->get('cust_location', 0);
// always a customer location set. if ($cust_location_id == 0)
$cust_location_id = $req->request->get('cust_location'); $error_array['cust_location'] = 'Customer location is required.';
else
{
// get customer location // get customer location
$cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id);
if ($cust_location == null) if ($cust_location == null)
$error_array['cust_location'] = 'Invalid customer location'; $error_array['cust_location'] = 'Invalid customer location';
}
if (empty($error_array)) { if (empty($error_array)) {
// coordinates // coordinates
@ -1516,14 +1531,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
// check if customer location is set // check if customer location is set
// since we didn't provide a blank option in the dropdown, there is $cust_location_id = $req->request->get('cust_location', 0);
// always a customer location set. if ($cust_location_id == 0)
$cust_location_id = $req->request->get('cust_location'); $error_array['cust_location'] = 'Customer location is required.';
else
{
// get customer location // get customer location
$cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id);
if ($cust_location == null) if ($cust_location == null)
$error_array['cust_location'] = 'Invalid customer location'; $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();
@ -1812,14 +1830,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
// check if customer location is set // check if customer location is set
// since we didn't provide a blank option in the dropdown, there is $cust_location_id = $req->request->get('cust_location', 0);
// always a customer location set. if ($cust_location_id == 0)
$cust_location_id = $req->request->get('cust_location'); $error_array['cust_location'] = 'Customer location is required.';
else
{
// get customer location // get customer location
$cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id);
if ($cust_location == null) if ($cust_location == null)
$error_array['cust_location'] = 'Invalid customer location'; $error_array['cust_location'] = 'Invalid customer location';
}
if (empty($error_array)) { if (empty($error_array)) {
// rider mqtt event // rider mqtt event

View file

@ -564,6 +564,7 @@
<div class="col-lg-6"> <div class="col-lg-6">
<label for="cust_location" data-field="cust_location"> Customer Location </label> <label for="cust_location" data-field="cust_location"> Customer Location </label>
<select class="form-control m-input" id="cust-location" name="cust_location"> <select class="form-control m-input" id="cust-location" name="cust_location">
<option value=""></option>
{% for id, label in cust_locations %} {% for id, label in cust_locations %}
{% if obj.getCustomerLocation %} {% if obj.getCustomerLocation %}
<option value="{{ id }}"{{ obj.getCustomerLocation.getID == id ? ' selected' }}>{{ label }}</option> <option value="{{ id }}"{{ obj.getCustomerLocation.getID == id ? ' selected' }}>{{ label }}</option>