revised approval system (all forms)
This commit is contained in:
@@ -8,7 +8,7 @@ use Illuminate\Support\Str;
|
||||
|
||||
class WhatsappHelper
|
||||
{
|
||||
public static function approveExpense($phones, $expense_number, $url = null)
|
||||
public static function approveExpense($phones, $expense_number, $url = null, $tanggal, $total, $name)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
@@ -17,15 +17,27 @@ class WhatsappHelper
|
||||
$url = 'https://' . $url;
|
||||
}
|
||||
|
||||
// Format the message like the email example using Markdown for WhatsApp
|
||||
$message = "
|
||||
Halo *{$name}*,
|
||||
Pengajuan Expense Anda telah di periksa & disetujui oleh *Admin Region Anda*:
|
||||
*Expense Number:* {$expense_number}
|
||||
*Expense Date:* " . \Carbon\Carbon::parse($tanggal)->locale('id')->isoFormat('D MMMM Y') . "
|
||||
*Total:* Rp " . number_format($total, 0, ',', '.') . "
|
||||
Silahkan buka link berikut untuk melihat detail expense Anda: {$url}
|
||||
Terima kasih.";
|
||||
|
||||
// Prepare the message for each phone number
|
||||
$data = [];
|
||||
foreach ($phones as $phone) {
|
||||
$data[] = [
|
||||
'phone' => $phone,
|
||||
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah disetujui. Silahkan buka link berikut untuk melihat detailnya: ' . $url,
|
||||
'message' => $message,
|
||||
'source' => 'web'
|
||||
];
|
||||
}
|
||||
|
||||
// Send the request to the WABLAS API
|
||||
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
||||
'headers' => [
|
||||
'Authorization' => env('WABLAS_TOKEN'),
|
||||
@@ -39,23 +51,36 @@ class WhatsappHelper
|
||||
return $response->getBody()->getContents();
|
||||
}
|
||||
|
||||
public static function rejectExpense($phones, $expense_number, $url = null)
|
||||
public static function approve2Expense($phones, $expense_number, $url = null, $tanggal, $total, $name)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
// Ensure the URL is formatted correctly
|
||||
if ($url && !preg_match('/^https?:\/\//', $url)) {
|
||||
$url = 'https://' . $url;
|
||||
}
|
||||
|
||||
// Format the message like the email example using Markdown for WhatsApp
|
||||
$message = "
|
||||
Halo *{$name}*,
|
||||
Pengajuan Expense Anda telah di periksa & disetujui oleh *Area Manager Anda*:
|
||||
*Expense Number:* {$expense_number}
|
||||
*Expense Date:* " . \Carbon\Carbon::parse($tanggal)->locale('id')->isoFormat('D MMMM Y') . "
|
||||
*Total:* Rp " . number_format($total, 0, ',', '.') . "
|
||||
Silahkan buka link berikut untuk melihat detail expense Anda: {$url}
|
||||
Terima kasih.";
|
||||
|
||||
// Prepare the message for each phone number
|
||||
$data = [];
|
||||
foreach ($phones as $phone) {
|
||||
$data[] = [
|
||||
'phone' => $phone,
|
||||
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah ditolak. Silahkan buka link berikut untuk melihat detailnya: ' . $url,
|
||||
'message' => $message,
|
||||
'source' => 'web'
|
||||
];
|
||||
}
|
||||
|
||||
// Send the request to the WABLAS API
|
||||
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
||||
'headers' => [
|
||||
'Authorization' => env('WABLAS_TOKEN'),
|
||||
@@ -69,23 +94,36 @@ class WhatsappHelper
|
||||
return $response->getBody()->getContents();
|
||||
}
|
||||
|
||||
public static function finalApprove($phones, $expense_number, $url = null)
|
||||
public static function rejectExpense($phones, $expense_number, $url = null, $tanggal, $total, $name)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
// Ensure the URL is formatted correctly
|
||||
if ($url && !preg_match('/^https?:\/\//', $url)) {
|
||||
$url = 'https://' . $url;
|
||||
}
|
||||
|
||||
// Format the message like the email example using Markdown for WhatsApp
|
||||
$message = "
|
||||
Halo *{$name}*,
|
||||
Pengajuan pengeluaran baru dengan detail berikut telah ditolak:
|
||||
*Expense Number:* {$expense_number}
|
||||
*Expense Date:* " . \Carbon\Carbon::parse($tanggal)->locale('id')->isoFormat('D MMMM Y') . "
|
||||
*Total:* Rp " . number_format($total, 0, ',', '.') . "
|
||||
Silahkan buka link berikut untuk melihat detail expense Anda: {$url}
|
||||
Terima kasih.";
|
||||
|
||||
// Prepare the message for each phone number
|
||||
$data = [];
|
||||
foreach ($phones as $phone) {
|
||||
$data[] = [
|
||||
'phone' => $phone,
|
||||
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah ditutup karena telah selesai diproses. Silahkan buka link berikut untuk melihat detailnya: ' . $url,
|
||||
'message' => $message,
|
||||
'source' => 'web'
|
||||
];
|
||||
}
|
||||
|
||||
// Send the request to the WABLAS API
|
||||
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
||||
'headers' => [
|
||||
'Authorization' => env('WABLAS_TOKEN'),
|
||||
@@ -99,23 +137,79 @@ class WhatsappHelper
|
||||
return $response->getBody()->getContents();
|
||||
}
|
||||
|
||||
public static function newExpense($phones, $expense_number, $url = null)
|
||||
public static function finalApprove($phones, $expense_number, $url = null, $tanggal, $total, $name)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
// Ensure the URL is formatted correctly
|
||||
if ($url && !preg_match('/^https?:\/\//', $url)) {
|
||||
$url = 'https://' . $url;
|
||||
}
|
||||
|
||||
// Format the message like the email example using Markdown for WhatsApp
|
||||
$message = "
|
||||
Halo *{$name}*,
|
||||
Pengajuan Expense Anda telah di setujui *( FINAL APPROVE )* oleh *MOM Region / HOSM* anda:
|
||||
*Expense Number:* {$expense_number}
|
||||
*Expense Date:* " . \Carbon\Carbon::parse($tanggal)->locale('id')->isoFormat('D MMMM Y') . "
|
||||
*Total:* Rp " . number_format($total, 0, ',', '.') . "
|
||||
Silahkan buka link berikut untuk melihat detail expense Anda: {$url}
|
||||
Terima kasih.";
|
||||
|
||||
// Prepare the message for each phone number
|
||||
$data = [];
|
||||
foreach ($phones as $phone) {
|
||||
$data[] = [
|
||||
'phone' => $phone,
|
||||
'message' => 'Pengajuan pengeluaran baru dengan nomor *' . $expense_number . '* telah dibuat. Silahkan buka link berikut untuk melihat detailnya: ' . $url,
|
||||
'message' => $message,
|
||||
'source' => 'web'
|
||||
];
|
||||
}
|
||||
|
||||
// Send the request to the WABLAS API
|
||||
$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 newExpense($phones, $expense_number, $url = null, $tanggal, $total, $name)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
// Ensure the URL is formatted correctly
|
||||
if ($url && !preg_match('/^https?:\/\//', $url)) {
|
||||
$url = 'https://' . $url;
|
||||
}
|
||||
|
||||
// Format the message like the email example using Markdown for WhatsApp
|
||||
$message = "
|
||||
Halo *{$name}*,
|
||||
Pengajuan pengeluaran baru dengan detail berikut telah dibuat:
|
||||
*Expense Number:* {$expense_number}
|
||||
*Expense Date:* " . \Carbon\Carbon::parse($tanggal)->locale('id')->isoFormat('D MMMM Y') . "
|
||||
*Total:* Rp " . number_format($total, 0, ',', '.') . "
|
||||
Silahkan buka link berikut untuk melihat detail expense Anda: {$url}
|
||||
Terima kasih.";
|
||||
|
||||
// Prepare the message for each phone number
|
||||
$data = [];
|
||||
foreach ($phones as $phone) {
|
||||
$data[] = [
|
||||
'phone' => $phone,
|
||||
'message' => $message,
|
||||
'source' => 'web'
|
||||
];
|
||||
}
|
||||
|
||||
// Send the request to the WABLAS API
|
||||
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
||||
'headers' => [
|
||||
'Authorization' => env('WABLAS_TOKEN'),
|
||||
|
||||
@@ -16,6 +16,7 @@ use App\Helpers\NextCloudHelper;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\ExpenseApproved;
|
||||
use App\Mail\ExpenseApproved2;
|
||||
use App\Mail\ExpenseRejected;
|
||||
use App\Mail\FinalApprove;
|
||||
use App\Mail\ExpenseCreated;
|
||||
@@ -127,7 +128,7 @@ class FormEntertainmentPresentationController extends Controller
|
||||
|
||||
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
|
||||
$region = Region::where('id', $cabang->region_id)->first();
|
||||
$kategori = Kategori::where('name', 'Entertainment & Presentation')->first();
|
||||
$kategori = Kategori::where('name', 'Entertainment')->first();
|
||||
|
||||
$filePaths = [];
|
||||
$folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/entertainment';
|
||||
@@ -189,7 +190,7 @@ class FormEntertainmentPresentationController extends Controller
|
||||
|
||||
// Generate URL and send WhatsApp notification
|
||||
$url = route('forms.entertainment.view', $form->id);
|
||||
WhatsappHelper::newExpense($phoneNumbers, $expense_number, $url);
|
||||
WhatsappHelper::newExpense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseCreated(
|
||||
@@ -246,7 +247,7 @@ class FormEntertainmentPresentationController extends Controller
|
||||
|
||||
$cabang = UserHasCabang::with('cabang')->where('user_id', $form->user_id)->first()->cabang;
|
||||
$region = Region::where('id', $cabang->region_id)->first();
|
||||
$kategori = Kategori::where('name', 'Entertainment & Presentation')->first();
|
||||
$kategori = Kategori::where('name', 'Entertainment')->first();
|
||||
|
||||
$filePaths = [];
|
||||
$folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/entertainment';
|
||||
@@ -282,33 +283,22 @@ class FormEntertainmentPresentationController extends Controller
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function approve(Request $request, $id)
|
||||
public function approve($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
||||
$request->validate([
|
||||
'total' => 'required',
|
||||
]);
|
||||
|
||||
$form = FormEntertaimentPresentation::findOrfail($id);
|
||||
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||
if($form->total > BudgetHelper::getAvailableBudget($cabang_id)) {
|
||||
session()->flash('error', 'The total nominal exceeds the available budget.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$form->update([
|
||||
'approved_at' => now(),
|
||||
'approved_by' => auth()->user()->id,
|
||||
'status' => 'Approved',
|
||||
|
||||
'approved_total' => $form->total,
|
||||
'status' => 'Approved 1',
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$total = $form->approved_total;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
@@ -324,15 +314,15 @@ class FormEntertainmentPresentationController extends Controller
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
}
|
||||
|
||||
// Remove duplicate email addresses, if any
|
||||
// Remove duplicate data, if any
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// Send bulk whatsapp
|
||||
$url = route('forms.entertainment.view', $form->id);
|
||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url);
|
||||
// send whatsapp message
|
||||
$url = route('forms.entertainment.view', $form->id);
|
||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// Send bulk email
|
||||
// // Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseApproved(
|
||||
$name,
|
||||
$expense_number,
|
||||
@@ -341,31 +331,92 @@ class FormEntertainmentPresentationController extends Controller
|
||||
$url
|
||||
));
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Approve', 'Approved Expense at Form Entertainment Presentation (' . $expense_number . ')');
|
||||
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Entertainment (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been approved.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function finalApprove($id)
|
||||
public function approve2($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['approval2.approve']);
|
||||
|
||||
$form = FormEntertaimentPresentation::findOrfail($id);
|
||||
$form->update([
|
||||
'approved2_at' => now(),
|
||||
'approved2_by' => auth()->user()->id,
|
||||
'status' => 'Approved 2',
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->created_at;
|
||||
$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 data, if any
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// send whatsapp message
|
||||
$url = route('forms.entertainment.view', $form->id);
|
||||
WhatsappHelper::approve2Expense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// // Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseApproved2(
|
||||
$name,
|
||||
$expense_number,
|
||||
$tanggal,
|
||||
$total,
|
||||
$url
|
||||
));
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Entertainment (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been approved.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function finalApprove(Request $request, $id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['final_approval.approve']);
|
||||
|
||||
$form = FormEntertaimentPresentation::findOrfail($id);
|
||||
if($form->approved_at == null) {
|
||||
session()->flash('error', 'Form must be approved by MIS first.');
|
||||
if($form->approved_at == null || $form->approved2_at == null) {
|
||||
session()->flash('error', 'Form must be approved by both approvers before final approval.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
// Check if the total nominal exceeds the available budget
|
||||
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||
if($form->total > BudgetHelper::getAvailableBudget($cabang_id)) {
|
||||
session()->flash('error', 'The total nominal exceeds the available budget.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$form->update([
|
||||
'final_approved_at' => now(),
|
||||
'final_approved_by' => auth()->user()->id,
|
||||
'status' => 'Closed'
|
||||
'status' => 'Closed',
|
||||
'approved_total' => $form->total,
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->approved_total;
|
||||
|
||||
// Collect all recipients
|
||||
@@ -388,7 +439,7 @@ class FormEntertainmentPresentationController extends Controller
|
||||
|
||||
// send whatsapp message
|
||||
$url = route('forms.entertainment.view', $form->id);
|
||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url);
|
||||
WhatsappHelper::finalApprove($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new FinalApprove(
|
||||
@@ -399,30 +450,14 @@ class FormEntertainmentPresentationController extends Controller
|
||||
$url
|
||||
));
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Final Approve', 'Final Approved Expense at Form Entertainment Presentation (' . $expense_number . ')');
|
||||
AuditTrailHelper::AddAuditTrail('Final Approve', 'Final Approve Expense at Form Entertainment (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been final approved.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function open($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['final_approval.open']);
|
||||
|
||||
$form = FormEntertaimentPresentation::findOrfail($id);
|
||||
$form->update([
|
||||
'final_approved_at' => null,
|
||||
'final_approved_by' => null,
|
||||
'status' => 'Approved'
|
||||
]);
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Open', 'Open Expense at Form Entertainment Presentation (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been opened.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function reject($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
||||
$this->checkAuthorization(auth()->user(), ['approval.reject']);
|
||||
|
||||
$form = FormEntertaimentPresentation::findOrfail($id);
|
||||
$form->update([
|
||||
@@ -432,7 +467,7 @@ class FormEntertainmentPresentationController extends Controller
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
@@ -453,9 +488,9 @@ class FormEntertainmentPresentationController extends Controller
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// Send bulk whatsapp
|
||||
// send whatsapp message
|
||||
$url = route('forms.entertainment.view', $form->id);
|
||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url);
|
||||
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseRejected(
|
||||
@@ -466,11 +501,27 @@ class FormEntertainmentPresentationController extends Controller
|
||||
$url
|
||||
));
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Reject', 'Reject Expense at Form Entertainment Presentation (' . $expense_number . ')');
|
||||
AuditTrailHelper::AddAuditTrail('Reject', 'Reject Expense at Form Entertainment (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been rejected.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function open($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['final_approval.open']);
|
||||
|
||||
$form = FormEntertaimentPresentation::findOrfail($id);
|
||||
$form->update([
|
||||
'final_approved_at' => null,
|
||||
'final_approved_by' => null,
|
||||
'status' => 'Approved'
|
||||
]);
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Open', 'Open Expense at Form Entertainment Presentation (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been opened.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.entertainment.delete']);
|
||||
|
||||
@@ -16,6 +16,7 @@ use App\Helpers\NextCloudHelper;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\ExpenseApproved;
|
||||
use App\Mail\ExpenseApproved2;
|
||||
use App\Mail\ExpenseRejected;
|
||||
use App\Mail\ExpenseCreated;
|
||||
use App\Mail\FinalApprove;
|
||||
@@ -82,7 +83,7 @@ class FormMeetingSeminarController extends Controller
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.country.view']);
|
||||
$this->checkAuthorization(auth()->user(), ['forms.meeting.view']);
|
||||
|
||||
$form = FormMeetingSeminar::with('user')->findOrFail($id);
|
||||
$form->bukti_allowance = $form->bukti_allowance ? NextCloudHelper::getFileUrl($form->bukti_allowance) : null;
|
||||
@@ -94,7 +95,7 @@ class FormMeetingSeminarController extends Controller
|
||||
|
||||
public function view($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.country.view']);
|
||||
$this->checkAuthorization(auth()->user(), ['forms.meeting.view']);
|
||||
|
||||
$form = FormMeetingSeminar::with('user')->findOrFail($id);
|
||||
$form->bukti_allowance = $form->bukti_allowance ? NextCloudHelper::getFileUrl($form->bukti_allowance) : null;
|
||||
@@ -128,7 +129,7 @@ class FormMeetingSeminarController extends Controller
|
||||
|
||||
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
|
||||
$region = Region::where('id', $cabang->region_id)->first();
|
||||
$kategori = Kategori::where('name', 'Meeting & Seminar')->first();
|
||||
$kategori = Kategori::where('name', 'Meeting / Seminar')->first();
|
||||
|
||||
$filePaths = [];
|
||||
$folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/meeting';
|
||||
@@ -227,7 +228,7 @@ class FormMeetingSeminarController extends Controller
|
||||
|
||||
// Generate URL and send WhatsApp notification
|
||||
$url = route('forms.meeting.view', $form->id);
|
||||
WhatsappHelper::newExpense($phoneNumbers, $expense_number, $url);
|
||||
WhatsappHelper::newExpense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseCreated(
|
||||
@@ -281,7 +282,7 @@ class FormMeetingSeminarController extends Controller
|
||||
|
||||
$cabang = UserHasCabang::with('cabang')->where('user_id', $form->user_id)->first()->cabang;
|
||||
$region = Region::where('id', $cabang->region_id)->first();
|
||||
$kategori = Kategori::where('name', 'Meeting & Seminar')->first();
|
||||
$kategori = Kategori::where('name', 'Meeting / Seminar')->first();
|
||||
|
||||
$filePaths = [];
|
||||
$folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/meeting';
|
||||
@@ -354,11 +355,122 @@ class FormMeetingSeminarController extends Controller
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function approve(Request $request, $id)
|
||||
public function approve($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
||||
|
||||
$form = FormMeetingSeminar::findOrfail($id);
|
||||
$form->update([
|
||||
'approved_at' => now(),
|
||||
'approved_by' => auth()->user()->id,
|
||||
'status' => 'Approved 1',
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->created_at;
|
||||
$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 data, if any
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// send whatsapp message
|
||||
$url = route('forms.meeting.view', $form->id);
|
||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// // Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseApproved(
|
||||
$name,
|
||||
$expense_number,
|
||||
$tanggal,
|
||||
$total,
|
||||
$url
|
||||
));
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Meeting Seminar (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been approved.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function approve2($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['approval2.approve']);
|
||||
|
||||
$form = FormMeetingSeminar::findOrfail($id);
|
||||
$form->update([
|
||||
'approved2_at' => now(),
|
||||
'approved2_by' => auth()->user()->id,
|
||||
'status' => 'Approved 2',
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->created_at;
|
||||
$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 data, if any
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// send whatsapp message
|
||||
$url = route('forms.meeting.view', $form->id);
|
||||
WhatsappHelper::approve2Expense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// // Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseApproved2(
|
||||
$name,
|
||||
$expense_number,
|
||||
$tanggal,
|
||||
$total,
|
||||
$url
|
||||
));
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Meeting Seminar (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been approved.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function finalApprove(Request $request, $id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['final_approval.approve']);
|
||||
|
||||
$form = FormMeetingSeminar::findOrfail($id);
|
||||
if($form->approved_at == null || $form->approved2_at == null) {
|
||||
session()->flash('error', 'Form must be approved by both approvers before final approval.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$approved_data = [
|
||||
'allowance' => $request->allowance ? $form->allowance : 0,
|
||||
'transport_ankot' => $request->transport_ankot ? $form->transport_ankot : 0,
|
||||
@@ -373,9 +485,9 @@ class FormMeetingSeminarController extends Controller
|
||||
}
|
||||
|
||||
$form->update([
|
||||
'approved_at' => now(),
|
||||
'approved_by' => auth()->user()->id,
|
||||
'status' => 'Approved',
|
||||
'final_approved_at' => now(),
|
||||
'final_approved_by' => auth()->user()->id,
|
||||
'status' => 'Closed',
|
||||
'approved_allowance' => $approved_data['allowance'],
|
||||
'approved_transport_ankot' => $approved_data['transport_ankot'],
|
||||
'approved_hotel' => $approved_data['hotel'],
|
||||
@@ -406,67 +518,9 @@ class FormMeetingSeminarController extends Controller
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// Send bulk WhatsApp message
|
||||
$url = route('forms.meeting.view', $form->id);
|
||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url);
|
||||
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseApproved(
|
||||
$name,
|
||||
$expense_number,
|
||||
$tanggal,
|
||||
$total,
|
||||
$url
|
||||
));
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Meeting Seminar (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been approved.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function finalApprove($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['final_approval.approve']);
|
||||
|
||||
$form = FormMeetingSeminar::findOrfail($id);
|
||||
if($form->approved_at == null) {
|
||||
session()->flash('error', 'Form must be approved by MIS first.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$form->update([
|
||||
'final_approved_at' => now(),
|
||||
'final_approved_by' => auth()->user()->id,
|
||||
'status' => 'Closed'
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->approved_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 whatsapp message
|
||||
$url = route('forms.meeting.view', $form->id);
|
||||
WhatsappHelper::finalApprove($phoneNumbers, $expense_number, $url);
|
||||
WhatsappHelper::finalApprove($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new FinalApprove(
|
||||
@@ -482,25 +536,9 @@ class FormMeetingSeminarController extends Controller
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function open($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['final_approval.open']);
|
||||
|
||||
$form = FormMeetingSeminar::findOrfail($id);
|
||||
$form->update([
|
||||
'final_approved_at' => null,
|
||||
'final_approved_by' => null,
|
||||
'status' => 'Approved'
|
||||
]);
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Open', 'Open Expense at Form Meeting Seminar (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been opened.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function reject($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
||||
$this->checkAuthorization(auth()->user(), ['approval.reject']);
|
||||
|
||||
$form = FormMeetingSeminar::findOrfail($id);
|
||||
$form->update([
|
||||
@@ -531,9 +569,9 @@ class FormMeetingSeminarController extends Controller
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// Send bulk WhatsApp message
|
||||
// send whatsapp message
|
||||
$url = route('forms.meeting.view', $form->id);
|
||||
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number, $url);
|
||||
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseRejected(
|
||||
@@ -549,6 +587,22 @@ class FormMeetingSeminarController extends Controller
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function open($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['final_approval.open']);
|
||||
|
||||
$form = FormMeetingSeminar::findOrfail($id);
|
||||
$form->update([
|
||||
'final_approved_at' => null,
|
||||
'final_approved_by' => null,
|
||||
'status' => 'Approved'
|
||||
]);
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Open', 'Open Expense at Form Meeting Seminar (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been opened.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.meeting.delete']);
|
||||
|
||||
@@ -16,6 +16,7 @@ use Illuminate\Support\Str;
|
||||
use App\Helpers\NextCloudHelper;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\ExpenseApproved;
|
||||
use App\Mail\ExpenseApproved2;
|
||||
use App\Mail\ExpenseRejected;
|
||||
use App\Mail\FinalApprove;
|
||||
use App\Mail\ExpenseCreated;
|
||||
@@ -187,7 +188,7 @@ class FormOtherController extends Controller
|
||||
|
||||
// Generate URL and send WhatsApp notification
|
||||
$url = route('forms.other.view', $form->id);
|
||||
WhatsappHelper::newExpense($phoneNumbers, $expense_number, $url);
|
||||
WhatsappHelper::newExpense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseCreated(
|
||||
@@ -275,34 +276,22 @@ class FormOtherController extends Controller
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function approve(Request $request, $id)
|
||||
public function approve($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
||||
|
||||
$request->validate([
|
||||
'total' => 'required',
|
||||
]);
|
||||
|
||||
$form = FormOthers::findOrfail($id);
|
||||
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||
if($form->total > BudgetHelper::getAvailableBudget($cabang_id)) {
|
||||
session()->flash('error', 'The total nominal exceeds the available budget.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$form->update([
|
||||
'approved_at' => now(),
|
||||
'approved_by' => auth()->user()->id,
|
||||
'status' => 'Approved',
|
||||
|
||||
'approved_total' => $form->total,
|
||||
'status' => 'Approved 1',
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$total = $form->approved_total;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
@@ -318,15 +307,15 @@ class FormOtherController extends Controller
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
}
|
||||
|
||||
// Remove duplicate email addresses, if any
|
||||
// Remove duplicate data, if any
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// Send bulk WhatsApp message
|
||||
// send whatsapp message
|
||||
$url = route('forms.other.view', $form->id);
|
||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url);
|
||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// Send bulk email
|
||||
// // Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseApproved(
|
||||
$name,
|
||||
$expense_number,
|
||||
@@ -340,26 +329,87 @@ class FormOtherController extends Controller
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function finalApprove($id)
|
||||
public function approve2($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['approval2.approve']);
|
||||
|
||||
$form = FormOthers::findOrfail($id);
|
||||
$form->update([
|
||||
'approved2_at' => now(),
|
||||
'approved2_by' => auth()->user()->id,
|
||||
'status' => 'Approved 2',
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->created_at;
|
||||
$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 data, if any
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// send whatsapp message
|
||||
$url = route('forms.other.view', $form->id);
|
||||
WhatsappHelper::approve2Expense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// // Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseApproved2(
|
||||
$name,
|
||||
$expense_number,
|
||||
$tanggal,
|
||||
$total,
|
||||
$url
|
||||
));
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Other (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been approved.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function finalApprove(Request $request, $id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['final_approval.approve']);
|
||||
|
||||
$form = FormOthers::findOrfail($id);
|
||||
if($form->approved_at == null) {
|
||||
session()->flash('error', 'Form must be approved by MIS first.');
|
||||
if($form->approved_at == null || $form->approved2_at == null) {
|
||||
session()->flash('error', 'Form must be approved by both approvers before final approval.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
// Check if the total nominal exceeds the available budget
|
||||
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||
if($form->total > BudgetHelper::getAvailableBudget($cabang_id)) {
|
||||
session()->flash('error', 'The total nominal exceeds the available budget.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$form->update([
|
||||
'final_approved_at' => now(),
|
||||
'final_approved_by' => auth()->user()->id,
|
||||
'status' => 'Closed'
|
||||
'status' => 'Closed',
|
||||
'approved_total' => $form->total,
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->approved_total;
|
||||
|
||||
// Collect all recipients
|
||||
@@ -382,7 +432,7 @@ class FormOtherController extends Controller
|
||||
|
||||
// send whatsapp message
|
||||
$url = route('forms.other.view', $form->id);
|
||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url);
|
||||
WhatsappHelper::finalApprove($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new FinalApprove(
|
||||
@@ -398,25 +448,9 @@ class FormOtherController extends Controller
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function open($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['final_approval.open']);
|
||||
|
||||
$form = FormOthers::findOrfail($id);
|
||||
$form->update([
|
||||
'final_approved_at' => null,
|
||||
'final_approved_by' => null,
|
||||
'status' => 'Approved'
|
||||
]);
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Open', 'Open Expense at Form Other (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been opened.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function reject($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
||||
$this->checkAuthorization(auth()->user(), ['approval.reject']);
|
||||
|
||||
$form = FormOthers::findOrfail($id);
|
||||
$form->update([
|
||||
@@ -426,7 +460,7 @@ class FormOtherController extends Controller
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
@@ -447,9 +481,9 @@ class FormOtherController extends Controller
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// Send bulk WhatsApp message
|
||||
// send whatsapp message
|
||||
$url = route('forms.other.view', $form->id);
|
||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url);
|
||||
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseRejected(
|
||||
@@ -465,6 +499,22 @@ class FormOtherController extends Controller
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function open($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['final_approval.open']);
|
||||
|
||||
$form = FormOthers::findOrfail($id);
|
||||
$form->update([
|
||||
'final_approved_at' => null,
|
||||
'final_approved_by' => null,
|
||||
'status' => 'Approved'
|
||||
]);
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Open', 'Open Expense at Form Other (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been opened.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.other.delete']);
|
||||
|
||||
@@ -15,6 +15,7 @@ use App\Models\Kategori;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\ExpenseApproved;
|
||||
use App\Mail\ExpenseApproved2;
|
||||
use App\Mail\ExpenseRejected;
|
||||
use App\Mail\FinalApprove;
|
||||
use App\Mail\ExpenseCreated;
|
||||
@@ -258,7 +259,7 @@ class FormUpCountryController extends Controller
|
||||
|
||||
// Generate URL and send WhatsApp notification
|
||||
$url = route('forms.up-country.view', $form->id);
|
||||
WhatsappHelper::newExpense($phoneNumbers, $expense_number, $url);
|
||||
WhatsappHelper::newExpense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseCreated(
|
||||
@@ -280,8 +281,8 @@ class FormUpCountryController extends Controller
|
||||
$role = auth()->user()->getRoleNames()[0];
|
||||
|
||||
$form = FormUpCountry::with('rayon')->findOrfail($id);
|
||||
if($form->status != 'On Progress' && $role == 'Medical Representatif') {
|
||||
session()->flash('error', 'You cannot edit this form because it has been approved or rejected.');
|
||||
if (($form->status != 'On Progress' && $form->status != 'Rejected') && $role == 'Medical Representatif') {
|
||||
session()->flash('error', 'You cannot edit this form because it has been approved or closed.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
@@ -312,8 +313,8 @@ class FormUpCountryController extends Controller
|
||||
]);
|
||||
|
||||
$form = FormUpCountry::findOrfail($id);
|
||||
if($form->status != 'On Progress' && $role == 'Medical Representatif') {
|
||||
session()->flash('error', 'You cannot edit this form because it has been approved or rejected.');
|
||||
if (($form->status != 'On Progress' && $form->status != 'Rejected') && $role == 'Medical Representatif') {
|
||||
session()->flash('error', 'You cannot edit this form because it has been approved or closed.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
@@ -411,11 +412,122 @@ class FormUpCountryController extends Controller
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function approve(Request $request, $id)
|
||||
public function approve($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
||||
|
||||
$form = FormUpCountry::findOrfail($id);
|
||||
$form->update([
|
||||
'approved_at' => now(),
|
||||
'approved_by' => auth()->user()->id,
|
||||
'status' => 'Approved 1',
|
||||
]);
|
||||
|
||||
$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 data, if any
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// send whatsapp message
|
||||
$url = route('forms.up-country.view', $form->id);
|
||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// // Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseApproved(
|
||||
$name,
|
||||
$expense_number,
|
||||
$tanggal,
|
||||
$total,
|
||||
$url
|
||||
));
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Up Country (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been approved.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function approve2($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['approval2.approve']);
|
||||
|
||||
$form = FormUpCountry::findOrfail($id);
|
||||
$form->update([
|
||||
'approved2_at' => now(),
|
||||
'approved2_by' => auth()->user()->id,
|
||||
'status' => 'Approved 2',
|
||||
]);
|
||||
|
||||
$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 data, if any
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// send whatsapp message
|
||||
$url = route('forms.up-country.view', $form->id);
|
||||
WhatsappHelper::approve2Expense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// // Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseApproved2(
|
||||
$name,
|
||||
$expense_number,
|
||||
$tanggal,
|
||||
$total,
|
||||
$url
|
||||
));
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Up Country (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been approved.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function finalApprove(Request $request, $id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['final_approval.approve']);
|
||||
|
||||
$form = FormUpCountry::findOrfail($id);
|
||||
if($form->approved_at == null || $form->approved2_at == null) {
|
||||
session()->flash('error', 'Form must be approved by both approvers before final approval.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$approved_data = [
|
||||
'allowance' => $request->allowance ? $form->allowance : 0,
|
||||
'transport_dalkot' => $request->transport_dalkot ? $form->transport_dalkot : 0,
|
||||
@@ -431,9 +543,9 @@ class FormUpCountryController extends Controller
|
||||
}
|
||||
|
||||
$form->update([
|
||||
'approved_at' => now(),
|
||||
'approved_by' => auth()->user()->id,
|
||||
'status' => 'Approved',
|
||||
'final_approved_at' => now(),
|
||||
'final_approved_by' => auth()->user()->id,
|
||||
'status' => 'Closed',
|
||||
'approved_allowance' => $approved_data['allowance'],
|
||||
'approved_transport_dalkot' => $approved_data['transport_dalkot'],
|
||||
'approved_transport_ankot' => $approved_data['transport_ankot'],
|
||||
@@ -461,16 +573,16 @@ class FormUpCountryController extends Controller
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
}
|
||||
|
||||
// Remove duplicate data, if any
|
||||
// Remove duplicate email addresses, if any
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// send whatsapp message
|
||||
$url = route('forms.up-country.view', $form->id);
|
||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url);
|
||||
WhatsappHelper::finalApprove($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// // Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseApproved(
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new FinalApprove(
|
||||
$name,
|
||||
$expense_number,
|
||||
$tanggal,
|
||||
@@ -478,14 +590,14 @@ class FormUpCountryController extends Controller
|
||||
$url
|
||||
));
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Up Country (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been approved.');
|
||||
AuditTrailHelper::AddAuditTrail('Final Approve', 'Final Approve Expense at Form Up Country (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been final approved.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function reject($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
||||
$this->checkAuthorization(auth()->user(), ['approval.reject']);
|
||||
|
||||
$form = FormUpCountry::findOrfail($id);
|
||||
$form->update([
|
||||
@@ -518,7 +630,7 @@ class FormUpCountryController extends Controller
|
||||
|
||||
// send whatsapp message
|
||||
$url = route('forms.up-country.view', $form->id);
|
||||
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number, $url);
|
||||
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseRejected(
|
||||
@@ -534,64 +646,6 @@ class FormUpCountryController extends Controller
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function finalApprove($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['final_approval.approve']);
|
||||
|
||||
$form = FormUpCountry::findOrfail($id);
|
||||
if($form->approved_at == null) {
|
||||
session()->flash('error', 'Form must be approved by MIS first.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$form->update([
|
||||
'final_approved_at' => now(),
|
||||
'final_approved_by' => auth()->user()->id,
|
||||
'status' => 'Closed'
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$total = $form->approved_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 whatsapp message
|
||||
$url = route('forms.up-country.view', $form->id);
|
||||
WhatsappHelper::finalApprove($phoneNumbers, $expense_number, $url);
|
||||
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new FinalApprove(
|
||||
$name,
|
||||
$expense_number,
|
||||
$tanggal,
|
||||
$total,
|
||||
$url
|
||||
));
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Final Approve', 'Final Approve Expense at Form Up Country (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been final approved.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function open($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['final_approval.open']);
|
||||
@@ -600,7 +654,7 @@ class FormUpCountryController extends Controller
|
||||
$form->update([
|
||||
'final_approved_at' => null,
|
||||
'final_approved_by' => null,
|
||||
'status' => 'Approved'
|
||||
'status' => 'Approved 2'
|
||||
]);
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Open', 'Open Expense at Form Up Country (' . $form->expense_number . ')');
|
||||
|
||||
@@ -16,6 +16,7 @@ use App\Helpers\NextCloudHelper;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\ExpenseApproved;
|
||||
use App\Mail\ExpenseApproved2;
|
||||
use App\Mail\ExpenseRejected;
|
||||
use App\Mail\FinalApprove;
|
||||
use App\Mail\ExpenseCreated;
|
||||
@@ -191,7 +192,7 @@ class FormVehicleController extends Controller
|
||||
|
||||
// Generate URL and send WhatsApp notification
|
||||
$url = route('forms.vehicle.view', $form->id);
|
||||
WhatsappHelper::newExpense($phoneNumbers, $expense_number, $url);
|
||||
WhatsappHelper::newExpense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseCreated(
|
||||
@@ -285,33 +286,22 @@ class FormVehicleController extends Controller
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function approve(Request $request, $id)
|
||||
public function approve($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
||||
$request->validate([
|
||||
'total' => 'required',
|
||||
]);
|
||||
|
||||
$form = FormVehicleRunningCost::findOrfail($id);
|
||||
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||
if($form->total > BudgetHelper::getAvailableBudget($cabang_id)) {
|
||||
session()->flash('error', 'The total nominal exceeds the available budget.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$form->update([
|
||||
'approved_at' => now(),
|
||||
'approved_by' => auth()->user()->id,
|
||||
'status' => 'Approved',
|
||||
|
||||
'approved_total' => $form->total,
|
||||
'status' => 'Approved 1',
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$total = $form->approved_total;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
$recipients = [$form->user->email, auth()->user()->email];
|
||||
@@ -327,15 +317,15 @@ class FormVehicleController extends Controller
|
||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
||||
}
|
||||
|
||||
// Remove duplicate email addresses, if any
|
||||
// Remove duplicate data, if any
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// Send bulk WhatsApp message
|
||||
// send whatsapp message
|
||||
$url = route('forms.vehicle.view', $form->id);
|
||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url);
|
||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// Send bulk email
|
||||
// // Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseApproved(
|
||||
$name,
|
||||
$expense_number,
|
||||
@@ -349,26 +339,87 @@ class FormVehicleController extends Controller
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function finalApprove($id)
|
||||
public function approve2($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['approval2.approve']);
|
||||
|
||||
$form = FormVehicleRunningCost::findOrfail($id);
|
||||
$form->update([
|
||||
'approved2_at' => now(),
|
||||
'approved2_by' => auth()->user()->id,
|
||||
'status' => 'Approved 2',
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->created_at;
|
||||
$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 data, if any
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// send whatsapp message
|
||||
$url = route('forms.vehicle.view', $form->id);
|
||||
WhatsappHelper::approve2Expense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// // Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseApproved2(
|
||||
$name,
|
||||
$expense_number,
|
||||
$tanggal,
|
||||
$total,
|
||||
$url
|
||||
));
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Vehicle Running Cost (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been approved.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function finalApprove(Request $request, $id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['final_approval.approve']);
|
||||
|
||||
$form = FormVehicleRunningCost::findOrfail($id);
|
||||
if($form->approved_at == null) {
|
||||
session()->flash('error', 'Form must be approved by MIS first.');
|
||||
if($form->approved_at == null || $form->approved2_at == null) {
|
||||
session()->flash('error', 'Form must be approved by both approvers before final approval.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
// Check if the total nominal exceeds the available budget
|
||||
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||
if($form->total > BudgetHelper::getAvailableBudget($cabang_id)) {
|
||||
session()->flash('error', 'The total nominal exceeds the available budget.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$form->update([
|
||||
'final_approved_at' => now(),
|
||||
'final_approved_by' => auth()->user()->id,
|
||||
'status' => 'Closed'
|
||||
'status' => 'Closed',
|
||||
'approved_total' => $form->total,
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->approved_total;
|
||||
|
||||
// Collect all recipients
|
||||
@@ -391,7 +442,7 @@ class FormVehicleController extends Controller
|
||||
|
||||
// send whatsapp message
|
||||
$url = route('forms.vehicle.view', $form->id);
|
||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url);
|
||||
WhatsappHelper::finalApprove($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new FinalApprove(
|
||||
@@ -407,25 +458,9 @@ class FormVehicleController extends Controller
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function open($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['final_approval.open']);
|
||||
|
||||
$form = FormVehicleRunningCost::findOrfail($id);
|
||||
$form->update([
|
||||
'final_approved_at' => null,
|
||||
'final_approved_by' => null,
|
||||
'status' => 'Approved'
|
||||
]);
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Open', 'Open Expense at Form Vehicle Running Cost (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been opened.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function reject($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
||||
$this->checkAuthorization(auth()->user(), ['approval.reject']);
|
||||
|
||||
$form = FormVehicleRunningCost::findOrfail($id);
|
||||
$form->update([
|
||||
@@ -435,7 +470,7 @@ class FormVehicleController extends Controller
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
$name = $form->user->name;
|
||||
$expense_number = $form->expense_number;
|
||||
$tanggal = $form->tanggal;
|
||||
$tanggal = $form->created_at;
|
||||
$total = $form->total;
|
||||
|
||||
// Collect all recipients
|
||||
@@ -456,9 +491,9 @@ class FormVehicleController extends Controller
|
||||
$recipients = array_unique($recipients);
|
||||
$phoneNumbers = array_unique($phoneNumbers);
|
||||
|
||||
// Send bulk WhatsApp message
|
||||
// send whatsapp message
|
||||
$url = route('forms.vehicle.view', $form->id);
|
||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url);
|
||||
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||
|
||||
// Send bulk email
|
||||
Mail::to($recipients)->send(new ExpenseRejected(
|
||||
@@ -468,12 +503,28 @@ class FormVehicleController extends Controller
|
||||
$total,
|
||||
$url
|
||||
));
|
||||
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Reject', 'Reject Expense at Form Vehicle Running Cost (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been rejected.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function open($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['final_approval.open']);
|
||||
|
||||
$form = FormVehicleRunningCost::findOrfail($id);
|
||||
$form->update([
|
||||
'final_approved_at' => null,
|
||||
'final_approved_by' => null,
|
||||
'status' => 'Approved'
|
||||
]);
|
||||
|
||||
AuditTrailHelper::AddAuditTrail('Open', 'Open Expense at Form Vehicle Running Cost (' . $form->expense_number . ')');
|
||||
session()->flash('success', 'Form has been opened.');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.vehicle.delete']);
|
||||
|
||||
@@ -30,7 +30,7 @@ class ExpenseApproved extends Mailable
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Expense Approved',
|
||||
subject: 'Expense First Approval',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?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 ExpenseApproved2 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,
|
||||
protected string $url,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Expense Second Approval',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mail.approved2',
|
||||
with: [
|
||||
'name' => $this->name,
|
||||
'expense_number' => $this->expense_number,
|
||||
'tanggal' => $this->tanggal,
|
||||
'total' => $this->total,
|
||||
'url' => $this->url,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ class FinalApprove extends Mailable
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Expense Closed',
|
||||
subject: 'Expense Final Approval',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@ class FormEntertaimentPresentation extends Model
|
||||
'account_number',
|
||||
'status',
|
||||
'approved_at',
|
||||
'approved2_at',
|
||||
'approved_by',
|
||||
'approved2_by',
|
||||
'final_approved_at',
|
||||
'final_approved_by',
|
||||
];
|
||||
|
||||
@@ -27,7 +27,9 @@ class FormMeetingSeminar extends Model
|
||||
'account_number',
|
||||
'status',
|
||||
'approved_at',
|
||||
'approved2_at',
|
||||
'approved_by',
|
||||
'approved2_by',
|
||||
'final_approved_at',
|
||||
'final_approved_by',
|
||||
];
|
||||
|
||||
@@ -22,7 +22,9 @@ class FormOthers extends Model
|
||||
'account_number',
|
||||
'status',
|
||||
'approved_at',
|
||||
'approved2_at',
|
||||
'approved_by',
|
||||
'approved2_by',
|
||||
'final_approved_at',
|
||||
'final_approved_by',
|
||||
];
|
||||
|
||||
@@ -34,7 +34,9 @@ class FormUpCountry extends Model
|
||||
'account_number',
|
||||
'status',
|
||||
'approved_at',
|
||||
'approved2_at',
|
||||
'approved_by',
|
||||
'approved2_by',
|
||||
'final_approved_at',
|
||||
'final_approved_by',
|
||||
];
|
||||
|
||||
@@ -25,7 +25,9 @@ class FormVehicleRunningCost extends Model
|
||||
'account_number',
|
||||
'status',
|
||||
'approved_at',
|
||||
'approved2_at',
|
||||
'approved_by',
|
||||
'approved2_by',
|
||||
'final_approved_at',
|
||||
'final_approved_by',
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user