diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index b45ecfba..a688a7ba 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -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(); diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig index 49fd8b30..3b8a6a37 100644 --- a/templates/job-order/form.html.twig +++ b/templates/job-order/form.html.twig @@ -831,20 +831,28 @@