Limit hub rejection SMS to one per JO/hub combo #800
This commit is contained in:
parent
b5f169c14e
commit
10c44fbe64
1 changed files with 19 additions and 0 deletions
|
|
@ -645,6 +645,25 @@ class HubSelector
|
|||
|
||||
protected function sendSMSMessage($hub, $jo_id, $order_date, $service_type, $rejection, $reason = "", $remarks = ""): void
|
||||
{
|
||||
// check if we already have a rejection record for this hub and JO. this also means an SMS was already sent
|
||||
$rejection_count = $this->em->createQueryBuilder()
|
||||
->select('count(r)')
|
||||
->from(JORejection::class, 'r')
|
||||
->where('r.job_order = :jo_id')
|
||||
->andWhere('r.hub = :hub_id')
|
||||
->andWhere('r.id != :rejection_id')
|
||||
->setParameter('jo_id', $jo_id)
|
||||
->setParameter('hub_id', $hub->getID())
|
||||
->setParameter('rejection_id', $rejection->getID())
|
||||
->getQuery()
|
||||
->getSingleScalarResult();
|
||||
|
||||
// if we already have a rejection record for this hub and JO, do not send another SMS
|
||||
if ($rejection_count >= 1) {
|
||||
error_log("ALREADY SENT REJECTION SMS TO HUB " . $hub->getID() . " FOR JO " . $jo_id);
|
||||
return;
|
||||
}
|
||||
|
||||
$message = 'Job Order #: ' . $jo_id . "\n" .
|
||||
'Order Date and Time: ' . $order_date->format('d M Y g:i A') . "\n" .
|
||||
'Date and Time Rejected: ' . $rejection->getDateCreate()->format('d M Y g:i A') . "\n" .
|
||||
|
|
|
|||
Loading…
Reference in a new issue