perabaikan team activity, form inspeksi rap,laporan memo, rap, resume dan penambahan basic data perizinan
This commit is contained in:
@@ -27,6 +27,7 @@ use Modules\Location\Models\Village;
|
||||
use Modules\Lpj\Models\PosisiKavling;
|
||||
use Modules\Lpj\Models\KondisiFisikTanah;
|
||||
use Modules\Lpj\Models\FotoObjekJaminan;
|
||||
use Modules\Lpj\Models\Perizinan;
|
||||
use Modules\Lpj\Models\KetinggianTanah;
|
||||
use Modules\Lpj\Models\SifatBangunan;
|
||||
use Modules\Lpj\Models\JenisJaminan;
|
||||
@@ -114,7 +115,18 @@ class SurveyorController extends Controller
|
||||
$bentukTanah = BentukTanah::all();
|
||||
|
||||
// Get all inspeksi data for this permohonan
|
||||
$inspeksiData = Inspeksi::where('permohonan_id', $id)
|
||||
if (strtolower($permohonan->tujuanPenilaian->name) == 'rap') {
|
||||
$inspeksiData = Inspeksi::where('permohonan_id', $id)
|
||||
->get()
|
||||
->keyBy('dokument_id')
|
||||
->map(function ($item) {
|
||||
return [
|
||||
'data_form' => json_decode($item->data_form, true),
|
||||
'foto_form' => json_decode($item->foto_form, true)
|
||||
];
|
||||
});
|
||||
} else {
|
||||
$inspeksiData = Inspeksi::where('permohonan_id', $id)
|
||||
->get()
|
||||
->keyBy('dokument_id')
|
||||
->map(function ($item) {
|
||||
@@ -125,7 +137,7 @@ class SurveyorController extends Controller
|
||||
'data_pembanding' => json_decode($item->data_pembanding, true),
|
||||
];
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return view('lpj::surveyor.detail', compact(
|
||||
'permohonan',
|
||||
@@ -192,12 +204,13 @@ class SurveyorController extends Controller
|
||||
'pesawat' => 'getPesawatData',
|
||||
'alat-berat' => 'getAlatBeratData',
|
||||
'lingkungan' => 'getLingkunganData',
|
||||
'fakta' => 'getFactData'
|
||||
'fakta' => 'getFactData',
|
||||
'rap' => 'getRapData',
|
||||
];
|
||||
|
||||
$rules = [];
|
||||
$hasAssetDescriptionRules = false;
|
||||
|
||||
$hasFactaDat = false;
|
||||
$pisah = array_filter(
|
||||
explode(',', $action),
|
||||
function ($act) use ($allowedActions) {
|
||||
@@ -212,15 +225,23 @@ class SurveyorController extends Controller
|
||||
$actionRules = $this->$method($data, $request);
|
||||
$rules = array_merge($rules, $actionRules);
|
||||
|
||||
if (in_array($act, ['apartemen-kantor', 'tanah', 'bangunan'])) {
|
||||
if (in_array($act, ['apartemen-kantor', 'tanah', 'bangunan', 'rap'])) {
|
||||
$hasAssetDescriptionRules = true;
|
||||
}
|
||||
|
||||
if (in_array($act, ['rap'])) {
|
||||
$hasFactaData = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($hasAssetDescriptionRules) {
|
||||
$rules = array_merge($rules, $this->getAssetData($data));
|
||||
}
|
||||
|
||||
if ($hasFactaData) {
|
||||
$rules = array_merge($rules, $this->getFactData($data, $request));
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
@@ -388,73 +409,73 @@ class SurveyorController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a photo
|
||||
* Process a photo
|
||||
*/
|
||||
protected function processFotoLantaiUnit(Request $request, &$formatFotojson)
|
||||
{
|
||||
// Pastikan foto_lantai_unit sudah ada di formatFotojson
|
||||
if (!isset($formatFotojson['foto_lantai_unit'])) {
|
||||
$formatFotojson['foto_lantai_unit'] = [];
|
||||
}
|
||||
|
||||
// Ambil nama-nama lantai dari request
|
||||
$lantaiNama = $request->input('lantai_nama', []);
|
||||
|
||||
// Tambahan: gunakan lantai_index jika tersedia
|
||||
$lantaiIndex = $request->input('lantai_index', null);
|
||||
|
||||
// Cek apakah ada file foto lantai yang diunggah
|
||||
$lantaiFiles = $request->file('foto_lantai_unit', []);
|
||||
|
||||
// Proses setiap file foto lantai
|
||||
foreach ($lantaiFiles as $index => $files) {
|
||||
// Pastikan $files adalah array
|
||||
if (!is_array($files)) {
|
||||
$files = [$files];
|
||||
}
|
||||
|
||||
// Gunakan lantai_index jika tersedia, jika tidak gunakan cara sebelumnya
|
||||
$lantaiNomor = $lantaiIndex ?? ($index + 1);
|
||||
|
||||
// Inisialisasi array untuk lantai ini jika belum ada
|
||||
if (!isset($formatFotojson['foto_lantai_unit'][$lantaiNomor])) {
|
||||
$formatFotojson['foto_lantai_unit'][$lantaiNomor] = [];
|
||||
}
|
||||
|
||||
foreach ($files as $fileIndex => $file) {
|
||||
// Validasi file
|
||||
if (!$file->isValid()) {
|
||||
continue; // Lewati file yang tidak valid
|
||||
}
|
||||
|
||||
// Generate nama file unik
|
||||
$uniqueFileName = 'lantai_unit_' . $lantaiNomor . '_' . $fileIndex . '_' . Str::random(10) . '.' . $file->getClientOriginalExtension();
|
||||
|
||||
// Simpan file dengan nama asli
|
||||
$path = $file->storeAs(
|
||||
'surveyor/lantai_unit',
|
||||
$uniqueFileName . '/' . time() . '_' . $file->getClientOriginalName(),
|
||||
'public'
|
||||
);
|
||||
|
||||
// Buat nama foto
|
||||
$fotoName = "Foto Lantai {$lantaiNomor} - " . ($fileIndex + 1);
|
||||
|
||||
// Tambahkan detail foto ke array
|
||||
$fotoDetail = [
|
||||
'path' => $path,
|
||||
'name' => $fotoName
|
||||
];
|
||||
|
||||
// Tambahkan ke array foto lantai unit sesuai struktur
|
||||
$formatFotojson['foto_lantai_unit'][$lantaiNomor][] = $fotoDetail;
|
||||
}
|
||||
}
|
||||
|
||||
return $formatFotojson;
|
||||
}
|
||||
|
||||
|
||||
protected function processFotoLantaiUnit(Request $request, &$formatFotojson)
|
||||
{
|
||||
// Pastikan foto_lantai_unit sudah ada di formatFotojson
|
||||
if (!isset($formatFotojson['foto_lantai_unit'])) {
|
||||
$formatFotojson['foto_lantai_unit'] = [];
|
||||
}
|
||||
|
||||
// Ambil nama-nama lantai dari request
|
||||
$lantaiNama = $request->input('lantai_nama', []);
|
||||
|
||||
// Tambahan: gunakan lantai_index jika tersedia
|
||||
$lantaiIndex = $request->input('lantai_index', null);
|
||||
|
||||
// Cek apakah ada file foto lantai yang diunggah
|
||||
$lantaiFiles = $request->file('foto_lantai_unit', []);
|
||||
|
||||
// Proses setiap file foto lantai
|
||||
foreach ($lantaiFiles as $index => $files) {
|
||||
// Pastikan $files adalah array
|
||||
if (!is_array($files)) {
|
||||
$files = [$files];
|
||||
}
|
||||
|
||||
// Gunakan lantai_index jika tersedia, jika tidak gunakan cara sebelumnya
|
||||
$lantaiNomor = $lantaiIndex ?? ($index + 1);
|
||||
|
||||
// Inisialisasi array untuk lantai ini jika belum ada
|
||||
if (!isset($formatFotojson['foto_lantai_unit'][$lantaiNomor])) {
|
||||
$formatFotojson['foto_lantai_unit'][$lantaiNomor] = [];
|
||||
}
|
||||
|
||||
foreach ($files as $fileIndex => $file) {
|
||||
// Validasi file
|
||||
if (!$file->isValid()) {
|
||||
continue; // Lewati file yang tidak valid
|
||||
}
|
||||
|
||||
// Generate nama file unik
|
||||
$uniqueFileName = 'lantai_unit_' . $lantaiNomor . '_' . $fileIndex . '_' . Str::random(10) . '.' . $file->getClientOriginalExtension();
|
||||
|
||||
// Simpan file dengan nama asli
|
||||
$path = $file->storeAs(
|
||||
'surveyor/lantai_unit',
|
||||
$uniqueFileName . '/' . time() . '_' . $file->getClientOriginalName(),
|
||||
'public'
|
||||
);
|
||||
|
||||
// Buat nama foto
|
||||
$fotoName = "Foto Lantai {$lantaiNomor} - " . ($fileIndex + 1);
|
||||
|
||||
// Tambahkan detail foto ke array
|
||||
$fotoDetail = [
|
||||
'path' => $path,
|
||||
'name' => $fotoName
|
||||
];
|
||||
|
||||
// Tambahkan ke array foto lantai unit sesuai struktur
|
||||
$formatFotojson['foto_lantai_unit'][$lantaiNomor][] = $fotoDetail;
|
||||
}
|
||||
}
|
||||
|
||||
return $formatFotojson;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function handleFileUpload(Request $request, $paramName, &$formatFotojson)
|
||||
{
|
||||
@@ -670,10 +691,10 @@ class SurveyorController extends Controller
|
||||
{
|
||||
$permohonanId = $request->permohonan_id;
|
||||
$dokumentId = $request->dokument_id;
|
||||
|
||||
|
||||
// Normalisasi path foto
|
||||
$cleanRequestPath = str_replace(['storage/', 'surveyor/'], '', $request->foto_path);
|
||||
|
||||
|
||||
$inspeksi = Inspeksi::firstOrNew(
|
||||
['permohonan_id' => $permohonanId, 'dokument_id' => $dokumentId]
|
||||
);
|
||||
@@ -681,7 +702,7 @@ class SurveyorController extends Controller
|
||||
|
||||
// Konversi lantai ke string untuk konsistensi
|
||||
$lantai = (string)$request->lantai;
|
||||
|
||||
|
||||
// Cek apakah lantai ada di array
|
||||
$pat = null;
|
||||
if (isset($fotoLantaiUnit['foto_lantai_unit'][$lantai])) {
|
||||
@@ -691,7 +712,7 @@ class SurveyorController extends Controller
|
||||
function ($foto) use ($cleanRequestPath) {
|
||||
// Normalisasi path foto yang tersimpan
|
||||
$storedPath = str_replace(['storage/', 'surveyor/'], '', $foto['path']);
|
||||
|
||||
|
||||
// Jika path cocok, hapus file dari storage
|
||||
if ($storedPath === $cleanRequestPath) {
|
||||
// Hapus file dari storage dengan berbagai kemungkinan path
|
||||
@@ -701,14 +722,14 @@ class SurveyorController extends Controller
|
||||
'storage/' . $cleanRequestPath,
|
||||
$cleanRequestPath
|
||||
];
|
||||
|
||||
|
||||
foreach ($possiblePaths as $path) {
|
||||
if (Storage::disk('public')->exists($path)) {
|
||||
Storage::disk('public')->delete($path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false; // Hapus dari array
|
||||
}
|
||||
return true;
|
||||
@@ -717,28 +738,28 @@ class SurveyorController extends Controller
|
||||
|
||||
// Reset index array
|
||||
$fotoLantaiUnit['foto_lantai_unit'][$lantai] = array_values($fotoLantaiUnit['foto_lantai_unit'][$lantai]);
|
||||
|
||||
|
||||
// Hapus lantai jika tidak ada foto
|
||||
if (empty($fotoLantaiUnit['foto_lantai_unit'][$lantai])) {
|
||||
unset($fotoLantaiUnit['foto_lantai_unit'][$lantai]);
|
||||
}
|
||||
|
||||
|
||||
// Update inspeksi
|
||||
$inspeksi->foto_form = json_encode($fotoLantaiUnit);
|
||||
$inspeksi->save();
|
||||
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'foto_lantai_unit' => $pat
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'gagal menghapus'
|
||||
], 404);
|
||||
}
|
||||
|
||||
|
||||
private function processPhotoLainnya(Request $request, array $fields, array $existingPhotos = [])
|
||||
{
|
||||
$result = $existingPhotos; // Start with existing photos
|
||||
@@ -869,30 +890,40 @@ class SurveyorController extends Controller
|
||||
return response()->json(['buttonDisable' => true]);
|
||||
}
|
||||
|
||||
$rapComplete = false;
|
||||
foreach ($inspeksiRecords as $inspeksi) {
|
||||
$dataForm = json_decode($inspeksi->data_form, true);
|
||||
$fotoForm = json_decode($inspeksi->foto_form, true);
|
||||
$denahForm = json_decode($inspeksi->denah_form, true);
|
||||
$dataPembanding = json_decode($inspeksi->data_pembanding, true);
|
||||
if (strtolower($inspeksi->name) === 'rap') {
|
||||
$dataForm = json_decode($inspeksi->data_form, true);
|
||||
$fotoForm = json_decode($inspeksi->foto_form, true);
|
||||
$isInvalid = empty($dataForm) &&
|
||||
empty($fotoForm);
|
||||
if ($isInvalid) {
|
||||
return response()->json(['buttonDisable' => true]);
|
||||
}
|
||||
} else {
|
||||
$dataForm = json_decode($inspeksi->data_form, true);
|
||||
$fotoForm = json_decode($inspeksi->foto_form, true);
|
||||
$denahForm = json_decode($inspeksi->denah_form, true);
|
||||
$dataPembanding = json_decode($inspeksi->data_pembanding, true);
|
||||
|
||||
$jenisJaminan = $inspeksi->dokument->jenisJaminan->name ?? '';
|
||||
$jenisJaminan = $inspeksi->dokument->jenisJaminan->name ?? '';
|
||||
|
||||
$isTanahBangunan = !in_array(
|
||||
strtoupper($jenisJaminan->name ?? ''),
|
||||
['KAPAL', 'PESAWAT', 'KENDARAAN', 'ALAT BERAT']
|
||||
);
|
||||
$isTanahBangunan = !in_array(
|
||||
strtoupper($jenisJaminan->name ?? ''),
|
||||
['KAPAL', 'PESAWAT', 'KENDARAAN', 'ALAT BERAT']
|
||||
);
|
||||
|
||||
$isInvalid =
|
||||
empty($dataForm) ||
|
||||
empty($fotoForm) ||
|
||||
(($isTanahBangunan && empty($denahForm)) ||
|
||||
empty($dataPembanding));
|
||||
$isInvalid =
|
||||
empty($dataForm) ||
|
||||
empty($fotoForm) ||
|
||||
(($isTanahBangunan && empty($denahForm)) ||
|
||||
empty($dataPembanding));
|
||||
|
||||
if ($isInvalid) {
|
||||
return response()->json(['buttonDisable' => true]);
|
||||
if ($isInvalid) {
|
||||
return response()->json(['buttonDisable' => true]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we get here, all checks passed
|
||||
return response()->json(['buttonDisable' => false]);
|
||||
|
||||
@@ -1880,6 +1911,7 @@ class SurveyorController extends Controller
|
||||
'Merupakan Daerah' => MerupakanDaerah::class,
|
||||
'Jenis unit' => JenisUnit::class,
|
||||
'Foto Objek Jaminan' => FotoObjekJaminan::class,
|
||||
'Perizinan' => Perizinan::class,
|
||||
];
|
||||
|
||||
|
||||
@@ -2023,7 +2055,8 @@ class SurveyorController extends Controller
|
||||
'merupakan-daerah' => MerupakanDaerah::class,
|
||||
'jenis-unit' => JenisUnit::class,
|
||||
'perkerasan-jalan' => PerkerasanJalan::class,
|
||||
'foto-objek-jaminan' => FotoObjekJaminan::class
|
||||
'foto-objek-jaminan' => FotoObjekJaminan::class,
|
||||
'perizinan' => Perizinan::class
|
||||
];
|
||||
|
||||
|
||||
@@ -2065,12 +2098,11 @@ class SurveyorController extends Controller
|
||||
'hubPenghuni' => HubunganPenghuniJaminan::all(),
|
||||
'perkerasanJalan' => PerkerasanJalan::all(),
|
||||
'terletakDiArea' => TerletakArea::all(),
|
||||
'tujuanPenilaian' => TujuanPenilaian::all()
|
||||
'tujuanPenilaian' => TujuanPenilaian::all(),
|
||||
'perizinan' => Perizinan::all()
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
private const HEADERS = [
|
||||
'bentuk-tanah' => ['Bentuk Tanah', 'bentuk-tanah'],
|
||||
'kontur-tanah' => ['Kontur Tanah', 'kontur-tanah'],
|
||||
@@ -2100,6 +2132,7 @@ class SurveyorController extends Controller
|
||||
'bentuk-unit' => ['Bentuk unit', 'bentuk-unit'],
|
||||
'fasilitas-objek' => ['Fasilitas Umum Dekat Objek', 'fasilitas-objek'],
|
||||
'foto-objek-jaminan' => ['Foto Objek Jaminan', 'foto-objek-jaminan'],
|
||||
'perizinan' => ['Perizinan', 'perizinan'],
|
||||
];
|
||||
|
||||
private function getAssetData(array $data): array
|
||||
@@ -2338,6 +2371,39 @@ class SurveyorController extends Controller
|
||||
return $factData;
|
||||
}
|
||||
|
||||
private function getRapData($data, $request): array
|
||||
{
|
||||
$rapData = [
|
||||
'perizinan' => $data['perizinan'] ?? null,
|
||||
'perizinan_file' => $data['perizinan_file'] ?? null,
|
||||
'brosur_price_list' => $data['brosur_price_list'] ?? null,
|
||||
'brosur_price_file' => $data['brosur_price_file'] ?? null,
|
||||
'pengalaman_developer' => $data['pengalaman_developer'] ?? null,
|
||||
'developer_anggota' => $data['developer_anggota'] ?? null,
|
||||
'lainnya_developer' => $data['lainnya_developer'] ?? null,
|
||||
'kapan_mulai_dibangun' => $data['kapan_mulai_dibangun'] ?? null,
|
||||
'kondisi_perumahan' => $data['kondisi_perumahan'] ?? null,
|
||||
'progres_pembangunan' => $data['progres_pembangunan'] ?? null,
|
||||
'kontraktor' => $data['kontraktor'] ?? null,
|
||||
'lingkungan_sekitar' => $data['lingkungan_sekitar'] ?? null,
|
||||
'komplek_disekitar' => $data['komplek_disekitar'] ?? null,
|
||||
'pusat_keramaian' => $data['pusat_keramaian'] ?? null,
|
||||
'transportasi_umum' => $data['transportasi_umum'] ?? null,
|
||||
'lainnya_kondisi' => $data['lainnya_kondisi'] ?? null,
|
||||
'partisi' => $data['partisi'] ?? null,
|
||||
'jumlah_unit' => $data['jumlah_unit'] ?? null,
|
||||
'batas_batas_perumahan' => $data['batas_batas_perumahan'] ?? null,
|
||||
'fasus_fasum' => $data['fasus_fasum'] ?? null,
|
||||
'progres_penjualan' => $data['progres_penjualan'] ?? null,
|
||||
'harga_unit' => $data['harga_unit'] ?? null,
|
||||
'target_market' => $data['target_market'] ?? null,
|
||||
'kerjasama_dengan_bank' => $data['kerjasama_dengan_bank'] ?? null,
|
||||
'rute_menuju_lokasi' => $data['rute_menuju_lokasi'] ?? null,
|
||||
];
|
||||
|
||||
return $rapData;
|
||||
}
|
||||
|
||||
private function updateOrDeleteFile($data, $request, $fileKey)
|
||||
{
|
||||
if ($request->hasFile($fileKey)) {
|
||||
|
||||
Reference in New Issue
Block a user