added whastapp notification

This commit is contained in:
Jagad R R
2024-12-25 13:37:49 +07:00
parent 0030c0f48e
commit 8c451d0d7a
7 changed files with 142 additions and 3 deletions
@@ -17,7 +17,7 @@ use App\Helpers\NextCloudHelper;
use Illuminate\Support\Facades\Mail;
use App\Mail\ExpenseApproved;
use App\Mail\ExpenseRejected;
use App\Helpers\WhatsappHelper;
class FormOtherController extends Controller
{
@@ -248,17 +248,21 @@ class FormOtherController extends Controller
// Collect all recipients
$recipients = [$form->user->email];
$phoneNumbers = [$form->user->phone];
if ($heads['cabang_head']) {
$recipients[] = $heads['cabang_head']['email'];
$phoneNumbers[] = $heads['cabang_head']['phone'];
}
if ($heads['region_head']) {
$recipients[] = $heads['region_head']['email'];
$phoneNumbers[] = $heads['region_head']['phone'];
}
// Remove duplicate email addresses, if any
$recipients = array_unique($recipients);
$phoneNumbers = array_unique($phoneNumbers);
// Send bulk email
Mail::to($recipients)->send(new ExpenseApproved(
@@ -268,6 +272,9 @@ class FormOtherController extends Controller
$total
));
// Send bulk WhatsApp message
WhatsappHelper::approveExpense($phoneNumbers, $expense_number);
session()->flash('success', 'Form has been approved.');
return redirect()->back();
}
@@ -324,17 +331,21 @@ class FormOtherController extends Controller
// Collect all recipients
$recipients = [$form->user->email];
$phoneNumbers = [$form->user->phone];
if ($heads['cabang_head']) {
$recipients[] = $heads['cabang_head']['email'];
$phoneNumbers[] = $heads['cabang_head']['phone'];
}
if ($heads['region_head']) {
$recipients[] = $heads['region_head']['email'];
$phoneNumbers[] = $heads['region_head']['phone'];
}
// Remove duplicate email addresses, if any
$recipients = array_unique($recipients);
$phoneNumbers = array_unique($phoneNumbers);
// Send bulk email
Mail::to($recipients)->send(new ExpenseRejected(
@@ -344,6 +355,9 @@ class FormOtherController extends Controller
$total
));
// Send bulk WhatsApp message
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number);
session()->flash('success', 'Form has been rejected.');
return redirect()->back();
}