Compare commits
133 Commits
23aa158cc2
...
lpj-db-mig
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45cebcf325 | ||
|
|
a442f879b7 | ||
|
|
796cb89d21 | ||
|
|
fb22d370b5 | ||
|
|
478c0c8079 | ||
|
|
73d0d238c0 | ||
|
|
d6d0ed28b9 | ||
|
|
ee828455a9 | ||
|
|
a6481dd482 | ||
|
|
cbf54353f4 | ||
|
|
a701e78982 | ||
|
|
6305f93f0f | ||
|
|
6ed4e8ba41 | ||
|
|
6b0022deed | ||
|
|
ae5a9ce5b7 | ||
|
|
c8b5fcc9d1 | ||
|
|
2937add646 | ||
|
|
b83920d8aa | ||
|
|
c6596cdea0 | ||
|
|
c981237663 | ||
|
|
291811b74a | ||
|
|
2d8bddff42 | ||
|
|
be41a815f7 | ||
|
|
c459d1be70 | ||
|
|
142257d18d | ||
|
|
32eab5f089 | ||
|
|
84933206ee | ||
|
|
1338085481 | ||
|
|
3f57d361f9 | ||
|
|
027c698a11 | ||
|
|
05f87f4767 | ||
|
|
6bb13dbcaf | ||
|
|
02d2e42621 | ||
|
|
fd7f5fb9c2 | ||
|
|
dbb930557b | ||
|
|
7aeab00535 | ||
|
|
22e9e6b6a9 | ||
|
|
e79b8c6449 | ||
|
|
e27a34d52f | ||
|
|
e63f9e7359 | ||
|
|
d0f3ffa93a | ||
|
|
37874aff3a | ||
|
|
44ff9d4ac6 | ||
|
|
5e8f979d05 | ||
|
|
ae15e1983f | ||
|
|
28513100f4 | ||
|
|
e72e82ea55 | ||
|
|
47bf7ab59b | ||
|
|
4ee42f38b9 | ||
|
|
60dd90a9ed | ||
|
|
3f979aef05 | ||
|
|
db3ffacebe | ||
|
|
daed7c5e48 | ||
|
|
4bb808b341 | ||
|
|
4405760df4 | ||
|
|
7ddcc14167 | ||
|
|
f69128e18e | ||
|
|
39424b5df5 | ||
|
|
ec22e5f632 | ||
|
|
887478c751 | ||
|
|
2708dead53 | ||
|
|
644f1da871 | ||
|
|
e32c73cdb2 | ||
|
|
40c3d84efc | ||
|
|
760a0cb85d | ||
|
|
0f8774a37c | ||
|
|
fa659ff115 | ||
|
|
fdfe591c39 | ||
|
|
7aae88ce85 | ||
|
|
8fbc02bfff | ||
|
|
0e4c8760f8 | ||
|
|
320dba9d9c | ||
|
|
6ddf78d2b0 | ||
|
|
79e66226b0 | ||
|
|
500118d787 | ||
|
|
ade4ffcad4 | ||
|
|
08b71604ec | ||
|
|
f81cdbb50d | ||
|
|
e731e9cea0 | ||
|
|
980b4e8e9f | ||
|
|
8158f3058f | ||
|
|
eea49b7943 | ||
|
|
d1ce5f2d55 | ||
|
|
5e8067ad72 | ||
|
|
e85ed55598 | ||
|
|
2cb68b6d94 | ||
|
|
7f6c702683 | ||
|
|
e6d05cc4aa | ||
|
|
4ebc700283 | ||
|
|
d2b4e380b5 | ||
|
|
3853b5d6eb | ||
|
|
bf7e6275e3 | ||
|
|
121d099402 | ||
|
|
54668820b1 | ||
|
|
d63108dea1 | ||
|
|
5cdc4b08b3 | ||
|
|
dd11f467fa | ||
|
|
49b13e6689 | ||
|
|
b9d0d9f03b | ||
|
|
0972f3fcff | ||
|
|
d251c7655d | ||
|
|
afbdad43db | ||
|
|
886a382f57 | ||
|
|
c1c37f5716 | ||
|
|
89957190c7 | ||
|
|
0167919542 | ||
|
|
b3ccf3bb8f | ||
|
|
d434680f0e | ||
|
|
53c86a79d0 | ||
|
|
f7b851d295 | ||
|
|
baf0000a3f | ||
|
|
5b50a36a60 | ||
|
|
45f911cef9 | ||
|
|
aa3efd6015 | ||
|
|
fd21a5b86f | ||
|
|
d1744b07ec | ||
|
|
10aa59d65d | ||
|
|
2506b6115c | ||
|
|
acfc282e25 | ||
|
|
ffb24b8cd6 | ||
|
|
d4c70fba00 | ||
|
|
7b14c16af1 | ||
|
|
fc466f6087 | ||
|
|
1e8ce1d6d9 | ||
|
|
589e06dc00 | ||
|
|
7936c3e275 | ||
|
|
5e946cdfa7 | ||
|
|
b53b94e27d | ||
|
|
6f8db74159 | ||
|
|
43b086f3ea | ||
|
|
e28da750c7 | ||
|
|
55036bf581 | ||
|
|
27633cef7a |
@@ -0,0 +1,305 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
use Maatwebsite\Excel\Concerns\WithCustomStartCell;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\Branch;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class LaporanHasilPenilaianJaminanInternalExternalExport implements FromCollection, WithHeadings, WithMapping, WithTitle, WithCustomStartCell, WithEvents
|
||||
{
|
||||
protected $request;
|
||||
|
||||
public function __construct($request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$query = Permohonan::query();
|
||||
$query = $query->where('status', 'done');
|
||||
|
||||
// Apply date range filter if provided
|
||||
if ($this->request->has('start_date') || $this->request->has('end_date')) {
|
||||
$startDate = $this->request->start_date ?? '1900-01-01';
|
||||
$endDate = $this->request->end_date ?? now()->toDateString();
|
||||
|
||||
$query->where(function ($q) use ($startDate, $endDate) {
|
||||
|
||||
$q->whereHas('penilaian', function ($q2) use ($startDate, $endDate) {
|
||||
$q2->whereBetween('tanggal_kunjungan', [$startDate, $endDate]);
|
||||
});
|
||||
|
||||
// OR check if has penawaran with date in range
|
||||
$q->orWhereHas('penawaran', function ($q3) use ($startDate, $endDate) {
|
||||
$q3->whereBetween('tanggal_penilaian_sebelumnya', [$startDate, $endDate]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Apply branch filter if provided
|
||||
if ($this->request->has('branch_id') && !empty($this->request->branch_id)) {
|
||||
$query->where('branch_id', $this->request->branch_id);
|
||||
}
|
||||
|
||||
if ($this->request->has('penilai_id') && !empty($this->request->penilai_id)) {
|
||||
$request = $this->request; // Store in a local variable
|
||||
$query->whereHas('penilaian._user_penilai.userPenilaiTeam', function ($q) use ($request) {
|
||||
$q->where('user_id', $request->penilai_id);
|
||||
});
|
||||
}
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($this->request->has('search') && !empty($this->request->search)) {
|
||||
$search = $this->request->search;
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('debiture', DB::raw('LOWER(name)'), 'LIKE', '%' . strtolower($search) . '%');
|
||||
|
||||
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('jenisFasilitasKredit', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
||||
});
|
||||
}
|
||||
|
||||
// Default ordering
|
||||
$query->orderBy('nomor_registrasi', 'asc');
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
protected $rowNumber = 0;
|
||||
|
||||
public function map($permohonan): array
|
||||
{
|
||||
$this->rowNumber++;
|
||||
$luas_tanah = 0;
|
||||
$luas_bangunan = 0;
|
||||
$nilai_tanah = 0;
|
||||
$nilai_bangunan = 0;
|
||||
$npw = 0;
|
||||
$nilai_liquidasi = 0;
|
||||
|
||||
if (isset($permohonan->penilai->lpj)) {
|
||||
$lpj = json_decode($permohonan->penilai->lpj, true);
|
||||
$npw = str_replace('.', '', $lpj['total_nilai_pasar_wajar'] ?? 0);
|
||||
|
||||
$luas_tanah = $lpj['luas_tanah'] ?? 0;
|
||||
$luas_bangunan = $lpj['luas_bangunan'] ?? 0;
|
||||
$nilai_tanah = str_replace('.', '', $lpj['nilai_tanah_2'] ?? 0);
|
||||
$nilai_bangunan = str_replace('.', '', $lpj['nilai_bangunan_2'] ?? 0);
|
||||
$nilai_liquidasi = str_replace('.', '', $lpj['likuidasi_nilai_2'] ?? 0);
|
||||
}
|
||||
|
||||
return [
|
||||
$this->rowNumber,
|
||||
$permohonan->nomor_registrasi,
|
||||
$permohonan->tanggal_permohonan ?? '',
|
||||
$permohonan->debiture->branch->name ?? '',
|
||||
$permohonan->user->name ?? $permohonan->mig_nama_ao ?? '',
|
||||
$permohonan->debiture->cif ?? '',
|
||||
$permohonan->debiture->name ?? '',
|
||||
$permohonan->tujuanPenilaian->name,
|
||||
$permohonan->jenisPenilaian->name ?? '',
|
||||
$permohonan->jenisFasilitasKredit->name,
|
||||
$permohonan->documents->pluck('jenisJaminan.name')->unique()->implode(', '),
|
||||
$permohonan->documents->map(function ($document) {
|
||||
return formatAlamat($document);
|
||||
})->unique()->implode(', '),
|
||||
$permohonan->documents->flatMap(function ($document) {
|
||||
return $document->detail->map(function ($detail) {
|
||||
return (!empty($detail->dokumen_nomor) && is_array($detail->dokumen_nomor))
|
||||
? ($detail->jenisLegalitasJaminan->name ?? '') . "\n" . implode(', ', $detail->dokumen_nomor)
|
||||
: null;
|
||||
});
|
||||
})->filter()->unique()->implode(', '),
|
||||
$permohonan->documents->pluck('pemilik.name')->unique()->implode(', '),
|
||||
$luas_tanah . ' m²',
|
||||
formatRupiah($nilai_tanah, 2),
|
||||
$luas_bangunan . ' m²',
|
||||
formatRupiah($nilai_bangunan, 2),
|
||||
formatRupiah($permohonan->nilai_njop ?? 0, 2),
|
||||
formatRupiah($npw, 2),
|
||||
formatRupiah($nilai_liquidasi, 2),
|
||||
$permohonan->documents->map(function ($document) {
|
||||
return formatTanggalIndonesia($document->created_at);
|
||||
})->first(),
|
||||
'', // tanggal_spk
|
||||
'', // nomor_spk
|
||||
'', // tanggal_rencana_kunjungan
|
||||
$permohonan->penilaian && $permohonan->penilaian->tanggal_kunjungan
|
||||
? formatTanggalIndonesia($permohonan->penilaian->tanggal_kunjungan)
|
||||
: '',
|
||||
'', // tanggal_delivered
|
||||
'', // jangka_waktu_sla
|
||||
($permohonan->approval_dd_at || $permohonan->approval_eo_at) ?
|
||||
formatTanggalIndonesia($permohonan->approval_dd_at ?? $permohonan->approval_eo_at) : '',
|
||||
$permohonan->penilaian && $permohonan->penilaian->tanggal_kunjungan
|
||||
? formatTanggalIndonesia($permohonan->penilaian->tanggal_kunjungan)
|
||||
: '',
|
||||
$permohonan->penilaian->_user_penilai->userPenilaiTeam->name ?? '',
|
||||
$permohonan->approveSo->name ?? '',
|
||||
'', // saran
|
||||
'' // catatan
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'No',
|
||||
'Nomor Registrasi',
|
||||
'Tanggal Permohonan',
|
||||
'Cabang',
|
||||
'Pemohon',
|
||||
'CIF',
|
||||
'Nama Debitur',
|
||||
'Jenis Penilaian',
|
||||
'Tujuan Penilaian',
|
||||
'Jenis Fasilitas Kredit',
|
||||
'Jenis Agunan',
|
||||
'Alamat Agunan',
|
||||
'Bukti Kepemilikan',
|
||||
'Nama Pemilik',
|
||||
'Luas Tanah',
|
||||
'Nilai Tanah',
|
||||
'Luas Bangunan',
|
||||
'Nilai Bangunan',
|
||||
'Nilai NJOP',
|
||||
'Nilai Pasar Wajar',
|
||||
'Nilai Likuidasi',
|
||||
'Tanggal Dokumen Diterima',
|
||||
'Tanggal SPK',
|
||||
'Nomor SPK',
|
||||
'Tanggal Rencana Kunjungan',
|
||||
'Tanggal Kunjungan',
|
||||
'Tanggal Delivered',
|
||||
'Jangka Waktu SLA',
|
||||
'Tanggal Laporan',
|
||||
'Tanggal Review',
|
||||
'Nama Penilai',
|
||||
'Nama Team Leader',
|
||||
'Saran',
|
||||
'Catatan'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return 'Laporan Hasil Penilaian Jaminan Internal & External';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function startCell(): string
|
||||
{
|
||||
return 'A7';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
// Get the sheet
|
||||
$sheet = $event->sheet->getDelegate();
|
||||
|
||||
// Set the title
|
||||
$sheet->setCellValue('A1', 'LAPORAN PENILAIAN JAMINAN');
|
||||
$sheet->getStyle('A1')->getFont()->setBold(true)->setSize(16);
|
||||
|
||||
// Merge cells for title
|
||||
$sheet->mergeCells('A1:AH1');
|
||||
$sheet->getStyle('A1')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
|
||||
// Set the branch information if filtered
|
||||
$branchInfo = '';
|
||||
if ($this->request->has('branch_id') && !empty($this->request->branch_id)) {
|
||||
$branch = Branch::find($this->request->branch_id);
|
||||
if ($branch) {
|
||||
$branchInfo = 'Cabang: ' . $branch->name;
|
||||
$sheet->setCellValue('A2', $branchInfo);
|
||||
$sheet->mergeCells('A2:AH2');
|
||||
$sheet->getStyle('A2')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
$sheet->getStyle('A2')->getFont()->setBold(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the period
|
||||
$startDate = $this->request->start_date ?? '';
|
||||
$endDate = $this->request->end_date ?? '';
|
||||
|
||||
$rowIndex = $branchInfo ? 3 : 2;
|
||||
|
||||
if ($startDate && $endDate) {
|
||||
$startDateFormatted = Carbon::parse($startDate)->format('d F Y');
|
||||
$endDateFormatted = Carbon::parse($endDate)->format('d F Y');
|
||||
$sheet->setCellValue('A' . $rowIndex, 'Periode: ' . $startDateFormatted . ' - ' . $endDateFormatted);
|
||||
} else {
|
||||
$sheet->setCellValue('A' . $rowIndex, 'Periode: Semua Data');
|
||||
}
|
||||
$sheet->mergeCells('A' . $rowIndex . ':AH' . $rowIndex);
|
||||
$sheet->getStyle('A' . $rowIndex)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
|
||||
// Set the date of export
|
||||
$rowIndex++;
|
||||
$sheet->setCellValue('A' . $rowIndex, 'Tanggal Export: ' . Carbon::now()->format('d F Y H:i:s'));
|
||||
|
||||
// Set the user who exported
|
||||
$rowIndex++;
|
||||
$userName = Auth::user() ? Auth::user()->name : 'System';
|
||||
$sheet->setCellValue('A' . $rowIndex, 'Diexport oleh: ' . $userName);
|
||||
|
||||
// Add a blank line
|
||||
$rowIndex++;
|
||||
$sheet->setCellValue('A' . $rowIndex, '');
|
||||
|
||||
// Style the header row
|
||||
$headerRange = 'A7:' . $sheet->getHighestColumn() . '7';
|
||||
$sheet->getStyle($headerRange)->getFont()->setBold(true);
|
||||
$sheet->getStyle($headerRange)->getFill()
|
||||
->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
|
||||
->getStartColor()->setARGB('FFCCCCCC');
|
||||
|
||||
// Auto-size columns - fixed to handle columns beyond Z
|
||||
$highestColumn = $sheet->getHighestColumn();
|
||||
$highestColumnIndex = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($highestColumn);
|
||||
|
||||
for ($i = 1; $i <= $highestColumnIndex; $i++) {
|
||||
$currentColumn = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($i);
|
||||
$sheet->getColumnDimension($currentColumn)->setAutoSize(true);
|
||||
}
|
||||
|
||||
// Add borders to all cells with data
|
||||
$dataRange = 'A7:' . $sheet->getHighestColumn() . $sheet->getHighestRow();
|
||||
$sheet->getStyle($dataRange)->getBorders()->getAllBorders()->setBorderStyle(\PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN);
|
||||
|
||||
// Center align the header row
|
||||
$sheet->getStyle($headerRange)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
|
||||
// Set text wrap for header cells
|
||||
$sheet->getStyle($headerRange)->getAlignment()->setWrapText(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
namespace Modules\Lpj\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
@@ -11,167 +12,299 @@ use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use Modules\Lpj\Models\Debiture;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Helpers\Lpj;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class LaporanPenilaiJaminanExport implements FromQuery, WithHeadings, WithMapping, ShouldAutoSize
|
||||
class LaporanPenilaiJaminanExport implements FromCollection, WithHeadings, WithMapping, ShouldAutoSize
|
||||
{
|
||||
protected $tanggalAwal;
|
||||
protected $tanggalAkhir;
|
||||
protected $status;
|
||||
protected $selectedIds;
|
||||
|
||||
public function __construct($tanggalAwal = null, $tanggalAkhir = null, $status = null, $selectedIds = null)
|
||||
protected $request;
|
||||
|
||||
public function __construct($request)
|
||||
{
|
||||
$this->tanggalAwal = $tanggalAwal;
|
||||
$this->tanggalAkhir = $tanggalAkhir;
|
||||
$this->status = $status;
|
||||
$this->selectedIds = $selectedIds;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
|
||||
public function query()
|
||||
public function collection()
|
||||
{
|
||||
$query = Permohonan::query()
|
||||
->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian', 'dokumenjaminan.jenisJaminan','nilaiPlafond', 'penilai', 'inspeksi']);
|
||||
$query = Permohonan::query();
|
||||
$query = $query->where('status', 'done');
|
||||
|
||||
// Filter by date range if provided
|
||||
if ($this->tanggalAwal && $this->tanggalAkhir) {
|
||||
$query->whereBetween('tanggal_permohonan', [$this->tanggalAwal, $this->tanggalAkhir]);
|
||||
}
|
||||
// Apply date range filter if provided
|
||||
if ($this->request->has('start_date') || $this->request->has('end_date')) {
|
||||
$startDate = $this->request->start_date ?? '1900-01-01';
|
||||
$endDate = $this->request->end_date ?? now()->toDateString();
|
||||
|
||||
$query->where('status', 'done');
|
||||
// Filter by status if provided
|
||||
if ($this->status) {
|
||||
$types = is_array($this->status) ? $this->status : [$this->status];
|
||||
$types = array_map('strtolower', $types);
|
||||
$query->whereHas('penilai', function (Builder $query) use ($types) {
|
||||
$query->whereIn('type_penilai', $types);
|
||||
$query->where(function ($q) use ($startDate, $endDate) {
|
||||
|
||||
$q->whereHas('penilaian', function ($q2) use ($startDate, $endDate) {
|
||||
$q2->whereBetween('tanggal_kunjungan', [$startDate, $endDate]);
|
||||
});
|
||||
|
||||
// OR check if has penawaran with date in range
|
||||
$q->orWhereHas('penawaran', function ($q3) use ($startDate, $endDate) {
|
||||
$q3->whereBetween('tanggal_penilaian_sebelumnya', [$startDate, $endDate]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Filter by laporan type if provided
|
||||
if ($this->request->has('laporan') && is_array($this->request->laporan) && !empty($this->request->laporan)) {
|
||||
foreach ($this->request->laporan as $type) {
|
||||
$query->whereHas('penilai', function ($q) use ($type) {
|
||||
$q->where('type_penilai', 'LIKE', '%' . $type . '%');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Apply branch filter if provided
|
||||
if ($this->request->has('branch_id') && !empty($this->request->branch_id)) {
|
||||
$query->where('branch_id', $this->request->branch_id);
|
||||
}
|
||||
|
||||
// Filter by selected IDs if provided
|
||||
if ($this->selectedIds) {
|
||||
$selectedIds = is_array($this->selectedIds) ? $this->selectedIds : explode(',', $this->selectedIds);
|
||||
if ($this->request->has('selected_ids') && !empty($this->request->selected_ids)) {
|
||||
$selectedIds = is_array($this->request->selected_ids) ? $this->request->selected_ids : explode(',', $this->request->selected_ids);
|
||||
$query->whereIn('id', $selectedIds);
|
||||
}
|
||||
|
||||
return $query;
|
||||
// Apply search filter if provided
|
||||
if ($this->request->has('search') && !empty($this->request->search)) {
|
||||
$search = $this->request->search;
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('debiture', DB::raw('LOWER(name)'), 'LIKE', '%' . strtolower($search) . '%');
|
||||
$q->orWhereRelation('jenisFasilitasKredit', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
||||
});
|
||||
}
|
||||
|
||||
// Default ordering
|
||||
$query->orderBy('nomor_registrasi', 'asc');
|
||||
|
||||
public function map($row): array
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
protected $rowNumber = 0;
|
||||
public function map($permohonan): array
|
||||
{
|
||||
$this->rowNumber++;
|
||||
$luas_tanah = 0;
|
||||
$luas_bangunan = 0;
|
||||
$nilai_tanah = 0;
|
||||
$nilai_bangunan = 0;
|
||||
$npw = 0;
|
||||
$nilai_liquidasi = 0;
|
||||
|
||||
// ambil data alamat dari inspeksi
|
||||
$alamat_inspeksi = null;
|
||||
if (isset($permohonan->penilai->lpj)) {
|
||||
$lpj = json_decode($permohonan->penilai->lpj, true);
|
||||
$npw = str_replace('.', '', $lpj['total_nilai_pasar_wajar'] ?? 0);
|
||||
|
||||
if ($row->inspeksi) {
|
||||
$alamat_inspeksi = json_decode($row->inspeksi->data_form, true) ?? null;
|
||||
$alamat_inspeksi = $alamat_inspeksi['asset']['alamat']['sesuai'] ?? $alamat_inspeksi['asset']['alamat']['tidak sesuai'] ?? [];
|
||||
$luas_tanah = $lpj['luas_tanah'] ?? 0;
|
||||
$luas_bangunan = $lpj['luas_bangunan'] ?? 0;
|
||||
$nilai_tanah = str_replace('.', '', $lpj['nilai_tanah_2'] ?? 0);
|
||||
$nilai_bangunan = str_replace('.', '', $lpj['nilai_bangunan_2'] ?? 0);
|
||||
$nilai_liquidasi = str_replace('.', '', $lpj['likuidasi_nilai_2'] ?? 0);
|
||||
}
|
||||
$alamat_inspeksi = $alamat_inspeksi['address'] ?? '-';
|
||||
|
||||
|
||||
// ambil data dari table penilai
|
||||
$fieldPenilai = ['lpj', 'resume', 'memo', 'rap', 'call-report'];
|
||||
$penilaiCek = null;
|
||||
|
||||
// Cari field yang tersedia
|
||||
foreach ($fieldPenilai as $value) {
|
||||
if (!empty($row->penilai->$value)) {
|
||||
$penilaiCek = $row->penilai->$value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$decodePenilai = json_decode($penilaiCek, true) ?? [];
|
||||
// Ambil nilai utama
|
||||
$luasTanah = $decodePenilai['luas_tanah'] ?? 0;
|
||||
$nilaiTanah1 = $decodePenilai['nilai_tanah_1'] ?? 0;
|
||||
$luasBangunan = $decodePenilai['luas_bangunan'] ?? 0;
|
||||
$nilaiBangunan1 = $decodePenilai['nilai_bangunan_1'] ?? 0;
|
||||
$totalNilaiPasar = $decodePenilai['total_nilai_pasar_wajar'] ?? 0;
|
||||
$likuidasi = $decodePenilai['likuidasi'] ?? 0;
|
||||
|
||||
// Ambil data npw_tambahan jika ada
|
||||
$npwTambahan = $decodePenilai['npw_tambahan'] ?? [];
|
||||
$tambahanDetails = [];
|
||||
foreach ($npwTambahan as $tambahan) {
|
||||
$tambahanDetails[] = sprintf(
|
||||
'%s: Luas: %s, Nilai 1: %s, Nilai 2: %s',
|
||||
$tambahan['name'] ?? '-',
|
||||
$tambahan['luas'] ?? 0,
|
||||
$tambahan['nilai_1'] ?? 0,
|
||||
$tambahan['nilai_2'] ?? 0
|
||||
);
|
||||
}
|
||||
$tambahanSummary = implode("; ", $tambahanDetails);
|
||||
|
||||
// Ambil data penilaian dari table penilaian
|
||||
$user_penilai = $row->penilaian->userPenilai ?? null;
|
||||
$user_penilai_name = null;
|
||||
foreach ($user_penilai as $value) {
|
||||
if ($value->role == 'penilai') {
|
||||
$user_penilai_name = $value->user->name;
|
||||
$nik_penilai = $value->user->nik ?? '-';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return [
|
||||
$row->id,
|
||||
$row->nomor_registrasi,
|
||||
$row->user->name,
|
||||
$row->branch->name,
|
||||
$row->tujuanPenilaian->name,
|
||||
$row->debiture->name,
|
||||
$row->penilai->type_penilai ?? '-',
|
||||
$alamat_inspeksi ?? '-',
|
||||
$luasTanah,
|
||||
$luasBangunan,
|
||||
$nilaiTanah1,
|
||||
$nilaiBangunan1,
|
||||
$totalNilaiPasar,
|
||||
$likuidasi,
|
||||
$row->laporan->created_at ?? '-',
|
||||
$user_penilai_name,
|
||||
$nik_penilai,
|
||||
$row->created_at,
|
||||
$this->rowNumber,
|
||||
$permohonan->nomor_registrasi,
|
||||
$permohonan->tanggal_permohonan ?? '',
|
||||
$permohonan->debiture->branch->name ?? '',
|
||||
$permohonan->user->name ?? $permohonan->mig_nama_ao ?? '',
|
||||
$permohonan->debiture->cif ?? '',
|
||||
$permohonan->debiture->name ?? '',
|
||||
$permohonan->tujuanPenilaian->name,
|
||||
$permohonan->jenisPenilaian->name ?? '',
|
||||
$permohonan->jenisFasilitasKredit->name,
|
||||
$permohonan->documents->pluck('jenisJaminan.name')->unique()->implode(', '),
|
||||
$permohonan->documents->map(function ($document) {
|
||||
return formatAlamat($document);
|
||||
})->unique()->implode(', '),
|
||||
$permohonan->documents->flatMap(function ($document) {
|
||||
return $document->detail->map(function ($detail) {
|
||||
return (!empty($detail->dokumen_nomor) && is_array($detail->dokumen_nomor))
|
||||
? ($detail->jenisLegalitasJaminan->name ?? '') . "\n" . implode(', ', $detail->dokumen_nomor)
|
||||
: null;
|
||||
});
|
||||
})->filter()->unique()->implode(', '),
|
||||
$permohonan->documents->pluck('pemilik.name')->unique()->implode(', '),
|
||||
$luas_tanah . ' m²',
|
||||
formatRupiah($nilai_tanah, 2),
|
||||
$luas_bangunan . ' m²',
|
||||
formatRupiah($nilai_bangunan, 2),
|
||||
formatRupiah($permohonan->nilai_njop ?? 0, 2),
|
||||
formatRupiah($npw, 2),
|
||||
formatRupiah($nilai_liquidasi, 2),
|
||||
$permohonan->documents->map(function ($document) {
|
||||
return formatTanggalIndonesia($document->created_at);
|
||||
})->first(),
|
||||
'', // tanggal_spk
|
||||
'', // nomor_spk
|
||||
'', // tanggal_rencana_kunjungan
|
||||
$permohonan->penilaian && $permohonan->penilaian->tanggal_kunjungan
|
||||
? formatTanggalIndonesia($permohonan->penilaian->tanggal_kunjungan)
|
||||
: '',
|
||||
'', // tanggal_delivered
|
||||
'', // jangka_waktu_sla
|
||||
($permohonan->approval_dd_at || $permohonan->approval_eo_at) ?
|
||||
formatTanggalIndonesia($permohonan->approval_dd_at ?? $permohonan->approval_eo_at) : '',
|
||||
$permohonan->penilaian && $permohonan->penilaian->tanggal_kunjungan
|
||||
? formatTanggalIndonesia($permohonan->penilaian->tanggal_kunjungan)
|
||||
: '',
|
||||
$permohonan->penilaian->_user_penilai->userPenilaiTeam->name ?? '',
|
||||
$permohonan->approveSo->name ?? '',
|
||||
$permohonan->penilai->type_penilai?? '',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'ID',
|
||||
'No',
|
||||
'Nomor Registrasi',
|
||||
'User Pemohon',
|
||||
'Tanggal Permohonan',
|
||||
'Cabang',
|
||||
'Pemohon',
|
||||
'CIF',
|
||||
'Nama Debitur',
|
||||
'Jenis Penilaian',
|
||||
'Tujuan Penilaian',
|
||||
'Debitur',
|
||||
'Jenis Laporan',
|
||||
'Lokasi Jaminan',
|
||||
'Jenis Fasilitas Kredit',
|
||||
'Jenis Agunan',
|
||||
'Alamat Agunan',
|
||||
'Bukti Kepemilikan',
|
||||
'Nama Pemilik',
|
||||
'Luas Tanah',
|
||||
'Nilai Tanah',
|
||||
'Luas Bangunan',
|
||||
'Harga Tanah',
|
||||
'Harga Bangunan',
|
||||
'Nilai Bangunan',
|
||||
'Nilai NJOP',
|
||||
'Nilai Pasar Wajar',
|
||||
'Likuidasi',
|
||||
'Nilai Likuidasi',
|
||||
'Tanggal Dokumen Diterima',
|
||||
'Tanggal SPK',
|
||||
'Nomor SPK',
|
||||
'Tanggal Rencana Kunjungan',
|
||||
'Tanggal Kunjungan',
|
||||
'Tanggal Delivered',
|
||||
'Jangka Waktu SLA',
|
||||
'Tanggal Laporan',
|
||||
'Tanggal Review',
|
||||
'Nama Penilai',
|
||||
'Nik Penilai',
|
||||
'Created At',
|
||||
'Nama Team Leader',
|
||||
'Laporan',
|
||||
|
||||
];
|
||||
}
|
||||
public function columnFormats(): array
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return 'Laporan Hasil Penilaian Jaminan Internal & External';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function startCell(): string
|
||||
{
|
||||
return 'A7';
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_NUMBER,
|
||||
'C' => NumberFormat::FORMAT_DATE_DATETIME,
|
||||
'K' => NumberFormat::FORMAT_DATE_DATETIME,
|
||||
'N' => NumberFormat::FORMAT_DATE_DATETIME
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
// Get the sheet
|
||||
$sheet = $event->sheet->getDelegate();
|
||||
|
||||
// Set the title
|
||||
$sheet->setCellValue('A1', 'LAPORAN PENILAIAN JAMINAN');
|
||||
$sheet->getStyle('A1')->getFont()->setBold(true)->setSize(16);
|
||||
|
||||
// Merge cells for title
|
||||
$sheet->mergeCells('A1:AH1');
|
||||
$sheet->getStyle('A1')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
|
||||
// Set the branch information if filtered
|
||||
$branchInfo = '';
|
||||
if ($this->request->has('branch_id') && !empty($this->request->branch_id)) {
|
||||
$branch = Branch::find($this->request->branch_id);
|
||||
if ($branch) {
|
||||
$branchInfo = 'Cabang: ' . $branch->name;
|
||||
$sheet->setCellValue('A2', $branchInfo);
|
||||
$sheet->mergeCells('A2:AH2');
|
||||
$sheet->getStyle('A2')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
$sheet->getStyle('A2')->getFont()->setBold(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the period
|
||||
$startDate = $this->request->start_date ?? '';
|
||||
$endDate = $this->request->end_date ?? '';
|
||||
|
||||
$rowIndex = $branchInfo ? 3 : 2;
|
||||
|
||||
if ($startDate && $endDate) {
|
||||
$startDateFormatted = Carbon::parse($startDate)->format('d F Y');
|
||||
$endDateFormatted = Carbon::parse($endDate)->format('d F Y');
|
||||
$sheet->setCellValue('A' . $rowIndex, 'Periode: ' . $startDateFormatted . ' - ' . $endDateFormatted);
|
||||
} else {
|
||||
$sheet->setCellValue('A' . $rowIndex, 'Periode: Semua Data');
|
||||
}
|
||||
$sheet->mergeCells('A' . $rowIndex . ':AH' . $rowIndex);
|
||||
$sheet->getStyle('A' . $rowIndex)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
|
||||
// Set the date of export
|
||||
$rowIndex++;
|
||||
$sheet->setCellValue('A' . $rowIndex, 'Tanggal Export: ' . Carbon::now()->format('d F Y H:i:s'));
|
||||
|
||||
// Set the user who exported
|
||||
$rowIndex++;
|
||||
$userName = Auth::user() ? Auth::user()->name : 'System';
|
||||
$sheet->setCellValue('A' . $rowIndex, 'Diexport oleh: ' . $userName);
|
||||
|
||||
// Add a blank line
|
||||
$rowIndex++;
|
||||
$sheet->setCellValue('A' . $rowIndex, '');
|
||||
|
||||
// Style the header row
|
||||
$headerRange = 'A7:' . $sheet->getHighestColumn() . '7';
|
||||
$sheet->getStyle($headerRange)->getFont()->setBold(true);
|
||||
$sheet->getStyle($headerRange)->getFill()
|
||||
->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
|
||||
->getStartColor()->setARGB('FFCCCCCC');
|
||||
|
||||
// Auto-size columns - fixed to handle columns beyond Z
|
||||
$highestColumn = $sheet->getHighestColumn();
|
||||
$highestColumnIndex = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($highestColumn);
|
||||
|
||||
for ($i = 1; $i <= $highestColumnIndex; $i++) {
|
||||
$currentColumn = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($i);
|
||||
$sheet->getColumnDimension($currentColumn)->setAutoSize(true);
|
||||
}
|
||||
|
||||
// Add borders to all cells with data
|
||||
$dataRange = 'A7:' . $sheet->getHighestColumn() . $sheet->getHighestRow();
|
||||
$sheet->getStyle($dataRange)->getBorders()->getAllBorders()->setBorderStyle(\PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN);
|
||||
|
||||
// Center align the header row
|
||||
$sheet->getStyle($headerRange)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
|
||||
// Set text wrap for header cells
|
||||
$sheet->getStyle($headerRange)->getAlignment()->setWrapText(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
260
app/Exports/LaporanPenilaianJaminanExport.php
Normal file
260
app/Exports/LaporanPenilaianJaminanExport.php
Normal file
@@ -0,0 +1,260 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
use Maatwebsite\Excel\Concerns\WithCustomStartCell;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\Branch;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
class LaporanPenilaianJaminanExport implements FromCollection, WithHeadings, WithMapping, WithTitle, WithCustomStartCell, WithEvents
|
||||
{
|
||||
protected $request;
|
||||
|
||||
public function __construct($request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$query = Permohonan::query();
|
||||
$query = $query->where('status', 'done');
|
||||
|
||||
// Apply date range filter if provided
|
||||
if ($this->request->has('start_date') || $this->request->has('end_date')) {
|
||||
|
||||
$startDate = $this->request->start_date ?? '1900-01-01';
|
||||
$endDate = $this->request->end_date ?? now()->toDateString();
|
||||
|
||||
$query->where(function ($q) use ($startDate, $endDate) {
|
||||
|
||||
$q->whereHas('penilaian', function ($q2) use ($startDate, $endDate) {
|
||||
$q2->whereBetween('tanggal_kunjungan', [$startDate, $endDate]);
|
||||
});
|
||||
|
||||
// OR check if has penawaran with date in range
|
||||
$q->orWhereHas('penawaran', function ($q3) use ($startDate, $endDate) {
|
||||
$q3->whereBetween('tanggal_penilaian_sebelumnya', [$startDate, $endDate]);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Apply branch filter if provided
|
||||
if ($this->request->has('branch_id') && !empty($this->request->branch_id)) {
|
||||
$query->where('branch_id', $this->request->branch_id);
|
||||
}
|
||||
|
||||
if ($this->request->has('penilai_id') && !empty($this->request->penilai_id)) {
|
||||
$request = $this->request; // Store in a local variable
|
||||
$query->whereHas('penilaian._user_penilai.userPenilaiTeam', function ($q) use ($request) {
|
||||
$q->where('user_id', $request->penilai_id);
|
||||
});
|
||||
}
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($this->request->has('search') && !empty($this->request->search)) {
|
||||
$search = $this->request->search;
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('debiture', DB::raw('LOWER(name)'), 'LIKE', '%' . strtolower($search) . '%');
|
||||
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('jenisFasilitasKredit', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
||||
});
|
||||
}
|
||||
|
||||
// Default ordering
|
||||
$query->orderBy('nomor_registrasi', 'asc');
|
||||
|
||||
dd($query->toSql(), $query->getBindings());
|
||||
|
||||
return $query->with(['debiture.branch'])->get();
|
||||
}
|
||||
|
||||
protected $rowNumber = 0;
|
||||
|
||||
public function map($permohonan): array
|
||||
{
|
||||
$this->rowNumber++;
|
||||
$luas_tanah = 0;
|
||||
$luas_bangunan = 0;
|
||||
$nilai_tanah = 0;
|
||||
$nilai_bangunan = 0;
|
||||
$npw = 0;
|
||||
$nilai_liquidasi = 0;
|
||||
|
||||
if (isset($permohonan->penilai->lpj)) {
|
||||
$lpj = json_decode($permohonan->penilai->lpj, true);
|
||||
$npw = str_replace('.', '', $lpj['total_nilai_pasar_wajar'] ?? 0);
|
||||
|
||||
$luas_tanah = $lpj['luas_tanah'] ?? 0;
|
||||
$luas_bangunan = $lpj['luas_bangunan'] ?? 0;
|
||||
$nilai_tanah = str_replace('.', '', $lpj['nilai_tanah_2'] ?? 0);
|
||||
$nilai_bangunan = str_replace('.', '', $lpj['nilai_bangunan_2'] ?? 0);
|
||||
$nilai_liquidasi = str_replace('.', '', $lpj['likuidasi_nilai_2'] ?? 0);
|
||||
}
|
||||
|
||||
return [
|
||||
$this->rowNumber,
|
||||
$permohonan->nomor_registrasi,
|
||||
$permohonan->tanggal_permohonan,
|
||||
$permohonan->debiture->branch->name,
|
||||
$permohonan->debiture->name,
|
||||
$permohonan->creator->name,
|
||||
$permohonan->tujuanPenilaian->name,
|
||||
$permohonan->documents->pluck('jenisJaminan.name')->unique()->implode(', '),
|
||||
$permohonan->documents->map(function ($document) {
|
||||
return formatAlamat($document);
|
||||
})->unique()->implode(', '),
|
||||
$luas_tanah . ' m²',
|
||||
formatRupiah($nilai_tanah, 2),
|
||||
$luas_bangunan . ' m²',
|
||||
formatRupiah($nilai_bangunan, 2),
|
||||
($permohonan->approval_dd_at || $permohonan->approval_eo_at) ?
|
||||
formatTanggalIndonesia($permohonan->approval_dd_at ?? $permohonan->approval_eo_at) : '',
|
||||
$permohonan->penilaian->tanggal_kunjungan ?
|
||||
formatTanggalIndonesia($permohonan->penilaian->tanggal_kunjungan) : '',
|
||||
formatRupiah($npw, 2),
|
||||
formatRupiah($nilai_liquidasi, 2),
|
||||
$permohonan->penilaian->_user_penilai->userPenilaiTeam->name,
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'No',
|
||||
'Nomor Registrasi',
|
||||
'Tanggal Permohonan',
|
||||
'Cabang',
|
||||
'Nama Debitur',
|
||||
'Pemohon',
|
||||
'Tujuan Penilaian',
|
||||
'Jenis Agunan',
|
||||
'Alamat Agunan',
|
||||
'Luas Tanah',
|
||||
'Nilai Tanah',
|
||||
'Luas Bangunan',
|
||||
'Nilai Bangunan',
|
||||
'Tanggal Laporan',
|
||||
'Tanggal Review',
|
||||
'Nilai Pasar Wajar',
|
||||
'Nilai Likuidasi',
|
||||
'Nama Penilai',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return 'Laporan Penilaian Jaminan';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function startCell(): string
|
||||
{
|
||||
return 'A7';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
// Get the sheet
|
||||
$sheet = $event->sheet->getDelegate();
|
||||
|
||||
// Set the title
|
||||
$sheet->setCellValue('A1', 'LAPORAN PENILAIAN JAMINAN');
|
||||
$sheet->getStyle('A1')->getFont()->setBold(true)->setSize(16);
|
||||
|
||||
// Merge cells for title
|
||||
$sheet->mergeCells('A1:R1');
|
||||
$sheet->getStyle('A1')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
|
||||
// Set the branch information if filtered
|
||||
$branchInfo = '';
|
||||
if ($this->request->has('branch_id') && !empty($this->request->branch_id)) {
|
||||
$branch = Branch::find($this->request->branch_id);
|
||||
if ($branch) {
|
||||
$branchInfo = 'Cabang: ' . $branch->name;
|
||||
$sheet->setCellValue('A2', $branchInfo);
|
||||
$sheet->mergeCells('A2:R2');
|
||||
$sheet->getStyle('A2')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
$sheet->getStyle('A2')->getFont()->setBold(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the period
|
||||
$startDate = $this->request->start_date ?? '';
|
||||
$endDate = $this->request->end_date ?? '';
|
||||
|
||||
$rowIndex = $branchInfo ? 3 : 2;
|
||||
|
||||
if ($startDate && $endDate) {
|
||||
$startDateFormatted = Carbon::parse($startDate)->format('d F Y');
|
||||
$endDateFormatted = Carbon::parse($endDate)->format('d F Y');
|
||||
$sheet->setCellValue('A' . $rowIndex, 'Periode: ' . $startDateFormatted . ' - ' . $endDateFormatted);
|
||||
} else {
|
||||
$sheet->setCellValue('A' . $rowIndex, 'Periode: Semua Data');
|
||||
}
|
||||
$sheet->mergeCells('A' . $rowIndex . ':R' . $rowIndex);
|
||||
$sheet->getStyle('A' . $rowIndex)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
|
||||
// Set the date of export
|
||||
$rowIndex++;
|
||||
$sheet->setCellValue('A' . $rowIndex, 'Tanggal Export: ' . Carbon::now()->format('d F Y H:i:s'));
|
||||
|
||||
// Set the user who exported
|
||||
$rowIndex++;
|
||||
$userName = Auth::user() ? Auth::user()->name : 'System';
|
||||
$sheet->setCellValue('A' . $rowIndex, 'Diexport oleh: ' . $userName);
|
||||
|
||||
// Add a blank line
|
||||
$rowIndex++;
|
||||
$sheet->setCellValue('A' . $rowIndex, '');
|
||||
|
||||
// Style the header row
|
||||
$headerRange = 'A7:' . $sheet->getHighestColumn() . '7';
|
||||
$sheet->getStyle($headerRange)->getFont()->setBold(true);
|
||||
$sheet->getStyle($headerRange)->getFill()
|
||||
->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
|
||||
->getStartColor()->setARGB('FFCCCCCC');
|
||||
|
||||
// Auto-size columns
|
||||
foreach (range('A', $sheet->getHighestColumn()) as $column) {
|
||||
$sheet->getColumnDimension($column)->setAutoSize(true);
|
||||
}
|
||||
|
||||
// Add borders to all cells with data
|
||||
$dataRange = 'A7:' . $sheet->getHighestColumn() . $sheet->getHighestRow();
|
||||
$sheet->getStyle($dataRange)->getBorders()->getAllBorders()->setBorderStyle(\PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN);
|
||||
|
||||
// Center align the header row
|
||||
$sheet->getStyle($headerRange)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
|
||||
// Set text wrap for header cells
|
||||
$sheet->getStyle($headerRange)->getAlignment()->setWrapText(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,7 @@
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$query = Permohonan::with(['user', 'branch', 'tujuanPenilaian', 'jenisFasilitasKredit', 'jenisPenilaian'])
|
||||
->select('permohonan.*');
|
||||
$query = Permohonan::query();
|
||||
|
||||
// Apply role-based filtering
|
||||
if (!Auth::user()->hasAnyRole(['administrator'])) {
|
||||
|
||||
232
app/Exports/LaporanUserLimitExport.php
Normal file
232
app/Exports/LaporanUserLimitExport.php
Normal file
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
use Maatwebsite\Excel\Concerns\WithCustomStartCell;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\Branch;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class LaporanUserLimitExport implements FromCollection, WithHeadings, WithMapping, WithTitle, WithCustomStartCell, WithEvents
|
||||
{
|
||||
protected $request;
|
||||
|
||||
public function __construct($request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$query = Permohonan::query();
|
||||
$query = $query->where('status', 'done');
|
||||
|
||||
// Apply date range filter if provided
|
||||
if ($this->request->has('start_date') || $this->request->has('end_date')) {
|
||||
$startDate = $this->request->start_date ?? '1900-01-01';
|
||||
$endDate = $this->request->end_date ?? now()->toDateString();
|
||||
|
||||
$query->where(function ($q) use ($startDate, $endDate) {
|
||||
|
||||
$q->whereHas('penilaian', function ($q2) use ($startDate, $endDate) {
|
||||
$q2->whereBetween('tanggal_kunjungan', [$startDate, $endDate]);
|
||||
});
|
||||
|
||||
// OR check if has penawaran with date in range
|
||||
$q->orWhereHas('penawaran', function ($q3) use ($startDate, $endDate) {
|
||||
$q3->whereBetween('tanggal_penilaian_sebelumnya', [$startDate, $endDate]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Apply branch filter if provided
|
||||
if ($this->request->has('branch_id') && !empty($this->request->branch_id)) {
|
||||
$query->where('branch_id', $this->request->branch_id);
|
||||
}
|
||||
|
||||
if ($this->request->has('penilai_id') && !empty($this->request->penilai_id)) {
|
||||
$request = $this->request; // Store in a local variable
|
||||
$query->whereHas('penilaian._user_penilai.userPenilaiTeam', function ($q) use ($request) {
|
||||
$q->where('user_id', $request->penilai_id);
|
||||
});
|
||||
}
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($this->request->has('search') && !empty($this->request->search)) {
|
||||
$search = $this->request->search;
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('debiture', DB::raw('LOWER(name)'), 'LIKE', '%' . strtolower($search) . '%');
|
||||
|
||||
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('jenisFasilitasKredit', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhere('status', 'LIKE', '%' . $search . '%');
|
||||
});
|
||||
}
|
||||
|
||||
// Default ordering
|
||||
$query->orderBy('nomor_registrasi', 'asc');
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
protected $rowNumber = 0;
|
||||
|
||||
public function map($permohonan): array
|
||||
{
|
||||
$this->rowNumber++;
|
||||
$npw = 0;
|
||||
|
||||
if (isset($permohonan->penilai->lpj)) {
|
||||
$lpj = json_decode($permohonan->penilai->lpj, true);
|
||||
$npw = str_replace('.', '', $lpj['total_nilai_pasar_wajar'] ?? 0);
|
||||
}
|
||||
|
||||
return [
|
||||
$this->rowNumber,
|
||||
$permohonan->nomor_registrasi,
|
||||
$permohonan->debiture->branch->name ?? '',
|
||||
$permohonan->debiture->name ?? '',
|
||||
$permohonan->user->name ?? $permohonan->mig_nama_ao ?? '',
|
||||
$permohonan->tanggal_permohonan ?? '',
|
||||
$permohonan->penilaian->_user_penilai->userPenilaiTeam->name ?? '',
|
||||
$permohonan->penilaian && $permohonan->penilaian->tanggal_kunjungan
|
||||
? formatTanggalIndonesia($permohonan->penilaian->tanggal_kunjungan)
|
||||
: '',
|
||||
formatRupiah($npw, 2),
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'No',
|
||||
'Nomor Registrasi',
|
||||
'Cabang',
|
||||
'Nama Debitur',
|
||||
'Pemohon',
|
||||
'Tanggal Permohonan',
|
||||
'Nama Penilai',
|
||||
'Tanggal Laporan',
|
||||
'Nilai Pasar Wajar',
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return 'Laporan User Limit';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function startCell(): string
|
||||
{
|
||||
return 'A7';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
// Get the sheet
|
||||
$sheet = $event->sheet->getDelegate();
|
||||
|
||||
// Set the title
|
||||
$sheet->setCellValue('A1', 'LAPORAN PENILAIAN JAMINAN');
|
||||
$sheet->getStyle('A1')->getFont()->setBold(true)->setSize(16);
|
||||
|
||||
// Merge cells for title
|
||||
$sheet->mergeCells('A1:AH1');
|
||||
$sheet->getStyle('A1')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
|
||||
// Set the branch information if filtered
|
||||
$branchInfo = '';
|
||||
if ($this->request->has('branch_id') && !empty($this->request->branch_id)) {
|
||||
$branch = Branch::find($this->request->branch_id);
|
||||
if ($branch) {
|
||||
$branchInfo = 'Cabang: ' . $branch->name;
|
||||
$sheet->setCellValue('A2', $branchInfo);
|
||||
$sheet->mergeCells('A2:AH2');
|
||||
$sheet->getStyle('A2')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
$sheet->getStyle('A2')->getFont()->setBold(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the period
|
||||
$startDate = $this->request->start_date ?? '';
|
||||
$endDate = $this->request->end_date ?? '';
|
||||
|
||||
$rowIndex = $branchInfo ? 3 : 2;
|
||||
|
||||
if ($startDate && $endDate) {
|
||||
$startDateFormatted = Carbon::parse($startDate)->format('d F Y');
|
||||
$endDateFormatted = Carbon::parse($endDate)->format('d F Y');
|
||||
$sheet->setCellValue('A' . $rowIndex, 'Periode: ' . $startDateFormatted . ' - ' . $endDateFormatted);
|
||||
} else {
|
||||
$sheet->setCellValue('A' . $rowIndex, 'Periode: Semua Data');
|
||||
}
|
||||
$sheet->mergeCells('A' . $rowIndex . ':AH' . $rowIndex);
|
||||
$sheet->getStyle('A' . $rowIndex)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
|
||||
// Set the date of export
|
||||
$rowIndex++;
|
||||
$sheet->setCellValue('A' . $rowIndex, 'Tanggal Export: ' . Carbon::now()->format('d F Y H:i:s'));
|
||||
|
||||
// Set the user who exported
|
||||
$rowIndex++;
|
||||
$userName = Auth::user() ? Auth::user()->name : 'System';
|
||||
$sheet->setCellValue('A' . $rowIndex, 'Diexport oleh: ' . $userName);
|
||||
|
||||
// Add a blank line
|
||||
$rowIndex++;
|
||||
$sheet->setCellValue('A' . $rowIndex, '');
|
||||
|
||||
// Style the header row
|
||||
$headerRange = 'A7:' . $sheet->getHighestColumn() . '7';
|
||||
$sheet->getStyle($headerRange)->getFont()->setBold(true);
|
||||
$sheet->getStyle($headerRange)->getFill()
|
||||
->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
|
||||
->getStartColor()->setARGB('FFCCCCCC');
|
||||
|
||||
// Auto-size columns - fixed to handle columns beyond Z
|
||||
$highestColumn = $sheet->getHighestColumn();
|
||||
$highestColumnIndex = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($highestColumn);
|
||||
|
||||
for ($i = 1; $i <= $highestColumnIndex; $i++) {
|
||||
$currentColumn = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($i);
|
||||
$sheet->getColumnDimension($currentColumn)->setAutoSize(true);
|
||||
}
|
||||
|
||||
// Add borders to all cells with data
|
||||
$dataRange = 'A7:' . $sheet->getHighestColumn() . $sheet->getHighestRow();
|
||||
$sheet->getStyle($dataRange)->getBorders()->getAllBorders()->setBorderStyle(\PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN);
|
||||
|
||||
// Center align the header row
|
||||
$sheet->getStyle($headerRange)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
|
||||
// Set text wrap for header cells
|
||||
$sheet->getStyle($headerRange)->getAlignment()->setWrapText(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,19 +2,21 @@
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\Location\Models\City;
|
||||
use Modules\Location\Models\District;
|
||||
use Modules\Location\Models\Province;
|
||||
use Modules\Location\Models\Village;
|
||||
use Modules\Lpj\Models\CustomField;
|
||||
use Modules\Lpj\Models\HolidayCalendar;
|
||||
use Modules\Lpj\Models\JenisDokumen;
|
||||
use Modules\Lpj\Models\Laporan;
|
||||
use Modules\Lpj\Models\PenawaranDetailTender;
|
||||
use Modules\Lpj\Models\PenawaranTender;
|
||||
use Modules\Lpj\Models\Penilaian;
|
||||
use Modules\Lpj\Models\JenisDokumen;
|
||||
use Modules\Lpj\Models\TeamsUsers;
|
||||
use Modules\Lpj\Models\Laporan;
|
||||
use Modules\Usermanagement\Models\User;
|
||||
use Modules\Location\Models\Province;
|
||||
use Modules\Location\Models\City;
|
||||
use Modules\Location\Models\District;
|
||||
use Modules\Location\Models\Village;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
function formatTanggalIndonesia($date, $time = false)
|
||||
{
|
||||
@@ -25,7 +27,7 @@ function formatTanggalIndonesia($date, $time = false)
|
||||
return $waktu->translatedFormat('d F Y');
|
||||
}
|
||||
return $waktu->translatedFormat('d F Y') . ' pukul ' . $waktu->format('H.i') . ' WIB';
|
||||
} catch (\Throwable $e) {
|
||||
} catch (Throwable $e) {
|
||||
return $date;
|
||||
}
|
||||
|
||||
@@ -119,7 +121,8 @@ function convertSlug($slug)
|
||||
}
|
||||
|
||||
// generate last penawaran.code
|
||||
function onLastnumberCodePenawaran(): string
|
||||
function onLastnumberCodePenawaran()
|
||||
: string
|
||||
{
|
||||
// ambil code terakhir
|
||||
$maxCode = PenawaranTender::max('code');
|
||||
@@ -133,7 +136,7 @@ function onLastnumberCodePenawaran(): string
|
||||
if ($penawaran) {
|
||||
$isNum = substr($maxCode, 2); // memastikan string ke 3 s/d 8 adalan numiric
|
||||
$isNP = substr($maxCode, 0, 2);
|
||||
if ((8 == strlen($maxCode)) && ("NP" == $isNP) && (isNumeric($isNum))) {
|
||||
if ((8 == strlen($maxCode)) && ("NP" == $isNP) && (ctype_digit($isNum))) {
|
||||
$code_penawaran_last = substr($maxCode, -4);
|
||||
$year_penawaran_last = Carbon::parse($penawaran->created_at)->year;
|
||||
$year_now = Carbon::now()->year;
|
||||
@@ -148,13 +151,9 @@ function onLastnumberCodePenawaran(): string
|
||||
return 'NP' . Carbon::now()->format('y') . $noUrutAkhirString;
|
||||
}
|
||||
|
||||
function isNumeric($str)
|
||||
{
|
||||
return ctype_digit($str);
|
||||
}
|
||||
|
||||
// generate last penawaran.no_spk
|
||||
function onLastnumberCodePenawaranSPK($jenis_laporan_code): string
|
||||
function onLastnumberCodePenawaranSPK($jenis_laporan_code)
|
||||
: string
|
||||
{
|
||||
|
||||
// 20241124_001 ==> spk_no_core
|
||||
@@ -183,54 +182,29 @@ function onLastnumberCodePenawaranSPK($jenis_laporan_code): string
|
||||
return $lastSPK;
|
||||
}
|
||||
|
||||
function onRomawi(int $bln): string
|
||||
function onRomawi(int $bln)
|
||||
: string
|
||||
{
|
||||
switch ($bln) {
|
||||
case 1:
|
||||
return "I";
|
||||
break;
|
||||
case 2:
|
||||
return "II";
|
||||
break;
|
||||
case 3:
|
||||
return "III";
|
||||
break;
|
||||
case 4:
|
||||
return "IV";
|
||||
break;
|
||||
case 5:
|
||||
return "V";
|
||||
break;
|
||||
case 6:
|
||||
return "VI";
|
||||
break;
|
||||
case 7:
|
||||
return "VII";
|
||||
break;
|
||||
case 8:
|
||||
return "VIII";
|
||||
break;
|
||||
case 9:
|
||||
return "IX";
|
||||
break;
|
||||
case 10:
|
||||
return "X";
|
||||
break;
|
||||
case 11:
|
||||
return "XI";
|
||||
break;
|
||||
case 12:
|
||||
return "XII";
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return convertToRoman($bln);
|
||||
}
|
||||
|
||||
function penyebut($nilai)
|
||||
{
|
||||
$nilai = abs($nilai);
|
||||
$huruf = array("", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas");
|
||||
$huruf = [
|
||||
"",
|
||||
"satu",
|
||||
"dua",
|
||||
"tiga",
|
||||
"empat",
|
||||
"lima",
|
||||
"enam",
|
||||
"tujuh",
|
||||
"delapan",
|
||||
"sembilan",
|
||||
"sepuluh",
|
||||
"sebelas"
|
||||
];
|
||||
$temp = "";
|
||||
if ($nilai < 12) {
|
||||
$temp = " " . $huruf[$nilai];
|
||||
@@ -265,6 +239,7 @@ function terbilang($nilai)
|
||||
}
|
||||
return $hasil;
|
||||
}
|
||||
|
||||
// andy add
|
||||
|
||||
|
||||
@@ -287,15 +262,6 @@ function hitungHariKerja($tanggalMulai, $tanggalSelesai)
|
||||
return $hariKerja;
|
||||
}
|
||||
|
||||
function holidays()
|
||||
{
|
||||
return HolidayCalendar::pluck('date')->map(
|
||||
function ($item) {
|
||||
return Carbon::parse($item)->format('Y-m-d');
|
||||
},
|
||||
)->toArray();
|
||||
}
|
||||
|
||||
function countPermohonanForUser($userId)
|
||||
{
|
||||
$validStatuses = [
|
||||
@@ -406,6 +372,7 @@ function getCustomField($param)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function getWilayahName($code, $type)
|
||||
{
|
||||
try {
|
||||
@@ -435,7 +402,7 @@ function getWilayahName($code, $type)
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -488,6 +455,7 @@ function calculateSLA($permohonan, $type)
|
||||
* @param array $detailsArray
|
||||
* @param string $key
|
||||
* @param int $jenisLegalitas
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function calculateTotalLuas($detailsArray, $key, $jenisLegalitas, $defaultJenisLegalitas, $fallbackJenisLegalitas)
|
||||
@@ -548,7 +516,8 @@ function calculateTotalLuas($detailsArray, $key, $jenisLegalitas, $defaultJenisL
|
||||
}
|
||||
|
||||
|
||||
function ubahNomorHp($nomorHp) {
|
||||
function ubahNomorHp($nomorHp)
|
||||
{
|
||||
|
||||
$nomorHp = preg_replace('/\D/', '', $nomorHp);
|
||||
if (strpos($nomorHp, '62') === 0) {
|
||||
@@ -562,3 +531,161 @@ function ubahNomorHp($nomorHp) {
|
||||
return "Nomor HP tidak valid";
|
||||
}
|
||||
}
|
||||
|
||||
function parsePembandingMigration($keterangan) {
|
||||
$keterangan = preg_replace('/[-]{5,}/', '',$keterangan); // Hapus ------
|
||||
$keterangan = preg_replace('/[.]{5,}/', '',$keterangan); // Hapus .....
|
||||
|
||||
$keterangan = preg_replace('/\s+/', ' ',$keterangan);
|
||||
$keterangan = preg_replace('/\s*\n\s*/', "\n",$keterangan);
|
||||
|
||||
// Pecah teks per baris untuk diproses
|
||||
$lines = explode("\n",$keterangan);
|
||||
$cleaned = [];
|
||||
|
||||
foreach ($lines as $line) {
|
||||
$line = trim($line);
|
||||
if (!empty($line)) {
|
||||
// Format angka dalam format Rp. 123.456.789
|
||||
$line = preg_replace_callback('/Rp\.\s*([\d.,]+)/', function($matches) {
|
||||
$angka = str_replace(['.', ','], '', $matches[1]);
|
||||
return 'Rp. ' . number_format((int)$angka, 0, ',', '.');
|
||||
}, $line);
|
||||
|
||||
// Jika ada tanda pagar (#), pisahkan menjadi baris baru
|
||||
$line = str_replace('#', "\n#", $line);
|
||||
|
||||
$cleaned[] = $line;
|
||||
}
|
||||
}
|
||||
|
||||
return implode("\n", $cleaned);
|
||||
}
|
||||
/**
|
||||
* get full path to internal storage file or external storage file
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
|
||||
function getFilePath($path)
|
||||
{
|
||||
// define base path external storage (use .env) example: 'F:\path\to\storage' in windows
|
||||
$externalBase = env('EXTERNAL_STORAGE_BASE_PATH', 'F:LPJ/lpj/LPJ Gambar/001/');
|
||||
|
||||
$segments = explode('/', $path);
|
||||
|
||||
if(strtoupper($segments[0]) === 'SURVEYOR'){
|
||||
$year = $segments[1];
|
||||
$month = ucfirst(strtolower($segments[2]));
|
||||
$date = $segments[3];
|
||||
$code = $segments[4];
|
||||
$file = $segments[5] ?? '';
|
||||
|
||||
$extenalFullpath = $externalBase . $year . '/' . $month . '/' . $date . '/' . $code . '/' . $file;
|
||||
|
||||
if(File::exists($extenalFullpath)){
|
||||
return $extenalFullpath;
|
||||
}
|
||||
}
|
||||
|
||||
// if not found in external storage, try to find in internal storage
|
||||
if (Storage::exists($path)) {
|
||||
return Storage::url('app/' . $path);
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
|
||||
function parseTimestamp(?string $timestamp): ?string
|
||||
{
|
||||
if (!$timestamp) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Trim whitespace dan normalize
|
||||
$timestamp = trim($timestamp);
|
||||
|
||||
// Log untuk debugging
|
||||
Log::info('Mencoba parsing timestamp: "' . $timestamp . '"');
|
||||
|
||||
// Parsing dengan DateTime native PHP untuk lebih robust
|
||||
try {
|
||||
// Pattern untuk format d/m/Y H:i:s
|
||||
if (preg_match('/^(\d{1,2})\/(\d{1,2})\/(\d{4})\s+(\d{1,2}):(\d{1,2}):(\d{1,2})$/', $timestamp, $matches)) {
|
||||
$day = (int) $matches[1];
|
||||
$month = (int) $matches[2];
|
||||
$year = (int) $matches[3];
|
||||
$hour = (int) $matches[4];
|
||||
$minute = (int) $matches[5];
|
||||
$second = (int) $matches[6];
|
||||
|
||||
// Validasi nilai
|
||||
if ($day >= 1 && $day <= 31 && $month >= 1 && $month <= 12 && $year >= 1900 && $year <= 2100 &&
|
||||
$hour >= 0 && $hour <= 23 && $minute >= 0 && $minute <= 59 && $second >= 0 && $second <= 59) {
|
||||
|
||||
// Buat DateTime object langsung
|
||||
$dateTime = new \DateTime();
|
||||
$dateTime->setDate($year, $month, $day);
|
||||
$dateTime->setTime($hour, $minute, $second);
|
||||
|
||||
$result = $dateTime->format('Y-m-d H:i:s');
|
||||
Log::info('Berhasil parsing dengan DateTime: ' . $timestamp . ' -> ' . $result);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
// Pattern untuk format d/m/Y tanpa waktu
|
||||
if (preg_match('/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/', $timestamp, $matches)) {
|
||||
$day = (int) $matches[1];
|
||||
$month = (int) $matches[2];
|
||||
$year = (int) $matches[3];
|
||||
|
||||
// Validasi nilai
|
||||
if ($day >= 1 && $day <= 31 && $month >= 1 && $month <= 12 && $year >= 1900 && $year <= 2100) {
|
||||
|
||||
// Buat DateTime object langsung
|
||||
$dateTime = new \DateTime();
|
||||
$dateTime->setDate($year, $month, $day);
|
||||
$dateTime->setTime(0, 0, 0);
|
||||
|
||||
$result = $dateTime->format('Y-m-d H:i:s');
|
||||
Log::info('Berhasil parsing tanpa waktu dengan DateTime: ' . $timestamp . ' -> ' . $result);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Gagal parsing dengan DateTime: ' . $timestamp . '. Error: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
// Fallback ke format Carbon standar untuk format lainnya
|
||||
$formats = [
|
||||
'Y-m-d H:i:s',
|
||||
'Y-m-d',
|
||||
'd-m-Y H:i:s',
|
||||
'd-m-Y',
|
||||
'j-n-Y H:i:s',
|
||||
'j-n-Y',
|
||||
];
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$carbon = \Carbon\Carbon::createFromFormat($format, $timestamp);
|
||||
|
||||
if ($carbon && $carbon->format($format) === $timestamp) {
|
||||
// Jika format tidak mengandung waktu, set ke awal hari
|
||||
if (!str_contains($format, 'H:i:s')) {
|
||||
$carbon = $carbon->startOfDay();
|
||||
}
|
||||
Log::info('Berhasil parsing dengan format ' . $format . ': ' . $timestamp . ' -> ' . $carbon->toDateTimeString());
|
||||
return $carbon->toDateTimeString();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// Lanjut ke format berikutnya
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Log::error('Tidak dapat memparsing timestamp dengan format apapun: "' . $timestamp . '"');
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -306,6 +306,7 @@ class ActivityController extends Controller
|
||||
$query = Permohonan::query();
|
||||
|
||||
// Apply search filter if provided
|
||||
$query = $query->orderBy('nomor_registrasi', 'desc');
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
$query->where(function ($q) use ($search) {
|
||||
@@ -324,7 +325,9 @@ class ActivityController extends Controller
|
||||
});
|
||||
}
|
||||
|
||||
// Default sorting if no sort provided
|
||||
|
||||
|
||||
// Apply sorting if provided
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
@@ -333,20 +336,13 @@ class ActivityController extends Controller
|
||||
$query->orderBy('nomor_registrasi', 'asc');
|
||||
}
|
||||
|
||||
// Get total count of records before pagination
|
||||
// Get the total count of records
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Pagination
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = (int) $request->get('page', 1);
|
||||
$size = (int) $request->get('size', 10);
|
||||
$offset = ($page - 1) * $size;
|
||||
$query->skip($offset)->take($size);
|
||||
$size = $request->get('size', 10);
|
||||
if ($size == 0) {
|
||||
$size = 10;
|
||||
}
|
||||
|
||||
// Get filtered count
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Filter by region if user is senior-officer
|
||||
if ($regionId) {
|
||||
$query->whereHas('region', function ($q) use ($regionId) {
|
||||
@@ -361,37 +357,36 @@ class ActivityController extends Controller
|
||||
});
|
||||
}
|
||||
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Pagination
|
||||
|
||||
// Apply pagination if provided
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = (int) $request->get('page', 1);
|
||||
$size = (int) $request->get('size', 10);
|
||||
$offset = ($page - 1) * $size;
|
||||
$page = $request->get('page');
|
||||
$size = $request->get('size');
|
||||
$offset = ($page - 1) * $size; // Calculate the offset
|
||||
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get filtered count
|
||||
// Get the filtered count of records
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get data with necessary relationships
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian', 'dokumenjaminan','nilaiPlafond'])->get();
|
||||
|
||||
// Calculate total pages
|
||||
$pageCount = ceil($totalRecords / $request->get('size', 10));
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $size);
|
||||
|
||||
// Calculate the current page number
|
||||
$currentPage = max(1, $request->get('page', 1));
|
||||
|
||||
|
||||
|
||||
// Calculate total pages
|
||||
$pageCount = ceil($totalRecords / $request->get('size', 10));
|
||||
|
||||
// Return the response data as a JSON object
|
||||
return response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $request->get('page', 1),
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
|
||||
152
app/Http/Controllers/CategoryDaftarPustakaController.php
Normal file
152
app/Http/Controllers/CategoryDaftarPustakaController.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Lpj\Models\CategoryDaftarPustaka;
|
||||
use Modules\Lpj\Http\Requests\CategoryDaftarPustakaRequest;
|
||||
|
||||
class CategoryDaftarPustakaController extends Controller
|
||||
{
|
||||
public $user;
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('lpj::category-daftar-pustaka.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('lpj::category-daftar-pustaka.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(CategoryDaftarPustakaRequest $request)
|
||||
{
|
||||
$validated = $request->validated();
|
||||
if ($validated) {
|
||||
try {
|
||||
CategoryDaftarPustaka::create($validated);
|
||||
return redirect()->route('category-daftar-pustaka.index')->with('success', 'Data Berhasil Disimpan');
|
||||
} catch (\Throwable $th) {
|
||||
return redirect()->route('category-daftar-pustaka.index')->with('error', $th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$category = CategoryDaftarPustaka::where('id', $id)->first();
|
||||
return view('lpj::category-daftar-pustaka.show', compact('category'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('lpj::category-daftar-pustaka.create', ['category' => CategoryDaftarPustaka::where('id', $id)->first()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(CategoryDaftarPustakaRequest $request, $id)
|
||||
{
|
||||
$validated = $request->validated();
|
||||
if ($validated) {
|
||||
try {
|
||||
CategoryDaftarPustaka::where('id', $id)->update($validated);
|
||||
return redirect()->route('category-daftar-pustaka.index')->with('success', 'Data Berhasil Disimpan');
|
||||
} catch (\Throwable $th) {
|
||||
return redirect()->route('category-daftar-pustaka.index')->with('error', $th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
CategoryDaftarPustaka::where('id', $id)->delete();
|
||||
return response()->json(['success' => true, 'message' => 'Data Berhasil Dihapus']);
|
||||
} catch (\Throwable $th) {
|
||||
return response()->json(['success' => false, 'message' => $th->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('jenis_aset.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = CategoryDaftarPustaka::query();
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('code', 'LIKE', "%$search%");
|
||||
$q->orWhere('name', 'LIKE', "%$search%");
|
||||
});
|
||||
}
|
||||
|
||||
// Apply sorting if provided
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
}
|
||||
|
||||
// Get the total count of records
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Apply pagination if provided
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = $request->get('page');
|
||||
$size = $request->get('size');
|
||||
$offset = ($page - 1) * $size; // Calculate the offset
|
||||
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get the filtered count of records
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->get();
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||
|
||||
// Calculate the current page number
|
||||
$currentPage = 0 + 1;
|
||||
|
||||
// Return the response data as a JSON object
|
||||
return response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
}
|
||||
129
app/Http/Controllers/DaftarPustakaController.php
Normal file
129
app/Http/Controllers/DaftarPustakaController.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Lpj\Models\CategoryDaftarPustaka;
|
||||
use Modules\Lpj\Services\DaftarPustakaService;
|
||||
use Modules\Lpj\Http\Requests\DaftarPustakaRequest;
|
||||
|
||||
class DaftarPustakaController extends Controller
|
||||
{
|
||||
private $daftarPustaka;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->daftarPustaka = app(DaftarPustakaService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$categories = CategoryDaftarPustaka::all();
|
||||
$daftar_pustaka = $this->daftarPustaka->getAllDaftarPustaka($request);
|
||||
|
||||
return view('lpj::daftar-pustaka.index', [
|
||||
'categories' => $categories,
|
||||
'daftar_pustaka' => $daftar_pustaka,
|
||||
'page' => $daftar_pustaka->currentPage(),
|
||||
'pageCount' => $daftar_pustaka->lastPage(),
|
||||
'limit' => $daftar_pustaka->perPage(),
|
||||
'total' => $daftar_pustaka->total(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$categories = CategoryDaftarPustaka::all();
|
||||
// dd($categories);
|
||||
return view('lpj::daftar-pustaka.create', compact('categories'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(DaftarPustakaRequest $request)
|
||||
{
|
||||
|
||||
$validate = $request->validated();
|
||||
// dd($validate);
|
||||
$file = $request->file('attachment');
|
||||
if ($validate) {
|
||||
try {
|
||||
// Save to database
|
||||
$this->daftarPustaka->storeDaftarPustaka($validate, $file);
|
||||
return redirect()
|
||||
->route('daftar-pustaka.index')
|
||||
->with('success', 'Daftar Pustaka created successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('daftar-pustaka.create')
|
||||
->with('error', 'Failed to create daftar pustaka');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$daftarPustaka = $this->daftarPustaka->getDaftarPustakaById($id);
|
||||
$categories = CategoryDaftarPustaka::all();
|
||||
|
||||
return view('lpj::daftar-pustaka.show', compact('daftarPustaka', 'categories'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$daftarPustaka = $this->daftarPustaka->getDaftarPustakaById($id);
|
||||
$categories = CategoryDaftarPustaka::all();
|
||||
return view('lpj::daftar-pustaka.create', compact('daftarPustaka', 'categories'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(DaftarPustakaRequest $request, $id)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
if ($validate) {
|
||||
try {
|
||||
// Save to database
|
||||
$file = $request->file('attachment');
|
||||
$this->daftarPustaka->updateDaftarPustaka($validate, $file, $id);
|
||||
return redirect()
|
||||
->route('daftar-pustaka.index')
|
||||
->with('success', 'Daftar Pustaka updated successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('daftar-pustaka.create')
|
||||
->with('error', 'Failed to update daftar pustaka');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$this->daftarPustaka->deleteDaftarPustaka($id);
|
||||
return response()->json(['success' => true, 'message' => 'Daftar Pustaka deleted successfully']);
|
||||
} catch (Exception $e) {
|
||||
return response()->json(['success' => false, 'message' => 'Failed to delete daftar pustaka']);
|
||||
}
|
||||
}
|
||||
}
|
||||
36
app/Http/Controllers/DashboardController.php
Normal file
36
app/Http/Controllers/DashboardController.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Lpj\Services\DashboardService;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public $dashboardService;
|
||||
public function __construct(DashboardService $dashboardService)
|
||||
{
|
||||
$this->dashboardService = $dashboardService;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
// nilai default
|
||||
$start_date = $request->input('start_date', now()->startOfYear()->format('Y-m-d'));
|
||||
$end_date = $request->input('end_date', now()->format('Y-m-d'));
|
||||
|
||||
$validate = $request->validate([
|
||||
'start_date' => 'nullable|date_format:Y-m-d',
|
||||
'end_date' => 'nullable|date_format:Y-m-d',
|
||||
]);
|
||||
|
||||
$dashboard = $this->dashboardService->getDashboardData($start_date, $end_date);
|
||||
|
||||
// dd($dashboard);
|
||||
return view('lpj::dashboard.index', compact('dashboard'));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -406,7 +406,9 @@
|
||||
|
||||
|
||||
// Remove values from $legalitasJaminan that are in $currentLegalitasJaminan
|
||||
$legalitasJaminan = array_diff($legalitasJaminan, $currentLegalitasJaminan->pluck('code')->toArray());
|
||||
$legalitasJaminan = is_array($legalitasJaminan)
|
||||
? array_diff($legalitasJaminan, $currentLegalitasJaminan->pluck('code')->toArray())
|
||||
: [];
|
||||
|
||||
$legalitas = JenisLegalitasJaminan::whereIn('code', $legalitasJaminan)->get();
|
||||
}
|
||||
|
||||
@@ -19,12 +19,7 @@
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$permohonan = Permohonan::with([
|
||||
'documents.jenisJaminan',
|
||||
'penilaian._user_penilai',
|
||||
'penilai',
|
||||
'documents.detail.jenisLegalitasJaminan'
|
||||
])->where(['status' => 'done'])->get();
|
||||
$permohonan = Permohonan::where(['status' => 'done'])->get();
|
||||
foreach ($permohonan as $_permohonan) {
|
||||
$npw = 0;
|
||||
if (isset($_permohonan->penilai->lpj)) {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LaporanBiayaInternalExternalController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function showLaporanBiayaInternal()
|
||||
{
|
||||
return view('lpj::laporan-biaya.internal');
|
||||
}
|
||||
|
||||
public function showLaporanBiayaExternal()
|
||||
{
|
||||
return view('lpj::laporan-biaya.external');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -75,11 +75,9 @@ class LaporanController extends Controller
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = Permohonan::query()->whereIn('status',['proses-laporan','done', 'paparan', 'proses-paparan'])->whereNotNull('approval_so_at')->whereNotNull('approval_eo_at')->where(function ($q) {
|
||||
$q->whereIn('nilai_plafond_id', [1,4])
|
||||
->whereNotNull('approval_dd_at')
|
||||
->orWhereIn('nilai_plafond_id', [2,3]);
|
||||
});
|
||||
$query = Permohonan::query()
|
||||
->whereIn('status',['proses-laporan','done', 'paparan', 'proses-paparan']);
|
||||
|
||||
|
||||
$query = $query->orderBy('nomor_registrasi', 'desc');
|
||||
// Apply search filter if provided
|
||||
@@ -123,7 +121,7 @@ class LaporanController extends Controller
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian','jenisFasilitasKredit', 'documents.inspeksi','penilai','documents.detail'])->get();
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian','jenisFasilitasKredit', 'documents.inspeksi','penilai','documents.detail','noc'])->get();
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $size);
|
||||
|
||||
33
app/Http/Controllers/LaporanDebitureController.php
Normal file
33
app/Http/Controllers/LaporanDebitureController.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Lpj\Models\Debiture;
|
||||
use Modules\Lpj\Services\LaporanDebitureService;
|
||||
|
||||
class LaporanDebitureController extends Controller
|
||||
{
|
||||
private $laporanDebitureService;
|
||||
public function __construct()
|
||||
{
|
||||
$this->laporanDebitureService = app(LaporanDebitureService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$debiture = Debiture::all();
|
||||
return view('lpj::laporan-debiture.index', compact('debiture'));
|
||||
}
|
||||
|
||||
|
||||
public function dataTableForDebiture(Request $request)
|
||||
{
|
||||
return $this->laporanDebitureService->dataForDatatables($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Lpj\Exports\LaporanHasilPenilaianJaminanInternalExternalExport;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class LaporanHasilPenilaianJaminanInternalExternalController extends Controller
|
||||
{
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('lpj::laporan_hasil_penilaian_jaminan_internal_external.index');
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('laporan-admin-kredit.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view laporan admin kredit.');
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = Permohonan::query();
|
||||
$query = $query->where('status', 'done');
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = json_decode($request->get('search'));
|
||||
|
||||
if (isset($search->start_date) || isset($search->end_date)) {
|
||||
$query->whereBetween('tanggal_permohonan', [
|
||||
$search->start_date ?? '1900-01-01',
|
||||
$search->end_date ?? now()->toDateString()
|
||||
]);
|
||||
}
|
||||
|
||||
// Filter by branch if provided
|
||||
if (isset($search->branch_id) && !empty($search->branch_id)) {
|
||||
$query->where('branch_id', $search->branch_id);
|
||||
}
|
||||
|
||||
if (isset($search->penilai_id) && !empty($search->penilai_id)) {
|
||||
$query->whereHas('penilaian._user_penilai.userPenilaiTeam', function ($q) use ($search) {
|
||||
$q->where('user_id', $search->penilai_id);
|
||||
});
|
||||
}
|
||||
|
||||
if (isset($search->search)) {
|
||||
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('debiture', DB::raw('LOWER(name)'), 'LIKE', '%' . strtolower($search->search) . '%');
|
||||
$q->orWhereRelation('jenisFasilitasKredit', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhere('status', 'LIKE', '%' . $search->search . '%');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Apply sorting if provided
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
}
|
||||
|
||||
// Get the total count of records
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Apply pagination if provided
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = $request->get('page');
|
||||
$size = $request->get('size');
|
||||
$offset = ($page - 1) * $size; // Calculate the offset
|
||||
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get the filtered count of records
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->with(['debiture.branch'])->get();
|
||||
|
||||
$data = $data->map(function ($permohonan) {
|
||||
$luas_tanah = 0;
|
||||
$luas_bangunan = 0;
|
||||
$nilai_tanah = 0;
|
||||
$nilai_bangunan = 0;
|
||||
$npw = 0;
|
||||
$nilai_liquidasi = 0;
|
||||
|
||||
if (isset($permohonan->penilai->lpj)) {
|
||||
$lpj = json_decode($permohonan->penilai->lpj, true);
|
||||
$npw = str_replace('.', '', $lpj['total_nilai_pasar_wajar'] ?? 0);
|
||||
|
||||
$luas_tanah = $lpj['luas_tanah'] ?? 0;
|
||||
$luas_bangunan = $lpj['luas_bangunan'] ?? 0;
|
||||
// Calculate nilai_tanah dynamically by looking for all keys that start with 'nilai_tanah_'
|
||||
$nilai_tanah = str_replace('.', '', $lpj['nilai_tanah_2'] ?? 0);
|
||||
|
||||
$nilai_bangunan = str_replace('.', '', $lpj['nilai_bangunan_2'] ?? 0);
|
||||
$nilai_liquidasi = str_replace('.', '', $lpj['likuidasi_nilai_2'] ?? 0);
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $permohonan->id,
|
||||
'nomor_registrasi' => $permohonan->nomor_registrasi,
|
||||
'jenis_penilaian' => $permohonan->jenisPenilaian?->name,
|
||||
'tujuan_penilaian' => $permohonan->tujuanPenilaian?->name,
|
||||
'jenis_fasilitas_kredit' => $permohonan->jenisFasilitasKredit?->name,
|
||||
'branch' => $permohonan->debiture->branch?->name,
|
||||
'pemohon' => $permohonan->creator?->name,
|
||||
'cif' => $permohonan->debiture->cif,
|
||||
'name' => $permohonan->debiture?->name,
|
||||
'jenis_agunan' => $permohonan->documents?->pluck('jenisJaminan.name')
|
||||
->unique()
|
||||
->implode(', '),
|
||||
'alamat_agunan' => $permohonan->documents?->map(function ($document) {
|
||||
return formatAlamat($document);
|
||||
})->unique()->implode(', '),
|
||||
'bukti_kepemilikan' => (function () use ($permohonan) {
|
||||
$legalitasItems = $permohonan->documents?->flatMap(function ($document) {
|
||||
return $document->detail->map(function ($detail) {
|
||||
// Jika tidak ada jenis legalitas jaminan, lewati
|
||||
if (empty($detail->jenisLegalitasJaminan)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Hanya tampilkan detail yang memiliki dokumen_jaminan
|
||||
if (empty($detail->dokumen_jaminan)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Tampilkan nama legalitas jaminan saja
|
||||
return $detail->jenisLegalitasJaminan->name ?? '';
|
||||
});
|
||||
})->filter()->unique()->values()->toArray();
|
||||
|
||||
// Buat daftar bernomor
|
||||
$result = '';
|
||||
foreach ($legalitasItems as $index => $item) {
|
||||
$result .= ($index + 1) . '. ' . $item . "\n";
|
||||
}
|
||||
|
||||
return $result;
|
||||
})(),
|
||||
'nama_pemilik' => $permohonan->documents?->pluck('pemilik.name')
|
||||
->unique()
|
||||
->implode(', '),
|
||||
'luas_tanah' => $luas_tanah . ' m²',
|
||||
'nilai_tanah' => formatRupiah($nilai_tanah, 2),
|
||||
'luas_bangunan' => $luas_bangunan . ' m²',
|
||||
'nilai_bangunan' => formatRupiah($nilai_bangunan, 2),
|
||||
'nilai_njop' => formatRupiah($permohonan->nilai_njop, 2),
|
||||
'nilai_pasar_wajar' => formatRupiah($npw, 2),
|
||||
'nilai_likuidasi' => formatRupiah($nilai_liquidasi, 2),
|
||||
'tanggal_documen_diterima' => $permohonan->documents?->map(function ($document) {
|
||||
return $document->created_at->format('d-m-Y');
|
||||
}),
|
||||
'tanggal_spk' => '',
|
||||
'nomor_spk' => '',
|
||||
'tanggal_rencana_kunjunagn' => '',
|
||||
'tanggal_kunjungan' => '',
|
||||
'taggal_delivered' => '',
|
||||
'jangka_waktu_sla' => '',
|
||||
'nama_penilai' => $permohonan->penilaian?->_user_penilai?->userPenilaiTeam?->name,
|
||||
'nama_team_leader' => $permohonan->penilaian?->teams,
|
||||
'saran' => '',
|
||||
'catatan' => '',
|
||||
|
||||
|
||||
'tanggal_permohonan' => $permohonan->tanggal_permohonan,
|
||||
'tanggal_laporan' => $permohonan->approval_dd_at ?? $permohonan->approval_eo_at ?? '',
|
||||
'tanggal_review' => $permohonan->penilaian?->tanggal_kunjungan ?? '',
|
||||
];
|
||||
});
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||
|
||||
// Calculate the current page number
|
||||
$currentPage = $request->get('page') ?: 1;
|
||||
|
||||
// Return the response data as a JSON object
|
||||
return response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
return Excel::download(new LaporanHasilPenilaianJaminanInternalExternalExport($request), 'laporan_hasil_penilaian_jaminan_internal_external.xlsx');
|
||||
}
|
||||
}
|
||||
43
app/Http/Controllers/LaporanMonitoringSoController.php
Normal file
43
app/Http/Controllers/LaporanMonitoringSoController.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Lpj\Services\LaporanMonitoringSoService;
|
||||
|
||||
class LaporanMonitoringSoController extends Controller
|
||||
{
|
||||
|
||||
private $laporanMonitoringSoService;
|
||||
|
||||
public function __construct(LaporanMonitoringSoService $laporanMonitoringSoService)
|
||||
{
|
||||
$this->laporanMonitoringSoService = $laporanMonitoringSoService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$user = auth()->user()->load('roles');
|
||||
$result = $this->laporanMonitoringSoService->progresPengerjaanLaporan($user);
|
||||
return view('lpj::laporan-monitoring.index', compact('result'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show details data.
|
||||
* @return Response
|
||||
*/
|
||||
|
||||
public function show($id){
|
||||
return view('lpj::laporan-monitoring.show', compact('id'));
|
||||
}
|
||||
|
||||
|
||||
public function dataForDatatablePenilai(Request $request, $id){
|
||||
return $this->laporanMonitoringSoService->showDetailsPermohonan($request, $id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,10 @@ use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\StatusPermohonan;
|
||||
use Modules\Lpj\Exports\LaporanPenilaiJaminanExport;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Lpj\Models\Branch;
|
||||
use Modules\Lpj\Services\PreviewLaporanService;
|
||||
use Modules\Lpj\Models\Inspeksi;
|
||||
use Modules\Lpj\Models\Penilai;
|
||||
|
||||
class LaporanPenilaiJaminanController extends Controller
|
||||
{
|
||||
@@ -16,59 +20,31 @@ class LaporanPenilaiJaminanController extends Controller
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
|
||||
protected $previewLaporanService;
|
||||
|
||||
public function __construct(PreviewLaporanService $previewLaporanService)
|
||||
{
|
||||
$this->previewLaporanService = $previewLaporanService;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$status_permohonan = StatusPermohonan::all();
|
||||
return view('lpj::laporan-penilai-jaminan.index', compact('status_permohonan'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('lpj::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
public function show($permohonan_id, $dokumen_id, $jaminan_id)
|
||||
{
|
||||
return view('lpj::laporan-penilai-jaminan.show');
|
||||
$back = route('laporan-penilai-jaminan.index');
|
||||
return $this->previewLaporanService->previewLaporan($permohonan_id, $dokumen_id, $jaminan_id, $back);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('lpj::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
@@ -93,91 +69,104 @@ class LaporanPenilaiJaminanController extends Controller
|
||||
// dd($startDate);
|
||||
// Retrieve data from the database
|
||||
$query = Permohonan::query();
|
||||
|
||||
$query = $query->where('status', 'done')->orderBy('tanggal_permohonan', 'desc');
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
$paramsSearch = json_decode($search);
|
||||
$search = json_decode($request->get('search'));
|
||||
|
||||
if (!empty($search->start_date) || !empty($search->end_date)) {
|
||||
$startDate = $search->start_date ?? '1900-01-01';
|
||||
$endDate = $search->end_date ?? now()->toDateString();
|
||||
|
||||
$query->where(function ($q) use ($startDate, $endDate) {
|
||||
|
||||
$q->whereHas('penilaian', function ($q2) use ($startDate, $endDate) {
|
||||
$q2->whereBetween('tanggal_kunjungan', [$startDate, $endDate]);
|
||||
});
|
||||
|
||||
// OR check if has penawaran with date in range
|
||||
$q->orWhereHas('penawaran', function ($q3) use ($startDate, $endDate) {
|
||||
$q3->whereBetween('tanggal_penilaian_sebelumnya', [$startDate, $endDate]);
|
||||
});
|
||||
});
|
||||
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%')
|
||||
->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%')
|
||||
->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%')
|
||||
->orWhereRelation('debiture', 'name', 'LIKE', '%' . $search . '%')
|
||||
->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%')
|
||||
->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||
|
||||
if (!empty($paramsSearch->tanggal_awal) && !empty($paramsSearch->tanggal_akhir)) {
|
||||
$q->whereBetween('tanggal_permohonan', [$paramsSearch->tanggal_awal, $paramsSearch->tanggal_akhir]);
|
||||
}
|
||||
|
||||
|
||||
$statusKeywords = explode(',', $search);
|
||||
foreach ($statusKeywords as $keyword) {
|
||||
$q->orWhereRelation('penilai', 'type_penilai', 'LIKE', '%' . trim($keyword) . '%');
|
||||
if (isset($search->branch_id) && !empty($search->branch_id)) {
|
||||
$query->where('branch_id', $search->branch_id);
|
||||
}
|
||||
|
||||
if (isset($search->laporan) && is_array($search->laporan) && !empty($search->laporan)) {
|
||||
foreach ($search->laporan as $type) {
|
||||
$query->whereHas('penilai', function ($q) use ($type) {
|
||||
$q->where('type_penilai', 'LIKE', '%' . $type . '%');
|
||||
});
|
||||
}
|
||||
$query->where('status', 'done');
|
||||
}
|
||||
|
||||
|
||||
// dd($search->search);
|
||||
|
||||
// Default sorting if no sort provided
|
||||
if (isset($search->search)) {
|
||||
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('debiture', DB::raw('LOWER(name)'), 'LIKE', '%' . strtolower($search->search) . '%');
|
||||
|
||||
$q->orWhereRelation('jenisFasilitasKredit', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhere('status', 'LIKE', '%' . $search->search . '%');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Apply sorting if provided
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
} else {
|
||||
$query->orderBy('nomor_registrasi', 'asc');
|
||||
}
|
||||
|
||||
// Get total count of records before pagination
|
||||
|
||||
// Get the total count of records
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Pagination
|
||||
// Apply pagination if provided
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = (int) $request->get('page', 1);
|
||||
$size = (int) $request->get('size', 10);
|
||||
$offset = ($page - 1) * $size;
|
||||
$page = $request->get('page');
|
||||
$size = $request->get('size');
|
||||
$offset = ($page - 1) * $size; // Calculate the offset
|
||||
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get filtered count
|
||||
// Get the filtered count of records
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
|
||||
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Pagination
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = (int) $request->get('page', 1);
|
||||
$size = (int) $request->get('size', 10);
|
||||
$offset = ($page - 1) * $size;
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get filtered count
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get data with necessary relationships
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian', 'dokumenjaminan.jenisJaminan','nilaiPlafond', 'penilai'])->get();
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian', 'dokumenjaminan.jenisJaminan','nilaiPlafond', 'penilai', 'dokumenjaminan.inspeksi'])->get();
|
||||
|
||||
// Calculate total pages
|
||||
$pageCount = ceil($totalRecords / $request->get('size', 10));
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $size);
|
||||
|
||||
// Calculate the current page number
|
||||
$currentPage = max(1, $request->get('page', 1));
|
||||
|
||||
|
||||
|
||||
// Calculate total pages
|
||||
$pageCount = ceil($totalRecords / $request->get('size', 10));
|
||||
|
||||
// Return the response data as a JSON object
|
||||
return response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $request->get('page', 1),
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
@@ -185,15 +174,53 @@ class LaporanPenilaiJaminanController extends Controller
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$tanggalAwal = $request->input('tanggal_awal');
|
||||
$tanggalAkhir = $request->input('tanggal_akhir');
|
||||
$status = $request->input('status');
|
||||
$selectedIds = $request->input('selected_ids');
|
||||
$startDate = $request->input('start_date');
|
||||
$endDate = $request->input('end_date');
|
||||
|
||||
// Validate the date format
|
||||
if (isset($startDate) && isset($endDate)) {
|
||||
$startDate = date('Y-m-d', strtotime($startDate));
|
||||
$endDate = date('Y-m-d', strtotime($endDate));
|
||||
|
||||
if ($startDate > $endDate) {
|
||||
return redirect()->back()->with('error', 'Tanggal awal tidak boleh lebih kecil dari tanggal akhir');
|
||||
}
|
||||
}
|
||||
// name the file
|
||||
$filename = $this->createNameLaporan($request);
|
||||
|
||||
$filename = 'laporan_penilai_jaminan_' . date('YmdHis') . '.xlsx';
|
||||
return Excel::download(
|
||||
new LaporanPenilaiJaminanExport($tanggalAwal, $tanggalAkhir, $status, $selectedIds),
|
||||
new LaporanPenilaiJaminanExport($request),
|
||||
$filename
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function createNameLaporan($request)
|
||||
{
|
||||
$startDate = $request->start_date ?? null;
|
||||
$endDate = $request->end_date ?? null;
|
||||
$branchId = $request->branch_id ?? null;
|
||||
$laporan = $request->laporan ?? null;
|
||||
|
||||
// Initialize filename parts
|
||||
$parts = ['Laporan Penilai Jaminan'];
|
||||
if ($startDate && $endDate) {
|
||||
$parts[] = "{$startDate}_{$endDate}";
|
||||
}
|
||||
if ($laporan) {
|
||||
$parts[] = $laporan;
|
||||
}
|
||||
if ($branchId) {
|
||||
$parts[] = $this->getBranchId($branchId);
|
||||
}
|
||||
// Return concatenated filename with extension
|
||||
return implode('_', $parts) . '.xlsx';
|
||||
}
|
||||
|
||||
public function getBranchId($branchId)
|
||||
{
|
||||
$branchesName = Branch::find($branchId)->name ?? null;
|
||||
return $branchesName;
|
||||
}
|
||||
}
|
||||
|
||||
180
app/Http/Controllers/LaporanPenilaianJaminanController.php
Normal file
180
app/Http/Controllers/LaporanPenilaianJaminanController.php
Normal file
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Lpj\Exports\LaporanPenilaianJaminanExport;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\Penilaian;
|
||||
use Modules\Lpj\Models\PenawaranTender;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class LaporanPenilaianJaminanController extends Controller
|
||||
{
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('lpj::laporan_penilaian_jaminan.index');
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('laporan-admin-kredit.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view laporan admin kredit.');
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = Permohonan::query();
|
||||
$query = $query->where('status', 'done');
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = json_decode($request->get('search'));
|
||||
|
||||
|
||||
if (!empty($search->start_date) || !empty($search->end_date)) {
|
||||
$startDate = $search->start_date ?? '1900-01-01';
|
||||
$endDate = $search->end_date ?? now()->toDateString();
|
||||
|
||||
$query->where(function ($q) use ($startDate, $endDate) {
|
||||
$q->whereHas('penilaian', function ($q2) use ($startDate, $endDate) {
|
||||
$q2->whereBetween('tanggal_kunjungan', [$startDate, $endDate]);
|
||||
})
|
||||
->orWhereHas('penawaran', function ($q3) use ($startDate, $endDate) {
|
||||
$q3->whereBetween('tanggal_penilaian_sebelumnya', [$startDate, $endDate]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Filter by branch if provided
|
||||
if (isset($search->branch_id) && !empty($search->branch_id)) {
|
||||
$query->where('branch_id', $search->branch_id);
|
||||
}
|
||||
|
||||
if (isset($search->penilai_id) && !empty($search->penilai_id)) {
|
||||
$query->whereHas('penilaian._user_penilai.userPenilaiTeam', function ($q) use ($search) {
|
||||
$q->where('user_id', $search->penilai_id);
|
||||
});
|
||||
}
|
||||
|
||||
if (isset($search->search)) {
|
||||
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('debiture', DB::raw('LOWER(name)'), 'LIKE', '%' . strtolower($search->search) . '%');
|
||||
|
||||
$q->orWhereRelation('jenisFasilitasKredit', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhere('status', 'LIKE', '%' . $search->search . '%');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Apply sorting if provided
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
}
|
||||
|
||||
// Get the total count of records
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Apply pagination if provided
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = $request->get('page');
|
||||
$size = $request->get('size');
|
||||
$offset = ($page - 1) * $size; // Calculate the offset
|
||||
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get the filtered count of records
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->with(['debiture.branch'])->get();
|
||||
|
||||
$data = $data->map(function ($permohonan) {
|
||||
$luas_tanah = 0;
|
||||
$luas_bangunan = 0;
|
||||
$nilai_tanah = 0;
|
||||
$nilai_bangunan = 0;
|
||||
$npw = 0;
|
||||
$nilai_liquidasi = 0;
|
||||
if (isset($permohonan->penilai->lpj)) {
|
||||
$lpj = json_decode($permohonan->penilai->lpj, true);
|
||||
$npw = str_replace('.', '', $lpj['total_nilai_pasar_wajar'] ?? 0);
|
||||
|
||||
$luas_tanah = $lpj['luas_tanah'] ?? 0;
|
||||
$luas_bangunan = $lpj['luas_bangunan'] ?? 0;
|
||||
// Calculate nilai_tanah dynamically by looking for all keys that start with 'nilai_tanah_'
|
||||
$nilai_tanah = str_replace('.', '', $lpj['nilai_tanah_2'] ?? 0);
|
||||
|
||||
$nilai_bangunan = str_replace('.', '', $lpj['nilai_bangunan_2'] ?? 0);
|
||||
$nilai_liquidasi = str_replace('.', '', $lpj['likuidasi_nilai_2'] ?? 0);
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $permohonan->id,
|
||||
'nomor_registrasi' => $permohonan->nomor_registrasi,
|
||||
'tanggal_permohonan' => $permohonan->tanggal_permohonan,
|
||||
'branch' => $permohonan->debiture?->branch?->name,
|
||||
'name' => $permohonan->debiture?->name,
|
||||
'pemohon' => $permohonan->creator?->name,
|
||||
'tujuan_penilaian' => $permohonan->tujuanPenilaian?->name,
|
||||
'jenis_agunan' => $permohonan->documents?->pluck('jenisJaminan.name')->unique()->implode(', '),
|
||||
'alamat_agunan' => $permohonan->documents?->map(function ($document) {
|
||||
return formatAlamat($document);
|
||||
})->unique()->implode(', '),
|
||||
'luas_tanah' => $luas_tanah . ' m²',
|
||||
'nilai_tanah' => formatRupiah($nilai_tanah, 2),
|
||||
'luas_bangunan' => $luas_bangunan . ' m²',
|
||||
'nilai_bangunan' => formatRupiah($nilai_bangunan, 2),
|
||||
'tanggal_laporan' => $permohonan->approval_dd_at ?? $permohonan->approval_eo_at ?? '',
|
||||
'tanggal_review' => $permohonan->penilaian?->tanggal_kunjungan ?? '',
|
||||
'nilai_pasar_wajar' => formatRupiah($npw, 2),
|
||||
'nilai_likuidasi' => formatRupiah($nilai_liquidasi, 2),
|
||||
'nama_penilai' => $permohonan->penilaian?->_user_penilai?->userPenilaiTeam?->name,
|
||||
];
|
||||
});
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||
|
||||
// Calculate the current page number
|
||||
$currentPage = $request->get('page', 1);
|
||||
|
||||
// Return the response data as a JSON object
|
||||
return response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$startDate = $request->start_date;
|
||||
$endDate = $request->end_date;
|
||||
// name of the file
|
||||
$fileName = 'laporan_penilaian_jaminan_' . $startDate . '_' . $endDate . '.xlsx';
|
||||
return Excel::download(new LaporanPenilaianJaminanExport($request), $fileName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
32
app/Http/Controllers/LaporanSLAPenilaiController.php
Normal file
32
app/Http/Controllers/LaporanSLAPenilaiController.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Lpj\Services\LaporanSLAPenilaiService;
|
||||
|
||||
class LaporanSLAPenilaiController extends Controller
|
||||
{
|
||||
private $laporanSLAPenilaiService;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->laporanSLAPenilaiService = app(LaporanSLAPenilaiService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('lpj::laporan-sla-penilai.index');
|
||||
}
|
||||
|
||||
public function dataForDatatableSLaPenilai(Request $request)
|
||||
{
|
||||
return $this->laporanSLAPenilaiService->dataForDatatables($request);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
51
app/Http/Controllers/LaporanUserController.php
Normal file
51
app/Http/Controllers/LaporanUserController.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Lpj\Exports\LaporanUserLimitExport;
|
||||
use Modules\Lpj\Services\LaporanUserService;
|
||||
|
||||
class LaporanUserController extends Controller
|
||||
{
|
||||
|
||||
|
||||
private $laporanUserService;
|
||||
|
||||
public function __construct(LaporanUserService $laporanUserService)
|
||||
{
|
||||
$this->laporanUserService = $laporanUserService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// $user = $this->laporanUserService->getUserPemohon();
|
||||
return view('lpj::laporan-user.index');
|
||||
}
|
||||
|
||||
public function searchUserPemohon(Request $request)
|
||||
{
|
||||
$search = $request->get('search');
|
||||
$user = $this->laporanUserService->getUserPemohon($search);
|
||||
return response()->json($user);
|
||||
}
|
||||
|
||||
public function dataTableForUserPemohon(Request $request)
|
||||
{
|
||||
return $this->laporanUserService->dataForDatatables($request);
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$startDate = $request->start_date;
|
||||
$endDate = $request->end_date;
|
||||
// name of the file
|
||||
$fileName = 'laporan_user_limit' . $startDate . '_' . $endDate . '.xlsx';
|
||||
return Excel::download(new LaporanUserLimitExport($request), $fileName);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Modules\Lpj\Http\Requests\NocRequest;
|
||||
use Modules\Lpj\Models\Noc;
|
||||
use Modules\Lpj\Models\PenawaranTender;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\PersetujuanPenawaran;
|
||||
@@ -18,9 +19,20 @@
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return redirect()->route('noc.pembayaran.index');
|
||||
}
|
||||
|
||||
public function pembayaran()
|
||||
{
|
||||
$persetujuanPenawarans = PersetujuanPenawaran::all();
|
||||
return view('lpj::noc.index', compact('persetujuanPenawarans'));
|
||||
return view('lpj::noc.pembayaran', compact('persetujuanPenawarans'));
|
||||
}
|
||||
|
||||
public function penyelesaian()
|
||||
{
|
||||
$persetujuanPenawarans = PersetujuanPenawaran::all();
|
||||
return view('lpj::noc.penyelesaian', compact('persetujuanPenawarans'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,26 +55,35 @@
|
||||
$status = "persetujuan-penawaran";
|
||||
}
|
||||
|
||||
$persetujuanPenawaran = PersetujuanPenawaran::updateOrCreate(
|
||||
['penawaran_id' => $validated['penawaran_id']],
|
||||
$validated,
|
||||
|
||||
$dataNoc = [
|
||||
'nominal_bayar' => $validated['nominal_bayar'],
|
||||
'tanggal_pembayaran' => $validated['tanggal_pembayaran'] ?? date('Y-m-d'),
|
||||
'status_bayar' => $validated['nominal_bayar'] < $validated['total_harus_bayar'] ? false : true,
|
||||
'catatan_noc' => $validated['catatan_noc'],
|
||||
];
|
||||
$noc = Noc::updateOrCreate(
|
||||
[
|
||||
'permohonan_id' => $validated['permohonan_id'],
|
||||
'persetujuan_penawaran_id' => $validated['persetujuan_penawaran_id'],
|
||||
],
|
||||
$dataNoc,
|
||||
);
|
||||
|
||||
$folderPath = 'noc/' . $validated['penawaran_id'];
|
||||
$folderPath = 'noc/' . request()->get('persetujuan_penawaran_id') . '/bukti_ksl/';
|
||||
|
||||
if ($request->hasFile('bukti_ksl')) {
|
||||
$persetujuanPenawaran->bukti_ksl = $request->file('bukti_ksl')->store(
|
||||
$noc->bukti_ksl = $request->file('bukti_ksl')->store(
|
||||
$folderPath,
|
||||
'public',
|
||||
);
|
||||
}
|
||||
$noc->save();
|
||||
|
||||
$persetujuanPenawaran->save();
|
||||
|
||||
// Update the status of the related permohonan to 'spk'
|
||||
/* Update the status of the related permohonan to 'spk'
|
||||
$permohonan = Permohonan::find(request()->get('permohonan_id'));
|
||||
if ($permohonan) {
|
||||
$permohonan->status_bayar = request()->get('status_bayar');
|
||||
$permohonan->status_bayar = request()->get('status_pembayar');
|
||||
if ($permohonan->jenis_penilaian_id == 2) {
|
||||
$permohonan->status = $status;
|
||||
}
|
||||
@@ -78,10 +99,10 @@
|
||||
]);
|
||||
}
|
||||
// andy add, update status penawaran.status='spk'
|
||||
}
|
||||
}*/
|
||||
|
||||
return redirect()
|
||||
->route('noc.index')->with('success', 'Penyelesaian KSL berhasil disimpan.');
|
||||
->route('noc.index')->with('success', 'NOC berhasil disimpan.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,12 +111,57 @@
|
||||
public function update(NocRequest $request, PersetujuanPenawaran $persetujuanPenawaran)
|
||||
{
|
||||
$validated = $request->validated();
|
||||
$validated['updated_by'] = Auth::id();
|
||||
|
||||
$persetujuanPenawaran->update($validated);
|
||||
if($request->get('is_memo')){
|
||||
|
||||
$memo = Noc::find($request->get('is_memo'));
|
||||
|
||||
$folderPath = 'noc/' . request()->get('persetujuan_penawaran_id') . '/memo_penyelesaian/';
|
||||
|
||||
if ($request->hasFile('memo_penyelesaian')) {
|
||||
$memo->memo_penyelesaian = $request->file('memo_penyelesaian')->store(
|
||||
$folderPath,
|
||||
'public',
|
||||
);
|
||||
}
|
||||
|
||||
$memo->catatan_noc = $validated['catatan_noc'];
|
||||
$memo->save();
|
||||
|
||||
|
||||
return redirect()
|
||||
->route('noc.index')->with('success', 'Persetujuan Penawaran updated successfully');
|
||||
->route('laporan.index')->with('success', 'Memo Penyelesaian updated successfully');
|
||||
}
|
||||
$dataNoc = [
|
||||
'nominal_penyelesaian' => $validated['nominal_penyelesaian'],
|
||||
'tanggal_penyelesaian' => $validated['tanggal_penyelesaian'] ?? date('Y-m-d'),
|
||||
'status_pelunasan' => ((int)$validated['nominal_bayar'] + (int)$validated['nominal_penyelesaian']) === (int)$validated['total_harus_bayar'] ? true : false,
|
||||
'catatan_noc' => $validated['catatan_noc'],
|
||||
];
|
||||
|
||||
|
||||
$noc = Noc::updateOrCreate(
|
||||
[
|
||||
'permohonan_id' => $validated['permohonan_id'],
|
||||
'permohonan_id' => $validated['permohonan_id'],
|
||||
'persetujuan_penawaran_id' => $validated['persetujuan_penawaran_id'],
|
||||
],
|
||||
$dataNoc,
|
||||
);
|
||||
|
||||
$folderPath = 'noc/' . request()->get('persetujuan_penawaran_id') . '/bukti_penyelesaian/';
|
||||
|
||||
if ($request->hasFile('bukti_penyelesaian')) {
|
||||
$noc->bukti_penyelesaian = $request->file('bukti_penyelesaian')->store(
|
||||
$folderPath,
|
||||
'public',
|
||||
);
|
||||
}
|
||||
$noc->save();
|
||||
|
||||
|
||||
return redirect()
|
||||
->route('noc.index')->with('success', 'NOC updated successfully');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,16 +175,16 @@
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show($id) {}
|
||||
public function show(Noc $noc) {
|
||||
return view('lpj::noc.memo', compact('noc'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$persetujuanPenawaran = PersetujuanPenawaran::where('id', $id)->with(
|
||||
['penawaran.detail', 'penawaran.permohonan.debiture','permohonan'],
|
||||
)->first();
|
||||
$persetujuanPenawaran = PersetujuanPenawaran::where('id', $id)->first();
|
||||
return view('lpj::noc.form', compact('persetujuanPenawaran'));
|
||||
}
|
||||
|
||||
@@ -134,6 +200,12 @@
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
// Redirect to pembayaran datatables by default
|
||||
return $this->dataForDatatablesPembayaran($request);
|
||||
}
|
||||
|
||||
public function dataForDatatablesPembayaran(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('noc.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view persetujuan penawaran.');
|
||||
@@ -142,6 +214,11 @@
|
||||
// Retrieve data from the database
|
||||
$query = PersetujuanPenawaran::query();
|
||||
|
||||
// Filter for pembayaran (where memo_penyelesaian is null)
|
||||
$query->whereDoesntHave('noc', function($q) {
|
||||
$q->whereNotNull('memo_penyelesaian');
|
||||
});
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
@@ -173,18 +250,122 @@
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query
|
||||
->with(
|
||||
[
|
||||
'penawaran.permohonan.debiture',
|
||||
'penawaran.permohonan.branch',
|
||||
'permohonan.debiture',
|
||||
'permohonan.branch',
|
||||
'penawaran.detail',
|
||||
'penawaran.persetujuan',
|
||||
],
|
||||
)->get();
|
||||
$data = $query->get();
|
||||
|
||||
$data = $data->map(function ($persetujuanPenawaran) {
|
||||
return [
|
||||
'id' => $persetujuanPenawaran->id,
|
||||
'nomor_registrasi' => $persetujuanPenawaran->permohonan->nomor_registrasi ?? $persetujuanPenawaran->penawaran->nomor_registrasi,
|
||||
'nama_debitur' => $persetujuanPenawaran->permohonan->debiture->name ?? $persetujuanPenawaran->penawaran->permohonan->debiture->name,
|
||||
'cabang' => $persetujuanPenawaran->permohonan->branch->name ?? $persetujuanPenawaran->penawaran->permohonan->branch->name,
|
||||
'tanggal_pembayaran' => dateFormat(
|
||||
$persetujuanPenawaran->noc->tanggal_pembayaran ?? $persetujuanPenawaran->noc?->created_at,
|
||||
true,
|
||||
),
|
||||
'nominal_bayar' => currencyFormat($persetujuanPenawaran->nominal_bayar ?? 0,
|
||||
),
|
||||
'nominal_diterima' => currencyFormat(
|
||||
$persetujuanPenawaran->noc->nominal_bayar ?? 0,
|
||||
),
|
||||
'bukti_ksl' => $persetujuanPenawaran->noc->bukti_ksl ?? $persetujuanPenawaran->bukti_ksl ?? null,
|
||||
'bukti_bayar' => $persetujuanPenawaran->bukti_bayar ?? null,
|
||||
'updated_at' => dateFormat($persetujuanPenawaran->updated_at, true),
|
||||
];
|
||||
})->sortBy('updated_at', 1);
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||
|
||||
// Calculate the current page number
|
||||
$currentPage = $request->get('page', 1);
|
||||
|
||||
// Return the response data as a JSON object
|
||||
return response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
public function dataForDatatablesPenyelesaian(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('noc.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view persetujuan penawaran.');
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = PersetujuanPenawaran::query();
|
||||
|
||||
// Filter for penyelesaian (where memo_penyelesaian is not null)
|
||||
$query->whereHas('noc', function($q) {
|
||||
$q->whereNotNull('memo_penyelesaian');
|
||||
});
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->orWhereRelation('penawaran', 'nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||
});
|
||||
}
|
||||
|
||||
// Apply sorting if provided
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
}
|
||||
|
||||
// Get the total count of records
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Apply pagination if provided
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = $request->get('page');
|
||||
$size = $request->get('size');
|
||||
$offset = ($page - 1) * $size; // Calculate the offset
|
||||
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get the filtered count of records
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->get();
|
||||
|
||||
$data = $data->map(function ($persetujuanPenawaran) {
|
||||
return [
|
||||
'id' => $persetujuanPenawaran->id,
|
||||
'nomor_registrasi' => $persetujuanPenawaran->permohonan->nomor_registrasi ?? $persetujuanPenawaran->penawaran->nomor_registrasi,
|
||||
'nama_debitur' => $persetujuanPenawaran->permohonan->debiture->name ?? $persetujuanPenawaran->penawaran->permohonan->debiture->name,
|
||||
'cabang' => $persetujuanPenawaran->permohonan->branch->name ?? $persetujuanPenawaran->penawaran->permohonan->branch->name,
|
||||
'tanggal_pembayaran' => dateFormat(
|
||||
$persetujuanPenawaran->noc->tanggal_pembayaran ?? $persetujuanPenawaran->noc?->created_at,
|
||||
true,
|
||||
),
|
||||
'nominal_bayar' => currencyFormat($persetujuanPenawaran->nominal_bayar ?? 0,
|
||||
),
|
||||
'nominal_diterima' => currencyFormat(
|
||||
$persetujuanPenawaran->noc->nominal_bayar ?? 0,
|
||||
),
|
||||
'bukti_ksl' => $persetujuanPenawaran->noc->bukti_ksl ?? $persetujuanPenawaran->bukti_ksl ?? null,
|
||||
'bukti_bayar' => $persetujuanPenawaran->bukti_bayar ?? null,
|
||||
'memo_penyelesaian' => $persetujuanPenawaran->noc->memo_penyelesaian ?? $persetujuanPenawaran->memo_penyelesaian ?? null,
|
||||
'nominal_penyelesaian' => currencyFormat(
|
||||
$persetujuanPenawaran->noc->nominal_penyelesaian ?? $persetujuanPenawaran->nominal_penyelesaian ?? 0,
|
||||
),
|
||||
'bukti_penyelesaian' => $persetujuanPenawaran->noc->bukti_penyelesaian ?? $persetujuanPenawaran->bukti_penyelesaian ?? null,
|
||||
'tanggal_penyelesaian' => $persetujuanPenawaran->noc?->tanggal_penyelesaian ? dateFormat(
|
||||
$persetujuanPenawaran->noc?->tanggal_penyelesaian,
|
||||
true) : '-',
|
||||
'updated_at' => dateFormat($persetujuanPenawaran->updated_at, true),
|
||||
];
|
||||
})->sortBy('updated_at', 1);
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||
|
||||
@@ -263,8 +263,7 @@ class PembayaranController extends Controller
|
||||
$subquery->select('permohonan_id')
|
||||
->from('persetujuan_penawaran')
|
||||
->whereNotNull('permohonan_id');
|
||||
})
|
||||
->orWhere('status', 'revisi-pembayaran');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -26,18 +26,21 @@ use Modules\Lpj\Http\Requests\FormSurveyorRequest;
|
||||
use Modules\Lpj\Models\Authorization;
|
||||
use Modules\Lpj\Models\Debiture;
|
||||
use Modules\Lpj\Services\SaveFormInspesksiService;
|
||||
use Modules\Lpj\Services\PreviewLaporanService;
|
||||
|
||||
class PenilaiController extends Controller
|
||||
{
|
||||
public $user;
|
||||
protected $surveyorController;
|
||||
protected $inspeksiService;
|
||||
protected $previewLaporanService;
|
||||
|
||||
|
||||
public function __construct(SurveyorController $surveyorController, SaveFormInspesksiService $inspeksiService)
|
||||
public function __construct(SurveyorController $surveyorController, SaveFormInspesksiService $inspeksiService, PreviewLaporanService $previewLaporanService)
|
||||
{
|
||||
$this->surveyorController = $surveyorController;
|
||||
$this->inspeksiService = $inspeksiService;
|
||||
$this->previewLaporanService = $previewLaporanService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,6 +155,11 @@ class PenilaiController extends Controller
|
||||
$jaminanId = $request->query('jaminanId');
|
||||
|
||||
$permohonan = $this->surveyorController->getPermohonanJaminanId($id, $documentId, $jaminanId);
|
||||
|
||||
if ($permohonan->status == 'proses-laporan') {
|
||||
return redirect()->back()->with('error', 'Masih dalam proses laporan');
|
||||
}
|
||||
|
||||
$basicData = $this->surveyorController->getCommonData();
|
||||
$noLpSederhana = $this->generateNoLaporan($permohonan, $documentId, 'lpj');
|
||||
|
||||
@@ -218,6 +226,11 @@ class PenilaiController extends Controller
|
||||
$jaminanId = $request->query('jaminanId');
|
||||
|
||||
$permohonan = $this->surveyorController->getPermohonanJaminanId($permohonanId, $documentId, $jaminanId);
|
||||
|
||||
if ($permohonan->status == 'proses-laporan') {
|
||||
return redirect()->back()->with('error', 'Masih dalam proses laporan');
|
||||
}
|
||||
|
||||
$nomorLaporan = $this->generateNoLaporan($permohonan, $documentId, 'resume');
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
|
||||
$noLpresume = $this->generateNoLaporan($permohonan, $documentId, 'resume');
|
||||
@@ -253,6 +266,9 @@ class PenilaiController extends Controller
|
||||
|
||||
$data = $this->getDataPermohonanWithPenilaiAndInspeksi($req['permohonanId'], $req['documentId'], $req['jaminanId']);
|
||||
$permohonan = $data['permohonan'];
|
||||
if ($permohonan->status == 'proses-laporan') {
|
||||
return redirect()->back()->with('error', 'Masih dalam proses laporan');
|
||||
}
|
||||
|
||||
$nomorLaporan = $this->generateNoLaporan($permohonan, $req['documentId'], 'memo');
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $req['permohonanId'])->where('dokument_id', $req['documentId'])->first();
|
||||
@@ -392,6 +408,11 @@ class PenilaiController extends Controller
|
||||
$jaminanId = $request->query('jaminanId');
|
||||
$provinces = Province::all();
|
||||
$permohonan = $this->surveyorController->getPermohonanJaminanId($permohonanId, $documentId, $jaminanId);
|
||||
|
||||
if ($permohonan->status == 'proses-laporan') {
|
||||
return redirect()->back()->with('error', 'Masih dalam proses laporan');
|
||||
}
|
||||
|
||||
$nomorLaporan = $this->generateNoLaporan($permohonan, $documentId, 'rap');
|
||||
$basicData = $this->surveyorController->getCommonData();
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
|
||||
@@ -470,6 +491,9 @@ class PenilaiController extends Controller
|
||||
$jaminanId = $request->query('jaminanId');
|
||||
$provinces = Province::all();
|
||||
$permohonan = $this->surveyorController->getPermohonanJaminanId($permohonanId, $documentId, $jaminanId);
|
||||
if ($permohonan->status == 'proses-laporan') {
|
||||
return redirect()->back()->with('error', 'Masih dalam proses laporan');
|
||||
}
|
||||
$nomorLaporan = $this->generateNoLaporan($permohonan, $documentId, 'call-report');
|
||||
$basicData = $this->surveyorController->getCommonData();
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
|
||||
@@ -527,13 +551,7 @@ class PenilaiController extends Controller
|
||||
return view('lpj::penilai.components.call-report', compact('permohonan', 'basicData', 'nomorLaporan', 'forminspeksi', 'cities', 'districts', 'villages', 'cekAlamat', 'callReport'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
@@ -679,6 +697,7 @@ class PenilaiController extends Controller
|
||||
'lokasi_lengkap' => $data->lokasi_lengkap ?? '',
|
||||
];
|
||||
|
||||
if(isset($dataPembanding)){
|
||||
// Extract data pembanding
|
||||
if (isset($dataPembanding['data_pembanding'])) {
|
||||
foreach ($dataPembanding['data_pembanding'] as $index => $pembanding) {
|
||||
@@ -691,6 +710,7 @@ class PenilaiController extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now create the export
|
||||
// return response()->json([ 'data' => $fotoForm]);
|
||||
@@ -1104,8 +1124,7 @@ class PenilaiController extends Controller
|
||||
$penilai = Penilai::updateOrCreate(
|
||||
[
|
||||
'permohonan_id' => $request->permohonanId,
|
||||
'dokument_id' => $request->documentId,
|
||||
|
||||
'dokument_id' => $request->input('dokument_id'),
|
||||
],
|
||||
[
|
||||
'lpj' => json_encode($data),
|
||||
@@ -1132,20 +1151,9 @@ class PenilaiController extends Controller
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$formRequest = new FormSurveyorRequest();
|
||||
$formRequest->setContainer(app());
|
||||
$formRequest->initialize(
|
||||
$request->all(),
|
||||
$request->query->all(),
|
||||
$request->attributes->all(),
|
||||
$request->cookies->all(),
|
||||
$request->files->all(),
|
||||
$request->server->all(),
|
||||
$request->getContent()
|
||||
);
|
||||
|
||||
$validated = $formRequest->validateResolved();
|
||||
$result = $this->surveyorController->store($formRequest);
|
||||
$validatedData = $request->all();
|
||||
$result = $this->inspeksiService->storeInspeksi($validatedData, $request->input('type'), $request);
|
||||
|
||||
$data = [
|
||||
'kepada' => $request->input('kepada'),
|
||||
@@ -1268,132 +1276,13 @@ class PenilaiController extends Controller
|
||||
|
||||
|
||||
|
||||
public function print_out(Request $request)
|
||||
public function print_out_laporan($permohonan_id, $document_id, $jaminan_id)
|
||||
{
|
||||
$documentId = $request->query('documentId');
|
||||
$jaminanId = $request->query('jaminanId');
|
||||
$permohonanId = $request->query('permohonanId');
|
||||
$statusLpj = $request->query('statusLpj');
|
||||
$tipeLaporan = $request->query('type');
|
||||
|
||||
$permohonan = $this->surveyorController->getPermohonanJaminanId(
|
||||
$permohonanId,
|
||||
$documentId,
|
||||
$jaminanId
|
||||
);
|
||||
|
||||
$basicData = $this->surveyorController->getCommonData();
|
||||
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
|
||||
$lpj = Penilai::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
|
||||
|
||||
$nomorLaporan = getNomorLaporan($permohonanId, $documentId);
|
||||
$tanggalLaporan = $lpj->created_at ?? null;
|
||||
$forminspeksi = null;
|
||||
$lpjData = null;
|
||||
$formFoto = null;
|
||||
|
||||
if ($inspeksi) {
|
||||
$forminspeksi = json_decode($inspeksi->data_form, true);
|
||||
$formFoto = json_decode($inspeksi->foto_form, true);
|
||||
// $denahForm = json_decode($data->denah_form, true);
|
||||
$dataPembanding = json_decode($inspeksi->data_pembanding, true);
|
||||
// jika tidak ada id kembalikan ke halaman sebelumnya
|
||||
if (!$permohonan_id || !$document_id || !$jaminan_id) {
|
||||
return redirect()->back()->with('error', 'Laporan tidak valid');
|
||||
}
|
||||
|
||||
if ($lpj) {
|
||||
$lpjData = json_decode($lpj->lpj, true);
|
||||
$memo = json_decode($lpj->memo, true);
|
||||
$resumeData = json_decode($lpj->resume, true);
|
||||
$rap = json_decode($lpj->rap, true);
|
||||
$report = json_decode($lpj->call_report, true);
|
||||
}
|
||||
|
||||
$inputAddress = $forminspeksi['asset']['alamat']['sesuai'] ?? $forminspeksi['asset']['alamat']['tidak sesuai'] ?? [];
|
||||
|
||||
$alamat = [
|
||||
'address' => $inputAddress['address'] ?? null,
|
||||
'village_code' => getWilayahName($inputAddress['village_code'] ?? null, 'village'),
|
||||
'district_code' => getWilayahName($inputAddress['district_code'] ?? null, 'district'),
|
||||
'city_code' => getWilayahName($inputAddress['city_code'] ?? null, 'city'),
|
||||
'province_code' => getWilayahName($inputAddress['province_code'] ?? null, 'province')
|
||||
];
|
||||
|
||||
$viewLaporan = $this->getViewLaporan($tipeLaporan);
|
||||
try {
|
||||
|
||||
if ($statusLpj) {
|
||||
// $pdf = view('lpj::' . $viewLaporan, compact(
|
||||
$pdf = PDF::loadView('lpj::' . $viewLaporan, compact(
|
||||
'permohonan',
|
||||
'forminspeksi',
|
||||
'lpjData',
|
||||
'formFoto',
|
||||
'basicData',
|
||||
'inspeksi',
|
||||
'lpj',
|
||||
'statusLpj',
|
||||
'alamat',
|
||||
'dataPembanding',
|
||||
'nomorLaporan',
|
||||
'memo',
|
||||
'resumeData',
|
||||
'tanggalLaporan',
|
||||
'rap',
|
||||
'report'
|
||||
));
|
||||
// return $pdf;
|
||||
$cleanNomorLaporan = str_replace(['/', '\\'], '-', $nomorLaporan);
|
||||
$pdf->setPaper('A4', 'portrait');
|
||||
$pdf->set_option('isHtml5ParserEnabled', true);
|
||||
$pdf->set_option('isPhpEnabled', true);
|
||||
return response($pdf->output(), 200)
|
||||
->header('Content-Type', 'application/pdf')
|
||||
->header('Content-Disposition', 'inline; filename="Laporan_' . $tipeLaporan . '_' . $permohonan->debiture->name . '_' . $cleanNomorLaporan . '.pdf"');
|
||||
// return $pdf->stream();
|
||||
} else {
|
||||
// $pdf = view('lpj::' . $viewLaporan, compact(
|
||||
$pdf = PDF::loadView('lpj::' . $viewLaporan, compact(
|
||||
'permohonan',
|
||||
'forminspeksi',
|
||||
'lpjData',
|
||||
'formFoto',
|
||||
'basicData',
|
||||
'inspeksi',
|
||||
'lpj',
|
||||
'statusLpj',
|
||||
'alamat',
|
||||
'dataPembanding',
|
||||
'nomorLaporan',
|
||||
'memo',
|
||||
'resumeData',
|
||||
'tanggalLaporan',
|
||||
'rap',
|
||||
'report'
|
||||
));
|
||||
// return $pdf;
|
||||
$cleanNomorLaporan = str_replace(['/', '\\'], '-', $nomorLaporan);
|
||||
$pdf->setPaper('A4', 'portrait');
|
||||
$pdf->set_option('isHtml5ParserEnabled', true);
|
||||
$pdf->set_option('isPhpEnabled', true);
|
||||
return $pdf->download('Laporan_' . $tipeLaporan . '_' . $permohonan->debiture->name . '_' . $cleanNomorLaporan . '_data.pdf');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('PDF generation failed: ' . $e->getMessage());
|
||||
return response()->json(['error' => 'Failed to generate PDF. Please check the log for details.' . $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
private function getViewLaporan($tipe)
|
||||
{
|
||||
$viewMap = [
|
||||
'sederhana' => 'penilai.components.print-out-sederhana',
|
||||
'standar' => 'penilai.components.print-out-standar',
|
||||
'resume' => 'penilai.components.print-resume',
|
||||
'memo' => 'penilai.components.print-memo',
|
||||
'rap' => 'penilai.components.print-out-rap',
|
||||
'call-report' => 'penilai.components.print-out-call-report'
|
||||
];
|
||||
return $viewMap[$tipe] ?? 'penilai.components.print-resume';
|
||||
return $this->previewLaporanService->printOutLaporan($permohonan_id, $document_id, $jaminan_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -1410,7 +1299,7 @@ class PenilaiController extends Controller
|
||||
}
|
||||
|
||||
|
||||
// pengunaan request query by id permohonan, dokument, jaminan , inspeksi
|
||||
// pengunaan request query by id permohonan, documentId, jaminan , inspeksi
|
||||
protected function getRequestQueryId(Request $request)
|
||||
{
|
||||
return [
|
||||
@@ -1420,46 +1309,7 @@ class PenilaiController extends Controller
|
||||
];
|
||||
}
|
||||
|
||||
public function checkPrintOutLaporan(Request $request)
|
||||
{
|
||||
$permohonanId = $request->query('permohonanId');
|
||||
$documentId = $request->query('documentId');
|
||||
|
||||
// Ambil data berdasarkan ID
|
||||
$statusLpj = Penilai::where('permohonan_id', $permohonanId)
|
||||
->where('dokument_id', $documentId)
|
||||
->first();
|
||||
|
||||
// Jika data tidak ditemukan, kembalikan status null
|
||||
if (!$statusLpj) {
|
||||
return response()->json(['status' => null]);
|
||||
}
|
||||
|
||||
// Tentukan tipe berdasarkan kondisi
|
||||
$type = $statusLpj->type_penilai ?? null;
|
||||
|
||||
if ($type === 'memo') {
|
||||
return $this->checkDataMemo($type, $statusLpj);
|
||||
}
|
||||
|
||||
if ($type === 'resume') {
|
||||
return $this->checkDataResume($type, $statusLpj);
|
||||
}
|
||||
|
||||
|
||||
if ($type === 'standar' || $type === 'sederhana') {
|
||||
return $this->checkDataLpj($type, $statusLpj);
|
||||
}
|
||||
|
||||
if ($type === 'rap') {
|
||||
return $this->checkDataRap($type, $statusLpj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Kembalikan respons dengan tipe yang sesuai
|
||||
return response()->json(['status' => $type]);
|
||||
}
|
||||
|
||||
|
||||
public function generateNoLaporan($permohonan, $documentId, $type)
|
||||
@@ -1499,239 +1349,6 @@ class PenilaiController extends Controller
|
||||
}
|
||||
|
||||
|
||||
public function checkDataMemo($type, $statusLpj)
|
||||
{
|
||||
// Ambil data JSON dari statusLpj
|
||||
$data = json_decode($statusLpj->memo, true) ?? [];
|
||||
|
||||
$validationRules = [
|
||||
'memo' => [
|
||||
'kepada',
|
||||
'dari',
|
||||
'nomor_memo',
|
||||
'tanggal',
|
||||
'perihal',
|
||||
'jenis_asset_tidak_sesuai',
|
||||
'lokasi.lokasi',
|
||||
'lokasi.province_code',
|
||||
'lokasi.city_code',
|
||||
'lokasi.district_code',
|
||||
'lokasi.village_code',
|
||||
'lokasi.penilai',
|
||||
'terlampir',
|
||||
'hasil_survey',
|
||||
'kesimpulan_saran',
|
||||
],
|
||||
];
|
||||
|
||||
// Validasi data JSON
|
||||
if (isset($validationRules[$type])) {
|
||||
$missingFields = [];
|
||||
|
||||
foreach ($validationRules[$type] as $field) {
|
||||
$keys = explode('.', $field);
|
||||
$value = $data;
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if (!isset($value[$key])) {
|
||||
$missingFields[] = $field;
|
||||
break;
|
||||
}
|
||||
$value = $value[$key];
|
||||
}
|
||||
}
|
||||
|
||||
// Jika ada field yang kosong, kembalikan error
|
||||
if (!empty($missingFields)) {
|
||||
return response()->json([
|
||||
'status' => null,
|
||||
'message' => "Silahkan lengkapi data memo terlebih dahulu.",
|
||||
'missing_fields' => $missingFields,
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
|
||||
// Jika data valid
|
||||
return response()->json([
|
||||
'status' => $type,
|
||||
'message' => "Data memo valid.",
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function checkDataResume($type, $statusLpj)
|
||||
{
|
||||
// Ambil data JSON dari statusLpj
|
||||
$data = json_decode($statusLpj->resume, true) ?? [];
|
||||
|
||||
$validationRules = [
|
||||
'resume' => [
|
||||
'fisik'
|
||||
],
|
||||
];
|
||||
|
||||
// Validasi data JSON
|
||||
if (isset($validationRules[$type])) {
|
||||
$missingFields = [];
|
||||
|
||||
foreach ($validationRules[$type] as $field) {
|
||||
$keys = explode('.', $field);
|
||||
$value = $data;
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if (!isset($value[$key])) {
|
||||
$missingFields[] = $field;
|
||||
break;
|
||||
}
|
||||
$value = $value[$key];
|
||||
}
|
||||
|
||||
// Validasi khusus untuk array fisik dan sesuai_imb
|
||||
if ($field === 'fisik' || $field === 'sesuai_imb') {
|
||||
if (empty($value) || !is_array($value)) {
|
||||
$missingFields[] = $field;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Validasi struktur data di dalam array
|
||||
foreach ($value as $item) {
|
||||
$requiredKeys = ['sertifikat', 'luas_tanah', 'nilai'];
|
||||
foreach ($requiredKeys as $requiredKey) {
|
||||
if (!isset($item[$requiredKey])) {
|
||||
$missingFields[] = $field . '.' . $requiredKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Jika ada field yang kosong, kembalikan error
|
||||
if (!empty($missingFields)) {
|
||||
return response()->json([
|
||||
'status' => null,
|
||||
'message' => "Silahkan lengkapi data resume terlebih dahulu.",
|
||||
'missing_fields' => $missingFields,
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
|
||||
// Jika data valid
|
||||
return response()->json([
|
||||
'status' => $type,
|
||||
'message' => "Data resume valid.",
|
||||
]);
|
||||
}
|
||||
|
||||
public function checkDataLpj($type, $statusLpj)
|
||||
{
|
||||
// Ambil data JSON dari statusLpj
|
||||
$data = json_decode($statusLpj->lpj, true) ?? [];
|
||||
|
||||
$validationRules = [
|
||||
'lpj' => [
|
||||
'luas_tanah',
|
||||
'nilai_tanah_1',
|
||||
'nilai_tanah_2',
|
||||
'luas_bangunan',
|
||||
'nilai_bangunan_1',
|
||||
'nilai_bangunan_2',
|
||||
'total_nilai_pasar_wajar',
|
||||
'likuidasi',
|
||||
'likuidasi_nilai_1',
|
||||
'likuidasi_nilai_2',
|
||||
'asuransi_luas_bangunan',
|
||||
'asuransi_nilai_1',
|
||||
'asuransi_nilai_2',
|
||||
'npw_tambahan'
|
||||
],
|
||||
];
|
||||
|
||||
// Validasi data JSON
|
||||
if (isset($validationRules[$type])) {
|
||||
$missingFields = [];
|
||||
|
||||
foreach ($validationRules[$type] as $field) {
|
||||
// Penanganan khusus untuk field yang boleh null
|
||||
if (in_array($field, ['sarana_pelengkap_penilai', 'nilai_sarana_pelengkap_1', 'nilai_sarana_pelengkap_2'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($data[$field])) {
|
||||
$missingFields[] = $field;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Validasi khusus untuk npw_tambahan
|
||||
if ($field === 'npw_tambahan' && is_array($data[$field])) {
|
||||
foreach ($data[$field] as $index => $item) {
|
||||
$requiredKeys = ['name', 'luas', 'nilai_1', 'nilai_2'];
|
||||
foreach ($requiredKeys as $key) {
|
||||
if (!isset($item[$key])) {
|
||||
$missingFields[] = "npw_tambahan[$index].$key";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Jika ada field yang kosong, kembalikan error
|
||||
if (!empty($missingFields)) {
|
||||
return response()->json([
|
||||
'status' => null,
|
||||
'message' => "Silahkan lengkapi data LPJ terlebih dahulu.",
|
||||
'missing_fields' => $missingFields,
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
|
||||
// Jika data valid
|
||||
return response()->json([
|
||||
'status' => $type,
|
||||
'message' => "Data LPJ valid.",
|
||||
]);
|
||||
}
|
||||
|
||||
public function checkDataRap($type, $statusLpj)
|
||||
{
|
||||
// Ambil data JSON dari statusLpj
|
||||
$data = json_decode($statusLpj->rap, true) ?? [];
|
||||
|
||||
$requiredFields = [
|
||||
'dari',
|
||||
'kepada',
|
||||
'perihal',
|
||||
'tanggal',
|
||||
'nomor_rap'
|
||||
];
|
||||
|
||||
// Cek apakah ada field yang kosong
|
||||
$missingFields = [];
|
||||
foreach ($requiredFields as $field) {
|
||||
if (!isset($data[$field]) || empty($data[$field])) {
|
||||
$missingFields[] = $field;
|
||||
}
|
||||
}
|
||||
|
||||
// Jika ada field yang kosong, kembalikan error
|
||||
if (!empty($missingFields)) {
|
||||
return response()->json([
|
||||
'status' => null,
|
||||
'message' => "Silahkan lengkapi data RAP terlebih dahulu.",
|
||||
'missing_fields' => $missingFields
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Jika semua data terisi
|
||||
return response()->json([
|
||||
'status' => $type,
|
||||
'message' => "Data RAP valid."
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function revisiSurveyor(Request $request, $id)
|
||||
{
|
||||
$permohonan = Permohonan::findOrFail($id);
|
||||
@@ -1762,4 +1379,24 @@ class PenilaiController extends Controller
|
||||
'message' => 'Berhasil Revisi Ke surveyor',
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function showLaporanInspeksi(
|
||||
$permohonan_id,
|
||||
$dokumen_id,
|
||||
$jaminan_id,
|
||||
Request $request)
|
||||
{
|
||||
if ($request->type == 'penilai') {
|
||||
$back = route('penilai.show', $permohonan_id);
|
||||
}else{
|
||||
$back = route('surveyor.show', $permohonan_id);
|
||||
}
|
||||
|
||||
return $this->previewLaporanService->previewLaporan($permohonan_id, $dokumen_id, $jaminan_id, $back);
|
||||
}
|
||||
|
||||
public function showInspectionReportReview($permohonan_id, $dokumen_id, $jaminan_id)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -603,8 +603,15 @@ class PenilaianController extends Controller
|
||||
break;
|
||||
case 'paparan':
|
||||
if (Auth::user()->roles[0]->name === 'senior-officer' || Auth::user()->roles[0]->name === 'administrator' && $authorization->approve_so === null) {
|
||||
$status = '3';
|
||||
if (in_array($permohonan->nilai_plafond_id, [3])) {
|
||||
$status = '1';
|
||||
$permohonan->update([
|
||||
'status' => $authorization->request
|
||||
]);
|
||||
}
|
||||
$authorization->update([
|
||||
'status' => '3',
|
||||
'status' => $status,
|
||||
'status_so' => '1',
|
||||
'approve_so' => Auth::user()->id,
|
||||
'approve_so_at' => now(),
|
||||
@@ -615,9 +622,10 @@ class PenilaianController extends Controller
|
||||
'tanggal_paparan' => $request->tanggalPaparan,
|
||||
'keterangan' => $request->keterangan
|
||||
]);
|
||||
|
||||
} elseif (Auth::user()->roles[0]->name === 'EO Appraisal') {
|
||||
$status = '2';
|
||||
if (in_array($permohonan->nilai_plafond_id, [1,2])) {
|
||||
if (in_array($permohonan->nilai_plafond_id, [1,2, 3])) {
|
||||
$status = '1';
|
||||
$permohonan->update([
|
||||
'status' => $authorization->request
|
||||
|
||||
@@ -3,15 +3,16 @@
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Exception;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Location\Models\City;
|
||||
use Modules\Location\Models\District;
|
||||
use Modules\Location\Models\Province;
|
||||
use Modules\Location\Models\Village;
|
||||
use Modules\Lpj\Models\PermohonanPembatalan;
|
||||
use Modules\Lpj\Exports\PermohonanExport;
|
||||
use Modules\Lpj\Http\Requests\PermohonanRequest;
|
||||
use Modules\Lpj\Models\Branch;
|
||||
@@ -19,14 +20,12 @@ use Modules\Lpj\Models\Debiture;
|
||||
use Modules\Lpj\Models\DokumenJaminan;
|
||||
use Modules\Lpj\Models\JenisFasilitasKredit;
|
||||
use Modules\Lpj\Models\NilaiPlafond;
|
||||
use Modules\Lpj\Models\Penilaian;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\PermohonanPembatalan;
|
||||
use Modules\Lpj\Models\StatusPermohonan;
|
||||
use Modules\Lpj\Models\TujuanPenilaian;
|
||||
use Modules\Lpj\Services\PermohonanHistoryService;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\Lpj\Models\Penilaian;
|
||||
|
||||
class PermohonanController extends Controller
|
||||
{
|
||||
@@ -75,7 +74,10 @@ class PermohonanController extends Controller
|
||||
|
||||
$documents = DokumenJaminan::where('permohonan_id', $permohonan->id)->get();
|
||||
if (count($documents) < 1) {
|
||||
return redirect()->route('debitur.jaminan.create', array_merge(['permohonan_id' => $permohonan->id], ['id' => $permohonan->debiture->id]))->with('success', 'Permohonan created successfully, Lengkapi data jaminan terlebih dahulu');
|
||||
return redirect()->route(
|
||||
'debitur.jaminan.create',
|
||||
array_merge(['permohonan_id' => $permohonan->id], ['id' => $permohonan->debiture->id]),
|
||||
)->with('success', 'Permohonan created successfully, Lengkapi data jaminan terlebih dahulu');
|
||||
}
|
||||
return redirect()
|
||||
->route('permohonan.index')->with('success', 'Permohonan created successfully');
|
||||
@@ -144,35 +146,6 @@ class PermohonanController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
public function update(PermohonanRequest $request, $id)
|
||||
{
|
||||
$permohonan = Permohonan::findOrFail($id);
|
||||
$beforeRequest = $permohonan->toArray();
|
||||
|
||||
$validate = $request->validated();
|
||||
if ($validate) {
|
||||
try {
|
||||
// Update in database
|
||||
|
||||
if ($permohonan->status == 'revisi') {
|
||||
$validate['status'] = 'order';
|
||||
}
|
||||
$permohonan->update($validate);
|
||||
|
||||
$documents = DokumenJaminan::where('permohonan_id', $permohonan->id)->get();
|
||||
if (count($documents) < 1) {
|
||||
return redirect()->route('debitur.jaminan.create', array_merge(['permohonan_id' => $permohonan->id], ['id' => $permohonan->debiture->id]))->with('success', 'Permohonan created successfully, Lengkapi data jaminan terlebih dahulu');
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->route('permohonan.index')->with('success', 'Permohonan updated successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('permohonan.edit', $id)->with('error', 'Failed to update permohonan');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
@@ -205,6 +178,7 @@ class PermohonanController extends Controller
|
||||
$search = $request->get('search');
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhere('mig_mst_lpj_nomor_jaminan', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
||||
$q->orWhereRelation('debiture', 'name', 'LIKE', '%' . $search . '%');
|
||||
@@ -241,7 +215,37 @@ class PermohonanController extends Controller
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian','documents'])->get();
|
||||
$data = $query->get();
|
||||
|
||||
$data = $data->map(function ($item) {
|
||||
return [
|
||||
'id' => $item->id,
|
||||
'nomor_registrasi' => $item->nomor_registrasi,
|
||||
'mig_mst_lpj_nomor_jaminan' => $item->mig_mst_lpj_nomor_jaminan,
|
||||
'tanggal_permohonan' => $item->tanggal_permohonan ? dateFormat(
|
||||
$item->tanggal_permohonan,
|
||||
) : null,
|
||||
'pemohon' => $item->user->name ?? 'N/A',
|
||||
'branch' => $item->branch->name ?? 'N/A',
|
||||
'debiture' => [
|
||||
'name' => $item->debiture->name,
|
||||
],
|
||||
'tujuan_penilaian' => [
|
||||
'code' => $item->tujuanPenilaian->code ?? null,
|
||||
'name' => $item->tujuanPenilaian->name ?? null,
|
||||
],
|
||||
'status' => $item->status,
|
||||
'documents' => count($item->documents),
|
||||
'keterangan' => $item->keterangan,
|
||||
'penilaian' => [
|
||||
'id' => $item->penilaian->id ?? null,
|
||||
'waktu_penilaian' => $item->penilaian->waktu_penilaian ?? null,
|
||||
'rejected_note' => $item->penilaian->rejected_note ?? null,
|
||||
'authorized_status' => $item->penilaian->authorized_status ?? null,
|
||||
],
|
||||
'registrasi_catatan' => $item->registrasi_catatan,
|
||||
];
|
||||
});
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $size);
|
||||
@@ -321,8 +325,7 @@ class PermohonanController extends Controller
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])->get(
|
||||
);
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])->get();
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||
@@ -384,7 +387,6 @@ class PermohonanController extends Controller
|
||||
return view('lpj::permohonan.pembatalan-form', compact('permohonan'));
|
||||
}
|
||||
|
||||
|
||||
public function pembatalan(Request $request)
|
||||
{
|
||||
// Validate the request
|
||||
@@ -411,8 +413,8 @@ class PermohonanController extends Controller
|
||||
return redirect()->route('permohonan.index')->with('success', 'Pembatalan Permohonan Menunggu Approval');
|
||||
}
|
||||
|
||||
public function storeAproved(Request $request, $id): JsonResponse
|
||||
{
|
||||
public function storeAproved(Request $request, $id)
|
||||
: JsonResponse {
|
||||
$data = [];
|
||||
if (request()->ajax()) {
|
||||
try {
|
||||
@@ -424,16 +426,15 @@ class PermohonanController extends Controller
|
||||
$permohonan = Permohonan::findOrFail($request->permohonan_id);
|
||||
|
||||
$permohonan->update([
|
||||
'status' => 'proses-survey'
|
||||
'status' => 'proses-survey',
|
||||
]);
|
||||
|
||||
$data['status'] = 'success';
|
||||
$data['message'] = 'Jadwal ' . $request->noReg . ' berhasil di aprove';
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$data['status'] = 'error';
|
||||
$data['message'] = 'Gagal membuat jadwal: ' . $e->getMessage();
|
||||
}
|
||||
|
||||
} else {
|
||||
$data['status'] = 'error';
|
||||
$data['message'] = "no ajax request";
|
||||
@@ -442,6 +443,37 @@ class PermohonanController extends Controller
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
public function update(PermohonanRequest $request, $id)
|
||||
{
|
||||
$permohonan = Permohonan::findOrFail($id);
|
||||
$beforeRequest = $permohonan->toArray();
|
||||
|
||||
$validate = $request->validated();
|
||||
if ($validate) {
|
||||
try {
|
||||
// Update in database
|
||||
|
||||
if ($permohonan->status == 'revisi') {
|
||||
$validate['status'] = 'order';
|
||||
}
|
||||
$permohonan->update($validate);
|
||||
|
||||
$documents = DokumenJaminan::where('permohonan_id', $permohonan->id)->get();
|
||||
if (count($documents) < 1) {
|
||||
return redirect()->route(
|
||||
'debitur.jaminan.create',
|
||||
array_merge(['permohonan_id' => $permohonan->id], ['id' => $permohonan->debiture->id]),
|
||||
)->with('success', 'Permohonan created successfully, Lengkapi data jaminan terlebih dahulu');
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->route('permohonan.index')->with('success', 'Permohonan updated successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('permohonan.edit', $id)->with('error', 'Failed to update permohonan');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function storeRescheduleSurvey(Request $request, $id)
|
||||
{
|
||||
@@ -452,14 +484,14 @@ class PermohonanController extends Controller
|
||||
'nomor_registrasi' => 'required',
|
||||
'reschedule_note' => 'required',
|
||||
'reschedule_date' => 'required',
|
||||
'keterangan' => 'required'
|
||||
'keterangan' => 'required',
|
||||
]);
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
$permohonan = Permohonan::findOrFail($request->permohonan_id);
|
||||
$permohonan->update([
|
||||
'status' => 'request-reschedule'
|
||||
'status' => 'request-reschedule',
|
||||
]);
|
||||
|
||||
$penilaian = Penilaian::findOrFail($id);
|
||||
@@ -474,7 +506,7 @@ class PermohonanController extends Controller
|
||||
'status' => 'success',
|
||||
'message' => 'Proses request reschedule permohonan Nomor registrasi ' . $request->nomor_registrasi . ' berhasil',
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Modules\Lpj\Http\Requests\PersetujuanPenawaranRequest;
|
||||
use Modules\Lpj\Models\Noc;
|
||||
use Modules\Lpj\Models\PenawaranDetailTender;
|
||||
use Modules\Lpj\Models\PenawaranDetailTenderLog;
|
||||
use Modules\Lpj\Models\PenawaranTender;
|
||||
@@ -67,6 +68,22 @@
|
||||
|
||||
$persetujuanPenawaran->save();
|
||||
|
||||
|
||||
// Save NOC
|
||||
try {
|
||||
$noc = Noc::updateOrCreate([
|
||||
'permohonan_id' => $persetujuanPenawaran->permohonan_id,
|
||||
'persetujuan_penawaran_id' => $persetujuanPenawaran->id
|
||||
],[
|
||||
'bukti_bayar' => $persetujuanPenawaran->bukti_bayar,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
\Log::error('Failed to create or update NOC: ' . $e->getMessage());
|
||||
return redirect()
|
||||
->route('persetujuan-penawaran.index')
|
||||
->with('error', 'Persetujuan Penawaran berhasil disimpan tetapi gagal membuat NOC: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->route('persetujuan-penawaran.index')->with('success', 'Persetujuan Penawaran berhasil disimpan.');
|
||||
}
|
||||
|
||||
22
app/Http/Controllers/RekapHarianSoController.php
Normal file
22
app/Http/Controllers/RekapHarianSoController.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Lpj\Models\TujuanPenilaian;
|
||||
|
||||
class RekapHarianSoController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$total_laporan_debitur = 0;
|
||||
$tujuan_penilaian = TujuanPenilaian::all();
|
||||
return view('lpj::rekap-harian-so.index', compact('tujuan_penilaian', 'total_laporan_debitur'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1556,11 +1556,11 @@ class SurveyorController extends Controller
|
||||
{
|
||||
|
||||
$validated = $request->validate([
|
||||
'dokument' => 'required',
|
||||
'documentId' => 'required',
|
||||
'jenis_jaminan' => 'required'
|
||||
]);
|
||||
|
||||
$dokumentId = $validated['dokument'];
|
||||
$dokumentId = $validated['documentId'];
|
||||
$jaminanId = $validated['jenis_jaminan'];
|
||||
|
||||
$permohonan = $this->getPermohonanJaminanId($id, $dokumentId, $jaminanId);
|
||||
@@ -1644,11 +1644,11 @@ class SurveyorController extends Controller
|
||||
public function denah(Request $request, $id)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'dokument' => 'required',
|
||||
'documentId' => 'required',
|
||||
'jenis_jaminan' => 'required'
|
||||
]);
|
||||
|
||||
$dokumentId = $validated['dokument'];
|
||||
$dokumentId = $validated['documentId'];
|
||||
$jaminanId = $validated['jenis_jaminan'];
|
||||
|
||||
$permohonan = $this->getPermohonanJaminanId($id, $dokumentId, $jaminanId);
|
||||
@@ -1672,11 +1672,11 @@ class SurveyorController extends Controller
|
||||
public function foto(Request $request, $id)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'dokument' => 'required',
|
||||
'documentId' => 'required',
|
||||
'jenis_jaminan' => 'required'
|
||||
]);
|
||||
|
||||
$dokumentId = $validated['dokument'];
|
||||
$dokumentId = $validated['documentId'];
|
||||
$jaminanId = $validated['jenis_jaminan'];
|
||||
$fotoObjekJaminan = FotoObjekJaminan::all();
|
||||
|
||||
@@ -1707,11 +1707,11 @@ class SurveyorController extends Controller
|
||||
// Ambil data permohonan dengan eager loading
|
||||
|
||||
$validated = $request->validate([
|
||||
'dokument' => 'required',
|
||||
'documentId' => 'required',
|
||||
'jenis_jaminan' => 'required'
|
||||
]);
|
||||
|
||||
$dokumentId = $validated['dokument'];
|
||||
$dokumentId = $validated['documentId'];
|
||||
$jaminanId = $validated['jenis_jaminan'];
|
||||
|
||||
$permohonan = $this->getPermohonanJaminanId($id, $dokumentId, $jaminanId);
|
||||
@@ -2718,7 +2718,7 @@ class SurveyorController extends Controller
|
||||
$fileName = 'inspeksi-' . $namaDebiture . '-data.pdf';
|
||||
$pdf->set_option('isHtml5ParserEnabled', true);
|
||||
$pdf->set_option('isPhpEnabled', true);
|
||||
return $pdf->stream($fileName);
|
||||
return $pdf->download($fileName);
|
||||
}
|
||||
|
||||
public function approveReschedule(Request $request, $id)
|
||||
|
||||
33
app/Http/Requests/CategoryDaftarPustakaRequest.php
Normal file
33
app/Http/Requests/CategoryDaftarPustakaRequest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CategoryDaftarPustakaRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required|max:255',
|
||||
];
|
||||
|
||||
if ($this->method() == 'PUT') {
|
||||
$rules['code'] = 'required|max:50|unique:category_daftar_pustaka,code,' . $this->id;
|
||||
} else {
|
||||
$rules['code'] = 'required|max:50|unique:category_daftar_pustaka,code';
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
38
app/Http/Requests/DaftarPustakaRequest.php
Normal file
38
app/Http/Requests/DaftarPustakaRequest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class DaftarPustakaRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
||||
$rules = [
|
||||
'judul' => 'required|max:255',
|
||||
'category_id' => 'required',
|
||||
'deskripsi' => 'nullable',
|
||||
];
|
||||
|
||||
if ($this->method() == 'PUT') {
|
||||
$rules['attachment'] = 'nullable|mimes:pdf,jpg,jpeg,png,gif';
|
||||
} else {
|
||||
$rules['attachment'] = 'required|mimes:pdf,jpg,jpeg,png,gif';
|
||||
}
|
||||
|
||||
return $rules;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -4,20 +4,150 @@
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* Form Request untuk validasi data NOC (Notice of Completion)
|
||||
*/
|
||||
class NocRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Konstanta untuk jenis file yang diizinkan
|
||||
*/
|
||||
private const ALLOWED_FILE_TYPES = 'pdf,jpg,jpeg,png';
|
||||
|
||||
/**
|
||||
* Konstanta untuk ukuran file maksimum (dalam KB)
|
||||
*/
|
||||
private const MAX_FILE_SIZE = 10240;
|
||||
|
||||
/**
|
||||
* Menentukan apakah pengguna berwenang untuk melakukan request ini
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mengumpulkan semua aturan validasi
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return array_merge(
|
||||
$this->getBasicInfoRules(),
|
||||
$this->getPaymentRules(),
|
||||
$this->getSettlementRules(),
|
||||
$this->getAuthorizationRules(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aturan validasi untuk informasi dasar
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getBasicInfoRules()
|
||||
{
|
||||
return [
|
||||
'penawaran_id' => 'nullable|exists:penawaran,id',
|
||||
'nominal_bayar' => 'nullable|numeric|min:0',
|
||||
'bukti_ksl' => 'nullable|file|mimes:pdf,jpg,jpeg,png|max:10240',
|
||||
'permohonan_id' => 'required|exists:permohonan,id',
|
||||
'persetujuan_penawaran_id' => 'required|exists:persetujuan_penawaran,id',
|
||||
'status' => 'nullable|boolean',
|
||||
'created_by' => 'nullable|exists:users,id',
|
||||
'updated_by' => 'nullable|exists:users,id',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Aturan validasi untuk data pembayaran
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getPaymentRules()
|
||||
{
|
||||
$fileRule = 'nullable|file|mimes:' . self::ALLOWED_FILE_TYPES . '|max:' . self::MAX_FILE_SIZE;
|
||||
|
||||
return [
|
||||
'total_harus_bayar' => 'nullable|numeric|min:0',
|
||||
'nominal_bayar' => 'nullable|numeric|min:0',
|
||||
'bukti_ksl' => $fileRule,
|
||||
'bukti_bayar' => $fileRule,
|
||||
'status_bayar' => 'nullable|boolean',
|
||||
'tanggal_pembayaran' => 'nullable|date',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Aturan validasi untuk data penyelesaian
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getSettlementRules()
|
||||
{
|
||||
$fileRule = 'nullable|file|mimes:' . self::ALLOWED_FILE_TYPES . '|max:' . self::MAX_FILE_SIZE;
|
||||
|
||||
return [
|
||||
'nominal_penyelesaian' => 'nullable|numeric|min:0',
|
||||
'status_penyelesaian' => 'nullable|boolean',
|
||||
'tanggal_penyelesaian' => 'nullable|date',
|
||||
'bukti_penyelesaian' => $fileRule,
|
||||
'memo_penyelesaian' => $fileRule,
|
||||
'catatan_noc' => 'nullable|string',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Aturan validasi untuk otorisasi
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getAuthorizationRules()
|
||||
{
|
||||
return [
|
||||
'authorized_status' => 'nullable|boolean',
|
||||
'authorized_at' => 'nullable|date',
|
||||
'authorized_by' => 'nullable|exists:users,id',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Pesan khusus untuk validasi
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'permohonan_id.required' => 'ID Permohonan harus diisi',
|
||||
'permohonan_id.exists' => 'ID Permohonan tidak valid',
|
||||
'persetujuan_penawaran_id.required' => 'ID Persetujuan Penawaran harus diisi',
|
||||
'persetujuan_penawaran_id.exists' => 'ID Persetujuan Penawaran tidak valid',
|
||||
'nominal_bayar.numeric' => 'Nominal Bayar harus berupa angka',
|
||||
'nominal_bayar.min' => 'Nominal Bayar minimal 0',
|
||||
'bukti_ksl.file' => 'Bukti KSL harus berupa file',
|
||||
'bukti_ksl.mimes' => 'Bukti KSL harus berformat pdf, jpg, jpeg, atau png',
|
||||
'bukti_ksl.max' => 'Ukuran Bukti KSL maksimal 10MB',
|
||||
'bukti_bayar.file' => 'Bukti Bayar harus berupa file',
|
||||
'bukti_bayar.mimes' => 'Bukti Bayar harus berformat pdf, jpg, jpeg, atau png',
|
||||
'bukti_bayar.max' => 'Ukuran Bukti Bayar maksimal 10MB',
|
||||
'status.boolean' => 'Status harus berupa boolean',
|
||||
'status_bayar.boolean' => 'Status Bayar harus berupa boolean',
|
||||
'tanggal_pembayaran.date' => 'Format Tanggal Pembayaran tidak valid',
|
||||
'nominal_penyelesaian.numeric' => 'Nominal Penyelesaian harus berupa angka',
|
||||
'nominal_penyelesaian.min' => 'Nominal Penyelesaian minimal 0',
|
||||
'status_penyelesaian.boolean' => 'Status Penyelesaian harus berupa boolean',
|
||||
'tanggal_penyelesaian.date' => 'Format Tanggal Penyelesaian tidak valid',
|
||||
'bukti_penyelesaian.file' => 'Bukti Penyelesaian harus berupa file',
|
||||
'bukti_penyelesaian.mimes' => 'Bukti Penyelesaian harus berformat pdf, jpg, jpeg, atau png',
|
||||
'bukti_penyelesaian.max' => 'Ukuran Bukti Penyelesaian maksimal 10MB',
|
||||
'memo_penyelesaian.file' => 'Memo Penyelesaian harus berupa file',
|
||||
'memo_penyelesaian.mimes' => 'Memo Penyelesaian harus berformat pdf, jpg, jpeg, atau png',
|
||||
'memo_penyelesaian.max' => 'Ukuran Memo Penyelesaian maksimal 10MB',
|
||||
'authorized_status.boolean' => 'Status Otorisasi harus berupa boolean',
|
||||
'authorized_at.date' => 'Format Tanggal Otorisasi tidak valid',
|
||||
'authorized_by.exists' => 'User Otorisasi tidak valid',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
'sla_final' => 'nullable|numeric|min:0',
|
||||
'file_persetujuan_penawaran' => 'nullable|file|mimes:pdf,doc,docx|max:10240',
|
||||
'surat_representasi' => 'nullable|file|mimes:pdf,doc,docx|max:10240',
|
||||
'bukti_bayar' => 'nullable|file|mimes:pdf,jpg,jpeg,png|max:10240',
|
||||
'nominal_bayar' => 'nullable|numeric|min:0',
|
||||
'status' => 'nullable|boolean',
|
||||
'authorized_status' => 'boolean',
|
||||
'authorized_at' => 'nullable|date',
|
||||
@@ -52,9 +50,6 @@
|
||||
'surat_representasi.file' => 'Surat Representasi harus berupa file.',
|
||||
'surat_representasi.mimes' => 'Surat Representasi harus berupa file PDF, DOC, atau DOCX.',
|
||||
'surat_representasi.max' => 'Ukuran Surat Representasi tidak boleh lebih dari 10MB.',
|
||||
'bukti_bayar.file' => 'Bukti Bayar harus berupa file.',
|
||||
'bukti_bayar.mimes' => 'Bukti Bayar harus berupa file PDF, JPG, JPEG, atau PNG.',
|
||||
'bukti_bayar.max' => 'Ukuran Bukti Bayar tidak boleh lebih dari 10MB.',
|
||||
'region_id.required' => 'Region ID wajib diisi.',
|
||||
'region_id.exists' => 'Region ID tidak valid.',
|
||||
'status.required' => 'Status wajib diisi.',
|
||||
@@ -62,8 +57,6 @@
|
||||
'authorized_status.boolean' => 'Status otorisasi harus berupa nilai boolean.',
|
||||
'authorized_at.date' => 'Tanggal otorisasi harus berupa tanggal yang valid.',
|
||||
'authorized_by.exists' => 'ID pengguna yang mengotorisasi tidak valid.',
|
||||
'status_bayar.required' => 'Status bayar wajib diisi.',
|
||||
'status_bayar.in' => 'Status bayar harus berupa "sudah_bayar", "belum_bayar" atau "tidak bayar".',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\AnalisaFactory;
|
||||
|
||||
class Analisa extends Model
|
||||
class Analisa extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'analisa';
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\AnalisaFaktaFactory;
|
||||
|
||||
class AnalisaFakta extends Model
|
||||
class AnalisaFakta extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\AnalisaLingkunganFactory;
|
||||
|
||||
class AnalisaLingkungan extends Model
|
||||
class AnalisaLingkungan extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\AnalisaTanahBagunanFactory;
|
||||
|
||||
class AnalisaTanahBagunan extends Model
|
||||
class AnalisaTanahBagunan extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\AnalisaUnitFactory;
|
||||
|
||||
class AnalisaUnit extends Model
|
||||
class AnalisaUnit extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
|
||||
/**
|
||||
@@ -14,7 +15,7 @@
|
||||
*/
|
||||
class Base extends Model
|
||||
{
|
||||
use LogsActivity, SoftDeletes, Userstamps;
|
||||
use LogsActivity, SoftDeletes, Userstamps, Notifiable;
|
||||
|
||||
protected $connection;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\BentukTanahFactory;
|
||||
|
||||
class BentukTanah extends Model
|
||||
class BentukTanah extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// use Modules\Lpj\Database\Factories\BentukUnitFactory;
|
||||
|
||||
class BentukUnit extends Model
|
||||
class BentukUnit extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
27
app/Models/CategoryDaftarPustaka.php
Normal file
27
app/Models/CategoryDaftarPustaka.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// use Modules\Lpj\Database\Factories\CategoryDaftarPustakaFactory;
|
||||
|
||||
class CategoryDaftarPustaka extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'category_daftar_pustaka';
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'name',
|
||||
'code',
|
||||
];
|
||||
|
||||
public function daftarPustaka(){
|
||||
return $this->hasMany(DaftarPustaka::class);
|
||||
}
|
||||
|
||||
}
|
||||
29
app/Models/DaftarPustaka.php
Normal file
29
app/Models/DaftarPustaka.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// use Modules\Lpj\Database\Factories\DaftarPustakaFactory;
|
||||
|
||||
class DaftarPustaka extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'daftar_pustaka';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'category_id',
|
||||
'judul',
|
||||
'attachment',
|
||||
'deskripsi',
|
||||
];
|
||||
|
||||
public function category(){
|
||||
return $this->belongsTo(CategoryDaftarPustaka::class);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\DenahFactory;
|
||||
|
||||
class Denah extends Model
|
||||
class Denah extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// use Modules\Lpj\Database\Factories\FasilitasObjekFactory;
|
||||
|
||||
class FasilitasObjek extends Model
|
||||
class FasilitasObjek extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\FotoJaminanFactory;
|
||||
|
||||
class FotoJaminan extends Model
|
||||
class FotoJaminan extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// use Modules\Lpj\Database\Factories\FotoObjekJaminanFactory;
|
||||
|
||||
class FotoObjekJaminan extends Model
|
||||
class FotoObjekJaminan extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\GolonganMasySekitarFactory;
|
||||
|
||||
class GolonganMasySekitar extends Model
|
||||
class GolonganMasySekitar extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// use Modules\Lpj\Database\Factories\InspeksiFactory;
|
||||
|
||||
class Inspeksi extends Model
|
||||
class Inspeksi extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
@@ -14,7 +14,7 @@ class Inspeksi extends Model
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = ['data_form', 'foto_form', 'denah_form','permohonan_id', 'name', 'status', 'authorized_status', 'authorized_at', 'authorized_by', 'created_by', 'updated_by', 'deleted_by','dokument_id','data_pembanding'];
|
||||
protected $fillable = ['data_form', 'foto_form', 'denah_form','permohonan_id', 'name', 'status', 'authorized_status', 'authorized_at', 'authorized_by', 'created_by', 'updated_by', 'deleted_by','dokument_id','data_pembanding','mig_detail_data_jaminan'];
|
||||
|
||||
public function permohonan()
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\JenisBangunanFactory;
|
||||
|
||||
class JenisBangunan extends Model
|
||||
class JenisBangunan extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// use Modules\Lpj\Database\Factories\JenisKapalFactory;
|
||||
|
||||
class JenisKapal extends Model
|
||||
class JenisKapal extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// use Modules\Lpj\Database\Factories\JenisKendaraanFactory;
|
||||
|
||||
class JenisKendaraan extends Model
|
||||
class JenisKendaraan extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Modules\Lpj\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Modules\Lpj\Database\Factories\JenisPenilaianFactory;
|
||||
use Modules\Lpj\Models\Penilaian;
|
||||
class JenisPenilaian extends Model
|
||||
class JenisPenilaian extends Base
|
||||
{
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// use Modules\Lpj\Database\Factories\JenisPesawatFactory;
|
||||
|
||||
class JenisPesawat extends Model
|
||||
class JenisPesawat extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
// use Modules\Lpj\Database\Factories\JenisUnitFactory;
|
||||
|
||||
class JenisUnit extends Model
|
||||
class JenisUnit extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\KetinggianTanahFactory;
|
||||
|
||||
class KetinggianTanah extends Model
|
||||
class KetinggianTanah extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\KondisiBangunanFactory;
|
||||
|
||||
class KondisiBangunan extends Model
|
||||
class KondisiBangunan extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\KondisiFisikTanahFactory;
|
||||
|
||||
class KondisiFisikTanah extends Model
|
||||
class KondisiFisikTanah extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\KonturTanahFactory;
|
||||
|
||||
class KonturTanah extends Model
|
||||
class KonturTanah extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\LaluLintasLokasiFactory;
|
||||
|
||||
class LaluLintasLokasi extends Model
|
||||
class LaluLintasLokasi extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'lalu_lintas_lokasi';
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\LokasiUnitFactory;
|
||||
|
||||
class Lantai extends Model
|
||||
class Lantai extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\LantaiUnitFactory;
|
||||
|
||||
class LantaiUnit extends Model
|
||||
class LantaiUnit extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// use Modules\Lpj\Database\Factories\LaporanFactory;
|
||||
|
||||
class Laporan extends Model
|
||||
class Laporan extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\LingkunganFactory;
|
||||
|
||||
class Lingkungan extends Model
|
||||
class Lingkungan extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
// use Modules\Lpj\Database\Factories\MerupakanDaerahFactory;
|
||||
|
||||
class MerupakanDaerah extends Model
|
||||
class MerupakanDaerah extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// use Modules\Lpj\Database\Factories\ModelAlatBeratFactory;
|
||||
|
||||
class ModelAlatBerat extends Model
|
||||
class ModelAlatBerat extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
62
app/Models/Noc.php
Normal file
62
app/Models/Noc.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// use Modules\Lpj\Database\Factories\NocFactory;
|
||||
|
||||
class Noc extends Base
|
||||
{
|
||||
protected $table = 'noc';
|
||||
|
||||
protected $fillable = [
|
||||
'permohonan_id',
|
||||
'persetujuan_penawaran_id',
|
||||
'bukti_bayar',
|
||||
'nominal_bayar',
|
||||
'status_bayar',
|
||||
'tanggal_pembayaran',
|
||||
'nominal_penyelesaian',
|
||||
'status_penyelesaiaan',
|
||||
'tanggal_penyelesaian',
|
||||
'bukti_penyelesaian',
|
||||
'bukti_ksl',
|
||||
'memo_penyelesaian',
|
||||
'catatan_noc',
|
||||
'status',
|
||||
'authorized_status',
|
||||
'authorized_at',
|
||||
'authorized_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'nominal_bayar' => 'decimal:2',
|
||||
'status_bayar' => 'boolean',
|
||||
'tanggal_pembayaran' => 'date',
|
||||
'nominal_penyelesaian' => 'decimal:2',
|
||||
'status_penyelesaiaan' => 'boolean',
|
||||
'tanggal_penyelesaian' => 'date',
|
||||
'status' => 'boolean',
|
||||
'authorized_status' => 'boolean',
|
||||
'authorized_at' => 'datetime',
|
||||
];
|
||||
|
||||
// Relationship with Permohonan
|
||||
public function permohonan()
|
||||
{
|
||||
return $this->belongsTo(Permohonan::class, 'permohonan_id');
|
||||
}
|
||||
|
||||
// Relationship with PersetujuanPenawaran
|
||||
public function persetujuanPenawaran()
|
||||
{
|
||||
return $this->belongsTo(PersetujuanPenawaran::class, 'persetujuan_penawaran_id');
|
||||
}
|
||||
|
||||
// Relationship with User (for authorized_by)
|
||||
public function authorizedBy()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'authorized_by');
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\ObjekJaminanFactory;
|
||||
|
||||
class ObjekJaminan extends Model
|
||||
class ObjekJaminan extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
// use Modules\Lpj\Database\Factories\PenawaranDetailTenderFactory;
|
||||
|
||||
class PenawaranDetailTenderLog extends Model
|
||||
class PenawaranDetailTenderLog extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// use Modules\Lpj\Database\Factories\PenilaiFactory;
|
||||
|
||||
class Penilai extends Model
|
||||
class Penilai extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ use Modules\Lpj\Models\Teams;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Usermanagement\Models\User;
|
||||
|
||||
class Penilaian extends Model
|
||||
class Penilaian extends Base
|
||||
{
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
@@ -32,6 +32,17 @@ class Penilaian extends Model
|
||||
return $this->belongsTo(Teams::class, 'teams_id', 'id');
|
||||
}
|
||||
|
||||
public function teamLeader(){
|
||||
return $this->belongsTo(Teams::class, 'teams_id', 'id')
|
||||
->with(['teamsUsers' => function($query) {
|
||||
$query->whereHas('user', function($q) {
|
||||
$q->whereHas('roles', function($r) {
|
||||
$r->where('name', 'senior-officer');
|
||||
});
|
||||
})->with('user');
|
||||
}]);
|
||||
}
|
||||
|
||||
public function userPenilai()
|
||||
{
|
||||
return $this->hasMany(PenilaianTeam::class, 'penilaian_id', 'id');
|
||||
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\PenilaianTeamFactory;
|
||||
|
||||
class PenilaianTeam extends Model
|
||||
class PenilaianTeam extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// use Modules\Lpj\Database\Factories\PerizinanFactory;
|
||||
|
||||
class Perizinan extends Model
|
||||
class Perizinan extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\PerkerasanJalanFactory;
|
||||
|
||||
class PerkerasanJalan extends Model
|
||||
class PerkerasanJalan extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -259,4 +259,10 @@
|
||||
return $this->belongsTo(Inspeksi::class, 'permohonan_id');
|
||||
}
|
||||
|
||||
// Add this relationship
|
||||
public function noc()
|
||||
{
|
||||
return $this->hasOne(Noc::class, 'permohonan_id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\PermohonanJaminanFactory;
|
||||
|
||||
class PermohonanJaminan extends Model
|
||||
class PermohonanJaminan extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'dokumen_jaminan';
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
'authorized_status',
|
||||
'authorized_at',
|
||||
'authorized_by',
|
||||
'status',
|
||||
'catatan',
|
||||
];
|
||||
|
||||
@@ -58,4 +57,10 @@
|
||||
{
|
||||
return $this->belongsTo(User::class, 'authorized_by');
|
||||
}
|
||||
|
||||
// Relationship with Noc
|
||||
public function noc()
|
||||
{
|
||||
return $this->hasOne(Noc::class, 'persetujuan_penawaran_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\PosisiKavlingFactory;
|
||||
|
||||
class PosisiKavling extends Model
|
||||
class PosisiKavling extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
// use Modules\Lpj\Database\Factories\PosisiUnitFactory;
|
||||
|
||||
class PosisiUnit extends Model
|
||||
class PosisiUnit extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\RegionsFactory;
|
||||
use Modules\Lpj\Models\Teams;
|
||||
|
||||
class Regions extends Model
|
||||
class Regions extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\RuteJaminanFactory;
|
||||
|
||||
class RuteJaminan extends Model
|
||||
class RuteJaminan extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class SLA extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'sla';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $guarded = ['id'];
|
||||
}
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\SaranaPelengkapFactory;
|
||||
|
||||
class SaranaPelengkap extends Model
|
||||
class SaranaPelengkap extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\SifatBangunanFactory;
|
||||
|
||||
class SifatBangunan extends Model
|
||||
class SifatBangunan extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\SpekBagunanAnalisaFactory;
|
||||
|
||||
class SpekBagunanAnalisa extends Model
|
||||
class SpekBagunanAnalisa extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\SpekBagunanAnalisaDetailFactory;
|
||||
|
||||
class SpekBagunanAnalisaDetail extends Model
|
||||
class SpekBagunanAnalisaDetail extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\SpekBangunanFactory;
|
||||
|
||||
class SpekBangunan extends Model
|
||||
class SpekBangunan extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\SpekKategoritBangunanFactory;
|
||||
|
||||
class SpekKategoritBangunan extends Model
|
||||
class SpekKategoritBangunan extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ use Modules\Lpj\Models\Regions;
|
||||
use Modules\Lpj\Models\Penilaian;
|
||||
|
||||
|
||||
class Teams extends Model
|
||||
class Teams extends Base
|
||||
{
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
||||
@@ -8,7 +8,7 @@ use Modules\Usermanagement\Models\User;
|
||||
use Modules\Lpj\Models\Teams;
|
||||
use Modules\Lpj\Models\Penilaian;
|
||||
|
||||
class TeamsUsers extends Model
|
||||
class TeamsUsers extends Base
|
||||
{
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
// use Modules\Lpj\Database\Factories\TerletakAreaFactory;
|
||||
|
||||
class TerletakArea extends Model
|
||||
class TerletakArea extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\TingkatKeramaianFactory;
|
||||
|
||||
class TingkatKeramaian extends Model
|
||||
class TingkatKeramaian extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Lpj\Database\Factories\ViewUnitFactory;
|
||||
|
||||
class ViewUnit extends Model
|
||||
class ViewUnit extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
58
app/Notifications/PermohonanNotif.php
Normal file
58
app/Notifications/PermohonanNotif.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class PermohonanNotif extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
protected $permohonan;
|
||||
protected $message;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct($permohonan, $message)
|
||||
{
|
||||
$this->permohonan = $permohonan;
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*/
|
||||
public function via($notifiable)
|
||||
: array
|
||||
{
|
||||
return ['mail', 'database'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
: MailMessage
|
||||
{
|
||||
return (new MailMessage)
|
||||
->line('The introduction to the notification.')
|
||||
->action('Notification Action', 'https://laravel.com')
|
||||
->line('Thank you for using our application!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*/
|
||||
public function toArray($notifiable)
|
||||
: array
|
||||
{
|
||||
return [
|
||||
'data' => $this->permohonan,
|
||||
'message' => $this->message,
|
||||
];
|
||||
}
|
||||
}
|
||||
90
app/Services/DaftarPustakaService.php
Normal file
90
app/Services/DaftarPustakaService.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Services;
|
||||
|
||||
use Modules\Lpj\Models\DaftarPustaka;
|
||||
|
||||
class DaftarPustakaService
|
||||
{
|
||||
public function storeDaftarPustaka(array $data, $file)
|
||||
{
|
||||
if ($file) {
|
||||
$data['attachment'] = $this->handleUpload($file);
|
||||
}
|
||||
return DaftarPustaka::create($data);
|
||||
}
|
||||
|
||||
public function updateDaftarPustaka($data, $file, $id)
|
||||
{
|
||||
// Ambil data inputan yang diperlukan saja
|
||||
|
||||
$daftarPustaka = DaftarPustaka::findOrFail($id);
|
||||
|
||||
// Jika ada file baru yang diupload
|
||||
if ($file) {
|
||||
// (Opsional) Hapus file lama
|
||||
if ($daftarPustaka->attachment && file_exists(public_path($daftarPustaka->attachment))) {
|
||||
unlink(public_path($daftarPustaka->attachment));
|
||||
}
|
||||
|
||||
// Upload file baru
|
||||
$data['attachment'] = $this->handleUpload($file);
|
||||
}
|
||||
|
||||
// Update data
|
||||
$daftarPustaka->update($data);
|
||||
|
||||
return $daftarPustaka;
|
||||
}
|
||||
|
||||
|
||||
public function deleteDaftarPustaka($id)
|
||||
{
|
||||
return DaftarPustaka::where('id', $id)->delete();
|
||||
}
|
||||
|
||||
public function getDaftarPustakaById($id)
|
||||
{
|
||||
return DaftarPustaka::where('id', $id)->first();
|
||||
}
|
||||
|
||||
// get all with pagination
|
||||
public function getAllDaftarPustaka($request)
|
||||
{
|
||||
$query = DaftarPustaka::query();
|
||||
|
||||
// Filter pencarian
|
||||
if (!empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->orWhere('judul', 'LIKE', "%$search%");
|
||||
});
|
||||
}
|
||||
|
||||
// Filter kategori
|
||||
if (!empty($request->get('category'))) {
|
||||
$category = explode(',', $request->input('category'));
|
||||
$query->whereIn('category_id', $category);
|
||||
}
|
||||
|
||||
// Default pagination
|
||||
$page = (int) $request->get('page', 1);
|
||||
$size = (int) $request->get('size', 10);
|
||||
|
||||
return $query->paginate($size, ['*'], 'page', $page);
|
||||
}
|
||||
|
||||
|
||||
private function handleUpload($file)
|
||||
{
|
||||
$today = now();
|
||||
$folderPath = 'daftar_pustaka/' . $today->format('Y/m/d');
|
||||
|
||||
$fileName = $file->getClientOriginalName();
|
||||
$filePath = $file->storeAs($folderPath, $fileName, 'public');
|
||||
|
||||
return $filePath;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
179
app/Services/DashboardService.php
Normal file
179
app/Services/DashboardService.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Services;
|
||||
|
||||
use Modules\Lpj\Models\Laporan;
|
||||
use Modules\Lpj\Models\Noc;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
class DashboardService
|
||||
{
|
||||
public function getDashboardData($start_date, $end_date)
|
||||
{
|
||||
$countLpjInternal = $this->getTotalLpjInternal($start_date, $end_date);
|
||||
$countLpjExternal = $this->getTotalLpjEksternal($start_date, $end_date);
|
||||
$countResume = $this->getResumeCabang($start_date, $end_date);
|
||||
$countPendapatan = $this->getPendapatanAppraisal($start_date, $end_date);
|
||||
|
||||
return [
|
||||
'count_lpj_internal' => $countLpjInternal,
|
||||
'count_lpj_eksternal' => $countLpjExternal,
|
||||
'count_resume' => $countResume,
|
||||
'count_pendapatan' => $countPendapatan
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getTotalLpjInternal($start_date, $end_date)
|
||||
{
|
||||
$months = $this->getMonthly();
|
||||
$regions = $this->getRegion();
|
||||
$data = [];
|
||||
|
||||
foreach ($months as $index => $month) {
|
||||
$monthNumber = $index + 1;
|
||||
$data[$month] = [];
|
||||
|
||||
foreach ($regions as $region) {
|
||||
if ($monthNumber > now()->month) {
|
||||
|
||||
$data[$month][$region] = [
|
||||
'total_laporan' => 0,
|
||||
'total_debiture' => 0,
|
||||
];
|
||||
} else {
|
||||
|
||||
$totalLaporan = Laporan::whereBetween('created_at', [$start_date, $end_date])
|
||||
->count();
|
||||
$totalDebitur = Permohonan::whereBetween('created_at', [$start_date, $end_date])
|
||||
->where('status', 'done')
|
||||
->distinct()
|
||||
->count('debiture_id');
|
||||
|
||||
|
||||
|
||||
$data[$month][$region] = [
|
||||
'total_laporan' => $totalLaporan,
|
||||
'total_debiture' => $totalDebitur,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getPendapatanAppraisal($start_date, $end_date)
|
||||
{
|
||||
$months = $this->getMonthly();
|
||||
$data = [];
|
||||
|
||||
foreach ($months as $index => $month) {
|
||||
$monthNumber = $index + 1;
|
||||
|
||||
if ($monthNumber > now()->month) {
|
||||
// Bulan belum terjadi
|
||||
$data[$month] = [
|
||||
'total_jumlah' => 0,
|
||||
'total_akumulasi' => 0,
|
||||
];
|
||||
} else {
|
||||
// Hitung jumlah nominal_bayar pada bulan ini
|
||||
$totalJumlah = Noc::whereYear('tanggal_pembayaran', now()->year)
|
||||
->whereMonth('tanggal_pembayaran', $monthNumber)
|
||||
->sum('nominal_bayar');
|
||||
|
||||
|
||||
$data[$month] = [
|
||||
'total_jumlah' => $totalJumlah,
|
||||
'total_akumulasi' => $totalJumlah,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getResumeCabang($start_date, $end_date)
|
||||
{
|
||||
$regions = $this->getRegion();
|
||||
$status = ['batal', 'done'];
|
||||
$data = [];
|
||||
|
||||
foreach ($status as $item) {
|
||||
$data[$item] = [];
|
||||
foreach ($regions as $region) {
|
||||
$totalLaporan = DB::table('laporan')
|
||||
->join('permohonan', 'laporan.permohonan_id', '=', 'permohonan.id')
|
||||
->where('permohonan.status', $item)
|
||||
->whereBetween('laporan.created_at', [$start_date, $end_date])
|
||||
->count();
|
||||
|
||||
$data[$item][$region] = [
|
||||
'count_report' => $totalLaporan,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
public function getTotalLpjEksternal($start_date, $end_date)
|
||||
{
|
||||
$months = $this->getMonthly();
|
||||
$data = [];
|
||||
foreach ($months as $index => $month) {
|
||||
$monthNumber = $index + 1;
|
||||
if ($monthNumber > now()->month) {
|
||||
$data[$month] = [
|
||||
'total_laporan' => 0,
|
||||
'total_debiture' => 0,
|
||||
];
|
||||
} else {
|
||||
$totalLaporan = Laporan::where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->count();
|
||||
|
||||
$totalDebitur = Permohonan::whereBetween('created_at', [$start_date, $end_date])
|
||||
->where('status', 'done')
|
||||
->distinct()
|
||||
->count('debiture_id');
|
||||
|
||||
$data[$month] = [
|
||||
'total_laporan' => $totalLaporan,
|
||||
'total_debiture' => $totalDebitur,
|
||||
];
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function getMonthly()
|
||||
{
|
||||
return [
|
||||
'januari',
|
||||
'februari',
|
||||
'maret',
|
||||
'april',
|
||||
'mei',
|
||||
'juni',
|
||||
'juli',
|
||||
'agustus',
|
||||
'september',
|
||||
'oktober',
|
||||
'november',
|
||||
'desember',
|
||||
];
|
||||
}
|
||||
|
||||
private function getRegion()
|
||||
{
|
||||
return [
|
||||
'jabodetabek',
|
||||
'non-jabodetabek',
|
||||
];
|
||||
}
|
||||
}
|
||||
21
app/Services/LaporanBiayaService.php
Normal file
21
app/Services/LaporanBiayaService.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Services;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
|
||||
class LaporanBiayaService
|
||||
{
|
||||
public function buildDataTableQuery(array $data){
|
||||
$query = Permohonan::with([
|
||||
'noc'
|
||||
]);
|
||||
|
||||
if($data['search']){
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
182
app/Services/LaporanDebitureService.php
Normal file
182
app/Services/LaporanDebitureService.php
Normal file
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Services;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Illuminate\Http\Request;
|
||||
class LaporanDebitureService
|
||||
{
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = Permohonan::query();
|
||||
$query = $query->where('status', 'done');
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = json_decode($request->get('search'));
|
||||
|
||||
if (isset($search->start_date) || isset($search->end_date)) {
|
||||
$query->whereBetween('tanggal_permohonan', [
|
||||
$search->start_date ?? '1900-01-01',
|
||||
$search->end_date ?? now()->toDateString()
|
||||
]);
|
||||
}
|
||||
|
||||
// Filter by branch if provided
|
||||
if (isset($search->debiture_id) && !empty($search->debiture_id)) {
|
||||
$query->where('debiture_id', $search->debiture_id);
|
||||
}
|
||||
|
||||
if (isset($search->search)) {
|
||||
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('jenisFasilitasKredit', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhere('status', 'LIKE', '%' . $search->search . '%');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Apply sorting if provided
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
}
|
||||
|
||||
// Get the total count of records
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Apply pagination if provided
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = $request->get('page');
|
||||
$size = $request->get('size');
|
||||
$offset = ($page - 1) * $size; // Calculate the offset
|
||||
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get the filtered count of records
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->with(['debiture.branch'])->get();
|
||||
|
||||
$data = $data->map(function ($permohonan) {
|
||||
$luas_tanah = 0;
|
||||
$luas_bangunan = 0;
|
||||
$nilai_tanah = 0;
|
||||
$nilai_bangunan = 0;
|
||||
$npw = 0;
|
||||
$nilai_liquidasi = 0;
|
||||
|
||||
if (isset($permohonan->penilai->lpj)) {
|
||||
$lpj = json_decode($permohonan->penilai->lpj, true);
|
||||
$npw = str_replace('.', '', $lpj['total_nilai_pasar_wajar'] ?? 0);
|
||||
|
||||
$luas_tanah = $lpj['luas_tanah'] ?? 0;
|
||||
$luas_bangunan = $lpj['luas_bangunan'] ?? 0;
|
||||
// Calculate nilai_tanah dynamically by looking for all keys that start with 'nilai_tanah_'
|
||||
$nilai_tanah = str_replace('.', '', $lpj['nilai_tanah_2'] ?? 0);
|
||||
|
||||
$nilai_bangunan = str_replace('.', '', $lpj['nilai_bangunan_2'] ?? 0);
|
||||
$nilai_liquidasi = str_replace('.', '', $lpj['likuidasi_nilai_2'] ?? 0);
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $permohonan->id,
|
||||
'nomor_registrasi' => $permohonan->nomor_registrasi,
|
||||
'jenis_penilaian' => $permohonan->jenisPenilaian?->name,
|
||||
'tujuan_penilaian' => $permohonan->tujuanPenilaian?->name,
|
||||
'jenis_fasilitas_kredit' => $permohonan->jenisFasilitasKredit?->name,
|
||||
'branch' => $permohonan->debiture->branch?->name,
|
||||
'pemohon' => $permohonan->creator?->name,
|
||||
'cif' => $permohonan->debiture->cif,
|
||||
'name' => $permohonan->debiture?->name,
|
||||
'jenis_agunan' => $permohonan->documents?->pluck('jenisJaminan.name')
|
||||
->unique()
|
||||
->implode(', '),
|
||||
'alamat_agunan' => $permohonan->documents?->map(function ($document) {
|
||||
return formatAlamat($document);
|
||||
})->unique()->implode(', '),
|
||||
'bukti_kepemilikan' => (function () use ($permohonan) {
|
||||
$legalitasItems = $permohonan->documents?->flatMap(function ($document) {
|
||||
return $document->detail->map(function ($detail) {
|
||||
// Jika tidak ada jenis legalitas jaminan, lewati
|
||||
if (empty($detail->jenisLegalitasJaminan)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Hanya tampilkan detail yang memiliki dokumen_jaminan
|
||||
if (empty($detail->dokumen_jaminan)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Tampilkan nama legalitas jaminan saja
|
||||
return $detail->jenisLegalitasJaminan->name ?? '';
|
||||
});
|
||||
})->filter()->unique()->values()->toArray();
|
||||
|
||||
// Buat daftar bernomor
|
||||
$result = '';
|
||||
foreach ($legalitasItems as $index => $item) {
|
||||
$result .= ($index + 1) . '. ' . $item . "\n";
|
||||
}
|
||||
|
||||
return $result;
|
||||
})(),
|
||||
'nama_pemilik' => $permohonan->documents?->pluck('pemilik.name')
|
||||
->unique()
|
||||
->implode(', '),
|
||||
'luas_tanah' => $luas_tanah . ' m²',
|
||||
'nilai_tanah' => formatRupiah($nilai_tanah, 2),
|
||||
'luas_bangunan' => $luas_bangunan . ' m²',
|
||||
'nilai_bangunan' => formatRupiah($nilai_bangunan, 2),
|
||||
'nilai_njop' => formatRupiah($permohonan->nilai_njop, 2),
|
||||
'nilai_pasar_wajar' => formatRupiah($npw, 2),
|
||||
'nilai_likuidasi' => formatRupiah($nilai_liquidasi, 2),
|
||||
'tanggal_documen_diterima' => $permohonan->documents?->map(function ($document) {
|
||||
return $document->created_at->format('d-m-Y');
|
||||
}),
|
||||
'tanggal_spk' => '',
|
||||
'nomor_spk' => '',
|
||||
'tanggal_rencana_kunjunagn' => '',
|
||||
'tanggal_kunjungan' => '',
|
||||
'taggal_delivered' => '',
|
||||
'jangka_waktu_sla' => '',
|
||||
'nama_penilai' => $permohonan->penilaian?->_user_penilai?->userPenilaiTeam?->name,
|
||||
'nama_team_leader' => $permohonan->penilaian?->teams,
|
||||
'saran' => '',
|
||||
'catatan' => '',
|
||||
|
||||
|
||||
'tanggal_permohonan' => $permohonan->tanggal_permohonan,
|
||||
'tanggal_laporan' => $permohonan->approval_dd_at ?? $permohonan->approval_eo_at ?? '',
|
||||
'tanggal_review' => $permohonan->penilaian?->tanggal_kunjungan ?? '',
|
||||
];
|
||||
});
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||
|
||||
// Calculate the current page number
|
||||
$currentPage = $request->get('page') ?: 1;
|
||||
|
||||
// Return the response data as a JSON object
|
||||
return response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
}
|
||||
228
app/Services/LaporanMonitoringSoService.php
Normal file
228
app/Services/LaporanMonitoringSoService.php
Normal file
@@ -0,0 +1,228 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Services;
|
||||
use Modules\Lpj\Models\TeamsUsers;
|
||||
use Modules\Lpj\Models\Teams;
|
||||
use Modules\Lpj\Models\Debiture;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\Penilaian;
|
||||
use Modules\Lpj\Models\StatusPermohonan;
|
||||
use Carbon\Carbon;
|
||||
class LaporanMonitoringSoService
|
||||
{
|
||||
|
||||
public function progresPengerjaanLaporan($user){
|
||||
|
||||
// Inisialisasi regionId dan teamId
|
||||
$regionId = $teamId = null;
|
||||
|
||||
if ($user->roles->pluck('name')->contains('senior-officer')) {
|
||||
$userTeam = TeamsUsers::with('team')->firstWhere('user_id', $user->id);
|
||||
$regionId = $userTeam?->team->regions_id;
|
||||
$teamId = $userTeam?->teams_id;
|
||||
}
|
||||
|
||||
|
||||
$teamsActivity = TeamsUsers::with(['user', 'team', 'team.regions', 'user.roles'])
|
||||
->whereHas('team', function ($q) use ($regionId, $teamId) {
|
||||
$q->when($regionId, fn ($q) => $q->where('regions_id', $regionId))
|
||||
->when($teamId, fn ($q) => $q->where('id', $teamId));
|
||||
})
|
||||
->where('user_id', '!=', $user->id)
|
||||
->whereHas('user.roles', fn ($q) => $q->whereIn('name', ['surveyor', 'surveyor-penilai']))
|
||||
->get();
|
||||
|
||||
$teamId = is_array($teamId) ? $teamId : [$teamId];
|
||||
|
||||
$teamPenilai = Teams::with(['regions', 'teamsUsers', 'teamsUsers.user'])->whereNotIn(
|
||||
'id',
|
||||
$teamId
|
||||
)->get();
|
||||
|
||||
return [
|
||||
'teamsActivity' => $teamsActivity,
|
||||
'teamPenilai' => $teamPenilai,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function showDetailsPermohonan($request,$id)
|
||||
{
|
||||
$query = Penilaian::with([
|
||||
'permohonan',
|
||||
'permohonan.debiture',
|
||||
'permohonan.tujuanPenilaian',
|
||||
'permohonan.debiture.documents.jenisJaminan',
|
||||
'userPenilai' => function ($query) use ($id) {
|
||||
$query->where('user_id', $id);
|
||||
},
|
||||
'permohonan.penilai',
|
||||
'permohonan.approveEo',
|
||||
'permohonan.approveDd',
|
||||
'permohonan.approveSo',
|
||||
|
||||
])
|
||||
->whereHas('userPenilai', function ($q) use ($id) {
|
||||
$q->where('user_id', $id);
|
||||
})
|
||||
->whereHas('permohonan', function ($q) {
|
||||
$q->whereIn('status', [
|
||||
'assign',
|
||||
'survey-completed',
|
||||
'proses-laporan',
|
||||
'paparan',
|
||||
'proses-paparan',
|
||||
'revisi-laporan',
|
||||
'revisi-paparan',
|
||||
'survey',
|
||||
'proses-survey',
|
||||
'request-reschedule',
|
||||
'reschedule',
|
||||
'rejected-reschedule',
|
||||
'approved-reschedule',
|
||||
'revisi-survey',
|
||||
'revisi-pembayaran'
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Filter pencarian
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('nomor_registrasi', 'LIKE', "%$search%")
|
||||
->orWhere('status', 'LIKE', "%$search%");
|
||||
});
|
||||
}
|
||||
|
||||
// Sorting
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
}
|
||||
|
||||
// Hitung total records
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Pagination
|
||||
$size = $request->get('size', 10);
|
||||
$page = $request->get('page', 1);
|
||||
$offset = ($page - 1) * $size;
|
||||
|
||||
// Ambil data dengan pagination
|
||||
$data = $query->skip($offset)->take($size)->get();
|
||||
|
||||
$data = $data->map(function ($item) {
|
||||
$jeniAsset = null;
|
||||
$statusPembayaran = trim(strtolower($item->permohonan->status_bayar ?? ''));
|
||||
$tujuanPenilaian = $item->permohonan->tujuanPenilaian->name ?? null;
|
||||
$plafond = $item->permohonan->nilaiPlafond->name ?? null;
|
||||
|
||||
$now = Carbon::now();
|
||||
$type_report = $item->permohonan->penilai->type ?? "";
|
||||
|
||||
$hari = $hariPaparan = 0;
|
||||
|
||||
if ($type_report == "sederhana") {
|
||||
$hari = 2;
|
||||
$item->paparan = 'Tidak Ada';
|
||||
} else {
|
||||
if ($plafond == '< 2M') {
|
||||
$item->paparan = 'Tidak Ada';
|
||||
$hari = 3;
|
||||
} elseif ($plafond == '2 M - 5 M') {
|
||||
$hari = 3;
|
||||
$hariPaparan = 2;
|
||||
} else {
|
||||
$hari = 5;
|
||||
$hariPaparan = 3;
|
||||
}
|
||||
}
|
||||
|
||||
if ($tujuanPenilaian == 'RAP') {
|
||||
$hari = 2;
|
||||
$hariPaparan = 2;
|
||||
}
|
||||
|
||||
|
||||
if ($item->permohonan && $item->permohonan->debiture) {
|
||||
$jeniAsset = $item->permohonan->debiture->documents->first() ?? null;
|
||||
}
|
||||
|
||||
/*$hariTambahan = 0;
|
||||
|
||||
if ($tujuanPenilaian == 'RAP') {
|
||||
$hariTambahan = 2;
|
||||
} else {
|
||||
if ($statusPembayaran == 'sudah_bayar') {
|
||||
$hariTambahan = 1; // H+1 untuk yang sudah bayar
|
||||
} else {
|
||||
$hariTambahan = 2; // H+2 untuk yang belum bayar
|
||||
}
|
||||
}*/
|
||||
|
||||
$tanggalMulai = $item->waktu_penilaian;
|
||||
|
||||
if ($tanggalMulai) {
|
||||
if (!$tanggalMulai instanceof Carbon) {
|
||||
$tanggalMulai = Carbon::parse($tanggalMulai);
|
||||
}
|
||||
$hariKerjaBerikutnya = hitungHariKerja($tanggalMulai->toDateString(), $tanggalMulai->copy()->addDays(1));
|
||||
$hariKerjaBerikutnya = max($hariKerjaBerikutnya, 1);
|
||||
$tanggalMulai = $tanggalMulai->copy()->addDays($hariKerjaBerikutnya);
|
||||
|
||||
// Konversi string tanggal ke objek Carbon jika belum
|
||||
if (!$tanggalMulai instanceof Carbon) {
|
||||
$tanggalMulai = Carbon::parse($tanggalMulai);
|
||||
}
|
||||
|
||||
// Hitung tanggal selesai berdasarkan hari tambahan
|
||||
$tanggalSelesai = $tanggalMulai->copy()->addDays($hari);
|
||||
$tanggalPaparan = $tanggalMulai->copy()->addDays($hariPaparan);
|
||||
|
||||
// Hitung hari kerja
|
||||
$hariKerja = hitungHariKerja($tanggalMulai->toDateString(), $tanggalSelesai->toDateString());
|
||||
$hariKerja = max($hariKerja, $hari);
|
||||
|
||||
$hariKerjaPaparan = hitungHariKerja($tanggalMulai->toDateString(), $tanggalPaparan->toDateString());
|
||||
$hariKerjaPaparan = max($hariKerjaPaparan, $hariPaparan);
|
||||
|
||||
// Set due date SLA
|
||||
$dueDateSla = $tanggalMulai->copy()->addDays($hariKerja);
|
||||
$dueDateSlaPaparan = $tanggalMulai->copy()->addDays($hariKerjaPaparan);
|
||||
|
||||
// Cek apakah sudah melewati due date
|
||||
/*if ($now->greaterThan($dueDateSla)) {
|
||||
$item->due_date_sla = null;
|
||||
} else {
|
||||
$item->due_date_sla = $dueDateSla->toDateString();
|
||||
}*/
|
||||
|
||||
$item->due_date_sla = $dueDateSla->toDateString();
|
||||
$item->paparan = $dueDateSlaPaparan->toDateString();
|
||||
} else {
|
||||
$item->due_date_sla = null;
|
||||
$item->paparan = null;
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
});
|
||||
|
||||
$filteredRecords = $data->count();
|
||||
$pageCount = ceil($totalRecords / $size);
|
||||
|
||||
// Return data dalam bentuk JSON
|
||||
return response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $page,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data
|
||||
]);
|
||||
}
|
||||
}
|
||||
123
app/Services/LaporanSLAPenilaiService.php
Normal file
123
app/Services/LaporanSLAPenilaiService.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Services;
|
||||
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\Penilaian;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class LaporanSLAPenilaiService
|
||||
{
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
// Retrieve data from the database
|
||||
$query = Permohonan::query();
|
||||
$query = $query->where('status', 'done');
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = json_decode($request->get('search'));
|
||||
|
||||
if (isset($search->start_date) || isset($search->end_date)) {
|
||||
$query->whereBetween('tanggal_permohonan', [
|
||||
$search->start_date ?? '1900-01-01',
|
||||
$search->end_date ?? now()->toDateString()
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
if (isset($search->penilai_id) && !empty($search->penilai_id)) {
|
||||
$query->whereHas('penilaian._user_penilai.userPenilaiTeam', function ($q) use ($search) {
|
||||
$q->where('user_id', $search->penilai_id);
|
||||
});
|
||||
}
|
||||
|
||||
if (isset($search->search)) {
|
||||
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('jenisFasilitasKredit', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhere('status', 'LIKE', '%' . $search->search . '%');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Apply sorting if provided
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
}
|
||||
|
||||
// Get the total count of records
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Apply pagination if provided
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = $request->get('page');
|
||||
$size = $request->get('size');
|
||||
$offset = ($page - 1) * $size; // Calculate the offset
|
||||
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get the filtered count of records
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->with(['documents','debiture.branch'])->get();
|
||||
|
||||
$data = $data->map(function ($permohonan) {
|
||||
|
||||
$tgl_kunjungan = $permohonan->penilaian?->tanggal_kunjungan;
|
||||
$tgl_otorisator = $permohonan->approval_dd_at ?? $permohonan->approval_eo_at ?? $permohonan->approval_so_at;
|
||||
$jangkaWaktu = $this->hitungTotalJangkaWaktuSla($tgl_kunjungan, $tgl_otorisator);
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'id' => $permohonan->id,
|
||||
'nomor_registrasi' => $permohonan->nomor_registrasi,
|
||||
'tanggal_permohonan' => $permohonan->tanggal_permohonan,
|
||||
'branch' => $permohonan->debiture?->branch?->name,
|
||||
'name' => $permohonan->debiture?->name,
|
||||
'pemohon' => $permohonan->creator?->name,
|
||||
'tujuan_penilaian' => $permohonan->tujuanPenilaian?->name,
|
||||
'tanggal_laporan' => $permohonan->approval_dd_at ?? $permohonan->approval_eo_at ?? '',
|
||||
'tanggal_approval' => $permohonan->approval_dd_at ?? $permohonan->approval_eo_at ?? '',
|
||||
'tanggal_kunjungan' => $permohonan->penilaian?->tanggal_kunjungan ?? '',
|
||||
'nama_penilai' => $permohonan->penilaian?->_user_penilai?->userPenilaiTeam?->name,
|
||||
'jangka_waktu' => $jangkaWaktu,
|
||||
'keterangan' => $permohonan->keterangan
|
||||
];
|
||||
});
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||
|
||||
// Calculate the current page number
|
||||
$currentPage = $request->get('page', 1);
|
||||
|
||||
// Return the response data as a JSON object
|
||||
return response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
private function hitungTotalJangkaWaktuSla($tgl_kunjungan,$tgl_otorisator){
|
||||
$countHariKerja = hitungHariKerja($tgl_kunjungan, $tgl_otorisator);
|
||||
return $countHariKerja;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user