From 252effabef1bf0b0849e0d6aebdd5264b4176040 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 24 Apr 2023 09:31:28 +1000 Subject: [PATCH] Add manual payment notifications --- app/Listeners/Payment/PaymentNotification.php | 33 ++++++++++++++++++- lang/en/texts.php | 1 + 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/app/Listeners/Payment/PaymentNotification.php b/app/Listeners/Payment/PaymentNotification.php index b1b7c82eef12..8b1a64d2977e 100644 --- a/app/Listeners/Payment/PaymentNotification.php +++ b/app/Listeners/Payment/PaymentNotification.php @@ -56,8 +56,39 @@ class PaymentNotification implements ShouldQueue $this->trackRevenue($event); } - if($payment->is_manual) + /* Manual Payment Notifications */ + if($payment->is_manual){ + + foreach ($payment->company->company_users as $company_user) { + $user = $company_user->user; + + $methods = $this->findUserEntityNotificationType( + $payment, + $company_user, + [ + 'payment_manual', + 'payment_manual_all', + 'payment_manual_user', + 'all_notifications', ] + ); + + if (($key = array_search('mail', $methods)) !== false) { + unset($methods[$key]); + + $nmo = new NinjaMailerObject; + $nmo->mailable = new NinjaMailer((new EntityPaidObject($payment))->build()); + $nmo->company = $event->company; + $nmo->settings = $event->company->settings; + $nmo->to_user = $user; + + (new NinjaMailerJob($nmo))->handle(); + + $nmo = null; + } + } + return; + } /*User notifications*/ foreach ($payment->company->company_users as $company_user) { diff --git a/lang/en/texts.php b/lang/en/texts.php index f8519d1424f3..1b9cc11b114b 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -5062,6 +5062,7 @@ $LANG = array( 'here' => 'here', 'industry_Restaurant & Catering' => 'Restaurant & Catering', 'show_credits_table' => 'Show Credits Table', + 'manual_payment' => 'Payment Manual', );