This commit is contained in:
@@ -5,288 +5,421 @@
|
||||
@endsection
|
||||
|
||||
@section('admin-content')
|
||||
<section class="content-header">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<section class="content-header">
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-6">
|
||||
<h1>{{ $pageInfo['title'] }}</h1>
|
||||
<h1 class="fw-bold">{{ $pageInfo['title'] }}</h1>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-form"><a href="{{ route('admin.dashboard') }}">{{ __('Dashboard') }}</a> / </li>
|
||||
<li class="breadcrumb-form active"> {{ $pageInfo['title'] }}</li>
|
||||
<li class="breadcrumb-item"><a href="{{ route('admin.dashboard') }}">{{ __('Dashboard') }}</a></li>
|
||||
<li class="breadcrumb-item active">{{ $pageInfo['title'] }}</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-4">
|
||||
<!-- Total Expense -->
|
||||
<div class="col-lg-3 col-6">
|
||||
<div class="small-box bg-info">
|
||||
<div class="inner">
|
||||
<h3>Rp {{ number_format($forms->sum('total'), 0, ',', '.') }}</h3>
|
||||
<p>Total Expense</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="fas fa-wallet"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Approved Expense -->
|
||||
<div class="col-lg-3 col-6">
|
||||
<div class="small-box bg-success">
|
||||
<div class="inner">
|
||||
<h3>Rp {{ number_format($forms->whereIn('status', ['Approved', 'Closed'])->sum('approved_total'), 0, ',', '.') }}</h3>
|
||||
<p>Approved Expenses</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="fas fa-check-circle"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Pending Expense -->
|
||||
<div class="col-lg-3 col-6">
|
||||
<div class="small-box bg-warning">
|
||||
<div class="inner">
|
||||
<h3 class="text-white">Rp {{ number_format($forms->where('status', 'On Progress')->sum('total'), 0, ',', '.') }}</h3>
|
||||
<p class="text-white">Pending Expenses</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="fas fa-hourglass-half"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Budget Available -->
|
||||
<div class="col-lg-3 col-6">
|
||||
<div class="small-box bg-purple">
|
||||
<div class="inner">
|
||||
{{-- <h3 class="text-white">Rp {{ number_format($availableBudget, 0, ',', '.') }}</h3> --}}
|
||||
{{-- check if availableBudget is not - --}}
|
||||
<h3 class="text-white">{{ $availableBudget == '0' ? '-' : 'Rp' . number_format($availableBudget, 0, ',', '.') }}</h3>
|
||||
<p class="text-white">Available Budget</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="fas fa-money-bill"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form action="{{ route('reports.all') }}" method="GET">
|
||||
<div class="d-flex">
|
||||
<div class="col-md-3">
|
||||
<div class="form-group mb-3">
|
||||
<label for="region">Pilih Region</label>
|
||||
<select name="region" id="region" class="form-control">
|
||||
<option value="">Semua Region</option>
|
||||
@foreach ($regions as $region)
|
||||
<option value="{{ $region->code }}" {{ request()->region == $region->code ? 'selected' : '' }}>
|
||||
{{ $region->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group mb-3">
|
||||
<label for="cabang">Pilih Cabang</label>
|
||||
<select name="cabang" id="cabang" class="form-control">
|
||||
<option value="">Semua Cabang</option>
|
||||
<!-- Cabang options will be dynamically populated -->
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="form-group mb-3">
|
||||
<label for="month">Pilih Periode Bulan</label>
|
||||
<select name="month" id="month" class="form-control">
|
||||
<option value="">Pilih Bulan</option>
|
||||
<option value="january" {{ request()->month == 'january' ? 'selected' : '' }}>Januari</option>
|
||||
<option value="february" {{ request()->month == 'february' ? 'selected' : '' }}>Februari</option>
|
||||
<option value="march" {{ request()->month == 'march' ? 'selected' : '' }}>Maret</option>
|
||||
<option value="april" {{ request()->month == 'april' ? 'selected' : '' }}>April</option>
|
||||
<option value="may" {{ request()->month == 'may' ? 'selected' : '' }}>Mei</option>
|
||||
<option value="june" {{ request()->month == 'june' ? 'selected' : '' }}>Juni</option>
|
||||
<option value="july" {{ request()->month == 'july' ? 'selected' : '' }}>Juli</option>
|
||||
<option value="august" {{ request()->month == 'august' ? 'selected' : '' }}>Agustus</option>
|
||||
<option value="september" {{ request()->month == 'september' ? 'selected' : '' }}>September</option>
|
||||
<option value="october" {{ request()->month == 'october' ? 'selected' : '' }}>Oktober</option>
|
||||
<option value="november" {{ request()->month == 'november' ? 'selected' : '' }}>November</option>
|
||||
<option value="december" {{ request()->month == 'december' ? 'selected' : '' }}>Desember</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
<div class="form-group mb-3">
|
||||
<label for="year">Pilih Periode Tahun</label>
|
||||
<select name="year" id="year" class="form-control">
|
||||
<option value="">Pilih Tahun</option>
|
||||
@for ($i = 2024; $i <= date('Y'); $i++)
|
||||
<option value="{{ $i }}" {{ request()->year == $i ? 'selected' : '' }}>{{ $i }}</option>
|
||||
@endfor
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{{-- Summary Widgets --}}
|
||||
<div class="row mt-4">
|
||||
<div class="col-lg-3 col-6">
|
||||
<div class="small-box bg-info shadow-sm" style="border-radius: 15px;">
|
||||
<div class="inner">
|
||||
<h3>Rp {{ number_format($forms->sum('total'), 0, ',', '.') }}</h3>
|
||||
<div class="fw-bold">Total Submission</div>
|
||||
</div>
|
||||
<div class="icon"><i class="fas fa-wallet"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-6">
|
||||
<div class="small-box bg-success shadow-sm" style="border-radius: 15px;">
|
||||
<div class="inner">
|
||||
<h3>Rp {{ number_format($forms->whereIn('status', ['Approved', 'Approved 1', 'Approved 2', 'Closed', 'Final Approved'])->sum('approved_total'), 0, ',', '.') }}</h3>
|
||||
<div class="fw-bold">Total Approved</div>
|
||||
</div>
|
||||
<div class="icon"><i class="fas fa-check-circle"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-6">
|
||||
<div class="small-box bg-warning shadow-sm" style="border-radius: 15px;">
|
||||
<div class="inner">
|
||||
<h3 class="text-white">Rp {{ number_format($forms->where('status', 'On Progress')->sum('total'), 0, ',', '.') }}</h3>
|
||||
<div class="text-white fw-bold">Total Pending</div>
|
||||
</div>
|
||||
<div class="icon"><i class="fas fa-hourglass-half"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-6">
|
||||
<div class="small-box bg-purple shadow-sm" style="border-radius: 15px; background-color: #6f42c1 !important;">
|
||||
<div class="inner">
|
||||
<h3 class="text-white">{{ !$availableBudget || $availableBudget == 0 ? '-' : 'Rp ' . number_format((float)$availableBudget, 0, ',', '.') }}</h3>
|
||||
<div class="text-white fw-bold">Budget Available</div>
|
||||
</div>
|
||||
<div class="icon"><i class="fas fa-money-bill"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
<div class="form-group mb-3">
|
||||
<label for="status">Status</label>
|
||||
<select name="status" id="status" class="form-control">
|
||||
<option value="">Semua Status</option>
|
||||
<option value="On Progress" {{ request()->status == 'On Progress' ? 'selected' : '' }}>On Progress</option>
|
||||
<option value="Approved 1" {{ request()->status == 'Approved 1' ? 'selected' : '' }}>Approved 1</option>
|
||||
<option value="Approved 2" {{ request()->status == 'Approved 2' ? 'selected' : '' }}>Approved 2</option>
|
||||
<option value="Closed" {{ request()->status == 'Closed' ? 'selected' : '' }}>Closed</option>
|
||||
<option value="Rejected" {{ request()->status == 'Rejected' ? 'selected' : '' }}>Rejected</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-primary">Filter</button>
|
||||
<a href="{{ route('reports.all') }}" class="btn btn-secondary">Reset</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{-- Filter Section - Sistem Periode Bulan Akuntansi --}}
|
||||
<div class="row mt-4">
|
||||
<div class="col-md-12">
|
||||
<div class="card shadow-sm border-0" style="border-radius: 15px;">
|
||||
<div class="card-body">
|
||||
<form action="{{ route('reports.all') }}" method="GET">
|
||||
<div class="row align-items-end">
|
||||
<div class="col-md-3">
|
||||
<div class="form-group mb-3">
|
||||
<label class="small fw-bold text-muted">Pilih Region</label>
|
||||
<select name="region" id="region" class="form-control select2">
|
||||
<option value="">Semua Region</option>
|
||||
@foreach ($regions as $region)
|
||||
<option value="{{ $region->code }}" {{ request()->region == $region->code ? 'selected' : '' }}>
|
||||
{{ $region->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group mb-3">
|
||||
<label class="small fw-bold text-muted">Pilih Cabang</label>
|
||||
<select name="cabang" id="cabang" class="form-control select2">
|
||||
<option value="">Semua Cabang</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="form-group mb-3">
|
||||
<label class="small fw-bold text-muted">Periode Bulan</label>
|
||||
<select name="month" id="month" class="form-control">
|
||||
<option value="">Pilih Bulan</option>
|
||||
@foreach(['january','february','march','april','may','june','july','august','september','october','november','december'] as $m)
|
||||
<option value="{{ $m }}" {{ (request()->month ?? strtolower(date('F'))) == $m ? 'selected' : '' }}>{{ ucfirst($m) }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="form-group mb-3">
|
||||
<label class="small fw-bold text-muted">Tahun</label>
|
||||
<select name="year" id="year" class="form-control">
|
||||
<option value="">Pilih Tahun</option>
|
||||
@for ($i = 2024; $i <= date('Y'); $i++)
|
||||
<option value="{{ $i }}" {{ (request()->year ?? date('Y')) == $i ? 'selected' : '' }}>{{ $i }}</option>
|
||||
@endfor
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="form-group mb-3">
|
||||
<label class="small fw-bold text-muted">Status</label>
|
||||
<select name="status" id="status" class="form-control">
|
||||
<option value="">Semua Status</option>
|
||||
@foreach(['On Progress', 'Approved 1', 'Approved 2', 'Closed', 'Rejected'] as $st)
|
||||
<option value="{{ $st }}" {{ request()->status == $st ? 'selected' : '' }}>{{ $st }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12 text-right mt-2">
|
||||
<button type="submit" class="btn btn-primary px-4 shadow-sm"><i class="fas fa-filter mr-1"></i> Filter</button>
|
||||
<a href="{{ route('reports.all') }}" class="btn btn-outline-secondary px-4 shadow-sm">Reset</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@php
|
||||
use App\Helpers\NextCloudHelper;
|
||||
@endphp
|
||||
@php use App\Helpers\NextCloudHelper; @endphp
|
||||
|
||||
<section class="content">
|
||||
<div class="container-fluid">
|
||||
<!-- All Forms Table -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card shadow-sm border-0" style="border-radius: 15px;">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title">All Forms</h4>
|
||||
<div class="data-tables">
|
||||
@include('backend.layouts.partials.messages')
|
||||
<div class="table-responsive">
|
||||
<table id="dataTable-table">
|
||||
<thead class="bg-light text-capitalize">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>No Expense</th>
|
||||
<th>Tipe</th>
|
||||
<th>Nama</th>
|
||||
<th>Region</th>
|
||||
<th>Cabang</th>
|
||||
<th>Total</th>
|
||||
<th>Total Approved</th>
|
||||
<th>Account Number</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($forms as $item)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $item->expense_number }}</td>
|
||||
<td>{{ $item->type }}</td>
|
||||
<td>{{ $item->user->name }}</td>
|
||||
<td>{{ $item->user->region->cabang->region->name }}</td>
|
||||
<td>{{ $item->user->cabang->cabang->name }}</td>
|
||||
<td>{{ number_format($item->total, 0, ',', '.') }}</td>
|
||||
<td>{{ number_format($item->approved_total, 0, ',', '.') }}</td>
|
||||
<td>{{ $item->account_number }}</td>
|
||||
<td>
|
||||
@if ($item->status == 'On Progress')
|
||||
<span class="badge badge-warning text-white">{{ $item->status }}</span>
|
||||
@elseif ($item->status == 'Approved 1' || $item->status == 'Approved 2' || $item->status == 'Final Approved')
|
||||
<span class="badge badge-success text-white">{{ $item->status }}</span>
|
||||
@else
|
||||
<span class="badge badge-danger text-white">{{ $item->status }}</span>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<h4 class="header-title mb-4">Database Konsolidasi (All Forms)</h4>
|
||||
<div class="table-responsive">
|
||||
@include('backend.layouts.partials.messages')
|
||||
<table id="dataTable-table" class="table table-hover w-100">
|
||||
<thead class="bg-light text-capitalize">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>No Expense</th>
|
||||
<th>Kategori</th>
|
||||
<th>Nama Pengaju</th>
|
||||
<th>Region / Cabang</th>
|
||||
<th>Tgl. Dibuat</th>
|
||||
<th>Nominal (Appr)</th>
|
||||
<th class="text-center">Bukti</th>
|
||||
<th>Status</th>
|
||||
<th>Detail Rejeksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($forms as $item)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td class="fw-bold text-primary">{{ $item->expense_number }}</td>
|
||||
<td>
|
||||
<span class="badge badge-light border text-capitalize px-2 py-1">
|
||||
{{ str_replace(['form_', '_'], ['', ' '], (string)$item->type) }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ $item->user->name ?? '-' }}</td>
|
||||
<td>
|
||||
<span class="d-block small fw-bold text-dark">{{ $item->user->region->cabang->region->name ?? '-' }}</span>
|
||||
<span class="text-muted small">{{ $item->user->cabang->cabang->name ?? '-' }}</span>
|
||||
</td>
|
||||
<td>
|
||||
@php $createdAt = \Carbon\Carbon::parse($item->created_at); @endphp
|
||||
<div class="fw-bold small">{{ $createdAt->locale('id')->translatedFormat('d F Y') }}</div>
|
||||
<small class="text-muted">{{ $createdAt->format('H:i') }} WIB</small>
|
||||
</td>
|
||||
<td class="text-success fw-bold">
|
||||
{{ $item->approved_total ? 'Rp ' . number_format($item->approved_total, 0, ',', '.') : '-' }}
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
@php
|
||||
$fileData = [];
|
||||
$imgExts = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp'];
|
||||
if (!empty($item->main_proof)) {
|
||||
$ext = strtolower(pathinfo($item->main_proof, PATHINFO_EXTENSION));
|
||||
$fileData[] = [
|
||||
'url' => NextCloudHelper::getFileUrl($item->main_proof),
|
||||
'is_img' => in_array($ext, $imgExts)
|
||||
];
|
||||
}
|
||||
if(isset($item->extra_attachments)) {
|
||||
foreach ($item->extra_attachments as $att) {
|
||||
$ext = strtolower(pathinfo($att->file_path, PATHINFO_EXTENSION));
|
||||
$fileData[] = [
|
||||
'url' => NextCloudHelper::getFileUrl($att->file_path),
|
||||
'is_img' => in_array($ext, $imgExts)
|
||||
];
|
||||
}
|
||||
}
|
||||
$uniqueFiles = collect($fileData)->unique('url')->values()->all();
|
||||
@endphp
|
||||
|
||||
@if (count($uniqueFiles) > 0)
|
||||
<button type="button" class="btn btn-sm btn-info rounded-pill px-3 shadow-sm btn-preview-bukti"
|
||||
data-expense="{{ $item->expense_number }}"
|
||||
data-files='@json($uniqueFiles)'>
|
||||
<i class="fas fa-eye"></i> {{ count($uniqueFiles) }}
|
||||
</button>
|
||||
@else
|
||||
<span class="text-muted small">-</span>
|
||||
@endif
|
||||
</td>
|
||||
|
||||
<td>
|
||||
@php
|
||||
$badgeClass = match($item->status) {
|
||||
'On Progress' => 'badge-warning text-white',
|
||||
'Approved 1', 'Approved 2', 'Closed', 'Final Approved' => 'badge-success text-white',
|
||||
'Rejected' => 'badge-danger text-white',
|
||||
default => 'badge-secondary'
|
||||
};
|
||||
@endphp
|
||||
<span class="badge {{ $badgeClass }} px-3 py-2">{{ $item->status }}</span>
|
||||
|
||||
{{-- Tgl Final Approved --}}
|
||||
@if(isset($item->report_date) && in_array($item->status, ['Approved 2', 'Closed', 'Final Approved']))
|
||||
<div class="mt-2" style="line-height: 1.2;">
|
||||
<small class="text-success fw-bold d-block" style="font-size: 10px;">
|
||||
<i class="fas fa-check-double mr-1"></i> Final Approved:
|
||||
</small>
|
||||
<small class="text-muted d-block" style="font-size: 10px;">
|
||||
{{ \Carbon\Carbon::parse($item->report_date)->translatedFormat('d M Y') }}
|
||||
</small>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- Penanda Tgl Waktu Rejeksi --}}
|
||||
@if($item->status == 'Rejected' && isset($item->rejected_at))
|
||||
<div class="mt-2" style="line-height: 1.2;">
|
||||
<small class="text-danger fw-bold d-block" style="font-size: 10px;">
|
||||
<i class="fas fa-times-circle mr-1"></i> Rejected At:
|
||||
</small>
|
||||
<small class="text-muted d-block" style="font-size: 10px;">
|
||||
{{ \Carbon\Carbon::parse($item->rejected_at)->translatedFormat('d M Y H:i') }} WIB
|
||||
</small>
|
||||
</div>
|
||||
@endif
|
||||
</td>
|
||||
|
||||
{{-- Kolom Detail Rejeksi Sinkron --}}
|
||||
<td>
|
||||
@if($item->status == 'Rejected')
|
||||
<div class="mt-1 p-2 bg-light border border-danger rounded" style="line-height: 1.3; min-width: 160px; border-style: dashed !important;">
|
||||
<div class="mb-1">
|
||||
<small class="fw-bold text-dark" style="font-size: 10px;">Oleh:</small>
|
||||
<small class="text-primary font-weight-bold" style="font-size: 10px;">{{ $item->rejector->name ?? $item->rejected_by ?? 'System' }}</small>
|
||||
</div>
|
||||
<div>
|
||||
<small class="fw-bold text-dark" style="font-size: 10px;">Alasan:</small>
|
||||
<small class="text-danger font-italic d-block mt-1" style="font-size: 10px; line-height: 1.1;">"{{ $item->remarks ?? '-' }}"</small>
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
<span class="text-muted small">-</span>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{{-- MODAL PREVIEW --}}
|
||||
<div class="modal fade" id="modalPreviewBukti" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content" style="border-radius: 15px; border: none; overflow: hidden;">
|
||||
<div class="modal-header bg-primary text-white border-0">
|
||||
<h5 class="modal-title fw-bold"><i class="fas fa-images mr-2"></i>Lampiran Bukti <span id="textExpenseNum"></span></h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">×</button>
|
||||
</div>
|
||||
<div class="modal-body bg-light" id="containerPreview" style="max-height: 70vh; overflow-y: auto; padding: 25px;"></div>
|
||||
<div class="modal-footer bg-light border-0">
|
||||
<button type="button" class="btn btn-secondary rounded-pill px-4" data-dismiss="modal">Tutup</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- MODAL ZOOM --}}
|
||||
<div class="modal fade" id="modalImageFull" tabindex="-2" role="dialog" aria-hidden="true" style="background: rgba(0,0,0,0.85); z-index: 1060;">
|
||||
<div class="modal-dialog modal-dialog-centered modal-xl">
|
||||
<div class="modal-content" style="background: transparent; border: none;">
|
||||
<div class="modal-header border-0 p-0">
|
||||
<button type="button" class="close text-white" data-dismiss="modal" style="font-size: 2.5rem; position: absolute; right: 15px; top: 10px; z-index: 999;">×</button>
|
||||
</div>
|
||||
<div class="modal-body p-0 text-center">
|
||||
<img src="" id="imgFullDisplay" style="max-width: 100%; max-height: 90vh; border-radius: 8px;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
<script>
|
||||
if ($('#dataTable-table').length) {
|
||||
$('#dataTable-table').DataTable({
|
||||
responsive: false,
|
||||
pagging: true,
|
||||
dom: 'Blfrtip',
|
||||
lengthMenu: [ [10, 25, 50, -1], [10, 25, 50, "All"] ], // Control the entries dropdown
|
||||
buttons: [
|
||||
{
|
||||
extend: 'excel',
|
||||
text: 'Excel'
|
||||
},
|
||||
{
|
||||
extend: 'pdf',
|
||||
text: 'PDF',
|
||||
orientation: 'landscape',
|
||||
pageSize: 'A4',
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'print',
|
||||
text: 'Print',
|
||||
orientation: 'landscape',
|
||||
exportOptions: {
|
||||
columns: ':visible'
|
||||
}
|
||||
},
|
||||
'colvis'
|
||||
]
|
||||
});
|
||||
}
|
||||
</script>
|
||||
$(document).ready(function() {
|
||||
if ($('#dataTable-table').length) {
|
||||
$('#dataTable-table').DataTable({
|
||||
responsive: false,
|
||||
dom: 'Blfrtip',
|
||||
deferRender: true, // Optimasi performa loading render DOM fisik tabel
|
||||
lengthMenu: [ [10, 25, 50, -1], [10, 25, 50, "All"] ],
|
||||
buttons: [
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
text: '<i class="fas fa-file-excel mr-1"></i> Excel',
|
||||
className: 'btn-success',
|
||||
exportOptions: {
|
||||
columns: [0, 1, 2, 3, 4, 5, 6, 8, 9],
|
||||
format: {
|
||||
body: function (data, row, column, node) {
|
||||
let text = node.textContent || node.innerText || "";
|
||||
text = text.replace(/\s+/g, ' ').trim();
|
||||
|
||||
if (column === 6) {
|
||||
return text.replace(/Rp\s?|[.]/g, '');
|
||||
}
|
||||
return text;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'pdfHtml5',
|
||||
text: '<i class="fas fa-file-pdf mr-1"></i> PDF',
|
||||
className: 'btn-danger',
|
||||
orientation: 'landscape',
|
||||
pageSize: 'A4',
|
||||
exportOptions: { columns: [0, 1, 2, 3, 4, 5, 6, 8, 9] },
|
||||
customize: function(doc) {
|
||||
doc.defaultStyle.fontSize = 7;
|
||||
doc.styles.tableHeader.fontSize = 8;
|
||||
}
|
||||
},
|
||||
'colvis'
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
<script>
|
||||
document.getElementById('region').addEventListener('change', function () {
|
||||
const regionCode = this.value;
|
||||
const cabangSelect = document.getElementById('cabang');
|
||||
$(document).on('click', '.btn-preview-bukti', function(e) {
|
||||
e.preventDefault();
|
||||
const expenseNum = $(this).data('expense');
|
||||
const files = $(this).data('files');
|
||||
let html = '<div class="row">';
|
||||
|
||||
// Clear existing options
|
||||
cabangSelect.innerHTML = '<option value="">Semua Cabang</option>';
|
||||
$('#textExpenseNum').text('#' + expenseNum);
|
||||
$('#containerPreview').html('<div class="text-center py-5"><i class="fas fa-spinner fa-spin fa-3x text-primary"></i></div>');
|
||||
|
||||
if (regionCode) {
|
||||
fetch(`/api/cabang-by-region/${regionCode}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
data.forEach(cabang => {
|
||||
const option = document.createElement('option');
|
||||
option.value = cabang.code;
|
||||
option.textContent = cabang.name;
|
||||
cabangSelect.appendChild(option);
|
||||
});
|
||||
})
|
||||
.catch(error => console.error('Error fetching cabang data:', error));
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
if(files && files.length > 0) {
|
||||
files.forEach((file) => {
|
||||
html += `
|
||||
<div class="col-md-6 mb-4">
|
||||
<div class="card h-100 border-0 shadow-sm rounded-lg overflow-hidden">
|
||||
<div class="card-body p-2 text-center bg-white">
|
||||
<div class="mb-3" style="height: 220px; display: flex; align-items: center; justify-content: center; background: #f8f9fa; border-radius: 8px; overflow: hidden; border: 1px solid #eee;">
|
||||
${file.is_img
|
||||
? `<img src="${file.url}" class="img-fluid" style="max-height: 100%; object-fit: contain; cursor: zoom-in;" onclick="openFullImage('${file.url}')">`
|
||||
: `<div class="text-center"><i class="fas fa-file-pdf fa-4x text-danger"></i><p class="small text-muted mt-2 fw-bold">Dokumen Digital</p></div>`
|
||||
}
|
||||
</div>
|
||||
<div class="btn-group w-100">
|
||||
${file.is_img
|
||||
? `<button type="button" onclick="openFullImage('${file.url}')" class="btn btn-outline-primary btn-sm px-3"><i class="fas fa-eye"></i> Preview</button>`
|
||||
: `<a href="${file.url}" target="_blank" class="btn btn-outline-primary btn-sm px-3"><i class="fas fa-external-link-alt"></i> Open PDF</a>`
|
||||
}
|
||||
<a href="${file.url}" download class="btn btn-primary btn-sm px-3"><i class="fas fa-download"></i> Download</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
});
|
||||
}
|
||||
$('#containerPreview').html(html + '</div>');
|
||||
$('#modalPreviewBukti').modal('show');
|
||||
});
|
||||
|
||||
function loadCabang(regionCode, selectedCabang = null) {
|
||||
const cabangSelect = $('#cabang');
|
||||
if (regionCode) {
|
||||
fetch(`/api/cabang-by-region/${regionCode}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
cabangSelect.html('<option value="">Semua Cabang</option>');
|
||||
data.forEach(cabang => {
|
||||
const isSelected = (selectedCabang && cabang.code === selectedCabang) ? 'selected' : '';
|
||||
cabangSelect.append(`<option value="${cabang.code}" ${isSelected}>${cabang.name}</option>`);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$('#region').on('change', function() { loadCabang(this.value); });
|
||||
const currentRegion = '{{ request()->region }}';
|
||||
const currentCabang = '{{ request()->cabang }}';
|
||||
if (currentRegion) { loadCabang(currentRegion, currentCabang); }
|
||||
});
|
||||
|
||||
function openFullImage(url) {
|
||||
$('#imgFullDisplay').attr('src', url);
|
||||
$('#modalImageFull').modal('show');
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user