Merge branch 'branch-jagad' into 'main'
Branch jagad See merge request fiqhpratama1/xpendify!32
This commit is contained in:
@@ -74,6 +74,7 @@ NEXT_CLOUD_PASSWORD=userdev12345
|
|||||||
NEXT_CLOUD_PATHPREFIX=""
|
NEXT_CLOUD_PATHPREFIX=""
|
||||||
|
|
||||||
WABLAS_HOST=https://bdg.wablas.com
|
WABLAS_HOST=https://bdg.wablas.com
|
||||||
WABLAS_TOKEN=5iCaiP0nEgfl3lzrdsZGb9TvNYuwFZF8s4rp8AYwCx5OrYeiKXgixFMo9nDWNrJN.IF98hujz
|
WABLAS_TOKEN=5iCaiP0nEgfl3lzrdsZGb9TvNYuwFZF8s4rp8AYwCx5OrYeiKXgixFMo9nDWNrJN.xvAwySaa
|
||||||
|
|
||||||
|
STARTING_DATE='12'
|
||||||
CLOSING_DATE='20'
|
CLOSING_DATE='20'
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class BudgetHelper
|
|||||||
public static function getAvailableBudget($cabang_id)
|
public static function getAvailableBudget($cabang_id)
|
||||||
{
|
{
|
||||||
// Get the budget control data
|
// Get the budget control data
|
||||||
$budget = BudgetControl::where('cabang_id', $cabang_id)->orderBy('created_at', 'desc')->with(['user', 'cabang'])->get();
|
$budget = BudgetControl::where('cabang_id', $cabang_id)->orderBy('created_at', 'desc')->with(['user.cabang'])->get();
|
||||||
|
|
||||||
// Initialize an empty array to hold the used budget sums
|
// Initialize an empty array to hold the used budget sums
|
||||||
$usedBudget = 0;
|
$usedBudget = 0;
|
||||||
@@ -41,6 +41,49 @@ class BudgetHelper
|
|||||||
return $availableBudget;
|
return $availableBudget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getNominalByFormType($userIds, $type, $type_id, $month, $year)
|
||||||
|
{
|
||||||
|
if ($type == 'Up Country') {
|
||||||
|
$form = FormUpCountry::select('approved_total')
|
||||||
|
->whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('tanggal', '=', $year)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get();
|
||||||
|
} elseif ($type == 'Vehicle Running Cost') {
|
||||||
|
$form = FormVehicleRunningCost::select('approved_total')
|
||||||
|
->whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('tanggal', '=', $year)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get();
|
||||||
|
} elseif ($type == 'Entertainment') {
|
||||||
|
$form = FormEntertaimentPresentation::select('approved_total')
|
||||||
|
->whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('tanggal', '=', $year)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get();
|
||||||
|
} elseif ($type == 'Meeting / Seminar') {
|
||||||
|
$form = FormMeetingSeminar::select('approved_total')
|
||||||
|
->whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('created_at', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('created_at', '=', $year)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get();
|
||||||
|
} else {
|
||||||
|
$form = FormOthers::select('approved_total')
|
||||||
|
->whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('tanggal', '=', $year)
|
||||||
|
->where('kategori_id', $type_id)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $form->sum('approved_total');
|
||||||
|
}
|
||||||
|
|
||||||
public static function getClosingDate($cabang_id)
|
public static function getClosingDate($cabang_id)
|
||||||
{
|
{
|
||||||
$budget = BudgetControl::where('cabang_id', $cabang_id)->orderBy('created_at', 'desc')->first();
|
$budget = BudgetControl::where('cabang_id', $cabang_id)->orderBy('created_at', 'desc')->first();
|
||||||
|
|||||||
+129
-109
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Helpers;
|
namespace App\Helpers;
|
||||||
|
|
||||||
|
use App\Models\Admin;
|
||||||
use App\Models\FormEntertaimentPresentation;
|
use App\Models\FormEntertaimentPresentation;
|
||||||
use App\Models\FormMeetingSeminar;
|
use App\Models\FormMeetingSeminar;
|
||||||
use App\Models\FormOthers;
|
use App\Models\FormOthers;
|
||||||
@@ -13,72 +14,77 @@ use App\Models\UserHasCabang;
|
|||||||
class FormHelper
|
class FormHelper
|
||||||
{
|
{
|
||||||
public static function getFormsByUserIds($userIds, $month, $year) {
|
public static function getFormsByUserIds($userIds, $month, $year) {
|
||||||
|
// Eager load 'user.region' and 'user.cabang'
|
||||||
|
$users = Admin::with(['region', 'cabang'])
|
||||||
|
->whereIn('id', $userIds)
|
||||||
|
->get();
|
||||||
|
|
||||||
$formUpCountryQuery = FormUpCountry::select(
|
$formUpCountryQuery = FormUpCountry::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'account_number',
|
'account_number',
|
||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Up Country' as type")
|
DB::raw("'Up Country' as type")
|
||||||
)->whereIn('user_id', $userIds)
|
)->whereIn('user_id', $userIds)
|
||||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
->whereYear('tanggal', '=', $year);
|
->whereYear('tanggal', '=', $year);
|
||||||
|
|
||||||
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
|
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'account_number',
|
'account_number',
|
||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Vehicle Running Cost' as type")
|
DB::raw("'Vehicle Running Cost' as type")
|
||||||
)->whereIn('user_id', $userIds)
|
)->whereIn('user_id', $userIds)
|
||||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
->whereYear('tanggal', '=', $year);
|
->whereYear('tanggal', '=', $year);
|
||||||
|
|
||||||
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
|
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'account_number',
|
'account_number',
|
||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Entertainment Presentation' as type")
|
DB::raw("'Entertainment Presentation' as type")
|
||||||
)->whereIn('user_id', $userIds)
|
)->whereIn('user_id', $userIds)
|
||||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
->whereYear('tanggal', '=', $year);
|
->whereYear('tanggal', '=', $year);
|
||||||
|
|
||||||
$formMeetingSeminarQuery = FormMeetingSeminar::select(
|
$formMeetingSeminarQuery = FormMeetingSeminar::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'account_number',
|
'account_number',
|
||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Meeting Seminar' as type")
|
DB::raw("'Meeting Seminar' as type")
|
||||||
)->whereIn('user_id', $userIds)
|
)->whereIn('user_id', $userIds)
|
||||||
->whereMonth('created_at', '=', date('m', strtotime($month)))
|
->whereMonth('created_at', '=', date('m', strtotime($month)))
|
||||||
->whereYear('created_at', '=', $year);
|
->whereYear('created_at', '=', $year);
|
||||||
|
|
||||||
$formOthersQuery = FormOthers::select(
|
$formOthersQuery = FormOthers::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'account_number',
|
'account_number',
|
||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Others' as type")
|
DB::raw("'Others' as type")
|
||||||
)->whereIn('user_id', $userIds)
|
)->whereIn('user_id', $userIds)
|
||||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
->whereYear('tanggal', '=', $year);
|
->whereYear('tanggal', '=', $year);
|
||||||
|
|
||||||
// Use union before fetching the data
|
// Use union to combine queries
|
||||||
$forms = $formUpCountryQuery
|
$forms = $formUpCountryQuery
|
||||||
->union($formVehicleRunningCostQuery)
|
->union($formVehicleRunningCostQuery)
|
||||||
->union($formEntertaimentPresentationQuery)
|
->union($formEntertaimentPresentationQuery)
|
||||||
@@ -86,71 +92,80 @@ class FormHelper
|
|||||||
->union($formOthersQuery)
|
->union($formOthersQuery)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return $forms;
|
// Return forms with eager loaded user details
|
||||||
|
return $forms->map(function ($form) use ($users) {
|
||||||
|
$user = $users->firstWhere('id', $form->user_id);
|
||||||
|
$form->user = $user;
|
||||||
|
return $form;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAllForms($month, $year) {
|
public static function getAllForms($month, $year) {
|
||||||
|
// Get all users with eager loading for 'region' and 'cabang'
|
||||||
|
$users = Admin::with(['region', 'cabang'])
|
||||||
|
->get();
|
||||||
|
|
||||||
$formUpCountryQuery = FormUpCountry::select(
|
$formUpCountryQuery = FormUpCountry::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'account_number',
|
'account_number',
|
||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Up Country' as type")
|
DB::raw("'Up Country' as type")
|
||||||
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
->whereYear('tanggal', '=', $year);
|
->whereYear('tanggal', '=', $year);
|
||||||
|
|
||||||
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
|
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'account_number',
|
'account_number',
|
||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Vehicle Running Cost' as type")
|
DB::raw("'Vehicle Running Cost' as type")
|
||||||
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
->whereYear('tanggal', '=', $year);
|
->whereYear('tanggal', '=', $year);
|
||||||
|
|
||||||
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
|
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'account_number',
|
'account_number',
|
||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Entertainment Presentation' as type")
|
DB::raw("'Entertainment Presentation' as type")
|
||||||
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
->whereYear('tanggal', '=', $year);
|
->whereYear('tanggal', '=', $year);
|
||||||
|
|
||||||
$formMeetingSeminarQuery = FormMeetingSeminar::select(
|
$formMeetingSeminarQuery = FormMeetingSeminar::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'account_number',
|
'account_number',
|
||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Meeting Seminar' as type")
|
DB::raw("'Meeting Seminar' as type")
|
||||||
)->whereMonth('created_at', '=', date('m', strtotime($month)))
|
)->whereMonth('created_at', '=', date('m', strtotime($month)))
|
||||||
->whereYear('created_at', '=', $year);
|
->whereYear('created_at', '=', $year);
|
||||||
|
|
||||||
$formOthersQuery = FormOthers::select(
|
$formOthersQuery = FormOthers::select(
|
||||||
'expense_number',
|
'expense_number',
|
||||||
'user_id',
|
'user_id',
|
||||||
'total',
|
'total',
|
||||||
'approved_total',
|
'approved_total',
|
||||||
'status',
|
'status',
|
||||||
'account_number',
|
'account_number',
|
||||||
'created_at',
|
'created_at',
|
||||||
DB::raw("'Others' as type")
|
DB::raw("'Others' as type")
|
||||||
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
->whereYear('tanggal', '=', $year);
|
->whereYear('tanggal', '=', $year);
|
||||||
|
|
||||||
// Use union before fetching the data
|
// Combine queries using union
|
||||||
$forms = $formUpCountryQuery
|
$forms = $formUpCountryQuery
|
||||||
->union($formVehicleRunningCostQuery)
|
->union($formVehicleRunningCostQuery)
|
||||||
->union($formEntertaimentPresentationQuery)
|
->union($formEntertaimentPresentationQuery)
|
||||||
@@ -158,7 +173,12 @@ class FormHelper
|
|||||||
->union($formOthersQuery)
|
->union($formOthersQuery)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return $forms;
|
// Map users to the forms with eager loaded data
|
||||||
|
return $forms->map(function ($form) use ($users) {
|
||||||
|
$user = $users->firstWhere('id', $form->user_id);
|
||||||
|
$form->user = $user;
|
||||||
|
return $form;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getNominalByFormType($cabang_id, $type, $type_id, $month, $year) {
|
public static function getNominalByFormType($cabang_id, $type, $type_id, $month, $year) {
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Helpers;
|
||||||
|
use App\Models\Notifications;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
|
class NotificationHelper
|
||||||
|
{
|
||||||
|
public static function newExpense($user_id, $expense_number, $receiver_ids = [])
|
||||||
|
{
|
||||||
|
if (!is_array($receiver_ids) || empty($receiver_ids)) {
|
||||||
|
throw new InvalidArgumentException('Receiver IDs must be a non-empty array.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Buat data untuk batch insert
|
||||||
|
$notifications = [];
|
||||||
|
foreach ($receiver_ids as $receiver_id) {
|
||||||
|
$notifications[] = [
|
||||||
|
'user_id' => $user_id,
|
||||||
|
'receiver_id' => $receiver_id,
|
||||||
|
'title' => 'New Expense',
|
||||||
|
'content' => 'You have new expense waiting for approval (' . $expense_number . ')',
|
||||||
|
'is_read' => 0,
|
||||||
|
'type' => 'new_expense',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lakukan batch insert
|
||||||
|
Notifications::insert($notifications);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function approveExpense($user_id, $expense_number, $receiver_ids = [])
|
||||||
|
{
|
||||||
|
if (!is_array($receiver_ids) || empty($receiver_ids)) {
|
||||||
|
throw new InvalidArgumentException('Receiver IDs must be a non-empty array.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Buat data untuk batch insert
|
||||||
|
$notifications = [];
|
||||||
|
foreach ($receiver_ids as $receiver_id) {
|
||||||
|
$notifications[] = [
|
||||||
|
'user_id' => $user_id,
|
||||||
|
'receiver_id' => $receiver_id,
|
||||||
|
'title' => 'New Expense',
|
||||||
|
'content' => 'You have new expense waiting for second approval (' . $expense_number . ')',
|
||||||
|
'is_read' => 0,
|
||||||
|
'type' => 'approve_expense',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lakukan batch insert
|
||||||
|
Notifications::insert($notifications);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function approve2Expense($user_id, $expense_number, $receiver_ids = [])
|
||||||
|
{
|
||||||
|
if (!is_array($receiver_ids) || empty($receiver_ids)) {
|
||||||
|
throw new InvalidArgumentException('Receiver IDs must be a non-empty array.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Buat data untuk batch insert
|
||||||
|
$notifications = [];
|
||||||
|
foreach ($receiver_ids as $receiver_id) {
|
||||||
|
$notifications[] = [
|
||||||
|
'user_id' => $user_id,
|
||||||
|
'receiver_id' => $receiver_id,
|
||||||
|
'title' => 'New Expense',
|
||||||
|
'content' => 'You have new expense waiting for final approval (' . $expense_number . ')',
|
||||||
|
'is_read' => 0,
|
||||||
|
'type' => 'approve2_expense',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lakukan batch insert
|
||||||
|
Notifications::insert($notifications);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ use Illuminate\Support\Str;
|
|||||||
|
|
||||||
class WhatsappHelper
|
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();
|
$client = new Client();
|
||||||
|
|
||||||
@@ -17,15 +17,27 @@ class WhatsappHelper
|
|||||||
$url = '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 *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 = [];
|
$data = [];
|
||||||
foreach ($phones as $phone) {
|
foreach ($phones as $phone) {
|
||||||
$data[] = [
|
$data[] = [
|
||||||
'phone' => $phone,
|
'phone' => $phone,
|
||||||
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah disetujui. Silahkan buka link berikut untuk melihat detailnya: ' . $url,
|
'message' => $message,
|
||||||
'source' => 'web'
|
'source' => 'web'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send the request to the WABLAS API
|
||||||
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
||||||
'headers' => [
|
'headers' => [
|
||||||
'Authorization' => env('WABLAS_TOKEN'),
|
'Authorization' => env('WABLAS_TOKEN'),
|
||||||
@@ -39,23 +51,36 @@ class WhatsappHelper
|
|||||||
return $response->getBody()->getContents();
|
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();
|
$client = new Client();
|
||||||
|
|
||||||
|
// Ensure the URL is formatted correctly
|
||||||
if ($url && !preg_match('/^https?:\/\//', $url)) {
|
if ($url && !preg_match('/^https?:\/\//', $url)) {
|
||||||
$url = '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 = [];
|
$data = [];
|
||||||
foreach ($phones as $phone) {
|
foreach ($phones as $phone) {
|
||||||
$data[] = [
|
$data[] = [
|
||||||
'phone' => $phone,
|
'phone' => $phone,
|
||||||
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah ditolak. Silahkan buka link berikut untuk melihat detailnya: ' . $url,
|
'message' => $message,
|
||||||
'source' => 'web'
|
'source' => 'web'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send the request to the WABLAS API
|
||||||
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
||||||
'headers' => [
|
'headers' => [
|
||||||
'Authorization' => env('WABLAS_TOKEN'),
|
'Authorization' => env('WABLAS_TOKEN'),
|
||||||
@@ -69,23 +94,36 @@ class WhatsappHelper
|
|||||||
return $response->getBody()->getContents();
|
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();
|
$client = new Client();
|
||||||
|
|
||||||
|
// Ensure the URL is formatted correctly
|
||||||
if ($url && !preg_match('/^https?:\/\//', $url)) {
|
if ($url && !preg_match('/^https?:\/\//', $url)) {
|
||||||
$url = '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 = [];
|
$data = [];
|
||||||
foreach ($phones as $phone) {
|
foreach ($phones as $phone) {
|
||||||
$data[] = [
|
$data[] = [
|
||||||
'phone' => $phone,
|
'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'
|
'source' => 'web'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send the request to the WABLAS API
|
||||||
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
||||||
'headers' => [
|
'headers' => [
|
||||||
'Authorization' => env('WABLAS_TOKEN'),
|
'Authorization' => env('WABLAS_TOKEN'),
|
||||||
@@ -99,23 +137,79 @@ class WhatsappHelper
|
|||||||
return $response->getBody()->getContents();
|
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();
|
$client = new Client();
|
||||||
|
|
||||||
|
// Ensure the URL is formatted correctly
|
||||||
if ($url && !preg_match('/^https?:\/\//', $url)) {
|
if ($url && !preg_match('/^https?:\/\//', $url)) {
|
||||||
$url = '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 = [];
|
$data = [];
|
||||||
foreach ($phones as $phone) {
|
foreach ($phones as $phone) {
|
||||||
$data[] = [
|
$data[] = [
|
||||||
'phone' => $phone,
|
'phone' => $phone,
|
||||||
'message' => 'Pengajuan pengeluaran baru dengan nomor *' . $expense_number . '* telah dibuat. Silahkan buka link berikut untuk melihat detailnya: ' . $url,
|
'message' => $message,
|
||||||
'source' => 'web'
|
'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', [
|
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
||||||
'headers' => [
|
'headers' => [
|
||||||
'Authorization' => env('WABLAS_TOKEN'),
|
'Authorization' => env('WABLAS_TOKEN'),
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ class AdminsController extends Controller
|
|||||||
'path' => url()->current()
|
'path' => url()->current()
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$admins = Admin::with(['region', 'cabang', 'roles'])->get();
|
||||||
return view('backend.pages.admins.index', [
|
return view('backend.pages.admins.index', [
|
||||||
'admins' => Admin::all(),
|
'admins' => $admins,
|
||||||
'pageInfo' => $pageInfo,
|
'pageInfo' => $pageInfo,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class AuditTrailController extends Controller
|
|||||||
'backend.pages.audit_trail.index',
|
'backend.pages.audit_trail.index',
|
||||||
[
|
[
|
||||||
// sort by newest
|
// sort by newest
|
||||||
'data' => AuditTrail::orderBy('created_at', 'desc')->get(),
|
'data' => AuditTrail::with('user')->orderBy('created_at', 'desc')->get(),
|
||||||
'pageInfo' => $pageInfo,
|
'pageInfo' => $pageInfo,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Backend;
|
namespace App\Http\Controllers\Backend;
|
||||||
|
|
||||||
|
use App\Helpers\BudgetHelper;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\BudgetControl;
|
use App\Models\BudgetControl;
|
||||||
use App\Models\BudgetControlLog;
|
use App\Models\BudgetControlLog;
|
||||||
@@ -23,8 +24,6 @@ class BudgetControlController extends Controller
|
|||||||
$this->checkAuthorization(auth()->user(), ['budget_control.view']);
|
$this->checkAuthorization(auth()->user(), ['budget_control.view']);
|
||||||
session()->put('redirect_url', route('budget_control'));
|
session()->put('redirect_url', route('budget_control'));
|
||||||
|
|
||||||
// Get the budget control data
|
|
||||||
// $budget = BudgetControl::orderBy('created_at', 'desc')->with(['user', 'cabang'])->get();
|
|
||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$budget = null;
|
$budget = null;
|
||||||
|
|
||||||
@@ -32,72 +31,32 @@ class BudgetControlController extends Controller
|
|||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|
||||||
if ($region_id) {
|
if ($region_id) {
|
||||||
// Get budget controls where the region matches
|
|
||||||
$budget = BudgetControl::whereHas('cabang', function ($query) use ($region_id) {
|
$budget = BudgetControl::whereHas('cabang', function ($query) use ($region_id) {
|
||||||
$query->where('region_id', $region_id);
|
$query->where('region_id', $region_id);
|
||||||
})->get();
|
})->with(['receiver', 'sender', 'cabang'])->get();
|
||||||
}
|
}
|
||||||
} elseif ($role == 'Area Manager Cabang') {
|
} elseif ($role == 'Area Manager Cabang') {
|
||||||
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
||||||
|
|
||||||
if ($cabang_id) {
|
if ($cabang_id) {
|
||||||
// Get budget controls where the cabang matches
|
$budget = BudgetControl::where('cabang_id', $cabang_id)
|
||||||
$budget = BudgetControl::where('cabang_id', $cabang_id)->get();
|
->with(['receiver', 'sender', 'cabang'])
|
||||||
|
->get();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Get all budget controls for other roles
|
$budget = BudgetControl::with(['receiver', 'sender', 'cabang'])->get();
|
||||||
$budget = BudgetControl::all();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize an empty array to hold the used budget sums
|
// Calculate usedBudget and availableBudget for each cabang
|
||||||
$usedBudget = [];
|
$budget->map(function ($b) {
|
||||||
|
$b->availableBudget = BudgetHelper::getAvailableBudget($b->cabang_id);
|
||||||
|
|
||||||
foreach ($budget as $b) {
|
return $b;
|
||||||
// Get the month and year from the budget
|
});
|
||||||
$month = $b->periode_month;
|
|
||||||
$year = $b->periode_year;
|
|
||||||
|
|
||||||
// Add the used budget per model for the specified month and year to the usedBudget array
|
return view('backend.pages.budget_control.index', [
|
||||||
$usedBudget[] = [
|
'data' => $budget,
|
||||||
'FormUpCountry' => FormUpCountry::whereIn('status', ['Approved', 'Closed'])
|
]);
|
||||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
|
||||||
->whereYear('tanggal', '=', $year)
|
|
||||||
->sum('approved_total'),
|
|
||||||
|
|
||||||
'FormMeetingSeminar' => FormMeetingSeminar::whereIn('status', ['Approved', 'Closed'])
|
|
||||||
->whereMonth('created_at', '=', date('m', strtotime($month)))
|
|
||||||
->whereYear('created_at', '=', $year)
|
|
||||||
->sum('approved_total'),
|
|
||||||
|
|
||||||
'FormOthers' => FormOthers::whereIn('status', ['Approved', 'Closed'])
|
|
||||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
|
||||||
->whereYear('tanggal', '=', $year)
|
|
||||||
->sum('approved_total'),
|
|
||||||
|
|
||||||
'FormEntertaimentPresentation' => FormEntertaimentPresentation::whereIn('status', ['Approved', 'Closed'])
|
|
||||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
|
||||||
->whereYear('tanggal', '=', $year)
|
|
||||||
->sum('approved_total'),
|
|
||||||
|
|
||||||
'FormVehicleRunningCost' => FormVehicleRunningCost::whereIn('status', ['Approved', 'Closed'])
|
|
||||||
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
|
||||||
->whereYear('tanggal', '=', $year)
|
|
||||||
->sum('approved_total')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$usedBudget = array_sum(array_map(function ($b) {
|
|
||||||
return array_sum($b);
|
|
||||||
}, $usedBudget));
|
|
||||||
|
|
||||||
return view(
|
|
||||||
'backend.pages.budget_control.index',
|
|
||||||
[
|
|
||||||
'data' => $budget,
|
|
||||||
'usedBudget' => $usedBudget,
|
|
||||||
'availableBudget' => $budget->sum('amount') - $usedBudget,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function log()
|
public function log()
|
||||||
@@ -108,7 +67,7 @@ class BudgetControlController extends Controller
|
|||||||
return view(
|
return view(
|
||||||
'backend.pages.budget_control.log',
|
'backend.pages.budget_control.log',
|
||||||
[
|
[
|
||||||
'data' => BudgetControlLog::orderBy('created_at', 'desc')->with(['user', 'cabang'])->get(),
|
'data' => BudgetControlLog::orderBy('created_at', 'desc')->with(['receiver', 'sender', 'cabang'])->get(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ use App\Models\FormVehicleRunningCost;
|
|||||||
use App\Models\FormMeetingSeminar;
|
use App\Models\FormMeetingSeminar;
|
||||||
use App\Models\FormOthers;
|
use App\Models\FormOthers;
|
||||||
use App\Models\UserHasCabang;
|
use App\Models\UserHasCabang;
|
||||||
|
use App\Models\Notifications;
|
||||||
|
|
||||||
|
|
||||||
class DashboardController extends Controller
|
class DashboardController extends Controller
|
||||||
@@ -99,4 +100,43 @@ class DashboardController extends Controller
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function notifications()
|
||||||
|
{
|
||||||
|
$this->checkAuthorization(auth()->user(), ['notification.view']);
|
||||||
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
|
|
||||||
|
// Mulai dengan query dasar
|
||||||
|
$notifications = Notifications::orderBy('created_at', 'desc')
|
||||||
|
->where('receiver_id', auth()->user()->id)
|
||||||
|
->where('is_read', 0);
|
||||||
|
|
||||||
|
// Tambahkan filter berdasarkan role
|
||||||
|
if ($role == 'Admin Region') {
|
||||||
|
$notifications->where('type', 'new_expense');
|
||||||
|
} elseif ($role == 'Marketing Operational Manager Region') {
|
||||||
|
$notifications->where('type', 'approve2_expense');
|
||||||
|
} elseif ($role == 'Area Manager Cabang' || $role == 'Marketing Information System') {
|
||||||
|
$notifications->where('type', 'approve_expense');
|
||||||
|
} elseif ($role == 'Head of Sales Marketing') {
|
||||||
|
$notifications->where('type', 'approve2_expense');
|
||||||
|
} else {
|
||||||
|
// Jika tidak ada role yang sesuai, kembalikan koleksi kosong
|
||||||
|
return response()->json([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ambil data dan kembalikan sebagai JSON
|
||||||
|
return response()->json($notifications->limit(6)->get());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function mark_read()
|
||||||
|
{
|
||||||
|
$this->checkAuthorization(auth()->user(), ['notification.delete']);
|
||||||
|
$receiver_id = auth()->user()->id;
|
||||||
|
|
||||||
|
Notifications::where('receiver_id', $receiver_id)->update(['is_read' => 1]);
|
||||||
|
|
||||||
|
session()->flash('success', 'Notifications marked as read.');
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,88 +27,75 @@ class ReportController extends Controller
|
|||||||
public function upcountry()
|
public function upcountry()
|
||||||
{
|
{
|
||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$cabangs = [];
|
$cabangs = collect(); // Default empty collection
|
||||||
$regions = [];
|
$regions = collect(); // Default empty collection
|
||||||
$forms = null;
|
$formsQuery = FormUpCountry::with([
|
||||||
|
'user.region',
|
||||||
|
'user.cabang',
|
||||||
|
'rayon'
|
||||||
|
]);
|
||||||
|
|
||||||
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|
||||||
if ($region_id) {
|
if ($region_id) {
|
||||||
$users = UserHasCabang::whereHas('cabang', function ($query) use ($region_id) {
|
|
||||||
$query->where('region_id', $region_id);
|
|
||||||
})->get();
|
|
||||||
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('region_id', $region_id)->get();
|
$cabangs = Cabang::where('region_id', $region_id)->get();
|
||||||
$regions = Region::where('id', $region_id)->get();
|
$regions = Region::where('id', $region_id)->get();
|
||||||
$forms = FormUpCountry::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::whereIn('cabang_id', $cabangs->pluck('id'))->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Area Manager Cabang') {
|
} elseif ($role == 'Area Manager Cabang') {
|
||||||
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
||||||
|
|
||||||
if ($cabang_id) {
|
if ($cabang_id) {
|
||||||
$users = UserHasCabang::where('cabang_id', $cabang_id)->get();
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('id', $cabang_id)->get();
|
$cabangs = Cabang::where('id', $cabang_id)->get();
|
||||||
$regions = Region::where('id', $cabangs[0]->region_id)->get();
|
$regions = Region::where('id', $cabangs->first()->region_id)->get();
|
||||||
$forms = FormUpCountry::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::where('cabang_id', $cabang_id)->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Medical Representatif') {
|
|
||||||
$userId = auth()->user()->id;
|
|
||||||
|
|
||||||
$cabangs = null;
|
|
||||||
$regions = null;
|
|
||||||
$forms = FormUpCountry::where('user_id', $userId)->get();
|
|
||||||
} else {
|
} else {
|
||||||
$cabangs = Cabang::all();
|
$cabangs = Cabang::all();
|
||||||
$regions = Region::all();
|
$regions = Region::all();
|
||||||
$forms = FormUpCountry::all();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get all params in url
|
// Apply filters from URL params
|
||||||
$params = request()->all();
|
$params = request()->all();
|
||||||
if ($params) {
|
|
||||||
// Filter by region
|
|
||||||
if (isset($params['region'])) {
|
|
||||||
$region = Region::where('code', $params['region'])->first();
|
|
||||||
if ($region) {
|
|
||||||
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id')->toArray();
|
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter by cabang
|
if (isset($params['region'])) {
|
||||||
if (isset($params['cabang'])) {
|
$region = Region::where('code', $params['region'])->first();
|
||||||
$cabang = Cabang::where('code', $params['cabang'])->first();
|
if ($region) {
|
||||||
if ($cabang) {
|
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id');
|
||||||
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id')->toArray();
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter by date range
|
|
||||||
if (isset($params['start_date']) || isset($params['end_date'])) {
|
|
||||||
$startDate = $params['start_date'] ?? null;
|
|
||||||
$endDate = $params['end_date'] ?? null;
|
|
||||||
|
|
||||||
if ($startDate && $endDate) {
|
|
||||||
$forms = $forms->whereBetween('tanggal', [$startDate, $endDate]);
|
|
||||||
} elseif ($startDate) {
|
|
||||||
$forms = $forms->where('tanggal', '>=', $startDate);
|
|
||||||
} elseif ($endDate) {
|
|
||||||
$forms = $forms->where('tanggal', '<=', $endDate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter by status
|
|
||||||
if (isset($params['status'])) {
|
|
||||||
$forms = $forms->where('status', $params['status']);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($params['cabang'])) {
|
||||||
|
$cabang = Cabang::where('code', $params['cabang'])->first();
|
||||||
|
if ($cabang) {
|
||||||
|
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['start_date']) || isset($params['end_date'])) {
|
||||||
|
$startDate = $params['start_date'] ?? null;
|
||||||
|
$endDate = $params['end_date'] ?? null;
|
||||||
|
|
||||||
|
if ($startDate && $endDate) {
|
||||||
|
$formsQuery->whereBetween('tanggal', [$startDate, $endDate]);
|
||||||
|
} elseif ($startDate) {
|
||||||
|
$formsQuery->where('tanggal', '>=', $startDate);
|
||||||
|
} elseif ($endDate) {
|
||||||
|
$formsQuery->where('tanggal', '<=', $endDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['status'])) {
|
||||||
|
$formsQuery->where('status', $params['status']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch forms after applying all filters
|
||||||
|
$forms = $formsQuery->get();
|
||||||
|
|
||||||
return view('backend.pages.report.upcountry', [
|
return view('backend.pages.report.upcountry', [
|
||||||
'pageInfo' => [
|
'pageInfo' => [
|
||||||
@@ -120,51 +107,43 @@ class ReportController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function vehicle()
|
public function vehicle()
|
||||||
{
|
{
|
||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$cabangs = [];
|
$cabangs = collect(); // Default empty collection
|
||||||
$regions = [];
|
$regions = collect(); // Default empty collection
|
||||||
$forms = null;
|
$formsQuery = FormVehicleRunningCost::with([
|
||||||
|
'user.region', // Eager load 'region' within 'user'
|
||||||
|
'user.cabang', // Eager load 'cabang' within 'user'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Apply role-based query logic
|
||||||
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|
||||||
if ($region_id) {
|
if ($region_id) {
|
||||||
$users = UserHasCabang::whereHas('cabang', function ($query) use ($region_id) {
|
|
||||||
$query->where('region_id', $region_id);
|
|
||||||
})->get();
|
|
||||||
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('region_id', $region_id)->get();
|
$cabangs = Cabang::where('region_id', $region_id)->get();
|
||||||
$regions = Region::where('id', $region_id)->get();
|
$regions = Region::where('id', $region_id)->get();
|
||||||
$forms = FormVehicleRunningCost::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::whereIn('cabang_id', $cabangs->pluck('id'))->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Area Manager Cabang') {
|
} elseif ($role == 'Area Manager Cabang') {
|
||||||
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
||||||
|
|
||||||
if ($cabang_id) {
|
if ($cabang_id) {
|
||||||
$users = UserHasCabang::where('cabang_id', $cabang_id)->get();
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('id', $cabang_id)->get();
|
$cabangs = Cabang::where('id', $cabang_id)->get();
|
||||||
$regions = Region::where('id', $cabangs[0]->region_id)->get();
|
$regions = Region::where('id', $cabangs->first()->region_id)->get();
|
||||||
$forms = FormVehicleRunningCost::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::where('cabang_id', $cabang_id)->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Medical Representatif') {
|
|
||||||
$userId = auth()->user()->id;
|
|
||||||
|
|
||||||
$cabangs = null;
|
|
||||||
$regions = null;
|
|
||||||
$forms = FormVehicleRunningCost::where('user_id', $userId)->get();
|
|
||||||
} else {
|
} else {
|
||||||
|
// Default behavior for other roles (if no specific role is matched)
|
||||||
$cabangs = Cabang::all();
|
$cabangs = Cabang::all();
|
||||||
$regions = Region::all();
|
$regions = Region::all();
|
||||||
$forms = FormVehicleRunningCost::all();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get all params in url
|
// Get all params in URL for filtering
|
||||||
$params = request()->all();
|
$params = request()->all();
|
||||||
|
|
||||||
if ($params) {
|
if ($params) {
|
||||||
@@ -172,8 +151,8 @@ class ReportController extends Controller
|
|||||||
if (isset($params['region'])) {
|
if (isset($params['region'])) {
|
||||||
$region = Region::where('code', $params['region'])->first();
|
$region = Region::where('code', $params['region'])->first();
|
||||||
if ($region) {
|
if ($region) {
|
||||||
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id')->toArray();
|
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id');
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,8 +160,8 @@ class ReportController extends Controller
|
|||||||
if (isset($params['cabang'])) {
|
if (isset($params['cabang'])) {
|
||||||
$cabang = Cabang::where('code', $params['cabang'])->first();
|
$cabang = Cabang::where('code', $params['cabang'])->first();
|
||||||
if ($cabang) {
|
if ($cabang) {
|
||||||
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id')->toArray();
|
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id');
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,20 +171,23 @@ class ReportController extends Controller
|
|||||||
$endDate = $params['end_date'] ?? null;
|
$endDate = $params['end_date'] ?? null;
|
||||||
|
|
||||||
if ($startDate && $endDate) {
|
if ($startDate && $endDate) {
|
||||||
$forms = $forms->whereBetween('tanggal', [$startDate, $endDate]);
|
$formsQuery->whereBetween('tanggal', [$startDate, $endDate]);
|
||||||
} elseif ($startDate) {
|
} elseif ($startDate) {
|
||||||
$forms = $forms->where('tanggal', '>=', $startDate);
|
$formsQuery->where('tanggal', '>=', $startDate);
|
||||||
} elseif ($endDate) {
|
} elseif ($endDate) {
|
||||||
$forms = $forms->where('tanggal', '<=', $endDate);
|
$formsQuery->where('tanggal', '<=', $endDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter by status
|
// Filter by status
|
||||||
if (isset($params['status'])) {
|
if (isset($params['status'])) {
|
||||||
$forms = $forms->where('status', $params['status']);
|
$formsQuery->where('status', $params['status']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch forms after applying all filters
|
||||||
|
$forms = $formsQuery->get();
|
||||||
|
|
||||||
return view('backend.pages.report.vehicle', [
|
return view('backend.pages.report.vehicle', [
|
||||||
'pageInfo' => [
|
'pageInfo' => [
|
||||||
'title' => 'Generate Reports For Form Vehicle Running Cost',
|
'title' => 'Generate Reports For Form Vehicle Running Cost',
|
||||||
@@ -219,48 +201,35 @@ class ReportController extends Controller
|
|||||||
public function entertainment()
|
public function entertainment()
|
||||||
{
|
{
|
||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$cabangs = [];
|
$cabangs = Cabang::all();
|
||||||
$regions = [];
|
$regions = Region::all();
|
||||||
$forms = null;
|
$formsQuery = FormEntertaimentPresentation::with([
|
||||||
|
'user.region', // Eager load 'region' within 'user'
|
||||||
|
'user.cabang', // Eager load 'cabang' within 'user'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Apply role-based query logic
|
||||||
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|
||||||
if ($region_id) {
|
if ($region_id) {
|
||||||
$users = UserHasCabang::whereHas('cabang', function ($query) use ($region_id) {
|
|
||||||
$query->where('region_id', $region_id);
|
|
||||||
})->get();
|
|
||||||
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('region_id', $region_id)->get();
|
$cabangs = Cabang::where('region_id', $region_id)->get();
|
||||||
$regions = Region::where('id', $region_id)->get();
|
$regions = Region::where('id', $region_id)->get();
|
||||||
$forms = FormEntertaimentPresentation::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::whereIn('cabang_id', $cabangs->pluck('id'))->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Area Manager Cabang') {
|
} elseif ($role == 'Area Manager Cabang') {
|
||||||
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
||||||
|
|
||||||
if ($cabang_id) {
|
if ($cabang_id) {
|
||||||
$users = UserHasCabang::where('cabang_id', $cabang_id)->get();
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('id', $cabang_id)->get();
|
$cabangs = Cabang::where('id', $cabang_id)->get();
|
||||||
$regions = Region::where('id', $cabangs[0]->region_id)->get();
|
$regions = Region::where('id', $cabangs->first()->region_id)->get();
|
||||||
$forms = FormEntertaimentPresentation::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::where('cabang_id', $cabang_id)->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Medical Representatif') {
|
|
||||||
$userId = auth()->user()->id;
|
|
||||||
|
|
||||||
$cabangs = null;
|
|
||||||
$regions = null;
|
|
||||||
$forms = FormEntertaimentPresentation::where('user_id', $userId)->get();
|
|
||||||
} else {
|
|
||||||
$cabangs = Cabang::all();
|
|
||||||
$regions = Region::all();
|
|
||||||
$forms = FormEntertaimentPresentation::all();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get all params in url
|
// Get all params in URL for filtering
|
||||||
$params = request()->all();
|
$params = request()->all();
|
||||||
|
|
||||||
if ($params) {
|
if ($params) {
|
||||||
@@ -268,8 +237,8 @@ class ReportController extends Controller
|
|||||||
if (isset($params['region'])) {
|
if (isset($params['region'])) {
|
||||||
$region = Region::where('code', $params['region'])->first();
|
$region = Region::where('code', $params['region'])->first();
|
||||||
if ($region) {
|
if ($region) {
|
||||||
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id')->toArray();
|
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id');
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,8 +246,8 @@ class ReportController extends Controller
|
|||||||
if (isset($params['cabang'])) {
|
if (isset($params['cabang'])) {
|
||||||
$cabang = Cabang::where('code', $params['cabang'])->first();
|
$cabang = Cabang::where('code', $params['cabang'])->first();
|
||||||
if ($cabang) {
|
if ($cabang) {
|
||||||
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id')->toArray();
|
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id');
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,20 +257,23 @@ class ReportController extends Controller
|
|||||||
$endDate = $params['end_date'] ?? null;
|
$endDate = $params['end_date'] ?? null;
|
||||||
|
|
||||||
if ($startDate && $endDate) {
|
if ($startDate && $endDate) {
|
||||||
$forms = $forms->whereBetween('tanggal', [$startDate, $endDate]);
|
$formsQuery->whereBetween('tanggal', [$startDate, $endDate]);
|
||||||
} elseif ($startDate) {
|
} elseif ($startDate) {
|
||||||
$forms = $forms->where('tanggal', '>=', $startDate);
|
$formsQuery->where('tanggal', '>=', $startDate);
|
||||||
} elseif ($endDate) {
|
} elseif ($endDate) {
|
||||||
$forms = $forms->where('tanggal', '<=', $endDate);
|
$formsQuery->where('tanggal', '<=', $endDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter by status
|
// Filter by status
|
||||||
if (isset($params['status'])) {
|
if (isset($params['status'])) {
|
||||||
$forms = $forms->where('status', $params['status']);
|
$formsQuery->where('status', $params['status']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch forms after applying all filters
|
||||||
|
$forms = $formsQuery->get();
|
||||||
|
|
||||||
return view('backend.pages.report.entertainment', [
|
return view('backend.pages.report.entertainment', [
|
||||||
'pageInfo' => [
|
'pageInfo' => [
|
||||||
'title' => 'Generate Reports For Form Entertainment & Presentation',
|
'title' => 'Generate Reports For Form Entertainment & Presentation',
|
||||||
@@ -315,48 +287,37 @@ class ReportController extends Controller
|
|||||||
public function meeting()
|
public function meeting()
|
||||||
{
|
{
|
||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$cabangs = [];
|
$cabangs = Cabang::all();
|
||||||
$regions = [];
|
$regions = Region::all();
|
||||||
$forms = null;
|
|
||||||
|
// Initialize the query for FormMeetingSeminar with eager loading
|
||||||
|
$formsQuery = FormMeetingSeminar::with([
|
||||||
|
'user.region', // Eager load 'region' within 'user'
|
||||||
|
'user.cabang', // Eager load 'cabang' within 'user'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Apply role-based query logic
|
||||||
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|
||||||
if ($region_id) {
|
if ($region_id) {
|
||||||
$users = UserHasCabang::whereHas('cabang', function ($query) use ($region_id) {
|
|
||||||
$query->where('region_id', $region_id);
|
|
||||||
})->get();
|
|
||||||
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('region_id', $region_id)->get();
|
$cabangs = Cabang::where('region_id', $region_id)->get();
|
||||||
$regions = Region::where('id', $region_id)->get();
|
$regions = Region::where('id', $region_id)->get();
|
||||||
$forms = FormMeetingSeminar::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::whereIn('cabang_id', $cabangs->pluck('id'))->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Area Manager Cabang') {
|
} elseif ($role == 'Area Manager Cabang') {
|
||||||
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
||||||
|
|
||||||
if ($cabang_id) {
|
if ($cabang_id) {
|
||||||
$users = UserHasCabang::where('cabang_id', $cabang_id)->get();
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('id', $cabang_id)->get();
|
$cabangs = Cabang::where('id', $cabang_id)->get();
|
||||||
$regions = Region::where('id', $cabangs[0]->region_id)->get();
|
$regions = Region::where('id', $cabangs->first()->region_id)->get();
|
||||||
$forms = FormMeetingSeminar::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::where('cabang_id', $cabang_id)->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Medical Representatif') {
|
|
||||||
$userId = auth()->user()->id;
|
|
||||||
|
|
||||||
$cabangs = null;
|
|
||||||
$regions = null;
|
|
||||||
$forms = FormMeetingSeminar::where('user_id', $userId)->get();
|
|
||||||
} else {
|
|
||||||
$cabangs = Cabang::all();
|
|
||||||
$regions = Region::all();
|
|
||||||
$forms = FormMeetingSeminar::all();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get all params in url
|
// Get all params in URL for filtering
|
||||||
$params = request()->all();
|
$params = request()->all();
|
||||||
|
|
||||||
if ($params) {
|
if ($params) {
|
||||||
@@ -364,8 +325,8 @@ class ReportController extends Controller
|
|||||||
if (isset($params['region'])) {
|
if (isset($params['region'])) {
|
||||||
$region = Region::where('code', $params['region'])->first();
|
$region = Region::where('code', $params['region'])->first();
|
||||||
if ($region) {
|
if ($region) {
|
||||||
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id')->toArray();
|
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id');
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,8 +334,8 @@ class ReportController extends Controller
|
|||||||
if (isset($params['cabang'])) {
|
if (isset($params['cabang'])) {
|
||||||
$cabang = Cabang::where('code', $params['cabang'])->first();
|
$cabang = Cabang::where('code', $params['cabang'])->first();
|
||||||
if ($cabang) {
|
if ($cabang) {
|
||||||
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id')->toArray();
|
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id');
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,20 +345,23 @@ class ReportController extends Controller
|
|||||||
$endDate = $params['end_date'] ?? null;
|
$endDate = $params['end_date'] ?? null;
|
||||||
|
|
||||||
if ($startDate && $endDate) {
|
if ($startDate && $endDate) {
|
||||||
$forms = $forms->whereBetween('tanggal', [$startDate, $endDate]);
|
$formsQuery->whereBetween('tanggal', [$startDate, $endDate]);
|
||||||
} elseif ($startDate) {
|
} elseif ($startDate) {
|
||||||
$forms = $forms->where('tanggal', '>=', $startDate);
|
$formsQuery->where('tanggal', '>=', $startDate);
|
||||||
} elseif ($endDate) {
|
} elseif ($endDate) {
|
||||||
$forms = $forms->where('tanggal', '<=', $endDate);
|
$formsQuery->where('tanggal', '<=', $endDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter by status
|
// Filter by status
|
||||||
if (isset($params['status'])) {
|
if (isset($params['status'])) {
|
||||||
$forms = $forms->where('status', $params['status']);
|
$formsQuery->where('status', $params['status']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch forms after applying all filters
|
||||||
|
$forms = $formsQuery->get();
|
||||||
|
|
||||||
return view('backend.pages.report.meeting', [
|
return view('backend.pages.report.meeting', [
|
||||||
'pageInfo' => [
|
'pageInfo' => [
|
||||||
'title' => 'Generate Reports For Form Meeting & Seminar',
|
'title' => 'Generate Reports For Form Meeting & Seminar',
|
||||||
@@ -411,48 +375,38 @@ class ReportController extends Controller
|
|||||||
public function others()
|
public function others()
|
||||||
{
|
{
|
||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$cabangs = [];
|
$cabangs = Cabang::all();
|
||||||
$regions = [];
|
$regions = Region::all();
|
||||||
$forms = null;
|
|
||||||
|
// Initialize the query for FormOthers with eager loading
|
||||||
|
$formsQuery = FormOthers::with([
|
||||||
|
'user.region', // Eager load 'region' within 'user'
|
||||||
|
'user.cabang', // Eager load 'cabang' within 'user'
|
||||||
|
'kategori'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Apply role-based query logic
|
||||||
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|
||||||
if ($region_id) {
|
if ($region_id) {
|
||||||
$users = UserHasCabang::whereHas('cabang', function ($query) use ($region_id) {
|
|
||||||
$query->where('region_id', $region_id);
|
|
||||||
})->get();
|
|
||||||
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('region_id', $region_id)->get();
|
$cabangs = Cabang::where('region_id', $region_id)->get();
|
||||||
$regions = Region::where('id', $region_id)->get();
|
$regions = Region::where('id', $region_id)->get();
|
||||||
$forms = FormOthers::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::whereIn('cabang_id', $cabangs->pluck('id'))->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Area Manager Cabang') {
|
} elseif ($role == 'Area Manager Cabang') {
|
||||||
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
||||||
|
|
||||||
if ($cabang_id) {
|
if ($cabang_id) {
|
||||||
$users = UserHasCabang::where('cabang_id', $cabang_id)->get();
|
|
||||||
$userIds = $users->pluck('user_id')->toArray();
|
|
||||||
|
|
||||||
$cabangs = Cabang::where('id', $cabang_id)->get();
|
$cabangs = Cabang::where('id', $cabang_id)->get();
|
||||||
$regions = Region::where('id', $cabangs[0]->region_id)->get();
|
$regions = Region::where('id', $cabangs->first()->region_id)->get();
|
||||||
$forms = FormOthers::whereIn('user_id', $userIds)->get();
|
$userIds = UserHasCabang::where('cabang_id', $cabang_id)->pluck('user_id');
|
||||||
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
} else if ($role == 'Medical Representatif') {
|
|
||||||
$userId = auth()->user()->id;
|
|
||||||
|
|
||||||
$cabangs = null;
|
|
||||||
$regions = null;
|
|
||||||
$forms = FormOthers::where('user_id', $userId)->get();
|
|
||||||
} else {
|
|
||||||
$cabangs = Cabang::all();
|
|
||||||
$regions = Region::all();
|
|
||||||
$forms = FormOthers::all();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get all params in url
|
// Get all params in URL for filtering
|
||||||
$params = request()->all();
|
$params = request()->all();
|
||||||
|
|
||||||
if ($params) {
|
if ($params) {
|
||||||
@@ -460,8 +414,8 @@ class ReportController extends Controller
|
|||||||
if (isset($params['region'])) {
|
if (isset($params['region'])) {
|
||||||
$region = Region::where('code', $params['region'])->first();
|
$region = Region::where('code', $params['region'])->first();
|
||||||
if ($region) {
|
if ($region) {
|
||||||
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id')->toArray();
|
$userIds = UserHasCabang::whereIn('cabang_id', Cabang::where('region_id', $region->id)->pluck('id'))->pluck('user_id');
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,8 +423,8 @@ class ReportController extends Controller
|
|||||||
if (isset($params['cabang'])) {
|
if (isset($params['cabang'])) {
|
||||||
$cabang = Cabang::where('code', $params['cabang'])->first();
|
$cabang = Cabang::where('code', $params['cabang'])->first();
|
||||||
if ($cabang) {
|
if ($cabang) {
|
||||||
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id')->toArray();
|
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id');
|
||||||
$forms = $forms->whereIn('user_id', $userIds);
|
$formsQuery->whereIn('user_id', $userIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,20 +434,23 @@ class ReportController extends Controller
|
|||||||
$endDate = $params['end_date'] ?? null;
|
$endDate = $params['end_date'] ?? null;
|
||||||
|
|
||||||
if ($startDate && $endDate) {
|
if ($startDate && $endDate) {
|
||||||
$forms = $forms->whereBetween('tanggal', [$startDate, $endDate]);
|
$formsQuery->whereBetween('tanggal', [$startDate, $endDate]);
|
||||||
} elseif ($startDate) {
|
} elseif ($startDate) {
|
||||||
$forms = $forms->where('tanggal', '>=', $startDate);
|
$formsQuery->where('tanggal', '>=', $startDate);
|
||||||
} elseif ($endDate) {
|
} elseif ($endDate) {
|
||||||
$forms = $forms->where('tanggal', '<=', $endDate);
|
$formsQuery->where('tanggal', '<=', $endDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter by status
|
// Filter by status
|
||||||
if (isset($params['status'])) {
|
if (isset($params['status'])) {
|
||||||
$forms = $forms->where('status', $params['status']);
|
$formsQuery->where('status', $params['status']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch forms after applying all filters
|
||||||
|
$forms = $formsQuery->get();
|
||||||
|
|
||||||
return view('backend.pages.report.others', [
|
return view('backend.pages.report.others', [
|
||||||
'pageInfo' => [
|
'pageInfo' => [
|
||||||
'title' => 'Generate Reports For Form Others',
|
'title' => 'Generate Reports For Form Others',
|
||||||
@@ -538,10 +495,6 @@ class ReportController extends Controller
|
|||||||
$regions = Region::where('id', $cabangs[0]->region_id)->get();
|
$regions = Region::where('id', $cabangs[0]->region_id)->get();
|
||||||
$forms = FormHelper::getFormsByUserIds($userIds, $month, $year)->sortByDesc('created_at');
|
$forms = FormHelper::getFormsByUserIds($userIds, $month, $year)->sortByDesc('created_at');
|
||||||
}
|
}
|
||||||
} elseif ($role == 'Medical Representatif') {
|
|
||||||
$cabangs = null;
|
|
||||||
$regions = null;
|
|
||||||
$forms = FormHelper::getFormsByUserIds([$userId], $month, $year)->sortByDesc('created_at');
|
|
||||||
} else {
|
} else {
|
||||||
$cabangs = Cabang::all();
|
$cabangs = Cabang::all();
|
||||||
$regions = Region::all();
|
$regions = Region::all();
|
||||||
@@ -674,11 +627,53 @@ class ReportController extends Controller
|
|||||||
$kategoris = Kategori::all();
|
$kategoris = Kategori::all();
|
||||||
$kategori_bca = Kategori::where('name', 'Cash in Bank BCA')->first();
|
$kategori_bca = Kategori::where('name', 'Cash in Bank BCA')->first();
|
||||||
$cabang = Cabang::with('cost')->where('code', $params['cabang'])->first();
|
$cabang = Cabang::with('cost')->where('code', $params['cabang'])->first();
|
||||||
|
|
||||||
$year = $params['year'];
|
$year = $params['year'];
|
||||||
$month = $params['month'];
|
$month = $params['month'];
|
||||||
|
|
||||||
$budget = BudgetControlLog::where('cabang_id', $cabang->id)->where('periode_year', $year)->where('periode_month', $month)->orderBy('created_at', 'desc')->first();
|
$budget = BudgetControlLog::where('cabang_id', $cabang->id)->where('periode_year', $year)->where('periode_month', $month)->orderBy('created_at', 'desc')->first();
|
||||||
|
$userIds = UserHasCabang::where('cabang_id', $cabang->id)->pluck('user_id');
|
||||||
|
|
||||||
|
// Fetch all relevant forms in one batch
|
||||||
|
$forms = [
|
||||||
|
'Up Country' => FormUpCountry::whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('tanggal', '=', $year)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get(),
|
||||||
|
'Vehicle Running Cost' => FormVehicleRunningCost::whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('tanggal', '=', $year)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get(),
|
||||||
|
'Entertainment' => FormEntertaimentPresentation::whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('tanggal', '=', $year)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get(),
|
||||||
|
'Meeting / Seminar' => FormMeetingSeminar::whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('created_at', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('created_at', '=', $year)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get(),
|
||||||
|
];
|
||||||
|
|
||||||
|
// Fetch 'Others' forms by kategori
|
||||||
|
$otherForms = FormOthers::whereIn('user_id', $userIds)
|
||||||
|
->whereMonth('tanggal', '=', date('m', strtotime($month)))
|
||||||
|
->whereYear('tanggal', '=', $year)
|
||||||
|
->whereIn('status', ['Approved', 'Closed'])
|
||||||
|
->get();
|
||||||
|
|
||||||
|
// Precompute totals for each category
|
||||||
|
$nominals = [];
|
||||||
|
foreach ($kategoris as $item) {
|
||||||
|
if (isset($forms[$item->name])) {
|
||||||
|
$nominals[$item->id] = $forms[$item->name]->sum('approved_total');
|
||||||
|
} else {
|
||||||
|
$nominals[$item->id] = $otherForms->where('kategori_id', $item->id)->sum('approved_total');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return view('backend.pages.report.generate_jurnal', [
|
return view('backend.pages.report.generate_jurnal', [
|
||||||
'pageInfo' => [
|
'pageInfo' => [
|
||||||
@@ -688,8 +683,9 @@ class ReportController extends Controller
|
|||||||
'cabang' => $cabang,
|
'cabang' => $cabang,
|
||||||
'year' => $year,
|
'year' => $year,
|
||||||
'month' => $month,
|
'month' => $month,
|
||||||
'budget' => $budget,
|
'kategori_bca' => $kategori_bca,
|
||||||
'kategori_bca' => $kategori_bca
|
'nominals' => $nominals,
|
||||||
|
'budget' => $budget
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ use App\Helpers\NextCloudHelper;
|
|||||||
use Illuminate\Support\Str;
|
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\ExpenseApproved2;
|
||||||
use App\Mail\ExpenseRejected;
|
use App\Mail\ExpenseRejected;
|
||||||
use App\Mail\FinalApprove;
|
use App\Mail\FinalApprove;
|
||||||
use App\Mail\ExpenseCreated;
|
use App\Mail\ExpenseCreated;
|
||||||
@@ -24,6 +25,7 @@ use App\Helpers\AuditTrailHelper;
|
|||||||
use App\Models\Admin;
|
use App\Models\Admin;
|
||||||
use App\Rules\FileType;
|
use App\Rules\FileType;
|
||||||
use App\Helpers\BudgetHelper;
|
use App\Helpers\BudgetHelper;
|
||||||
|
use App\Helpers\NotificationHelper;
|
||||||
|
|
||||||
class FormEntertainmentPresentationController extends Controller
|
class FormEntertainmentPresentationController extends Controller
|
||||||
{
|
{
|
||||||
@@ -37,6 +39,7 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
||||||
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
|
->with('user')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$availableBudget = null;
|
$availableBudget = null;
|
||||||
@@ -126,7 +129,7 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
|
|
||||||
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
|
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
|
||||||
$region = Region::where('id', $cabang->region_id)->first();
|
$region = Region::where('id', $cabang->region_id)->first();
|
||||||
$kategori = Kategori::where('name', 'Entertainment & Presentation')->first();
|
$kategori = Kategori::where('name', 'Entertainment')->first();
|
||||||
|
|
||||||
$filePaths = [];
|
$filePaths = [];
|
||||||
$folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/entertainment';
|
$folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/entertainment';
|
||||||
@@ -165,30 +168,44 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
'status' => 'On Progress',
|
'status' => 'On Progress',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Send notification to MIS and Admin Region
|
|
||||||
$roles = ['Marketing Information System', 'Admin Region'];
|
|
||||||
$recipients = [];
|
|
||||||
$phoneNumbers = [];
|
|
||||||
|
|
||||||
$name = auth()->user()->name;
|
$name = auth()->user()->name;
|
||||||
$tanggal = $form->tanggal;
|
$tanggal = $form->created_at;
|
||||||
$total = $form->total;
|
$total = $form->total;
|
||||||
|
|
||||||
|
// Send notification to MIS and Admin Region and Area Manager Cabang
|
||||||
|
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||||
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
$receiver_ids = [];
|
||||||
|
|
||||||
// Collect all recipients (emails and phone numbers) for the specified roles
|
// Collect all recipients (emails and phone numbers) for the specified roles
|
||||||
foreach ($roles as $role) {
|
foreach ($roles as $role) {
|
||||||
$users = Admin::getUserByRoleName($role);
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang) {
|
||||||
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
|
return $user->cabang && $user->cabang->cabang->id === $cabang->id;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract emails and phone numbers
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
$recipients[] = $user->email;
|
$recipients[] = $user->email;
|
||||||
$phoneNumbers[] = $user->phone;
|
$phoneNumbers[] = $user->phone;
|
||||||
|
$receiver_ids[] = $user->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicate email addresses, if any
|
// Remove duplicate email addresses, if any
|
||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
$receiver_ids = array_unique($receiver_ids);
|
||||||
|
|
||||||
// Generate URL and send WhatsApp notification
|
// Generate URL and send WhatsApp notification
|
||||||
$url = route('forms.entertainment.view', $form->id);
|
$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
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new ExpenseCreated(
|
Mail::to($recipients)->send(new ExpenseCreated(
|
||||||
@@ -199,6 +216,8 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
$url
|
$url
|
||||||
));
|
));
|
||||||
|
|
||||||
|
NotificationHelper::newExpense($form->user_id, $expense_number, $receiver_ids);
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Insert', 'Insert New Expense at Form Entertainment Presentation (' . $expense_number . ')');
|
AuditTrailHelper::AddAuditTrail('Insert', 'Insert New Expense at Form Entertainment Presentation (' . $expense_number . ')');
|
||||||
session()->flash('success', 'Form has been created.');
|
session()->flash('success', 'Form has been created.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
@@ -245,7 +264,7 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
|
|
||||||
$cabang = UserHasCabang::with('cabang')->where('user_id', $form->user_id)->first()->cabang;
|
$cabang = UserHasCabang::with('cabang')->where('user_id', $form->user_id)->first()->cabang;
|
||||||
$region = Region::where('id', $cabang->region_id)->first();
|
$region = Region::where('id', $cabang->region_id)->first();
|
||||||
$kategori = Kategori::where('name', 'Entertainment & Presentation')->first();
|
$kategori = Kategori::where('name', 'Entertainment')->first();
|
||||||
|
|
||||||
$filePaths = [];
|
$filePaths = [];
|
||||||
$folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/entertainment';
|
$folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/entertainment';
|
||||||
@@ -281,57 +300,58 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function approve(Request $request, $id)
|
public function approve($id)
|
||||||
{
|
{
|
||||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
||||||
$request->validate([
|
|
||||||
'total' => 'required',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$form = FormEntertaimentPresentation::findOrfail($id);
|
$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([
|
$form->update([
|
||||||
'approved_at' => now(),
|
'approved_at' => now(),
|
||||||
'approved_by' => auth()->user()->id,
|
'approved_by' => auth()->user()->id,
|
||||||
'status' => 'Approved',
|
'status' => 'Approved 1',
|
||||||
|
|
||||||
'approved_total' => $form->total,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$heads = $form->user->getCabangAndRegionHead();
|
|
||||||
$name = $form->user->name;
|
$name = $form->user->name;
|
||||||
$expense_number = $form->expense_number;
|
$expense_number = $form->expense_number;
|
||||||
$tanggal = $form->tanggal;
|
$tanggal = $form->created_at;
|
||||||
$total = $form->approved_total;
|
$total = $form->total;
|
||||||
|
|
||||||
// Collect all recipients
|
// Collect all recipients
|
||||||
|
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang'];
|
||||||
|
$receiver_ids = [];
|
||||||
$recipients = [$form->user->email, auth()->user()->email];
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
|
||||||
if ($heads['cabang_head']) {
|
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||||
$recipients[] = $heads['cabang_head']['email'];
|
foreach ($roles as $role) {
|
||||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||||
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
|
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract emails and phone numbers
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$recipients[] = $user->email;
|
||||||
|
$phoneNumbers[] = $user->phone;
|
||||||
|
$receiver_ids[] = $user->id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($heads['region_head']) {
|
// Remove duplicate data, if any
|
||||||
$recipients[] = $heads['region_head']['email'];
|
|
||||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove duplicate email addresses, if any
|
|
||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
$phoneNumbers = array_unique($phoneNumbers);
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
$receiver_ids = array_unique($receiver_ids);
|
||||||
|
|
||||||
// Send bulk whatsapp
|
// send whatsapp message
|
||||||
$url = route('forms.entertainment.view', $form->id);
|
$url = route('forms.entertainment.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(
|
Mail::to($recipients)->send(new ExpenseApproved(
|
||||||
$name,
|
$name,
|
||||||
$expense_number,
|
$expense_number,
|
||||||
@@ -340,32 +360,167 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
$url
|
$url
|
||||||
));
|
));
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Approve', 'Approved Expense at Form Entertainment Presentation (' . $expense_number . ')');
|
NotificationHelper::approveExpense($form->user_id, $expense_number, $receiver_ids);
|
||||||
|
|
||||||
|
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Entertainment (' . $form->expense_number . ')');
|
||||||
session()->flash('success', 'Form has been approved.');
|
session()->flash('success', 'Form has been approved.');
|
||||||
return redirect()->back();
|
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',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$name = $form->user->name;
|
||||||
|
$expense_number = $form->expense_number;
|
||||||
|
$tanggal = $form->created_at;
|
||||||
|
$total = $form->total;
|
||||||
|
|
||||||
|
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||||
|
$receiver_ids = [];
|
||||||
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
|
||||||
|
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||||
|
|
||||||
|
foreach ($roles as $role) {
|
||||||
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||||
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
|
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract emails and phone numbers
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$recipients[] = $user->email;
|
||||||
|
$phoneNumbers[] = $user->phone;
|
||||||
|
$receiver_ids[] = $user->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove duplicate data, if any
|
||||||
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
$receiver_ids = array_unique($receiver_ids);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
));
|
||||||
|
|
||||||
|
NotificationHelper::approve2Expense($form->user_id, $expense_number, $receiver_ids);
|
||||||
|
|
||||||
|
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']);
|
$this->checkAuthorization(auth()->user(), ['final_approval.approve']);
|
||||||
|
|
||||||
$form = FormEntertaimentPresentation::findOrfail($id);
|
$form = FormEntertaimentPresentation::findOrfail($id);
|
||||||
if($form->approved_at == null) {
|
if($form->approved_at == null || $form->approved2_at == null) {
|
||||||
session()->flash('error', 'Form must be approved by MIS first.');
|
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();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
$form->update([
|
$form->update([
|
||||||
'final_approved_at' => now(),
|
'final_approved_at' => now(),
|
||||||
'final_approved_by' => auth()->user()->id,
|
'final_approved_by' => auth()->user()->id,
|
||||||
'status' => 'Closed'
|
'status' => 'Closed',
|
||||||
|
'approved_total' => $form->total,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$name = $form->user->name;
|
||||||
|
$expense_number = $form->expense_number;
|
||||||
|
$tanggal = $form->created_at;
|
||||||
|
$total = $form->approved_total;
|
||||||
|
|
||||||
|
$roles = ['Head of Sales Marketing', 'Marketing Operational Manager Region'];
|
||||||
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
|
||||||
|
foreach ($roles as $role) {
|
||||||
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||||
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
|
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract emails and phone numbers
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$recipients[] = $user->email;
|
||||||
|
$phoneNumbers[] = $user->phone;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove duplicate email addresses, if any
|
||||||
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
|
||||||
|
// send whatsapp message
|
||||||
|
$url = route('forms.entertainment.view', $form->id);
|
||||||
|
WhatsappHelper::finalApprove($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||||
|
|
||||||
|
// Send bulk email
|
||||||
|
Mail::to($recipients)->send(new FinalApprove(
|
||||||
|
$name,
|
||||||
|
$expense_number,
|
||||||
|
$tanggal,
|
||||||
|
$total,
|
||||||
|
$url
|
||||||
|
));
|
||||||
|
|
||||||
|
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 reject($id)
|
||||||
|
{
|
||||||
|
$this->checkAuthorization(auth()->user(), ['approval.reject']);
|
||||||
|
|
||||||
|
$form = FormEntertaimentPresentation::findOrfail($id);
|
||||||
|
$form->update([
|
||||||
|
'status' => 'Rejected'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$heads = $form->user->getCabangAndRegionHead();
|
$heads = $form->user->getCabangAndRegionHead();
|
||||||
$name = $form->user->name;
|
$name = $form->user->name;
|
||||||
$expense_number = $form->expense_number;
|
$expense_number = $form->expense_number;
|
||||||
$tanggal = $form->tanggal;
|
$tanggal = $form->created_at;
|
||||||
$total = $form->approved_total;
|
$total = $form->total;
|
||||||
|
|
||||||
// Collect all recipients
|
// Collect all recipients
|
||||||
$recipients = [$form->user->email, auth()->user()->email];
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
@@ -387,10 +542,10 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
|
|
||||||
// send whatsapp message
|
// send whatsapp message
|
||||||
$url = route('forms.entertainment.view', $form->id);
|
$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
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new FinalApprove(
|
Mail::to($recipients)->send(new ExpenseRejected(
|
||||||
$name,
|
$name,
|
||||||
$expense_number,
|
$expense_number,
|
||||||
$tanggal,
|
$tanggal,
|
||||||
@@ -398,8 +553,8 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
$url
|
$url
|
||||||
));
|
));
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Final Approve', 'Final Approved Expense at Form Entertainment Presentation (' . $expense_number . ')');
|
AuditTrailHelper::AddAuditTrail('Reject', 'Reject Expense at Form Entertainment (' . $form->expense_number . ')');
|
||||||
session()->flash('success', 'Form has been final approved.');
|
session()->flash('success', 'Form has been rejected.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,57 +574,6 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reject($id)
|
|
||||||
{
|
|
||||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
|
||||||
|
|
||||||
$form = FormEntertaimentPresentation::findOrfail($id);
|
|
||||||
$form->update([
|
|
||||||
'status' => 'Rejected'
|
|
||||||
]);
|
|
||||||
|
|
||||||
$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 whatsapp
|
|
||||||
$url = route('forms.entertainment.view', $form->id);
|
|
||||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url);
|
|
||||||
|
|
||||||
// Send bulk email
|
|
||||||
Mail::to($recipients)->send(new ExpenseRejected(
|
|
||||||
$name,
|
|
||||||
$expense_number,
|
|
||||||
$tanggal,
|
|
||||||
$total,
|
|
||||||
$url
|
|
||||||
));
|
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Reject', 'Reject Expense at Form Entertainment Presentation (' . $expense_number . ')');
|
|
||||||
session()->flash('success', 'Form has been rejected.');
|
|
||||||
return redirect()->back();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function destroy($id)
|
public function destroy($id)
|
||||||
{
|
{
|
||||||
$this->checkAuthorization(auth()->user(), ['forms.entertainment.delete']);
|
$this->checkAuthorization(auth()->user(), ['forms.entertainment.delete']);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ use App\Helpers\NextCloudHelper;
|
|||||||
use Illuminate\Support\Str;
|
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\ExpenseApproved2;
|
||||||
use App\Mail\ExpenseRejected;
|
use App\Mail\ExpenseRejected;
|
||||||
use App\Mail\ExpenseCreated;
|
use App\Mail\ExpenseCreated;
|
||||||
use App\Mail\FinalApprove;
|
use App\Mail\FinalApprove;
|
||||||
@@ -24,6 +25,7 @@ use App\Helpers\AuditTrailHelper;
|
|||||||
use App\Rules\FileType;
|
use App\Rules\FileType;
|
||||||
use App\Models\Admin;
|
use App\Models\Admin;
|
||||||
use App\Helpers\BudgetHelper;
|
use App\Helpers\BudgetHelper;
|
||||||
|
use App\Helpers\NotificationHelper;
|
||||||
|
|
||||||
class FormMeetingSeminarController extends Controller
|
class FormMeetingSeminarController extends Controller
|
||||||
{
|
{
|
||||||
@@ -37,6 +39,7 @@ class FormMeetingSeminarController extends Controller
|
|||||||
->where('created_at', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
->where('created_at', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
||||||
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
|
->with('user')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$availableBudget = null;
|
$availableBudget = null;
|
||||||
@@ -81,7 +84,7 @@ class FormMeetingSeminarController extends Controller
|
|||||||
|
|
||||||
public function detail($id)
|
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 = FormMeetingSeminar::with('user')->findOrFail($id);
|
||||||
$form->bukti_allowance = $form->bukti_allowance ? NextCloudHelper::getFileUrl($form->bukti_allowance) : null;
|
$form->bukti_allowance = $form->bukti_allowance ? NextCloudHelper::getFileUrl($form->bukti_allowance) : null;
|
||||||
@@ -93,7 +96,7 @@ class FormMeetingSeminarController extends Controller
|
|||||||
|
|
||||||
public function view($id)
|
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 = FormMeetingSeminar::with('user')->findOrFail($id);
|
||||||
$form->bukti_allowance = $form->bukti_allowance ? NextCloudHelper::getFileUrl($form->bukti_allowance) : null;
|
$form->bukti_allowance = $form->bukti_allowance ? NextCloudHelper::getFileUrl($form->bukti_allowance) : null;
|
||||||
@@ -127,7 +130,7 @@ class FormMeetingSeminarController extends Controller
|
|||||||
|
|
||||||
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
|
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
|
||||||
$region = Region::where('id', $cabang->region_id)->first();
|
$region = Region::where('id', $cabang->region_id)->first();
|
||||||
$kategori = Kategori::where('name', 'Meeting & Seminar')->first();
|
$kategori = Kategori::where('name', 'Meeting / Seminar')->first();
|
||||||
|
|
||||||
$filePaths = [];
|
$filePaths = [];
|
||||||
$folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/meeting';
|
$folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/meeting';
|
||||||
@@ -203,30 +206,44 @@ class FormMeetingSeminarController extends Controller
|
|||||||
'status' => 'On Progress',
|
'status' => 'On Progress',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Send notification to MIS and Admin Region
|
|
||||||
$roles = ['Marketing Information System', 'Admin Region'];
|
|
||||||
$recipients = [];
|
|
||||||
$phoneNumbers = [];
|
|
||||||
|
|
||||||
$name = auth()->user()->name;
|
$name = auth()->user()->name;
|
||||||
$tanggal = $form->created_at;
|
$tanggal = $form->created_at;
|
||||||
$total = $form->total;
|
$total = $form->total;
|
||||||
|
|
||||||
|
// Send notification to MIS and Admin Region and Area Manager Cabang
|
||||||
|
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||||
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
$receiver_ids = [];
|
||||||
|
|
||||||
// Collect all recipients (emails and phone numbers) for the specified roles
|
// Collect all recipients (emails and phone numbers) for the specified roles
|
||||||
foreach ($roles as $role) {
|
foreach ($roles as $role) {
|
||||||
$users = Admin::getUserByRoleName($role);
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang) {
|
||||||
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
|
return $user->cabang && $user->cabang->cabang->id === $cabang->id;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract emails and phone numbers
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
$recipients[] = $user->email;
|
$recipients[] = $user->email;
|
||||||
$phoneNumbers[] = $user->phone;
|
$phoneNumbers[] = $user->phone;
|
||||||
|
$receiver_ids[] = $user->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicate email addresses, if any
|
// Remove duplicate email addresses, if any
|
||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
$receiver_ids = array_unique($receiver_ids);
|
||||||
|
|
||||||
// Generate URL and send WhatsApp notification
|
// Generate URL and send WhatsApp notification
|
||||||
$url = route('forms.meeting.view', $form->id);
|
$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
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new ExpenseCreated(
|
Mail::to($recipients)->send(new ExpenseCreated(
|
||||||
@@ -237,6 +254,8 @@ class FormMeetingSeminarController extends Controller
|
|||||||
$url
|
$url
|
||||||
));
|
));
|
||||||
|
|
||||||
|
NotificationHelper::newExpense($form->user_id, $expense_number, $receiver_ids);
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Insert', 'Insert New Expense at Form Meeting Seminar (' . $expense_number . ')');
|
AuditTrailHelper::AddAuditTrail('Insert', 'Insert New Expense at Form Meeting Seminar (' . $expense_number . ')');
|
||||||
session()->flash('success', 'Form has been created.');
|
session()->flash('success', 'Form has been created.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
@@ -280,7 +299,7 @@ class FormMeetingSeminarController extends Controller
|
|||||||
|
|
||||||
$cabang = UserHasCabang::with('cabang')->where('user_id', $form->user_id)->first()->cabang;
|
$cabang = UserHasCabang::with('cabang')->where('user_id', $form->user_id)->first()->cabang;
|
||||||
$region = Region::where('id', $cabang->region_id)->first();
|
$region = Region::where('id', $cabang->region_id)->first();
|
||||||
$kategori = Kategori::where('name', 'Meeting & Seminar')->first();
|
$kategori = Kategori::where('name', 'Meeting / Seminar')->first();
|
||||||
|
|
||||||
$filePaths = [];
|
$filePaths = [];
|
||||||
$folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/meeting';
|
$folderPath = '/expense/' . $region->code . '/' . $cabang->code . '/meeting';
|
||||||
@@ -353,11 +372,150 @@ class FormMeetingSeminarController extends Controller
|
|||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function approve(Request $request, $id)
|
public function approve($id)
|
||||||
{
|
{
|
||||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
||||||
|
|
||||||
$form = FormMeetingSeminar::findOrfail($id);
|
$form = FormMeetingSeminar::findOrfail($id);
|
||||||
|
$form->update([
|
||||||
|
'approved_at' => now(),
|
||||||
|
'approved_by' => auth()->user()->id,
|
||||||
|
'status' => 'Approved 1',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$name = $form->user->name;
|
||||||
|
$expense_number = $form->expense_number;
|
||||||
|
$tanggal = $form->created_at;
|
||||||
|
$total = $form->total;
|
||||||
|
|
||||||
|
// Collect all recipients
|
||||||
|
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang'];
|
||||||
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
$receiver_ids = [];
|
||||||
|
|
||||||
|
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||||
|
foreach ($roles as $role) {
|
||||||
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||||
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
|
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract emails and phone numbers
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$recipients[] = $user->email;
|
||||||
|
$phoneNumbers[] = $user->phone;
|
||||||
|
$receiver_ids[] = $user->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove duplicate data, if any
|
||||||
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
$receiver_ids = array_unique($receiver_ids);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
));
|
||||||
|
|
||||||
|
NotificationHelper::approveExpense($form->user_id, $expense_number, $receiver_ids);
|
||||||
|
|
||||||
|
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',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$name = $form->user->name;
|
||||||
|
$expense_number = $form->expense_number;
|
||||||
|
$tanggal = $form->created_at;
|
||||||
|
$total = $form->total;
|
||||||
|
|
||||||
|
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||||
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
$receiver_ids = [];
|
||||||
|
|
||||||
|
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||||
|
|
||||||
|
foreach ($roles as $role) {
|
||||||
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||||
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
|
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract emails and phone numbers
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$recipients[] = $user->email;
|
||||||
|
$phoneNumbers[] = $user->phone;
|
||||||
|
$receiver_ids[] = $user->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove duplicate data, if any
|
||||||
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
$receiver_ids = array_unique($receiver_ids);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
));
|
||||||
|
|
||||||
|
NotificationHelper::approve2Expense($form->user_id, $expense_number, $receiver_ids);
|
||||||
|
|
||||||
|
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 = [
|
$approved_data = [
|
||||||
'allowance' => $request->allowance ? $form->allowance : 0,
|
'allowance' => $request->allowance ? $form->allowance : 0,
|
||||||
'transport_ankot' => $request->transport_ankot ? $form->transport_ankot : 0,
|
'transport_ankot' => $request->transport_ankot ? $form->transport_ankot : 0,
|
||||||
@@ -372,91 +530,40 @@ class FormMeetingSeminarController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$form->update([
|
$form->update([
|
||||||
'approved_at' => now(),
|
'final_approved_at' => now(),
|
||||||
'approved_by' => auth()->user()->id,
|
'final_approved_by' => auth()->user()->id,
|
||||||
'status' => 'Approved',
|
'status' => 'Closed',
|
||||||
'approved_allowance' => $approved_data['allowance'],
|
'approved_allowance' => $approved_data['allowance'],
|
||||||
'approved_transport_ankot' => $approved_data['transport_ankot'],
|
'approved_transport_ankot' => $approved_data['transport_ankot'],
|
||||||
'approved_hotel' => $approved_data['hotel'],
|
'approved_hotel' => $approved_data['hotel'],
|
||||||
'approved_total' => array_sum($approved_data),
|
'approved_total' => array_sum($approved_data),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$heads = $form->user->getCabangAndRegionHead();
|
|
||||||
$name = $form->user->name;
|
$name = $form->user->name;
|
||||||
$expense_number = $form->expense_number;
|
$expense_number = $form->expense_number;
|
||||||
$tanggal = $form->created_at;
|
$tanggal = $form->created_at;
|
||||||
$total = $form->approved_total;
|
$total = $form->approved_total;
|
||||||
|
|
||||||
// Collect all recipients
|
$roles = ['Head of Sales Marketing', 'Marketing Operational Manager Region'];
|
||||||
$recipients = [$form->user->email, auth()->user()->email];
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
|
||||||
if ($heads['cabang_head']) {
|
foreach ($roles as $role) {
|
||||||
$recipients[] = $heads['cabang_head']['email'];
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
}
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if ($heads['region_head']) {
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
$recipients[] = $heads['region_head']['email'];
|
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// Remove duplicate email addresses, if any
|
// Extract emails and phone numbers
|
||||||
$recipients = array_unique($recipients);
|
foreach ($users as $user) {
|
||||||
$phoneNumbers = array_unique($phoneNumbers);
|
$recipients[] = $user->email;
|
||||||
|
$phoneNumbers[] = $user->phone;
|
||||||
// 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
|
// Remove duplicate email addresses, if any
|
||||||
@@ -465,7 +572,7 @@ class FormMeetingSeminarController extends Controller
|
|||||||
|
|
||||||
// send whatsapp message
|
// send whatsapp message
|
||||||
$url = route('forms.meeting.view', $form->id);
|
$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
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new FinalApprove(
|
Mail::to($recipients)->send(new FinalApprove(
|
||||||
@@ -481,25 +588,9 @@ class FormMeetingSeminarController extends Controller
|
|||||||
return redirect()->back();
|
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)
|
public function reject($id)
|
||||||
{
|
{
|
||||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
$this->checkAuthorization(auth()->user(), ['approval.reject']);
|
||||||
|
|
||||||
$form = FormMeetingSeminar::findOrfail($id);
|
$form = FormMeetingSeminar::findOrfail($id);
|
||||||
$form->update([
|
$form->update([
|
||||||
@@ -530,9 +621,9 @@ class FormMeetingSeminarController extends Controller
|
|||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
$phoneNumbers = array_unique($phoneNumbers);
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
|
||||||
// Send bulk WhatsApp message
|
// send whatsapp message
|
||||||
$url = route('forms.meeting.view', $form->id);
|
$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
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new ExpenseRejected(
|
Mail::to($recipients)->send(new ExpenseRejected(
|
||||||
@@ -548,6 +639,22 @@ class FormMeetingSeminarController extends Controller
|
|||||||
return redirect()->back();
|
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)
|
public function destroy($id)
|
||||||
{
|
{
|
||||||
$this->checkAuthorization(auth()->user(), ['forms.meeting.delete']);
|
$this->checkAuthorization(auth()->user(), ['forms.meeting.delete']);
|
||||||
|
|||||||
@@ -5,17 +5,14 @@ namespace App\Http\Controllers\Forms;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\FormOthers;
|
use App\Models\FormOthers;
|
||||||
use App\Models\Rayon;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use App\Models\Region;
|
use App\Models\Region;
|
||||||
use App\Models\Cabang;
|
|
||||||
use App\Models\UserHasCabang;
|
use App\Models\UserHasCabang;
|
||||||
use App\Models\Kategori;
|
use App\Models\Kategori;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use App\Helpers\NextCloudHelper;
|
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\ExpenseApproved2;
|
||||||
use App\Mail\ExpenseRejected;
|
use App\Mail\ExpenseRejected;
|
||||||
use App\Mail\FinalApprove;
|
use App\Mail\FinalApprove;
|
||||||
use App\Mail\ExpenseCreated;
|
use App\Mail\ExpenseCreated;
|
||||||
@@ -24,6 +21,7 @@ use App\Helpers\AuditTrailHelper;
|
|||||||
use App\Rules\FileType;
|
use App\Rules\FileType;
|
||||||
use App\Models\Admin;
|
use App\Models\Admin;
|
||||||
use App\Helpers\BudgetHelper;
|
use App\Helpers\BudgetHelper;
|
||||||
|
use App\Helpers\NotificationHelper;
|
||||||
|
|
||||||
class FormOtherController extends Controller
|
class FormOtherController extends Controller
|
||||||
{
|
{
|
||||||
@@ -37,6 +35,7 @@ class FormOtherController extends Controller
|
|||||||
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
||||||
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
|
->with(['user', 'kategori'])
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$availableBudget = null;
|
$availableBudget = null;
|
||||||
@@ -163,30 +162,44 @@ class FormOtherController extends Controller
|
|||||||
'status' => 'On Progress',
|
'status' => 'On Progress',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Send notification to MIS and Admin Region
|
|
||||||
$roles = ['Marketing Information System', 'Admin Region'];
|
|
||||||
$recipients = [];
|
|
||||||
$phoneNumbers = [];
|
|
||||||
|
|
||||||
$name = auth()->user()->name;
|
$name = auth()->user()->name;
|
||||||
$tanggal = $request->tanggal;
|
$tanggal = $request->tanggal;
|
||||||
$total = $request->total;
|
$total = $request->total;
|
||||||
|
|
||||||
|
// Send notification to MIS and Admin Region and Area Manager Cabang
|
||||||
|
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||||
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
$receiver_ids = [];
|
||||||
|
|
||||||
// Collect all recipients (emails and phone numbers) for the specified roles
|
// Collect all recipients (emails and phone numbers) for the specified roles
|
||||||
foreach ($roles as $role) {
|
foreach ($roles as $role) {
|
||||||
$users = Admin::getUserByRoleName($role);
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang) {
|
||||||
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
|
return $user->cabang && $user->cabang->cabang->id === $cabang->id;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract emails and phone numbers
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
$recipients[] = $user->email;
|
$recipients[] = $user->email;
|
||||||
$phoneNumbers[] = $user->phone;
|
$phoneNumbers[] = $user->phone;
|
||||||
|
$receiver_ids[] = $user->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicate email addresses, if any
|
// Remove duplicate email addresses, if any
|
||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
$receiver_ids = array_unique($receiver_ids);
|
||||||
|
|
||||||
// Generate URL and send WhatsApp notification
|
// Generate URL and send WhatsApp notification
|
||||||
$url = route('forms.other.view', $form->id);
|
$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
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new ExpenseCreated(
|
Mail::to($recipients)->send(new ExpenseCreated(
|
||||||
@@ -197,6 +210,9 @@ class FormOtherController extends Controller
|
|||||||
$url
|
$url
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Send notification to the user
|
||||||
|
NotificationHelper::newExpense($form->user_id, $expense_number, $receiver_ids);
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Insert', 'Insert New Expense at Form Other (' . $expense_number . ')');
|
AuditTrailHelper::AddAuditTrail('Insert', 'Insert New Expense at Form Other (' . $expense_number . ')');
|
||||||
session()->flash('success', 'Form has been created.');
|
session()->flash('success', 'Form has been created.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
@@ -274,58 +290,58 @@ class FormOtherController extends Controller
|
|||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function approve(Request $request, $id)
|
public function approve($id)
|
||||||
{
|
{
|
||||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
||||||
|
|
||||||
$request->validate([
|
|
||||||
'total' => 'required',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$form = FormOthers::findOrfail($id);
|
$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([
|
$form->update([
|
||||||
'approved_at' => now(),
|
'approved_at' => now(),
|
||||||
'approved_by' => auth()->user()->id,
|
'approved_by' => auth()->user()->id,
|
||||||
'status' => 'Approved',
|
'status' => 'Approved 1',
|
||||||
|
|
||||||
'approved_total' => $form->total,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$heads = $form->user->getCabangAndRegionHead();
|
|
||||||
$name = $form->user->name;
|
$name = $form->user->name;
|
||||||
$expense_number = $form->expense_number;
|
$expense_number = $form->expense_number;
|
||||||
$tanggal = $form->tanggal;
|
$tanggal = $form->created_at;
|
||||||
$total = $form->approved_total;
|
$total = $form->total;
|
||||||
|
|
||||||
// Collect all recipients
|
// Collect all recipients
|
||||||
|
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang'];
|
||||||
$recipients = [$form->user->email, auth()->user()->email];
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
$receiver_ids = [];
|
||||||
|
|
||||||
if ($heads['cabang_head']) {
|
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||||
$recipients[] = $heads['cabang_head']['email'];
|
foreach ($roles as $role) {
|
||||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||||
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
|
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract emails and phone numbers
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$recipients[] = $user->email;
|
||||||
|
$phoneNumbers[] = $user->phone;
|
||||||
|
$receiver_ids[] = $user->id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($heads['region_head']) {
|
// Remove duplicate data, if any
|
||||||
$recipients[] = $heads['region_head']['email'];
|
|
||||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove duplicate email addresses, if any
|
|
||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
$phoneNumbers = array_unique($phoneNumbers);
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
$receiver_ids = array_unique($receiver_ids);
|
||||||
|
|
||||||
// Send bulk WhatsApp message
|
// send whatsapp message
|
||||||
$url = route('forms.other.view', $form->id);
|
$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(
|
Mail::to($recipients)->send(new ExpenseApproved(
|
||||||
$name,
|
$name,
|
||||||
$expense_number,
|
$expense_number,
|
||||||
@@ -334,32 +350,167 @@ class FormOtherController extends Controller
|
|||||||
$url
|
$url
|
||||||
));
|
));
|
||||||
|
|
||||||
|
NotificationHelper::approveExpense($form->user_id, $expense_number, $receiver_ids);
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Other (' . $form->expense_number . ')');
|
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Other (' . $form->expense_number . ')');
|
||||||
session()->flash('success', 'Form has been approved.');
|
session()->flash('success', 'Form has been approved.');
|
||||||
return redirect()->back();
|
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',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$name = $form->user->name;
|
||||||
|
$expense_number = $form->expense_number;
|
||||||
|
$tanggal = $form->created_at;
|
||||||
|
$total = $form->total;
|
||||||
|
|
||||||
|
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||||
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
$receiver_ids = [];
|
||||||
|
|
||||||
|
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||||
|
|
||||||
|
foreach ($roles as $role) {
|
||||||
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||||
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
|
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract emails and phone numbers
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$recipients[] = $user->email;
|
||||||
|
$phoneNumbers[] = $user->phone;
|
||||||
|
$receiver_ids[] = $user->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove duplicate data, if any
|
||||||
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
$receiver_ids = array_unique($receiver_ids);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
));
|
||||||
|
|
||||||
|
NotificationHelper::approve2Expense($form->user_id, $expense_number, $receiver_ids);
|
||||||
|
|
||||||
|
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']);
|
$this->checkAuthorization(auth()->user(), ['final_approval.approve']);
|
||||||
|
|
||||||
$form = FormOthers::findOrfail($id);
|
$form = FormOthers::findOrfail($id);
|
||||||
if($form->approved_at == null) {
|
if($form->approved_at == null || $form->approved2_at == null) {
|
||||||
session()->flash('error', 'Form must be approved by MIS first.');
|
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();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
$form->update([
|
$form->update([
|
||||||
'final_approved_at' => now(),
|
'final_approved_at' => now(),
|
||||||
'final_approved_by' => auth()->user()->id,
|
'final_approved_by' => auth()->user()->id,
|
||||||
'status' => 'Closed'
|
'status' => 'Closed',
|
||||||
|
'approved_total' => $form->total,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$name = $form->user->name;
|
||||||
|
$expense_number = $form->expense_number;
|
||||||
|
$tanggal = $form->created_at;
|
||||||
|
$total = $form->approved_total;
|
||||||
|
|
||||||
|
$roles = ['Head of Sales Marketing', 'Marketing Operational Manager Region'];
|
||||||
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
|
||||||
|
foreach ($roles as $role) {
|
||||||
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||||
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
|
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract emails and phone numbers
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$recipients[] = $user->email;
|
||||||
|
$phoneNumbers[] = $user->phone;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove duplicate email addresses, if any
|
||||||
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
|
||||||
|
// send whatsapp message
|
||||||
|
$url = route('forms.other.view', $form->id);
|
||||||
|
WhatsappHelper::finalApprove($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||||
|
|
||||||
|
// Send bulk email
|
||||||
|
Mail::to($recipients)->send(new FinalApprove(
|
||||||
|
$name,
|
||||||
|
$expense_number,
|
||||||
|
$tanggal,
|
||||||
|
$total,
|
||||||
|
$url
|
||||||
|
));
|
||||||
|
|
||||||
|
AuditTrailHelper::AddAuditTrail('Final Approve', 'Final Approve Expense at Form Other (' . $form->expense_number . ')');
|
||||||
|
session()->flash('success', 'Form has been final approved.');
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function reject($id)
|
||||||
|
{
|
||||||
|
$this->checkAuthorization(auth()->user(), ['approval.reject']);
|
||||||
|
|
||||||
|
$form = FormOthers::findOrfail($id);
|
||||||
|
$form->update([
|
||||||
|
'status' => 'Rejected'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$heads = $form->user->getCabangAndRegionHead();
|
$heads = $form->user->getCabangAndRegionHead();
|
||||||
$name = $form->user->name;
|
$name = $form->user->name;
|
||||||
$expense_number = $form->expense_number;
|
$expense_number = $form->expense_number;
|
||||||
$tanggal = $form->tanggal;
|
$tanggal = $form->created_at;
|
||||||
$total = $form->approved_total;
|
$total = $form->total;
|
||||||
|
|
||||||
// Collect all recipients
|
// Collect all recipients
|
||||||
$recipients = [$form->user->email, auth()->user()->email];
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
@@ -381,10 +532,10 @@ class FormOtherController extends Controller
|
|||||||
|
|
||||||
// send whatsapp message
|
// send whatsapp message
|
||||||
$url = route('forms.other.view', $form->id);
|
$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
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new FinalApprove(
|
Mail::to($recipients)->send(new ExpenseRejected(
|
||||||
$name,
|
$name,
|
||||||
$expense_number,
|
$expense_number,
|
||||||
$tanggal,
|
$tanggal,
|
||||||
@@ -392,8 +543,8 @@ class FormOtherController extends Controller
|
|||||||
$url
|
$url
|
||||||
));
|
));
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Final Approve', 'Final Approve Expense at Form Other (' . $form->expense_number . ')');
|
AuditTrailHelper::AddAuditTrail('Reject', 'Reject Expense at Form Other (' . $form->expense_number . ')');
|
||||||
session()->flash('success', 'Form has been final approved.');
|
session()->flash('success', 'Form has been rejected.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,57 +564,6 @@ class FormOtherController extends Controller
|
|||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reject($id)
|
|
||||||
{
|
|
||||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
|
||||||
|
|
||||||
$form = FormOthers::findOrfail($id);
|
|
||||||
$form->update([
|
|
||||||
'status' => 'Rejected'
|
|
||||||
]);
|
|
||||||
|
|
||||||
$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 WhatsApp message
|
|
||||||
$url = route('forms.other.view', $form->id);
|
|
||||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url);
|
|
||||||
|
|
||||||
// Send bulk email
|
|
||||||
Mail::to($recipients)->send(new ExpenseRejected(
|
|
||||||
$name,
|
|
||||||
$expense_number,
|
|
||||||
$tanggal,
|
|
||||||
$total,
|
|
||||||
$url
|
|
||||||
));
|
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Reject', 'Reject Expense at Form Other (' . $form->expense_number . ')');
|
|
||||||
session()->flash('success', 'Form has been rejected.');
|
|
||||||
return redirect()->back();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function destroy($id)
|
public function destroy($id)
|
||||||
{
|
{
|
||||||
$this->checkAuthorization(auth()->user(), ['forms.other.delete']);
|
$this->checkAuthorization(auth()->user(), ['forms.other.delete']);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use App\Models\Kategori;
|
|||||||
use Illuminate\Support\Str;
|
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\ExpenseApproved2;
|
||||||
use App\Mail\ExpenseRejected;
|
use App\Mail\ExpenseRejected;
|
||||||
use App\Mail\FinalApprove;
|
use App\Mail\FinalApprove;
|
||||||
use App\Mail\ExpenseCreated;
|
use App\Mail\ExpenseCreated;
|
||||||
@@ -24,6 +25,7 @@ use App\Helpers\NextCloudHelper;
|
|||||||
use App\Rules\FileType;
|
use App\Rules\FileType;
|
||||||
use App\Models\Admin;
|
use App\Models\Admin;
|
||||||
use App\Helpers\BudgetHelper;
|
use App\Helpers\BudgetHelper;
|
||||||
|
use App\Helpers\NotificationHelper;
|
||||||
|
|
||||||
class FormUpCountryController extends Controller
|
class FormUpCountryController extends Controller
|
||||||
{
|
{
|
||||||
@@ -37,6 +39,7 @@ class FormUpCountryController extends Controller
|
|||||||
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
||||||
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
|
->with(['rayon', 'user'])
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$availableBudget = null;
|
$availableBudget = null;
|
||||||
@@ -234,10 +237,11 @@ class FormUpCountryController extends Controller
|
|||||||
'status' => 'On Progress',
|
'status' => 'On Progress',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Send notification to MIS and Admin Region
|
// Send notification to MIS and Admin Region and Area Manager Cabang
|
||||||
$roles = ['Marketing Information System', 'Admin Region'];
|
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||||
$recipients = [];
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
$phoneNumbers = [];
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
$receiver_ids = [];
|
||||||
|
|
||||||
$name = auth()->user()->name;
|
$name = auth()->user()->name;
|
||||||
$tanggal = $form->tanggal;
|
$tanggal = $form->tanggal;
|
||||||
@@ -245,19 +249,32 @@ class FormUpCountryController extends Controller
|
|||||||
|
|
||||||
// Collect all recipients (emails and phone numbers) for the specified roles
|
// Collect all recipients (emails and phone numbers) for the specified roles
|
||||||
foreach ($roles as $role) {
|
foreach ($roles as $role) {
|
||||||
$users = Admin::getUserByRoleName($role);
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang) {
|
||||||
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
|
return $user->cabang && $user->cabang->cabang->id === $cabang->id;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract emails and phone numbers
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
$recipients[] = $user->email;
|
$recipients[] = $user->email;
|
||||||
$phoneNumbers[] = $user->phone;
|
$phoneNumbers[] = $user->phone;
|
||||||
|
$receiver_ids[] = $user->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicate email addresses, if any
|
// Remove duplicate email addresses, if any
|
||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
$receiver_ids = array_unique($receiver_ids);
|
||||||
|
|
||||||
// Generate URL and send WhatsApp notification
|
// Generate URL and send WhatsApp notification
|
||||||
$url = route('forms.up-country.view', $form->id);
|
$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
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new ExpenseCreated(
|
Mail::to($recipients)->send(new ExpenseCreated(
|
||||||
@@ -268,6 +285,8 @@ class FormUpCountryController extends Controller
|
|||||||
$url
|
$url
|
||||||
));
|
));
|
||||||
|
|
||||||
|
NotificationHelper::newExpense($form->user_id, $expense_number, $receiver_ids);
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Insert', 'Insert New Expense at Form Up Country (' . $expense_number . ')');
|
AuditTrailHelper::AddAuditTrail('Insert', 'Insert New Expense at Form Up Country (' . $expense_number . ')');
|
||||||
session()->flash('success', 'Form has been created.');
|
session()->flash('success', 'Form has been created.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
@@ -279,8 +298,8 @@ class FormUpCountryController extends Controller
|
|||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
|
|
||||||
$form = FormUpCountry::with('rayon')->findOrfail($id);
|
$form = FormUpCountry::with('rayon')->findOrfail($id);
|
||||||
if($form->status != 'On Progress' && $role == 'Medical Representatif') {
|
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 rejected.');
|
session()->flash('error', 'You cannot edit this form because it has been approved or closed.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,8 +330,8 @@ class FormUpCountryController extends Controller
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$form = FormUpCountry::findOrfail($id);
|
$form = FormUpCountry::findOrfail($id);
|
||||||
if($form->status != 'On Progress' && $role == 'Medical Representatif') {
|
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 rejected.');
|
session()->flash('error', 'You cannot edit this form because it has been approved or closed.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,11 +429,149 @@ class FormUpCountryController extends Controller
|
|||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function approve(Request $request, $id)
|
public function approve($id)
|
||||||
{
|
{
|
||||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
||||||
|
|
||||||
$form = FormUpCountry::findOrfail($id);
|
$form = FormUpCountry::findOrfail($id);
|
||||||
|
$form->update([
|
||||||
|
'approved_at' => now(),
|
||||||
|
'approved_by' => auth()->user()->id,
|
||||||
|
'status' => 'Approved 1',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$name = $form->user->name;
|
||||||
|
$expense_number = $form->expense_number;
|
||||||
|
$tanggal = $form->tanggal;
|
||||||
|
$total = $form->total;
|
||||||
|
|
||||||
|
// Collect all recipients
|
||||||
|
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang'];
|
||||||
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
$receiver_ids = [];
|
||||||
|
|
||||||
|
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||||
|
foreach ($roles as $role) {
|
||||||
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||||
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
|
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract emails and phone numbers
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$recipients[] = $user->email;
|
||||||
|
$phoneNumbers[] = $user->phone;
|
||||||
|
$receiver_ids[] = $user->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove duplicate data, if any
|
||||||
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
$receiver_ids = array_unique($receiver_ids);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
));
|
||||||
|
|
||||||
|
NotificationHelper::approveExpense($form->user_id, $expense_number, $receiver_ids);
|
||||||
|
|
||||||
|
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',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$name = $form->user->name;
|
||||||
|
$expense_number = $form->expense_number;
|
||||||
|
$tanggal = $form->tanggal;
|
||||||
|
$total = $form->total;
|
||||||
|
|
||||||
|
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||||
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
$receiver_ids = [];
|
||||||
|
|
||||||
|
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||||
|
|
||||||
|
foreach ($roles as $role) {
|
||||||
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||||
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
|
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract emails and phone numbers
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$recipients[] = $user->email;
|
||||||
|
$phoneNumbers[] = $user->phone;
|
||||||
|
$receiver_ids[] = $user->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
));
|
||||||
|
|
||||||
|
NotificationHelper::approve2Expense($form->user_id, $expense_number, $receiver_ids);
|
||||||
|
|
||||||
|
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 = [
|
$approved_data = [
|
||||||
'allowance' => $request->allowance ? $form->allowance : 0,
|
'allowance' => $request->allowance ? $form->allowance : 0,
|
||||||
'transport_dalkot' => $request->transport_dalkot ? $form->transport_dalkot : 0,
|
'transport_dalkot' => $request->transport_dalkot ? $form->transport_dalkot : 0,
|
||||||
@@ -430,9 +587,9 @@ class FormUpCountryController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$form->update([
|
$form->update([
|
||||||
'approved_at' => now(),
|
'final_approved_at' => now(),
|
||||||
'approved_by' => auth()->user()->id,
|
'final_approved_by' => auth()->user()->id,
|
||||||
'status' => 'Approved',
|
'status' => 'Closed',
|
||||||
'approved_allowance' => $approved_data['allowance'],
|
'approved_allowance' => $approved_data['allowance'],
|
||||||
'approved_transport_dalkot' => $approved_data['transport_dalkot'],
|
'approved_transport_dalkot' => $approved_data['transport_dalkot'],
|
||||||
'approved_transport_ankot' => $approved_data['transport_ankot'],
|
'approved_transport_ankot' => $approved_data['transport_ankot'],
|
||||||
@@ -440,36 +597,43 @@ class FormUpCountryController extends Controller
|
|||||||
'approved_total' => array_sum($approved_data),
|
'approved_total' => array_sum($approved_data),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$heads = $form->user->getCabangAndRegionHead();
|
|
||||||
$name = $form->user->name;
|
$name = $form->user->name;
|
||||||
$expense_number = $form->expense_number;
|
$expense_number = $form->expense_number;
|
||||||
$tanggal = $form->tanggal;
|
$tanggal = $form->tanggal;
|
||||||
$total = $form->approved_total;
|
$total = $form->approved_total;
|
||||||
|
|
||||||
// Collect all recipients
|
$roles = ['Head of Sales Marketing', 'Marketing Operational Manager Region'];
|
||||||
$recipients = [$form->user->email, auth()->user()->email];
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
|
||||||
if ($heads['cabang_head']) {
|
foreach ($roles as $role) {
|
||||||
$recipients[] = $heads['cabang_head']['email'];
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
|
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract emails and phone numbers
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$recipients[] = $user->email;
|
||||||
|
$phoneNumbers[] = $user->phone;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($heads['region_head']) {
|
// Remove duplicate email addresses, if any
|
||||||
$recipients[] = $heads['region_head']['email'];
|
|
||||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove duplicate data, if any
|
|
||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
$phoneNumbers = array_unique($phoneNumbers);
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
|
||||||
// send whatsapp message
|
// send whatsapp message
|
||||||
$url = route('forms.up-country.view', $form->id);
|
$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
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new ExpenseApproved(
|
Mail::to($recipients)->send(new FinalApprove(
|
||||||
$name,
|
$name,
|
||||||
$expense_number,
|
$expense_number,
|
||||||
$tanggal,
|
$tanggal,
|
||||||
@@ -477,14 +641,14 @@ class FormUpCountryController extends Controller
|
|||||||
$url
|
$url
|
||||||
));
|
));
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Up Country (' . $form->expense_number . ')');
|
AuditTrailHelper::AddAuditTrail('Final Approve', 'Final Approve Expense at Form Up Country (' . $form->expense_number . ')');
|
||||||
session()->flash('success', 'Form has been approved.');
|
session()->flash('success', 'Form has been final approved.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reject($id)
|
public function reject($id)
|
||||||
{
|
{
|
||||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
$this->checkAuthorization(auth()->user(), ['approval.reject']);
|
||||||
|
|
||||||
$form = FormUpCountry::findOrfail($id);
|
$form = FormUpCountry::findOrfail($id);
|
||||||
$form->update([
|
$form->update([
|
||||||
@@ -517,7 +681,7 @@ class FormUpCountryController extends Controller
|
|||||||
|
|
||||||
// send whatsapp message
|
// send whatsapp message
|
||||||
$url = route('forms.up-country.view', $form->id);
|
$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
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new ExpenseRejected(
|
Mail::to($recipients)->send(new ExpenseRejected(
|
||||||
@@ -533,64 +697,6 @@ class FormUpCountryController extends Controller
|
|||||||
return redirect()->back();
|
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)
|
public function open($id)
|
||||||
{
|
{
|
||||||
$this->checkAuthorization(auth()->user(), ['final_approval.open']);
|
$this->checkAuthorization(auth()->user(), ['final_approval.open']);
|
||||||
@@ -599,7 +705,7 @@ class FormUpCountryController extends Controller
|
|||||||
$form->update([
|
$form->update([
|
||||||
'final_approved_at' => null,
|
'final_approved_at' => null,
|
||||||
'final_approved_by' => null,
|
'final_approved_by' => null,
|
||||||
'status' => 'Approved'
|
'status' => 'Approved 2'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Open', 'Open Expense at Form Up Country (' . $form->expense_number . ')');
|
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\Str;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
use App\Mail\ExpenseApproved;
|
use App\Mail\ExpenseApproved;
|
||||||
|
use App\Mail\ExpenseApproved2;
|
||||||
use App\Mail\ExpenseRejected;
|
use App\Mail\ExpenseRejected;
|
||||||
use App\Mail\FinalApprove;
|
use App\Mail\FinalApprove;
|
||||||
use App\Mail\ExpenseCreated;
|
use App\Mail\ExpenseCreated;
|
||||||
@@ -24,6 +25,7 @@ use App\Helpers\AuditTrailHelper;
|
|||||||
use App\Rules\FileType;
|
use App\Rules\FileType;
|
||||||
use App\Models\Admin;
|
use App\Models\Admin;
|
||||||
use App\Helpers\BudgetHelper;
|
use App\Helpers\BudgetHelper;
|
||||||
|
use App\Helpers\NotificationHelper;
|
||||||
|
|
||||||
class FormVehicleController extends Controller
|
class FormVehicleController extends Controller
|
||||||
{
|
{
|
||||||
@@ -37,6 +39,7 @@ class FormVehicleController extends Controller
|
|||||||
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
||||||
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
|
->with('user')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$availableBudget = null;
|
$availableBudget = null;
|
||||||
@@ -167,30 +170,44 @@ class FormVehicleController extends Controller
|
|||||||
'status' => 'On Progress',
|
'status' => 'On Progress',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Send notification to MIS and Admin Region
|
|
||||||
$roles = ['Marketing Information System', 'Admin Region'];
|
|
||||||
$recipients = [];
|
|
||||||
$phoneNumbers = [];
|
|
||||||
|
|
||||||
$name = auth()->user()->name;
|
$name = auth()->user()->name;
|
||||||
$tanggal = $form->tanggal;
|
$tanggal = $form->tanggal;
|
||||||
$total = $form->total;
|
$total = $form->total;
|
||||||
|
|
||||||
|
// Send notification to MIS and Admin Region and Area Manager Cabang
|
||||||
|
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||||
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
$receiver_ids = [];
|
||||||
|
|
||||||
// Collect all recipients (emails and phone numbers) for the specified roles
|
// Collect all recipients (emails and phone numbers) for the specified roles
|
||||||
foreach ($roles as $role) {
|
foreach ($roles as $role) {
|
||||||
$users = Admin::getUserByRoleName($role);
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang) {
|
||||||
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
|
return $user->cabang && $user->cabang->cabang->id === $cabang->id;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract emails and phone numbers
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
$recipients[] = $user->email;
|
$recipients[] = $user->email;
|
||||||
$phoneNumbers[] = $user->phone;
|
$phoneNumbers[] = $user->phone;
|
||||||
|
$receiver_ids[] = $user->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicate email addresses, if any
|
// Remove duplicate email addresses, if any
|
||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
$receiver_ids = array_unique($receiver_ids);
|
||||||
|
|
||||||
// Generate URL and send WhatsApp notification
|
// Generate URL and send WhatsApp notification
|
||||||
$url = route('forms.vehicle.view', $form->id);
|
$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
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new ExpenseCreated(
|
Mail::to($recipients)->send(new ExpenseCreated(
|
||||||
@@ -201,6 +218,8 @@ class FormVehicleController extends Controller
|
|||||||
$url
|
$url
|
||||||
));
|
));
|
||||||
|
|
||||||
|
NotificationHelper::newExpense($form->user_id, $expense_number, $receiver_ids);
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Insert', 'Insert New Expense at Form Vehicle Running Cost (' . $expense_number . ')');
|
AuditTrailHelper::AddAuditTrail('Insert', 'Insert New Expense at Form Vehicle Running Cost (' . $expense_number . ')');
|
||||||
session()->flash('success', 'Form has been created.');
|
session()->flash('success', 'Form has been created.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
@@ -284,57 +303,58 @@ class FormVehicleController extends Controller
|
|||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function approve(Request $request, $id)
|
public function approve($id)
|
||||||
{
|
{
|
||||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
||||||
$request->validate([
|
|
||||||
'total' => 'required',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$form = FormVehicleRunningCost::findOrfail($id);
|
$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([
|
$form->update([
|
||||||
'approved_at' => now(),
|
'approved_at' => now(),
|
||||||
'approved_by' => auth()->user()->id,
|
'approved_by' => auth()->user()->id,
|
||||||
'status' => 'Approved',
|
'status' => 'Approved 1',
|
||||||
|
|
||||||
'approved_total' => $form->total,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$heads = $form->user->getCabangAndRegionHead();
|
|
||||||
$name = $form->user->name;
|
$name = $form->user->name;
|
||||||
$expense_number = $form->expense_number;
|
$expense_number = $form->expense_number;
|
||||||
$tanggal = $form->tanggal;
|
$tanggal = $form->created_at;
|
||||||
$total = $form->approved_total;
|
$total = $form->total;
|
||||||
|
|
||||||
// Collect all recipients
|
// Collect all recipients
|
||||||
|
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang'];
|
||||||
$recipients = [$form->user->email, auth()->user()->email];
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
$receiver_ids = [];
|
||||||
|
|
||||||
if ($heads['cabang_head']) {
|
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||||
$recipients[] = $heads['cabang_head']['email'];
|
foreach ($roles as $role) {
|
||||||
$phoneNumbers[] = $heads['cabang_head']['phone'];
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||||
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
|
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract emails and phone numbers
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$recipients[] = $user->email;
|
||||||
|
$phoneNumbers[] = $user->phone;
|
||||||
|
$receiver_ids[] = $user->id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($heads['region_head']) {
|
// Remove duplicate data, if any
|
||||||
$recipients[] = $heads['region_head']['email'];
|
|
||||||
$phoneNumbers[] = $heads['region_head']['phone'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove duplicate email addresses, if any
|
|
||||||
$recipients = array_unique($recipients);
|
$recipients = array_unique($recipients);
|
||||||
$phoneNumbers = array_unique($phoneNumbers);
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
$receiver_ids = array_unique($receiver_ids);
|
||||||
|
|
||||||
// Send bulk WhatsApp message
|
// send whatsapp message
|
||||||
$url = route('forms.vehicle.view', $form->id);
|
$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(
|
Mail::to($recipients)->send(new ExpenseApproved(
|
||||||
$name,
|
$name,
|
||||||
$expense_number,
|
$expense_number,
|
||||||
@@ -343,32 +363,167 @@ class FormVehicleController extends Controller
|
|||||||
$url
|
$url
|
||||||
));
|
));
|
||||||
|
|
||||||
|
NotificationHelper::approveExpense($form->user_id, $expense_number, $receiver_ids);
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Vehicle Running Cost (' . $form->expense_number . ')');
|
AuditTrailHelper::AddAuditTrail('Approve', 'Approve Expense at Form Vehicle Running Cost (' . $form->expense_number . ')');
|
||||||
session()->flash('success', 'Form has been approved.');
|
session()->flash('success', 'Form has been approved.');
|
||||||
return redirect()->back();
|
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',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$name = $form->user->name;
|
||||||
|
$expense_number = $form->expense_number;
|
||||||
|
$tanggal = $form->created_at;
|
||||||
|
$total = $form->total;
|
||||||
|
|
||||||
|
$roles = ['Marketing Information System', 'Admin Region', 'Area Manager Cabang', 'Marketing Operational Manager Region'];
|
||||||
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
$receiver_ids = [];
|
||||||
|
|
||||||
|
$cabang_id = UserHasCabang::where('user_id', $form->user_id)->first()->cabang_id;
|
||||||
|
|
||||||
|
foreach ($roles as $role) {
|
||||||
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||||
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
|
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract emails and phone numbers
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$recipients[] = $user->email;
|
||||||
|
$phoneNumbers[] = $user->phone;
|
||||||
|
$receiver_ids[] = $user->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove duplicate data, if any
|
||||||
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
$receiver_ids = array_unique($receiver_ids);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
));
|
||||||
|
|
||||||
|
NotificationHelper::approve2Expense($form->user_id, $expense_number, $receiver_ids);
|
||||||
|
|
||||||
|
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']);
|
$this->checkAuthorization(auth()->user(), ['final_approval.approve']);
|
||||||
|
|
||||||
$form = FormVehicleRunningCost::findOrfail($id);
|
$form = FormVehicleRunningCost::findOrfail($id);
|
||||||
if($form->approved_at == null) {
|
if($form->approved_at == null || $form->approved2_at == null) {
|
||||||
session()->flash('error', 'Form must be approved by MIS first.');
|
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();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
$form->update([
|
$form->update([
|
||||||
'final_approved_at' => now(),
|
'final_approved_at' => now(),
|
||||||
'final_approved_by' => auth()->user()->id,
|
'final_approved_by' => auth()->user()->id,
|
||||||
'status' => 'Closed'
|
'status' => 'Closed',
|
||||||
|
'approved_total' => $form->total,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$name = $form->user->name;
|
||||||
|
$expense_number = $form->expense_number;
|
||||||
|
$tanggal = $form->created_at;
|
||||||
|
$total = $form->approved_total;
|
||||||
|
|
||||||
|
$roles = ['Head of Sales Marketing', 'Marketing Operational Manager Region'];
|
||||||
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
|
$phoneNumbers = [$form->user->phone, auth()->user()->phone];
|
||||||
|
|
||||||
|
foreach ($roles as $role) {
|
||||||
|
$users = Admin::getUserByRoleName($role)->filter(function ($user) use ($role, $cabang_id) {
|
||||||
|
// Include 'Marketing Information System' without cabang filtering
|
||||||
|
if ($role === 'Marketing Information System') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure user has a cabang and matches the current cabang ID
|
||||||
|
return $user->cabang && $user->cabang->cabang->id === $cabang_id;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extract emails and phone numbers
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$recipients[] = $user->email;
|
||||||
|
$phoneNumbers[] = $user->phone;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove duplicate email addresses, if any
|
||||||
|
$recipients = array_unique($recipients);
|
||||||
|
$phoneNumbers = array_unique($phoneNumbers);
|
||||||
|
|
||||||
|
// send whatsapp message
|
||||||
|
$url = route('forms.vehicle.view', $form->id);
|
||||||
|
WhatsappHelper::finalApprove($phoneNumbers, $expense_number, $url, $tanggal, $total, $name);
|
||||||
|
|
||||||
|
// Send bulk email
|
||||||
|
Mail::to($recipients)->send(new FinalApprove(
|
||||||
|
$name,
|
||||||
|
$expense_number,
|
||||||
|
$tanggal,
|
||||||
|
$total,
|
||||||
|
$url
|
||||||
|
));
|
||||||
|
|
||||||
|
AuditTrailHelper::AddAuditTrail('Final Approve', 'Final Approve Expense at Form Vehicle Running Cost (' . $form->expense_number . ')');
|
||||||
|
session()->flash('success', 'Form has been final approved.');
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function reject($id)
|
||||||
|
{
|
||||||
|
$this->checkAuthorization(auth()->user(), ['approval.reject']);
|
||||||
|
|
||||||
|
$form = FormVehicleRunningCost::findOrfail($id);
|
||||||
|
$form->update([
|
||||||
|
'status' => 'Rejected'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$heads = $form->user->getCabangAndRegionHead();
|
$heads = $form->user->getCabangAndRegionHead();
|
||||||
$name = $form->user->name;
|
$name = $form->user->name;
|
||||||
$expense_number = $form->expense_number;
|
$expense_number = $form->expense_number;
|
||||||
$tanggal = $form->tanggal;
|
$tanggal = $form->created_at;
|
||||||
$total = $form->approved_total;
|
$total = $form->total;
|
||||||
|
|
||||||
// Collect all recipients
|
// Collect all recipients
|
||||||
$recipients = [$form->user->email, auth()->user()->email];
|
$recipients = [$form->user->email, auth()->user()->email];
|
||||||
@@ -390,10 +545,10 @@ class FormVehicleController extends Controller
|
|||||||
|
|
||||||
// send whatsapp message
|
// send whatsapp message
|
||||||
$url = route('forms.vehicle.view', $form->id);
|
$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
|
// Send bulk email
|
||||||
Mail::to($recipients)->send(new FinalApprove(
|
Mail::to($recipients)->send(new ExpenseRejected(
|
||||||
$name,
|
$name,
|
||||||
$expense_number,
|
$expense_number,
|
||||||
$tanggal,
|
$tanggal,
|
||||||
@@ -401,8 +556,8 @@ class FormVehicleController extends Controller
|
|||||||
$url
|
$url
|
||||||
));
|
));
|
||||||
|
|
||||||
AuditTrailHelper::AddAuditTrail('Final Approve', 'Final Approve Expense at Form Vehicle Running Cost (' . $form->expense_number . ')');
|
AuditTrailHelper::AddAuditTrail('Reject', 'Reject Expense at Form Vehicle Running Cost (' . $form->expense_number . ')');
|
||||||
session()->flash('success', 'Form has been final approved.');
|
session()->flash('success', 'Form has been rejected.');
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,57 +577,6 @@ class FormVehicleController extends Controller
|
|||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reject($id)
|
|
||||||
{
|
|
||||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
|
||||||
|
|
||||||
$form = FormVehicleRunningCost::findOrfail($id);
|
|
||||||
$form->update([
|
|
||||||
'status' => 'Rejected'
|
|
||||||
]);
|
|
||||||
|
|
||||||
$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 WhatsApp message
|
|
||||||
$url = route('forms.vehicle.view', $form->id);
|
|
||||||
WhatsappHelper::approveExpense($phoneNumbers, $expense_number, $url);
|
|
||||||
|
|
||||||
// Send bulk email
|
|
||||||
Mail::to($recipients)->send(new ExpenseRejected(
|
|
||||||
$name,
|
|
||||||
$expense_number,
|
|
||||||
$tanggal,
|
|
||||||
$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 destroy($id)
|
public function destroy($id)
|
||||||
{
|
{
|
||||||
$this->checkAuthorization(auth()->user(), ['forms.vehicle.delete']);
|
$this->checkAuthorization(auth()->user(), ['forms.vehicle.delete']);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class CabangController extends Controller
|
|||||||
session()->put('redirect_url', route('admin.cabang.index'));
|
session()->put('redirect_url', route('admin.cabang.index'));
|
||||||
|
|
||||||
return view('backend.pages.master.cabang.index', [
|
return view('backend.pages.master.cabang.index', [
|
||||||
'cabang' => Cabang::all()
|
'cabang' => Cabang::with(['head', 'region', 'cost'])->get()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class RegionController extends Controller
|
|||||||
session()->put('redirect_url', route('admin.region.index'));
|
session()->put('redirect_url', route('admin.region.index'));
|
||||||
|
|
||||||
return view('backend.pages.master.region.index', [
|
return view('backend.pages.master.region.index', [
|
||||||
'region' => Region::all()
|
'region' => Region::with('head')->get()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class ExpenseApproved extends Mailable
|
|||||||
public function envelope(): Envelope
|
public function envelope(): Envelope
|
||||||
{
|
{
|
||||||
return new 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
|
public function envelope(): Envelope
|
||||||
{
|
{
|
||||||
return new Envelope(
|
return new Envelope(
|
||||||
subject: 'Expense Closed',
|
subject: 'Expense Final Approval',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-1
@@ -9,6 +9,7 @@ use Illuminate\Notifications\Notifiable;
|
|||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Spatie\Permission\Traits\HasRoles;
|
use Spatie\Permission\Traits\HasRoles;
|
||||||
use Spatie\Permission\Models\Role;
|
use Spatie\Permission\Models\Role;
|
||||||
|
use App\Models\UserHasCabang;
|
||||||
|
|
||||||
class Admin extends Authenticatable
|
class Admin extends Authenticatable
|
||||||
{
|
{
|
||||||
@@ -167,12 +168,21 @@ class Admin extends Authenticatable
|
|||||||
$role = Role::where('name', $roleName)->first();
|
$role = Role::where('name', $roleName)->first();
|
||||||
|
|
||||||
if ($role) {
|
if ($role) {
|
||||||
return $role->users()->with('cabang')->get();
|
return $role->users()->with('cabang.cabang')->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getUserByRoleNameAndCabang($roleName, $cabang_id)
|
||||||
|
{
|
||||||
|
$users = self::getUserByRoleName($roleName);
|
||||||
|
|
||||||
|
return $users->filter(function ($user) use ($cabang_id) {
|
||||||
|
return $user->cabang ? $user->cabang->id == $cabang_id : false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static function getUserWhereRoleIsNot($roleName)
|
public static function getUserWhereRoleIsNot($roleName)
|
||||||
{
|
{
|
||||||
return self::whereDoesntHave('roles', function ($query) use ($roleName) {
|
return self::whereDoesntHave('roles', function ($query) use ($roleName) {
|
||||||
|
|||||||
@@ -25,7 +25,9 @@ class FormEntertaimentPresentation extends Model
|
|||||||
'account_number',
|
'account_number',
|
||||||
'status',
|
'status',
|
||||||
'approved_at',
|
'approved_at',
|
||||||
|
'approved2_at',
|
||||||
'approved_by',
|
'approved_by',
|
||||||
|
'approved2_by',
|
||||||
'final_approved_at',
|
'final_approved_at',
|
||||||
'final_approved_by',
|
'final_approved_by',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ class FormMeetingSeminar extends Model
|
|||||||
'account_number',
|
'account_number',
|
||||||
'status',
|
'status',
|
||||||
'approved_at',
|
'approved_at',
|
||||||
|
'approved2_at',
|
||||||
'approved_by',
|
'approved_by',
|
||||||
|
'approved2_by',
|
||||||
'final_approved_at',
|
'final_approved_at',
|
||||||
'final_approved_by',
|
'final_approved_by',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ class FormOthers extends Model
|
|||||||
'account_number',
|
'account_number',
|
||||||
'status',
|
'status',
|
||||||
'approved_at',
|
'approved_at',
|
||||||
|
'approved2_at',
|
||||||
'approved_by',
|
'approved_by',
|
||||||
|
'approved2_by',
|
||||||
'final_approved_at',
|
'final_approved_at',
|
||||||
'final_approved_by',
|
'final_approved_by',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ class FormUpCountry extends Model
|
|||||||
'account_number',
|
'account_number',
|
||||||
'status',
|
'status',
|
||||||
'approved_at',
|
'approved_at',
|
||||||
|
'approved2_at',
|
||||||
'approved_by',
|
'approved_by',
|
||||||
|
'approved2_by',
|
||||||
'final_approved_at',
|
'final_approved_at',
|
||||||
'final_approved_by',
|
'final_approved_by',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -25,7 +25,9 @@ class FormVehicleRunningCost extends Model
|
|||||||
'account_number',
|
'account_number',
|
||||||
'status',
|
'status',
|
||||||
'approved_at',
|
'approved_at',
|
||||||
|
'approved2_at',
|
||||||
'approved_by',
|
'approved_by',
|
||||||
|
'approved2_by',
|
||||||
'final_approved_at',
|
'final_approved_at',
|
||||||
'final_approved_by',
|
'final_approved_by',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Notifications extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'notifications';
|
||||||
|
protected $fillable = [
|
||||||
|
'user_id',
|
||||||
|
'receiver_id',
|
||||||
|
'title',
|
||||||
|
'content',
|
||||||
|
'is_read',
|
||||||
|
'type',
|
||||||
|
'created_at',
|
||||||
|
'updated_at'
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -25,6 +25,7 @@
|
|||||||
"yajra/laravel-datatables-oracle": "11.0"
|
"yajra/laravel-datatables-oracle": "11.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
"barryvdh/laravel-debugbar": "^3.14",
|
||||||
"fakerphp/faker": "^1.23",
|
"fakerphp/faker": "^1.23",
|
||||||
"laravel/pail": "^1.1",
|
"laravel/pail": "^1.1",
|
||||||
"laravel/pint": "^1.13",
|
"laravel/pint": "^1.13",
|
||||||
|
|||||||
Generated
+153
-1
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "868009e8371e3394bb5e17f99038a6b8",
|
"content-hash": "5ba74d8866276fa9daa9d6c52fd9f690",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "barryvdh/laravel-dompdf",
|
"name": "barryvdh/laravel-dompdf",
|
||||||
@@ -8044,6 +8044,90 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
|
{
|
||||||
|
"name": "barryvdh/laravel-debugbar",
|
||||||
|
"version": "v3.14.10",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/barryvdh/laravel-debugbar.git",
|
||||||
|
"reference": "56b9bd235e3fe62e250124804009ce5bab97cc63"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/56b9bd235e3fe62e250124804009ce5bab97cc63",
|
||||||
|
"reference": "56b9bd235e3fe62e250124804009ce5bab97cc63",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"illuminate/routing": "^9|^10|^11",
|
||||||
|
"illuminate/session": "^9|^10|^11",
|
||||||
|
"illuminate/support": "^9|^10|^11",
|
||||||
|
"maximebf/debugbar": "~1.23.0",
|
||||||
|
"php": "^8.0",
|
||||||
|
"symfony/finder": "^6|^7"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"mockery/mockery": "^1.3.3",
|
||||||
|
"orchestra/testbench-dusk": "^5|^6|^7|^8|^9",
|
||||||
|
"phpunit/phpunit": "^9.6|^10.5",
|
||||||
|
"squizlabs/php_codesniffer": "^3.5"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"aliases": {
|
||||||
|
"Debugbar": "Barryvdh\\Debugbar\\Facades\\Debugbar"
|
||||||
|
},
|
||||||
|
"providers": [
|
||||||
|
"Barryvdh\\Debugbar\\ServiceProvider"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "3.14-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"src/helpers.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Barryvdh\\Debugbar\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Barry vd. Heuvel",
|
||||||
|
"email": "barryvdh@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PHP Debugbar integration for Laravel",
|
||||||
|
"keywords": [
|
||||||
|
"debug",
|
||||||
|
"debugbar",
|
||||||
|
"laravel",
|
||||||
|
"profiler",
|
||||||
|
"webprofiler"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/barryvdh/laravel-debugbar/issues",
|
||||||
|
"source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.14.10"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://fruitcake.nl",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/barryvdh",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-12-23T10:10:42+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "fakerphp/faker",
|
"name": "fakerphp/faker",
|
||||||
"version": "v1.24.1",
|
"version": "v1.24.1",
|
||||||
@@ -8436,6 +8520,74 @@
|
|||||||
},
|
},
|
||||||
"time": "2024-11-27T15:42:28+00:00"
|
"time": "2024-11-27T15:42:28+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "maximebf/debugbar",
|
||||||
|
"version": "v1.23.5",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/php-debugbar/php-debugbar.git",
|
||||||
|
"reference": "eeabd61a1f19ba5dcd5ac4585a477130ee03ce25"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/php-debugbar/php-debugbar/zipball/eeabd61a1f19ba5dcd5ac4585a477130ee03ce25",
|
||||||
|
"reference": "eeabd61a1f19ba5dcd5ac4585a477130ee03ce25",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.2|^8",
|
||||||
|
"psr/log": "^1|^2|^3",
|
||||||
|
"symfony/var-dumper": "^4|^5|^6|^7"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"dbrekelmans/bdi": "^1",
|
||||||
|
"phpunit/phpunit": "^8|^9",
|
||||||
|
"symfony/panther": "^1|^2.1",
|
||||||
|
"twig/twig": "^1.38|^2.7|^3.0"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"kriswallsmith/assetic": "The best way to manage assets",
|
||||||
|
"monolog/monolog": "Log using Monolog",
|
||||||
|
"predis/predis": "Redis storage"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.23-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"DebugBar\\": "src/DebugBar/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Maxime Bouroumeau-Fuseau",
|
||||||
|
"email": "maxime.bouroumeau@gmail.com",
|
||||||
|
"homepage": "http://maximebf.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Barry vd. Heuvel",
|
||||||
|
"email": "barryvdh@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Debug bar in the browser for php application",
|
||||||
|
"homepage": "https://github.com/maximebf/php-debugbar",
|
||||||
|
"keywords": [
|
||||||
|
"debug",
|
||||||
|
"debugbar"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/php-debugbar/php-debugbar/issues",
|
||||||
|
"source": "https://github.com/php-debugbar/php-debugbar/tree/v1.23.5"
|
||||||
|
},
|
||||||
|
"time": "2024-12-15T19:20:42+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "mockery/mockery",
|
"name": "mockery/mockery",
|
||||||
"version": "1.6.12",
|
"version": "1.6.12",
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('form_up_country', function (Blueprint $table) {
|
||||||
|
$table->timestamp('approved2_at')->nullable()->after('approved_at');
|
||||||
|
$table->foreignId('approved2_by')->nullable()->constrained('admins')->cascadeOnDelete()->after('approved_by');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('form_up_country', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('approved2_at');
|
||||||
|
$table->dropForeign(['approved2_by']);
|
||||||
|
$table->dropColumn('approved2_by');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('form_vehicle_running_cost', function (Blueprint $table) {
|
||||||
|
$table->timestamp('approved2_at')->nullable()->after('approved_at');
|
||||||
|
$table->foreignId('approved2_by')->nullable()->constrained('admins')->cascadeOnDelete()->after('approved_by');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('form_vehicle_running_cost', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('approved2_at');
|
||||||
|
$table->dropForeign(['approved2_by']);
|
||||||
|
$table->dropColumn('approved2_by');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('form_entertainment_presentation', function (Blueprint $table) {
|
||||||
|
$table->timestamp('approved2_at')->nullable()->after('approved_at');
|
||||||
|
$table->foreignId('approved2_by')->nullable()->constrained('admins')->cascadeOnDelete()->after('approved_by');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('form_entertainment_presentation', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('approved2_at');
|
||||||
|
$table->dropForeign(['approved2_by']);
|
||||||
|
$table->dropColumn('approved2_by');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('form_meeting_seminar', function (Blueprint $table) {
|
||||||
|
$table->timestamp('approved2_at')->nullable()->after('approved_at');
|
||||||
|
$table->foreignId('approved2_by')->nullable()->constrained('admins')->cascadeOnDelete()->after('approved_by');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('form_meeting_seminar', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('approved2_at');
|
||||||
|
$table->dropForeign(['approved2_by']);
|
||||||
|
$table->dropColumn('approved2_by');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('form_others', function (Blueprint $table) {
|
||||||
|
$table->timestamp('approved2_at')->nullable()->after('approved_at');
|
||||||
|
$table->foreignId('approved2_by')->nullable()->constrained('admins')->cascadeOnDelete()->after('approved_by');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('form_others', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('approved2_at');
|
||||||
|
$table->dropForeign(['approved2_by']);
|
||||||
|
$table->dropColumn('approved2_by');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('notifications', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('user_id')->constrained('admins')->onDelete('cascade');
|
||||||
|
$table->foreignId('receiver_id')->constrained('admins')->onDelete('cascade');
|
||||||
|
$table->string('title');
|
||||||
|
$table->text('content');
|
||||||
|
$table->boolean('is_read')->default(false);
|
||||||
|
$table->string('type');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('notifications');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -12,6 +12,8 @@ use Database\Seeds\RolePermissionSeeder4;
|
|||||||
use Database\Seeds\RolePermissionSeeder5;
|
use Database\Seeds\RolePermissionSeeder5;
|
||||||
use Database\Seeds\RolePermissionSeeder6;
|
use Database\Seeds\RolePermissionSeeder6;
|
||||||
use Database\Seeds\RolePermissionSeeder7;
|
use Database\Seeds\RolePermissionSeeder7;
|
||||||
|
use Database\Seeds\RolePermissionSeeder8;
|
||||||
|
use Database\Seeds\RolePermissionSeeder9;
|
||||||
|
|
||||||
class DatabaseSeeder extends Seeder
|
class DatabaseSeeder extends Seeder
|
||||||
{
|
{
|
||||||
@@ -32,6 +34,8 @@ class DatabaseSeeder extends Seeder
|
|||||||
// $this->call(RolePermissionSeeder4::class);
|
// $this->call(RolePermissionSeeder4::class);
|
||||||
// $this->call(RolePermissionSeeder5::class);
|
// $this->call(RolePermissionSeeder5::class);
|
||||||
// $this->call(RolePermissionSeeder6::class);
|
// $this->call(RolePermissionSeeder6::class);
|
||||||
$this->call(RolePermissionSeeder7::class);
|
// $this->call(RolePermissionSeeder7::class);
|
||||||
|
// $this->call(RolePermissionSeeder8::class);
|
||||||
|
$this->call(RolePermissionSeeder9::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeds;
|
||||||
|
|
||||||
|
use App\Models\Admin;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
use Spatie\Permission\Models\Permission;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class RolePermissionSeeder.
|
||||||
|
*
|
||||||
|
* @see https://spatie.be/docs/laravel-permission/v5/basic-usage/multiple-guards
|
||||||
|
*
|
||||||
|
* @package App\Database\Seeds
|
||||||
|
*/
|
||||||
|
class RolePermissionSeeder8 extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Enable these options if you need same role and other permission for User Model
|
||||||
|
* Else, please follow the below steps for admin guard
|
||||||
|
*/
|
||||||
|
$permissions = [
|
||||||
|
[
|
||||||
|
'group_name' => 'approval2',
|
||||||
|
'permissions' => [
|
||||||
|
'approval2.view',
|
||||||
|
'approval2.approve',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'group_name' => 'notification',
|
||||||
|
'permissions' => [
|
||||||
|
'notification.view',
|
||||||
|
'notification.delete',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Do same for the admin guard for tutorial purposes.
|
||||||
|
$admin = Admin::where('username', 'superadmin')->first();
|
||||||
|
$roleSuperAdmin = $this->maybeCreateSuperAdminRole($admin);
|
||||||
|
|
||||||
|
// Create and Assign Permissions
|
||||||
|
for ($i = 0; $i < count($permissions); $i++) {
|
||||||
|
$permissionGroup = $permissions[$i]['group_name'];
|
||||||
|
for ($j = 0; $j < count($permissions[$i]['permissions']); $j++) {
|
||||||
|
$permissionExist = Permission::where('name', $permissions[$i]['permissions'][$j])->first();
|
||||||
|
if (is_null($permissionExist)) {
|
||||||
|
$permission = Permission::create(
|
||||||
|
[
|
||||||
|
'name' => $permissions[$i]['permissions'][$j],
|
||||||
|
'group_name' => $permissionGroup,
|
||||||
|
'guard_name' => 'admin'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$roleSuperAdmin->givePermissionTo($permission);
|
||||||
|
$permission->assignRole($roleSuperAdmin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign super admin role permission to superadmin user
|
||||||
|
if ($admin) {
|
||||||
|
$admin->assignRole($roleSuperAdmin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function maybeCreateSuperAdminRole($admin): Role
|
||||||
|
{
|
||||||
|
if (is_null($admin)) {
|
||||||
|
$roleSuperAdmin = Role::create(['name' => 'superadmin', 'guard_name' => 'admin']);
|
||||||
|
} else {
|
||||||
|
$roleSuperAdmin = Role::where('name', 'superadmin')->where('guard_name', 'admin')->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null($roleSuperAdmin)) {
|
||||||
|
$roleSuperAdmin = Role::create(['name' => 'superadmin', 'guard_name' => 'admin']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $roleSuperAdmin;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeds;
|
||||||
|
|
||||||
|
use App\Models\Admin;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
use Spatie\Permission\Models\Permission;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class RolePermissionSeeder.
|
||||||
|
*
|
||||||
|
* @see https://spatie.be/docs/laravel-permission/v5/basic-usage/multiple-guards
|
||||||
|
*
|
||||||
|
* @package App\Database\Seeds
|
||||||
|
*/
|
||||||
|
class RolePermissionSeeder9 extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Enable these options if you need same role and other permission for User Model
|
||||||
|
* Else, please follow the below steps for admin guard
|
||||||
|
*/
|
||||||
|
$permissions = [
|
||||||
|
[
|
||||||
|
'group_name' => 'approval',
|
||||||
|
'permissions' => [
|
||||||
|
'approval.reject',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'group_name' => 'approval2',
|
||||||
|
'permissions' => [
|
||||||
|
'approval2.reject',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Do same for the admin guard for tutorial purposes.
|
||||||
|
$admin = Admin::where('username', 'superadmin')->first();
|
||||||
|
$roleSuperAdmin = $this->maybeCreateSuperAdminRole($admin);
|
||||||
|
|
||||||
|
// Create and Assign Permissions
|
||||||
|
for ($i = 0; $i < count($permissions); $i++) {
|
||||||
|
$permissionGroup = $permissions[$i]['group_name'];
|
||||||
|
for ($j = 0; $j < count($permissions[$i]['permissions']); $j++) {
|
||||||
|
$permissionExist = Permission::where('name', $permissions[$i]['permissions'][$j])->first();
|
||||||
|
if (is_null($permissionExist)) {
|
||||||
|
$permission = Permission::create(
|
||||||
|
[
|
||||||
|
'name' => $permissions[$i]['permissions'][$j],
|
||||||
|
'group_name' => $permissionGroup,
|
||||||
|
'guard_name' => 'admin'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$roleSuperAdmin->givePermissionTo($permission);
|
||||||
|
$permission->assignRole($roleSuperAdmin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign super admin role permission to superadmin user
|
||||||
|
if ($admin) {
|
||||||
|
$admin->assignRole($roleSuperAdmin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function maybeCreateSuperAdminRole($admin): Role
|
||||||
|
{
|
||||||
|
if (is_null($admin)) {
|
||||||
|
$roleSuperAdmin = Role::create(['name' => 'superadmin', 'guard_name' => 'admin']);
|
||||||
|
} else {
|
||||||
|
$roleSuperAdmin = Role::where('name', 'superadmin')->where('guard_name', 'admin')->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null($roleSuperAdmin)) {
|
||||||
|
$roleSuperAdmin = Role::create(['name' => 'superadmin', 'guard_name' => 'admin']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $roleSuperAdmin;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -66,8 +66,8 @@
|
|||||||
</span>
|
</span>
|
||||||
@endforeach
|
@endforeach
|
||||||
</td>
|
</td>
|
||||||
<td>{{ $admin->getMyCabangAndRegion()['region'] }}</td>
|
<td>{{ $admin->region->cabang->region->name ?? '' }}</td>
|
||||||
<td>{{ $admin->getMyCabangAndRegion()['cabang'] }}</td>
|
<td>{{ $admin->cabang->cabang->name ?? '' }}</td>
|
||||||
<td>
|
<td>
|
||||||
<a class="btn btn-success text-white" href="{{ route('admin.admins.expense', $admin->id) }}">View Expense</a>
|
<a class="btn btn-success text-white" href="{{ route('admin.admins.expense', $admin->id) }}">View Expense</a>
|
||||||
@if (auth()->user()->can('admin.edit'))
|
@if (auth()->user()->can('admin.edit'))
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
<td>{{ $item->cabang->name }}</td>
|
<td>{{ $item->cabang->name }}</td>
|
||||||
<td>{{ $item->sender->name }}</td>
|
<td>{{ $item->sender->name }}</td>
|
||||||
<td>{{ number_format($item->amount, 0, ',', '.') }}</td>
|
<td>{{ number_format($item->amount, 0, ',', '.') }}</td>
|
||||||
<td>{{ number_format(BudgetHelper::getAvailableBudget($item->cabang->id), 0, ',', '.') }}</td>
|
<td>{{ number_format($item->availableBudget, 0, ',', '.') }}</td>
|
||||||
<td>{{ $item->remarks }}</td>
|
<td>{{ $item->remarks }}</td>
|
||||||
<td>{{ strtoupper($item->periode_month) }} {{ $item->periode_year }}</td>
|
<td>{{ strtoupper($item->periode_month) }} {{ $item->periode_year }}</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="card card-primary card-outline">
|
<div class="card card-primary card-outline">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form method="POST" action="{{ route('forms.entertainment.store') }}" enctype="multipart/form-data">
|
<form id="expense-form" method="POST" action="{{ route('forms.entertainment.store') }}" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
@include('backend.layouts.partials.messages')
|
@include('backend.layouts.partials.messages')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -76,6 +76,14 @@
|
|||||||
<button type="submit" class="btn btn-primary ml-2">Submit</button>
|
<button type="submit" class="btn btn-primary ml-2">Submit</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<div id="loading-spinner-overlay" class="d-none">
|
||||||
|
<div class="spinner-wrapper">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
</div>
|
||||||
|
<p>Submitting, please wait...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -89,5 +97,11 @@
|
|||||||
decimalPlaces: 0, // Tidak ada angka desimal
|
decimalPlaces: 0, // Tidak ada angka desimal
|
||||||
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.getElementById('expense-form').addEventListener('submit', function (e) {
|
||||||
|
const spinnerOverlay = document.getElementById('loading-spinner-overlay');
|
||||||
|
spinnerOverlay.classList.remove('d-none'); // Show overlay
|
||||||
|
spinnerOverlay.classList.add('d-flex'); // Use flexbox for centering
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="card card-primary card-outline">
|
<div class="card card-primary card-outline">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form method="POST" action="{{ route('forms.entertainment.update', $form->id) }}" enctype="multipart/form-data">
|
<form id="expense-form" method="POST" action="{{ route('forms.entertainment.update', $form->id) }}" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
@method('PUT')
|
@method('PUT')
|
||||||
@include('backend.layouts.partials.messages')
|
@include('backend.layouts.partials.messages')
|
||||||
@@ -77,6 +77,14 @@
|
|||||||
<button type="submit" class="btn btn-primary ml-2">Update</button>
|
<button type="submit" class="btn btn-primary ml-2">Update</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<div id="loading-spinner-overlay" class="d-none">
|
||||||
|
<div class="spinner-wrapper">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
</div>
|
||||||
|
<p>Submitting, please wait...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -90,5 +98,11 @@
|
|||||||
decimalPlaces: 0, // Tidak ada angka desimal
|
decimalPlaces: 0, // Tidak ada angka desimal
|
||||||
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.getElementById('expense-form').addEventListener('submit', function (e) {
|
||||||
|
const spinnerOverlay = document.getElementById('loading-spinner-overlay');
|
||||||
|
spinnerOverlay.classList.remove('d-none'); // Show overlay
|
||||||
|
spinnerOverlay.classList.add('d-flex'); // Use flexbox for centering
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -110,7 +110,10 @@
|
|||||||
<th>Account Number</th>
|
<th>Account Number</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
@if (auth()->user()->can('approval.approve'))
|
@if (auth()->user()->can('approval.approve'))
|
||||||
<th>Approval</th>
|
<th>Approval 1</th>
|
||||||
|
@endif
|
||||||
|
@if (auth()->user()->can('approval2.approve'))
|
||||||
|
<th>Approval 2</th>
|
||||||
@endif
|
@endif
|
||||||
@if (auth()->user()->can('final_approval.approve'))
|
@if (auth()->user()->can('final_approval.approve'))
|
||||||
<th>Final Approval</th>
|
<th>Final Approval</th>
|
||||||
@@ -148,7 +151,7 @@
|
|||||||
<td>
|
<td>
|
||||||
@if ($item->status == 'On Progress')
|
@if ($item->status == 'On Progress')
|
||||||
<span class="badge badge-warning text-white">{{ $item->status }}</span>
|
<span class="badge badge-warning text-white">{{ $item->status }}</span>
|
||||||
@elseif ($item->status == 'Approved' || $item->status == 'Final Approved')
|
@elseif ($item->status == 'Approved 1' || $item->status == 'Approved 2' || $item->status == 'Final Approved')
|
||||||
<span class="badge badge-success text-white">{{ $item->status }}</span>
|
<span class="badge badge-success text-white">{{ $item->status }}</span>
|
||||||
@else
|
@else
|
||||||
<span class="badge badge-danger text-white">{{ $item->status }}</span>
|
<span class="badge badge-danger text-white">{{ $item->status }}</span>
|
||||||
@@ -157,16 +160,16 @@
|
|||||||
@if (auth()->user()->can('approval.approve'))
|
@if (auth()->user()->can('approval.approve'))
|
||||||
<td>
|
<td>
|
||||||
{{-- approve / reject button --}}
|
{{-- approve / reject button --}}
|
||||||
@if ($item->status == 'On Progress')
|
@if ($item->status == 'On Progress' || $item->status == 'Rejected')
|
||||||
<form action="javascript:void(0);" class="d-inline">
|
<form action="javascript:void(0);" class="d-inline">
|
||||||
<button type="button"
|
<button type="button"
|
||||||
class="btn btn-success btn-sm open-approve-modal"
|
class="btn btn-success btn-sm open-approve-modal"
|
||||||
data-id="{{ route('forms.entertainment.approve', $item->id) }}">
|
data-id="{{ route('forms.entertainment.approve', $item->id) }}">
|
||||||
Approve
|
Approve 1
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form action="{{ route('forms.entertainment.reject', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to reject this item?');">
|
<form action="{{ route('forms.entertainment.reject', $item->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to reject this item?');">
|
||||||
@csrf
|
@csrf
|
||||||
@method('PUT')
|
@method('PUT')
|
||||||
<button type="submit" class="btn btn-danger btn-sm">
|
<button type="submit" class="btn btn-danger btn-sm">
|
||||||
@@ -184,14 +187,44 @@
|
|||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
@endif
|
@endif
|
||||||
|
@if (auth()->user()->can('approval2.approve'))
|
||||||
|
<td>
|
||||||
|
{{-- approve / reject button --}}
|
||||||
|
@if ($item->status == 'Approved 1' && $item->approved_at)
|
||||||
|
<form action="javascript:void(0);" class="d-inline">
|
||||||
|
<button type="button"
|
||||||
|
class="btn btn-success btn-sm open-approve-modal"
|
||||||
|
data-id="{{ route('forms.entertainment.approve2', $item->id) }}">
|
||||||
|
Approve 2
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form action="{{ route('forms.entertainment.reject', $item->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to reject this item?');">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
<button type="submit" class="btn btn-danger btn-sm">
|
||||||
|
Reject
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@else
|
||||||
|
@if ($item->approved2_at)
|
||||||
|
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
|
||||||
|
@elseif($item->rejected_at)
|
||||||
|
{{ \Carbon\Carbon::parse($item->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
|
||||||
|
@else
|
||||||
|
-
|
||||||
|
@endif
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
@endif
|
||||||
@if(auth()->user()->can('final_approval.approve'))
|
@if(auth()->user()->can('final_approval.approve'))
|
||||||
<td>
|
<td>
|
||||||
{{-- approve / reject button --}}
|
{{-- approve / reject button --}}
|
||||||
@if ($item->status == 'Approved' && $item->approved_at && !$item->final_approved_at)
|
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
|
||||||
<form action="{{ route('forms.entertainment.final-approve', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this item?');">
|
<form action="javascript:void(0);" class="d-inline">
|
||||||
@csrf
|
<button type="button"
|
||||||
@method('PUT')
|
class="btn btn-success btn-sm final-approve-modal"
|
||||||
<button type="submit" class="btn btn-success btn-sm">
|
data-id="{{ route('forms.entertainment.final-approve', $item->id) }}">
|
||||||
Final Approve
|
Final Approve
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
@@ -280,22 +313,84 @@
|
|||||||
<strong>NIK/NPWP Penerima:</strong> <span id="nik_or_npwp"></span>
|
<strong>NIK/NPWP Penerima:</strong> <span id="nik_or_npwp"></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Nama Penerima:</strong> <span id="name"></span>
|
<strong>Tanggal:</strong> <span id="tanggal"></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Alamat Penerima:</strong> <span id="alamat"></span>
|
<strong>Nama Penerima:</strong> <span id="name"></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Jenis:</strong> <span id="jenis"></span>
|
<strong>Jenis:</strong> <span id="jenis"></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
|
||||||
<strong>Tanggal:</strong> <span id="tanggal"></span>
|
|
||||||
</li>
|
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Keterangan:</strong> <span id="keterangan"></span>
|
<strong>Keterangan:</strong> <span id="keterangan"></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Bukti Total Pengeluaran:</strong> <span id="bukti_total"></span>
|
<strong>Bukti Total:</strong> <span id="bukti_total"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Nominal Total:</strong> <span id="total_value"></span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Approve</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<div class="modal fade" id="finalApproveModal" tabindex="-1" role="dialog" aria-labelledby="finalApproveModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<form id="finalApproveForm" method="POST" action="">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="approveModalLabel">Approve Item</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<!-- Loading spinner -->
|
||||||
|
<div id="finalLoadingSpinner" class="d-flex justify-content-center align-items-center" style="height: 200px;">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
<span class="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal content (hidden initially) -->
|
||||||
|
<div id="finalModalContent" class="d-none">
|
||||||
|
<p>Please review the details below:</p>
|
||||||
|
<ul class="list-group">
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Expense Number:</strong> <span id="final_expense_number"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>User:</strong> <span id="final_user"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>NIK/NPWP Penerima:</strong> <span id="final_nik_or_npwp"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Tanggal:</strong> <span id="final_tanggal"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Nama Penerima:</strong> <span id="final_name"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Jenis:</strong> <span id="final_jenis"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Keterangan:</strong> <span id="final_keterangan"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Bukti Total:</strong> <span id="final_bukti_total"></span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p class="mt-2">Please select the items you want to approve:</p>
|
<p class="mt-2">Please select the items you want to approve:</p>
|
||||||
@@ -303,17 +398,11 @@
|
|||||||
<li>
|
<li>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="custom-control custom-checkbox">
|
<div class="custom-control custom-checkbox">
|
||||||
<input type="checkbox" class="custom-control-input" id="total_bensin" name="total_bensin">
|
<input type="checkbox" class="custom-control-input" id="final_total" name="total" required>
|
||||||
<label class="custom-control-label" for="total_bensin">Total Pengeluaran (<span id="total_bensin_value"></span>)</label>
|
<label class="custom-control-label" for="final_total">Total (<span id="final_total_value"></span>)</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="total">Total</label>
|
|
||||||
<input type="text" class="form-control" id="total" name="total" value="0" readonly>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -379,32 +468,31 @@
|
|||||||
$('#loadingSpinner').addClass('d-flex');
|
$('#loadingSpinner').addClass('d-flex');
|
||||||
$('#approveModal').modal('show'); // Show the modal
|
$('#approveModal').modal('show'); // Show the modal
|
||||||
|
|
||||||
// Get detail from /forms/up-country/detail/{id}
|
// Get detail from /forms/entertainment/detail/{id}
|
||||||
$.get(approveUrl.replace('approve', 'detail'), function (data) {
|
$.get(approveUrl.replace(/approve(2)?/, 'detail'), function (data) {
|
||||||
const formatter = new Intl.NumberFormat('id-ID', {
|
const formatter = new Intl.NumberFormat('id-ID', {
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
currency: 'IDR',
|
currency: 'IDR',
|
||||||
minimumFractionDigits: 0
|
minimumFractionDigits: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#total_bensin_value').text(formatter.format(data.total));
|
$('#total_value').text(formatter.format(data.total));
|
||||||
$('#total_bensin').data('value', data.total);
|
|
||||||
|
|
||||||
// Detail data
|
// Detail data
|
||||||
$('#user').text(data.user.name);
|
$('#user').text(data.user.name);
|
||||||
$('#nik_or_npwp').text(data.nik_or_npwp);
|
|
||||||
$('#name').text(data.name);
|
|
||||||
$('#alamat').text(data.alamat);
|
|
||||||
$('#expense_number').text(data.expense_number);
|
$('#expense_number').text(data.expense_number);
|
||||||
$('#jenis').text(data.jenis);
|
$('#tanggal').text(new Date(data.created_at).toLocaleDateString('id-ID', {
|
||||||
$('#keterangan').text(data.keterangan);
|
|
||||||
$('#tanggal').text(new Date(data.tanggal).toLocaleDateString('id-ID', {
|
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
month: 'long',
|
month: 'long',
|
||||||
day: 'numeric',
|
day: 'numeric'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
$('#bukti_total').html(data.bukti_total ? '<a href="' + data.bukti_total + '" target="_blank">Download</a>' : '-');
|
$('#nik_or_npwp').text(data.nik_or_npwp);
|
||||||
|
$('#name').text(data.name);
|
||||||
|
$('#jenis').text(data.jenis);
|
||||||
|
$('#keterangan').text(data.keterangan);
|
||||||
|
|
||||||
|
$('#bukti_total').html(data.total ? '<a href="' + data.total + '" target="_blank">Download</a>' : '-');
|
||||||
|
|
||||||
// Hide spinner and show content
|
// Hide spinner and show content
|
||||||
$('#loadingSpinner').hide();
|
$('#loadingSpinner').hide();
|
||||||
@@ -417,27 +505,79 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Handle Approve Button Click
|
||||||
|
$('.final-approve-modal').on('click', function () {
|
||||||
|
const approveUrl = $(this).data('id');
|
||||||
|
|
||||||
|
// Show spinner and hide content initially
|
||||||
|
$('#finalLoadingSpinner').show();
|
||||||
|
$('#finalModalContent').addClass('d-none');
|
||||||
|
|
||||||
|
$('#finalApproveForm').attr('action', approveUrl); // Set the form action
|
||||||
|
$('#finalLoadingSpinner').addClass('d-flex');
|
||||||
|
$('#finalApproveModal').modal('show'); // Show the modal
|
||||||
|
|
||||||
|
// Get detail from /forms/entertainment/detail/{id}
|
||||||
|
$.get(approveUrl.replace('final-approve', 'detail'), function (data) {
|
||||||
|
console.log(data);
|
||||||
|
const formatter = new Intl.NumberFormat('id-ID', {
|
||||||
|
style: 'currency',
|
||||||
|
currency: 'IDR',
|
||||||
|
minimumFractionDigits: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#final_total_value').text(formatter.format(data.total));
|
||||||
|
|
||||||
|
// Assign data values to checkboxes
|
||||||
|
$('#final_total').data('value', data.total);
|
||||||
|
|
||||||
|
// Detail data
|
||||||
|
$('#final_user').text(data.user.name);
|
||||||
|
$('#final_expense_number').text(data.expense_number);
|
||||||
|
$('#final_tanggal').text(new Date(data.created_at).toLocaleDateString('id-ID', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
day: 'numeric'
|
||||||
|
}));
|
||||||
|
|
||||||
|
$('#final_nik_or_npwp').text(data.nik_or_npwp);
|
||||||
|
$('#final_name').text(data.name);
|
||||||
|
$('#final_jenis').text(data.jenis);
|
||||||
|
$('#final_keterangan').text(data.keterangan);
|
||||||
|
|
||||||
|
|
||||||
|
$('#final_bukti_total').html(data.bukti_total ? '<a href="' + data.bukti_total + '" target="_blank">Download</a>' : '-');
|
||||||
|
|
||||||
|
// Hide spinner and show content
|
||||||
|
$('#finalLoadingSpinner').hide();
|
||||||
|
$('#finalLoadingSpinner').removeClass('d-flex');
|
||||||
|
$('#finalLoadingSpinner').addClass('d-none');
|
||||||
|
$('#finalModalContent').removeClass('d-none');
|
||||||
|
|
||||||
|
// Reset the total to zero
|
||||||
|
$('#total').val(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Update total dynamically
|
// Update total dynamically
|
||||||
$('.custom-control-input').on('change', function () {
|
$('.custom-control-input').on('change', function () {
|
||||||
let total = 0;
|
let total = 0;
|
||||||
|
|
||||||
// Calculate the total based on checked checkboxes
|
|
||||||
$('.custom-control-input:checked').each(function () {
|
$('.custom-control-input:checked').each(function () {
|
||||||
total += parseFloat($(this).data('value') || 0);
|
total += parseFloat($(this).data('value') || 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update the total field with formatted value
|
|
||||||
const formatter = new Intl.NumberFormat('id-ID', {
|
const formatter = new Intl.NumberFormat('id-ID', {
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
currency: 'IDR',
|
currency: 'IDR',
|
||||||
minimumFractionDigits: 0
|
minimumFractionDigits: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#total').val(formatter.format(total));
|
$('#total').val(formatter.format(total));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Uncheck all checkboxes when the modal is closed
|
// Uncheck all checkboxes when the modal is closed
|
||||||
$('#approveModal').on('hidden.bs.modal', function () {
|
$('#finalApproveModal').on('hidden.bs.modal', function () {
|
||||||
$('.custom-control-input').prop('checked', false); // Uncheck all checkboxes
|
$('.custom-control-input').prop('checked', false); // Uncheck all checkboxes
|
||||||
$('#total').val('0'); // Reset total to 0
|
$('#total').val('0'); // Reset total to 0
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,11 +22,30 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
<style>
|
||||||
|
#loading-spinner-overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black background */
|
||||||
|
z-index: 9999; /* High z-index to cover everything */
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner-wrapper {
|
||||||
|
text-align: center;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="card card-primary card-outline">
|
<div class="card card-primary card-outline">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form method="POST" action="{{ route('forms.meeting.store') }}" enctype="multipart/form-data">
|
<form id="expense-form" method="POST" action="{{ route('forms.meeting.store') }}" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
@include('backend.layouts.partials.messages')
|
@include('backend.layouts.partials.messages')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -63,6 +82,14 @@
|
|||||||
<button type="submit" class="btn btn-primary ml-2">Submit</button>
|
<button type="submit" class="btn btn-primary ml-2">Submit</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<div id="loading-spinner-overlay" class="d-none">
|
||||||
|
<div class="spinner-wrapper">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
</div>
|
||||||
|
<p>Submitting, please wait...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -92,5 +119,11 @@
|
|||||||
decimalPlaces: 0, // Tidak ada angka desimal
|
decimalPlaces: 0, // Tidak ada angka desimal
|
||||||
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.getElementById('expense-form').addEventListener('submit', function (e) {
|
||||||
|
const spinnerOverlay = document.getElementById('loading-spinner-overlay');
|
||||||
|
spinnerOverlay.classList.remove('d-none'); // Show overlay
|
||||||
|
spinnerOverlay.classList.add('d-flex'); // Use flexbox for centering
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -22,11 +22,30 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
<style>
|
||||||
|
#loading-spinner-overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black background */
|
||||||
|
z-index: 9999; /* High z-index to cover everything */
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner-wrapper {
|
||||||
|
text-align: center;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="card card-primary card-outline">
|
<div class="card card-primary card-outline">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form method="POST" action="{{ route('forms.meeting.update', $form->id) }}" enctype="multipart/form-data">
|
<form id="expense-form" method="POST" action="{{ route('forms.meeting.update', $form->id) }}" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
@method('PUT')
|
@method('PUT')
|
||||||
@include('backend.layouts.partials.messages')
|
@include('backend.layouts.partials.messages')
|
||||||
@@ -64,6 +83,14 @@
|
|||||||
<button type="submit" class="btn btn-primary ml-2">Update</button>
|
<button type="submit" class="btn btn-primary ml-2">Update</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<div id="loading-spinner-overlay" class="d-none">
|
||||||
|
<div class="spinner-wrapper">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
</div>
|
||||||
|
<p>Submitting, please wait...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -93,5 +120,11 @@
|
|||||||
decimalPlaces: 0, // Tidak ada angka desimal
|
decimalPlaces: 0, // Tidak ada angka desimal
|
||||||
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.getElementById('expense-form').addEventListener('submit', function (e) {
|
||||||
|
const spinnerOverlay = document.getElementById('loading-spinner-overlay');
|
||||||
|
spinnerOverlay.classList.remove('d-none'); // Show overlay
|
||||||
|
spinnerOverlay.classList.add('d-flex'); // Use flexbox for centering
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -75,7 +75,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="card card-primary card-outline">
|
<div class="card card-primary card-outline">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@@ -109,7 +109,10 @@
|
|||||||
<th>Account Number</th>
|
<th>Account Number</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
@if (auth()->user()->can('approval.approve'))
|
@if (auth()->user()->can('approval.approve'))
|
||||||
<th>Approval</th>
|
<th>Approval 1</th>
|
||||||
|
@endif
|
||||||
|
@if (auth()->user()->can('approval2.approve'))
|
||||||
|
<th>Approval 2</th>
|
||||||
@endif
|
@endif
|
||||||
@if (auth()->user()->can('final_approval.approve'))
|
@if (auth()->user()->can('final_approval.approve'))
|
||||||
<th>Final Approval</th>
|
<th>Final Approval</th>
|
||||||
@@ -138,7 +141,7 @@
|
|||||||
<td>
|
<td>
|
||||||
@if ($item->status == 'On Progress')
|
@if ($item->status == 'On Progress')
|
||||||
<span class="badge badge-warning text-white">{{ $item->status }}</span>
|
<span class="badge badge-warning text-white">{{ $item->status }}</span>
|
||||||
@elseif ($item->status == 'Approved' || $item->status == 'Final Approved')
|
@elseif ($item->status == 'Approved 1' || $item->status == 'Approved 2' || $item->status == 'Final Approved')
|
||||||
<span class="badge badge-success text-white">{{ $item->status }}</span>
|
<span class="badge badge-success text-white">{{ $item->status }}</span>
|
||||||
@else
|
@else
|
||||||
<span class="badge badge-danger text-white">{{ $item->status }}</span>
|
<span class="badge badge-danger text-white">{{ $item->status }}</span>
|
||||||
@@ -147,16 +150,16 @@
|
|||||||
@if (auth()->user()->can('approval.approve'))
|
@if (auth()->user()->can('approval.approve'))
|
||||||
<td>
|
<td>
|
||||||
{{-- approve / reject button --}}
|
{{-- approve / reject button --}}
|
||||||
@if ($item->status == 'On Progress')
|
@if ($item->status == 'On Progress' || $item->status == 'Rejected')
|
||||||
<form action="javascript:void(0);" class="d-inline">
|
<form action="javascript:void(0);" class="d-inline">
|
||||||
<button type="button"
|
<button type="button"
|
||||||
class="btn btn-success btn-sm open-approve-modal"
|
class="btn btn-success btn-sm open-approve-modal"
|
||||||
data-id="{{ route('forms.meeting.approve', $item->id) }}">
|
data-id="{{ route('forms.meeting.approve', $item->id) }}">
|
||||||
Approve
|
Approve 1
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form action="{{ route('forms.meeting.reject', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to reject this item?');">
|
<form action="{{ route('forms.meeting.reject', $item->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to reject this item?');">
|
||||||
@csrf
|
@csrf
|
||||||
@method('PUT')
|
@method('PUT')
|
||||||
<button type="submit" class="btn btn-danger btn-sm">
|
<button type="submit" class="btn btn-danger btn-sm">
|
||||||
@@ -174,14 +177,44 @@
|
|||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
@endif
|
@endif
|
||||||
|
@if (auth()->user()->can('approval2.approve'))
|
||||||
|
<td>
|
||||||
|
{{-- approve / reject button --}}
|
||||||
|
@if ($item->status == 'Approved 1' && $item->approved_at)
|
||||||
|
<form action="javascript:void(0);" class="d-inline">
|
||||||
|
<button type="button"
|
||||||
|
class="btn btn-success btn-sm open-approve-modal"
|
||||||
|
data-id="{{ route('forms.meeting.approve2', $item->id) }}">
|
||||||
|
Approve 2
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form action="{{ route('forms.meeting.reject', $item->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to reject this item?');">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
<button type="submit" class="btn btn-danger btn-sm">
|
||||||
|
Reject
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@else
|
||||||
|
@if ($item->approved2_at)
|
||||||
|
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
|
||||||
|
@elseif($item->rejected_at)
|
||||||
|
{{ \Carbon\Carbon::parse($item->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
|
||||||
|
@else
|
||||||
|
-
|
||||||
|
@endif
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
@endif
|
||||||
@if(auth()->user()->can('final_approval.approve'))
|
@if(auth()->user()->can('final_approval.approve'))
|
||||||
<td>
|
<td>
|
||||||
{{-- approve / reject button --}}
|
{{-- approve / reject button --}}
|
||||||
@if ($item->status == 'Approved' && $item->approved_at && !$item->final_approved_at)
|
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
|
||||||
<form action="{{ route('forms.meeting.final-approve', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this item?');">
|
<form action="javascript:void(0);" class="d-inline">
|
||||||
@csrf
|
<button type="button"
|
||||||
@method('PUT')
|
class="btn btn-success btn-sm final-approve-modal"
|
||||||
<button type="submit" class="btn btn-success btn-sm">
|
data-id="{{ route('forms.meeting.final-approve', $item->id) }}">
|
||||||
Final Approve
|
Final Approve
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
@@ -235,7 +268,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<div class="modal fade" id="approveModal" tabindex="-1" role="dialog" aria-labelledby="approveModalLabel" aria-hidden="true">
|
<div class="modal fade" id="approveModal" tabindex="-1" role="dialog" aria-labelledby="approveModalLabel" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-lg" role="document">
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@@ -267,44 +300,112 @@
|
|||||||
<strong>User:</strong> <span id="user"></span>
|
<strong>User:</strong> <span id="user"></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Tipe:</strong> Meeting & Seminar
|
<strong>Tipe:</strong> Meeting / Seminar
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Tanggal:</strong> <span id="tanggal"></span>
|
<strong>Tanggal:</strong> <span id="tanggal"></span>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Nominal Allowance:</strong> <span id="allowance_value"></span>
|
||||||
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Bukti Allowance:</strong> <span id="bukti_allowance"></span>
|
<strong>Bukti Allowance:</strong> <span id="bukti_allowance"></span>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Nominal Transport Antar Kota:</strong> <span id="transport_ankot_value"></span>
|
||||||
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Bukti Transport Antar Kota:</strong> <span id="bukti_transport_ankot"></span>
|
<strong>Bukti Transport Antar Kota:</strong> <span id="bukti_transport_ankot"></span>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Nominal Hotel:</strong> <span id="hotel_value"></span>
|
||||||
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Bukti Hotel:</strong> <span id="bukti_hotel"></span>
|
<strong>Bukti Hotel:</strong> <span id="bukti_hotel"></span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Approve</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<div class="modal fade" id="finalApproveModal" tabindex="-1" role="dialog" aria-labelledby="finalApproveModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<form id="finalApproveForm" method="POST" action="">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="approveModalLabel">Approve Item</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<!-- Loading spinner -->
|
||||||
|
<div id="finalLoadingSpinner" class="d-flex justify-content-center align-items-center" style="height: 200px;">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
<span class="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal content (hidden initially) -->
|
||||||
|
<div id="finalModalContent" class="d-none">
|
||||||
|
<p>Please review the details below:</p>
|
||||||
|
<ul class="list-group">
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Expense Number:</strong> <span id="final_expense_number"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>User:</strong> <span id="final_user"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Tipe:</strong> Meeting / Seminar
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Tanggal:</strong> <span id="final_tanggal"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Bukti Allowance:</strong> <span id="final_bukti_allowance"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Bukti Transport Antar Kota:</strong> <span id="final_bukti_transport_ankot"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Bukti Hotel:</strong> <span id="final_bukti_hotel"></span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
<p class="mt-2">Please select the items you want to approve:</p>
|
<p class="mt-2">Please select the items you want to approve:</p>
|
||||||
<ul class="list-group list-unstyled">
|
<ul class="list-group list-unstyled">
|
||||||
<li>
|
<li>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="custom-control custom-checkbox">
|
<div class="custom-control custom-checkbox">
|
||||||
<input type="checkbox" class="custom-control-input" id="allowance" name="allowance">
|
<input type="checkbox" class="custom-control-input" id="final_allowance" name="allowance">
|
||||||
<label class="custom-control-label" for="allowance">Allowance (<span id="allowance_value"></span>)</label>
|
<label class="custom-control-label" for="final_allowance">Allowance (<span id="final_allowance_value"></span>)</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="custom-control custom-checkbox">
|
<div class="custom-control custom-checkbox">
|
||||||
<input type="checkbox" class="custom-control-input" id="transport_ankot" name="transport_ankot">
|
<input type="checkbox" class="custom-control-input" id="final_transport_ankot" name="transport_ankot">
|
||||||
<label class="custom-control-label" for="transport_ankot">Transport Ankot (<span id="transport_ankot_value"></span>)</label>
|
<label class="custom-control-label" for="final_transport_ankot">Transport Ankot (<span id="final_transport_ankot_value"></span>)</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="custom-control custom-checkbox">
|
<div class="custom-control custom-checkbox">
|
||||||
<input type="checkbox" class="custom-control-input" id="hotel" name="hotel">
|
<input type="checkbox" class="custom-control-input" id="final_hotel" name="hotel">
|
||||||
<label class="custom-control-label" for="hotel">Hotel (<span id="hotel_value"></span>)</label>
|
<label class="custom-control-label" for="final_hotel">Hotel (<span id="final_hotel_value"></span>)</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
@@ -379,8 +480,8 @@
|
|||||||
$('#loadingSpinner').addClass('d-flex');
|
$('#loadingSpinner').addClass('d-flex');
|
||||||
$('#approveModal').modal('show'); // Show the modal
|
$('#approveModal').modal('show'); // Show the modal
|
||||||
|
|
||||||
// Get detail from /forms/up-country/detail/{id}
|
// Get detail from /forms/meeting/detail/{id}
|
||||||
$.get(approveUrl.replace('approve', 'detail'), function (data) {
|
$.get(approveUrl.replace(/approve(2)?/, 'detail'), function (data) {
|
||||||
const formatter = new Intl.NumberFormat('id-ID', {
|
const formatter = new Intl.NumberFormat('id-ID', {
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
currency: 'IDR',
|
currency: 'IDR',
|
||||||
@@ -391,11 +492,6 @@
|
|||||||
$('#transport_ankot_value').text(formatter.format(data.transport_ankot));
|
$('#transport_ankot_value').text(formatter.format(data.transport_ankot));
|
||||||
$('#hotel_value').text(formatter.format(data.hotel));
|
$('#hotel_value').text(formatter.format(data.hotel));
|
||||||
|
|
||||||
// Assign data values to checkboxes
|
|
||||||
$('#allowance').data('value', data.allowance);
|
|
||||||
$('#transport_ankot').data('value', data.transport_ankot);
|
|
||||||
$('#hotel').data('value', data.hotel);
|
|
||||||
|
|
||||||
// Detail data
|
// Detail data
|
||||||
$('#user').text(data.user.name);
|
$('#user').text(data.user.name);
|
||||||
$('#expense_number').text(data.expense_number);
|
$('#expense_number').text(data.expense_number);
|
||||||
@@ -420,27 +516,79 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Handle Approve Button Click
|
||||||
|
$('.final-approve-modal').on('click', function () {
|
||||||
|
const approveUrl = $(this).data('id');
|
||||||
|
|
||||||
|
// Show spinner and hide content initially
|
||||||
|
$('#finalLoadingSpinner').show();
|
||||||
|
$('#finalModalContent').addClass('d-none');
|
||||||
|
|
||||||
|
$('#finalApproveForm').attr('action', approveUrl); // Set the form action
|
||||||
|
$('#finalLoadingSpinner').addClass('d-flex');
|
||||||
|
$('#finalApproveModal').modal('show'); // Show the modal
|
||||||
|
|
||||||
|
// Get detail from /forms/meeting/detail/{id}
|
||||||
|
$.get(approveUrl.replace('final-approve', 'detail'), function (data) {
|
||||||
|
console.log(data);
|
||||||
|
const formatter = new Intl.NumberFormat('id-ID', {
|
||||||
|
style: 'currency',
|
||||||
|
currency: 'IDR',
|
||||||
|
minimumFractionDigits: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#final_allowance_value').text(formatter.format(data.allowance));
|
||||||
|
$('#final_transport_ankot_value').text(formatter.format(data.transport_ankot));
|
||||||
|
$('#final_hotel_value').text(formatter.format(data.hotel));
|
||||||
|
|
||||||
|
// Assign data values to checkboxes
|
||||||
|
$('#final_allowance').data('value', data.allowance);
|
||||||
|
$('#final_transport_ankot').data('value', data.transport_ankot);
|
||||||
|
$('#final_hotel').data('value', data.hotel);
|
||||||
|
|
||||||
|
// Detail data
|
||||||
|
$('#final_user').text(data.user.name);
|
||||||
|
$('#final_expense_number').text(data.expense_number);
|
||||||
|
$('#final_tanggal').text(new Date(data.created_at).toLocaleDateString('id-ID', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
day: 'numeric'
|
||||||
|
}));
|
||||||
|
|
||||||
|
$('#final_bukti_allowance').html(data.bukti_allowance ? '<a href="' + data.bukti_allowance + '" target="_blank">Download</a>' : '-');
|
||||||
|
$('#final_bukti_transport_ankot').html(data.bukti_transport_ankot ? '<a href="' + data.bukti_transport_ankot + '" target="_blank">Download</a>' : '-');
|
||||||
|
$('#final_bukti_hotel').html(data.bukti_hotel ? '<a href="' + data.bukti_hotel + '" target="_blank">Download</a>' : '-');
|
||||||
|
|
||||||
|
// Hide spinner and show content
|
||||||
|
$('#finalLoadingSpinner').hide();
|
||||||
|
$('#finalLoadingSpinner').removeClass('d-flex');
|
||||||
|
$('#finalLoadingSpinner').addClass('d-none');
|
||||||
|
$('#finalModalContent').removeClass('d-none');
|
||||||
|
|
||||||
|
// Reset the total to zero
|
||||||
|
$('#total').val(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Update total dynamically
|
// Update total dynamically
|
||||||
$('.custom-control-input').on('change', function () {
|
$('.custom-control-input').on('change', function () {
|
||||||
let total = 0;
|
let total = 0;
|
||||||
|
|
||||||
// Calculate the total based on checked checkboxes
|
|
||||||
$('.custom-control-input:checked').each(function () {
|
$('.custom-control-input:checked').each(function () {
|
||||||
total += parseFloat($(this).data('value') || 0);
|
total += parseFloat($(this).data('value') || 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update the total field with formatted value
|
|
||||||
const formatter = new Intl.NumberFormat('id-ID', {
|
const formatter = new Intl.NumberFormat('id-ID', {
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
currency: 'IDR',
|
currency: 'IDR',
|
||||||
minimumFractionDigits: 0
|
minimumFractionDigits: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#total').val(formatter.format(total));
|
$('#total').val(formatter.format(total));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Uncheck all checkboxes when the modal is closed
|
// Uncheck all checkboxes when the modal is closed
|
||||||
$('#approveModal').on('hidden.bs.modal', function () {
|
$('#finalApproveModal').on('hidden.bs.modal', function () {
|
||||||
$('.custom-control-input').prop('checked', false); // Uncheck all checkboxes
|
$('.custom-control-input').prop('checked', false); // Uncheck all checkboxes
|
||||||
$('#total').val('0'); // Reset total to 0
|
$('#total').val('0'); // Reset total to 0
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,11 +22,30 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
<style>
|
||||||
|
#loading-spinner-overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black background */
|
||||||
|
z-index: 9999; /* High z-index to cover everything */
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner-wrapper {
|
||||||
|
text-align: center;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="card card-primary card-outline">
|
<div class="card card-primary card-outline">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form method="POST" action="{{ route('forms.other.store') }}" enctype="multipart/form-data">
|
<form id="expense-form" method="POST" action="{{ route('forms.other.store') }}" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
@include('backend.layouts.partials.messages')
|
@include('backend.layouts.partials.messages')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -66,6 +85,14 @@
|
|||||||
<button type="submit" class="btn btn-primary ml-2">Submit</button>
|
<button type="submit" class="btn btn-primary ml-2">Submit</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<div id="loading-spinner-overlay" class="d-none">
|
||||||
|
<div class="spinner-wrapper">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
</div>
|
||||||
|
<p>Submitting, please wait...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -79,5 +106,11 @@
|
|||||||
decimalPlaces: 0, // Tidak ada angka desimal
|
decimalPlaces: 0, // Tidak ada angka desimal
|
||||||
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.getElementById('expense-form').addEventListener('submit', function (e) {
|
||||||
|
const spinnerOverlay = document.getElementById('loading-spinner-overlay');
|
||||||
|
spinnerOverlay.classList.remove('d-none'); // Show overlay
|
||||||
|
spinnerOverlay.classList.add('d-flex'); // Use flexbox for centering
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -22,11 +22,30 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
<style>
|
||||||
|
#loading-spinner-overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black background */
|
||||||
|
z-index: 9999; /* High z-index to cover everything */
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner-wrapper {
|
||||||
|
text-align: center;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="card card-primary card-outline">
|
<div class="card card-primary card-outline">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form method="POST" action="{{ route('forms.other.update', $form->id) }}" enctype="multipart/form-data">
|
<form id="expense-form" method="POST" action="{{ route('forms.other.update', $form->id) }}" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
@method('PUT')
|
@method('PUT')
|
||||||
@include('backend.layouts.partials.messages')
|
@include('backend.layouts.partials.messages')
|
||||||
@@ -67,6 +86,14 @@
|
|||||||
<button type="submit" class="btn btn-primary ml-2">Update</button>
|
<button type="submit" class="btn btn-primary ml-2">Update</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<div id="loading-spinner-overlay" class="d-none">
|
||||||
|
<div class="spinner-wrapper">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
</div>
|
||||||
|
<p>Submitting, please wait...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -80,5 +107,11 @@
|
|||||||
decimalPlaces: 0, // Tidak ada angka desimal
|
decimalPlaces: 0, // Tidak ada angka desimal
|
||||||
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.getElementById('expense-form').addEventListener('submit', function (e) {
|
||||||
|
const spinnerOverlay = document.getElementById('loading-spinner-overlay');
|
||||||
|
spinnerOverlay.classList.remove('d-none'); // Show overlay
|
||||||
|
spinnerOverlay.classList.add('d-flex'); // Use flexbox for centering
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -109,7 +109,10 @@
|
|||||||
<th>Account Number</th>
|
<th>Account Number</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
@if (auth()->user()->can('approval.approve'))
|
@if (auth()->user()->can('approval.approve'))
|
||||||
<th>Approval</th>
|
<th>Approval 1</th>
|
||||||
|
@endif
|
||||||
|
@if (auth()->user()->can('approval2.approve'))
|
||||||
|
<th>Approval 2</th>
|
||||||
@endif
|
@endif
|
||||||
@if (auth()->user()->can('final_approval.approve'))
|
@if (auth()->user()->can('final_approval.approve'))
|
||||||
<th>Final Approval</th>
|
<th>Final Approval</th>
|
||||||
@@ -146,7 +149,7 @@
|
|||||||
<td>
|
<td>
|
||||||
@if ($item->status == 'On Progress')
|
@if ($item->status == 'On Progress')
|
||||||
<span class="badge badge-warning text-white">{{ $item->status }}</span>
|
<span class="badge badge-warning text-white">{{ $item->status }}</span>
|
||||||
@elseif ($item->status == 'Approved' || $item->status == 'Final Approved')
|
@elseif ($item->status == 'Approved 1' || $item->status == 'Approved 2' || $item->status == 'Final Approved')
|
||||||
<span class="badge badge-success text-white">{{ $item->status }}</span>
|
<span class="badge badge-success text-white">{{ $item->status }}</span>
|
||||||
@else
|
@else
|
||||||
<span class="badge badge-danger text-white">{{ $item->status }}</span>
|
<span class="badge badge-danger text-white">{{ $item->status }}</span>
|
||||||
@@ -155,16 +158,16 @@
|
|||||||
@if (auth()->user()->can('approval.approve'))
|
@if (auth()->user()->can('approval.approve'))
|
||||||
<td>
|
<td>
|
||||||
{{-- approve / reject button --}}
|
{{-- approve / reject button --}}
|
||||||
@if ($item->status == 'On Progress')
|
@if ($item->status == 'On Progress' || $item->status == 'Rejected')
|
||||||
<form action="javascript:void(0);" class="d-inline">
|
<form action="javascript:void(0);" class="d-inline">
|
||||||
<button type="button"
|
<button type="button"
|
||||||
class="btn btn-success btn-sm open-approve-modal"
|
class="btn btn-success btn-sm open-approve-modal"
|
||||||
data-id="{{ route('forms.other.approve', $item->id) }}">
|
data-id="{{ route('forms.other.approve', $item->id) }}">
|
||||||
Approve
|
Approve 1
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form action="{{ route('forms.other.reject', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to reject this item?');">
|
<form action="{{ route('forms.other.reject', $item->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to reject this item?');">
|
||||||
@csrf
|
@csrf
|
||||||
@method('PUT')
|
@method('PUT')
|
||||||
<button type="submit" class="btn btn-danger btn-sm">
|
<button type="submit" class="btn btn-danger btn-sm">
|
||||||
@@ -182,14 +185,44 @@
|
|||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
@endif
|
@endif
|
||||||
|
@if (auth()->user()->can('approval2.approve'))
|
||||||
|
<td>
|
||||||
|
{{-- approve / reject button --}}
|
||||||
|
@if ($item->status == 'Approved 1' && $item->approved_at)
|
||||||
|
<form action="javascript:void(0);" class="d-inline">
|
||||||
|
<button type="button"
|
||||||
|
class="btn btn-success btn-sm open-approve-modal"
|
||||||
|
data-id="{{ route('forms.other.approve2', $item->id) }}">
|
||||||
|
Approve 2
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form action="{{ route('forms.other.reject', $item->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to reject this item?');">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
<button type="submit" class="btn btn-danger btn-sm">
|
||||||
|
Reject
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@else
|
||||||
|
@if ($item->approved2_at)
|
||||||
|
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
|
||||||
|
@elseif($item->rejected_at)
|
||||||
|
{{ \Carbon\Carbon::parse($item->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
|
||||||
|
@else
|
||||||
|
-
|
||||||
|
@endif
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
@endif
|
||||||
@if(auth()->user()->can('final_approval.approve'))
|
@if(auth()->user()->can('final_approval.approve'))
|
||||||
<td>
|
<td>
|
||||||
{{-- approve / reject button --}}
|
{{-- approve / reject button --}}
|
||||||
@if ($item->status == 'Approved' && $item->approved_at && !$item->final_approved_at)
|
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
|
||||||
<form action="{{ route('forms.other.final-approve', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this item?');">
|
<form action="javascript:void(0);" class="d-inline">
|
||||||
@csrf
|
<button type="button"
|
||||||
@method('PUT')
|
class="btn btn-success btn-sm final-approve-modal"
|
||||||
<button type="submit" class="btn btn-success btn-sm">
|
data-id="{{ route('forms.other.final-approve', $item->id) }}">
|
||||||
Final Approve
|
Final Approve
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
@@ -278,13 +311,72 @@
|
|||||||
<strong>Kategori:</strong> <span id="kategori"></span>
|
<strong>Kategori:</strong> <span id="kategori"></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Tanggal & Waktu:</strong> <span id="tanggal"></span>
|
<strong>Tanggal:</strong> <span id="tanggal"></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Keterangan:</strong> <span id="keterangan"></span>
|
<strong>Keterangan:</strong> <span id="keterangan"></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Bukti Total Pengeluaran:</strong> <span id="bukti_total"></span>
|
<strong>Bukti Total:</strong> <span id="bukti_total"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Nominal Total:</strong> <span id="total_value"></span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Approve</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<div class="modal fade" id="finalApproveModal" tabindex="-1" role="dialog" aria-labelledby="finalApproveModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<form id="finalApproveForm" method="POST" action="">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="approveModalLabel">Approve Item</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<!-- Loading spinner -->
|
||||||
|
<div id="finalLoadingSpinner" class="d-flex justify-content-center align-items-center" style="height: 200px;">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
<span class="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal content (hidden initially) -->
|
||||||
|
<div id="finalModalContent" class="d-none">
|
||||||
|
<p>Please review the details below:</p>
|
||||||
|
<ul class="list-group">
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Expense Number:</strong> <span id="final_expense_number"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>User:</strong> <span id="final_user"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Kategori:</strong> <span id="final_kategori"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Tanggal:</strong> <span id="final_tanggal"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Keterangan:</strong> <span id="final_keterangan"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Bukti Total:</strong> <span id="final_bukti_total"></span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p class="mt-2">Please select the items you want to approve:</p>
|
<p class="mt-2">Please select the items you want to approve:</p>
|
||||||
@@ -292,17 +384,11 @@
|
|||||||
<li>
|
<li>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="custom-control custom-checkbox">
|
<div class="custom-control custom-checkbox">
|
||||||
<input type="checkbox" class="custom-control-input" id="total_pengeluaran" name="total_pengeluaran">
|
<input type="checkbox" class="custom-control-input" id="final_total" name="total" required>
|
||||||
<label class="custom-control-label" for="total_pengeluaran">Total Pengeluaran (<span id="total_pengeluaran_value"></span>)</label>
|
<label class="custom-control-label" for="final_total">Total (<span id="final_total_value"></span>)</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="total">Total</label>
|
|
||||||
<input type="text" class="form-control" id="total" name="total" value="0" readonly>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -368,31 +454,29 @@
|
|||||||
$('#loadingSpinner').addClass('d-flex');
|
$('#loadingSpinner').addClass('d-flex');
|
||||||
$('#approveModal').modal('show'); // Show the modal
|
$('#approveModal').modal('show'); // Show the modal
|
||||||
|
|
||||||
// Get detail from /forms/up-country/detail/{id}
|
// Get detail from /forms/vehicle/detail/{id}
|
||||||
$.get(approveUrl.replace('approve', 'detail'), function (data) {
|
$.get(approveUrl.replace(/approve(2)?/, 'detail'), function (data) {
|
||||||
const formatter = new Intl.NumberFormat('id-ID', {
|
const formatter = new Intl.NumberFormat('id-ID', {
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
currency: 'IDR',
|
currency: 'IDR',
|
||||||
minimumFractionDigits: 0
|
minimumFractionDigits: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#kategori').text(data.kategori.name);
|
$('#total_value').text(formatter.format(data.total));
|
||||||
$('#keterangan').text(data.keterangan);
|
|
||||||
$('#total_pengeluaran_value').text(formatter.format(data.total));
|
|
||||||
$('#total_pengeluaran').data('value', data.total);
|
|
||||||
|
|
||||||
// Detail data
|
// Detail data
|
||||||
$('#user').text(data.user.name);
|
$('#user').text(data.user.name);
|
||||||
$('#expense_number').text(data.expense_number);
|
$('#expense_number').text(data.expense_number);
|
||||||
$('#tanggal').text(new Date(data.tanggal).toLocaleDateString('id-ID', {
|
$('#tanggal').text(new Date(data.created_at).toLocaleDateString('id-ID', {
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
month: 'long',
|
month: 'long',
|
||||||
day: 'numeric',
|
day: 'numeric'
|
||||||
hour: '2-digit',
|
|
||||||
minute: '2-digit',
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
$('#kategori').text(data.kategori.name);
|
||||||
|
$('#keterangan').text(data.keterangan);
|
||||||
|
|
||||||
$('#bukti_total').html(data.bukti_total ? '<a href="' + data.bukti_total + '" target="_blank">Download</a>' : '-');
|
$('#bukti_total').html(data.total ? '<a href="' + data.total + '" target="_blank">Download</a>' : '-');
|
||||||
|
|
||||||
// Hide spinner and show content
|
// Hide spinner and show content
|
||||||
$('#loadingSpinner').hide();
|
$('#loadingSpinner').hide();
|
||||||
@@ -405,27 +489,76 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Handle Approve Button Click
|
||||||
|
$('.final-approve-modal').on('click', function () {
|
||||||
|
const approveUrl = $(this).data('id');
|
||||||
|
|
||||||
|
// Show spinner and hide content initially
|
||||||
|
$('#finalLoadingSpinner').show();
|
||||||
|
$('#finalModalContent').addClass('d-none');
|
||||||
|
|
||||||
|
$('#finalApproveForm').attr('action', approveUrl); // Set the form action
|
||||||
|
$('#finalLoadingSpinner').addClass('d-flex');
|
||||||
|
$('#finalApproveModal').modal('show'); // Show the modal
|
||||||
|
|
||||||
|
// Get detail from /forms/vehicle/detail/{id}
|
||||||
|
$.get(approveUrl.replace('final-approve', 'detail'), function (data) {
|
||||||
|
console.log(data);
|
||||||
|
const formatter = new Intl.NumberFormat('id-ID', {
|
||||||
|
style: 'currency',
|
||||||
|
currency: 'IDR',
|
||||||
|
minimumFractionDigits: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#final_total_value').text(formatter.format(data.total));
|
||||||
|
|
||||||
|
// Assign data values to checkboxes
|
||||||
|
$('#final_total').data('value', data.total);
|
||||||
|
|
||||||
|
// Detail data
|
||||||
|
$('#final_user').text(data.user.name);
|
||||||
|
$('#final_expense_number').text(data.expense_number);
|
||||||
|
$('#final_tanggal').text(new Date(data.created_at).toLocaleDateString('id-ID', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
day: 'numeric'
|
||||||
|
}));
|
||||||
|
|
||||||
|
$('#final_kategori').text(data.kategori.name);
|
||||||
|
$('#final_keterangan').text(data.keterangan);
|
||||||
|
|
||||||
|
$('#final_bukti_total').html(data.bukti_total ? '<a href="' + data.bukti_total + '" target="_blank">Download</a>' : '-');
|
||||||
|
|
||||||
|
// Hide spinner and show content
|
||||||
|
$('#finalLoadingSpinner').hide();
|
||||||
|
$('#finalLoadingSpinner').removeClass('d-flex');
|
||||||
|
$('#finalLoadingSpinner').addClass('d-none');
|
||||||
|
$('#finalModalContent').removeClass('d-none');
|
||||||
|
|
||||||
|
// Reset the total to zero
|
||||||
|
$('#total').val(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Update total dynamically
|
// Update total dynamically
|
||||||
$('.custom-control-input').on('change', function () {
|
$('.custom-control-input').on('change', function () {
|
||||||
let total = 0;
|
let total = 0;
|
||||||
|
|
||||||
// Calculate the total based on checked checkboxes
|
|
||||||
$('.custom-control-input:checked').each(function () {
|
$('.custom-control-input:checked').each(function () {
|
||||||
total += parseFloat($(this).data('value') || 0);
|
total += parseFloat($(this).data('value') || 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update the total field with formatted value
|
|
||||||
const formatter = new Intl.NumberFormat('id-ID', {
|
const formatter = new Intl.NumberFormat('id-ID', {
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
currency: 'IDR',
|
currency: 'IDR',
|
||||||
minimumFractionDigits: 0
|
minimumFractionDigits: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#total').val(formatter.format(total));
|
$('#total').val(formatter.format(total));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Uncheck all checkboxes when the modal is closed
|
// Uncheck all checkboxes when the modal is closed
|
||||||
$('#approveModal').on('hidden.bs.modal', function () {
|
$('#finalApproveModal').on('hidden.bs.modal', function () {
|
||||||
$('.custom-control-input').prop('checked', false); // Uncheck all checkboxes
|
$('.custom-control-input').prop('checked', false); // Uncheck all checkboxes
|
||||||
$('#total').val('0'); // Reset total to 0
|
$('#total').val('0'); // Reset total to 0
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -21,11 +21,30 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
<style>
|
||||||
|
#loading-spinner-overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black background */
|
||||||
|
z-index: 9999; /* High z-index to cover everything */
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner-wrapper {
|
||||||
|
text-align: center;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="card card-primary card-outline">
|
<div class="card card-primary card-outline">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form method="POST" action="{{ route('forms.up-country.store') }}" enctype="multipart/form-data">
|
<form id="expense-form" method="POST" action="{{ route('forms.up-country.store') }}" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
@include('backend.layouts.partials.messages')
|
@include('backend.layouts.partials.messages')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -91,6 +110,14 @@
|
|||||||
<button type="submit" class="btn btn-primary ml-2">Submit</button>
|
<button type="submit" class="btn btn-primary ml-2">Submit</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<div id="loading-spinner-overlay" class="d-none">
|
||||||
|
<div class="spinner-wrapper">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
</div>
|
||||||
|
<p>Submitting, please wait...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -128,5 +155,11 @@
|
|||||||
decimalPlaces: 0, // Tidak ada angka desimal
|
decimalPlaces: 0, // Tidak ada angka desimal
|
||||||
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.getElementById('expense-form').addEventListener('submit', function (e) {
|
||||||
|
const spinnerOverlay = document.getElementById('loading-spinner-overlay');
|
||||||
|
spinnerOverlay.classList.remove('d-none'); // Show overlay
|
||||||
|
spinnerOverlay.classList.add('d-flex'); // Use flexbox for centering
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -21,11 +21,30 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
<style>
|
||||||
|
#loading-spinner-overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black background */
|
||||||
|
z-index: 9999; /* High z-index to cover everything */
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner-wrapper {
|
||||||
|
text-align: center;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="card card-primary card-outline">
|
<div class="card card-primary card-outline">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form method="POST" action="{{ route('forms.up-country.update', $form->id) }}" enctype="multipart/form-data">
|
<form id="expense-form" method="POST" action="{{ route('forms.up-country.update', $form->id) }}" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
@method('PUT')
|
@method('PUT')
|
||||||
@include('backend.layouts.partials.messages')
|
@include('backend.layouts.partials.messages')
|
||||||
@@ -92,6 +111,14 @@
|
|||||||
<button type="submit" class="btn btn-primary ml-2">Save</button>
|
<button type="submit" class="btn btn-primary ml-2">Save</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<div id="loading-spinner-overlay" class="d-none">
|
||||||
|
<div class="spinner-wrapper">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
</div>
|
||||||
|
<p>Submitting, please wait...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -129,5 +156,11 @@
|
|||||||
decimalPlaces: 0, // Tidak ada angka desimal
|
decimalPlaces: 0, // Tidak ada angka desimal
|
||||||
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.getElementById('expense-form').addEventListener('submit', function (e) {
|
||||||
|
const spinnerOverlay = document.getElementById('loading-spinner-overlay');
|
||||||
|
spinnerOverlay.classList.remove('d-none'); // Show overlay
|
||||||
|
spinnerOverlay.classList.add('d-flex'); // Use flexbox for centering
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -109,7 +109,10 @@
|
|||||||
<th>Account Number</th>
|
<th>Account Number</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
@if (auth()->user()->can('approval.approve'))
|
@if (auth()->user()->can('approval.approve'))
|
||||||
<th>Approval</th>
|
<th>Approval 1</th>
|
||||||
|
@endif
|
||||||
|
@if (auth()->user()->can('approval2.approve'))
|
||||||
|
<th>Approval 2</th>
|
||||||
@endif
|
@endif
|
||||||
@if (auth()->user()->can('final_approval.approve'))
|
@if (auth()->user()->can('final_approval.approve'))
|
||||||
<th>Final Approval</th>
|
<th>Final Approval</th>
|
||||||
@@ -144,7 +147,7 @@
|
|||||||
<td>
|
<td>
|
||||||
@if ($item->status == 'On Progress')
|
@if ($item->status == 'On Progress')
|
||||||
<span class="badge badge-warning text-white">{{ $item->status }}</span>
|
<span class="badge badge-warning text-white">{{ $item->status }}</span>
|
||||||
@elseif ($item->status == 'Approved' || $item->status == 'Final Approved')
|
@elseif ($item->status == 'Approved 1' || $item->status == 'Approved 2' || $item->status == 'Final Approved')
|
||||||
<span class="badge badge-success text-white">{{ $item->status }}</span>
|
<span class="badge badge-success text-white">{{ $item->status }}</span>
|
||||||
@else
|
@else
|
||||||
<span class="badge badge-danger text-white">{{ $item->status }}</span>
|
<span class="badge badge-danger text-white">{{ $item->status }}</span>
|
||||||
@@ -153,12 +156,12 @@
|
|||||||
@if (auth()->user()->can('approval.approve'))
|
@if (auth()->user()->can('approval.approve'))
|
||||||
<td>
|
<td>
|
||||||
{{-- approve / reject button --}}
|
{{-- approve / reject button --}}
|
||||||
@if ($item->status == 'On Progress')
|
@if ($item->status == 'On Progress' || $item->status == 'Rejected')
|
||||||
<form action="javascript:void(0);" class="d-inline">
|
<form action="javascript:void(0);" class="d-inline">
|
||||||
<button type="button"
|
<button type="button"
|
||||||
class="btn btn-success btn-sm open-approve-modal"
|
class="btn btn-success btn-sm open-approve-modal"
|
||||||
data-id="{{ route('forms.up-country.approve', $item->id) }}">
|
data-id="{{ route('forms.up-country.approve', $item->id) }}">
|
||||||
Approve
|
Approve 1
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@@ -180,14 +183,44 @@
|
|||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
@endif
|
@endif
|
||||||
|
@if (auth()->user()->can('approval2.approve'))
|
||||||
|
<td>
|
||||||
|
{{-- approve / reject button --}}
|
||||||
|
@if ($item->status == 'Approved 1' && $item->approved_at)
|
||||||
|
<form action="javascript:void(0);" class="d-inline">
|
||||||
|
<button type="button"
|
||||||
|
class="btn btn-success btn-sm open-approve-modal"
|
||||||
|
data-id="{{ route('forms.up-country.approve2', $item->id) }}">
|
||||||
|
Approve 2
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form action="{{ route('forms.up-country.reject', $item->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to reject this item?');">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
<button type="submit" class="btn btn-danger btn-sm">
|
||||||
|
Reject
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@else
|
||||||
|
@if ($item->approved2_at)
|
||||||
|
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
|
||||||
|
@elseif($item->rejected_at)
|
||||||
|
{{ \Carbon\Carbon::parse($item->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
|
||||||
|
@else
|
||||||
|
-
|
||||||
|
@endif
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
@endif
|
||||||
@if(auth()->user()->can('final_approval.approve'))
|
@if(auth()->user()->can('final_approval.approve'))
|
||||||
<td>
|
<td>
|
||||||
{{-- approve / reject button --}}
|
{{-- approve / reject button --}}
|
||||||
@if ($item->status == 'Approved' && $item->approved_at && !$item->final_approved_at)
|
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
|
||||||
<form action="{{ route('forms.up-country.final-approve', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this item?');">
|
<form action="javascript:void(0);" class="d-inline">
|
||||||
@csrf
|
<button type="button"
|
||||||
@method('PUT')
|
class="btn btn-success btn-sm final-approve-modal"
|
||||||
<button type="submit" class="btn btn-success btn-sm">
|
data-id="{{ route('forms.up-country.final-approve', $item->id) }}">
|
||||||
Final Approve
|
Final Approve
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
@@ -287,50 +320,133 @@
|
|||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Jarak:</strong> <span id="jarak"></span>
|
<strong>Jarak:</strong> <span id="jarak"></span>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Nominal Allowance:</strong> <span id="allowance_value"></span>
|
||||||
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Bukti Allowance:</strong> <span id="bukti_allowance"></span>
|
<strong>Bukti Allowance:</strong> <span id="bukti_allowance"></span>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Nominal Transport Dalam Kota:</strong> <span id="transport_dalkot_value"></span>
|
||||||
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Bukti Transport Dalam Kota:</strong> <span id="bukti_transport_dalkot"></span>
|
<strong>Bukti Transport Dalam Kota:</strong> <span id="bukti_transport_dalkot"></span>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Nominal Transport Antar Kota:</strong> <span id="transport_ankot_value"></span>
|
||||||
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Bukti Transport Antar Kota:</strong> <span id="bukti_transport_ankot"></span>
|
<strong>Bukti Transport Antar Kota:</strong> <span id="bukti_transport_ankot"></span>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Nominal Hotel:</strong> <span id="hotel_value"></span>
|
||||||
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Bukti Hotel:</strong> <span id="bukti_hotel"></span>
|
<strong>Bukti Hotel:</strong> <span id="bukti_hotel"></span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Approve</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<div class="modal fade" id="finalApproveModal" tabindex="-1" role="dialog" aria-labelledby="finalApproveModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<form id="finalApproveForm" method="POST" action="">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="approveModalLabel">Approve Item</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<!-- Loading spinner -->
|
||||||
|
<div id="finalLoadingSpinner" class="d-flex justify-content-center align-items-center" style="height: 200px;">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
<span class="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal content (hidden initially) -->
|
||||||
|
<div id="finalModalContent" class="d-none">
|
||||||
|
<p>Please review the details below:</p>
|
||||||
|
<ul class="list-group">
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Expense Number:</strong> <span id="final_expense_number"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>User:</strong> <span id="final_user"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Tipe:</strong> Up Country
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Rayon:</strong> <span id="final_rayon"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Tanggal:</strong> <span id="final_tanggal"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Tujuan:</strong> <span id="final_tujuan"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Jarak:</strong> <span id="final_jarak"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Bukti Allowance:</strong> <span id="final_bukti_allowance"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Bukti Transport Dalam Kota:</strong> <span id="final_bukti_transport_dalkot"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Bukti Transport Antar Kota:</strong> <span id="final_bukti_transport_ankot"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Bukti Hotel:</strong> <span id="final_bukti_hotel"></span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
<p class="mt-2">Please select the items you want to approve:</p>
|
<p class="mt-2">Please select the items you want to approve:</p>
|
||||||
<ul class="list-group list-unstyled">
|
<ul class="list-group list-unstyled">
|
||||||
<li>
|
<li>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="custom-control custom-checkbox">
|
<div class="custom-control custom-checkbox">
|
||||||
<input type="checkbox" class="custom-control-input" id="allowance" name="allowance">
|
<input type="checkbox" class="custom-control-input" id="final_allowance" name="allowance">
|
||||||
<label class="custom-control-label" for="allowance">Allowance (<span id="allowance_value"></span>)</label>
|
<label class="custom-control-label" for="final_allowance">Allowance (<span id="final_allowance_value"></span>)</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="custom-control custom-checkbox">
|
<div class="custom-control custom-checkbox">
|
||||||
<input type="checkbox" class="custom-control-input" id="transport_dalkot" name="transport_dalkot">
|
<input type="checkbox" class="custom-control-input" id="final_transport_dalkot" name="transport_dalkot">
|
||||||
<label class="custom-control-label" for="transport_dalkot">Transport Dalkot (<span id="transport_dalkot_value"></span>)</label>
|
<label class="custom-control-label" for="final_transport_dalkot">Transport Dalkot (<span id="final_transport_dalkot_value"></span>)</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="custom-control custom-checkbox">
|
<div class="custom-control custom-checkbox">
|
||||||
<input type="checkbox" class="custom-control-input" id="transport_ankot" name="transport_ankot">
|
<input type="checkbox" class="custom-control-input" id="final_transport_ankot" name="transport_ankot">
|
||||||
<label class="custom-control-label" for="transport_ankot">Transport Ankot (<span id="transport_ankot_value"></span>)</label>
|
<label class="custom-control-label" for="final_transport_ankot">Transport Ankot (<span id="final_transport_ankot_value"></span>)</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="custom-control custom-checkbox">
|
<div class="custom-control custom-checkbox">
|
||||||
<input type="checkbox" class="custom-control-input" id="hotel" name="hotel">
|
<input type="checkbox" class="custom-control-input" id="final_hotel" name="hotel">
|
||||||
<label class="custom-control-label" for="hotel">Hotel (<span id="hotel_value"></span>)</label>
|
<label class="custom-control-label" for="final_hotel">Hotel (<span id="final_hotel_value"></span>)</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
@@ -406,7 +522,7 @@
|
|||||||
$('#approveModal').modal('show'); // Show the modal
|
$('#approveModal').modal('show'); // Show the modal
|
||||||
|
|
||||||
// Get detail from /forms/up-country/detail/{id}
|
// Get detail from /forms/up-country/detail/{id}
|
||||||
$.get(approveUrl.replace('approve', 'detail'), function (data) {
|
$.get(approveUrl.replace(/approve(2)?/, 'detail'), function (data) {
|
||||||
const formatter = new Intl.NumberFormat('id-ID', {
|
const formatter = new Intl.NumberFormat('id-ID', {
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
currency: 'IDR',
|
currency: 'IDR',
|
||||||
@@ -418,12 +534,6 @@
|
|||||||
$('#transport_ankot_value').text(formatter.format(data.transport_ankot));
|
$('#transport_ankot_value').text(formatter.format(data.transport_ankot));
|
||||||
$('#hotel_value').text(formatter.format(data.hotel));
|
$('#hotel_value').text(formatter.format(data.hotel));
|
||||||
|
|
||||||
// Assign data values to checkboxes
|
|
||||||
$('#allowance').data('value', data.allowance);
|
|
||||||
$('#transport_dalkot').data('value', data.transport_dalkot);
|
|
||||||
$('#transport_ankot').data('value', data.transport_ankot);
|
|
||||||
$('#hotel').data('value', data.hotel);
|
|
||||||
|
|
||||||
// Detail data
|
// Detail data
|
||||||
$('#user').text(data.user.name);
|
$('#user').text(data.user.name);
|
||||||
$('#expense_number').text(data.expense_number);
|
$('#expense_number').text(data.expense_number);
|
||||||
@@ -452,27 +562,85 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Handle Approve Button Click
|
||||||
|
$('.final-approve-modal').on('click', function () {
|
||||||
|
const approveUrl = $(this).data('id');
|
||||||
|
|
||||||
|
// Show spinner and hide content initially
|
||||||
|
$('#finalLoadingSpinner').show();
|
||||||
|
$('#finalModalContent').addClass('d-none');
|
||||||
|
|
||||||
|
$('#finalApproveForm').attr('action', approveUrl); // Set the form action
|
||||||
|
$('#finalLoadingSpinner').addClass('d-flex');
|
||||||
|
$('#finalApproveModal').modal('show'); // Show the modal
|
||||||
|
|
||||||
|
// Get detail from /forms/up-country/detail/{id}
|
||||||
|
$.get(approveUrl.replace('final-approve', 'detail'), function (data) {
|
||||||
|
console.log(data);
|
||||||
|
const formatter = new Intl.NumberFormat('id-ID', {
|
||||||
|
style: 'currency',
|
||||||
|
currency: 'IDR',
|
||||||
|
minimumFractionDigits: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#final_allowance_value').text(formatter.format(data.allowance));
|
||||||
|
$('#final_transport_dalkot_value').text(formatter.format(data.transport_dalkot));
|
||||||
|
$('#final_transport_ankot_value').text(formatter.format(data.transport_ankot));
|
||||||
|
$('#final_hotel_value').text(formatter.format(data.hotel));
|
||||||
|
|
||||||
|
// Assign data values to checkboxes
|
||||||
|
$('#final_allowance').data('value', data.allowance);
|
||||||
|
$('#final_transport_dalkot').data('value', data.transport_dalkot);
|
||||||
|
$('#final_transport_ankot').data('value', data.transport_ankot);
|
||||||
|
$('#final_hotel').data('value', data.hotel);
|
||||||
|
|
||||||
|
// Detail data
|
||||||
|
$('#final_user').text(data.user.name);
|
||||||
|
$('#final_expense_number').text(data.expense_number);
|
||||||
|
$('#final_rayon').text(data.rayon.code);
|
||||||
|
$('#final_tanggal').text(new Date(data.tanggal).toLocaleDateString('id-ID', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
day: 'numeric'
|
||||||
|
}));
|
||||||
|
$('#final_tujuan').text(data.tujuan);
|
||||||
|
$('#final_jarak').text(data.jarak + ' km');
|
||||||
|
|
||||||
|
$('#final_bukti_allowance').html(data.bukti_allowance ? '<a href="' + data.bukti_allowance + '" target="_blank">Download</a>' : '-');
|
||||||
|
$('#final_bukti_transport_dalkot').html(data.bukti_transport_dalkot ? '<a href="' + data.bukti_transport_dalkot + '" target="_blank">Download</a>' : '-');
|
||||||
|
$('#final_bukti_transport_ankot').html(data.bukti_transport_ankot ? '<a href="' + data.bukti_transport_ankot + '" target="_blank">Download</a>' : '-');
|
||||||
|
$('#final_bukti_hotel').html(data.bukti_hotel ? '<a href="' + data.bukti_hotel + '" target="_blank">Download</a>' : '-');
|
||||||
|
|
||||||
|
// Hide spinner and show content
|
||||||
|
$('#finalLoadingSpinner').hide();
|
||||||
|
$('#finalLoadingSpinner').removeClass('d-flex');
|
||||||
|
$('#finalLoadingSpinner').addClass('d-none');
|
||||||
|
$('#finalModalContent').removeClass('d-none');
|
||||||
|
|
||||||
|
// Reset the total to zero
|
||||||
|
$('#total').val(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Update total dynamically
|
// Update total dynamically
|
||||||
$('.custom-control-input').on('change', function () {
|
$('.custom-control-input').on('change', function () {
|
||||||
let total = 0;
|
let total = 0;
|
||||||
|
|
||||||
// Calculate the total based on checked checkboxes
|
|
||||||
$('.custom-control-input:checked').each(function () {
|
$('.custom-control-input:checked').each(function () {
|
||||||
total += parseFloat($(this).data('value') || 0);
|
total += parseFloat($(this).data('value') || 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update the total field with formatted value
|
|
||||||
const formatter = new Intl.NumberFormat('id-ID', {
|
const formatter = new Intl.NumberFormat('id-ID', {
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
currency: 'IDR',
|
currency: 'IDR',
|
||||||
minimumFractionDigits: 0
|
minimumFractionDigits: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#total').val(formatter.format(total));
|
$('#total').val(formatter.format(total));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Uncheck all checkboxes when the modal is closed
|
// Uncheck all checkboxes when the modal is closed
|
||||||
$('#approveModal').on('hidden.bs.modal', function () {
|
$('#finalApproveModal').on('hidden.bs.modal', function () {
|
||||||
$('.custom-control-input').prop('checked', false); // Uncheck all checkboxes
|
$('.custom-control-input').prop('checked', false); // Uncheck all checkboxes
|
||||||
$('#total').val('0'); // Reset total to 0
|
$('#total').val('0'); // Reset total to 0
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,11 +22,30 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
<style>
|
||||||
|
#loading-spinner-overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black background */
|
||||||
|
z-index: 9999; /* High z-index to cover everything */
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner-wrapper {
|
||||||
|
text-align: center;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="card card-primary card-outline">
|
<div class="card card-primary card-outline">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form method="POST" action="{{ route('forms.vehicle.store') }}" enctype="multipart/form-data">
|
<form id="expense-form" method="POST" action="{{ route('forms.vehicle.store') }}" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
@include('backend.layouts.partials.messages')
|
@include('backend.layouts.partials.messages')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -76,6 +95,14 @@
|
|||||||
<button type="submit" class="btn btn-primary ml-2">Submit</button>
|
<button type="submit" class="btn btn-primary ml-2">Submit</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<div id="loading-spinner-overlay" class="d-none">
|
||||||
|
<div class="spinner-wrapper">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
</div>
|
||||||
|
<p>Submitting, please wait...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -89,5 +116,11 @@
|
|||||||
decimalPlaces: 0, // Tidak ada angka desimal
|
decimalPlaces: 0, // Tidak ada angka desimal
|
||||||
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.getElementById('expense-form').addEventListener('submit', function (e) {
|
||||||
|
const spinnerOverlay = document.getElementById('loading-spinner-overlay');
|
||||||
|
spinnerOverlay.classList.remove('d-none'); // Show overlay
|
||||||
|
spinnerOverlay.classList.add('d-flex'); // Use flexbox for centering
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -21,11 +21,30 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
<style>
|
||||||
|
#loading-spinner-overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black background */
|
||||||
|
z-index: 9999; /* High z-index to cover everything */
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner-wrapper {
|
||||||
|
text-align: center;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="card card-primary card-outline">
|
<div class="card card-primary card-outline">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form method="POST" action="{{ route('forms.vehicle.update', $form->id) }}" enctype="multipart/form-data">
|
<form id="expense-form" method="POST" action="{{ route('forms.vehicle.update', $form->id) }}" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
@method('PUT')
|
@method('PUT')
|
||||||
@include('backend.layouts.partials.messages')
|
@include('backend.layouts.partials.messages')
|
||||||
@@ -75,6 +94,14 @@
|
|||||||
<button type="submit" class="btn btn-primary ml-2">Save</button>
|
<button type="submit" class="btn btn-primary ml-2">Save</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<div id="loading-spinner-overlay" class="d-none">
|
||||||
|
<div class="spinner-wrapper">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
</div>
|
||||||
|
<p>Submitting, please wait...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -88,5 +115,11 @@
|
|||||||
decimalPlaces: 0, // Tidak ada angka desimal
|
decimalPlaces: 0, // Tidak ada angka desimal
|
||||||
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.getElementById('expense-form').addEventListener('submit', function (e) {
|
||||||
|
const spinnerOverlay = document.getElementById('loading-spinner-overlay');
|
||||||
|
spinnerOverlay.classList.remove('d-none'); // Show overlay
|
||||||
|
spinnerOverlay.classList.add('d-flex'); // Use flexbox for centering
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -111,7 +111,10 @@
|
|||||||
<th>Account Number</th>
|
<th>Account Number</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
@if (auth()->user()->can('approval.approve'))
|
@if (auth()->user()->can('approval.approve'))
|
||||||
<th>Approval</th>
|
<th>Approval 1</th>
|
||||||
|
@endif
|
||||||
|
@if (auth()->user()->can('approval2.approve'))
|
||||||
|
<th>Approval 2</th>
|
||||||
@endif
|
@endif
|
||||||
@if (auth()->user()->can('final_approval.approve'))
|
@if (auth()->user()->can('final_approval.approve'))
|
||||||
<th>Final Approval</th>
|
<th>Final Approval</th>
|
||||||
@@ -150,7 +153,7 @@
|
|||||||
<td>
|
<td>
|
||||||
@if ($item->status == 'On Progress')
|
@if ($item->status == 'On Progress')
|
||||||
<span class="badge badge-warning text-white">{{ $item->status }}</span>
|
<span class="badge badge-warning text-white">{{ $item->status }}</span>
|
||||||
@elseif ($item->status == 'Approved' || $item->status == 'Final Approved')
|
@elseif ($item->status == 'Approved 1' || $item->status == 'Approved 2' || $item->status == 'Final Approved')
|
||||||
<span class="badge badge-success text-white">{{ $item->status }}</span>
|
<span class="badge badge-success text-white">{{ $item->status }}</span>
|
||||||
@else
|
@else
|
||||||
<span class="badge badge-danger text-white">{{ $item->status }}</span>
|
<span class="badge badge-danger text-white">{{ $item->status }}</span>
|
||||||
@@ -159,16 +162,16 @@
|
|||||||
@if (auth()->user()->can('approval.approve'))
|
@if (auth()->user()->can('approval.approve'))
|
||||||
<td>
|
<td>
|
||||||
{{-- approve / reject button --}}
|
{{-- approve / reject button --}}
|
||||||
@if ($item->status == 'On Progress')
|
@if ($item->status == 'On Progress' || $item->status == 'Rejected')
|
||||||
<form action="javascript:void(0);" class="d-inline">
|
<form action="javascript:void(0);" class="d-inline">
|
||||||
<button type="button"
|
<button type="button"
|
||||||
class="btn btn-success btn-sm open-approve-modal"
|
class="btn btn-success btn-sm open-approve-modal"
|
||||||
data-id="{{ route('forms.vehicle.approve', $item->id) }}">
|
data-id="{{ route('forms.vehicle.approve', $item->id) }}">
|
||||||
Approve
|
Approve 1
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form action="{{ route('forms.vehicle.reject', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to reject this item?');">
|
<form action="{{ route('forms.vehicle.reject', $item->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to reject this item?');">
|
||||||
@csrf
|
@csrf
|
||||||
@method('PUT')
|
@method('PUT')
|
||||||
<button type="submit" class="btn btn-danger btn-sm">
|
<button type="submit" class="btn btn-danger btn-sm">
|
||||||
@@ -186,14 +189,44 @@
|
|||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
@endif
|
@endif
|
||||||
|
@if (auth()->user()->can('approval2.approve'))
|
||||||
|
<td>
|
||||||
|
{{-- approve / reject button --}}
|
||||||
|
@if ($item->status == 'Approved 1' && $item->approved_at)
|
||||||
|
<form action="javascript:void(0);" class="d-inline">
|
||||||
|
<button type="button"
|
||||||
|
class="btn btn-success btn-sm open-approve-modal"
|
||||||
|
data-id="{{ route('forms.vehicle.approve2', $item->id) }}">
|
||||||
|
Approve 2
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form action="{{ route('forms.vehicle.reject', $item->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to reject this item?');">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
<button type="submit" class="btn btn-danger btn-sm">
|
||||||
|
Reject
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@else
|
||||||
|
@if ($item->approved2_at)
|
||||||
|
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
|
||||||
|
@elseif($item->rejected_at)
|
||||||
|
{{ \Carbon\Carbon::parse($item->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
|
||||||
|
@else
|
||||||
|
-
|
||||||
|
@endif
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
@endif
|
||||||
@if(auth()->user()->can('final_approval.approve'))
|
@if(auth()->user()->can('final_approval.approve'))
|
||||||
<td>
|
<td>
|
||||||
{{-- approve / reject button --}}
|
{{-- approve / reject button --}}
|
||||||
@if ($item->status == 'Approved' && $item->approved_at && !$item->final_approved_at)
|
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
|
||||||
<form action="{{ route('forms.vehicle.final-approve', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this item?');">
|
<form action="javascript:void(0);" class="d-inline">
|
||||||
@csrf
|
<button type="button"
|
||||||
@method('PUT')
|
class="btn btn-success btn-sm final-approve-modal"
|
||||||
<button type="submit" class="btn btn-success btn-sm">
|
data-id="{{ route('forms.vehicle.final-approve', $item->id) }}">
|
||||||
Final Approve
|
Final Approve
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
@@ -297,10 +330,75 @@
|
|||||||
<strong>Tipe Bensin:</strong> <span id="tipe_bensin"></span>
|
<strong>Tipe Bensin:</strong> <span id="tipe_bensin"></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Keterangan:</strong> <span id="keterangan"></span>
|
<strong>Bukti Total:</strong> <span id="bukti_total"></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Bukti Total Harga Bensin:</strong> <span id="bukti_total"></span>
|
<strong>Nominal Total:</strong> <span id="total_value"></span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Approve</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<div class="modal fade" id="finalApproveModal" tabindex="-1" role="dialog" aria-labelledby="finalApproveModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<form id="finalApproveForm" method="POST" action="">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="approveModalLabel">Approve Item</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<!-- Loading spinner -->
|
||||||
|
<div id="finalLoadingSpinner" class="d-flex justify-content-center align-items-center" style="height: 200px;">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
<span class="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal content (hidden initially) -->
|
||||||
|
<div id="finalModalContent" class="d-none">
|
||||||
|
<p>Please review the details below:</p>
|
||||||
|
<ul class="list-group">
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Expense Number:</strong> <span id="final_expense_number"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>User:</strong> <span id="final_user"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Tipe:</strong> Vehicle Running Cost
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Tanggal & Waktu:</strong> <span id="final_tanggal"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Jarak:</strong> <span id="final_jarak"></span> km
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Total Liter Bensin:</strong> <span id="final_liter"></span> liter
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>No Polisi:</strong> <span id="final_nopol"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Tipe Bensin:</strong> <span id="final_tipe_bensin"></span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong>Bukti Total:</strong> <span id="final_bukti_total"></span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p class="mt-2">Please select the items you want to approve:</p>
|
<p class="mt-2">Please select the items you want to approve:</p>
|
||||||
@@ -308,17 +406,11 @@
|
|||||||
<li>
|
<li>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="custom-control custom-checkbox">
|
<div class="custom-control custom-checkbox">
|
||||||
<input type="checkbox" class="custom-control-input" id="total_bensin" name="total_bensin">
|
<input type="checkbox" class="custom-control-input" id="final_total" name="total" required>
|
||||||
<label class="custom-control-label" for="total_bensin">Total Harga Bensin (<span id="total_bensin_value"></span>)</label>
|
<label class="custom-control-label" for="final_total">Total (<span id="final_total_value"></span>)</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="total">Total</label>
|
|
||||||
<input type="text" class="form-control" id="total" name="total" value="0" readonly>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -384,34 +476,31 @@
|
|||||||
$('#loadingSpinner').addClass('d-flex');
|
$('#loadingSpinner').addClass('d-flex');
|
||||||
$('#approveModal').modal('show'); // Show the modal
|
$('#approveModal').modal('show'); // Show the modal
|
||||||
|
|
||||||
// Get detail from /forms/up-country/detail/{id}
|
// Get detail from /forms/vehicle/detail/{id}
|
||||||
$.get(approveUrl.replace('approve', 'detail'), function (data) {
|
$.get(approveUrl.replace(/approve(2)?/, 'detail'), function (data) {
|
||||||
const formatter = new Intl.NumberFormat('id-ID', {
|
const formatter = new Intl.NumberFormat('id-ID', {
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
currency: 'IDR',
|
currency: 'IDR',
|
||||||
minimumFractionDigits: 0
|
minimumFractionDigits: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#total_bensin_value').text(formatter.format(data.total));
|
$('#total_value').text(formatter.format(data.total));
|
||||||
$('#total_bensin').data('value', data.total);
|
|
||||||
$('#jarak').text(data.jarak);
|
|
||||||
$('#liter').text(data.liter);
|
|
||||||
$('#nopol').text(data.nopol);
|
|
||||||
$('#tipe_bensin').text(data.tipe_bensin);
|
|
||||||
$('#keterangan').text(data.keterangan);
|
|
||||||
|
|
||||||
// Detail data
|
// Detail data
|
||||||
$('#user').text(data.user.name);
|
$('#user').text(data.user.name);
|
||||||
$('#expense_number').text(data.expense_number);
|
$('#expense_number').text(data.expense_number);
|
||||||
$('#tanggal').text(new Date(data.tanggal).toLocaleDateString('id-ID', {
|
$('#tanggal').text(new Date(data.created_at).toLocaleDateString('id-ID', {
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
month: 'long',
|
month: 'long',
|
||||||
day: 'numeric',
|
day: 'numeric'
|
||||||
hour: '2-digit',
|
|
||||||
minute: '2-digit',
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
$('#jarak').text(data.jarak);
|
||||||
|
$('#liter').text(data.liter);
|
||||||
|
$('#tipe_bensin').text(data.tipe_bensin);
|
||||||
|
$('#nopol').text(data.nopol);
|
||||||
|
|
||||||
$('#bukti_total').html(data.bukti_total ? '<a href="' + data.bukti_total + '" target="_blank">Download</a>' : '-');
|
$('#bukti_total').html(data.total ? '<a href="' + data.total + '" target="_blank">Download</a>' : '-');
|
||||||
|
|
||||||
// Hide spinner and show content
|
// Hide spinner and show content
|
||||||
$('#loadingSpinner').hide();
|
$('#loadingSpinner').hide();
|
||||||
@@ -424,27 +513,78 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Handle Approve Button Click
|
||||||
|
$('.final-approve-modal').on('click', function () {
|
||||||
|
const approveUrl = $(this).data('id');
|
||||||
|
|
||||||
|
// Show spinner and hide content initially
|
||||||
|
$('#finalLoadingSpinner').show();
|
||||||
|
$('#finalModalContent').addClass('d-none');
|
||||||
|
|
||||||
|
$('#finalApproveForm').attr('action', approveUrl); // Set the form action
|
||||||
|
$('#finalLoadingSpinner').addClass('d-flex');
|
||||||
|
$('#finalApproveModal').modal('show'); // Show the modal
|
||||||
|
|
||||||
|
// Get detail from /forms/vehicle/detail/{id}
|
||||||
|
$.get(approveUrl.replace('final-approve', 'detail'), function (data) {
|
||||||
|
console.log(data);
|
||||||
|
const formatter = new Intl.NumberFormat('id-ID', {
|
||||||
|
style: 'currency',
|
||||||
|
currency: 'IDR',
|
||||||
|
minimumFractionDigits: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#final_total_value').text(formatter.format(data.total));
|
||||||
|
|
||||||
|
// Assign data values to checkboxes
|
||||||
|
$('#final_total').data('value', data.total);
|
||||||
|
|
||||||
|
// Detail data
|
||||||
|
$('#final_user').text(data.user.name);
|
||||||
|
$('#final_expense_number').text(data.expense_number);
|
||||||
|
$('#final_tanggal').text(new Date(data.created_at).toLocaleDateString('id-ID', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
day: 'numeric'
|
||||||
|
}));
|
||||||
|
|
||||||
|
$('#final_jarak').text(data.jarak);
|
||||||
|
$('#final_liter').text(data.liter);
|
||||||
|
$('#final_tipe_bensin').text(data.tipe_bensin);
|
||||||
|
$('#final_nopol').text(data.nopol);
|
||||||
|
|
||||||
|
$('#final_bukti_total').html(data.bukti_total ? '<a href="' + data.bukti_total + '" target="_blank">Download</a>' : '-');
|
||||||
|
|
||||||
|
// Hide spinner and show content
|
||||||
|
$('#finalLoadingSpinner').hide();
|
||||||
|
$('#finalLoadingSpinner').removeClass('d-flex');
|
||||||
|
$('#finalLoadingSpinner').addClass('d-none');
|
||||||
|
$('#finalModalContent').removeClass('d-none');
|
||||||
|
|
||||||
|
// Reset the total to zero
|
||||||
|
$('#total').val(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Update total dynamically
|
// Update total dynamically
|
||||||
$('.custom-control-input').on('change', function () {
|
$('.custom-control-input').on('change', function () {
|
||||||
let total = 0;
|
let total = 0;
|
||||||
|
|
||||||
// Calculate the total based on checked checkboxes
|
|
||||||
$('.custom-control-input:checked').each(function () {
|
$('.custom-control-input:checked').each(function () {
|
||||||
total += parseFloat($(this).data('value') || 0);
|
total += parseFloat($(this).data('value') || 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update the total field with formatted value
|
|
||||||
const formatter = new Intl.NumberFormat('id-ID', {
|
const formatter = new Intl.NumberFormat('id-ID', {
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
currency: 'IDR',
|
currency: 'IDR',
|
||||||
minimumFractionDigits: 0
|
minimumFractionDigits: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#total').val(formatter.format(total));
|
$('#total').val(formatter.format(total));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Uncheck all checkboxes when the modal is closed
|
// Uncheck all checkboxes when the modal is closed
|
||||||
$('#approveModal').on('hidden.bs.modal', function () {
|
$('#finalApproveModal').on('hidden.bs.modal', function () {
|
||||||
$('.custom-control-input').prop('checked', false); // Uncheck all checkboxes
|
$('.custom-control-input').prop('checked', false); // Uncheck all checkboxes
|
||||||
$('#total').val('0'); // Reset total to 0
|
$('#total').val('0'); // Reset total to 0
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
@endphp
|
@endphp
|
||||||
@foreach ($kategori as $item)
|
@foreach ($kategori as $item)
|
||||||
@php
|
@php
|
||||||
$drValue = FormHelper::getNominalByFormType($cabang->id, $item->name, $item->id, $month, $year);
|
$drValue = $nominals[$item->id] ?? 0;
|
||||||
$drFormatted = $drValue == 0 ? '' : number_format($drValue, 0, ',', '.');
|
$drFormatted = $drValue == 0 ? '' : number_format($drValue, 0, ',', '.');
|
||||||
$totalDr += $drValue;
|
$totalDr += $drValue;
|
||||||
@endphp
|
@endphp
|
||||||
@@ -79,6 +79,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ $kategori->count() + 1 }}</td>
|
<td>{{ $kategori->count() + 1 }}</td>
|
||||||
<td>Petty Cash</td>
|
<td>Petty Cash</td>
|
||||||
@@ -140,36 +141,15 @@
|
|||||||
|
|
||||||
@section('scripts')
|
@section('scripts')
|
||||||
<script>
|
<script>
|
||||||
if ($('#dataTable-table').length) {
|
if ($('#dataTable-table').length) {
|
||||||
$('#dataTable-table').DataTable({
|
$('#dataTable-table').DataTable({
|
||||||
responsive: false,
|
responsive: false,
|
||||||
dom: 'Blfrtip',
|
dom: 'Bfrtip',
|
||||||
lengthMenu: [ [10, 50, 100, -1], [10, 50, 100, "All"] ], // Control the entries dropdown
|
buttons: ['excel', 'csv', 'pdf', 'print', 'colvis'],
|
||||||
buttons: [
|
paging: false,
|
||||||
{
|
info: false,
|
||||||
extend: 'excel',
|
pageLength: -1
|
||||||
text: 'Excel'
|
});
|
||||||
},
|
}
|
||||||
{
|
</script>
|
||||||
extend: 'pdf',
|
|
||||||
text: 'PDF',
|
|
||||||
orientation: 'landscape',
|
|
||||||
pageSize: 'A4',
|
|
||||||
exportOptions: {
|
|
||||||
columns: ':visible'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
extend: 'print',
|
|
||||||
text: 'Print',
|
|
||||||
orientation: 'landscape',
|
|
||||||
exportOptions: {
|
|
||||||
columns: ':visible'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'colvis'
|
|
||||||
]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -33,12 +33,37 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
|
<li class="nav-item dropdown">
|
||||||
|
<a class="nav-link" data-toggle="dropdown" href="#" role="button" data-widget="notification">
|
||||||
|
<i class="fas fa-bell"></i>
|
||||||
|
</a>
|
||||||
|
<div class="dropdown-menu dropdown-menu-xl dropdown-menu-right">
|
||||||
|
<div id="notification">
|
||||||
|
<span class="dropdown-item dropdown-header" id="notification_title">Notifications</span>
|
||||||
|
<div id="loading-bar" style="text-align: center; padding: 10px; display: none;">
|
||||||
|
<div class="spinner-border text-primary" style="width: 2rem; height: 2rem;" role="status">
|
||||||
|
<span class="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="notification-list"></div>
|
||||||
|
<div class="dropdown-divider"></div>
|
||||||
|
<form action="{{ route('dashboard.mark_read') }}" method="POST">
|
||||||
|
@csrf
|
||||||
|
@include('backend.layouts.partials.messages')
|
||||||
|
<button type="submit" class="dropdown-item dropdown-footer" id="notification_mark">Mark all as read</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<!-- Fullscreen Icon -->
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" data-widget="fullscreen" href="#" role="button">
|
<a class="nav-link" data-widget="fullscreen" href="#" role="button">
|
||||||
<i class="fas fa-expand-arrows-alt"></i>
|
<i class="fas fa-expand-arrows-alt"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<!-- Profile Section -->
|
||||||
<li class="nav-item dropdown" title="Account Profile">
|
<li class="nav-item dropdown" title="Account Profile">
|
||||||
<a class="nav-link" data-toggle="dropdown" href="#">
|
<a class="nav-link" data-toggle="dropdown" href="#">
|
||||||
{{ Auth::guard('admin')->user()->name }} <i class="far fa-user"></i>
|
{{ Auth::guard('admin')->user()->name }} <i class="far fa-user"></i>
|
||||||
@@ -145,4 +170,57 @@
|
|||||||
|
|
||||||
// Initialize the clock on page load
|
// Initialize the clock on page load
|
||||||
updateDateTime();
|
updateDateTime();
|
||||||
|
|
||||||
|
document.querySelector('[data-widget="notification"]').addEventListener('click', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const loadingBar = document.getElementById('loading-bar');
|
||||||
|
const notificationList = document.getElementById('notification-list');
|
||||||
|
|
||||||
|
// Show loading bar and hide notification list
|
||||||
|
loadingBar.style.display = 'block';
|
||||||
|
notificationList.classList.add('d-none');
|
||||||
|
|
||||||
|
fetch('/api/notifications')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
notificationList.innerHTML = ''; // Clear existing notifications
|
||||||
|
|
||||||
|
data.forEach(notification => {
|
||||||
|
const item = document.createElement('a');
|
||||||
|
item.href = notification.link || '#';
|
||||||
|
item.classList.add('dropdown-item');
|
||||||
|
item.innerHTML = `
|
||||||
|
<div style="display: flex; justify-content: space-between; align-items: center;">
|
||||||
|
<div style="display: flex; align-items: center;">
|
||||||
|
<i class="fas fa-bell" style="font-size: 16px; margin-right: 5px;"></i>
|
||||||
|
<strong style="font-size: 12px;">${notification.title}</strong>
|
||||||
|
</div>
|
||||||
|
<span class="text-muted text-sm" style="font-size: 12px !important;">
|
||||||
|
${new Date(notification.created_at).toLocaleDateString('en-US', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'short',
|
||||||
|
day: 'numeric',
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<span class="text-muted text-sm" style="font-size: 12px !important;">${notification.content || ''}</span>
|
||||||
|
`;
|
||||||
|
notificationList.appendChild(item);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Hide loading bar and show notification list
|
||||||
|
loadingBar.style.display = 'none';
|
||||||
|
notificationList.classList.remove('d-none');
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error fetching notifications:', error);
|
||||||
|
loadingBar.style.display = 'none';
|
||||||
|
notificationList.innerHTML = '<span class="dropdown-item text-danger">Failed to load notifications.</span>';
|
||||||
|
notificationList.classList.remove('d-none');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
<title>Expense Approved</title>
|
<title>Expense First Approval</title>
|
||||||
<style media="all" type="text/css">
|
<style media="all" type="text/css">
|
||||||
/* -------------------------------------
|
/* -------------------------------------
|
||||||
GLOBAL RESETS
|
GLOBAL RESETS
|
||||||
@@ -308,7 +308,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="wrapper">
|
<td class="wrapper">
|
||||||
<p>Halo {{ $name }},</p>
|
<p>Halo {{ $name }},</p>
|
||||||
<p>Kami ingin memberitahukan bahwa pengajuan pengeluaran dengan detail sebagai berikut telah disetujui:</p>
|
<p>Pengajuan Expense anda telah di periksa & setujui oleh <b>Admin Region</b> Anda:</p>
|
||||||
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
|
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -0,0 +1,361 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>Expense Second Approval</title>
|
||||||
|
<style media="all" type="text/css">
|
||||||
|
/* -------------------------------------
|
||||||
|
GLOBAL RESETS
|
||||||
|
------------------------------------- */
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: Helvetica, sans-serif;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 1.3;
|
||||||
|
-ms-text-size-adjust: 100%;
|
||||||
|
-webkit-text-size-adjust: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
border-collapse: separate;
|
||||||
|
mso-table-lspace: 0pt;
|
||||||
|
mso-table-rspace: 0pt;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
table td {
|
||||||
|
font-family: Helvetica, sans-serif;
|
||||||
|
font-size: 16px;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
/* -------------------------------------
|
||||||
|
BODY & CONTAINER
|
||||||
|
------------------------------------- */
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: #f4f5f6;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.body {
|
||||||
|
background-color: #f4f5f6;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
margin: 0 auto !important;
|
||||||
|
max-width: 600px;
|
||||||
|
padding: 0;
|
||||||
|
padding-top: 24px;
|
||||||
|
width: 600px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
box-sizing: border-box;
|
||||||
|
display: block;
|
||||||
|
margin: 0 auto;
|
||||||
|
max-width: 600px;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------
|
||||||
|
HEADER, FOOTER, MAIN
|
||||||
|
------------------------------------- */
|
||||||
|
|
||||||
|
.main {
|
||||||
|
background: #ffffff;
|
||||||
|
border: 1px solid #eaebed;
|
||||||
|
border-radius: 16px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wrapper {
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
clear: both;
|
||||||
|
padding-top: 24px;
|
||||||
|
text-align: center;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer td,
|
||||||
|
.footer p,
|
||||||
|
.footer span,
|
||||||
|
.footer a {
|
||||||
|
color: #9a9ea6;
|
||||||
|
font-size: 16px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
/* -------------------------------------
|
||||||
|
TYPOGRAPHY
|
||||||
|
------------------------------------- */
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-family: Helvetica, sans-serif;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: normal;
|
||||||
|
margin: 0;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #0867ec;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
/* -------------------------------------
|
||||||
|
BUTTONS
|
||||||
|
------------------------------------- */
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
box-sizing: border-box;
|
||||||
|
min-width: 100% !important;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn > tbody > tr > td {
|
||||||
|
padding-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn table {
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn table td {
|
||||||
|
background-color: #ffffff;
|
||||||
|
border-radius: 4px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn a {
|
||||||
|
background-color: #ffffff;
|
||||||
|
border: solid 2px #0867ec;
|
||||||
|
border-radius: 4px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
color: #0867ec;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
margin: 0;
|
||||||
|
padding: 12px 24px;
|
||||||
|
text-decoration: none;
|
||||||
|
text-transform: capitalize;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary table td {
|
||||||
|
background-color: #0867ec;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary a {
|
||||||
|
background-color: #0867ec;
|
||||||
|
border-color: #0867ec;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media all {
|
||||||
|
.btn-primary table td:hover {
|
||||||
|
background-color: #ec0867 !important;
|
||||||
|
}
|
||||||
|
.btn-primary a:hover {
|
||||||
|
background-color: #ec0867 !important;
|
||||||
|
border-color: #ec0867 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------
|
||||||
|
OTHER STYLES THAT MIGHT BE USEFUL
|
||||||
|
------------------------------------- */
|
||||||
|
|
||||||
|
.last {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.first {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.align-center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.align-right {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.align-left {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-link {
|
||||||
|
color: #0867ec !important;
|
||||||
|
text-decoration: underline !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clear {
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mt0 {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mb0 {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preheader {
|
||||||
|
color: transparent;
|
||||||
|
display: none;
|
||||||
|
height: 0;
|
||||||
|
max-height: 0;
|
||||||
|
max-width: 0;
|
||||||
|
opacity: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
mso-hide: all;
|
||||||
|
visibility: hidden;
|
||||||
|
width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.powered-by a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------
|
||||||
|
RESPONSIVE AND MOBILE FRIENDLY STYLES
|
||||||
|
------------------------------------- */
|
||||||
|
|
||||||
|
@media only screen and (max-width: 640px) {
|
||||||
|
.main p,
|
||||||
|
.main td,
|
||||||
|
.main span {
|
||||||
|
font-size: 16px !important;
|
||||||
|
}
|
||||||
|
.wrapper {
|
||||||
|
padding: 8px !important;
|
||||||
|
}
|
||||||
|
.content {
|
||||||
|
padding: 0 !important;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
padding: 0 !important;
|
||||||
|
padding-top: 8px !important;
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
.main {
|
||||||
|
border-left-width: 0 !important;
|
||||||
|
border-radius: 0 !important;
|
||||||
|
border-right-width: 0 !important;
|
||||||
|
}
|
||||||
|
.btn table {
|
||||||
|
max-width: 100% !important;
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
.btn a {
|
||||||
|
font-size: 16px !important;
|
||||||
|
max-width: 100% !important;
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* -------------------------------------
|
||||||
|
PRESERVE THESE STYLES IN THE HEAD
|
||||||
|
------------------------------------- */
|
||||||
|
|
||||||
|
@media all {
|
||||||
|
.ExternalClass {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.ExternalClass,
|
||||||
|
.ExternalClass p,
|
||||||
|
.ExternalClass span,
|
||||||
|
.ExternalClass font,
|
||||||
|
.ExternalClass td,
|
||||||
|
.ExternalClass div {
|
||||||
|
line-height: 100%;
|
||||||
|
}
|
||||||
|
.apple-link a {
|
||||||
|
color: inherit !important;
|
||||||
|
font-family: inherit !important;
|
||||||
|
font-size: inherit !important;
|
||||||
|
font-weight: inherit !important;
|
||||||
|
line-height: inherit !important;
|
||||||
|
text-decoration: none !important;
|
||||||
|
}
|
||||||
|
#MessageViewBody a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
font-size: inherit;
|
||||||
|
font-family: inherit;
|
||||||
|
font-weight: inherit;
|
||||||
|
line-height: inherit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<table role="presentation" border="0" cellpadding="0" cellspacing="0" class="body">
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td class="container">
|
||||||
|
<div class="content">
|
||||||
|
<table role="presentation" border="0" cellpadding="0" cellspacing="0" class="main">
|
||||||
|
<!-- START MAIN CONTENT AREA -->
|
||||||
|
<tr>
|
||||||
|
<td class="wrapper">
|
||||||
|
<p>Halo {{ $name }},</p>
|
||||||
|
<p>Pengajuan Expense anda telah di periksa & setujui oleh <b>Area Manager</b> Anda:</p>
|
||||||
|
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td align="left">
|
||||||
|
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<strong>Expense Number:</strong> {{ $expense_number }}<br>
|
||||||
|
<strong>Expense Date:</strong> {{ \Carbon\Carbon::parse($tanggal)->locale('id')->isoFormat('D MMMM Y') }}<br>
|
||||||
|
<strong>Total:</strong> Rp {{ number_format($total, 0, ',', '.') }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<p style="margin-top: 20px;">Silahkan buka link berikut untuk melihat detail expense anda: <a href="{{ $url }}">{{ $url }}</a></p>
|
||||||
|
<p>Terima kasih.</p>
|
||||||
|
</td>
|
||||||
|
<!-- END MAIN CONTENT AREA -->
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- START FOOTER -->
|
||||||
|
<div class="footer">
|
||||||
|
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
|
||||||
|
<tr>
|
||||||
|
<td class="content-block">
|
||||||
|
<span class="apple-link">© PT TUNGGAL IDAMAN ABDI.</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="content-block powered-by" style="margin-bottom: 20px;">
|
||||||
|
Jl. Jend. Ahmad Yani No 7, Jakarta 13230, Indonesia.
|
||||||
|
</td>
|
||||||
|
<br>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- END FOOTER -->
|
||||||
|
|
||||||
|
<!-- END CENTERED WHITE CONTAINER --></div>
|
||||||
|
</td>
|
||||||
|
<td> </td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
<title>Expense Closed</title>
|
<title>Expense Final Approval</title>
|
||||||
<style media="all" type="text/css">
|
<style media="all" type="text/css">
|
||||||
/* -------------------------------------
|
/* -------------------------------------
|
||||||
GLOBAL RESETS
|
GLOBAL RESETS
|
||||||
@@ -308,7 +308,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="wrapper">
|
<td class="wrapper">
|
||||||
<p>Halo {{ $name }},</p>
|
<p>Halo {{ $name }},</p>
|
||||||
<p>Kami ingin memberitahukan bahwa pengajuan pengeluaran dengan detail sebagai berikut telah ditutup karena telah selesai:</p>
|
<p>Kami ingin memberitahukan bahwa pengajuan pengeluaran dengan detail sebagai berikut telah di setujui <b>( FINAL APPROVE )</b> oleh <b>MOM Region / HOSM</b> anda:</p>
|
||||||
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
|
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
+6
-1
@@ -3,6 +3,7 @@
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use App\Http\Controllers\Master\CabangController;
|
use App\Http\Controllers\Master\CabangController;
|
||||||
|
use App\Http\Controllers\Backend\DashboardController;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@@ -19,4 +20,8 @@ use App\Http\Controllers\Master\CabangController;
|
|||||||
// return $request->user();
|
// return $request->user();
|
||||||
// });
|
// });
|
||||||
|
|
||||||
Route::get('/api/cabang-by-region/{regionCode}', [CabangController::class, 'getCabangByRegion']);
|
Route::get('/api/cabang-by-region/{regionCode}', [CabangController::class, 'getCabangByRegion']);
|
||||||
|
|
||||||
|
Route::middleware(['auth:admin', 'menu'])->group(function () {
|
||||||
|
Route::get('/api/notifications', [DashboardController::class, 'notifications']);
|
||||||
|
});
|
||||||
+7
-1
@@ -90,6 +90,7 @@ Route::group(['prefix' => 'admin', 'as' => 'admin.', 'middleware' => ['auth:admi
|
|||||||
|
|
||||||
Route::middleware(['auth:admin', 'menu'])->group(function () {
|
Route::middleware(['auth:admin', 'menu'])->group(function () {
|
||||||
Route::get('/', [DashboardController::class, 'index'])->name('dashboard.index');
|
Route::get('/', [DashboardController::class, 'index'])->name('dashboard.index');
|
||||||
|
Route::post('/mark_read', [DashboardController::class, 'mark_read'])->name('dashboard.mark_read');
|
||||||
|
|
||||||
Route::prefix('budgets')->group(function () {
|
Route::prefix('budgets')->group(function () {
|
||||||
Route::get('/', [BudgetControlController::class, 'index'])->name('budget_control');
|
Route::get('/', [BudgetControlController::class, 'index'])->name('budget_control');
|
||||||
@@ -127,6 +128,7 @@ Route::middleware(['auth:admin', 'menu'])->group(function () {
|
|||||||
Route::put('/up-country/update/{id}', [FormUpCountryController::class, 'update'])->name('forms.up-country.update');
|
Route::put('/up-country/update/{id}', [FormUpCountryController::class, 'update'])->name('forms.up-country.update');
|
||||||
Route::delete('/up-country/destroy/{id}', [FormUpCountryController::class, 'destroy'])->name('forms.up-country.destroy');
|
Route::delete('/up-country/destroy/{id}', [FormUpCountryController::class, 'destroy'])->name('forms.up-country.destroy');
|
||||||
Route::put('/up-country/approve/{id}', [FormUpCountryController::class, 'approve'])->name('forms.up-country.approve');
|
Route::put('/up-country/approve/{id}', [FormUpCountryController::class, 'approve'])->name('forms.up-country.approve');
|
||||||
|
Route::put('/up-country/approve2/{id}', [FormUpCountryController::class, 'approve2'])->name('forms.up-country.approve2');
|
||||||
Route::put('/up-country/reject/{id}', [FormUpCountryController::class, 'reject'])->name('forms.up-country.reject');
|
Route::put('/up-country/reject/{id}', [FormUpCountryController::class, 'reject'])->name('forms.up-country.reject');
|
||||||
Route::put('/up-country/final-approve/{id}', [FormUpCountryController::class, 'finalApprove'])->name('forms.up-country.final-approve');
|
Route::put('/up-country/final-approve/{id}', [FormUpCountryController::class, 'finalApprove'])->name('forms.up-country.final-approve');
|
||||||
Route::put('/up-country/open/{id}', [FormUpCountryController::class, 'open'])->name('forms.up-country.open');
|
Route::put('/up-country/open/{id}', [FormUpCountryController::class, 'open'])->name('forms.up-country.open');
|
||||||
@@ -141,6 +143,7 @@ Route::middleware(['auth:admin', 'menu'])->group(function () {
|
|||||||
Route::put('/vehicle-running-cost/update/{id}', [FormVehicleController::class, 'update'])->name('forms.vehicle.update');
|
Route::put('/vehicle-running-cost/update/{id}', [FormVehicleController::class, 'update'])->name('forms.vehicle.update');
|
||||||
Route::delete('/vehicle-running-cost/destroy/{id}', [FormVehicleController::class, 'destroy'])->name('forms.vehicle.destroy');
|
Route::delete('/vehicle-running-cost/destroy/{id}', [FormVehicleController::class, 'destroy'])->name('forms.vehicle.destroy');
|
||||||
Route::put('/vehicle-running-cost/approve/{id}', [FormVehicleController::class, 'approve'])->name('forms.vehicle.approve');
|
Route::put('/vehicle-running-cost/approve/{id}', [FormVehicleController::class, 'approve'])->name('forms.vehicle.approve');
|
||||||
|
Route::put('/vehicle-running-cost/approve2/{id}', [FormVehicleController::class, 'approve2'])->name('forms.vehicle.approve2');
|
||||||
Route::put('/vehicle-running-cost/reject/{id}', [FormVehicleController::class, 'reject'])->name('forms.vehicle.reject');
|
Route::put('/vehicle-running-cost/reject/{id}', [FormVehicleController::class, 'reject'])->name('forms.vehicle.reject');
|
||||||
Route::put('/vehicle-running-cost/final-approve/{id}', [FormVehicleController::class, 'finalApprove'])->name('forms.vehicle.final-approve');
|
Route::put('/vehicle-running-cost/final-approve/{id}', [FormVehicleController::class, 'finalApprove'])->name('forms.vehicle.final-approve');
|
||||||
Route::put('/vehicle-running-cost/open/{id}', [FormVehicleController::class, 'open'])->name('forms.vehicle.open');
|
Route::put('/vehicle-running-cost/open/{id}', [FormVehicleController::class, 'open'])->name('forms.vehicle.open');
|
||||||
@@ -155,6 +158,7 @@ Route::middleware(['auth:admin', 'menu'])->group(function () {
|
|||||||
Route::put('/entertainment-presentation/update/{id}', [FormEntertainmentPresentationController::class, 'update'])->name('forms.entertainment.update');
|
Route::put('/entertainment-presentation/update/{id}', [FormEntertainmentPresentationController::class, 'update'])->name('forms.entertainment.update');
|
||||||
Route::delete('/entertainment-presentation/destroy/{id}', [FormEntertainmentPresentationController::class, 'destroy'])->name('forms.entertainment.destroy');
|
Route::delete('/entertainment-presentation/destroy/{id}', [FormEntertainmentPresentationController::class, 'destroy'])->name('forms.entertainment.destroy');
|
||||||
Route::put('/entertainment-presentation/approve/{id}', [FormEntertainmentPresentationController::class, 'approve'])->name('forms.entertainment.approve');
|
Route::put('/entertainment-presentation/approve/{id}', [FormEntertainmentPresentationController::class, 'approve'])->name('forms.entertainment.approve');
|
||||||
|
Route::put('/entertainment-presentation/approve2/{id}', [FormEntertainmentPresentationController::class, 'approve2'])->name('forms.entertainment.approve2');
|
||||||
Route::put('/entertainment-presentation/reject/{id}', [FormEntertainmentPresentationController::class, 'reject'])->name('forms.entertainment.reject');
|
Route::put('/entertainment-presentation/reject/{id}', [FormEntertainmentPresentationController::class, 'reject'])->name('forms.entertainment.reject');
|
||||||
Route::put('/entertainment-presentation/final-approve/{id}', [FormEntertainmentPresentationController::class, 'finalApprove'])->name('forms.entertainment.final-approve');
|
Route::put('/entertainment-presentation/final-approve/{id}', [FormEntertainmentPresentationController::class, 'finalApprove'])->name('forms.entertainment.final-approve');
|
||||||
Route::put('/entertainment-presentation/open/{id}', [FormEntertainmentPresentationController::class, 'open'])->name('forms.entertainment.open');
|
Route::put('/entertainment-presentation/open/{id}', [FormEntertainmentPresentationController::class, 'open'])->name('forms.entertainment.open');
|
||||||
@@ -169,6 +173,7 @@ Route::middleware(['auth:admin', 'menu'])->group(function () {
|
|||||||
Route::put('/meeting-seminar/update/{id}', [FormMeetingSeminarController::class, 'update'])->name('forms.meeting.update');
|
Route::put('/meeting-seminar/update/{id}', [FormMeetingSeminarController::class, 'update'])->name('forms.meeting.update');
|
||||||
Route::delete('/meeting-seminar/destroy/{id}', [FormMeetingSeminarController::class, 'destroy'])->name('forms.meeting.destroy');
|
Route::delete('/meeting-seminar/destroy/{id}', [FormMeetingSeminarController::class, 'destroy'])->name('forms.meeting.destroy');
|
||||||
Route::put('/meeting-seminar/approve/{id}', [FormMeetingSeminarController::class, 'approve'])->name('forms.meeting.approve');
|
Route::put('/meeting-seminar/approve/{id}', [FormMeetingSeminarController::class, 'approve'])->name('forms.meeting.approve');
|
||||||
|
Route::put('/meeting-seminar/approve2/{id}', [FormMeetingSeminarController::class, 'approve2'])->name('forms.meeting.approve2');
|
||||||
Route::put('/meeting-seminar/reject/{id}', [FormMeetingSeminarController::class, 'reject'])->name('forms.meeting.reject');
|
Route::put('/meeting-seminar/reject/{id}', [FormMeetingSeminarController::class, 'reject'])->name('forms.meeting.reject');
|
||||||
Route::put('/meeting-seminar/final-approve/{id}', [FormMeetingSeminarController::class, 'finalApprove'])->name('forms.meeting.final-approve');
|
Route::put('/meeting-seminar/final-approve/{id}', [FormMeetingSeminarController::class, 'finalApprove'])->name('forms.meeting.final-approve');
|
||||||
Route::put('/meeting-seminar/open/{id}', [FormMeetingSeminarController::class, 'open'])->name('forms.meeting.open');
|
Route::put('/meeting-seminar/open/{id}', [FormMeetingSeminarController::class, 'open'])->name('forms.meeting.open');
|
||||||
@@ -183,6 +188,7 @@ Route::middleware(['auth:admin', 'menu'])->group(function () {
|
|||||||
Route::put('/other/update/{id}', [FormOtherController::class, 'update'])->name('forms.other.update');
|
Route::put('/other/update/{id}', [FormOtherController::class, 'update'])->name('forms.other.update');
|
||||||
Route::delete('/other/destroy/{id}', [FormOtherController::class, 'destroy'])->name('forms.other.destroy');
|
Route::delete('/other/destroy/{id}', [FormOtherController::class, 'destroy'])->name('forms.other.destroy');
|
||||||
Route::put('/other/approve/{id}', [FormOtherController::class, 'approve'])->name('forms.other.approve');
|
Route::put('/other/approve/{id}', [FormOtherController::class, 'approve'])->name('forms.other.approve');
|
||||||
|
Route::put('/other/approve2/{id}', [FormOtherController::class, 'approve2'])->name('forms.other.approve2');
|
||||||
Route::put('/other/reject/{id}', [FormOtherController::class, 'reject'])->name('forms.other.reject');
|
Route::put('/other/reject/{id}', [FormOtherController::class, 'reject'])->name('forms.other.reject');
|
||||||
Route::put('/other/final-approve/{id}', [FormOtherController::class, 'finalApprove'])->name('forms.other.final-approve');
|
Route::put('/other/final-approve/{id}', [FormOtherController::class, 'finalApprove'])->name('forms.other.final-approve');
|
||||||
Route::put('/other/open/{id}', [FormOtherController::class, 'open'])->name('forms.other.open');
|
Route::put('/other/open/{id}', [FormOtherController::class, 'open'])->name('forms.other.open');
|
||||||
@@ -191,4 +197,4 @@ Route::middleware(['auth:admin', 'menu'])->group(function () {
|
|||||||
//Menu Role
|
//Menu Role
|
||||||
Route::get('/auth/menu-tree/{id}', [MenuRoleController::class, 'index'])->name('auth.menurole.index');
|
Route::get('/auth/menu-tree/{id}', [MenuRoleController::class, 'index'])->name('auth.menurole.index');
|
||||||
Route::post('/auth/menu-tree/submit', [MenuRoleController::class, 'saveMenu'])->name('auth.menurole.submit');
|
Route::post('/auth/menu-tree/submit', [MenuRoleController::class, 'saveMenu'])->name('auth.menurole.submit');
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
||||||
Reference in New Issue
Block a user