fix(penilai/surveyor): perbaikkan activity, form inspeksi, print out inspeksi dan laporan, ganti nama detail penilai ke detail penilaian

This commit is contained in:
majid76
2025-03-03 01:27:44 +07:00
parent f65b9bec23
commit 8c08b46c8f
17 changed files with 547 additions and 441 deletions

View File

@@ -297,7 +297,6 @@ class PenilaiController extends Controller
return redirect()
->route('penilai.show', ['id' => $id])->with('success', 'diperbarui ke status paparan dan dikirim ke So untuk proses lebih lanjut.');
} catch (\Exception $e) {
return redirect()->route('penilai.show', ['id' => $id])->with('error', 'Terjadi kesalahan saat memproses permohonan.');
}
@@ -505,7 +504,7 @@ class PenilaiController extends Controller
});
}
$query->whereRaw('LOWER(status) IN (?, ?, ?, ?, ?, ?,?, ?)', ['assign','survey-completed', 'proses-laporan', 'paparan', 'proses-paparan','paparan', 'revisi-laporan','revisi-paparan']);
$query->whereRaw('LOWER(status) IN (?, ?, ?, ?, ?, ?,?, ?)', ['assign', 'survey-completed', 'proses-laporan', 'paparan', 'proses-paparan', 'paparan', 'revisi-laporan', 'revisi-paparan']);
if (!Auth::user()->hasRole('administrator')) {
$query->whereHas('penilaian.userPenilai', function ($q) {
@@ -574,8 +573,8 @@ class PenilaiController extends Controller
$jaminanId = $request->query('jaminanId');
// Fetch the data from the database
$data = Inspeksi::where('permohonan_id', $permohonanId)
->where('dokument_id', $documentId)
->first();
->where('dokument_id', $documentId)
->first();
$permohonan = $this->surveyorController->getPermohonanJaminanId(
$permohonanId,
@@ -772,7 +771,6 @@ class PenilaiController extends Controller
'success' => true,
'message' => 'Berhasil Megirim reported ke so'
], 200);
} catch (\Exception $e) {
return response()->json([
'success' => false,
@@ -810,8 +808,8 @@ class PenilaiController extends Controller
);
$inspeksi = Inspeksi::where('permohonan_id', $validatedData['permohonan_id'])
->where('dokument_id', $validatedData['dokument_id'])
->first();
->where('dokument_id', $validatedData['dokument_id'])
->first();
if ($inspeksi) {
// Get existing data_form
$existingData = json_decode($inspeksi->data_form, true) ?: [];
@@ -1039,7 +1037,6 @@ class PenilaiController extends Controller
'trace' => $e->getTraceAsString()
], 500);
}
}
public function storeCallReport(Request $request)
@@ -1057,7 +1054,7 @@ class PenilaiController extends Controller
'type' => 'required',
'action' => 'required',
'keterangan' => 'nullable|array',
]);
@@ -1073,8 +1070,8 @@ class PenilaiController extends Controller
);
$inspeksi = Inspeksi::where('permohonan_id', $validated['permohonan_id'])
->where('dokument_id', $validated['dokument_id'])
->first();
->where('dokument_id', $validated['dokument_id'])
->first();
if ($inspeksi) {
// Get existing data_form
$existingData = json_decode($inspeksi->data_form, true) ?: [];
@@ -1207,8 +1204,8 @@ class PenilaiController extends Controller
$cleanNomorLaporan = str_replace(['/', '\\'], '-', $nomorLaporan);
$pdf->setPaper('A4', 'portrait');
return response($pdf->output(), 200)
->header('Content-Type', 'application/pdf')
->header('Content-Disposition', 'inline; filename="Laporan_' . $tipeLaporan . '_' .$permohonan->debiture->name . '_' . $cleanNomorLaporan .'.pdf"');
->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(
@@ -1233,14 +1230,12 @@ class PenilaiController extends Controller
// return $pdf;
$cleanNomorLaporan = str_replace(['/', '\\'], '-', $nomorLaporan);
$pdf->setPaper('A4', 'portrait');
return $pdf->download('Laporan_'. $tipeLaporan . '_' .$permohonan->debiture->name . '_' . $cleanNomorLaporan .'_data.pdf');
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 response()->json(['error' => 'Failed to generate PDF. Please check the log for details.' . $e->getMessage()], 500);
}
}
private function getViewLaporan($tipe)
@@ -1263,10 +1258,10 @@ class PenilaiController extends Controller
private function getDataPermohonanWithPenilaiAndInspeksi($permohonanId, $documentId, $jaminanId)
{
return [
'permohonan' => $this->surveyorController->getPermohonanJaminanId($permohonanId, $documentId, $jaminanId),
'penilai' => Penilai::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first(),
'inspeksi' => Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first()
];
'permohonan' => $this->surveyorController->getPermohonanJaminanId($permohonanId, $documentId, $jaminanId),
'penilai' => Penilai::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first(),
'inspeksi' => Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first()
];
}
@@ -1609,6 +1604,4 @@ class PenilaiController extends Controller
'message' => 'Berhasil Revisi Ke surveyor',
], 200);
}
}