perbaikan nomor laporan, dan penambahan button revisi laporan di so
This commit is contained in:
@@ -75,12 +75,23 @@ class PenilaiController extends Controller
|
||||
|
||||
$documentId = $request->query('documentId');
|
||||
$jaminanId = $request->query('jaminanId');
|
||||
|
||||
$inspeksiId = $request->query('inspeksiId');
|
||||
$permohonan = $this->surveyorController->getPermohonanJaminanId($id, $documentId, $jaminanId);
|
||||
$basicData = $this->surveyorController->getCommonData();
|
||||
|
||||
$noLpSederhana = $this->generateNoLaporan($permohonan, $documentId, 'lpj');
|
||||
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $id)->where('dokument_id', $documentId)->first();
|
||||
$lpj = Penilai::where('permohonan_id', $id)->where('dokument_id', $documentId)->first();
|
||||
$lpj = Penilai::updateOrCreate(
|
||||
[
|
||||
'permohonan_id' => $id,
|
||||
'dokument_id' => $documentId,
|
||||
'inspeksi_id' => $inspeksiId,
|
||||
],
|
||||
[
|
||||
'type_penilai' => 'standard',
|
||||
]
|
||||
);
|
||||
|
||||
$forminspeksi = null;
|
||||
$lpjData = null;
|
||||
@@ -100,12 +111,24 @@ class PenilaiController extends Controller
|
||||
|
||||
$documentId = $request->query('documentId');
|
||||
$jaminanId = $request->query('jaminanId');
|
||||
$inspeksiId = $request->query('inspeksiId');
|
||||
|
||||
$permohonan = $this->surveyorController->getPermohonanJaminanId($id, $documentId, $jaminanId);
|
||||
$basicData = $this->surveyorController->getCommonData();
|
||||
$noLpSederhana = $this->generateNoLaporan($permohonan, $documentId, 'lpj');
|
||||
|
||||
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $id)->where('dokument_id', $documentId)->first();
|
||||
$lpj = Penilai::where('permohonan_id', $id)->where('dokument_id', $documentId)->first();
|
||||
$lpj = Penilai::updateOrCreate(
|
||||
[
|
||||
'permohonan_id' => $id,
|
||||
'dokument_id' => $documentId,
|
||||
'inspeksi_id' => $inspeksiId,
|
||||
],
|
||||
[
|
||||
'type_penilai' => 'standard',
|
||||
]
|
||||
);
|
||||
|
||||
$forminspeksi = null;
|
||||
$lpjData = null;
|
||||
@@ -129,6 +152,7 @@ class PenilaiController extends Controller
|
||||
|
||||
$permohonan = $this->surveyorController->getPermohonanJaminanId($permohonanId, $documentId, $jaminanId);
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
|
||||
$noLpresume = $this->generateNoLaporan($permohonan, $documentId, 'resume');
|
||||
Penilai::updateOrCreate(
|
||||
[
|
||||
'permohonan_id' => $permohonanId,
|
||||
@@ -153,7 +177,7 @@ class PenilaiController extends Controller
|
||||
$forminspeksi = json_decode($inspeksi->data_form, true);
|
||||
}
|
||||
|
||||
return view('lpj::penilai.components.resume', compact('permohonan', 'resumeData','forminspeksi'));
|
||||
return view('lpj::penilai.components.resume', compact('permohonan', 'resumeData', 'forminspeksi'));
|
||||
}
|
||||
|
||||
public function memo(Request $request)
|
||||
@@ -163,6 +187,7 @@ class PenilaiController extends Controller
|
||||
$data = $this->getDataPermohonanWithPenilaiAndInspeksi($req['permohonanId'], $req['documentId'], $req['jaminanId']);
|
||||
$permohonan = $data['permohonan'];
|
||||
|
||||
$noLpmemo = $this->generateNoLaporan($permohonan, $req['documentId'], 'memo');
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $req['permohonanId'])->where('dokument_id', $req['documentId'])->first();
|
||||
$penilai = Penilai::where('permohonan_id', $req['permohonanId'])->where('dokument_id', $req['documentId'])->first();
|
||||
$provinces = Province::all();
|
||||
@@ -198,7 +223,7 @@ class PenilaiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
return view('lpj::penilai.components.memo', compact('permohonan', 'formFoto', 'formPeta', 'provinces', 'basicData', 'memo', 'cities', 'districts', 'villages'));
|
||||
return view('lpj::penilai.components.memo', compact('permohonan', 'formFoto', 'formPeta', 'provinces', 'basicData', 'memo', 'cities', 'districts', 'villages', 'noLpmemo'));
|
||||
}
|
||||
|
||||
|
||||
@@ -271,13 +296,13 @@ class PenilaiController extends Controller
|
||||
|
||||
$lpjData = null;
|
||||
$rap = null;
|
||||
$forminspeksi= null;
|
||||
$forminspeksi = null;
|
||||
if ($resume) {
|
||||
$forminspeksi = json_decode($inspeksi->data_form, true);
|
||||
$rap = json_decode($resume->rap, true);
|
||||
}
|
||||
|
||||
return view('lpj::penilai.components.rap-penilai', compact('permohonan', 'rap', 'provinces','forminspeksi'));
|
||||
return view('lpj::penilai.components.rap-penilai', compact('permohonan', 'rap', 'provinces', 'forminspeksi'));
|
||||
}
|
||||
|
||||
|
||||
@@ -310,6 +335,7 @@ class PenilaiController extends Controller
|
||||
});
|
||||
}
|
||||
|
||||
$query->whereRaw('LOWER(status) IN (?, ?, ?)', ['assign','done', 'proses-laporan']);
|
||||
|
||||
if (!Auth::user()->hasRole('administrator')) {
|
||||
$query->whereHas('penilaian.userPenilai', function ($q) {
|
||||
@@ -373,12 +399,17 @@ class PenilaiController extends Controller
|
||||
{
|
||||
$permohonanId = $request->query('permohonanId');
|
||||
$documentId = $request->query('documentId');
|
||||
|
||||
$jaminanId = $request->query('jaminanId');
|
||||
// Fetch the data from the database
|
||||
$data = Inspeksi::where('permohonan_id', $permohonanId)
|
||||
->where('dokument_id', $documentId)
|
||||
->first();
|
||||
|
||||
$permohonan = $this->surveyorController->getPermohonanJaminanId(
|
||||
$permohonanId,
|
||||
$documentId,
|
||||
$jaminanId
|
||||
);
|
||||
// Check if data exists
|
||||
if (!$data) {
|
||||
return response()->json(['message' => 'Data not found'], 404);
|
||||
@@ -436,7 +467,10 @@ class PenilaiController extends Controller
|
||||
|
||||
// Now create the export
|
||||
// return response()->json([ 'data' => $fotoForm]);
|
||||
return Excel::download(new KertasKerjaExport($exportData), 'kertas-kerja.xlsx');
|
||||
|
||||
// return view('lpj::component.kertas-kerja-tes
|
||||
// ', compact('permohonan', 'data'));
|
||||
return Excel::download(new KertasKerjaExport($permohonan, $data), 'kertas-kerja.xlsx');
|
||||
}
|
||||
|
||||
|
||||
@@ -498,23 +532,23 @@ class PenilaiController extends Controller
|
||||
}
|
||||
|
||||
public function saveStatusLpj(Request $request)
|
||||
{
|
||||
{
|
||||
|
||||
|
||||
Penilai::updateOrCreate(
|
||||
[
|
||||
'permohonan_id' => $request->permohonan_id,
|
||||
'dokument_id' => $request->document_id,
|
||||
'inspeksi_id' => $request->inspeksi_id,
|
||||
],
|
||||
[
|
||||
'type' => $request->type,
|
||||
'type_penilai' => $request->type,
|
||||
]
|
||||
);
|
||||
Penilai::updateOrCreate(
|
||||
[
|
||||
'permohonan_id' => $request->permohonan_id,
|
||||
'dokument_id' => $request->document_id,
|
||||
'inspeksi_id' => $request->inspeksi_id,
|
||||
],
|
||||
[
|
||||
'type' => $request->type,
|
||||
'type_penilai' => $request->type,
|
||||
]
|
||||
);
|
||||
|
||||
return response()->json(['success' => true]);
|
||||
}
|
||||
return response()->json(['success' => true]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -532,8 +566,8 @@ class PenilaiController extends Controller
|
||||
!empty($item->rap)
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
if (!$allComplete) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
@@ -718,26 +752,18 @@ class PenilaiController extends Controller
|
||||
$statusLpj = $request->query('statusLpj');
|
||||
$tipeLaporan = $request->query('type');
|
||||
|
||||
$permohonan = $this->surveyorController->getPermohonanJaminanId($permohonanId,
|
||||
$documentId,
|
||||
$jaminanId);
|
||||
$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();
|
||||
|
||||
$laporan = Laporan::firstOrCreate(
|
||||
[
|
||||
'permohonan_id' => $permohonanId,
|
||||
'dokumen_jaminan_id' => $documentId,
|
||||
],
|
||||
[
|
||||
'nomor_laporan' => generateLpjUniqueCode(6),
|
||||
]
|
||||
);
|
||||
|
||||
$nomorLaporan = $laporan->nomor_laporan;
|
||||
$nomorLaporan = getNomorLaporan($permohonanId, $documentId);
|
||||
$forminspeksi = null;
|
||||
$lpjData = null;
|
||||
$formFoto = null;
|
||||
@@ -789,7 +815,7 @@ class PenilaiController extends Controller
|
||||
return $pdf->stream();
|
||||
} else {
|
||||
// $pdf = view('lpj::' . $viewLaporan, compact(
|
||||
$pdf = PDF::loadView('lpj::' . $viewLaporan, compact(
|
||||
$pdf = PDF::loadView('lpj::' . $viewLaporan, compact(
|
||||
'permohonan',
|
||||
'forminspeksi',
|
||||
'lpjData',
|
||||
@@ -806,8 +832,10 @@ class PenilaiController extends Controller
|
||||
));
|
||||
|
||||
// return $pdf;
|
||||
|
||||
$cleanNomorLaporan = str_replace(['/', '\\'], '-', $nomorLaporan);
|
||||
$pdf->setPaper('A4', 'portrait');
|
||||
return $pdf->download('Laporan_'. $tipeLaporan . '_' . $permohonan->nomor_registrasi . '_' .$permohonan->debiture->name .'_data.pdf');
|
||||
return $pdf->download('Laporan_'. $tipeLaporan . '_' .$permohonan->debiture->name . '_' . $cleanNomorLaporan .'_data.pdf');
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
@@ -818,16 +846,16 @@ class PenilaiController extends Controller
|
||||
}
|
||||
|
||||
private function getViewLaporan($tipe)
|
||||
{
|
||||
$viewMap = [
|
||||
'sederhana' => 'penilai.components.print-out-sederhana',
|
||||
'standard' => 'penilai.components.print-out-standard',
|
||||
'resume' => 'penilai.components.print-resume',
|
||||
'memo' => 'penilai.components.print-memo',
|
||||
'rap' => 'penilai.components.print-out-rap'
|
||||
];
|
||||
return $viewMap[$tipe] ?? 'penilai.components.print-resume';
|
||||
}
|
||||
{
|
||||
$viewMap = [
|
||||
'sederhana' => 'penilai.components.print-out-sederhana',
|
||||
'standard' => 'penilai.components.print-out-standard',
|
||||
'resume' => 'penilai.components.print-resume',
|
||||
'memo' => 'penilai.components.print-memo',
|
||||
'rap' => 'penilai.components.print-out-rap'
|
||||
];
|
||||
return $viewMap[$tipe] ?? 'penilai.components.print-resume';
|
||||
}
|
||||
|
||||
public function getWilayahName($code, $type)
|
||||
{
|
||||
@@ -887,7 +915,8 @@ class PenilaiController extends Controller
|
||||
];
|
||||
}
|
||||
|
||||
public function checkPrintOutLaporan(Request $request) {
|
||||
public function checkPrintOutLaporan(Request $request)
|
||||
{
|
||||
$permohonanId = $request->query('permohonanId');
|
||||
$documentId = $request->query('documentId');
|
||||
$inspeksiId = $request->query('inspeksiId');
|
||||
@@ -911,4 +940,42 @@ class PenilaiController extends Controller
|
||||
}
|
||||
|
||||
|
||||
public function generateNoLaporan($permohonan, $documentId, $type)
|
||||
{
|
||||
$typeMapping = ['lpj' => 'LPJ', 'memo' => 'MAK', 'rap' => 'RAP'];
|
||||
|
||||
// Cek apakah data sudah ada
|
||||
$laporan = Laporan::where([
|
||||
'permohonan_id' => $permohonan->id,
|
||||
'dokumen_jaminan_id' => $documentId,
|
||||
])->first();
|
||||
|
||||
if ($laporan) {
|
||||
|
||||
$nomorArray = explode('/', $laporan->nomor_laporan);
|
||||
$nomorArray[2] = $typeMapping[$type] ?? 'RSM';
|
||||
$laporan->update([
|
||||
'nomor_laporan' => implode('/', $nomorArray)
|
||||
]);
|
||||
} else {
|
||||
|
||||
$laporan = Laporan::create([
|
||||
'permohonan_id' => $permohonan->id,
|
||||
'dokumen_jaminan_id' => $documentId,
|
||||
'nomor_laporan' => implode('/', [
|
||||
$permohonan->debiture->branch->code,
|
||||
generateLpjUniqueCode(3),
|
||||
$typeMapping[$type] ?? 'RSM',
|
||||
$permohonan->nomor_registrasi,
|
||||
onRomawi(date('m')),
|
||||
substr(date('Y'), -2)
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
return $laporan->nomor_laporan;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user