@extends('layouts.app')
@section('title')
Dashboard
@endsection
@section('admin-content')
@php
$outstandingIdCollection = collect($outstandingIds ?? []);
// ==========================================
// FILTER PERIODE BERJALAN KHUSUS UNTUK MINI CARDS
// (Sinkronisasi Angka Realtime Siklus Tanggal 11-13)
// ==========================================
$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();
}
// Filter koleksi data pengajuan murni yang berada dalam rentang aktif berjalan
$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.entertainment.create'))
Add New Expense
@endif
#
No Expense
User
Cabang
Nama Penerima
Tanggal
Jenis
Keterangan
Total
Total Approved
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
// SUNTIKAN PERBAIKAN: Impor Class Helper NextCloud ke dalam scope Blade View
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 }}
{{ $item->name }}
{{ \Carbon\Carbon::parse($item->tanggal)->locale('id')->isoFormat('D MMMM Y') }}
{{ $item->jenis }}
{{ $item->keterangan }}
{{ number_format($item->total, 0, ',', '.') }}
{{ number_format($item->approved_total, 0, ',', '.') }}
@if ($item->bukti_total)
Download
@else - @endif
{{ $item->account_number }}
@if ($item->status == 'On Progress')
{{ $item->status }}
@elseif (in_array($item->status, ['Approved 1', 'Approved 2', 'Final Approved']))
{{ $item->status }}
@else
{{ $item->status }}
@endif
@if (auth()->user()->can('approval.view'))
@if (auth()->user()->can('approval.approve') && $item->status == 'On Progress')
Approve 1
Reject
@endif
@if ($item->approved_at) {{ \Carbon\Carbon::parse($item->approved_at)->format('d/m/y H:i') }} @endif
@endif
@if (auth()->user()->can('approval2.view'))
@if (auth()->user()->can('approval2.approve') && $item->status == 'Approved 1' && $item->approved_at)
Approve 2
Reject
@endif
@if ($item->approved2_at) {{ \Carbon\Carbon::parse($item->approved2_at)->format('d/m/y H:i') }} @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)
Final Approve
Reject
@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)->format('d/m/y H:i') }} @endif
@endif
@if (auth()->user()->can('forms.entertainment.view')) @endif
@php $canEdit = auth()->user()->can('forms.entertainment.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.entertainment.delete')) || ($role == 'Medical Representatif' && $item->status == 'On Progress'))
@endif
@endforeach
{{-- MODAL CONTAINER DI BAWAH (TETAP UTUH UNTUK KEBUTUHAN AJAX ROUTING) --}}
@endsection
@section('scripts')
@endsection