added whastapp notification
This commit is contained in:
@@ -72,3 +72,6 @@ NEXT_CLOUD_URL=https://mkt.tunggal-pharma.com
|
|||||||
NEXT_CLOUD_USERNAME=user_dev
|
NEXT_CLOUD_USERNAME=user_dev
|
||||||
NEXT_CLOUD_PASSWORD=userdev12345
|
NEXT_CLOUD_PASSWORD=userdev12345
|
||||||
NEXT_CLOUD_PATHPREFIX=""
|
NEXT_CLOUD_PATHPREFIX=""
|
||||||
|
|
||||||
|
WABLAS_HOST=https://bdg.wablas.com
|
||||||
|
WABLAS_TOKEN=5iCaiP0nEgfl3lzrdsZGb9TvNYuwFZF8s4rp8AYwCx5OrYeiKXgixFMo9nDWNrJN
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Helpers;
|
||||||
|
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use GuzzleHttp\Exception\RequestException;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class WhatsappHelper
|
||||||
|
{
|
||||||
|
public static function approveExpense($phones, $expense_number)
|
||||||
|
{
|
||||||
|
$client = new Client();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
foreach ($phones as $phone) {
|
||||||
|
$data[] = [
|
||||||
|
'phone' => $phone,
|
||||||
|
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah disetujui. Silahkan buka website untuk melihat detailnya.',
|
||||||
|
'source' => 'web'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
||||||
|
'headers' => [
|
||||||
|
'Authorization' => env('WABLAS_TOKEN'),
|
||||||
|
'Content-Type' => 'application/json'
|
||||||
|
],
|
||||||
|
'json' => [
|
||||||
|
'data' => $data
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $response->getBody()->getContents();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function rejectExpense($phones, $expense_number)
|
||||||
|
{
|
||||||
|
$client = new Client();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
foreach ($phones as $phone) {
|
||||||
|
$data[] = [
|
||||||
|
'phone' => $phone,
|
||||||
|
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah ditolak. Silahkan buka website untuk melihat detailnya.',
|
||||||
|
'source' => 'web'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
||||||
|
'headers' => [
|
||||||
|
'Authorization' => env('WABLAS_TOKEN'),
|
||||||
|
'Content-Type' => 'application/json'
|
||||||
|
],
|
||||||
|
'json' => [
|
||||||
|
'data' => $data
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $response->getBody()->getContents();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@ use Illuminate\Support\Str;
|
|||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
use App\Mail\ExpenseApproved;
|
use App\Mail\ExpenseApproved;
|
||||||
use App\Mail\ExpenseRejected;
|
use App\Mail\ExpenseRejected;
|
||||||
|
use App\Helpers\WhatsappHelper;
|
||||||
|
|
||||||
class FormEntertainmentPresentationController extends Controller
|
class FormEntertainmentPresentationController extends Controller
|
||||||
{
|
{
|
||||||
@@ -256,17 +257,21 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
|
|
||||||
// Collect all recipients
|
// Collect all recipients
|
||||||
$recipients = [$form->user->email];
|
$recipients = [$form->user->email];
|
||||||
|
$phoneNumbers = [$form->user->phone];
|
||||||
|
|
||||||
if ($heads['cabang_head']) {
|
if ($heads['cabang_head']) {
|
||||||
$recipients[] = $heads['cabang_head']['email'];
|
$recipients[] = $heads['cabang_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($heads['region_head']) {
|
if ($heads['region_head']) {
|
||||||
$recipients[] = $heads['region_head']['email'];
|
$recipients[] = $heads['region_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicate email addresses, if any
|
// Remove duplicate email addresses, if any
|
||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
|
||||||
// Send bulk email
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new ExpenseApproved(
|
Mail::to($recipients)->send(new ExpenseApproved(
|
||||||
@@ -276,6 +281,9 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
$total
|
$total
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Send bulk whatsapp
|
||||||
|
WhatsappHelper::approveExpense($phoneNumbers, $expense_number);
|
||||||
|
|
||||||
session()->flash('success', 'Form has been approved.');
|
session()->flash('success', 'Form has been approved.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
@@ -332,17 +340,21 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
|
|
||||||
// Collect all recipients
|
// Collect all recipients
|
||||||
$recipients = [$form->user->email];
|
$recipients = [$form->user->email];
|
||||||
|
$phoneNumbers = [$form->user->phone];
|
||||||
|
|
||||||
if ($heads['cabang_head']) {
|
if ($heads['cabang_head']) {
|
||||||
$recipients[] = $heads['cabang_head']['email'];
|
$recipients[] = $heads['cabang_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($heads['region_head']) {
|
if ($heads['region_head']) {
|
||||||
$recipients[] = $heads['region_head']['email'];
|
$recipients[] = $heads['region_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicate email addresses, if any
|
// Remove duplicate email addresses, if any
|
||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
|
||||||
// Send bulk email
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new ExpenseRejected(
|
Mail::to($recipients)->send(new ExpenseRejected(
|
||||||
@@ -352,6 +364,9 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
$total
|
$total
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Send bulk whatsapp
|
||||||
|
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number);
|
||||||
|
|
||||||
session()->flash('success', 'Form has been rejected.');
|
session()->flash('success', 'Form has been rejected.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use Illuminate\Support\Str;
|
|||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
use App\Mail\ExpenseApproved;
|
use App\Mail\ExpenseApproved;
|
||||||
use App\Mail\ExpenseRejected;
|
use App\Mail\ExpenseRejected;
|
||||||
|
use App\Helpers\WhatsappHelper;
|
||||||
|
|
||||||
class FormMeetingSeminarController extends Controller
|
class FormMeetingSeminarController extends Controller
|
||||||
{
|
{
|
||||||
@@ -242,17 +243,21 @@ class FormMeetingSeminarController extends Controller
|
|||||||
|
|
||||||
// Collect all recipients
|
// Collect all recipients
|
||||||
$recipients = [$form->user->email];
|
$recipients = [$form->user->email];
|
||||||
|
$phoneNumbers = [$form->user->phone];
|
||||||
|
|
||||||
if ($heads['cabang_head']) {
|
if ($heads['cabang_head']) {
|
||||||
$recipients[] = $heads['cabang_head']['email'];
|
$recipients[] = $heads['cabang_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($heads['region_head']) {
|
if ($heads['region_head']) {
|
||||||
$recipients[] = $heads['region_head']['email'];
|
$recipients[] = $heads['region_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicate email addresses, if any
|
// Remove duplicate email addresses, if any
|
||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
|
||||||
// Send bulk email
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new ExpenseApproved(
|
Mail::to($recipients)->send(new ExpenseApproved(
|
||||||
@@ -262,6 +267,9 @@ class FormMeetingSeminarController extends Controller
|
|||||||
$total
|
$total
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Send bulk WhatsApp message
|
||||||
|
WhatsappHelper::approveExpense($phoneNumbers, $expense_number);
|
||||||
|
|
||||||
session()->flash('success', 'Form has been approved.');
|
session()->flash('success', 'Form has been approved.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
@@ -318,17 +326,21 @@ class FormMeetingSeminarController extends Controller
|
|||||||
|
|
||||||
// Collect all recipients
|
// Collect all recipients
|
||||||
$recipients = [$form->user->email];
|
$recipients = [$form->user->email];
|
||||||
|
$phoneNumbers = [$form->user->phone];
|
||||||
|
|
||||||
if ($heads['cabang_head']) {
|
if ($heads['cabang_head']) {
|
||||||
$recipients[] = $heads['cabang_head']['email'];
|
$recipients[] = $heads['cabang_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($heads['region_head']) {
|
if ($heads['region_head']) {
|
||||||
$recipients[] = $heads['region_head']['email'];
|
$recipients[] = $heads['region_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicate email addresses, if any
|
// Remove duplicate email addresses, if any
|
||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
|
||||||
// Send bulk email
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new ExpenseRejected(
|
Mail::to($recipients)->send(new ExpenseRejected(
|
||||||
@@ -338,6 +350,9 @@ class FormMeetingSeminarController extends Controller
|
|||||||
$total
|
$total
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Send bulk WhatsApp message
|
||||||
|
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number);
|
||||||
|
|
||||||
session()->flash('success', 'Form has been rejected.');
|
session()->flash('success', 'Form has been rejected.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ use App\Helpers\NextCloudHelper;
|
|||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
use App\Mail\ExpenseApproved;
|
use App\Mail\ExpenseApproved;
|
||||||
use App\Mail\ExpenseRejected;
|
use App\Mail\ExpenseRejected;
|
||||||
|
use App\Helpers\WhatsappHelper;
|
||||||
|
|
||||||
class FormOtherController extends Controller
|
class FormOtherController extends Controller
|
||||||
{
|
{
|
||||||
@@ -248,17 +248,21 @@ class FormOtherController extends Controller
|
|||||||
|
|
||||||
// Collect all recipients
|
// Collect all recipients
|
||||||
$recipients = [$form->user->email];
|
$recipients = [$form->user->email];
|
||||||
|
$phoneNumbers = [$form->user->phone];
|
||||||
|
|
||||||
if ($heads['cabang_head']) {
|
if ($heads['cabang_head']) {
|
||||||
$recipients[] = $heads['cabang_head']['email'];
|
$recipients[] = $heads['cabang_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($heads['region_head']) {
|
if ($heads['region_head']) {
|
||||||
$recipients[] = $heads['region_head']['email'];
|
$recipients[] = $heads['region_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicate email addresses, if any
|
// Remove duplicate email addresses, if any
|
||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
|
||||||
// Send bulk email
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new ExpenseApproved(
|
Mail::to($recipients)->send(new ExpenseApproved(
|
||||||
@@ -268,6 +272,9 @@ class FormOtherController extends Controller
|
|||||||
$total
|
$total
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Send bulk WhatsApp message
|
||||||
|
WhatsappHelper::approveExpense($phoneNumbers, $expense_number);
|
||||||
|
|
||||||
session()->flash('success', 'Form has been approved.');
|
session()->flash('success', 'Form has been approved.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
@@ -324,17 +331,21 @@ class FormOtherController extends Controller
|
|||||||
|
|
||||||
// Collect all recipients
|
// Collect all recipients
|
||||||
$recipients = [$form->user->email];
|
$recipients = [$form->user->email];
|
||||||
|
$phoneNumbers = [$form->user->phone];
|
||||||
|
|
||||||
if ($heads['cabang_head']) {
|
if ($heads['cabang_head']) {
|
||||||
$recipients[] = $heads['cabang_head']['email'];
|
$recipients[] = $heads['cabang_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($heads['region_head']) {
|
if ($heads['region_head']) {
|
||||||
$recipients[] = $heads['region_head']['email'];
|
$recipients[] = $heads['region_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicate email addresses, if any
|
// Remove duplicate email addresses, if any
|
||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
|
||||||
// Send bulk email
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new ExpenseRejected(
|
Mail::to($recipients)->send(new ExpenseRejected(
|
||||||
@@ -344,6 +355,9 @@ class FormOtherController extends Controller
|
|||||||
$total
|
$total
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Send bulk WhatsApp message
|
||||||
|
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number);
|
||||||
|
|
||||||
session()->flash('success', 'Form has been rejected.');
|
session()->flash('success', 'Form has been rejected.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use Illuminate\Support\Str;
|
|||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
use App\Mail\ExpenseApproved;
|
use App\Mail\ExpenseApproved;
|
||||||
use App\Mail\ExpenseRejected;
|
use App\Mail\ExpenseRejected;
|
||||||
|
use App\Helpers\WhatsappHelper;
|
||||||
|
|
||||||
class FormUpCountryController extends Controller
|
class FormUpCountryController extends Controller
|
||||||
{
|
{
|
||||||
@@ -264,19 +265,23 @@ class FormUpCountryController extends Controller
|
|||||||
|
|
||||||
// Collect all recipients
|
// Collect all recipients
|
||||||
$recipients = [$form->user->email];
|
$recipients = [$form->user->email];
|
||||||
|
$phoneNumbers = [$form->user->phone];
|
||||||
|
|
||||||
if ($heads['cabang_head']) {
|
if ($heads['cabang_head']) {
|
||||||
$recipients[] = $heads['cabang_head']['email'];
|
$recipients[] = $heads['cabang_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($heads['region_head']) {
|
if ($heads['region_head']) {
|
||||||
$recipients[] = $heads['region_head']['email'];
|
$recipients[] = $heads['region_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicate email addresses, if any
|
// Remove duplicate data, if any
|
||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
|
||||||
// Send bulk email
|
// // Send bulk email
|
||||||
Mail::to($recipients)->send(new ExpenseApproved(
|
Mail::to($recipients)->send(new ExpenseApproved(
|
||||||
$name,
|
$name,
|
||||||
$expense_number,
|
$expense_number,
|
||||||
@@ -284,6 +289,9 @@ class FormUpCountryController extends Controller
|
|||||||
$total
|
$total
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// send whatsapp message
|
||||||
|
WhatsappHelper::approveExpense($phoneNumbers, $expense_number);
|
||||||
|
|
||||||
session()->flash('success', 'Form has been approved.');
|
session()->flash('success', 'Form has been approved.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
@@ -305,17 +313,21 @@ class FormUpCountryController extends Controller
|
|||||||
|
|
||||||
// Collect all recipients
|
// Collect all recipients
|
||||||
$recipients = [$form->user->email];
|
$recipients = [$form->user->email];
|
||||||
|
$phoneNumbers = [$form->user->phone];
|
||||||
|
|
||||||
if ($heads['cabang_head']) {
|
if ($heads['cabang_head']) {
|
||||||
$recipients[] = $heads['cabang_head']['email'];
|
$recipients[] = $heads['cabang_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($heads['region_head']) {
|
if ($heads['region_head']) {
|
||||||
$recipients[] = $heads['region_head']['email'];
|
$recipients[] = $heads['region_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicate email addresses, if any
|
// Remove duplicate email addresses, if any
|
||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
|
||||||
// Send bulk email
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new ExpenseRejected(
|
Mail::to($recipients)->send(new ExpenseRejected(
|
||||||
@@ -325,6 +337,9 @@ class FormUpCountryController extends Controller
|
|||||||
$total
|
$total
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// send whatsapp message
|
||||||
|
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number);
|
||||||
|
|
||||||
session()->flash('success', 'Form has been rejected.');
|
session()->flash('success', 'Form has been rejected.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use Illuminate\Support\Str;
|
|||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
use App\Mail\ExpenseApproved;
|
use App\Mail\ExpenseApproved;
|
||||||
use App\Mail\ExpenseRejected;
|
use App\Mail\ExpenseRejected;
|
||||||
|
use App\Helpers\WhatsappHelper;
|
||||||
|
|
||||||
class FormVehicleController extends Controller
|
class FormVehicleController extends Controller
|
||||||
{
|
{
|
||||||
@@ -257,17 +258,21 @@ class FormVehicleController extends Controller
|
|||||||
|
|
||||||
// Collect all recipients
|
// Collect all recipients
|
||||||
$recipients = [$form->user->email];
|
$recipients = [$form->user->email];
|
||||||
|
$phoneNumbers = [$form->user->phone];
|
||||||
|
|
||||||
if ($heads['cabang_head']) {
|
if ($heads['cabang_head']) {
|
||||||
$recipients[] = $heads['cabang_head']['email'];
|
$recipients[] = $heads['cabang_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($heads['region_head']) {
|
if ($heads['region_head']) {
|
||||||
$recipients[] = $heads['region_head']['email'];
|
$recipients[] = $heads['region_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicate email addresses, if any
|
// Remove duplicate email addresses, if any
|
||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
|
||||||
// Send bulk email
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new ExpenseApproved(
|
Mail::to($recipients)->send(new ExpenseApproved(
|
||||||
@@ -277,6 +282,9 @@ class FormVehicleController extends Controller
|
|||||||
$total
|
$total
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Send bulk WhatsApp message
|
||||||
|
WhatsappHelper::approveExpense($phoneNumbers, $expense_number);
|
||||||
|
|
||||||
session()->flash('success', 'Form has been approved.');
|
session()->flash('success', 'Form has been approved.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
@@ -333,17 +341,21 @@ class FormVehicleController extends Controller
|
|||||||
|
|
||||||
// Collect all recipients
|
// Collect all recipients
|
||||||
$recipients = [$form->user->email];
|
$recipients = [$form->user->email];
|
||||||
|
$phoneNumbers = [$form->user->phone];
|
||||||
|
|
||||||
if ($heads['cabang_head']) {
|
if ($heads['cabang_head']) {
|
||||||
$recipients[] = $heads['cabang_head']['email'];
|
$recipients[] = $heads['cabang_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($heads['region_head']) {
|
if ($heads['region_head']) {
|
||||||
$recipients[] = $heads['region_head']['email'];
|
$recipients[] = $heads['region_head']['email'];
|
||||||
|
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicate email addresses, if any
|
// Remove duplicate email addresses, if any
|
||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
|
||||||
// Send bulk email
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new ExpenseRejected(
|
Mail::to($recipients)->send(new ExpenseRejected(
|
||||||
@@ -353,6 +365,9 @@ class FormVehicleController extends Controller
|
|||||||
$total
|
$total
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Send bulk WhatsApp message
|
||||||
|
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number);
|
||||||
|
|
||||||
session()->flash('success', 'Form has been rejected.');
|
session()->flash('success', 'Form has been rejected.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user