@extends('layouts.app')
@section('title')
Dashboard
@endsection
@section('admin-content')
@php
$outstandingIdCollection = collect($outstandingIds ?? []);
// ==========================================
// FILTER PERIODE BERJALAN KHUSUS UNTUK MINI CARDS
// (Agar Angka sinkron dengan tabel filter JS di bawah)
// ==========================================
$startDayIndex = (int) env('STARTING_DATE', 11);
$closingDayIndex = (int) env('CLOSING_DATE', 13);
$nowIndex = \Carbon\Carbon::now();
if ($nowIndex->day >= $startDayIndex) {
$startPeriodIndex = \Carbon\Carbon::create($nowIndex->year, $nowIndex->month, $startDayIndex)->startOfDay();
$endPeriodIndex = \Carbon\Carbon::create($nowIndex->copy()->addMonth()->year, $nowIndex->copy()->addMonth()->month, $closingDayIndex)->endOfDay();
} else {
$startPeriodIndex = \Carbon\Carbon::create($nowIndex->copy()->subMonth()->year, $nowIndex->copy()->subMonth()->month, $startDayIndex)->startOfDay();
$endPeriodIndex = \Carbon\Carbon::create($nowIndex->year, $nowIndex->month, $closingDayIndex)->endOfDay();
}
// Penampung data pengajuan MURNI HANYA DI PERIODE BERJALAN SAAT INI
$currentPeriodForms = $forms->filter(function($form) use ($startPeriodIndex, $endPeriodIndex) {
$tanggalForm = \Carbon\Carbon::parse($form->tanggal);
return $tanggalForm->between($startPeriodIndex, $endPeriodIndex);
});
@endphp
Rp {{ number_format($forms->sum('total'), 0, ',', '.') }}
Total Expense
Rp {{ number_format($forms->whereIn('status', ['Approved', 'Closed', 'Final Approved'])->sum('approved_total'), 0, ',', '.') }}
Approved Expenses
Rp {{ number_format($forms->where('status', 'On Progress')->sum('total'), 0, ',', '.') }}
Pending Expenses
{{ $outstandingCount }}
Outstanding Expenses
Total Rp {{ number_format($outstandingTotal, 0, ',', '.') }}
Klik untuk menampilkan detail
@if($availableBudget > 0)
Rp {{ number_format($availableBudget, 0, ',', '.') }}
Available Budget
@endif
Semua
{{ $currentPeriodForms->count() }}
Progress
{{ $currentPeriodForms->where('status', 'On Progress')->count() }}
App 1
{{ $currentPeriodForms->where('status', 'Approved 1')->count() }}
App 2
{{ $currentPeriodForms->where('status', 'Approved 2')->count() }}
Final
{{ $currentPeriodForms->where('status', 'Final Approved')->count() }}
Reject
{{ $currentPeriodForms->where('status', 'Rejected')->count() }}
Closed
{{ $currentPeriodForms->where('status', 'Closed')->count() }}
@if (auth()->user()->can('forms.vehicle.create'))
Add New Expense Vehicle Running Cost
@endif
@include('backend.layouts.partials.messages')
| # |
No Expense |
Nama |
Cabang |
Tanggal |
Type |
Liter |
Keterangan |
Total |
Total Approved |
Km (Odometer) |
Tipe Bensin |
Nomor Polisi |
Bukti |
Account Number |
Status |
@if (auth()->user()->can('approval.view')) Approval 1 | @endif
@if (auth()->user()->can('approval2.view')) Approval 2 | @endif
@if (auth()->user()->can('final_approval.view')) Final Approval | @endif
Aksi |
@php
use App\Helpers\NextCloudHelper;
$role = auth()->user()->getRoleNames()[0];
@endphp
@foreach ($forms as $item)
| {{ $loop->iteration }} |
{{ $item->expense_number }} |
{{ $item->user->name }} |
{{ $item->user->cabang->cabang->name }} |
{{ \Carbon\Carbon::parse($item->tanggal)->locale('id')->isoFormat('dddd, D MMMM Y HH:mm:ss') }} |
@if ($item->type == 'gasoline')
Gasoline
@elseif ($item->type == 'parking_toll')
Parking / Toll
@else
Unknown
@endif
|
{{ $item->liter }} |
{{ $item->keterangan }} |
{{ number_format($item->total, 0, ',', '.') }} |
{{ number_format($item->approved_total, 0, ',', '.') }} |
{{ $item->jarak }} km |
{{ $item->tipe_bensin }} |
{{ $item->nopol }} |
@if ($item->bukti_total)
Download
@else
-
@endif
|
{{ $item->account_number }} |
@if ($item->status == 'On Progress')
{{ $item->status }}
@elseif ($item->status == 'Approved 1' || $item->status == 'Approved 2' || $item->status == 'Final Approved')
{{ $item->status }}
@else
{{ $item->status }}
@endif
|
{{-- SELEKTIF MENYEMBUNYIKAN TOMBOL APPROVE/REJECT DIRECT DI INDEX TANPA MENGHAPUS LOGIKA KODE --}}
@if (auth()->user()->can('approval.view'))
@if (auth()->user()->can('approval.approve') && $item->status == 'On Progress')
@endif
@if ($item->approved_at) {{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y HH:mm') }} @endif
|
@endif
@if (auth()->user()->can('approval2.view'))
@if (auth()->user()->can('approval2.approve') && $item->status == 'Approved 1' && $item->approved_at)
@endif
@if ($item->approved2_at) {{ \Carbon\Carbon::parse($item->approved2_at)->locale('id')->isoFormat('D MMMM Y HH:mm') }} @endif
|
@endif
@if(auth()->user()->can('final_approval.view'))
@if(auth()->user()->can('final_approval.approve'))
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
@elseif ($item->final_approved_at && auth()->user()->can('final_approval.open'))
@endif
@endif
@if ($item->final_approved_at) {{ \Carbon\Carbon::parse($item->final_approved_at)->locale('id')->isoFormat('D MMMM Y HH:mm') }} @endif
|
@endif
@if (auth()->user()->can('forms.vehicle.view'))
@endif
@php
$canEdit = auth()->user()->can('forms.vehicle.edit') && (!in_array($role, ['Medical Representatif', 'Area Manager Cabang']) || $item->status == 'On Progress');
@endphp
@if ($canEdit)
@endif
@if (($role != 'Medical Representatif' && auth()->user()->can('forms.vehicle.delete')) || ($role == 'Medical Representatif' && $item->status == 'On Progress'))
@endif
|
@endforeach
{{-- MODAL CONTAINER DI BAWAH (TETAP UTUH UNTUK KEBUTUHAN ROUTING AJAX) --}}
@endsection
@section('scripts')
@endsection