update form apartemen dan foto
This commit is contained in:
@@ -94,7 +94,6 @@ class SurveyorController extends Controller
|
||||
$saranaPelengkap = SaranaPelengkap::all();
|
||||
$arahMataAngin = ArahMataAngin::all();
|
||||
|
||||
$jenisJaminanIds = $permohonan->debiture->documents;
|
||||
|
||||
|
||||
|
||||
@@ -104,7 +103,15 @@ class SurveyorController extends Controller
|
||||
->where('permohonan_id', $id)
|
||||
->get();
|
||||
|
||||
$inpeksi = Inspeksi::where('permohonan_id', $id)->first();
|
||||
|
||||
|
||||
$jenisJaminanIds = $permohonan->debiture->documents->pluck('jenisJaminan.id')->toArray(); // Convert to array
|
||||
|
||||
$jaminanId = $jenisJaminanIds[0];
|
||||
$inpeksi = Inspeksi::where('permohonan_id', $id)
|
||||
->whereIn('jenis_jaminan_id', $jenisJaminanIds)
|
||||
->first();
|
||||
|
||||
if ($inpeksi) {
|
||||
$forminspeksi = json_decode($inpeksi->data_form, true);
|
||||
$formFoto = json_decode($inpeksi->foto_form, true);
|
||||
@@ -139,6 +146,7 @@ class SurveyorController extends Controller
|
||||
'forminspeksi',
|
||||
'formDenah',
|
||||
'formFoto',
|
||||
'jaminanId'
|
||||
));
|
||||
}
|
||||
/**
|
||||
@@ -158,15 +166,15 @@ class SurveyorController extends Controller
|
||||
$action = $request->input('type');
|
||||
$rules = $this->getActionSpecificRules($data, $action, $request);
|
||||
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))->first();
|
||||
|
||||
if ($inspeksi) {
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))->where('jenis_jaminan_id', $request->input('jenis_jaminan_id'))->first();
|
||||
if ($request->input('permohonan_id') == $inspeksi->permohonan_id && $request->input('jenis_jaminan_id') == $inspeksi->jenis_jaminan_id) {
|
||||
$inspeksi->update(['data_form' => json_encode($rules)]);
|
||||
} else {
|
||||
Inspeksi::create([
|
||||
'permohonan_id' => $request->permohonan_id,
|
||||
'data_form' => json_encode($rules),
|
||||
'name' => $request->type,
|
||||
'jenis_jaminan_id' => $request->input('jenis_jaminan_id'),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -236,8 +244,8 @@ class SurveyorController extends Controller
|
||||
];
|
||||
|
||||
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))->first();
|
||||
if ($request->input('permohonan_id') == $inspeksi->permohonan_id) {
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))->where('jenis_jaminan_id', $request->input('jenis_jaminan_id'))->first();
|
||||
if ($request->input('permohonan_id') == $inspeksi->permohonan_id && $request->input('jenis_jaminan_id') == $inspeksi->jenis_jaminan_id) {
|
||||
$inspeksi->update([
|
||||
'denah_form' => json_encode($formatJsonDenah)
|
||||
]);
|
||||
@@ -262,7 +270,6 @@ class SurveyorController extends Controller
|
||||
$validatedData = $request->validate([
|
||||
'permohonan_id' => 'required',
|
||||
'jenis_jaminan_id' => 'required',
|
||||
'analisa_type' => 'required|in:tanah_bangunan,unit',
|
||||
'pendamping' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
|
||||
'foto_objek.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
|
||||
'name_objek.*' => 'required|string|max:255',
|
||||
@@ -366,8 +373,8 @@ class SurveyorController extends Controller
|
||||
'pendamping' => $pendamping
|
||||
];
|
||||
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))->first();
|
||||
if ($request->input('permohonan_id') == $inspeksi->permohonan_id) {
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))->where('jenis_jaminan_id', $request->input('jenis_jaminan_id'))->first();
|
||||
if ($request->input('permohonan_id') == $inspeksi->permohonan_id && $request->input('jenis_jaminan_id') == $inspeksi->jenis_jaminan_id) {
|
||||
$inspeksi->update([
|
||||
'foto_form' => json_encode($formatFotojson)
|
||||
]);
|
||||
@@ -384,7 +391,7 @@ class SurveyorController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function submitSurveyor($id)
|
||||
public function submitSurveyor($id,$jaminanId)
|
||||
{
|
||||
try {
|
||||
$cekButton = $this->checkButtonStatus($id)->getData();
|
||||
@@ -407,6 +414,7 @@ class SurveyorController extends Controller
|
||||
public function checkButtonStatus($id)
|
||||
{
|
||||
try {
|
||||
|
||||
$inpeksi = Inspeksi::where('permohonan_id', $id)->first();
|
||||
|
||||
if ($inpeksi) {
|
||||
@@ -428,64 +436,64 @@ class SurveyorController extends Controller
|
||||
return response()->json(['buttonDisable' => true]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['error' => 'Something went wrong', 'message' => $e->getMessage()], 500);
|
||||
return response()->json(['buttonDisable' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function storeJadwal(Request $request)
|
||||
{
|
||||
try {
|
||||
{
|
||||
try {
|
||||
|
||||
$validate = $request->validate([
|
||||
'id' => 'required',
|
||||
'waktu_penilaian' => 'required',
|
||||
'deskripsi_penilaian' => 'required'
|
||||
]);
|
||||
$validate = $request->validate([
|
||||
'id' => 'required',
|
||||
'waktu_penilaian' => 'required',
|
||||
'deskripsi_penilaian' => 'required'
|
||||
]);
|
||||
|
||||
// return response()->json([
|
||||
// 'daa'=>$validate
|
||||
// ]);
|
||||
$id = $request->input('id');
|
||||
$penilaian = Penilaian::findOrFail($id);
|
||||
// return response()->json([
|
||||
// 'daa'=>$validate
|
||||
// ]);
|
||||
$id = $request->input('id');
|
||||
$penilaian = Penilaian::findOrFail($id);
|
||||
|
||||
$penilaian->update([
|
||||
'waktu_penilaian' => $validate['waktu_penilaian'],
|
||||
'deskripsi_penilaian' => $validate['deskripsi_penilaian'],
|
||||
|
||||
]);
|
||||
$penilaian->update([
|
||||
'waktu_penilaian' => $validate['waktu_penilaian'],
|
||||
'deskripsi_penilaian' => $validate['deskripsi_penilaian'],
|
||||
|
||||
return redirect()
|
||||
->route('surveyor.index')
|
||||
->with('success', 'Jadwal berhasil dibuat.');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()
|
||||
->route('surveyor.index')
|
||||
->with('error', 'Gagal membuat jadwal: ' . $e->getMessage());
|
||||
]);
|
||||
|
||||
return redirect()
|
||||
->route('surveyor.index')
|
||||
->with('success', 'Jadwal berhasil dibuat.');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()
|
||||
->route('surveyor.index')
|
||||
->with('error', 'Gagal membuat jadwal: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function storeAproved($id)
|
||||
{
|
||||
try {
|
||||
public function storeAproved($id)
|
||||
{
|
||||
try {
|
||||
|
||||
|
||||
$penilaian = Penilaian::findOrFail($id);
|
||||
$penilaian = Penilaian::findOrFail($id);
|
||||
|
||||
$penilaian->update([
|
||||
'authorized_status' => 1,
|
||||
]);
|
||||
$penilaian->update([
|
||||
'authorized_status' => 1,
|
||||
]);
|
||||
|
||||
return redirect()
|
||||
->route('permohonan.index')
|
||||
->with('success', 'Jadwal berhasil di aprove.');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()
|
||||
->route('permohonan.index')
|
||||
->with('error', 'Gagal membuat jadwal: ' . $e->getMessage());
|
||||
return redirect()
|
||||
->route('permohonan.index')
|
||||
->with('success', 'Jadwal berhasil di aprove.');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()
|
||||
->route('permohonan.index')
|
||||
->with('error', 'Gagal membuat jadwal: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Form inspeksi.
|
||||
*/
|
||||
@@ -534,7 +542,7 @@ public function storeAproved($id)
|
||||
|
||||
|
||||
|
||||
$inpeksi = Inspeksi::where('permohonan_id', $id)->first();
|
||||
$inpeksi = Inspeksi::where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first();
|
||||
$forminspeksi = null;
|
||||
if ($inpeksi) {
|
||||
$forminspeksi = json_decode($inpeksi->data_form, true);
|
||||
@@ -577,8 +585,7 @@ public function storeAproved($id)
|
||||
|
||||
$denah = null;
|
||||
|
||||
|
||||
$inpeksi = Inspeksi::where('permohonan_id', $id)->first();
|
||||
$inpeksi = Inspeksi::where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first();
|
||||
$formDenah = null;
|
||||
if ($inpeksi) {
|
||||
$formDenah = json_decode($inpeksi->denah_form, true);
|
||||
@@ -601,7 +608,8 @@ public function storeAproved($id)
|
||||
|
||||
|
||||
|
||||
$inpeksi = Inspeksi::where('permohonan_id', $id)->first();
|
||||
$inpeksi = Inspeksi::where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first();
|
||||
|
||||
$formFoto = null;
|
||||
if ($inpeksi) {
|
||||
$formFoto = json_decode($inpeksi->foto_form, true);
|
||||
@@ -1074,7 +1082,7 @@ public function storeAproved($id)
|
||||
}
|
||||
|
||||
|
||||
private function getTanahData($data,$request): array
|
||||
private function getTanahData($data, $request): array
|
||||
{
|
||||
return [
|
||||
'luas_tanah' => $data['luas_tanah'] ?? null,
|
||||
|
||||
Reference in New Issue
Block a user