Compare commits
124 Commits
fc466f6087
...
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 | ||
|
|
6f8db74159 | ||
|
|
43b086f3ea |
@@ -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;
|
namespace Modules\Lpj\Exports;
|
||||||
|
|
||||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||||
@@ -11,167 +12,299 @@ use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
|||||||
use Modules\Lpj\Models\Debiture;
|
use Modules\Lpj\Models\Debiture;
|
||||||
use Modules\Lpj\Models\Permohonan;
|
use Modules\Lpj\Models\Permohonan;
|
||||||
use Modules\Lpj\Helpers\Lpj;
|
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->request = $request;
|
||||||
$this->tanggalAkhir = $tanggalAkhir;
|
|
||||||
$this->status = $status;
|
|
||||||
$this->selectedIds = $selectedIds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function query()
|
public function collection()
|
||||||
{
|
{
|
||||||
$query = Permohonan::query()
|
$query = Permohonan::query();
|
||||||
->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian', 'dokumenjaminan.jenisJaminan','nilaiPlafond', 'penilai', 'inspeksi']);
|
$query = $query->where('status', 'done');
|
||||||
|
|
||||||
// Filter by date range if provided
|
// Apply date range filter if provided
|
||||||
if ($this->tanggalAwal && $this->tanggalAkhir) {
|
if ($this->request->has('start_date') || $this->request->has('end_date')) {
|
||||||
$query->whereBetween('tanggal_permohonan', [$this->tanggalAwal, $this->tanggalAkhir]);
|
$startDate = $this->request->start_date ?? '1900-01-01';
|
||||||
}
|
$endDate = $this->request->end_date ?? now()->toDateString();
|
||||||
|
|
||||||
$query->where('status', 'done');
|
$query->where(function ($q) use ($startDate, $endDate) {
|
||||||
// Filter by status if provided
|
|
||||||
if ($this->status) {
|
$q->whereHas('penilaian', function ($q2) use ($startDate, $endDate) {
|
||||||
$types = is_array($this->status) ? $this->status : [$this->status];
|
$q2->whereBetween('tanggal_kunjungan', [$startDate, $endDate]);
|
||||||
$types = array_map('strtolower', $types);
|
});
|
||||||
$query->whereHas('penilai', function (Builder $query) use ($types) {
|
|
||||||
$query->whereIn('type_penilai', $types);
|
// 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
|
// Filter by selected IDs if provided
|
||||||
if ($this->selectedIds) {
|
if ($this->request->has('selected_ids') && !empty($this->request->selected_ids)) {
|
||||||
$selectedIds = is_array($this->selectedIds) ? $this->selectedIds : explode(',', $this->selectedIds);
|
$selectedIds = is_array($this->request->selected_ids) ? $this->request->selected_ids : explode(',', $this->request->selected_ids);
|
||||||
$query->whereIn('id', $selectedIds);
|
$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');
|
||||||
|
|
||||||
|
return $query->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected $rowNumber = 0;
|
||||||
public function map($row): array
|
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
|
if (isset($permohonan->penilai->lpj)) {
|
||||||
$alamat_inspeksi = null;
|
$lpj = json_decode($permohonan->penilai->lpj, true);
|
||||||
|
$npw = str_replace('.', '', $lpj['total_nilai_pasar_wajar'] ?? 0);
|
||||||
|
|
||||||
if ($row->inspeksi) {
|
$luas_tanah = $lpj['luas_tanah'] ?? 0;
|
||||||
$alamat_inspeksi = json_decode($row->inspeksi->data_form, true) ?? null;
|
$luas_bangunan = $lpj['luas_bangunan'] ?? 0;
|
||||||
$alamat_inspeksi = $alamat_inspeksi['asset']['alamat']['sesuai'] ?? $alamat_inspeksi['asset']['alamat']['tidak sesuai'] ?? [];
|
$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 [
|
return [
|
||||||
$row->id,
|
$this->rowNumber,
|
||||||
$row->nomor_registrasi,
|
$permohonan->nomor_registrasi,
|
||||||
$row->user->name,
|
$permohonan->tanggal_permohonan ?? '',
|
||||||
$row->branch->name,
|
$permohonan->debiture->branch->name ?? '',
|
||||||
$row->tujuanPenilaian->name,
|
$permohonan->user->name ?? $permohonan->mig_nama_ao ?? '',
|
||||||
$row->debiture->name,
|
$permohonan->debiture->cif ?? '',
|
||||||
$row->penilai->type_penilai ?? '-',
|
$permohonan->debiture->name ?? '',
|
||||||
$alamat_inspeksi ?? '-',
|
$permohonan->tujuanPenilaian->name,
|
||||||
$luasTanah,
|
$permohonan->jenisPenilaian->name ?? '',
|
||||||
$luasBangunan,
|
$permohonan->jenisFasilitasKredit->name,
|
||||||
$nilaiTanah1,
|
$permohonan->documents->pluck('jenisJaminan.name')->unique()->implode(', '),
|
||||||
$nilaiBangunan1,
|
$permohonan->documents->map(function ($document) {
|
||||||
$totalNilaiPasar,
|
return formatAlamat($document);
|
||||||
$likuidasi,
|
})->unique()->implode(', '),
|
||||||
$row->laporan->created_at ?? '-',
|
$permohonan->documents->flatMap(function ($document) {
|
||||||
$user_penilai_name,
|
return $document->detail->map(function ($detail) {
|
||||||
$nik_penilai,
|
return (!empty($detail->dokumen_nomor) && is_array($detail->dokumen_nomor))
|
||||||
$row->created_at,
|
? ($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
|
public function headings(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'ID',
|
'No',
|
||||||
'Nomor Registrasi',
|
'Nomor Registrasi',
|
||||||
'User Pemohon',
|
'Tanggal Permohonan',
|
||||||
'Cabang',
|
'Cabang',
|
||||||
|
'Pemohon',
|
||||||
|
'CIF',
|
||||||
|
'Nama Debitur',
|
||||||
|
'Jenis Penilaian',
|
||||||
'Tujuan Penilaian',
|
'Tujuan Penilaian',
|
||||||
'Debitur',
|
'Jenis Fasilitas Kredit',
|
||||||
'Jenis Laporan',
|
'Jenis Agunan',
|
||||||
'Lokasi Jaminan',
|
'Alamat Agunan',
|
||||||
|
'Bukti Kepemilikan',
|
||||||
|
'Nama Pemilik',
|
||||||
'Luas Tanah',
|
'Luas Tanah',
|
||||||
|
'Nilai Tanah',
|
||||||
'Luas Bangunan',
|
'Luas Bangunan',
|
||||||
'Harga Tanah',
|
'Nilai Bangunan',
|
||||||
'Harga Bangunan',
|
'Nilai NJOP',
|
||||||
'Nilai Pasar Wajar',
|
'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 Laporan',
|
||||||
|
'Tanggal Review',
|
||||||
'Nama Penilai',
|
'Nama Penilai',
|
||||||
'Nik Penilai',
|
'Nama Team Leader',
|
||||||
'Created At',
|
'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 [
|
return [
|
||||||
'A' => NumberFormat::FORMAT_NUMBER,
|
AfterSheet::class => function (AfterSheet $event) {
|
||||||
'C' => NumberFormat::FORMAT_DATE_DATETIME,
|
// Get the sheet
|
||||||
'K' => NumberFormat::FORMAT_DATE_DATETIME,
|
$sheet = $event->sheet->getDelegate();
|
||||||
'N' => NumberFormat::FORMAT_DATE_DATETIME
|
|
||||||
|
// 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()
|
public function collection()
|
||||||
{
|
{
|
||||||
$query = Permohonan::with(['user', 'branch', 'tujuanPenilaian', 'jenisFasilitasKredit', 'jenisPenilaian'])
|
$query = Permohonan::query();
|
||||||
->select('permohonan.*');
|
|
||||||
|
|
||||||
// Apply role-based filtering
|
// Apply role-based filtering
|
||||||
if (!Auth::user()->hasAnyRole(['administrator'])) {
|
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);
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
1071
app/Helpers/Lpj.php
1071
app/Helpers/Lpj.php
File diff suppressed because it is too large
Load Diff
@@ -306,6 +306,7 @@ class ActivityController extends Controller
|
|||||||
$query = Permohonan::query();
|
$query = Permohonan::query();
|
||||||
|
|
||||||
// Apply search filter if provided
|
// Apply search filter if provided
|
||||||
|
$query = $query->orderBy('nomor_registrasi', 'desc');
|
||||||
if ($request->has('search') && !empty($request->get('search'))) {
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
$search = $request->get('search');
|
$search = $request->get('search');
|
||||||
$query->where(function ($q) use ($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'))) {
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
$order = $request->get('sortOrder');
|
$order = $request->get('sortOrder');
|
||||||
$column = $request->get('sortField');
|
$column = $request->get('sortField');
|
||||||
@@ -333,20 +336,13 @@ class ActivityController extends Controller
|
|||||||
$query->orderBy('nomor_registrasi', 'asc');
|
$query->orderBy('nomor_registrasi', 'asc');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get total count of records before pagination
|
// Get the total count of records
|
||||||
$totalRecords = $query->count();
|
$totalRecords = $query->count();
|
||||||
|
$size = $request->get('size', 10);
|
||||||
// Pagination
|
if ($size == 0) {
|
||||||
if ($request->has('page') && $request->has('size')) {
|
$size = 10;
|
||||||
$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();
|
|
||||||
|
|
||||||
// Filter by region if user is senior-officer
|
// Filter by region if user is senior-officer
|
||||||
if ($regionId) {
|
if ($regionId) {
|
||||||
$query->whereHas('region', function ($q) use ($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')) {
|
if ($request->has('page') && $request->has('size')) {
|
||||||
$page = (int) $request->get('page', 1);
|
$page = $request->get('page');
|
||||||
$size = (int) $request->get('size', 10);
|
$size = $request->get('size');
|
||||||
$offset = ($page - 1) * $size;
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
$query->skip($offset)->take($size);
|
$query->skip($offset)->take($size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get filtered count
|
// Get the filtered count of records
|
||||||
$filteredRecords = $query->count();
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
// Get data with necessary relationships
|
// Get data with necessary relationships
|
||||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian', 'dokumenjaminan','nilaiPlafond'])->get();
|
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian', 'dokumenjaminan','nilaiPlafond'])->get();
|
||||||
|
|
||||||
// Calculate total pages
|
// Calculate the page count
|
||||||
$pageCount = ceil($totalRecords / $request->get('size', 10));
|
$pageCount = ceil($totalRecords / $size);
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = max(1, $request->get('page', 1));
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
|
||||||
// Calculate total pages
|
|
||||||
$pageCount = ceil($totalRecords / $request->get('size', 10));
|
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'draw' => $request->get('draw'),
|
'draw' => $request->get('draw'),
|
||||||
'recordsTotal' => $totalRecords,
|
'recordsTotal' => $totalRecords,
|
||||||
'recordsFiltered' => $filteredRecords,
|
'recordsFiltered' => $filteredRecords,
|
||||||
'pageCount' => $pageCount,
|
'pageCount' => $pageCount,
|
||||||
'page' => $request->get('page', 1),
|
'page' => $currentPage,
|
||||||
'totalCount' => $totalRecords,
|
'totalCount' => $totalRecords,
|
||||||
'data' => $data,
|
'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
|
// 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();
|
$legalitas = JenisLegalitasJaminan::whereIn('code', $legalitasJaminan)->get();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,12 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$permohonan = Permohonan::with([
|
$permohonan = Permohonan::where(['status' => 'done'])->get();
|
||||||
'documents.jenisJaminan',
|
|
||||||
'penilaian._user_penilai',
|
|
||||||
'penilai',
|
|
||||||
'documents.detail.jenisLegalitasJaminan'
|
|
||||||
])->where(['status' => 'done'])->get();
|
|
||||||
foreach ($permohonan as $_permohonan) {
|
foreach ($permohonan as $_permohonan) {
|
||||||
$npw = 0;
|
$npw = 0;
|
||||||
if (isset($_permohonan->penilai->lpj)) {
|
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
|
// 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) {
|
$query = Permohonan::query()
|
||||||
$q->whereIn('nilai_plafond_id', [1,4])
|
->whereIn('status',['proses-laporan','done', 'paparan', 'proses-paparan']);
|
||||||
->whereNotNull('approval_dd_at')
|
|
||||||
->orWhereIn('nilai_plafond_id', [2,3]);
|
|
||||||
});
|
|
||||||
|
|
||||||
$query = $query->orderBy('nomor_registrasi', 'desc');
|
$query = $query->orderBy('nomor_registrasi', 'desc');
|
||||||
// Apply search filter if provided
|
// Apply search filter if provided
|
||||||
@@ -123,7 +121,7 @@ class LaporanController extends Controller
|
|||||||
$filteredRecords = $query->count();
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
// Get the data for the current page
|
// 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
|
// Calculate the page count
|
||||||
$pageCount = ceil($totalRecords / $size);
|
$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\Models\StatusPermohonan;
|
||||||
use Modules\Lpj\Exports\LaporanPenilaiJaminanExport;
|
use Modules\Lpj\Exports\LaporanPenilaiJaminanExport;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
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
|
class LaporanPenilaiJaminanController extends Controller
|
||||||
{
|
{
|
||||||
@@ -16,59 +20,31 @@ class LaporanPenilaiJaminanController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
protected $previewLaporanService;
|
||||||
|
|
||||||
|
public function __construct(PreviewLaporanService $previewLaporanService)
|
||||||
|
{
|
||||||
|
$this->previewLaporanService = $previewLaporanService;
|
||||||
|
}
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$status_permohonan = StatusPermohonan::all();
|
$status_permohonan = StatusPermohonan::all();
|
||||||
return view('lpj::laporan-penilai-jaminan.index', compact('status_permohonan'));
|
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.
|
* 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)
|
public function dataForDatatables(Request $request)
|
||||||
{
|
{
|
||||||
@@ -93,91 +69,104 @@ class LaporanPenilaiJaminanController extends Controller
|
|||||||
// dd($startDate);
|
// dd($startDate);
|
||||||
// Retrieve data from the database
|
// Retrieve data from the database
|
||||||
$query = Permohonan::query();
|
$query = Permohonan::query();
|
||||||
|
$query = $query->where('status', 'done')->orderBy('tanggal_permohonan', 'desc');
|
||||||
// Apply search filter if provided
|
// Apply search filter if provided
|
||||||
if ($request->has('search') && !empty($request->get('search'))) {
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
$search = $request->get('search');
|
$search = json_decode($request->get('search'));
|
||||||
$paramsSearch = json_decode($search);
|
|
||||||
|
|
||||||
$query->where(function ($q) use ($search) {
|
if (!empty($search->start_date) || !empty($search->end_date)) {
|
||||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%')
|
$startDate = $search->start_date ?? '1900-01-01';
|
||||||
->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%')
|
$endDate = $search->end_date ?? now()->toDateString();
|
||||||
->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)) {
|
$query->where(function ($q) use ($startDate, $endDate) {
|
||||||
$q->whereBetween('tanggal_permohonan', [$paramsSearch->tanggal_awal, $paramsSearch->tanggal_akhir]);
|
|
||||||
|
$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]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 . '%');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$statusKeywords = explode(',', $search);
|
// dd($search->search);
|
||||||
foreach ($statusKeywords as $keyword) {
|
|
||||||
$q->orWhereRelation('penilai', 'type_penilai', 'LIKE', '%' . trim($keyword) . '%');
|
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 . '%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$query->where('status', 'done');
|
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
|
||||||
// Default sorting if no sort provided
|
|
||||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
$order = $request->get('sortOrder');
|
$order = $request->get('sortOrder');
|
||||||
$column = $request->get('sortField');
|
$column = $request->get('sortField');
|
||||||
$query->orderBy($column, $order);
|
$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();
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
// Pagination
|
// Apply pagination if provided
|
||||||
if ($request->has('page') && $request->has('size')) {
|
if ($request->has('page') && $request->has('size')) {
|
||||||
$page = (int) $request->get('page', 1);
|
$page = $request->get('page');
|
||||||
$size = (int) $request->get('size', 10);
|
$size = $request->get('size');
|
||||||
$offset = ($page - 1) * $size;
|
$offset = ($page - 1) * $size; // Calculate the offset
|
||||||
|
|
||||||
$query->skip($offset)->take($size);
|
$query->skip($offset)->take($size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get filtered count
|
// Get the filtered count of records
|
||||||
$filteredRecords = $query->count();
|
$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
|
// 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
|
// Calculate the page count
|
||||||
$pageCount = ceil($totalRecords / $request->get('size', 10));
|
$pageCount = ceil($totalRecords / $size);
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = max(1, $request->get('page', 1));
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
|
||||||
// Calculate total pages
|
|
||||||
$pageCount = ceil($totalRecords / $request->get('size', 10));
|
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'draw' => $request->get('draw'),
|
'draw' => $request->get('draw'),
|
||||||
'recordsTotal' => $totalRecords,
|
'recordsTotal' => $totalRecords,
|
||||||
'recordsFiltered' => $filteredRecords,
|
'recordsFiltered' => $filteredRecords,
|
||||||
'pageCount' => $pageCount,
|
'pageCount' => $pageCount,
|
||||||
'page' => $request->get('page', 1),
|
'page' => $currentPage,
|
||||||
'totalCount' => $totalRecords,
|
'totalCount' => $totalRecords,
|
||||||
'data' => $data,
|
'data' => $data,
|
||||||
]);
|
]);
|
||||||
@@ -185,15 +174,53 @@ class LaporanPenilaiJaminanController extends Controller
|
|||||||
|
|
||||||
public function export(Request $request)
|
public function export(Request $request)
|
||||||
{
|
{
|
||||||
$tanggalAwal = $request->input('tanggal_awal');
|
$startDate = $request->input('start_date');
|
||||||
$tanggalAkhir = $request->input('tanggal_akhir');
|
$endDate = $request->input('end_date');
|
||||||
$status = $request->input('status');
|
|
||||||
$selectedIds = $request->input('selected_ids');
|
// 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(
|
return Excel::download(
|
||||||
new LaporanPenilaiJaminanExport($tanggalAwal, $tanggalAkhir, $status, $selectedIds),
|
new LaporanPenilaiJaminanExport($request),
|
||||||
$filename
|
$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\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Modules\Lpj\Http\Requests\NocRequest;
|
use Modules\Lpj\Http\Requests\NocRequest;
|
||||||
|
use Modules\Lpj\Models\Noc;
|
||||||
use Modules\Lpj\Models\PenawaranTender;
|
use Modules\Lpj\Models\PenawaranTender;
|
||||||
use Modules\Lpj\Models\Permohonan;
|
use Modules\Lpj\Models\Permohonan;
|
||||||
use Modules\Lpj\Models\PersetujuanPenawaran;
|
use Modules\Lpj\Models\PersetujuanPenawaran;
|
||||||
@@ -18,9 +19,20 @@
|
|||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
|
{
|
||||||
|
return redirect()->route('noc.pembayaran.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function pembayaran()
|
||||||
{
|
{
|
||||||
$persetujuanPenawarans = PersetujuanPenawaran::all();
|
$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,34 +55,43 @@
|
|||||||
$status = "persetujuan-penawaran";
|
$status = "persetujuan-penawaran";
|
||||||
}
|
}
|
||||||
|
|
||||||
$persetujuanPenawaran = PersetujuanPenawaran::updateOrCreate(
|
|
||||||
['penawaran_id' => $validated['penawaran_id']],
|
$dataNoc = [
|
||||||
$validated,
|
'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')) {
|
if ($request->hasFile('bukti_ksl')) {
|
||||||
$persetujuanPenawaran->bukti_ksl = $request->file('bukti_ksl')->store(
|
$noc->bukti_ksl = $request->file('bukti_ksl')->store(
|
||||||
$folderPath,
|
$folderPath,
|
||||||
'public',
|
'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'));
|
$permohonan = Permohonan::find(request()->get('permohonan_id'));
|
||||||
if ($permohonan) {
|
if ($permohonan) {
|
||||||
$permohonan->status_bayar = request()->get('status_bayar');
|
$permohonan->status_bayar = request()->get('status_pembayar');
|
||||||
if($permohonan->jenis_penilaian_id==2) {
|
if ($permohonan->jenis_penilaian_id == 2) {
|
||||||
$permohonan->status = $status;
|
$permohonan->status = $status;
|
||||||
}
|
}
|
||||||
$permohonan->save();
|
$permohonan->save();
|
||||||
|
|
||||||
// andy add, update status penawaran.status='spk'
|
// andy add, update status penawaran.status='spk'
|
||||||
// $penawaran = PenawaranTender::where('nomor_registrasi',$permohonan->nomor_registrasi)->first();
|
// $penawaran = PenawaranTender::where('nomor_registrasi',$permohonan->nomor_registrasi)->first();
|
||||||
if($permohonan->jenis_penilaian_id==2) {
|
if ($permohonan->jenis_penilaian_id == 2) {
|
||||||
PenawaranTender::where('nomor_registrasi', $permohonan->nomor_registrasi)->update([
|
PenawaranTender::where('nomor_registrasi', $permohonan->nomor_registrasi)->update([
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
'updated_by' => Auth::id(),
|
'updated_by' => Auth::id(),
|
||||||
@@ -78,10 +99,10 @@
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
// andy add, update status penawaran.status='spk'
|
// andy add, update status penawaran.status='spk'
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return redirect()
|
return redirect()
|
||||||
->route('noc.index')->with('success', 'Penyelesaian KSL berhasil disimpan.');
|
->route('noc.index')->with('success', 'NOC berhasil disimpan.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,13 +110,58 @@
|
|||||||
*/
|
*/
|
||||||
public function update(NocRequest $request, PersetujuanPenawaran $persetujuanPenawaran)
|
public function update(NocRequest $request, PersetujuanPenawaran $persetujuanPenawaran)
|
||||||
{
|
{
|
||||||
$validated = $request->validated();
|
$validated = $request->validated();
|
||||||
$validated['updated_by'] = Auth::id();
|
|
||||||
|
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('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();
|
||||||
|
|
||||||
$persetujuanPenawaran->update($validated);
|
|
||||||
|
|
||||||
return redirect()
|
return redirect()
|
||||||
->route('noc.index')->with('success', 'Persetujuan Penawaran updated successfully');
|
->route('noc.index')->with('success', 'NOC updated successfully');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -109,16 +175,16 @@
|
|||||||
/**
|
/**
|
||||||
* Display the specified resource.
|
* 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.
|
* Show the form for editing the specified resource.
|
||||||
*/
|
*/
|
||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
$persetujuanPenawaran = PersetujuanPenawaran::where('id', $id)->with(
|
$persetujuanPenawaran = PersetujuanPenawaran::where('id', $id)->first();
|
||||||
['penawaran.detail', 'penawaran.permohonan.debiture','permohonan'],
|
|
||||||
)->first();
|
|
||||||
return view('lpj::noc.form', compact('persetujuanPenawaran'));
|
return view('lpj::noc.form', compact('persetujuanPenawaran'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,6 +200,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function dataForDatatables(Request $request)
|
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')) {
|
if (is_null($this->user) || !$this->user->can('noc.view')) {
|
||||||
//abort(403, 'Sorry! You are not allowed to view persetujuan penawaran.');
|
//abort(403, 'Sorry! You are not allowed to view persetujuan penawaran.');
|
||||||
@@ -142,6 +214,11 @@
|
|||||||
// Retrieve data from the database
|
// Retrieve data from the database
|
||||||
$query = PersetujuanPenawaran::query();
|
$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
|
// Apply search filter if provided
|
||||||
if ($request->has('search') && !empty($request->get('search'))) {
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
$search = $request->get('search');
|
$search = $request->get('search');
|
||||||
@@ -173,18 +250,122 @@
|
|||||||
$filteredRecords = $query->count();
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
// Get the data for the current page
|
// Get the data for the current page
|
||||||
$data = $query
|
$data = $query->get();
|
||||||
->with(
|
|
||||||
[
|
|
||||||
'penawaran.permohonan.debiture',
|
|
||||||
'penawaran.permohonan.branch',
|
|
||||||
'permohonan.debiture',
|
|
||||||
'permohonan.branch',
|
|
||||||
'penawaran.detail',
|
|
||||||
'penawaran.persetujuan',
|
|
||||||
],
|
|
||||||
)->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
|
// Calculate the page count
|
||||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|||||||
@@ -263,8 +263,7 @@ class PembayaranController extends Controller
|
|||||||
$subquery->select('permohonan_id')
|
$subquery->select('permohonan_id')
|
||||||
->from('persetujuan_penawaran')
|
->from('persetujuan_penawaran')
|
||||||
->whereNotNull('permohonan_id');
|
->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\Authorization;
|
||||||
use Modules\Lpj\Models\Debiture;
|
use Modules\Lpj\Models\Debiture;
|
||||||
use Modules\Lpj\Services\SaveFormInspesksiService;
|
use Modules\Lpj\Services\SaveFormInspesksiService;
|
||||||
|
use Modules\Lpj\Services\PreviewLaporanService;
|
||||||
|
|
||||||
class PenilaiController extends Controller
|
class PenilaiController extends Controller
|
||||||
{
|
{
|
||||||
public $user;
|
public $user;
|
||||||
protected $surveyorController;
|
protected $surveyorController;
|
||||||
protected $inspeksiService;
|
protected $inspeksiService;
|
||||||
|
protected $previewLaporanService;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(SurveyorController $surveyorController, SaveFormInspesksiService $inspeksiService)
|
public function __construct(SurveyorController $surveyorController, SaveFormInspesksiService $inspeksiService, PreviewLaporanService $previewLaporanService)
|
||||||
{
|
{
|
||||||
$this->surveyorController = $surveyorController;
|
$this->surveyorController = $surveyorController;
|
||||||
$this->inspeksiService = $inspeksiService;
|
$this->inspeksiService = $inspeksiService;
|
||||||
|
$this->previewLaporanService = $previewLaporanService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,6 +155,11 @@ class PenilaiController extends Controller
|
|||||||
$jaminanId = $request->query('jaminanId');
|
$jaminanId = $request->query('jaminanId');
|
||||||
|
|
||||||
$permohonan = $this->surveyorController->getPermohonanJaminanId($id, $documentId, $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();
|
$basicData = $this->surveyorController->getCommonData();
|
||||||
$noLpSederhana = $this->generateNoLaporan($permohonan, $documentId, 'lpj');
|
$noLpSederhana = $this->generateNoLaporan($permohonan, $documentId, 'lpj');
|
||||||
|
|
||||||
@@ -218,6 +226,11 @@ class PenilaiController extends Controller
|
|||||||
$jaminanId = $request->query('jaminanId');
|
$jaminanId = $request->query('jaminanId');
|
||||||
|
|
||||||
$permohonan = $this->surveyorController->getPermohonanJaminanId($permohonanId, $documentId, $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');
|
$nomorLaporan = $this->generateNoLaporan($permohonan, $documentId, 'resume');
|
||||||
$inspeksi = Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
|
$inspeksi = Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
|
||||||
$noLpresume = $this->generateNoLaporan($permohonan, $documentId, 'resume');
|
$noLpresume = $this->generateNoLaporan($permohonan, $documentId, 'resume');
|
||||||
@@ -253,6 +266,9 @@ class PenilaiController extends Controller
|
|||||||
|
|
||||||
$data = $this->getDataPermohonanWithPenilaiAndInspeksi($req['permohonanId'], $req['documentId'], $req['jaminanId']);
|
$data = $this->getDataPermohonanWithPenilaiAndInspeksi($req['permohonanId'], $req['documentId'], $req['jaminanId']);
|
||||||
$permohonan = $data['permohonan'];
|
$permohonan = $data['permohonan'];
|
||||||
|
if ($permohonan->status == 'proses-laporan') {
|
||||||
|
return redirect()->back()->with('error', 'Masih dalam proses laporan');
|
||||||
|
}
|
||||||
|
|
||||||
$nomorLaporan = $this->generateNoLaporan($permohonan, $req['documentId'], 'memo');
|
$nomorLaporan = $this->generateNoLaporan($permohonan, $req['documentId'], 'memo');
|
||||||
$inspeksi = Inspeksi::where('permohonan_id', $req['permohonanId'])->where('dokument_id', $req['documentId'])->first();
|
$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');
|
$jaminanId = $request->query('jaminanId');
|
||||||
$provinces = Province::all();
|
$provinces = Province::all();
|
||||||
$permohonan = $this->surveyorController->getPermohonanJaminanId($permohonanId, $documentId, $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, 'rap');
|
$nomorLaporan = $this->generateNoLaporan($permohonan, $documentId, 'rap');
|
||||||
$basicData = $this->surveyorController->getCommonData();
|
$basicData = $this->surveyorController->getCommonData();
|
||||||
$inspeksi = Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
|
$inspeksi = Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
|
||||||
@@ -470,6 +491,9 @@ class PenilaiController extends Controller
|
|||||||
$jaminanId = $request->query('jaminanId');
|
$jaminanId = $request->query('jaminanId');
|
||||||
$provinces = Province::all();
|
$provinces = Province::all();
|
||||||
$permohonan = $this->surveyorController->getPermohonanJaminanId($permohonanId, $documentId, $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, 'call-report');
|
$nomorLaporan = $this->generateNoLaporan($permohonan, $documentId, 'call-report');
|
||||||
$basicData = $this->surveyorController->getCommonData();
|
$basicData = $this->surveyorController->getCommonData();
|
||||||
$inspeksi = Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
|
$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'));
|
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)
|
public function dataForDatatables(Request $request)
|
||||||
{
|
{
|
||||||
@@ -679,15 +697,17 @@ class PenilaiController extends Controller
|
|||||||
'lokasi_lengkap' => $data->lokasi_lengkap ?? '',
|
'lokasi_lengkap' => $data->lokasi_lengkap ?? '',
|
||||||
];
|
];
|
||||||
|
|
||||||
// Extract data pembanding
|
if(isset($dataPembanding)){
|
||||||
if (isset($dataPembanding['data_pembanding'])) {
|
// Extract data pembanding
|
||||||
foreach ($dataPembanding['data_pembanding'] as $index => $pembanding) {
|
if (isset($dataPembanding['data_pembanding'])) {
|
||||||
if ($index == 0) {
|
foreach ($dataPembanding['data_pembanding'] as $index => $pembanding) {
|
||||||
$exportData['pembanding1'] = $pembanding;
|
if ($index == 0) {
|
||||||
} elseif ($index == 1) {
|
$exportData['pembanding1'] = $pembanding;
|
||||||
$exportData['pembanding2'] = $pembanding;
|
} elseif ($index == 1) {
|
||||||
} elseif ($index == 2) {
|
$exportData['pembanding2'] = $pembanding;
|
||||||
$exportData['pembanding3'] = $pembanding;
|
} elseif ($index == 2) {
|
||||||
|
$exportData['pembanding3'] = $pembanding;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1056,14 +1076,14 @@ class PenilaiController extends Controller
|
|||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
$kategoriUnik = ['tanah', 'bangunan', 'apartemen-kantor', 'alat-berat', 'mesin', 'kendaraan', 'pesawat', 'kapal', 'sarana_pelengkap_penilai'];
|
$kategoriUnik = ['tanah', 'bangunan', 'apartemen-kantor', 'alat-berat', 'mesin', 'kendaraan', 'pesawat', 'kapal', 'sarana_pelengkap_penilai'];
|
||||||
|
|
||||||
foreach ($kategoriUnik as $kategori) {
|
foreach ($kategoriUnik as $kategori) {
|
||||||
// Dynamically generate keys
|
// Dynamically generate keys
|
||||||
$luasKey = 'luas_' . $kategori;
|
$luasKey = 'luas_' . $kategori;
|
||||||
$nilaiKey1 = 'nilai_' . $kategori . '_1';
|
$nilaiKey1 = 'nilai_' . $kategori . '_1';
|
||||||
$nilaiKey2 = 'nilai_' . $kategori . '_2';
|
$nilaiKey2 = 'nilai_' . $kategori . '_2';
|
||||||
|
|
||||||
// Collect data if exists
|
// Collect data if exists
|
||||||
if ($request->has($luasKey)) {
|
if ($request->has($luasKey)) {
|
||||||
$data[$luasKey] = $request->input($luasKey);
|
$data[$luasKey] = $request->input($luasKey);
|
||||||
@@ -1075,7 +1095,7 @@ class PenilaiController extends Controller
|
|||||||
$data[$nilaiKey2] = $request->input($nilaiKey2);
|
$data[$nilaiKey2] = $request->input($nilaiKey2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['total_nilai_pasar_wajar'] = $request->input('total_nilai_pasar_wajar');
|
$data['total_nilai_pasar_wajar'] = $request->input('total_nilai_pasar_wajar');
|
||||||
$data['likuidasi'] = $request->input('likuidasi');
|
$data['likuidasi'] = $request->input('likuidasi');
|
||||||
$data['likuidasi_nilai_1'] = $request->input('likuidasi_nilai_1');
|
$data['likuidasi_nilai_1'] = $request->input('likuidasi_nilai_1');
|
||||||
@@ -1104,8 +1124,7 @@ class PenilaiController extends Controller
|
|||||||
$penilai = Penilai::updateOrCreate(
|
$penilai = Penilai::updateOrCreate(
|
||||||
[
|
[
|
||||||
'permohonan_id' => $request->permohonanId,
|
'permohonan_id' => $request->permohonanId,
|
||||||
'dokument_id' => $request->documentId,
|
'dokument_id' => $request->input('dokument_id'),
|
||||||
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'lpj' => json_encode($data),
|
'lpj' => json_encode($data),
|
||||||
@@ -1132,20 +1151,9 @@ class PenilaiController extends Controller
|
|||||||
{
|
{
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
try {
|
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();
|
$validatedData = $request->all();
|
||||||
$result = $this->surveyorController->store($formRequest);
|
$result = $this->inspeksiService->storeInspeksi($validatedData, $request->input('type'), $request);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'kepada' => $request->input('kepada'),
|
'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');
|
// jika tidak ada id kembalikan ke halaman sebelumnya
|
||||||
$jaminanId = $request->query('jaminanId');
|
if (!$permohonan_id || !$document_id || !$jaminan_id) {
|
||||||
$permohonanId = $request->query('permohonanId');
|
return redirect()->back()->with('error', 'Laporan tidak valid');
|
||||||
$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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return $this->previewLaporanService->printOutLaporan($permohonan_id, $document_id, $jaminan_id);
|
||||||
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';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -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)
|
protected function getRequestQueryId(Request $request)
|
||||||
{
|
{
|
||||||
return [
|
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)
|
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)
|
public function revisiSurveyor(Request $request, $id)
|
||||||
{
|
{
|
||||||
$permohonan = Permohonan::findOrFail($id);
|
$permohonan = Permohonan::findOrFail($id);
|
||||||
@@ -1762,4 +1379,24 @@ class PenilaiController extends Controller
|
|||||||
'message' => 'Berhasil Revisi Ke surveyor',
|
'message' => 'Berhasil Revisi Ke surveyor',
|
||||||
], 200);
|
], 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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,486 +1,518 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Modules\Lpj\Http\Controllers;
|
namespace Modules\Lpj\Http\Controllers;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Barryvdh\DomPDF\Facade\Pdf;
|
use Exception;
|
||||||
use Exception;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Modules\Location\Models\City;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Modules\Location\Models\District;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
use Modules\Location\Models\Province;
|
use Modules\Location\Models\City;
|
||||||
use Modules\Location\Models\Village;
|
use Modules\Location\Models\District;
|
||||||
use Modules\Lpj\Models\PermohonanPembatalan;
|
use Modules\Location\Models\Province;
|
||||||
use Modules\Lpj\Exports\PermohonanExport;
|
use Modules\Location\Models\Village;
|
||||||
use Modules\Lpj\Http\Requests\PermohonanRequest;
|
use Modules\Lpj\Exports\PermohonanExport;
|
||||||
use Modules\Lpj\Models\Branch;
|
use Modules\Lpj\Http\Requests\PermohonanRequest;
|
||||||
use Modules\Lpj\Models\Debiture;
|
use Modules\Lpj\Models\Branch;
|
||||||
use Modules\Lpj\Models\DokumenJaminan;
|
use Modules\Lpj\Models\Debiture;
|
||||||
use Modules\Lpj\Models\JenisFasilitasKredit;
|
use Modules\Lpj\Models\DokumenJaminan;
|
||||||
use Modules\Lpj\Models\NilaiPlafond;
|
use Modules\Lpj\Models\JenisFasilitasKredit;
|
||||||
use Modules\Lpj\Models\Permohonan;
|
use Modules\Lpj\Models\NilaiPlafond;
|
||||||
use Modules\Lpj\Models\StatusPermohonan;
|
use Modules\Lpj\Models\Penilaian;
|
||||||
use Modules\Lpj\Models\TujuanPenilaian;
|
use Modules\Lpj\Models\Permohonan;
|
||||||
use Modules\Lpj\Services\PermohonanHistoryService;
|
use Modules\Lpj\Models\PermohonanPembatalan;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Modules\Lpj\Models\StatusPermohonan;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Modules\Lpj\Models\TujuanPenilaian;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Modules\Lpj\Services\PermohonanHistoryService;
|
||||||
use Modules\Lpj\Models\Penilaian;
|
|
||||||
|
|
||||||
class PermohonanController extends Controller
|
class PermohonanController extends Controller
|
||||||
{
|
|
||||||
public $user;
|
|
||||||
protected $historyService;
|
|
||||||
|
|
||||||
public function __construct(PermohonanHistoryService $historyService)
|
|
||||||
{
|
{
|
||||||
$this->historyService = $historyService;
|
public $user;
|
||||||
}
|
protected $historyService;
|
||||||
|
|
||||||
public function index()
|
public function __construct(PermohonanHistoryService $historyService)
|
||||||
{
|
{
|
||||||
return view('lpj::permohonan.index');
|
$this->historyService = $historyService;
|
||||||
}
|
|
||||||
|
|
||||||
public function store(PermohonanRequest $request)
|
|
||||||
{
|
|
||||||
$validate = $request->validated();
|
|
||||||
if ($validate) {
|
|
||||||
try {
|
|
||||||
// Process file upload
|
|
||||||
$filePath = null;
|
|
||||||
if ($request->hasFile('attachment')) {
|
|
||||||
$file = $request->file('attachment');
|
|
||||||
$fileName = time() . '_' . $file->getClientOriginalName();
|
|
||||||
$filePath = $file->storeAs('permohonan_attachments', $fileName, 'public');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get keterangan if provided
|
|
||||||
$keterangan = $request->input('keterangan') ?? null;
|
|
||||||
|
|
||||||
|
|
||||||
// Save to database
|
|
||||||
$permohonan = Permohonan::create($validate);
|
|
||||||
|
|
||||||
// Create history
|
|
||||||
$this->historyService->createHistory(
|
|
||||||
$permohonan,
|
|
||||||
$validate['status'],
|
|
||||||
$keterangan,
|
|
||||||
[], // beforeRequest is empty for new permohonan
|
|
||||||
$permohonan->toArray(),
|
|
||||||
$filePath,
|
|
||||||
);
|
|
||||||
|
|
||||||
$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 created successfully');
|
|
||||||
} catch (Exception $e) {
|
|
||||||
return redirect()
|
|
||||||
->route('permohonan.create')->with('error', 'Failed to create permohonan' . $e->getMessage());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return redirect()
|
|
||||||
->route('permohonan.create')->with('success', 'error naon iye')->withInput();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function create()
|
public function index()
|
||||||
{
|
{
|
||||||
return view('lpj::permohonan.create');
|
return view('lpj::permohonan.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPermohonan($debitur)
|
public function store(PermohonanRequest $request)
|
||||||
{
|
{
|
||||||
$branches = Branch::all();
|
$validate = $request->validated();
|
||||||
$debitur = Debiture::find($debitur);
|
if ($validate) {
|
||||||
$tujuanPenilaian = TujuanPenilaian::all();
|
try {
|
||||||
$status = StatusPermohonan::all();
|
// Process file upload
|
||||||
$fasilitasKredit = JenisFasilitasKredit::all();
|
$filePath = null;
|
||||||
$plafond = NilaiPlafond::all();
|
if ($request->hasFile('attachment')) {
|
||||||
|
$file = $request->file('attachment');
|
||||||
|
$fileName = time() . '_' . $file->getClientOriginalName();
|
||||||
|
$filePath = $file->storeAs('permohonan_attachments', $fileName, 'public');
|
||||||
|
}
|
||||||
|
|
||||||
return view(
|
// Get keterangan if provided
|
||||||
'lpj::permohonan.form',
|
$keterangan = $request->input('keterangan') ?? null;
|
||||||
compact('branches', 'debitur', 'tujuanPenilaian', 'status', 'fasilitasKredit', 'plafond'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function edit($id)
|
|
||||||
{
|
|
||||||
$permohonan = Permohonan::find($id);
|
|
||||||
$branches = Branch::all();
|
|
||||||
$debitur = Debiture::find($permohonan->debiture_id);
|
|
||||||
$tujuanPenilaian = TujuanPenilaian::all();
|
|
||||||
$status = StatusPermohonan::all();
|
|
||||||
$provinces = Province::all();
|
|
||||||
$cities = City::where('province_code', $debitur->province_code)->get();
|
|
||||||
$districts = District::where('city_code', $debitur->city_code)->get();
|
|
||||||
$villages = Village::where('district_code', $debitur->district_code)->get();
|
|
||||||
$documents = DokumenJaminan::with('pemilik', 'detail')->where('debiture_id', $id)->get();
|
|
||||||
|
|
||||||
$fasilitasKredit = JenisFasilitasKredit::all();
|
// Save to database
|
||||||
$plafond = NilaiPlafond::all();
|
$permohonan = Permohonan::create($validate);
|
||||||
|
|
||||||
return view(
|
// Create history
|
||||||
'lpj::permohonan.form',
|
$this->historyService->createHistory(
|
||||||
compact(
|
$permohonan,
|
||||||
'permohonan',
|
$validate['status'],
|
||||||
'branches',
|
$keterangan,
|
||||||
'debitur',
|
[], // beforeRequest is empty for new permohonan
|
||||||
'tujuanPenilaian',
|
$permohonan->toArray(),
|
||||||
'status',
|
$filePath,
|
||||||
'provinces',
|
);
|
||||||
'cities',
|
|
||||||
'districts',
|
|
||||||
'villages',
|
|
||||||
'documents',
|
|
||||||
'fasilitasKredit',
|
|
||||||
'plafond',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(PermohonanRequest $request, $id)
|
$documents = DokumenJaminan::where('permohonan_id', $permohonan->id)->get();
|
||||||
{
|
if (count($documents) < 1) {
|
||||||
$permohonan = Permohonan::findOrFail($id);
|
return redirect()->route(
|
||||||
$beforeRequest = $permohonan->toArray();
|
'debitur.jaminan.create',
|
||||||
|
array_merge(['permohonan_id' => $permohonan->id], ['id' => $permohonan->debiture->id]),
|
||||||
$validate = $request->validated();
|
)->with('success', 'Permohonan created successfully, Lengkapi data jaminan terlebih dahulu');
|
||||||
if ($validate) {
|
}
|
||||||
try {
|
return redirect()
|
||||||
// Update in database
|
->route('permohonan.index')->with('success', 'Permohonan created successfully');
|
||||||
|
} catch (Exception $e) {
|
||||||
if ($permohonan->status == 'revisi') {
|
return redirect()
|
||||||
$validate['status'] = 'order';
|
->route('permohonan.create')->with('error', 'Failed to create permohonan' . $e->getMessage());
|
||||||
}
|
}
|
||||||
$permohonan->update($validate);
|
} else {
|
||||||
|
|
||||||
$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()
|
return redirect()
|
||||||
->route('permohonan.index')->with('success', 'Permohonan updated successfully');
|
->route('permohonan.create')->with('success', 'error naon iye')->withInput();
|
||||||
} catch (Exception $e) {
|
|
||||||
return redirect()
|
|
||||||
->route('permohonan.edit', $id)->with('error', 'Failed to update permohonan');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function destroy($id)
|
public function create()
|
||||||
{
|
{
|
||||||
try {
|
return view('lpj::permohonan.create');
|
||||||
// Delete from database
|
}
|
||||||
|
|
||||||
|
public function createPermohonan($debitur)
|
||||||
|
{
|
||||||
|
$branches = Branch::all();
|
||||||
|
$debitur = Debiture::find($debitur);
|
||||||
|
$tujuanPenilaian = TujuanPenilaian::all();
|
||||||
|
$status = StatusPermohonan::all();
|
||||||
|
$fasilitasKredit = JenisFasilitasKredit::all();
|
||||||
|
$plafond = NilaiPlafond::all();
|
||||||
|
|
||||||
|
return view(
|
||||||
|
'lpj::permohonan.form',
|
||||||
|
compact('branches', 'debitur', 'tujuanPenilaian', 'status', 'fasilitasKredit', 'plafond'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$permohonan = Permohonan::find($id);
|
||||||
|
$branches = Branch::all();
|
||||||
|
$debitur = Debiture::find($permohonan->debiture_id);
|
||||||
|
$tujuanPenilaian = TujuanPenilaian::all();
|
||||||
|
$status = StatusPermohonan::all();
|
||||||
|
$provinces = Province::all();
|
||||||
|
$cities = City::where('province_code', $debitur->province_code)->get();
|
||||||
|
$districts = District::where('city_code', $debitur->city_code)->get();
|
||||||
|
$villages = Village::where('district_code', $debitur->district_code)->get();
|
||||||
|
$documents = DokumenJaminan::with('pemilik', 'detail')->where('debiture_id', $id)->get();
|
||||||
|
|
||||||
|
$fasilitasKredit = JenisFasilitasKredit::all();
|
||||||
|
$plafond = NilaiPlafond::all();
|
||||||
|
|
||||||
|
return view(
|
||||||
|
'lpj::permohonan.form',
|
||||||
|
compact(
|
||||||
|
'permohonan',
|
||||||
|
'branches',
|
||||||
|
'debitur',
|
||||||
|
'tujuanPenilaian',
|
||||||
|
'status',
|
||||||
|
'provinces',
|
||||||
|
'cities',
|
||||||
|
'districts',
|
||||||
|
'villages',
|
||||||
|
'documents',
|
||||||
|
'fasilitasKredit',
|
||||||
|
'plafond',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Delete from database
|
||||||
|
$permohonan = Permohonan::find($id);
|
||||||
|
$permohonan->delete();
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Permohonan deleted successfully']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Failed to delete permohonan']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = Permohonan::query();
|
||||||
|
|
||||||
|
if (!Auth::user()->hasAnyRole(['administrator'])) {
|
||||||
|
$query = $query->where('branch_id', Auth::user()->branch_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = $query->orderBy('nomor_registrasi', 'desc');
|
||||||
|
// 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('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 . '%');
|
||||||
|
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('status', '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();
|
||||||
|
$size = $request->get('size', 10);
|
||||||
|
if ($size == 0) {
|
||||||
|
$size = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 ($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);
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = max(1, $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()
|
||||||
|
{
|
||||||
|
return Excel::download(new PermohonanExport(), 'permohonan.xlsx');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function authorization()
|
||||||
|
{
|
||||||
|
return view('lpj::permohonan.authorization.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataForAuthorization(Request $request)
|
||||||
|
{
|
||||||
|
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||||
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = Permohonan::query()->with('documents')->has('documents', '>', 0)->where('status', '=', 'order');
|
||||||
|
|
||||||
|
if (!Auth::user()->hasAnyRole(['administrator'])) {
|
||||||
|
$query = $query->where('branch_id', Auth::user()->branch_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('debiture', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||||
|
$q->orWhere('status', '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->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])->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,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showAuthorization($id)
|
||||||
|
{
|
||||||
$permohonan = Permohonan::find($id);
|
$permohonan = Permohonan::find($id);
|
||||||
$permohonan->delete();
|
return view('lpj::permohonan.authorization.show', compact('permohonan'));
|
||||||
|
|
||||||
echo json_encode(['success' => true, 'message' => 'Permohonan deleted successfully']);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
echo json_encode(['success' => false, 'message' => 'Failed to delete permohonan']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function dataForDatatables(Request $request)
|
|
||||||
{
|
|
||||||
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
|
||||||
//abort(403, 'Sorry! You are not allowed to view users.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve data from the database
|
public function updateAuthorization(Request $request, $id)
|
||||||
$query = Permohonan::query();
|
{
|
||||||
|
|
||||||
if (!Auth::user()->hasAnyRole(['administrator'])) {
|
|
||||||
$query = $query->where('branch_id', Auth::user()->branch_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = $query->orderBy('nomor_registrasi', 'desc');
|
|
||||||
// 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('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
|
||||||
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
|
||||||
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
|
||||||
$q->orWhereRelation('debiture', 'name', 'LIKE', '%' . $search . '%');
|
|
||||||
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
|
||||||
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
|
||||||
$q->orWhere('status', '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();
|
|
||||||
$size = $request->get('size', 10);
|
|
||||||
if ($size == 0) {
|
|
||||||
$size = 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian','documents'])->get();
|
|
||||||
|
|
||||||
// Calculate the page count
|
|
||||||
$pageCount = ceil($totalRecords / $size);
|
|
||||||
|
|
||||||
// Calculate the current page number
|
|
||||||
$currentPage = max(1, $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()
|
|
||||||
{
|
|
||||||
return Excel::download(new PermohonanExport(), 'permohonan.xlsx');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function authorization()
|
|
||||||
{
|
|
||||||
return view('lpj::permohonan.authorization.index');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function dataForAuthorization(Request $request)
|
|
||||||
{
|
|
||||||
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
|
||||||
//abort(403, 'Sorry! You are not allowed to view users.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve data from the database
|
|
||||||
$query = Permohonan::query()->with('documents')->has('documents', '>', 0)->where('status', '=', 'order');
|
|
||||||
|
|
||||||
if (!Auth::user()->hasAnyRole(['administrator'])) {
|
|
||||||
$query = $query->where('branch_id', Auth::user()->branch_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
|
||||||
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
|
|
||||||
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
|
||||||
$q->orWhereRelation('debiture', 'name', 'LIKE', '%' . $search . '%');
|
|
||||||
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
|
||||||
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
|
||||||
$q->orWhere('status', '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->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])->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,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function showAuthorization($id)
|
|
||||||
{
|
|
||||||
$permohonan = Permohonan::find($id);
|
|
||||||
return view('lpj::permohonan.authorization.show', compact('permohonan'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateAuthorization(Request $request, $id)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$permohonan = Permohonan::find($id);
|
|
||||||
$permohonan->status = $request->status;
|
|
||||||
$permohonan->keterangan = $request->keterangan;
|
|
||||||
$permohonan->save();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
return redirect()->route('authorization.show', $id)->with('error', 'Failed to update permohonan');
|
|
||||||
}
|
|
||||||
|
|
||||||
return redirect()->route('authorization.index')->with('success', 'Permohonan updated successfully');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function show($id)
|
|
||||||
{
|
|
||||||
$permohonan = Permohonan::find($id);
|
|
||||||
|
|
||||||
return view('lpj::permohonan.show', compact('permohonan'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function print($id)
|
|
||||||
{
|
|
||||||
$permohonan = Permohonan::find($id);
|
|
||||||
return view('lpj::permohonan.print', compact('permohonan'));
|
|
||||||
|
|
||||||
// $pdf = Pdf::loadView('lpj::permohonan.print', compact('permohonan'));
|
|
||||||
// return $pdf->stream();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function showPembatalan($id)
|
|
||||||
{
|
|
||||||
$permohonan = Permohonan::with(['pembatalan','debiture'])->findOrFail($id);
|
|
||||||
return view('lpj::permohonan.pembatalan-form', compact('permohonan'));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function pembatalan(Request $request)
|
|
||||||
{
|
|
||||||
// Validate the request
|
|
||||||
$validatedData = $request->validate([
|
|
||||||
'permohonan_id' => 'required|exists:permohonan,id',
|
|
||||||
'alasan_pembatalan' => 'required|string',
|
|
||||||
'file_pembatalan' => 'required|file|mimes:pdf,doc,docx|max:2048',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Handle file upload
|
|
||||||
if ($request->hasFile('file_pembatalan')) {
|
|
||||||
$file = $request->file('file_pembatalan');
|
|
||||||
$filename = time() . '_' . $file->getClientOriginalName();
|
|
||||||
$filePath = $file->storeAs('pembatalan', $filename, 'public');
|
|
||||||
$validatedData['file_pembatalan'] = $filePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add created_by
|
|
||||||
$validatedData['created_by'] = auth()->id();
|
|
||||||
|
|
||||||
// Create new PermohonanPembatalan
|
|
||||||
$pembatalan = PermohonanPembatalan::create($validatedData);
|
|
||||||
|
|
||||||
return redirect()->route('permohonan.index')->with('success', 'Pembatalan Permohonan Menunggu Approval');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function storeAproved(Request $request, $id): JsonResponse
|
|
||||||
{
|
|
||||||
$data = [];
|
|
||||||
if (request()->ajax()) {
|
|
||||||
try {
|
try {
|
||||||
$penilaian = Penilaian::findOrFail($id);
|
$permohonan = Permohonan::find($id);
|
||||||
$penilaian->update([
|
$permohonan->status = $request->status;
|
||||||
'authorized_status' => 1,
|
$permohonan->keterangan = $request->keterangan;
|
||||||
]);
|
$permohonan->save();
|
||||||
|
} catch (Exception $e) {
|
||||||
$permohonan = Permohonan::findOrFail($request->permohonan_id);
|
return redirect()->route('authorization.show', $id)->with('error', 'Failed to update permohonan');
|
||||||
|
|
||||||
$permohonan->update([
|
|
||||||
'status' => 'proses-survey'
|
|
||||||
]);
|
|
||||||
|
|
||||||
$data['status'] = 'success';
|
|
||||||
$data['message'] = 'Jadwal '.$request->noReg.' berhasil di aprove';
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$data['status'] = 'error';
|
|
||||||
$data['message'] = 'Gagal membuat jadwal: ' . $e->getMessage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
return redirect()->route('authorization.index')->with('success', 'Permohonan updated successfully');
|
||||||
$data['status'] = 'error';
|
|
||||||
$data['message'] = "no ajax request";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json($data);
|
public function show($id)
|
||||||
}
|
{
|
||||||
|
$permohonan = Permohonan::find($id);
|
||||||
|
|
||||||
|
return view('lpj::permohonan.show', compact('permohonan'));
|
||||||
|
}
|
||||||
|
|
||||||
public function storeRescheduleSurvey(Request $request, $id)
|
public function print($id)
|
||||||
{
|
{
|
||||||
try {
|
$permohonan = Permohonan::find($id);
|
||||||
|
return view('lpj::permohonan.print', compact('permohonan'));
|
||||||
|
|
||||||
|
// $pdf = Pdf::loadView('lpj::permohonan.print', compact('permohonan'));
|
||||||
|
// return $pdf->stream();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showPembatalan($id)
|
||||||
|
{
|
||||||
|
$permohonan = Permohonan::with(['pembatalan', 'debiture'])->findOrFail($id);
|
||||||
|
return view('lpj::permohonan.pembatalan-form', compact('permohonan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function pembatalan(Request $request)
|
||||||
|
{
|
||||||
|
// Validate the request
|
||||||
$validatedData = $request->validate([
|
$validatedData = $request->validate([
|
||||||
'permohonan_id' => 'required|exists:permohonan,id',
|
'permohonan_id' => 'required|exists:permohonan,id',
|
||||||
'penilaian_id' => 'nullable',
|
'alasan_pembatalan' => 'required|string',
|
||||||
'nomor_registrasi' => 'required',
|
'file_pembatalan' => 'required|file|mimes:pdf,doc,docx|max:2048',
|
||||||
'reschedule_note' => 'required',
|
|
||||||
'reschedule_date' => 'required',
|
|
||||||
'keterangan' => 'required'
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
DB::beginTransaction();
|
// Handle file upload
|
||||||
|
if ($request->hasFile('file_pembatalan')) {
|
||||||
|
$file = $request->file('file_pembatalan');
|
||||||
|
$filename = time() . '_' . $file->getClientOriginalName();
|
||||||
|
$filePath = $file->storeAs('pembatalan', $filename, 'public');
|
||||||
|
$validatedData['file_pembatalan'] = $filePath;
|
||||||
|
}
|
||||||
|
|
||||||
$permohonan = Permohonan::findOrFail($request->permohonan_id);
|
// Add created_by
|
||||||
$permohonan->update([
|
$validatedData['created_by'] = auth()->id();
|
||||||
'status' => 'request-reschedule'
|
|
||||||
]);
|
|
||||||
|
|
||||||
$penilaian = Penilaian::findOrFail($id);
|
// Create new PermohonanPembatalan
|
||||||
|
$pembatalan = PermohonanPembatalan::create($validatedData);
|
||||||
|
|
||||||
$penilaian->update([
|
return redirect()->route('permohonan.index')->with('success', 'Pembatalan Permohonan Menunggu Approval');
|
||||||
'reschedule_date' => $request->reschedule_date,
|
|
||||||
'reschedule_note' => $request->reschedule_note,
|
|
||||||
]);
|
|
||||||
|
|
||||||
DB::commit();
|
|
||||||
return response()->json([
|
|
||||||
'status' => 'success',
|
|
||||||
'message' => 'Proses request reschedule permohonan Nomor registrasi '.$request->nomor_registrasi.' berhasil',
|
|
||||||
]);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
DB::rollBack();
|
|
||||||
return response()->json([
|
|
||||||
'status' => 'error',
|
|
||||||
'message' => 'Gagal membuat request reschedule: ' . $e->getMessage(),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
public function storeAproved(Request $request, $id)
|
||||||
|
: JsonResponse {
|
||||||
|
$data = [];
|
||||||
|
if (request()->ajax()) {
|
||||||
|
try {
|
||||||
|
$penilaian = Penilaian::findOrFail($id);
|
||||||
|
$penilaian->update([
|
||||||
|
'authorized_status' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$permohonan = Permohonan::findOrFail($request->permohonan_id);
|
||||||
|
|
||||||
|
$permohonan->update([
|
||||||
|
'status' => 'proses-survey',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data['status'] = 'success';
|
||||||
|
$data['message'] = 'Jadwal ' . $request->noReg . ' berhasil di aprove';
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message'] = 'Gagal membuat jadwal: ' . $e->getMessage();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$data['status'] = 'error';
|
||||||
|
$data['message'] = "no ajax request";
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$validatedData = $request->validate([
|
||||||
|
'permohonan_id' => 'required|exists:permohonan,id',
|
||||||
|
'penilaian_id' => 'nullable',
|
||||||
|
'nomor_registrasi' => 'required',
|
||||||
|
'reschedule_note' => 'required',
|
||||||
|
'reschedule_date' => 'required',
|
||||||
|
'keterangan' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
$permohonan = Permohonan::findOrFail($request->permohonan_id);
|
||||||
|
$permohonan->update([
|
||||||
|
'status' => 'request-reschedule',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$penilaian = Penilaian::findOrFail($id);
|
||||||
|
|
||||||
|
$penilaian->update([
|
||||||
|
'reschedule_date' => $request->reschedule_date,
|
||||||
|
'reschedule_note' => $request->reschedule_note,
|
||||||
|
]);
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'success',
|
||||||
|
'message' => 'Proses request reschedule permohonan Nomor registrasi ' . $request->nomor_registrasi . ' berhasil',
|
||||||
|
]);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => 'Gagal membuat request reschedule: ' . $e->getMessage(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Modules\Lpj\Http\Requests\PersetujuanPenawaranRequest;
|
use Modules\Lpj\Http\Requests\PersetujuanPenawaranRequest;
|
||||||
|
use Modules\Lpj\Models\Noc;
|
||||||
use Modules\Lpj\Models\PenawaranDetailTender;
|
use Modules\Lpj\Models\PenawaranDetailTender;
|
||||||
use Modules\Lpj\Models\PenawaranDetailTenderLog;
|
use Modules\Lpj\Models\PenawaranDetailTenderLog;
|
||||||
use Modules\Lpj\Models\PenawaranTender;
|
use Modules\Lpj\Models\PenawaranTender;
|
||||||
@@ -67,6 +68,22 @@
|
|||||||
|
|
||||||
$persetujuanPenawaran->save();
|
$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()
|
return redirect()
|
||||||
->route('persetujuan-penawaran.index')->with('success', 'Persetujuan Penawaran berhasil disimpan.');
|
->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([
|
$validated = $request->validate([
|
||||||
'dokument' => 'required',
|
'documentId' => 'required',
|
||||||
'jenis_jaminan' => 'required'
|
'jenis_jaminan' => 'required'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$dokumentId = $validated['dokument'];
|
$dokumentId = $validated['documentId'];
|
||||||
$jaminanId = $validated['jenis_jaminan'];
|
$jaminanId = $validated['jenis_jaminan'];
|
||||||
|
|
||||||
$permohonan = $this->getPermohonanJaminanId($id, $dokumentId, $jaminanId);
|
$permohonan = $this->getPermohonanJaminanId($id, $dokumentId, $jaminanId);
|
||||||
@@ -1644,11 +1644,11 @@ class SurveyorController extends Controller
|
|||||||
public function denah(Request $request, $id)
|
public function denah(Request $request, $id)
|
||||||
{
|
{
|
||||||
$validated = $request->validate([
|
$validated = $request->validate([
|
||||||
'dokument' => 'required',
|
'documentId' => 'required',
|
||||||
'jenis_jaminan' => 'required'
|
'jenis_jaminan' => 'required'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$dokumentId = $validated['dokument'];
|
$dokumentId = $validated['documentId'];
|
||||||
$jaminanId = $validated['jenis_jaminan'];
|
$jaminanId = $validated['jenis_jaminan'];
|
||||||
|
|
||||||
$permohonan = $this->getPermohonanJaminanId($id, $dokumentId, $jaminanId);
|
$permohonan = $this->getPermohonanJaminanId($id, $dokumentId, $jaminanId);
|
||||||
@@ -1672,11 +1672,11 @@ class SurveyorController extends Controller
|
|||||||
public function foto(Request $request, $id)
|
public function foto(Request $request, $id)
|
||||||
{
|
{
|
||||||
$validated = $request->validate([
|
$validated = $request->validate([
|
||||||
'dokument' => 'required',
|
'documentId' => 'required',
|
||||||
'jenis_jaminan' => 'required'
|
'jenis_jaminan' => 'required'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$dokumentId = $validated['dokument'];
|
$dokumentId = $validated['documentId'];
|
||||||
$jaminanId = $validated['jenis_jaminan'];
|
$jaminanId = $validated['jenis_jaminan'];
|
||||||
$fotoObjekJaminan = FotoObjekJaminan::all();
|
$fotoObjekJaminan = FotoObjekJaminan::all();
|
||||||
|
|
||||||
@@ -1707,11 +1707,11 @@ class SurveyorController extends Controller
|
|||||||
// Ambil data permohonan dengan eager loading
|
// Ambil data permohonan dengan eager loading
|
||||||
|
|
||||||
$validated = $request->validate([
|
$validated = $request->validate([
|
||||||
'dokument' => 'required',
|
'documentId' => 'required',
|
||||||
'jenis_jaminan' => 'required'
|
'jenis_jaminan' => 'required'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$dokumentId = $validated['dokument'];
|
$dokumentId = $validated['documentId'];
|
||||||
$jaminanId = $validated['jenis_jaminan'];
|
$jaminanId = $validated['jenis_jaminan'];
|
||||||
|
|
||||||
$permohonan = $this->getPermohonanJaminanId($id, $dokumentId, $jaminanId);
|
$permohonan = $this->getPermohonanJaminanId($id, $dokumentId, $jaminanId);
|
||||||
@@ -2718,7 +2718,7 @@ class SurveyorController extends Controller
|
|||||||
$fileName = 'inspeksi-' . $namaDebiture . '-data.pdf';
|
$fileName = 'inspeksi-' . $namaDebiture . '-data.pdf';
|
||||||
$pdf->set_option('isHtml5ParserEnabled', true);
|
$pdf->set_option('isHtml5ParserEnabled', true);
|
||||||
$pdf->set_option('isPhpEnabled', true);
|
$pdf->set_option('isPhpEnabled', true);
|
||||||
return $pdf->stream($fileName);
|
return $pdf->download($fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function approveReschedule(Request $request, $id)
|
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;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form Request untuk validasi data NOC (Notice of Completion)
|
||||||
|
*/
|
||||||
class NocRequest extends FormRequest
|
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()
|
public function authorize()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mengumpulkan semua aturan validasi
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function rules()
|
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 [
|
return [
|
||||||
'penawaran_id' => 'nullable|exists:penawaran,id',
|
'permohonan_id' => 'required|exists:permohonan,id',
|
||||||
'nominal_bayar' => 'nullable|numeric|min:0',
|
'persetujuan_penawaran_id' => 'required|exists:persetujuan_penawaran,id',
|
||||||
'bukti_ksl' => 'nullable|file|mimes:pdf,jpg,jpeg,png|max:10240',
|
'status' => 'nullable|boolean',
|
||||||
'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',
|
'sla_final' => 'nullable|numeric|min:0',
|
||||||
'file_persetujuan_penawaran' => 'nullable|file|mimes:pdf,doc,docx|max:10240',
|
'file_persetujuan_penawaran' => 'nullable|file|mimes:pdf,doc,docx|max:10240',
|
||||||
'surat_representasi' => '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',
|
'status' => 'nullable|boolean',
|
||||||
'authorized_status' => 'boolean',
|
'authorized_status' => 'boolean',
|
||||||
'authorized_at' => 'nullable|date',
|
'authorized_at' => 'nullable|date',
|
||||||
@@ -52,9 +50,6 @@
|
|||||||
'surat_representasi.file' => 'Surat Representasi harus berupa file.',
|
'surat_representasi.file' => 'Surat Representasi harus berupa file.',
|
||||||
'surat_representasi.mimes' => 'Surat Representasi harus berupa file PDF, DOC, atau DOCX.',
|
'surat_representasi.mimes' => 'Surat Representasi harus berupa file PDF, DOC, atau DOCX.',
|
||||||
'surat_representasi.max' => 'Ukuran Surat Representasi tidak boleh lebih dari 10MB.',
|
'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.required' => 'Region ID wajib diisi.',
|
||||||
'region_id.exists' => 'Region ID tidak valid.',
|
'region_id.exists' => 'Region ID tidak valid.',
|
||||||
'status.required' => 'Status wajib diisi.',
|
'status.required' => 'Status wajib diisi.',
|
||||||
@@ -62,8 +57,6 @@
|
|||||||
'authorized_status.boolean' => 'Status otorisasi harus berupa nilai boolean.',
|
'authorized_status.boolean' => 'Status otorisasi harus berupa nilai boolean.',
|
||||||
'authorized_at.date' => 'Tanggal otorisasi harus berupa tanggal yang valid.',
|
'authorized_at.date' => 'Tanggal otorisasi harus berupa tanggal yang valid.',
|
||||||
'authorized_by.exists' => 'ID pengguna yang mengotorisasi tidak 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 Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\AnalisaFactory;
|
use Modules\Lpj\Database\Factories\AnalisaFactory;
|
||||||
|
|
||||||
class Analisa extends Model
|
class Analisa extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
protected $table = 'analisa';
|
protected $table = 'analisa';
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\AnalisaFaktaFactory;
|
use Modules\Lpj\Database\Factories\AnalisaFaktaFactory;
|
||||||
|
|
||||||
class AnalisaFakta extends Model
|
class AnalisaFakta extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\AnalisaLingkunganFactory;
|
use Modules\Lpj\Database\Factories\AnalisaLingkunganFactory;
|
||||||
|
|
||||||
class AnalisaLingkungan extends Model
|
class AnalisaLingkungan extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\AnalisaTanahBagunanFactory;
|
use Modules\Lpj\Database\Factories\AnalisaTanahBagunanFactory;
|
||||||
|
|
||||||
class AnalisaTanahBagunan extends Model
|
class AnalisaTanahBagunan extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\AnalisaUnitFactory;
|
use Modules\Lpj\Database\Factories\AnalisaUnitFactory;
|
||||||
|
|
||||||
class AnalisaUnit extends Model
|
class AnalisaUnit extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
use Spatie\Activitylog\LogOptions;
|
use Spatie\Activitylog\LogOptions;
|
||||||
use Spatie\Activitylog\Traits\LogsActivity;
|
use Spatie\Activitylog\Traits\LogsActivity;
|
||||||
use Wildside\Userstamps\Userstamps;
|
use Wildside\Userstamps\Userstamps;
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
class Base extends Model
|
class Base extends Model
|
||||||
{
|
{
|
||||||
use LogsActivity, SoftDeletes, Userstamps;
|
use LogsActivity, SoftDeletes, Userstamps, Notifiable;
|
||||||
|
|
||||||
protected $connection;
|
protected $connection;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\BentukTanahFactory;
|
use Modules\Lpj\Database\Factories\BentukTanahFactory;
|
||||||
|
|
||||||
class BentukTanah extends Model
|
class BentukTanah extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
// use Modules\Lpj\Database\Factories\BentukUnitFactory;
|
// use Modules\Lpj\Database\Factories\BentukUnitFactory;
|
||||||
|
|
||||||
class BentukUnit extends Model
|
class BentukUnit extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
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 Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\DenahFactory;
|
use Modules\Lpj\Database\Factories\DenahFactory;
|
||||||
|
|
||||||
class Denah extends Model
|
class Denah extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
// use Modules\Lpj\Database\Factories\FasilitasObjekFactory;
|
// use Modules\Lpj\Database\Factories\FasilitasObjekFactory;
|
||||||
|
|
||||||
class FasilitasObjek extends Model
|
class FasilitasObjek extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\FotoJaminanFactory;
|
use Modules\Lpj\Database\Factories\FotoJaminanFactory;
|
||||||
|
|
||||||
class FotoJaminan extends Model
|
class FotoJaminan extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
// use Modules\Lpj\Database\Factories\FotoObjekJaminanFactory;
|
// use Modules\Lpj\Database\Factories\FotoObjekJaminanFactory;
|
||||||
|
|
||||||
class FotoObjekJaminan extends Model
|
class FotoObjekJaminan extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\GolonganMasySekitarFactory;
|
use Modules\Lpj\Database\Factories\GolonganMasySekitarFactory;
|
||||||
|
|
||||||
class GolonganMasySekitar extends Model
|
class GolonganMasySekitar extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
// use Modules\Lpj\Database\Factories\InspeksiFactory;
|
// use Modules\Lpj\Database\Factories\InspeksiFactory;
|
||||||
|
|
||||||
class Inspeksi extends Model
|
class Inspeksi extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ class Inspeksi extends Model
|
|||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* 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()
|
public function permohonan()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\JenisBangunanFactory;
|
use Modules\Lpj\Database\Factories\JenisBangunanFactory;
|
||||||
|
|
||||||
class JenisBangunan extends Model
|
class JenisBangunan extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
// use Modules\Lpj\Database\Factories\JenisKapalFactory;
|
// use Modules\Lpj\Database\Factories\JenisKapalFactory;
|
||||||
|
|
||||||
class JenisKapal extends Model
|
class JenisKapal extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
// use Modules\Lpj\Database\Factories\JenisKendaraanFactory;
|
// use Modules\Lpj\Database\Factories\JenisKendaraanFactory;
|
||||||
|
|
||||||
class JenisKendaraan extends Model
|
class JenisKendaraan extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace Modules\Lpj\Models;
|
|||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Modules\Lpj\Database\Factories\JenisPenilaianFactory;
|
use Modules\Lpj\Database\Factories\JenisPenilaianFactory;
|
||||||
use Modules\Lpj\Models\Penilaian;
|
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 Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
// use Modules\Lpj\Database\Factories\JenisPesawatFactory;
|
// use Modules\Lpj\Database\Factories\JenisPesawatFactory;
|
||||||
|
|
||||||
class JenisPesawat extends Model
|
class JenisPesawat extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||||||
|
|
||||||
// use Modules\Lpj\Database\Factories\JenisUnitFactory;
|
// use Modules\Lpj\Database\Factories\JenisUnitFactory;
|
||||||
|
|
||||||
class JenisUnit extends Model
|
class JenisUnit extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\KetinggianTanahFactory;
|
use Modules\Lpj\Database\Factories\KetinggianTanahFactory;
|
||||||
|
|
||||||
class KetinggianTanah extends Model
|
class KetinggianTanah extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\KondisiBangunanFactory;
|
use Modules\Lpj\Database\Factories\KondisiBangunanFactory;
|
||||||
|
|
||||||
class KondisiBangunan extends Model
|
class KondisiBangunan extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\KondisiFisikTanahFactory;
|
use Modules\Lpj\Database\Factories\KondisiFisikTanahFactory;
|
||||||
|
|
||||||
class KondisiFisikTanah extends Model
|
class KondisiFisikTanah extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\KonturTanahFactory;
|
use Modules\Lpj\Database\Factories\KonturTanahFactory;
|
||||||
|
|
||||||
class KonturTanah extends Model
|
class KonturTanah extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\LaluLintasLokasiFactory;
|
use Modules\Lpj\Database\Factories\LaluLintasLokasiFactory;
|
||||||
|
|
||||||
class LaluLintasLokasi extends Model
|
class LaluLintasLokasi extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
protected $table = 'lalu_lintas_lokasi';
|
protected $table = 'lalu_lintas_lokasi';
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\LokasiUnitFactory;
|
use Modules\Lpj\Database\Factories\LokasiUnitFactory;
|
||||||
|
|
||||||
class Lantai extends Model
|
class Lantai extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\LantaiUnitFactory;
|
use Modules\Lpj\Database\Factories\LantaiUnitFactory;
|
||||||
|
|
||||||
class LantaiUnit extends Model
|
class LantaiUnit extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
// use Modules\Lpj\Database\Factories\LaporanFactory;
|
// use Modules\Lpj\Database\Factories\LaporanFactory;
|
||||||
|
|
||||||
class Laporan extends Model
|
class Laporan extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\LingkunganFactory;
|
use Modules\Lpj\Database\Factories\LingkunganFactory;
|
||||||
|
|
||||||
class Lingkungan extends Model
|
class Lingkungan extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||||||
|
|
||||||
// use Modules\Lpj\Database\Factories\MerupakanDaerahFactory;
|
// use Modules\Lpj\Database\Factories\MerupakanDaerahFactory;
|
||||||
|
|
||||||
class MerupakanDaerah extends Model
|
class MerupakanDaerah extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
// use Modules\Lpj\Database\Factories\ModelAlatBeratFactory;
|
// use Modules\Lpj\Database\Factories\ModelAlatBeratFactory;
|
||||||
|
|
||||||
class ModelAlatBerat extends Model
|
class ModelAlatBerat extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
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 Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\ObjekJaminanFactory;
|
use Modules\Lpj\Database\Factories\ObjekJaminanFactory;
|
||||||
|
|
||||||
class ObjekJaminan extends Model
|
class ObjekJaminan extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
// use Modules\Lpj\Database\Factories\PenawaranDetailTenderFactory;
|
// use Modules\Lpj\Database\Factories\PenawaranDetailTenderFactory;
|
||||||
|
|
||||||
class PenawaranDetailTenderLog extends Model
|
class PenawaranDetailTenderLog extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ class PenawaranDetailTenderLog extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(PenawaranTender::class, 'penawaran_id', 'id');
|
return $this->belongsTo(PenawaranTender::class, 'penawaran_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function penawarandetail(): BelongsTo
|
public function penawarandetail(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(PenawaranDetailTender::class, 'detail_penawaran_id', 'id');
|
return $this->belongsTo(PenawaranDetailTender::class, 'detail_penawaran_id', 'id');
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
// use Modules\Lpj\Database\Factories\PenilaiFactory;
|
// use Modules\Lpj\Database\Factories\PenilaiFactory;
|
||||||
|
|
||||||
class Penilai extends Model
|
class Penilai extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use Modules\Lpj\Models\Teams;
|
|||||||
use Modules\Lpj\Models\Permohonan;
|
use Modules\Lpj\Models\Permohonan;
|
||||||
use Modules\Usermanagement\Models\User;
|
use Modules\Usermanagement\Models\User;
|
||||||
|
|
||||||
class Penilaian extends Model
|
class Penilaian extends Base
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
@@ -32,6 +32,17 @@ class Penilaian extends Model
|
|||||||
return $this->belongsTo(Teams::class, 'teams_id', 'id');
|
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()
|
public function userPenilai()
|
||||||
{
|
{
|
||||||
return $this->hasMany(PenilaianTeam::class, 'penilaian_id', 'id');
|
return $this->hasMany(PenilaianTeam::class, 'penilaian_id', 'id');
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\PenilaianTeamFactory;
|
use Modules\Lpj\Database\Factories\PenilaianTeamFactory;
|
||||||
|
|
||||||
class PenilaianTeam extends Model
|
class PenilaianTeam extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
// use Modules\Lpj\Database\Factories\PerizinanFactory;
|
// use Modules\Lpj\Database\Factories\PerizinanFactory;
|
||||||
|
|
||||||
class Perizinan extends Model
|
class Perizinan extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\PerkerasanJalanFactory;
|
use Modules\Lpj\Database\Factories\PerkerasanJalanFactory;
|
||||||
|
|
||||||
class PerkerasanJalan extends Model
|
class PerkerasanJalan extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -259,4 +259,10 @@
|
|||||||
return $this->belongsTo(Inspeksi::class, 'permohonan_id');
|
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 Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\PermohonanJaminanFactory;
|
use Modules\Lpj\Database\Factories\PermohonanJaminanFactory;
|
||||||
|
|
||||||
class PermohonanJaminan extends Model
|
class PermohonanJaminan extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
protected $table = 'dokumen_jaminan';
|
protected $table = 'dokumen_jaminan';
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
'authorized_status',
|
'authorized_status',
|
||||||
'authorized_at',
|
'authorized_at',
|
||||||
'authorized_by',
|
'authorized_by',
|
||||||
'status',
|
|
||||||
'catatan',
|
'catatan',
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -58,4 +57,10 @@
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'authorized_by');
|
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 Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\PosisiKavlingFactory;
|
use Modules\Lpj\Database\Factories\PosisiKavlingFactory;
|
||||||
|
|
||||||
class PosisiKavling extends Model
|
class PosisiKavling extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||||||
|
|
||||||
// use Modules\Lpj\Database\Factories\PosisiUnitFactory;
|
// use Modules\Lpj\Database\Factories\PosisiUnitFactory;
|
||||||
|
|
||||||
class PosisiUnit extends Model
|
class PosisiUnit extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||||||
use Modules\Lpj\Database\Factories\RegionsFactory;
|
use Modules\Lpj\Database\Factories\RegionsFactory;
|
||||||
use Modules\Lpj\Models\Teams;
|
use Modules\Lpj\Models\Teams;
|
||||||
|
|
||||||
class Regions extends Model
|
class Regions extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\RuteJaminanFactory;
|
use Modules\Lpj\Database\Factories\RuteJaminanFactory;
|
||||||
|
|
||||||
class RuteJaminan extends Model
|
class RuteJaminan extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
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 Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\SaranaPelengkapFactory;
|
use Modules\Lpj\Database\Factories\SaranaPelengkapFactory;
|
||||||
|
|
||||||
class SaranaPelengkap extends Model
|
class SaranaPelengkap extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\SifatBangunanFactory;
|
use Modules\Lpj\Database\Factories\SifatBangunanFactory;
|
||||||
|
|
||||||
class SifatBangunan extends Model
|
class SifatBangunan extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\SpekBagunanAnalisaFactory;
|
use Modules\Lpj\Database\Factories\SpekBagunanAnalisaFactory;
|
||||||
|
|
||||||
class SpekBagunanAnalisa extends Model
|
class SpekBagunanAnalisa extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\SpekBagunanAnalisaDetailFactory;
|
use Modules\Lpj\Database\Factories\SpekBagunanAnalisaDetailFactory;
|
||||||
|
|
||||||
class SpekBagunanAnalisaDetail extends Model
|
class SpekBagunanAnalisaDetail extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\SpekBangunanFactory;
|
use Modules\Lpj\Database\Factories\SpekBangunanFactory;
|
||||||
|
|
||||||
class SpekBangunan extends Model
|
class SpekBangunan extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\SpekKategoritBangunanFactory;
|
use Modules\Lpj\Database\Factories\SpekKategoritBangunanFactory;
|
||||||
|
|
||||||
class SpekKategoritBangunan extends Model
|
class SpekKategoritBangunan extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use Modules\Lpj\Models\Regions;
|
|||||||
use Modules\Lpj\Models\Penilaian;
|
use Modules\Lpj\Models\Penilaian;
|
||||||
|
|
||||||
|
|
||||||
class Teams extends Model
|
class Teams extends Base
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use Modules\Usermanagement\Models\User;
|
|||||||
use Modules\Lpj\Models\Teams;
|
use Modules\Lpj\Models\Teams;
|
||||||
use Modules\Lpj\Models\Penilaian;
|
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;
|
// use Modules\Lpj\Database\Factories\TerletakAreaFactory;
|
||||||
|
|
||||||
class TerletakArea extends Model
|
class TerletakArea extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\TingkatKeramaianFactory;
|
use Modules\Lpj\Database\Factories\TingkatKeramaianFactory;
|
||||||
|
|
||||||
class TingkatKeramaian extends Model
|
class TingkatKeramaian extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Modules\Lpj\Database\Factories\ViewUnitFactory;
|
use Modules\Lpj\Database\Factories\ViewUnitFactory;
|
||||||
|
|
||||||
class ViewUnit extends Model
|
class ViewUnit extends Base
|
||||||
{
|
{
|
||||||
use HasFactory;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
96
app/Services/LaporanUserService.php
Normal file
96
app/Services/LaporanUserService.php
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Lpj\Services;
|
||||||
|
|
||||||
|
use Modules\Lpj\Models\Permohonan;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Modules\Usermanagement\Models\User;
|
||||||
|
|
||||||
|
class LaporanUserService
|
||||||
|
{
|
||||||
|
public function getUserPemohon($search = null)
|
||||||
|
{
|
||||||
|
return Permohonan::join('users', 'users.id', '=', 'permohonan.user_id')
|
||||||
|
->whereNotNull('permohonan.nomor_registrasi')
|
||||||
|
->when($search, function ($query) use ($search) {
|
||||||
|
$query->where('users.name', 'like', "%$search%");
|
||||||
|
})
|
||||||
|
->select('users.id', 'users.name')
|
||||||
|
->distinct()
|
||||||
|
->orderBy('users.name')
|
||||||
|
->limit(20)
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function dataForDatatables(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = User::query();
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = json_decode($request->get('search'));
|
||||||
|
if (isset($search->search)) {
|
||||||
|
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->whereRaw('LOWER(name) LIKE ?', ['%' . strtolower($search) . '%']);
|
||||||
|
$q->where('nik', '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(['branch', 'roles'])->get();
|
||||||
|
|
||||||
|
$data = $data->map(function ($user) {
|
||||||
|
|
||||||
|
return [
|
||||||
|
'id' => $user->id,
|
||||||
|
'nik' => $user->nik,
|
||||||
|
'name' => $user->name,
|
||||||
|
'level' => $user->roles->pluck('name')->implode(', '),
|
||||||
|
'approval_limit' => 0,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
// 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,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user