added whastapp notification
This commit is contained in:
@@ -17,6 +17,7 @@ use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\ExpenseApproved;
|
||||
use App\Mail\ExpenseRejected;
|
||||
use App\Helpers\WhatsappHelper;
|
||||
|
||||
class FormEntertainmentPresentationController extends Controller
|
||||
{
|
||||
@@ -256,17 +257,21 @@ class FormEntertainmentPresentationController 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(
|
||||
@@ -276,6 +281,9 @@ class FormEntertainmentPresentationController extends Controller
|
||||
$total
|
||||
));
|
||||
|
||||
// Send bulk whatsapp
|
||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number);
|
||||
|
||||
session()->flash('success', 'Form has been approved.');
|
||||
return redirect()->back();
|
||||
}
|
||||
@@ -332,17 +340,21 @@ class FormEntertainmentPresentationController 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(
|
||||
@@ -352,6 +364,9 @@ class FormEntertainmentPresentationController extends Controller
|
||||
$total
|
||||
));
|
||||
|
||||
// Send bulk whatsapp
|
||||
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number);
|
||||
|
||||
session()->flash('success', 'Form has been rejected.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user