added final approval (close) expense notification
This commit is contained in:
@@ -59,4 +59,30 @@ class WhatsappHelper
|
||||
|
||||
return $response->getBody()->getContents();
|
||||
}
|
||||
|
||||
public static function finalApprove($phones, $expense_number)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
$data = [];
|
||||
foreach ($phones as $phone) {
|
||||
$data[] = [
|
||||
'phone' => $phone,
|
||||
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah ditutup karena telah selesai diproses. 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 App\Mail\ExpenseApproved;
|
||||
use App\Mail\ExpenseRejected;
|
||||
use App\Mail\FinalApprove;
|
||||
use App\Helpers\WhatsappHelper;
|
||||
|
||||
class FormEntertainmentPresentationController extends Controller
|
||||
@@ -305,6 +306,41 @@ class FormEntertainmentPresentationController extends Controller
|
||||
'status' => 'Closed'
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->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 FinalApprove(
|
||||
$name,
|
||||
$expense_number,
|
||||
$tanggal,
|
||||
$total
|
||||
));
|
||||
|
||||
// send whatsapp message
|
||||
WhatsappHelper::finalApprove($phoneNumbers, $expense_number);
|
||||
|
||||
session()->flash('success', 'Form has been final approved.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\ExpenseApproved;
|
||||
use App\Mail\ExpenseRejected;
|
||||
use App\Mail\FinalApprove;
|
||||
use App\Helpers\WhatsappHelper;
|
||||
|
||||
class FormMeetingSeminarController extends Controller
|
||||
@@ -291,6 +292,41 @@ class FormMeetingSeminarController extends Controller
|
||||
'status' => 'Closed'
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->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 FinalApprove(
|
||||
$name,
|
||||
$expense_number,
|
||||
$tanggal,
|
||||
$total
|
||||
));
|
||||
|
||||
// send whatsapp message
|
||||
WhatsappHelper::finalApprove($phoneNumbers, $expense_number);
|
||||
|
||||
session()->flash('success', 'Form has been final approved.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ use App\Helpers\NextCloudHelper;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\ExpenseApproved;
|
||||
use App\Mail\ExpenseRejected;
|
||||
use App\Mail\FinalApprove;
|
||||
use App\Helpers\WhatsappHelper;
|
||||
|
||||
class FormOtherController extends Controller
|
||||
@@ -296,6 +297,41 @@ class FormOtherController extends Controller
|
||||
'status' => 'Closed'
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->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 FinalApprove(
|
||||
$name,
|
||||
$expense_number,
|
||||
$tanggal,
|
||||
$total
|
||||
));
|
||||
|
||||
// send whatsapp message
|
||||
WhatsappHelper::finalApprove($phoneNumbers, $expense_number);
|
||||
|
||||
session()->flash('success', 'Form has been final approved.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\ExpenseApproved;
|
||||
use App\Mail\ExpenseRejected;
|
||||
use App\Mail\FinalApprove;
|
||||
use App\Helpers\WhatsappHelper;
|
||||
|
||||
class FormUpCountryController extends Controller
|
||||
@@ -361,6 +362,41 @@ class FormUpCountryController extends Controller
|
||||
'status' => 'Closed'
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->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 FinalApprove(
|
||||
$name,
|
||||
$expense_number,
|
||||
$tanggal,
|
||||
$total
|
||||
));
|
||||
|
||||
// send whatsapp message
|
||||
WhatsappHelper::finalApprove($phoneNumbers, $expense_number);
|
||||
|
||||
session()->flash('success', 'Form has been final approved.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\ExpenseApproved;
|
||||
use App\Mail\ExpenseRejected;
|
||||
use App\Mail\FinalApprove;
|
||||
use App\Helpers\WhatsappHelper;
|
||||
|
||||
class FormVehicleController extends Controller
|
||||
@@ -306,6 +307,41 @@ class FormVehicleController extends Controller
|
||||
'status' => 'Closed'
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
$phoneNumbers = [$form->user->phone, auth()->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 FinalApprove(
|
||||
$name,
|
||||
$expense_number,
|
||||
$tanggal,
|
||||
$total
|
||||
));
|
||||
|
||||
// send whatsapp message
|
||||
WhatsappHelper::finalApprove($phoneNumbers, $expense_number);
|
||||
|
||||
session()->flash('success', 'Form has been final approved.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class FinalApprove extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct(
|
||||
protected string $name,
|
||||
protected string $expense_number,
|
||||
protected string $tanggal,
|
||||
protected int $total,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Expense Closed',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mail.closed',
|
||||
with: [
|
||||
'name' => $this->name,
|
||||
'expense_number' => $this->expense_number,
|
||||
'tanggal' => $this->tanggal,
|
||||
'total' => $this->total,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user