Merge branch 'staging' of https://git.putrakuningan.com/daengdeni/lpj into tender
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Modules\Lpj\Http\Controllers;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\Inspeksi;
|
||||
use Modules\Lpj\Models\Penilai;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
@@ -15,6 +16,13 @@ class PenilaiController extends Controller
|
||||
{
|
||||
public $user;
|
||||
|
||||
protected $surveyorController;
|
||||
|
||||
public function __construct(SurveyorController $surveyorController)
|
||||
{
|
||||
$this->surveyorController = $surveyorController;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
@@ -30,9 +38,9 @@ class PenilaiController extends Controller
|
||||
{
|
||||
$permohonan = Permohonan::with('debiture.documents')->find($id);
|
||||
|
||||
$jaminanId = $permohonan->debiture->documents->first()->jenis_jaminan_id;
|
||||
$documentId = $request->query('documentId');
|
||||
|
||||
$inpeksi = Inspeksi::where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first();
|
||||
$inpeksi = Inspeksi::where('permohonan_id', $id)->where('dokument_id', $jaminanId)->first();
|
||||
|
||||
$formFoto = null;
|
||||
if ($inpeksi) {
|
||||
@@ -56,14 +64,20 @@ class PenilaiController extends Controller
|
||||
//
|
||||
}
|
||||
|
||||
public function sederhana($id)
|
||||
public function sederhana(Request $request,$id)
|
||||
{
|
||||
$data = new SurveyorController();
|
||||
$basicData = $data->getCommonData();
|
||||
|
||||
$permohonan = Permohonan::with(['debiture.documents.jenisjaminan', 'region.teams.teamsUsers.user', 'penilaian'])->find($id);
|
||||
$jaminanId = $permohonan->debiture->documents->first()->jenis_jaminan_id;
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first();
|
||||
$basicData = $this->surveyorController->getCommonData();
|
||||
|
||||
$documentId = $request->query('documentId');
|
||||
$inspeksiId = $request->query('inspeksiId');
|
||||
$jaminanId = $request->query('jaminanId');
|
||||
|
||||
$permohonan = $this->surveyorController->getPermohonanJaminanId($id, $documentId, $jaminanId);
|
||||
|
||||
|
||||
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $id)->where('dokument_id', $documentId)->first();
|
||||
$forminspeksi = null;
|
||||
if ($inspeksi) {
|
||||
$forminspeksi = json_decode($inspeksi->data_form, true);
|
||||
@@ -71,33 +85,55 @@ class PenilaiController extends Controller
|
||||
return view('lpj::penilai.components.lpj-sederhana-standard', compact('permohonan', 'basicData', 'forminspeksi', 'inspeksi'));
|
||||
}
|
||||
|
||||
public function standard($id)
|
||||
public function standard(Request $request, $id)
|
||||
{
|
||||
$permohonan = Permohonan::with(['debiture.documents.jenisjaminan', 'region.teams.teamsUsers.user', 'penilaian'])->find($id);
|
||||
|
||||
$jaminanId = $permohonan->debiture->documents->first()->jenis_jaminan_id;
|
||||
$documentId = $request->query('documentId');
|
||||
$jaminanId = $request->query('jaminanId');
|
||||
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first();
|
||||
$permohonan = $this->surveyorController->getPermohonanJaminanId($id, $documentId, $jaminanId);
|
||||
$basicData = $this->surveyorController->getCommonData();
|
||||
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $id)->where('dokument_id', $documentId)->first();
|
||||
$forminspeksi = null;
|
||||
if ($inspeksi) {
|
||||
$forminspeksi = json_decode($inspeksi->data_form, true);
|
||||
}
|
||||
|
||||
$data = new SurveyorController();
|
||||
$basicData = $data->getCommonData();
|
||||
|
||||
|
||||
|
||||
return view('lpj::penilai.components.lpj-sederhana-standard', compact('permohonan', 'forminspeksi', 'basicData', 'inspeksi'));
|
||||
}
|
||||
|
||||
public function resume($id)
|
||||
public function resume(Request $request)
|
||||
{
|
||||
$permohonan = Permohonan::with(['debiture.documents.jenisjaminan', 'region.teams.teamsUsers.user', 'penilaian'])->find($id);
|
||||
$permohonanId = $request->query('permohonanId');
|
||||
$permohonan = Permohonan::with(['debiture.documents.jenisjaminan', 'region.teams.teamsUsers.user', 'penilaian'])->find($permohonanId);
|
||||
return view('lpj::penilai.components.resume', compact('permohonan'));
|
||||
}
|
||||
|
||||
public function memo()
|
||||
public function memo(Request $request)
|
||||
{
|
||||
return view('lpj::resume.index');
|
||||
$permohonanId = $request->query('permohonanId');
|
||||
$documentId = $request->query('documentId');
|
||||
$inspeksiId = $request->query('inspeksiId');
|
||||
$jaminanId = $request->query('jaminanId');
|
||||
|
||||
$permohonan = $this->surveyorController->getPermohonanJaminanId($permohonanId, $documentId, $jaminanId);
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
|
||||
|
||||
$formFoto = null;
|
||||
$formPeta = null;
|
||||
if ($inspeksi) {
|
||||
$formFoto = json_decode($inspeksi->foto_form, true);
|
||||
$formPeta = json_decode($inspeksi->data_form, true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return view('lpj::penilai.components.memo', compact('permohonan', 'formFoto', 'formPeta'));
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +142,7 @@ class PenilaiController extends Controller
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$permohonan = Permohonan::with(['debiture.documents.jenisjaminan', 'region.teams.teamsUsers.user', 'penilaian'])->find($id);
|
||||
$permohonan = Permohonan::with(['debiture.documents.jenisjaminan', 'region.teams.teamsUsers.user', 'penilaian', 'documents.inspeksi'])->find($id);
|
||||
|
||||
// return response()->json(['permohonan' => $permohonan]);
|
||||
return view('lpj::penilai.show', compact('permohonan'));
|
||||
@@ -123,11 +159,20 @@ class PenilaiController extends Controller
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function paparan(Request $request)
|
||||
{
|
||||
//
|
||||
$permohonanId = $request->query('permohonanId');
|
||||
return view('lpj::penilai.components.paparan');
|
||||
}
|
||||
|
||||
|
||||
public function rap(Request $request)
|
||||
{
|
||||
$permohonanId = $request->query('permohonanId');
|
||||
return view('lpj::penilai.components.paparan');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
@@ -160,7 +205,7 @@ class PenilaiController extends Controller
|
||||
// Apply whereHas to check penilai_id, role, and user_id specifically for 'penilai' role
|
||||
$query->whereHas('penilaian.userPenilai', function ($q) {
|
||||
$q->where('role', 'penilai') // Ensure the role is 'penilai'
|
||||
->where('user_id', 12); // Ganti dengan Auth::user()->id jika dinamis
|
||||
->where('user_id', Auth::user()->id); // Ganti dengan Auth::user()->id jika dinamis
|
||||
});
|
||||
|
||||
// Apply sorting if provided
|
||||
@@ -213,9 +258,9 @@ class PenilaiController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function kertas_kerja($id, $jaminanId)
|
||||
public function export_kertas_kerja($id, $jaminanId)
|
||||
{
|
||||
$data = Inspeksi::where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first();
|
||||
$data = Inspeksi::where('permohonan_id', $id)->where('dokument_id', $jaminanId)->first();
|
||||
|
||||
// $data = null;
|
||||
// $headerInfo = [
|
||||
@@ -234,5 +279,100 @@ class PenilaiController extends Controller
|
||||
}
|
||||
|
||||
|
||||
public function import_kertas_kerja(Request $request)
|
||||
{
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'permohonan_id' => 'required|integer',
|
||||
'document_id' => 'required|integer',
|
||||
'inspeksi_id' => 'required|integer',
|
||||
'kertas_kerja' => 'required|file|mimes:pdf,doc,docx,xls,xlsx,xlsx',
|
||||
]);
|
||||
|
||||
try {
|
||||
// Simpan file kertas kerja
|
||||
if ($request->hasFile('kertas_kerja')) {
|
||||
$file = $request->file('kertas_kerja');
|
||||
$filePath = $this->surveyorController->uploadFile($file, 'kertas_kerja');
|
||||
Penilai::updateOrCreate(
|
||||
[
|
||||
'permohonan_id' => $validatedData['permohonan_id'],
|
||||
'dokument_id' => $validatedData['document_id'],
|
||||
'inspeksi_id' => $validatedData['inspeksi_id'],
|
||||
],
|
||||
[
|
||||
'kertas_kerja' => $filePath,
|
||||
]
|
||||
);
|
||||
|
||||
return response()->json(['success' => true, 'message' => 'Kertas kerja berhasil diunggah.']);
|
||||
}
|
||||
|
||||
return response()->json(['success' => false, 'message' => 'File kertas kerja tidak ditemukan.'], 400);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['success' => false, 'message' => 'Terjadi kesalahan: ' . $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function status($id)
|
||||
{
|
||||
$penilai = Penilai::find($id);
|
||||
return response()->json(['data' => $penilai]);
|
||||
}
|
||||
|
||||
public function checkStatusLpj(Request $request)
|
||||
{
|
||||
$permohonanId = $request->query('permohonanId');
|
||||
$documentId = $request->query('documentId');
|
||||
$inspeksiId = $request->query('inspeksiId');
|
||||
|
||||
$statusLpj = Penilai::where('permohonan_id', $permohonanId)
|
||||
->where('dokument_id', $documentId)
|
||||
->where('inspeksi_id', $inspeksiId)
|
||||
->first();
|
||||
|
||||
return response()->json(['status' => $statusLpj ? $statusLpj->type : null]);
|
||||
}
|
||||
|
||||
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,
|
||||
]
|
||||
);
|
||||
|
||||
return response()->json(['success' => true]);
|
||||
}
|
||||
|
||||
|
||||
public function storePenilaian($id){
|
||||
try {
|
||||
$permohonan = Permohonan::findOrFail($id);
|
||||
$permohonan->update([
|
||||
'status' => 'proses-laporan',
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Berhasil menyimpan penilaian'
|
||||
], 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Terjadi kesalahan',
|
||||
'error' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -102,6 +102,7 @@ class SurveyorController extends Controller
|
||||
'tujuanPenilaian',
|
||||
'penilaian',
|
||||
'documents.jenisJaminan',
|
||||
'documents',
|
||||
])->findOrFail($id);
|
||||
|
||||
$surveyor = $id;
|
||||
@@ -112,7 +113,7 @@ class SurveyorController extends Controller
|
||||
// Get all inspeksi data for this permohonan
|
||||
$inspeksiData = Inspeksi::where('permohonan_id', $id)
|
||||
->get()
|
||||
->keyBy('jenis_jaminan_id')
|
||||
->keyBy('dokument_id')
|
||||
->map(function ($item) {
|
||||
return [
|
||||
'data_form' => json_decode($item->data_form, true),
|
||||
@@ -153,7 +154,7 @@ class SurveyorController extends Controller
|
||||
$inspeksi = Inspeksi::updateOrCreate(
|
||||
[
|
||||
'permohonan_id' => $request->input('permohonan_id'),
|
||||
'jenis_jaminan_id' => $request->input('jenis_jaminan_id')
|
||||
'dokument_id' => $request->input('dokument_id')
|
||||
],
|
||||
[
|
||||
'data_form' => json_encode($processedData),
|
||||
@@ -164,6 +165,7 @@ class SurveyorController extends Controller
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data berhasil disimpan',
|
||||
'data' => $processedData
|
||||
], 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
@@ -195,7 +197,7 @@ class SurveyorController extends Controller
|
||||
|
||||
$pisah = array_filter(
|
||||
explode(',', $action),
|
||||
function($act) use ($allowedActions) {
|
||||
function ($act) use ($allowedActions) {
|
||||
return isset($allowedActions[trim($act)]);
|
||||
}
|
||||
);
|
||||
@@ -227,7 +229,7 @@ class SurveyorController extends Controller
|
||||
$validationRules = [
|
||||
'luas' => 'required|numeric',
|
||||
'permohonan_id' => 'required',
|
||||
'jenis_jaminan_id' => 'required'
|
||||
'dokument_id' => 'required'
|
||||
];
|
||||
|
||||
if ($request->hasFile('foto_denah')) {
|
||||
@@ -247,7 +249,7 @@ class SurveyorController extends Controller
|
||||
|
||||
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))
|
||||
->where('jenis_jaminan_id', $request->input('jenis_jaminan_id'))
|
||||
->where('dokument_id', $request->input('dokument_id'))
|
||||
->first();
|
||||
|
||||
if ($inspeksi) {
|
||||
@@ -261,7 +263,7 @@ class SurveyorController extends Controller
|
||||
} else {
|
||||
Inspeksi::create([
|
||||
'permohonan_id' => $request->input('permohonan_id'),
|
||||
'jenis_jaminan_id' => $request->input('jenis_jaminan_id'),
|
||||
'dokument_id' => $request->input('dokument_id'),
|
||||
'denah_form' => json_encode($formatJsonDenah)
|
||||
]);
|
||||
}
|
||||
@@ -293,7 +295,7 @@ class SurveyorController extends Controller
|
||||
|
||||
$inspeksi = Inspeksi::firstOrNew([
|
||||
'permohonan_id' => $request->input('permohonan_id'),
|
||||
'jenis_jaminan_id' => $request->input('jenis_jaminan_id')
|
||||
'dokument_id' => $request->input('dokument_id')
|
||||
]);
|
||||
|
||||
// Get existing foto_form data if it exists
|
||||
@@ -398,24 +400,24 @@ class SurveyorController extends Controller
|
||||
$maxSize = getMaxFileSize('Foto');
|
||||
return $request->validate([
|
||||
'permohonan_id' => 'required',
|
||||
'jenis_jaminan_id' => 'required',
|
||||
'pendamping' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:'. $maxSize,
|
||||
'foto_objek.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:'. $maxSize,
|
||||
'dokument_id' => 'required',
|
||||
'pendamping' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,webp,bmp,tiff,heic,heif|max:'. $maxSize,
|
||||
'foto_objek.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg,webp,bmp,tiff,heic,heif|max:'. $maxSize,
|
||||
'name_objek.*' => 'required|string|max:255',
|
||||
'foto_lingkungan.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:'. $maxSize,
|
||||
'foto_lingkungan.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg,webp,bmp,tiff,heic,heif|max:'. $maxSize,
|
||||
'name_lingkungan.*' => 'required|string|max:255',
|
||||
'foto_rute.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:'. $maxSize,
|
||||
'foto_rute.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg,webp,bmp,tiff,heic,heif|max:'. $maxSize,
|
||||
'name_rute.*' => 'required|string|max:255',
|
||||
'lantai.*' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:'. $maxSize,
|
||||
'lantai.*' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,webp,bmp,tiff,heic,heif|max:'. $maxSize,
|
||||
'name_lantai_unit.*' => 'nullable|string|max:255',
|
||||
'foto_lantai_unit.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:'. $maxSize,
|
||||
'foto_lantai_unit.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg,webp,bmp,tiff,heic,heif|max:'. $maxSize,
|
||||
'name_rute_lainnya.*' => 'nullable|string',
|
||||
'foto_rute_lainnya.*' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:'. $maxSize,
|
||||
'foto_lantai_lainnya.*' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:'. $maxSize,
|
||||
'foto_rute_lainnya.*' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,webp,bmp,tiff,heic,heif|max:'. $maxSize,
|
||||
'foto_lantai_lainnya.*' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,webp,bmp,tiff,heic,heif|max:'. $maxSize,
|
||||
'name_lantai_lainnya.*' => 'nullable|string|max:255',
|
||||
'foto_basement.*' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:'. $maxSize,
|
||||
'foto_basement.*' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,webp,bmp,tiff,heic,heif|max:'. $maxSize,
|
||||
'name_basement.*' => 'nullable|string|max:255',
|
||||
'foto_gerbang' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:'. $maxSize,
|
||||
'foto_gerbang' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,webp,bmp,tiff,heic,heif|max:'. $maxSize,
|
||||
'name_gerbang' => 'nullable|string|max:255',
|
||||
]);
|
||||
}
|
||||
@@ -557,7 +559,7 @@ class SurveyorController extends Controller
|
||||
]);
|
||||
|
||||
$data['status'] = 'success';
|
||||
$data['message']= 'Jadwal '.$request->noReg.' berhasil di aprove';
|
||||
$data['message'] = 'Jadwal '.$request->noReg.' berhasil di aprove';
|
||||
} catch (\Exception $e) {
|
||||
$data['status'] = 'error';
|
||||
$data['message'] = 'Gagal membuat jadwal: ' . $e->getMessage();
|
||||
@@ -585,9 +587,9 @@ class SurveyorController extends Controller
|
||||
$fotoPembanding = $request->file('foto_objek_pembanding') ?? [];
|
||||
|
||||
$existingData = null;
|
||||
if ($request->has('permohonan_id') && $request->has('jenis_jaminan_id')) {
|
||||
if ($request->has('permohonan_id') && $request->has('dokument_id')) {
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))
|
||||
->where('jenis_jaminan_id', $request->input('jenis_jaminan_id'))
|
||||
->where('dokument_id', $request->input('dokument_id'))
|
||||
->first();
|
||||
|
||||
if ($inspeksi) {
|
||||
@@ -682,7 +684,7 @@ class SurveyorController extends Controller
|
||||
];
|
||||
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))
|
||||
->where('jenis_jaminan_id', $request->input('jenis_jaminan_id'))
|
||||
->where('dokument_id', $request->input('dokument_id'))
|
||||
->first();
|
||||
|
||||
if ($inspeksi) {
|
||||
@@ -699,12 +701,12 @@ class SurveyorController extends Controller
|
||||
$dataForm = json_decode($inspeksi->data_form, true) ?: [];
|
||||
|
||||
// Inisialisasi struktur data jika belum ada
|
||||
if(!isset($dataForm['bangunan'])) {
|
||||
if (!isset($dataForm['bangunan'])) {
|
||||
$dataForm['bangunan'] = [];
|
||||
$needsSave = true;
|
||||
}
|
||||
|
||||
if(!isset($dataForm['tanah'])) {
|
||||
if (!isset($dataForm['tanah'])) {
|
||||
$dataForm['tanah'] = [];
|
||||
$needsSave = true;
|
||||
}
|
||||
@@ -721,17 +723,35 @@ class SurveyorController extends Controller
|
||||
|
||||
// Fields untuk tanah
|
||||
if (in_array($field, ['luas_tanah'])) {
|
||||
$cekLuas = $dataForm['tanah']['luas_tanah'] == 'sesuai' ? 'sesuai' : 'tidak sesuai';
|
||||
$dataForm['tanah'][$field][$cekLuas] = $newValue;
|
||||
}
|
||||
// Fields untuk bangunan
|
||||
else if (in_array($field, ['luas_tanah_bagunan'])) {
|
||||
// Pastikan struktur array ada sebelum diakses
|
||||
if (!isset($dataForm['tanah']['luas_tanah'])) {
|
||||
$dataForm['tanah']['luas_tanah'] = [];
|
||||
}
|
||||
|
||||
$cekBanguan = $dataForm['bangunan']['luas_tanah_bagunan'] == 'sesuai' ? 'sesuai' : 'tidak sesuai';
|
||||
$dataForm['bangunan'][$field][$cekBanguan] = $newValue;
|
||||
$cekLuas = isset($dataForm['tanah']['luas_tanah']['sesuai']) && $dataForm['tanah']['luas_tanah']['sesuai'] === 'sesuai'
|
||||
? 'sesuai'
|
||||
: 'tidak sesuai';
|
||||
|
||||
$dataForm['tanah']['luas_tanah'][$cekLuas] = $newValue;
|
||||
$needsSave = true;
|
||||
}
|
||||
|
||||
// Fields untuk bangunan
|
||||
elseif (in_array($field, ['luas_tanah_bagunan'])) {
|
||||
if (!isset($dataForm['bangunan']['luas_tanah_bagunan'])) {
|
||||
$dataForm['bangunan']['luas_tanah_bagunan'] = [];
|
||||
}
|
||||
|
||||
$cekBanguan = isset($dataForm['bangunan']['luas_tanah_bagunan']['sesuai']) && $dataForm['bangunan']['luas_tanah_bagunan']['sesuai'] === 'sesuai'
|
||||
? 'sesuai'
|
||||
: 'tidak sesuai';
|
||||
|
||||
$dataForm['bangunan']['luas_tanah_bagunan'][$cekBanguan] = $newValue;
|
||||
$needsSave = true;
|
||||
}
|
||||
|
||||
// Fields untuk alamat dalam asset
|
||||
else if (in_array($field, ['address', 'village_code', 'district_code', 'city_code', 'province_code'])) {
|
||||
elseif (in_array($field, ['address', 'village_code', 'district_code', 'city_code', 'province_code'])) {
|
||||
|
||||
if (!isset($dataForm['asset']['alamat'])) {
|
||||
$dataForm['asset']['alamat'] = [];
|
||||
@@ -745,7 +765,7 @@ class SurveyorController extends Controller
|
||||
$dataForm['asset']['alamat'][$alamatStatus][$field] = $newValue;
|
||||
}
|
||||
// Jenis asset dalam asset
|
||||
else if ($field === 'jenis_asset') {
|
||||
elseif ($field === 'jenis_asset') {
|
||||
$assetStatus = $request->input('asset_status', 'sesuai');
|
||||
$dataForm['asset']['jenis_asset'] = [
|
||||
$assetStatus => $newValue
|
||||
@@ -809,7 +829,7 @@ class SurveyorController extends Controller
|
||||
$inspeksi = Inspeksi::updateOrCreate(
|
||||
[
|
||||
'permohonan_id' => $formattedData['permohonan_id'],
|
||||
'jenis_jaminan_id' => $formattedData['jenis_jaminan_id']
|
||||
'dokument_id' => $formattedData['dokument_id']
|
||||
],
|
||||
[
|
||||
'data_pembanding' => json_encode($formattedData),
|
||||
@@ -828,7 +848,7 @@ class SurveyorController extends Controller
|
||||
$validator = $request->validate([
|
||||
'permohonan_id' => 'required|exists:permohonan,id',
|
||||
'type' => 'required|string',
|
||||
'jenis_jaminan_id' => 'required',
|
||||
'dokument_id' => 'required',
|
||||
'foto_objek' => 'nullable|image|max:'.$maxSize,
|
||||
'foto_objek_pembanding.*' => 'nullable|image|max:'.$maxSize,
|
||||
]);
|
||||
@@ -843,7 +863,7 @@ class SurveyorController extends Controller
|
||||
|
||||
// Update foto_form
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))
|
||||
->where('jenis_jaminan_id', $request->input('jenis_jaminan_id'))
|
||||
->where('dokument_id', $request->input('dokument_id'))
|
||||
->first();
|
||||
|
||||
if ($inspeksi) {
|
||||
@@ -868,7 +888,7 @@ class SurveyorController extends Controller
|
||||
$formattedData = [
|
||||
'permohonan_id' => $request->input('permohonan_id'),
|
||||
'type' => $request->input('type'),
|
||||
'jenis_jaminan_id' => $request->input('jenis_jaminan_id'),
|
||||
'dokument_id' => $request->input('dokument_id'),
|
||||
'objek_penilaian' => $objekPenilaian,
|
||||
'data_pembanding' => $this->formatDataPembanding($request)
|
||||
];
|
||||
@@ -899,9 +919,21 @@ class SurveyorController extends Controller
|
||||
* Form inspeksi.
|
||||
*/
|
||||
|
||||
public function formInspeksi($id, $jaminanId)
|
||||
public function formInspeksi(Request $request, $id)
|
||||
{
|
||||
$permohonan = $this->getPermohonanJaminanId($id, $jaminanId);
|
||||
|
||||
$validated = $request->validate([
|
||||
'form' => 'required|in:create-inspeksi',
|
||||
'inspeksi' => 'required|exists:permohonan,id',
|
||||
'dokument' => 'required',
|
||||
'jenisjaminan' => 'required'
|
||||
]);
|
||||
|
||||
$dokumentId = $validated['dokument'];
|
||||
$jaminanId = $validated['jenisjaminan'];
|
||||
|
||||
$permohonan = $this->getPermohonanJaminanId($id, $dokumentId, $jaminanId);
|
||||
|
||||
$link_url_region = Teams::with('regions', 'teamsUsers')
|
||||
->whereHas('teamsUsers', function ($query) {
|
||||
$query->where('user_id', Auth::user()->id);
|
||||
@@ -915,7 +947,7 @@ class SurveyorController extends Controller
|
||||
$surveyor = $id;
|
||||
$basicData = $this->getCommonData();
|
||||
|
||||
$inpeksi = Inspeksi::where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first();
|
||||
$inpeksi = Inspeksi::where('permohonan_id', $id)->where('dokument_id', $dokumentId)->first();
|
||||
$forminspeksi = null;
|
||||
if ($inpeksi) {
|
||||
$forminspeksi = json_decode($inpeksi->data_form, true);
|
||||
@@ -962,13 +994,23 @@ class SurveyorController extends Controller
|
||||
* Denah.
|
||||
*/
|
||||
|
||||
public function denah($id, $jaminanId)
|
||||
public function denah(Request $request, $id)
|
||||
{
|
||||
$permohonan = $this->getPermohonanJaminanId($id, $jaminanId);
|
||||
$validated = $request->validate([
|
||||
'form' => 'required|in:create-denah',
|
||||
'denah' => 'required|exists:permohonan,id',
|
||||
'dokument' => 'required',
|
||||
'jenisjaminan' => 'required'
|
||||
]);
|
||||
|
||||
$dokumentId = $validated['dokument'];
|
||||
$jaminanId = $validated['jenisjaminan'];
|
||||
|
||||
$permohonan = $this->getPermohonanJaminanId($id, $dokumentId, $jaminanId);
|
||||
|
||||
$denah = null;
|
||||
|
||||
$inpeksi = Inspeksi::where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first();
|
||||
$inpeksi = Inspeksi::where('permohonan_id', $id)->where('dokument_id', $dokumentId)->first();
|
||||
$formDenah = null;
|
||||
if ($inpeksi) {
|
||||
$formDenah = json_decode($inpeksi->denah_form, true);
|
||||
@@ -982,14 +1024,25 @@ class SurveyorController extends Controller
|
||||
* Foto.
|
||||
*/
|
||||
|
||||
public function foto($id, $jaminanId)
|
||||
public function foto(Request $request, $id)
|
||||
{
|
||||
$permohonan = $this->getPermohonanJaminanId($id, $jaminanId);
|
||||
$validated = $request->validate([
|
||||
'form' => 'required|in:create-foto',
|
||||
'foto' => 'required|exists:permohonan,id',
|
||||
'dokument' => 'required',
|
||||
'jenisjaminan' => 'required'
|
||||
]);
|
||||
|
||||
$dokumentId = $validated['dokument'];
|
||||
$jaminanId = $validated['jenisjaminan'];
|
||||
|
||||
$permohonan = $this->getPermohonanJaminanId($id, $dokumentId, $jaminanId);
|
||||
|
||||
$surveyor = $id;
|
||||
$branches = Branch::all();
|
||||
$provinces = Province::all();
|
||||
|
||||
$inpeksi = Inspeksi::where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first();
|
||||
$inpeksi = Inspeksi::where('permohonan_id', $id)->where('dokument_id', $dokumentId)->first();
|
||||
|
||||
$formFoto = null;
|
||||
if ($inpeksi) {
|
||||
@@ -1003,25 +1056,28 @@ class SurveyorController extends Controller
|
||||
* Data pembanding.
|
||||
*/
|
||||
|
||||
public function dataPembanding($id, $jaminanId)
|
||||
public function dataPembanding(Request $request, $id)
|
||||
{
|
||||
try {
|
||||
// Ambil data permohonan dengan eager loading
|
||||
$permohonan = Permohonan::with([
|
||||
'user',
|
||||
'debiture.province',
|
||||
'debiture.city',
|
||||
'debiture.district',
|
||||
'debiture.village',
|
||||
'branch',
|
||||
'tujuanPenilaian',
|
||||
'penilaian'
|
||||
])->findOrFail($id);
|
||||
|
||||
$validated = $request->validate([
|
||||
'form' => 'required|in:data-pembanding',
|
||||
'pembanding' => 'required|exists:permohonan,id',
|
||||
'dokument' => 'required',
|
||||
'jenisjaminan' => 'required'
|
||||
]);
|
||||
|
||||
$dokumentId = $validated['dokument'];
|
||||
$jaminanId = $validated['jenisjaminan'];
|
||||
|
||||
$permohonan = $this->getPermohonanJaminanId($id, $dokumentId, $jaminanId);
|
||||
|
||||
|
||||
// Ambil data inspeksi
|
||||
$inspeksi = Inspeksi::where([
|
||||
'permohonan_id' => $id,
|
||||
'jenis_jaminan_id' => $jaminanId
|
||||
'dokument_id' => $dokumentId
|
||||
])->first();
|
||||
|
||||
// Inisialisasi variabel
|
||||
@@ -1496,7 +1552,7 @@ class SurveyorController extends Controller
|
||||
}
|
||||
|
||||
|
||||
private function getPermohonanJaminanId($id, $jaminanId)
|
||||
public function getPermohonanJaminanId($id, $dokumentId, $jaminanId)
|
||||
{
|
||||
return Permohonan::with([
|
||||
'user',
|
||||
@@ -1507,15 +1563,11 @@ class SurveyorController extends Controller
|
||||
'branch',
|
||||
'tujuanPenilaian',
|
||||
'penilaian',
|
||||
'debiture.documents.jenisJaminan',
|
||||
'debiture.documents' => function ($query) use ($jaminanId) {
|
||||
$query->where('jenis_jaminan_id', $jaminanId);
|
||||
'debiture.documents' => function ($query) use ($dokumentId, $jaminanId) {
|
||||
$query->where('id', $dokumentId)
|
||||
->where('jenis_jaminan_id', $jaminanId);
|
||||
}
|
||||
])
|
||||
->whereHas('debiture.documents', function ($query) use ($jaminanId) {
|
||||
$query->where('jenis_jaminan_id', $jaminanId);
|
||||
})
|
||||
->findOrFail($id);
|
||||
])->findOrFail($id);
|
||||
}
|
||||
|
||||
|
||||
@@ -1763,10 +1815,8 @@ class SurveyorController extends Controller
|
||||
'sifat_bangunan' => $data['sifat_bangunan'] ?? null,
|
||||
'sifat_bangunan_input' => $data['sifat_bangunan_input'] ?? null,
|
||||
'spesifikasi_bangunan' => $result ?? null,
|
||||
'sarana_pelengkap' => $this->mapArrayWithInputs(
|
||||
$data['sarana_pelengkap'] ?? [],
|
||||
$data['sarana_pelengkap_input'] ?? []
|
||||
),
|
||||
'sarana_pelengkap' => $data['sarana_pelengkap'] ?? null,
|
||||
'sarana_pelengkap_input' => $data['sarana_pelengkap_input'] ?? null,
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -1808,10 +1858,8 @@ class SurveyorController extends Controller
|
||||
'jarak_tps' => $data['jarak_tps'] ?? null,
|
||||
'nama_tps' => $data['nama_tps'] ?? null,
|
||||
'merupakan_daerah' => $data['merupakan_daerah'] ?? null,
|
||||
'fasilitas_dekat_object' => $this->mapArrayWithInputs(
|
||||
$data['fasilitas_dekat_object'] ?? [],
|
||||
$data['fasilitas_dekat_object_input'] ?? []
|
||||
),
|
||||
'fasilitas_dekat_object' => $data['fasilitas_dekat_object'] ?? null,
|
||||
'fasilitas_dekat_object_input' => $data['fasilitas_dekat_object_input'] ?? null,
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -1823,10 +1871,8 @@ class SurveyorController extends Controller
|
||||
'fakta_positif' => $data['fakta_positif'] ?? null,
|
||||
'fakta_negatif' => $data['fakta_negatif'] ?? null,
|
||||
'rute_menuju' => $data['rute_menuju'] ?? null,
|
||||
'batas_batas' => $this->mapArrayWithInputs(
|
||||
$data['batas_batas'] ?? [],
|
||||
$data['batas_batas_input'] ?? []
|
||||
),
|
||||
'batas_batas' => $data['batas_batas'] ?? null,
|
||||
'batas_batas_input' => $data['batas_batas_input'] ?? null,
|
||||
'kondisi_lingkungan' => $data['kondisi_lingkungan'] ?? null,
|
||||
'kondisi_lain_bangunan' => $data['kondisi_lain_bangunan'] ?? null,
|
||||
'informasi_dokument' => $data['informasi_dokument'] ?? null,
|
||||
@@ -1844,7 +1890,7 @@ class SurveyorController extends Controller
|
||||
];
|
||||
|
||||
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))->where('jenis_jaminan_id', $request->input('jenis_jaminan_id'))->first();
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))->where('dokument_id', $request->input('dokument_id'))->first();
|
||||
|
||||
|
||||
$fotoTypes = [
|
||||
@@ -2278,7 +2324,7 @@ class SurveyorController extends Controller
|
||||
*/
|
||||
|
||||
|
||||
private function uploadFile($file, $type)
|
||||
public function uploadFile($file, $type)
|
||||
{
|
||||
if (!$file->isValid()) {
|
||||
throw new Exception("Invalid file upload for {$type}");
|
||||
@@ -2306,8 +2352,10 @@ class SurveyorController extends Controller
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($keys as $index => $key) {
|
||||
$result[$key] = $values[$index] ?? null;
|
||||
foreach ($keys as $key) {
|
||||
// Jika checkbox dicentang, ambil nilai input yang sesuai
|
||||
// Gunakan nilai dari $values berdasarkan nama checkbox
|
||||
$result[$key] = $values[$key] ?? null;
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -2315,6 +2363,7 @@ class SurveyorController extends Controller
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Helper method generic untuk mengambil data field
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user