Merge branch '792-battery-facilitated-by-issue' into 'master'

Resolve "Battery Facilitated By issue"

Closes #792

See merge request jankstudio/resq!903
This commit is contained in:
Ramon Gutierrez 2024-09-24 04:40:00 +00:00 committed by Korina Cordero
commit 6994d69020
2 changed files with 74 additions and 9 deletions

View file

@ -1612,6 +1612,26 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$error_array['cust_location'] = 'Invalid customer location';
}
// check facilitated type
$fac_type = $req->request->get('facilitated_type');
if (!empty($fac_type))
{
if (!FacilitatedType::validate($fac_type))
$fac_type = null;
}
else
$fac_type = null;
// check facilitated by
$fac_by_id = $req->request->get('facilitated_by');
$fac_by = null;
if (!empty($fac_by_id))
{
$fac_by = $em->getRepository(Hub::class)->find($fac_by_id);
if (empty($fac_by))
$fac_by = null;
}
// get previously assigned hub, if any
$old_hub = $obj->getHub();
@ -1672,6 +1692,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->setOwnershipType($owner_type)
->setCustomerLocation($cust_location)
->setInventoryCount($req->request->get('hub_inv_count', 0))
->setFacilitatedType($fac_type)
->setFacilitatedBy($fac_by)
->clearRider();
if ($user != null)
@ -4345,12 +4367,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$phone_number = $this->country_code . $notif_number;
// check if reason is administrative
if ($rejection->getReason() == JORejectionReason::ADMINISTRATIVE)
return null;
// check if reason is in the list of rejection reason
$flag_send_sms = $this->checkRejectionReason($rejection->getReason());
// check if reason is discount
if ($rejection->getReason() == JORejectionReason::DISCOUNT)
if (!$flag_send_sms)
return null;
// sms content
@ -4384,6 +4404,43 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$this->rt->sendSMS($phone_number, $this->translator->trans('message.battery_brand_allcaps'), $msg);
}
protected function checkRejectionReason($reason): bool
{
// reason is administrative
if ($reason == JORejectionReason::ADMINISTRATIVE)
return false;
// reason is discount
if ($reason == JORejectionReason::DISCOUNT)
return false;
// reason is store closed on schedule
if ($reason == JORejectionReason::STORE_CLOSED_SCHEDULED)
return false;
// store closed half day
if ($reason == JORejectionReason::STORE_CLOSED_HALF_DAY)
return false;
// prio hub for warranty claim
if ($reason == JORejectionReason::PRIORITY_HUB_WTY_CLAIM)
return false;
// prio hub for jumpstart
if ($reason == JORejectionReason::PRIORITY_HUB_JUMPSTART)
return false;
// prio hub for RES-Q request
if ($reason == JORejectionReason::PRIORITY_HUB_RESQ_REQUEST)
return false;
// customer request
if ($reason == JORejectionReason::CUSTOMER_REQUEST)
return false;
return true;
}
protected function skipInventoryCheck(Point $coordinates): bool
{
$long = $coordinates->getLongitude();

View file

@ -831,20 +831,28 @@
<div class="m-form__section">
<div class="form-group m-form__group row">
<div class="col-lg-2">
<label for="faciliateted-type">Battery Facilitated By</label>
<label for="facilitated-type">Battery Facilitated By</label>
<select name="facilitated_type" class="form-control m-input" id="facilitated-type">
<option value="">None</option>
{% for key, type in facilitated_types %}
<option value="{{ key }}">{{ type }}</option>
{% if obj.getFacilitatedType %}
<option value="{{ key }}"{{ obj.getFacilitatedType == key ? ' selected' }}>{{ type }}</option>
{% else %}
<option value="{{ key }}">{{ type }}</option>
{% endif %}
{% endfor %}
</select>
</div>
<div class="col-lg-8">
<label for="faciliateted-by">&nbsp;</label>
<label for="facilitated-by">&nbsp;</label>
<select name="facilitated_by" class="form-control m-input" id="facilitated-by">
<option value="">None</option>
{% for key, name in facilitated_hubs %}
<option value="{{ key }}">{{ name }}</option>
{% if obj.getFacilitatedBy %}
<option value="{{ key }}"{{ obj.getFacilitatedBy.getID == key ? ' selected' }}>{{ name }}</option>
{% else %}
<option value="{{ key }}">{{ name }}</option>
{% endif %}
{% endfor %}
</select>
</div>