Merge branch 'branch-jagad' into 'main'

Branch jagad

See merge request fiqhpratama1/xpendify!35
This commit is contained in:
Jagad Raya
2025-01-19 08:40:29 +00:00
17 changed files with 642 additions and 501 deletions
+91 -21
View File
@@ -14,7 +14,9 @@ use App\Models\UserHasCabang;
class FormHelper
{
public static function getFormsByUserIds($userIds, $month, $year) {
// Eager load 'user.region' and 'user.cabang'
$startDate = date('Y-m-' . env('STARTING_DATE'));
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
$users = Admin::with(['region', 'cabang'])
->whereIn('id', $userIds)
->get();
@@ -29,8 +31,7 @@ class FormHelper
'created_at',
DB::raw("'Up Country' as type")
)->whereIn('user_id', $userIds)
->whereMonth('tanggal', '=', date('m', strtotime($month)))
->whereYear('tanggal', '=', $year);
->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
'expense_number',
@@ -42,8 +43,7 @@ class FormHelper
'created_at',
DB::raw("'Vehicle Running Cost' as type")
)->whereIn('user_id', $userIds)
->whereMonth('tanggal', '=', date('m', strtotime($month)))
->whereYear('tanggal', '=', $year);
->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
'expense_number',
@@ -55,8 +55,7 @@ class FormHelper
'created_at',
DB::raw("'Entertainment Presentation' as type")
)->whereIn('user_id', $userIds)
->whereMonth('tanggal', '=', date('m', strtotime($month)))
->whereYear('tanggal', '=', $year);
->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
$formMeetingSeminarQuery = FormMeetingSeminar::select(
'expense_number',
@@ -68,8 +67,7 @@ class FormHelper
'created_at',
DB::raw("'Meeting Seminar' as type")
)->whereIn('user_id', $userIds)
->whereMonth('created_at', '=', date('m', strtotime($month)))
->whereYear('created_at', '=', $year);
->whereBetween('created_at', [$startDate, $closingDateNextMonth]);
$formOthersQuery = FormOthers::select(
'expense_number',
@@ -81,8 +79,7 @@ class FormHelper
'created_at',
DB::raw("'Others' as type")
)->whereIn('user_id', $userIds)
->whereMonth('tanggal', '=', date('m', strtotime($month)))
->whereYear('tanggal', '=', $year);
->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
// Use union to combine queries
$forms = $formUpCountryQuery
@@ -101,6 +98,84 @@ class FormHelper
}
public static function getAllForms($month, $year) {
$startDate = date('Y-m-' . env('STARTING_DATE'));
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
$users = Admin::with(['region', 'cabang'])
->get();
$formUpCountryQuery = FormUpCountry::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Up Country' as type")
)->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Vehicle Running Cost' as type")
)->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Entertainment Presentation' as type")
)->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
$formMeetingSeminarQuery = FormMeetingSeminar::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Meeting Seminar' as type")
)->whereBetween('created_at', [$startDate, $closingDateNextMonth]);
$formOthersQuery = FormOthers::select(
'expense_number',
'user_id',
'total',
'approved_total',
'status',
'account_number',
'created_at',
DB::raw("'Others' as type")
)->whereBetween('tanggal', [$startDate, $closingDateNextMonth]);
// Combine queries using union
$forms = $formUpCountryQuery
->union($formVehicleRunningCostQuery)
->union($formEntertaimentPresentationQuery)
->union($formMeetingSeminarQuery)
->union($formOthersQuery)
->get();
// 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 getAllForms2() {
// Get all users with eager loading for 'region' and 'cabang'
$users = Admin::with(['region', 'cabang'])
->get();
@@ -114,8 +189,7 @@ class FormHelper
'account_number',
'created_at',
DB::raw("'Up Country' as type")
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
->whereYear('tanggal', '=', $year);
);
$formVehicleRunningCostQuery = FormVehicleRunningCost::select(
'expense_number',
@@ -126,8 +200,7 @@ class FormHelper
'account_number',
'created_at',
DB::raw("'Vehicle Running Cost' as type")
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
->whereYear('tanggal', '=', $year);
);
$formEntertaimentPresentationQuery = FormEntertaimentPresentation::select(
'expense_number',
@@ -138,8 +211,7 @@ class FormHelper
'account_number',
'created_at',
DB::raw("'Entertainment Presentation' as type")
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
->whereYear('tanggal', '=', $year);
);
$formMeetingSeminarQuery = FormMeetingSeminar::select(
'expense_number',
@@ -150,8 +222,7 @@ class FormHelper
'account_number',
'created_at',
DB::raw("'Meeting Seminar' as type")
)->whereMonth('created_at', '=', date('m', strtotime($month)))
->whereYear('created_at', '=', $year);
);
$formOthersQuery = FormOthers::select(
'expense_number',
@@ -162,8 +233,7 @@ class FormHelper
'account_number',
'created_at',
DB::raw("'Others' as type")
)->whereMonth('tanggal', '=', date('m', strtotime($month)))
->whereYear('tanggal', '=', $year);
);
// Combine queries using union
$forms = $formUpCountryQuery
@@ -104,29 +104,17 @@ 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());
return response()->json([
'count' => $notifications->count(),
'data' => $notifications->take(7)->get(),
]);
}
public function mark_read()
@@ -498,7 +498,7 @@ class ReportController extends Controller
} else {
$cabangs = Cabang::all();
$regions = Region::all();
$forms = FormHelper::getAllForms($month, $year)->sortByDesc('created_at');
$forms = FormHelper::getAllForms2()->sortByDesc('created_at');
}
// get all params in url
@@ -565,7 +565,7 @@ class ReportController extends Controller
} else {
$cabangs = Cabang::all();
$regions = Region::all();
$forms = FormHelper::getAllForms($month, $year)->sortByDesc('tanggal')->sortByDesc('created_at');
$forms = FormHelper::getAllForms($month, $year)->sortByDesc('tanggal')->sortByDesc('created_at');
}
}
}
@@ -114,30 +114,32 @@ class FormEntertainmentPresentationController extends Controller
public function store(Request $request)
{
$this->checkAuthorization(auth()->user(), ['forms.entertainment.create']);
$cabang_id = UserHasCabang::where('user_id', auth()->user()->id)->first()->cabang_id;
$request->validate([
'tanggal' => 'required',
'jenis' => 'required|in:entertainment,presentation,sponsorship',
'keterangan' => 'required',
'total' => 'required|numeric|min:1|max:' . BudgetHelper::getAvailableBudget($cabang_id),
'total' => 'required|numeric|min:1',
'name' => 'required',
'alamat' => 'required',
'nik_or_npwp' => 'required',
'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
]);
$currentDate = date('Y-m-d');
$startDate = date('Y-m-' . env('STARTING_DATE'));
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
if ($currentDate < $startDate || $currentDate > $closingDateNextMonth) {
return response()->json([
'error' => 'Current date is not within the valid range.'
], 400);
if ($request->tanggal < $startDate || $request->tanggal > $closingDateNextMonth) {
session()->flash('error', 'Gagal, Input expense sudah melewati periode input 12-10');
return redirect()->back();
}
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
if($request->total > BudgetHelper::getAvailableBudget($cabang->id)) {
session()->flash('error', 'Alokasi budget bulanan cabang tidak mencukupi,silahkan ajukan pada periode expense berikutnya');
return redirect()->back();
}
$region = Region::where('id', $cabang->region_id)->first();
$kategori = Kategori::where('name', 'Entertainment')->first();
@@ -133,9 +133,8 @@ class FormMeetingSeminarController extends Controller
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
if ($currentDate < $startDate || $currentDate > $closingDateNextMonth) {
return response()->json([
'error' => 'Current date is not within the valid range.'
], 400);
session()->flash('error', 'Gagal, Input expense sudah melewati periode input 12-10');
return redirect()->back();
}
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
@@ -195,9 +194,8 @@ class FormMeetingSeminarController extends Controller
];
// Check if the total nominal exceeds the available budget
$cabang_id = UserHasCabang::where('user_id', auth()->user()->id)->first()->cabang_id;
if(array_sum($data_nominal) > BudgetHelper::getAvailableBudget($cabang_id)) {
session()->flash('error', 'The total nominal exceeds the available budget.');
if(array_sum($data_nominal) > BudgetHelper::getAvailableBudget($cabang->id)) {
session()->flash('error', 'Alokasi budget bulanan cabang tidak mencukupi,silahkan ajukan pada periode expense berikutnya');
return redirect()->back();
}
@@ -114,27 +114,29 @@ class FormOtherController extends Controller
public function store(Request $request)
{
$this->checkAuthorization(auth()->user(), ['forms.other.create']);
$cabang_id = UserHasCabang::where('user_id', auth()->user()->id)->first()->cabang_id;
$request->validate([
'kategori_id' => 'required',
'tanggal' => 'required|date',
'keterangan' => 'required',
'total' => 'required|numeric|min:1|max:' . BudgetHelper::getAvailableBudget($cabang_id),
'total' => 'required|numeric|min:1',
'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
]);
$currentDate = date('Y-m-d');
$startDate = date('Y-m-' . env('STARTING_DATE'));
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
if ($currentDate < $startDate || $currentDate > $closingDateNextMonth) {
return response()->json([
'error' => 'Current date is not within the valid range.'
], 400);
if ($request->tanggal < $startDate || $request->tanggal > $closingDateNextMonth) {
session()->flash('error', 'Gagal, Input expense sudah melewati periode input 12-10');
return redirect()->back();
}
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
if($request->total > BudgetHelper::getAvailableBudget($cabang->id)) {
session()->flash('error', 'Alokasi budget bulanan cabang tidak mencukupi,silahkan ajukan pada periode expense berikutnya');
return redirect()->back();
}
$region = Region::where('id', $cabang->region_id)->first();
$kategori = Kategori::where('id', $request->kategori_id)->first();
@@ -115,9 +115,10 @@ class FormUpCountryController extends Controller
public function create()
{
$this->checkAuthorization(auth()->user(), ['forms.country.create']);
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
return view('backend.pages.forms.upcountry.create', [
'rayons' => Rayon::all()
'rayons' => Rayon::where('cabang_id', $cabang->id)->get()
]);
}
@@ -140,14 +141,12 @@ class FormUpCountryController extends Controller
'bukti_hotel' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
]);
$currentDate = date('Y-m-d');
$startDate = date('Y-m-' . env('STARTING_DATE'));
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
if ($currentDate < $startDate || $currentDate > $closingDateNextMonth) {
return response()->json([
'error' => 'Current date is not within the valid range.'
], 400);
if ($request->tanggal < $startDate || $request->tanggal > $closingDateNextMonth) {
session()->flash('error', 'Gagal, Input expense sudah melewati periode input 12-10');
return redirect()->back();
}
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
@@ -220,9 +219,8 @@ class FormUpCountryController extends Controller
];
// Check if the total nominal exceeds the available budget
$cabang_id = UserHasCabang::where('user_id', auth()->user()->id)->first()->cabang_id;
if(array_sum($data_nominal) > BudgetHelper::getAvailableBudget($cabang_id)) {
session()->flash('error', 'The total nominal exceeds the available budget.');
if(array_sum($data_nominal) > BudgetHelper::getAvailableBudget($cabang->id)) {
session()->flash('error', 'Alokasi budget bulanan cabang tidak mencukupi,silahkan ajukan pada periode expense berikutnya');
return redirect()->back();
}
@@ -307,6 +305,8 @@ class FormUpCountryController extends Controller
$this->checkAuthorization(auth()->user(), ['forms.country.edit']);
$role = auth()->user()->getRoleNames()[0];
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
$form = FormUpCountry::with('rayon')->findOrfail($id);
if (($form->status != 'On Progress' && $form->status != 'Rejected') && $role == 'Medical Representatif') {
session()->flash('error', 'You cannot edit this form because it has been approved or closed.');
@@ -314,7 +314,7 @@ class FormUpCountryController extends Controller
}
return view('backend.pages.forms.upcountry.edit', [
'rayons' => Rayon::all(),
'rayons' => Rayon::where('cabang_id', $cabang->id)->get(),
'form' => $form
]);
}
@@ -115,12 +115,11 @@ class FormVehicleController extends Controller
public function store(Request $request)
{
$this->checkAuthorization(auth()->user(), ['forms.vehicle.create']);
$cabang_id = UserHasCabang::where('user_id', auth()->user()->id)->first()->cabang_id;
$request->validate([
'tanggal' => 'required',
'liter' => 'required',
'total' => 'required|numeric|min:1|max:' . BudgetHelper::getAvailableBudget($cabang_id),
'total' => 'required|numeric|min:1',
'jarak' => 'required',
'tipe_bensin' => 'required|in:pertalite,pertamax',
'nopol' => 'required',
@@ -128,17 +127,20 @@ class FormVehicleController extends Controller
'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
]);
$currentDate = date('Y-m-d');
$startDate = date('Y-m-' . env('STARTING_DATE'));
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
if ($currentDate < $startDate || $currentDate > $closingDateNextMonth) {
return response()->json([
'error' => 'Current date is not within the valid range.'
], 400);
if ($request->tanggal < $startDate || $request->tanggal > $closingDateNextMonth) {
session()->flash('error', 'Gagal, Input expense sudah melewati periode input 12-10');
return redirect()->back();
}
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
if($request->total > BudgetHelper::getAvailableBudget($cabang->id)) {
session()->flash('error', 'Alokasi budget bulanan cabang tidak mencukupi,silahkan ajukan pada periode expense berikutnya');
return redirect()->back();
}
$region = Region::where('id', $cabang->region_id)->first();
$kategori = Kategori::where('name', 'Vehicle Running Cost')->first();
+1 -1
View File
@@ -10,5 +10,5 @@ class Rayon extends Model
use SoftDeletes;
protected $table = 'rayon';
protected $fillable = ['code', 'name'];
protected $fillable = ['code', 'name', 'cabang_id'];
}
@@ -0,0 +1,29 @@
<?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('rayon', function (Blueprint $table) {
$table->foreignId('cabang_id')->nullable()->constrained('cabang')->cascadeOnDelete()->after('id')->default(1);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('rayon', function (Blueprint $table) {
$table->dropForeign(['cabang_id']);
$table->dropColumn('cabang_id');
});
}
};
@@ -109,13 +109,13 @@
<th>Bukti</th>
<th>Account Number</th>
<th>Status</th>
@if (auth()->user()->can('approval.approve'))
@if (auth()->user()->can('approval.view'))
<th>Approval 1</th>
@endif
@if (auth()->user()->can('approval2.approve'))
@if (auth()->user()->can('approval2.view'))
<th>Approval 2</th>
@endif
@if (auth()->user()->can('final_approval.approve'))
@if (auth()->user()->can('final_approval.view'))
<th>Final Approval</th>
@endif
<th>Aksi</th>
@@ -157,92 +157,87 @@
<span class="badge badge-danger text-white">{{ $item->status }}</span>
@endif
</td>
@if (auth()->user()->can('approval.approve'))
@if (auth()->user()->can('approval.view'))
<td>
{{-- approve / reject button --}}
@if ($item->status == 'On Progress' || $item->status == 'Rejected')
<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.approve', $item->id) }}">
Approve 1
</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->approved_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('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'))
<td>
{{-- approve / reject button --}}
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
<form action="javascript:void(0);" class="d-inline">
<button type="button"
class="btn btn-success btn-sm final-approve-modal"
data-id="{{ route('forms.entertainment.final-approve', $item->id) }}">
Final Approve
</button>
</form>
@else
@if ($item->final_approved_at && auth()->user()->can('final_approval.open'))
<form action="{{ route('forms.entertainment.open', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this item?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-success btn-sm">
Open
@if (auth()->user()->can('approval.approve'))
@if ($item->status == 'On Progress')
<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.approve', $item->id) }}">
Approve 1
</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>
@elseif ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif
@endif
@if ($item->approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td>
@endif
@if (auth()->user()->can('approval2.view'))
<td>
{{-- approve / reject button --}}
@if (auth()->user()->can('approval2.approve'))
@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>
@endif
@endif
@if ($item->approved2_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td>
@endif
@if(auth()->user()->can('final_approval.view'))
<td>
{{-- approve / reject button --}}
@if(auth()->user()->can('final_approval.approve'))
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
<form action="javascript:void(0);" class="d-inline">
<button type="button"
class="btn btn-success btn-sm final-approve-modal"
data-id="{{ route('forms.entertainment.final-approve', $item->id) }}">
Final Approve
</button>
</form>
@else
@if ($item->final_approved_at && auth()->user()->can('final_approval.open'))
<form action="{{ route('forms.entertainment.open', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this item?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-success btn-sm">
Open
</button>
</form>
@endif
@endif
@endif
@if ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td>
@endif
<td>
@@ -108,13 +108,13 @@
<th>Total Approved</th>
<th>Account Number</th>
<th>Status</th>
@if (auth()->user()->can('approval.approve'))
@if (auth()->user()->can('approval.view'))
<th>Approval 1</th>
@endif
@if (auth()->user()->can('approval2.approve'))
@if (auth()->user()->can('approval2.view'))
<th>Approval 2</th>
@endif
@if (auth()->user()->can('final_approval.approve'))
@if (auth()->user()->can('final_approval.view'))
<th>Final Approval</th>
@endif
<th>Aksi</th>
@@ -147,92 +147,87 @@
<span class="badge badge-danger text-white">{{ $item->status }}</span>
@endif
</td>
@if (auth()->user()->can('approval.approve'))
@if (auth()->user()->can('approval.view'))
<td>
{{-- approve / reject button --}}
@if ($item->status == 'On Progress' || $item->status == 'Rejected')
<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.approve', $item->id) }}">
Approve 1
</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->approved_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('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'))
<td>
{{-- approve / reject button --}}
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
<form action="javascript:void(0);" class="d-inline">
<button type="button"
class="btn btn-success btn-sm final-approve-modal"
data-id="{{ route('forms.meeting.final-approve', $item->id) }}">
Final Approve
</button>
</form>
@else
@if ($item->final_approved_at && auth()->user()->can('final_approval.open'))
<form action="{{ route('forms.meeting.open', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this item?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-success btn-sm">
Open
@if (auth()->user()->can('approval.approve'))
@if ($item->status == 'On Progress')
<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.approve', $item->id) }}">
Approve 1
</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>
@elseif ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif
@endif
@if ($item->approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td>
@endif
@if (auth()->user()->can('approval2.view'))
<td>
{{-- approve / reject button --}}
@if (auth()->user()->can('approval2.approve'))
@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>
@endif
@endif
@if ($item->approved2_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td>
@endif
@if(auth()->user()->can('final_approval.view'))
<td>
{{-- approve / reject button --}}
@if(auth()->user()->can('final_approval.approve'))
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
<form action="javascript:void(0);" class="d-inline">
<button type="button"
class="btn btn-success btn-sm final-approve-modal"
data-id="{{ route('forms.meeting.final-approve', $item->id) }}">
Final Approve
</button>
</form>
@else
@if ($item->final_approved_at && auth()->user()->can('final_approval.open'))
<form action="{{ route('forms.meeting.open', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this item?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-success btn-sm">
Open
</button>
</form>
@endif
@endif
@endif
@if ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td>
@endif
<td>
@@ -108,13 +108,13 @@
<th>Bukti Total</th>
<th>Account Number</th>
<th>Status</th>
@if (auth()->user()->can('approval.approve'))
@if (auth()->user()->can('approval.view'))
<th>Approval 1</th>
@endif
@if (auth()->user()->can('approval2.approve'))
@if (auth()->user()->can('approval2.view'))
<th>Approval 2</th>
@endif
@if (auth()->user()->can('final_approval.approve'))
@if (auth()->user()->can('final_approval.view'))
<th>Final Approval</th>
@endif
<th>Aksi</th>
@@ -155,92 +155,87 @@
<span class="badge badge-danger text-white">{{ $item->status }}</span>
@endif
</td>
@if (auth()->user()->can('approval.approve'))
@if (auth()->user()->can('approval.view'))
<td>
{{-- approve / reject button --}}
@if ($item->status == 'On Progress' || $item->status == 'Rejected')
<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.approve', $item->id) }}">
Approve 1
</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->approved_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('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'))
<td>
{{-- approve / reject button --}}
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
<form action="javascript:void(0);" class="d-inline">
<button type="button"
class="btn btn-success btn-sm final-approve-modal"
data-id="{{ route('forms.other.final-approve', $item->id) }}">
Final Approve
</button>
</form>
@else
@if ($item->final_approved_at && auth()->user()->can('final_approval.open'))
<form action="{{ route('forms.other.open', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this item?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-success btn-sm">
Open
@if (auth()->user()->can('approval.approve'))
@if ($item->status == 'On Progress')
<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.approve', $item->id) }}">
Approve 1
</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>
@elseif ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif
@endif
@if ($item->approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td>
@endif
@if (auth()->user()->can('approval2.view'))
<td>
{{-- approve / reject button --}}
@if (auth()->user()->can('approval2.approve'))
@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>
@endif
@endif
@if ($item->approved2_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td>
@endif
@if(auth()->user()->can('final_approval.view'))
<td>
{{-- approve / reject button --}}
@if(auth()->user()->can('final_approval.approve'))
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
<form action="javascript:void(0);" class="d-inline">
<button type="button"
class="btn btn-success btn-sm final-approve-modal"
data-id="{{ route('forms.other.final-approve', $item->id) }}">
Final Approve
</button>
</form>
@else
@if ($item->final_approved_at && auth()->user()->can('final_approval.open'))
<form action="{{ route('forms.other.open', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this item?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-success btn-sm">
Open
</button>
</form>
@endif
@endif
@endif
@if ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td>
@endif
<td>
@@ -108,13 +108,13 @@
<th>Total Approved</th>
<th>Account Number</th>
<th>Status</th>
@if (auth()->user()->can('approval.approve'))
@if (auth()->user()->can('approval.view'))
<th>Approval 1</th>
@endif
@if (auth()->user()->can('approval2.approve'))
@if (auth()->user()->can('approval2.view'))
<th>Approval 2</th>
@endif
@if (auth()->user()->can('final_approval.approve'))
@if (auth()->user()->can('final_approval.view'))
<th>Final Approval</th>
@endif
<th>Aksi</th>
@@ -153,92 +153,87 @@
<span class="badge badge-danger text-white">{{ $item->status }}</span>
@endif
</td>
@if (auth()->user()->can('approval.approve'))
@if (auth()->user()->can('approval.view'))
<td>
{{-- approve / reject button --}}
@if ($item->status == 'On Progress' || $item->status == 'Rejected')
<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.approve', $item->id) }}">
Approve 1
</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->approved_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('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'))
<td>
{{-- approve / reject button --}}
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
<form action="javascript:void(0);" class="d-inline">
<button type="button"
class="btn btn-success btn-sm final-approve-modal"
data-id="{{ route('forms.up-country.final-approve', $item->id) }}">
Final Approve
</button>
</form>
@else
@if ($item->final_approved_at && auth()->user()->can('final_approval.open'))
<form action="{{ route('forms.up-country.open', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this item?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-success btn-sm">
Open
@if (auth()->user()->can('approval.approve'))
@if ($item->status == 'On Progress')
<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.approve', $item->id) }}">
Approve 1
</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>
@elseif ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif
@endif
@if ($item->approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td>
@endif
@if (auth()->user()->can('approval2.view'))
<td>
{{-- approve / reject button --}}
@if (auth()->user()->can('approval2.approve'))
@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>
@endif
@endif
@if ($item->approved2_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td>
@endif
@if(auth()->user()->can('final_approval.view'))
<td>
{{-- approve / reject button --}}
@if(auth()->user()->can('final_approval.approve'))
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
<form action="javascript:void(0);" class="d-inline">
<button type="button"
class="btn btn-success btn-sm final-approve-modal"
data-id="{{ route('forms.up-country.final-approve', $item->id) }}">
Final Approve
</button>
</form>
@else
@if ($item->final_approved_at && auth()->user()->can('final_approval.open'))
<form action="{{ route('forms.up-country.open', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this item?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-success btn-sm">
Open
</button>
</form>
@endif
@endif
@endif
@if ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td>
@endif
<td>
@@ -110,13 +110,13 @@
<th>Bukti</th>
<th>Account Number</th>
<th>Status</th>
@if (auth()->user()->can('approval.approve'))
@if (auth()->user()->can('approval.view'))
<th>Approval 1</th>
@endif
@if (auth()->user()->can('approval2.approve'))
@if (auth()->user()->can('approval2.view'))
<th>Approval 2</th>
@endif
@if (auth()->user()->can('final_approval.approve'))
@if (auth()->user()->can('final_approval.view'))
<th>Final Approval</th>
@endif
<th>Aksi</th>
@@ -159,92 +159,87 @@
<span class="badge badge-danger text-white">{{ $item->status }}</span>
@endif
</td>
@if (auth()->user()->can('approval.approve'))
@if (auth()->user()->can('approval.view'))
<td>
{{-- approve / reject button --}}
@if ($item->status == 'On Progress' || $item->status == 'Rejected')
<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.approve', $item->id) }}">
Approve 1
</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->approved_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('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'))
<td>
{{-- approve / reject button --}}
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
<form action="javascript:void(0);" class="d-inline">
<button type="button"
class="btn btn-success btn-sm final-approve-modal"
data-id="{{ route('forms.vehicle.final-approve', $item->id) }}">
Final Approve
</button>
</form>
@else
@if ($item->final_approved_at && auth()->user()->can('final_approval.open'))
<form action="{{ route('forms.vehicle.open', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this item?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-success btn-sm">
Open
@if (auth()->user()->can('approval.approve'))
@if ($item->status == 'On Progress')
<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.approve', $item->id) }}">
Approve 1
</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>
@elseif ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@else
-
@endif
@endif
@if ($item->approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td>
@endif
@if (auth()->user()->can('approval2.view'))
<td>
{{-- approve / reject button --}}
@if (auth()->user()->can('approval2.approve'))
@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>
@endif
@endif
@if ($item->approved2_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td>
@endif
@if(auth()->user()->can('final_approval.view'))
<td>
{{-- approve / reject button --}}
@if(auth()->user()->can('final_approval.approve'))
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
<form action="javascript:void(0);" class="d-inline">
<button type="button"
class="btn btn-success btn-sm final-approve-modal"
data-id="{{ route('forms.vehicle.final-approve', $item->id) }}">
Final Approve
</button>
</form>
@else
@if ($item->final_approved_at && auth()->user()->can('final_approval.open'))
<form action="{{ route('forms.vehicle.open', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this item?');">
@csrf
@method('PUT')
<button type="submit" class="btn btn-success btn-sm">
Open
</button>
</form>
@endif
@endif
@endif
@if ($item->final_approved_at)
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
@endif
</td>
@endif
<td>
@@ -149,7 +149,45 @@
{
extend: 'excel',
text: 'Export Excel',
buttons: ['excel', 'csv', 'pdf', 'print', 'colvis'],
customize: function (xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
// Add a blank row for spacing
var blankRow = `<row><c t="inlineStr"><is><t></t></is></c></row>`;
// Bold text using Excel XML structure
var additionalInfo = `
<row>
<c t="inlineStr" s="2"><is><t>Cabang: {{ $cabang->name }}</t></is></c>
</row>
<row>
<c t="inlineStr" s="2"><is><t>Periode: {{ ucfirst($month) }} {{ $year }}</t></is></c>
</row>
<row>
<c t="inlineStr" s="2"><is><t>Cost Centre: {{ $cabang->cost->code }}</t></is></c>
</row>
`;
// Locate the sheet data and append the blank row and additional information
var sheetData = $(sheet).find('sheetData');
var existingRows = sheetData.children();
existingRows.last().after(blankRow + additionalInfo);
// Add bold style to the sheet
var styles = xlsx.xl['styles.xml'];
var cellXfs = $(styles).find('cellXfs');
cellXfs.append(`
<xf xfId="0" applyFont="1">
<alignment horizontal="left"/>
<font>
<b/>
<sz val="11"/>
<name val="Calibri"/>
<family val="2"/>
</font>
</xf>
`);
}
},
{
extend: 'csv',
@@ -157,11 +195,10 @@
customize: function (csv) {
// Add header information to the CSV
var additionalInfo = `
Cabang: {{ $cabang->name }}
Periode: {{ ucfirst($month) }} {{ $year }}
Cost Centre: {{ $cabang->cost->code }}
`;
Cabang: {{ $cabang->name }}
Periode: {{ ucfirst($month) }} {{ $year }}
Cost Centre: {{ $cabang->cost->code }}
`;
return additionalInfo + csv;
}
},
+41 -3
View File
@@ -26,6 +26,12 @@
<li class="nav-item">
<a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
</li>
<li class="nav-item">
{{-- periode --}}
<a class="nav-link" href="{{ route('dashboard.index') }}" role="button">
<span class="ml-2 font-weight-bold text-white">Periode: <span id="periode"></span></span>
</a>
</li>
</ul>
<div class="navbar-center text-white m-auto">
@@ -36,6 +42,7 @@
<li class="nav-item dropdown">
<a class="nav-link" data-toggle="dropdown" href="#" role="button" data-widget="notification">
<i class="fas fa-bell"></i>
<span id="notification-dot" class="badge badge-danger" style="display: none; position: absolute; top: 8px; right: 10px; font-size: 0.6rem;"></span>
</a>
<div class="dropdown-menu dropdown-menu-xl dropdown-menu-right">
<div id="notification">
@@ -101,7 +108,10 @@
<a class="d-block font-weight-bold" style="font-size: 11px;">
{{ Auth::guard('admin')->user()->getRoleNames()[0] }}
</a>
@if(auth()->user()->getMyCabangAndRegion()['cabang'] != '-' && Auth::guard('admin')->user()->getRoleNames()[0] == 'Medical Representatif')
@if(
auth()->user()->getMyCabangAndRegion()['cabang'] != '-' &&
in_array(Auth::guard('admin')->user()->getRoleNames()[0], ['Medical Representatif', 'Area Manager Cabang'])
)
<a class="d-block" style="font-size: 14px;">
<span class="badge badge-primary">
{{ auth()->user()->getMyCabangAndRegion()['cabang'] }}
@@ -162,7 +172,7 @@
hour12: false // Use 24-hour format
};
dateTimeElement.textContent = new Intl.DateTimeFormat('id-ID', options).format(now);
dateTimeElement.textContent = new Intl.DateTimeFormat('id-ID', options).format(now) + ' WIB';
}
// Update the clock every second
@@ -186,7 +196,7 @@
.then(data => {
notificationList.innerHTML = ''; // Clear existing notifications
data.forEach(notification => {
data.data.forEach(notification => {
const item = document.createElement('a');
item.href = notification.link || '#';
item.classList.add('dropdown-item');
@@ -223,4 +233,32 @@
});
});
fetch('/api/notifications')
.then(response => response.json())
.then(data => {
const notificationDot = document.getElementById('notification-dot');
if (data.count > 0) {
// Show red dot if there are notifications
// show the number of notifications
notificationDot.textContent = data.count;
notificationDot.style.display = 'block';
} else {
// Hide red dot if there are no notifications
notificationDot.style.display = 'none';
}
})
.catch(error => {
console.error('Error checking notifications:', error);
});
const periode = document.getElementById('periode');
const date = new Date();
const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
const month = months[date.getMonth()]; // Get the current month's short name
const nextMonth = months[(date.getMonth() + 1) % 12]; // Get the next month's short name, wrapping around if necessary
const year = date.getFullYear();
periode.textContent = `${month} (12 ${month} - 10 ${nextMonth} ${year})`;
</script>