diff --git a/Entities/Branch.php b/Entities/Branch.php index a40201d..fa5aed1 100644 --- a/Entities/Branch.php +++ b/Entities/Branch.php @@ -26,4 +26,9 @@ return $this->hasMany(Rekening::class); } + public function subrogasi_jamkrindo() + { + return $this->hasMany(SubrogasiJamkrindo::class, 'kode_cabang', 'kode'); + } + } diff --git a/Entities/Debitur.php b/Entities/Debitur.php index 496ef9a..0db0f2f 100644 --- a/Entities/Debitur.php +++ b/Entities/Debitur.php @@ -28,4 +28,9 @@ return $this->hasMany(Rekening::class); } + public function subrogasi_jamkrindo() + { + return $this->hasMany(SubrogasiJamkrindo::class, 'kode_debitur', 'kode'); + } + } diff --git a/Entities/DetailSubrogasiJamkrindo.php b/Entities/DetailSubrogasiJamkrindo.php index 2245527..11d8d0c 100644 --- a/Entities/DetailSubrogasiJamkrindo.php +++ b/Entities/DetailSubrogasiJamkrindo.php @@ -19,4 +19,9 @@ 'authorized_status', 'authorized_by', ]; + + public function subrogasi_jamkrindo() + { + return $this->belongsTo('Modules\Writeoff\Entities\SubrogasiJamkrindo', 'nomor_pinjaman', 'nomor_pinjaman'); + } } diff --git a/Entities/SubrogasiJamkrindo.php b/Entities/SubrogasiJamkrindo.php index 1ca3c67..5ad4f14 100644 --- a/Entities/SubrogasiJamkrindo.php +++ b/Entities/SubrogasiJamkrindo.php @@ -28,4 +28,14 @@ 'authorized_status', 'authorized_by', ]; + + public function debitur() + { + return $this->belongsTo('Modules\Writeoff\Entities\Debitur', 'kode_debitur', 'kode'); + } + + public function branch() + { + return $this->belongsTo('Modules\Writeoff\Entities\Branch', 'kode_cabang', 'kode'); + } } diff --git a/Http/Controllers/ReportController.php b/Http/Controllers/ReportController.php index 4904d18..6d99ed3 100644 --- a/Http/Controllers/ReportController.php +++ b/Http/Controllers/ReportController.php @@ -5,6 +5,8 @@ use App\Http\Controllers\Controller; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; + use Modules\Writeoff\Entities\Branch; + use Modules\Writeoff\Entities\DetailSubrogasiJamkrindo; use Modules\Writeoff\Entities\KlaimJamkrindo; use Yajra\DataTables\Facades\DataTables; use Yajra\DataTables\Html\Builder; @@ -34,12 +36,12 @@ public function subrogasi() { - return view('writeoff::report.subrogasi'); + $branches = Branch::all(); + return view('writeoff::report.subrogasi', compact('branches')); } public function laporan_subrogasi(Builder $builder, Request $request) { - if ($request->jenis_laporan == 'C1') { if (request()->ajax()) { @@ -80,6 +82,66 @@ ->orderBy(1); return view('writeoff::report.laporan_klaim_jamkrindo', compact('dataTable')); + } else if ($request->jenis_laporan == 'C2') { + $start_date = request()->get('start_date'); + $month = date('m', strtotime($start_date)); + $year = date('Y', strtotime($start_date)); + + if (request()->ajax()) { + if (request()->get('kode_cabang') == 'all') { + $data = DetailSubrogasiJamkrindo::with([ + 'subrogasi_jamkrindo', + 'subrogasi_jamkrindo.branch', + 'subrogasi_jamkrindo.debitur' + ]) + ->selectRaw('nomor_pinjaman, SUM(pembayaran_debitur) AS pembayaran_debitur, SUM(subrogasi_jamkrindo) AS subrogasi_jamkrindo, SUM(pendapatan_bank) AS pendapatan_bank') + ->whereMonth('tanggal_pembayaran', request()->get('bulan')) + ->whereYear('tanggal_pembayaran', request()->get('tahun')) + ->groupBy('nomor_pinjaman') + ->get(); + } else { + $data = DetailSubrogasiJamkrindo::with([ + 'subrogasi_jamkrindo', + 'subrogasi_jamkrindo.branch', + 'subrogasi_jamkrindo.debitur' + ]) + ->selectRaw('nomor_pinjaman, SUM(pembayaran_debitur) AS pembayaran_debitur, SUM(subrogasi_jamkrindo) AS subrogasi_jamkrindo, SUM(pendapatan_bank) AS pendapatan_bank') + ->whereRelation('subrogasi_jamkrindo', 'kode_cabang', request()->get('kode_cabang')) + ->whereMonth('tanggal_pembayaran', request()->get('bulan')) + ->whereYear('tanggal_pembayaran', request()->get('tahun')) + ->groupBy('nomor_pinjaman') + ->get(); + } + echo json_encode($data);exit; + return DataTables::of($data)->editColumn('branch', function ($q) { + return $q->subrogasi_jamkrindo->branch->name; + })->addIndexColumn()->toJson(); + } + + $start_date = request()->get('start_date'); + $month = date('m', strtotime($start_date)); + $year = date('Y', strtotime($start_date)); + + $req = ['kode_cabang' => request()->get('kode_cabang'), 'bulan' => $month, 'tahun' => $year]; + + $dataTable = $builder->columns([ + Column::make('DT_RowIndex')->title('No')->orderable(false)->searchable(false), + Column::make('branch')->title('Cabang'), + ]) + ->parameters([ + 'scrollX' => false, + 'drawCallback' => 'function() { KTMenu.createInstances(); }', + ]) + ->addTableClass('align-middle table-row-dashed fs-6 gy-5') + ->setTableId('laporan-table') + ->minifiedAjax(request()->url(), null, $req) + ->stateSave(false) + ->responsive() + ->autoWidth(true) + ->orderBy(1); + + return view('writeoff::report.laporan_klaim_jamkrindo', compact('dataTable')); + } } } diff --git a/Resources/views/report/subrogasi.blade.php b/Resources/views/report/subrogasi.blade.php index 7f7172c..0254f39 100644 --- a/Resources/views/report/subrogasi.blade.php +++ b/Resources/views/report/subrogasi.blade.php @@ -20,41 +20,75 @@ - - @error('jenis_fasilitas') + @error('jenis_laporan') {{ $message }} @enderror -
- -
- - - - - - @error('debitur') - {{ $message }} @enderror +
+
+ +
+ + + + + + @error('debitur') + {{ $message }} @enderror +
+
+ +
+ +
+ + + + + + @error('debitur') + {{ $message }} @enderror +
+
+
+ +
+ + + + + + @error('kode_cabang') + {{ $message }} @enderror +
+
-
- -
- - - - - - @error('debitur') - {{ $message }} @enderror +
+ +
+ + + + + + @error('debitur') + {{ $message }} @enderror +
@@ -69,4 +103,18 @@
+ + @push('scripts') + + @endpush