Merge branch 'staging' of https://git.putrakuningan.com/daengdeni/lpj into tender

This commit is contained in:
2025-02-11 10:59:07 +07:00
9 changed files with 1467 additions and 1356 deletions

View File

@@ -1032,10 +1032,10 @@ class PenilaiController extends Controller
$alamat = [
'address' => $inputAddress['address'] ?? null,
'village_code' => $this->getWilayahName($inputAddress['village_code'] ?? null, 'village'),
'district_code' => $this->getWilayahName($inputAddress['district_code'] ?? null, 'district'),
'city_code' => $this->getWilayahName($inputAddress['city_code'] ?? null, 'city'),
'province_code' => $this->getWilayahName($inputAddress['province_code'] ?? null, 'province')
'village_code' => getWilayahName($inputAddress['village_code'] ?? null, 'village'),
'district_code' => getWilayahName($inputAddress['district_code'] ?? null, 'district'),
'city_code' => getWilayahName($inputAddress['city_code'] ?? null, 'city'),
'province_code' => getWilayahName($inputAddress['province_code'] ?? null, 'province')
];
$viewLaporan = $this->getViewLaporan($tipeLaporan);
@@ -1112,39 +1112,6 @@ class PenilaiController extends Controller
return $viewMap[$tipe] ?? 'penilai.components.print-resume';
}
public function getWilayahName($code, $type)
{
try {
$wilayah = null;
if (!$code) {
return null;
}
switch ($type) {
case 'province':
$wilayah = Province::where('code', $code)->first();
return $wilayah ? $wilayah->name : null;
case 'city':
$wilayah = City::where('code', $code)->first();
return $wilayah ? $wilayah->name : null;
case 'district':
$wilayah = District::where('code', $code)->first();
return $wilayah ? $wilayah->name : null;
case 'village':
$wilayah = Village::where('code', $code)->first();
return $wilayah ? $wilayah->name : null;
default:
return null;
}
} catch (\Exception $e) {
return null;
}
}
// mengambil data dari fungsi permohonan di surveyor, dan table
@@ -1322,8 +1289,7 @@ class PenilaiController extends Controller
'resume' => [
'fakta.fakta_positif',
'fakta.fakta_negatif',
'fisik',
'keterangan'
'fisik'
],
];

View File

@@ -80,6 +80,7 @@ use Modules\Lpj\Models\SpekBagunanAnalisaDetail;
use Modules\Lpj\Http\Requests\SurveyorRequest;
use Modules\Lpj\Http\Requests\FormSurveyorRequest;
use Modules\Lpj\Emails\SendJadwalKunjunganEmail;
use App\Helpers\Lpj;
class SurveyorController extends Controller
{
@@ -3303,6 +3304,7 @@ class SurveyorController extends Controller
$validator = Validator::make($request->all(), [
'signature' => 'required',
'type' => 'required|in:penilai,cabang,debitur,kjjp',
'name' => 'nullable|string',
'document_id' => 'nullable|string'
]);
@@ -3338,6 +3340,7 @@ class SurveyorController extends Controller
// Simpan atau update signature berdasarkan type
$dataForm['signature'][$request->type] = [
'image' => $request->signature,
'name' => $request->name,
'created_at' => now()->toDateTimeString(),
'updated_at' => now()->toDateTimeString()
];
@@ -3381,6 +3384,7 @@ class SurveyorController extends Controller
'data' => [
'signature' => $dataForm['signature'][$type]['image'],
'type' => $type,
'name' => $dataForm['signature'][$type]['name'] ?? '',
'created_at' => $dataForm['signature'][$type]['created_at'],
'updated_at' => $dataForm['signature'][$type]['updated_at']
]
@@ -3495,6 +3499,25 @@ class SurveyorController extends Controller
return redirect()->back()->with('error', 'Data inspeksi tidak ditemukan.');
}
$forminspeksi = json_decode($inspeksi->data_form, true);
if (!$forminspeksi) {
// Redirect jika data form inspeksi kosong
return redirect()->back()->with('error', 'Silahkan isi terlebih dahulu form inspeksi.');
}
$inputAddress = $forminspeksi['asset']['alamat']['sesuai'] ?? $forminspeksi['asset']['alamat']['tidak sesuai'] ?? [];
$alamat = [
'address' => $inputAddress['address'] ?? null,
'village_code' => getWilayahName($inputAddress['village_code'] ?? null, 'village'),
'district_code' => getWilayahName($inputAddress['district_code'] ?? null, 'district'),
'city_code' => getWilayahName($inputAddress['city_code'] ?? null, 'city'),
'province_code' => getWilayahName($inputAddress['province_code'] ?? null, 'province')
];
// Decode data form inspeksi
$forminspeksi = json_decode($inspeksi->data_form, true);
@@ -3509,7 +3532,7 @@ class SurveyorController extends Controller
: 'lpj::surveyor.components.print-out.main';
// Generate PDF
$pdf = PDF::loadView($templateView, compact('permohonan', 'basicData', 'forminspeksi'));
$pdf = PDF::loadView($templateView, compact('permohonan', 'basicData', 'forminspeksi','alamat'));
$pdf->setPaper('A4', 'portrait');
// Tentukan nama file PDF