Resolve "Source of Awareness field to be required and not optional" #1625

Open
korina.cordero wants to merge 2 commits from 698-source-of-awareness-field-to-be-required-and-not-optional into master
4 changed files with 42 additions and 8 deletions

View file

@ -208,6 +208,9 @@ class TicketController extends Controller
$em = $this->getDoctrine()->getManager();
// initialize error list
$error_array = [];
// get customer data
if ($customer_id) {
$customer = $em->getRepository(Customer::class)->find($customer_id);
@ -254,6 +257,10 @@ class TicketController extends Controller
// get source of awareness if any
$soa_type = $req->request->get('source_of_awareness');
// source of awareness is now required
if (empty($soa_type))
$error_array['source_of_awareness'] = 'Source of awareness is required.';
// get remarks
$remarks = $req->request->get('remarks', '');
@ -281,9 +288,6 @@ class TicketController extends Controller
$obj->setJobOrder($job_order);
}
// initialize error list
$error_array = [];
// validate
$errors = $validator->validate($obj);
@ -423,6 +427,9 @@ class TicketController extends Controller
$em = $this->getDoctrine()->getManager();
$obj = $em->getRepository(Ticket::class)->find($id);
// initialize error list
$error_array = [];
// make sure this row exists
if (empty($obj))
throw $this->createNotFoundException('The item does not exist');
@ -461,6 +468,10 @@ class TicketController extends Controller
// get source of awareness if any
$soa_type = $req->request->get('source_of_awareness');
// source of awareness is now required
if (empty($soa_type))
$error_array['source_of_awareness'] = 'Source of awareness is required.';
// get remarks
$remarks = $req->request->get('remarks', '');
@ -476,9 +487,6 @@ class TicketController extends Controller
->setSourceOfAwareness($soa_type)
->setRemarks($remarks);
// initialize error list
$error_array = [];
// validate
$errors = $validator->validate($obj);

View file

@ -450,6 +450,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$ownertype_id = $req->request->get('ownership_type', 0);
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
// source of awareness is now required
if (empty($soa_type))
$error_array['source_of_awareness'] = 'Source of awareness is required.';
// TODO: check status before saving since JO might already
// have a status that needs to be retained
@ -710,6 +714,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$ownertype_id = $req->request->get('ownership_type', 0);
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
// source of awareness is now required
if (empty($soa_type))
$error_array['source_of_awareness'] = 'Source of awareness is required.';
if (empty($error_array))
{
// get current user
@ -916,6 +924,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$ownertype_id = $req->request->get('ownership_type', 0);
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
// source of awareness is now required
if (empty($soa_type))
$error_array['source_of_awareness'] = 'Source of awareness is required.';
if (empty($error_array))
{
// coordinates
@ -1065,6 +1077,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$ownertype_id = $req->request->get('ownership_type', 0);
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
// source of awareness is now required
if (empty($soa_type))
$error_array['source_of_awareness'] = 'Source of awareness is required.';
// get current user
$user = $this->security->getUser();
@ -1205,6 +1221,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$ownertype_id = $req->request->get('ownership_type', 0);
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
// source of awareness is now required
if (empty($soa_type))
$error_array['source_of_awareness'] = 'Source of awareness is required.';
if (empty($error_array)) {
// coordinates
$point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat'));
@ -1459,6 +1479,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$ownertype_id = $req->request->get('ownership_type', 0);
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
// source of awareness is now required
if (empty($soa_type))
$error_array['source_of_awareness'] = 'Source of awareness is required.';
// get previously assigned hub, if any
$old_hub = $obj->getHub();
@ -1739,6 +1763,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$ownertype_id = $req->request->get('ownership_type', 0);
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
// source of awareness is now required
if (empty($soa_type))
$error_array['source_of_awareness'] = 'Source of awareness is required.';
if (empty($error_array)) {
// rider mqtt event
// NOTE: need to send this before saving because rider will be cleared

View file

@ -510,7 +510,6 @@
<div class="col-lg-6">
<label data-field="status">Source of Awareness</label>
<select class="form-control m-input" id="source-of-awareness" name="source_of_awareness">
<option value=""></option>
{% for key, soa in soa_types %}
<option value="{{ key }}"{{ key == obj.getSourceOfAwareness ? ' selected' }}>{{ soa }}</option>
{% endfor %}

View file

@ -126,7 +126,6 @@
<div class="col-lg-4">
<label data-field="status">Source of Awareness</label>
<select class="form-control m-input" id="source-of-awareness" name="source_of_awareness">
<option value=""></option>
{% for key, soa in soa_types %}
<option value="{{ key }}"{{ key == obj.getSourceOfAwareness ? ' selected' }}>{{ soa }}</option>
{% endfor %}