update data pembading surveyor
This commit is contained in:
@@ -6,6 +6,7 @@ use Illuminate\Http\Request;
|
|||||||
use Modules\Lpj\Models\Permohonan;
|
use Modules\Lpj\Models\Permohonan;
|
||||||
use Modules\Lpj\Models\Inspeksi;
|
use Modules\Lpj\Models\Inspeksi;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
class PenilaiController extends Controller
|
class PenilaiController extends Controller
|
||||||
{
|
{
|
||||||
@@ -22,7 +23,8 @@ class PenilaiController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Show the form for creating a new resource.
|
* Show the form for creating a new resource.
|
||||||
*/
|
*/
|
||||||
public function lampiran($id){
|
public function lampiran($id)
|
||||||
|
{
|
||||||
$permohonan = Permohonan::with('debiture.documents')->find($id);
|
$permohonan = Permohonan::with('debiture.documents')->find($id);
|
||||||
|
|
||||||
$jaminanId = $permohonan->debiture->documents->first()->jenis_jaminan_id;
|
$jaminanId = $permohonan->debiture->documents->first()->jenis_jaminan_id;
|
||||||
@@ -36,7 +38,7 @@ class PenilaiController extends Controller
|
|||||||
|
|
||||||
|
|
||||||
return view('lpj::penilai.lampiran', compact('permohonan', 'formFoto'));
|
return view('lpj::penilai.lampiran', compact('permohonan', 'formFoto'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
@@ -87,67 +89,83 @@ class PenilaiController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function dataForDatatables(Request $request)
|
public function dataForDatatables(Request $request)
|
||||||
{
|
{
|
||||||
if (is_null($this->user) || !$this->user->can('penilai.view')) {
|
if (is_null($this->user) || !$this->user->can('penilai.view')) {
|
||||||
//abort(403, 'Sorry! You are not allowed to view users.');
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve data from the database
|
|
||||||
$query = Permohonan::query()->where('status', '=', 'done');
|
|
||||||
|
|
||||||
// Apply search filter if provided
|
|
||||||
if ($request->has('search') && !empty($request->get('search'))) {
|
|
||||||
$search = $request->get('search');
|
|
||||||
$query->where(function ($q) use ($search) {
|
|
||||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
|
|
||||||
$q->orWhereRelation('debiture', 'name', 'LIKE', '%' . $search . '%');
|
|
||||||
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
|
||||||
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
|
|
||||||
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
|
|
||||||
$q->orWhereRelation('jenisfasilitasKredit', 'name', 'LIKE', '%' . $search . '%');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply sorting if provided
|
|
||||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
|
||||||
$order = $request->get('sortOrder');
|
|
||||||
$column = $request->get('sortField');
|
|
||||||
$query->orderBy($column, $order);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the total count of records
|
|
||||||
$totalRecords = $query->count();
|
|
||||||
|
|
||||||
// Apply pagination if provided
|
|
||||||
if ($request->has('page') && $request->has('size')) {
|
|
||||||
$page = $request->get('page');
|
|
||||||
$size = $request->get('size');
|
|
||||||
$offset = ($page - 1) * $size; // Calculate the offset
|
|
||||||
|
|
||||||
$query->skip($offset)->take($size);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the filtered count of records
|
|
||||||
$filteredRecords = $query->count();
|
|
||||||
|
|
||||||
// Get the data for the current page
|
|
||||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'jenisfasilitasKredit'])->get();
|
|
||||||
|
|
||||||
// Calculate the page count
|
|
||||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
|
||||||
|
|
||||||
// Calculate the current page number
|
|
||||||
$currentPage = 0 + 1;
|
|
||||||
|
|
||||||
// Return the response data as a JSON object
|
|
||||||
return response()->json([
|
|
||||||
'draw' => $request->get('draw'),
|
|
||||||
'recordsTotal' => $totalRecords,
|
|
||||||
'recordsFiltered' => $filteredRecords,
|
|
||||||
'pageCount' => $pageCount,
|
|
||||||
'page' => $currentPage,
|
|
||||||
'totalCount' => $totalRecords,
|
|
||||||
'data' => $data,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Retrieve data from the database
|
||||||
|
$query = Permohonan::query();
|
||||||
|
|
||||||
|
// Apply search filter if provided
|
||||||
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
|
$search = $request->get('search');
|
||||||
|
$columns = ['nomor_registrasi', 'debiture.name', 'branch.name', 'user.name', 'tujuanPenilaian.name', 'jenisfasilitasKredit.name'];
|
||||||
|
|
||||||
|
$query->where(function ($q) use ($search, $columns) {
|
||||||
|
foreach ($columns as $column) {
|
||||||
|
$q->orWhereRelation(explode('.', $column)[0], explode('.', $column)[1], 'LIKE', '%' . $search . '%');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
});
|
||||||
|
|
||||||
|
// Apply sorting if provided
|
||||||
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
$order = $request->get('sortOrder');
|
||||||
|
$column = $request->get('sortField');
|
||||||
|
$query->orderBy($column, $order);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the total count of records
|
||||||
|
$totalRecords = $query->count();
|
||||||
|
|
||||||
|
// Apply pagination if provided
|
||||||
|
if ($request->has('page') && $request->has('size')) {
|
||||||
|
$page = $request->get('page');
|
||||||
|
$size = $request->get('size');
|
||||||
|
$offset = ($page - 1) * $size;
|
||||||
|
|
||||||
|
$query->skip($offset)->take($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the filtered count of records
|
||||||
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
|
// Get the data for the current page
|
||||||
|
$data = $query->with([
|
||||||
|
'user',
|
||||||
|
'debiture',
|
||||||
|
'branch',
|
||||||
|
'tujuanPenilaian',
|
||||||
|
'jenisfasilitasKredit',
|
||||||
|
'penilaian.userPenilai' // Ensure this relation is included
|
||||||
|
])->get();
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||||
|
|
||||||
|
// Calculate the current page number
|
||||||
|
$currentPage = $request->get('page', 1);
|
||||||
|
|
||||||
|
// Return the response data as a JSON object
|
||||||
|
return response()->json([
|
||||||
|
'draw' => $request->get('draw'),
|
||||||
|
'recordsTotal' => $totalRecords,
|
||||||
|
'recordsFiltered' => $filteredRecords,
|
||||||
|
'pageCount' => $pageCount,
|
||||||
|
'page' => $currentPage,
|
||||||
|
'totalCount' => $totalRecords,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace Modules\Lpj\Http\Controllers;
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
use Modules\Lpj\Exports\BasicDataSurveyorExport;
|
use Modules\Lpj\Exports\BasicDataSurveyorExport;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
@@ -97,12 +98,12 @@ class SurveyorController extends Controller
|
|||||||
'penilaian',
|
'penilaian',
|
||||||
'documents.jenisJaminan',
|
'documents.jenisJaminan',
|
||||||
])->findOrFail($id);
|
])->findOrFail($id);
|
||||||
|
|
||||||
$surveyor = $id;
|
$surveyor = $id;
|
||||||
$branches = Branch::all();
|
$branches = Branch::all();
|
||||||
$provinces = Province::all();
|
$provinces = Province::all();
|
||||||
$bentukTanah = BentukTanah::all();
|
$bentukTanah = BentukTanah::all();
|
||||||
|
|
||||||
// Get all inspeksi data for this permohonan
|
// Get all inspeksi data for this permohonan
|
||||||
$inspeksiData = Inspeksi::where('permohonan_id', $id)
|
$inspeksiData = Inspeksi::where('permohonan_id', $id)
|
||||||
->get()
|
->get()
|
||||||
@@ -115,7 +116,8 @@ class SurveyorController extends Controller
|
|||||||
'data_pembanding' => json_decode($item->data_pembanding, true),
|
'data_pembanding' => json_decode($item->data_pembanding, true),
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return view('lpj::surveyor.detail', compact(
|
return view('lpj::surveyor.detail', compact(
|
||||||
'permohonan',
|
'permohonan',
|
||||||
'surveyor',
|
'surveyor',
|
||||||
@@ -125,7 +127,7 @@ class SurveyorController extends Controller
|
|||||||
'inspeksiData'
|
'inspeksiData'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store form inspeksi.
|
* Store form inspeksi.
|
||||||
*/
|
*/
|
||||||
@@ -134,10 +136,10 @@ class SurveyorController extends Controller
|
|||||||
try {
|
try {
|
||||||
// Validate request data
|
// Validate request data
|
||||||
$validatedData = $request->validated();
|
$validatedData = $request->validated();
|
||||||
|
|
||||||
// Get action specific rules and process data
|
// Get action specific rules and process data
|
||||||
$processedData = $this->getActionSpecificRules(
|
$processedData = $this->getActionSpecificRules(
|
||||||
$validatedData,
|
$validatedData,
|
||||||
$request->input('type'),
|
$request->input('type'),
|
||||||
$request
|
$request
|
||||||
);
|
);
|
||||||
@@ -264,19 +266,19 @@ class SurveyorController extends Controller
|
|||||||
'foto_lantai_lainnya' => ['foto_lantai_lainnya', 'name_lantai_lainnya'],
|
'foto_lantai_lainnya' => ['foto_lantai_lainnya', 'name_lantai_lainnya'],
|
||||||
'foto_rute_lainnya' => ['foto_rute_lainnya', 'name_rute_lainnya'],
|
'foto_rute_lainnya' => ['foto_rute_lainnya', 'name_rute_lainnya'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$inspeksi = Inspeksi::firstOrNew([
|
$inspeksi = Inspeksi::firstOrNew([
|
||||||
'permohonan_id' => $request->input('permohonan_id'),
|
'permohonan_id' => $request->input('permohonan_id'),
|
||||||
'jenis_jaminan_id' => $request->input('jenis_jaminan_id')
|
'jenis_jaminan_id' => $request->input('jenis_jaminan_id')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Get existing foto_form data if it exists
|
// Get existing foto_form data if it exists
|
||||||
$existingData = $inspeksi->exists && $inspeksi->foto_form
|
$existingData = $inspeksi->exists && $inspeksi->foto_form
|
||||||
? json_decode($inspeksi->foto_form, true)
|
? json_decode($inspeksi->foto_form, true)
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
$formatFotojson = $existingData; // Start with existing data
|
$formatFotojson = $existingData; // Start with existing data
|
||||||
|
|
||||||
// Process each photo category
|
// Process each photo category
|
||||||
foreach ($photoCategories as $category => $fields) {
|
foreach ($photoCategories as $category => $fields) {
|
||||||
// Only update if new files are provided
|
// Only update if new files are provided
|
||||||
@@ -288,7 +290,7 @@ class SurveyorController extends Controller
|
|||||||
$formatFotojson[$category] = $this->processPhotoCategory($request, $fields);
|
$formatFotojson[$category] = $this->processPhotoCategory($request, $fields);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process single files
|
// Process single files
|
||||||
$singleFiles = ['foto_basement', 'foto_gerbang', 'pendamping'];
|
$singleFiles = ['foto_basement', 'foto_gerbang', 'pendamping'];
|
||||||
foreach ($singleFiles as $file) {
|
foreach ($singleFiles as $file) {
|
||||||
@@ -300,7 +302,7 @@ class SurveyorController extends Controller
|
|||||||
$formatFotojson[$file] = $this->uploadFile($request->file($file), $file);
|
$formatFotojson[$file] = $this->uploadFile($request->file($file), $file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update record
|
// Update record
|
||||||
$inspeksi->foto_form = json_encode($formatFotojson);
|
$inspeksi->foto_form = json_encode($formatFotojson);
|
||||||
$inspeksi->save();
|
$inspeksi->save();
|
||||||
@@ -340,34 +342,34 @@ class SurveyorController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function categoryHasNewFiles(Request $request, array $fields): bool
|
private function categoryHasNewFiles(Request $request, array $fields): bool
|
||||||
{
|
{
|
||||||
$photoField = $fields[0]; // First element is usually the photo field
|
$photoField = $fields[0]; // First element is usually the photo field
|
||||||
return $request->hasFile($photoField) ||
|
return $request->hasFile($photoField) ||
|
||||||
(is_array($request->file($photoField)) && count($request->file($photoField)) > 0);
|
(is_array($request->file($photoField)) && count($request->file($photoField)) > 0);
|
||||||
}
|
|
||||||
|
|
||||||
private function deleteFilesForCategory($categoryData)
|
|
||||||
{
|
|
||||||
if (!is_array($categoryData)) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($categoryData as $item) {
|
private function deleteFilesForCategory($categoryData)
|
||||||
if (isset($item['foto'])) {
|
{
|
||||||
$this->deleteOfFile($item['foto']);
|
if (!is_array($categoryData)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($categoryData as $item) {
|
||||||
|
if (isset($item['foto'])) {
|
||||||
|
$this->deleteOfFile($item['foto']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private function deleteOfFile($filePath)
|
private function deleteOfFile($filePath)
|
||||||
{
|
{
|
||||||
if ($filePath && Storage::exists($filePath)) {
|
if ($filePath && Storage::exists($filePath)) {
|
||||||
Storage::delete($filePath);
|
Storage::delete($filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom validation request for foto
|
* Custom validation request for foto
|
||||||
@@ -377,7 +379,7 @@ private function deleteOfFile($filePath)
|
|||||||
return $request->validate([
|
return $request->validate([
|
||||||
'permohonan_id' => 'required',
|
'permohonan_id' => 'required',
|
||||||
'jenis_jaminan_id' => 'required',
|
'jenis_jaminan_id' => 'required',
|
||||||
'pendamping' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
|
'pendamping' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
|
||||||
'foto_objek.*' => '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',
|
'name_objek.*' => 'required|string|max:255',
|
||||||
'foto_lingkungan.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
|
'foto_lingkungan.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
|
||||||
@@ -399,40 +401,40 @@ private function deleteOfFile($filePath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function submitSurveyor($id)
|
public function submitSurveyor($id)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// Get button status check result
|
// Get button status check result
|
||||||
$buttonStatusCheck = $this->checkButtonStatus($id);
|
$buttonStatusCheck = $this->checkButtonStatus($id);
|
||||||
$buttonStatus = json_decode($buttonStatusCheck->getContent(), true);
|
$buttonStatus = json_decode($buttonStatusCheck->getContent(), true);
|
||||||
|
|
||||||
// Check if button should be disabled
|
// Check if button should be disabled
|
||||||
if ($buttonStatus['buttonDisable']) {
|
if ($buttonStatus['buttonDisable']) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Form belum lengkap. Pastikan semua data telah diisi dengan benar.',
|
||||||
|
], 422);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If validation passes, update permohonan status
|
||||||
|
// $permohonan = Permohonan::findOrFail($id);
|
||||||
|
// $permohonan->update([
|
||||||
|
// 'status' => 'done',
|
||||||
|
// 'submitted_at' => now()
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Form surveyor berhasil disubmit'
|
||||||
|
], 200);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'message' => 'Form belum lengkap. Pastikan semua data telah diisi dengan benar.',
|
'message' => 'Terjadi kesalahan',
|
||||||
], 422);
|
'error' => $e->getMessage()
|
||||||
|
], 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If validation passes, update permohonan status
|
|
||||||
// $permohonan = Permohonan::findOrFail($id);
|
|
||||||
// $permohonan->update([
|
|
||||||
// 'status' => 'done',
|
|
||||||
// 'submitted_at' => now()
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'success' => true,
|
|
||||||
'message' => 'Form surveyor berhasil disubmit'
|
|
||||||
], 200);
|
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return response()->json([
|
|
||||||
'success' => false,
|
|
||||||
'message' => 'Terjadi kesalahan',
|
|
||||||
'error' => $e->getMessage()
|
|
||||||
], 500);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -442,41 +444,41 @@ private function deleteOfFile($filePath)
|
|||||||
try {
|
try {
|
||||||
// Get all inspeksi records for this permohonan
|
// Get all inspeksi records for this permohonan
|
||||||
$inspeksiRecords = Inspeksi::where('permohonan_id', $id)->get();
|
$inspeksiRecords = Inspeksi::where('permohonan_id', $id)->get();
|
||||||
|
|
||||||
if ($inspeksiRecords->isEmpty()) {
|
if ($inspeksiRecords->isEmpty()) {
|
||||||
return response()->json(['buttonDisable' => true]);
|
return response()->json(['buttonDisable' => true]);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($inspeksiRecords as $inspeksi) {
|
foreach ($inspeksiRecords as $inspeksi) {
|
||||||
$dataForm = json_decode($inspeksi->data_form, true);
|
$dataForm = json_decode($inspeksi->data_form, true);
|
||||||
$fotoForm = json_decode($inspeksi->foto_form, true);
|
$fotoForm = json_decode($inspeksi->foto_form, true);
|
||||||
$denahForm = json_decode($inspeksi->denah_form, true);
|
$denahForm = json_decode($inspeksi->denah_form, true);
|
||||||
$dataPembanding = json_decode($inspeksi->data_pembanding, true);
|
$dataPembanding = json_decode($inspeksi->data_pembanding, true);
|
||||||
|
|
||||||
// Get jenis jaminan to check if it needs denah
|
// Get jenis jaminan to check if it needs denah
|
||||||
$jenisJaminan = JenisJaminan::find($inspeksi->jenis_jaminan_id);
|
$jenisJaminan = JenisJaminan::find($inspeksi->jenis_jaminan_id);
|
||||||
$isTanahBangunan = !in_array(
|
$isTanahBangunan = !in_array(
|
||||||
strtoupper($jenisJaminan->name ?? ''),
|
strtoupper($jenisJaminan->name ?? ''),
|
||||||
['KAPAL', 'PESAWAT', 'KENDARAAN', 'ALAT BERAT']
|
['KAPAL', 'PESAWAT', 'KENDARAAN', 'ALAT BERAT']
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check if required forms are empty or incomplete
|
// Check if required forms are empty or incomplete
|
||||||
if (empty($dataForm) || empty($fotoForm)) {
|
if (empty($dataForm) || empty($fotoForm)) {
|
||||||
return response()->json(['buttonDisable' => true]);
|
return response()->json(['buttonDisable' => true]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($isTanahBangunan && empty($denahForm)) {
|
if ($isTanahBangunan && empty($denahForm)) {
|
||||||
return response()->json(['buttonDisable' => true]);
|
return response()->json(['buttonDisable' => true]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($dataPembanding)) {
|
if (empty($dataPembanding)) {
|
||||||
return response()->json(['buttonDisable' => true]);
|
return response()->json(['buttonDisable' => true]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we get here, all checks passed
|
// If we get here, all checks passed
|
||||||
return response()->json(['buttonDisable' => false]);
|
return response()->json(['buttonDisable' => false]);
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'error' => 'Something went wrong',
|
'error' => 'Something went wrong',
|
||||||
@@ -485,7 +487,7 @@ private function deleteOfFile($filePath)
|
|||||||
], 500);
|
], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -548,41 +550,141 @@ private function deleteOfFile($filePath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function storeDataPembanding(Request $request)
|
private function formatDataPembanding($request)
|
||||||
{
|
{
|
||||||
$data = $request->all();
|
$dataPembanding = [];
|
||||||
if (!$data) {
|
$pembandingCount = count($request->input('alamat_pembanding', []));
|
||||||
return response()->json(['success' => false, 'message' => 'Invalid data'], 400);
|
|
||||||
|
for ($i = 0; $i < $pembandingCount; $i++) {
|
||||||
|
$pembanding = $this->formatSinglePembanding($request, $i);
|
||||||
|
|
||||||
|
// Perbaikan penanganan foto pembanding
|
||||||
|
$fotoKey = "foto_objek_pembanding_{$i}"; // Sesuaikan dengan nama field di form
|
||||||
|
if ($request->hasFile($fotoKey)) {
|
||||||
|
$pembanding['foto_objek'] = $this->handleFileUpload(
|
||||||
|
$request->file($fotoKey),
|
||||||
|
'pembanding',
|
||||||
|
"pembanding_{$i}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$dataPembanding[] = $pembanding;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $dataPembanding;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function handleFileUpload($file, $folder, $prefix)
|
||||||
|
{
|
||||||
|
if (!$file) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Buat nama file yang unik
|
||||||
|
$extension = $file->getClientOriginalExtension();
|
||||||
|
$fileName = $prefix . '_' . time() . '_' . uniqid() . '.' . $extension;
|
||||||
|
|
||||||
|
// Pastikan folder exists
|
||||||
|
$path = storage_path("app/public/{$folder}");
|
||||||
|
if (!File::exists($path)) {
|
||||||
|
File::makeDirectory($path, 0777, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Simpan file
|
||||||
|
$file->storeAs("public/{$folder}", $fileName);
|
||||||
|
|
||||||
|
// Log untuk debugging
|
||||||
|
\Log::info("File berhasil disimpan: {$folder}/{$fileName}");
|
||||||
|
|
||||||
|
return $fileName;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
\Log::error("Error saat upload file: " . $e->getMessage());
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function formatSinglePembanding($request, $index)
|
||||||
|
{
|
||||||
|
$fields = [
|
||||||
|
'alamat', 'desa', 'kecamatan', 'kabupaten', 'provinsi',
|
||||||
|
'tahun', 'luas_tanah', 'luas_bangunan', 'tahun_bangunan',
|
||||||
|
'status_nara_sumber', 'harga', 'nama_nara_sumber',
|
||||||
|
'peruntukan', 'penawaran_transaksi', 'nomor_tlp',
|
||||||
|
'kordinat_lat', 'kordinat_lng', 'jenis_aset',
|
||||||
|
];
|
||||||
|
|
||||||
|
$pembanding = [];
|
||||||
|
foreach ($fields as $field) {
|
||||||
|
$inputName = "{$field}_pembanding";
|
||||||
|
$pembanding[$field] = $request->input($inputName)[$index] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inisialisasi foto_objek sebagai null
|
||||||
|
$pembanding['foto_objek'] = null;
|
||||||
|
|
||||||
|
return $pembanding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeDataPembanding(Request $request)
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
|
||||||
// $action = $request->input('type');
|
$validator = $request->validate([
|
||||||
// $rules = $this->getActionSpecificRules($data, $action, $request);
|
'permohonan_id' => 'required|exists:permohonan,id',
|
||||||
|
'type' => 'required|string',
|
||||||
|
'jenis_jaminan_id' => 'required',
|
||||||
|
'foto_objek' => 'nullable|image|max:2048',
|
||||||
|
'foto_objek_pembanding_*' => 'nullable|image|max:2048',
|
||||||
|
]);
|
||||||
|
|
||||||
$inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))->where('jenis_jaminan_id', $request->input('jenis_jaminan_id'))->first();
|
if ($validator->fails()) {
|
||||||
|
return response()->json([
|
||||||
if (!$inspeksi) {
|
'success' => false,
|
||||||
Inspeksi::create([
|
'message' => 'Validasi gagal',
|
||||||
'permohonan_id' => $request->input('permohonan_id'),
|
'errors' => $validator->errors()
|
||||||
'data_pembanding' => json_encode($data),
|
], 422);
|
||||||
'name' => $request->input('type'),
|
|
||||||
'jenis_jaminan_id' => $request->input('jenis_jaminan_id'),
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
$inspeksi->update(['data_pembanding' => json_encode($data)]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$objekPenilaian = $this->formatObjekPenilaian($request);
|
||||||
|
if ($request->hasFile('foto_objek')) {
|
||||||
|
$objekPenilaian['foto_objek'] = $this->handleFileUpload(
|
||||||
|
$request->file('foto_objek'),
|
||||||
|
'pembanding',
|
||||||
|
'objek_penilaian'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$formattedData = [
|
||||||
|
'permohonan_id' => $request->input('permohonan_id'),
|
||||||
|
'type' => $request->input('type'),
|
||||||
|
'jenis_jaminan_id' => $request->input('jenis_jaminan_id'),
|
||||||
|
'objek_penilaian' => $objekPenilaian,
|
||||||
|
'data_pembanding' => $this->formatDataPembanding($request)
|
||||||
|
];
|
||||||
|
|
||||||
|
$inspeksi = $this->saveInspeksi($formattedData);
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response()->json(['success' => true, 'message' => 'Data saved successfully', 'data' => json_encode($data)], 200);
|
return response()->json([
|
||||||
} catch (Exception $e) {
|
'success' => true,
|
||||||
|
'message' => 'Data berhasil disimpan',
|
||||||
|
'data' => $formattedData
|
||||||
|
], 200);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
return response()->json(['success' => false, 'message' => 'Failed to save data: ' . $e->getMessage()], 500);
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Gagal menyimpan data: ' . $e->getMessage()
|
||||||
|
], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form inspeksi.
|
* Form inspeksi.
|
||||||
*/
|
*/
|
||||||
@@ -737,8 +839,9 @@ private function deleteOfFile($filePath)
|
|||||||
|
|
||||||
public function dataPembanding($id, $jaminanId)
|
public function dataPembanding($id, $jaminanId)
|
||||||
{
|
{
|
||||||
$permohonan = Permohonan::with(
|
try {
|
||||||
[
|
// Ambil data permohonan dengan eager loading
|
||||||
|
$permohonan = Permohonan::with([
|
||||||
'user',
|
'user',
|
||||||
'debiture.province',
|
'debiture.province',
|
||||||
'debiture.city',
|
'debiture.city',
|
||||||
@@ -747,28 +850,65 @@ private function deleteOfFile($filePath)
|
|||||||
'branch',
|
'branch',
|
||||||
'tujuanPenilaian',
|
'tujuanPenilaian',
|
||||||
'penilaian'
|
'penilaian'
|
||||||
],
|
])->findOrFail($id);
|
||||||
)->findOrFail($id);
|
|
||||||
$surveyor = $id;
|
|
||||||
$branches = Branch::all();
|
|
||||||
$provinces = Province::all();
|
|
||||||
|
|
||||||
$data = $this->getCommonData();
|
// Ambil data inspeksi
|
||||||
|
$inspeksi = Inspeksi::where([
|
||||||
|
'permohonan_id' => $id,
|
||||||
|
'jenis_jaminan_id' => $jaminanId
|
||||||
|
])->first();
|
||||||
|
|
||||||
$inpeksi = Inspeksi::where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first();
|
// Inisialisasi variabel
|
||||||
$forminspeksi = null;
|
$inspectionData = null;
|
||||||
if ($inpeksi) {
|
$comparisons = null;
|
||||||
$forminspeksi = $inpeksi;
|
$fotoForm = null;
|
||||||
// $forminspeksi = json_decode($inpeksi->data_form, true);
|
|
||||||
|
|
||||||
|
if ($inspeksi) {
|
||||||
|
|
||||||
|
$inspectionData = json_decode($inspeksi->data_form, true);
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
throw new \Exception('Error decoding inspection data: ' . json_last_error_msg());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($inspeksi->data_pembanding) {
|
||||||
|
$comparisons = json_decode($inspeksi->data_pembanding, true);
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
throw new \Exception('Error decoding comparison data: ' . json_last_error_msg());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
$fotoForm = json_decode($inspeksi->foto_form, true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ambil data pendukung
|
||||||
|
$data = $this->getCommonData();
|
||||||
|
$branches = Branch::all();
|
||||||
|
$provinces = Province::all();
|
||||||
|
|
||||||
|
return view('lpj::surveyor.components.data-pembanding', compact(
|
||||||
|
'permohonan',
|
||||||
|
'id',
|
||||||
|
'branches',
|
||||||
|
'provinces',
|
||||||
|
'inspectionData',
|
||||||
|
'comparisons',
|
||||||
|
'data',
|
||||||
|
'jaminanId',
|
||||||
|
'fotoForm'
|
||||||
|
));
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return redirect()
|
||||||
|
->back()
|
||||||
|
->with('error', 'Terjadi kesalahan saat memuat data: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// return response()->json($forminspeksi);
|
|
||||||
return view('lpj::surveyor.components.data-pembanding', compact('permohonan', 'surveyor', 'branches', 'provinces', 'forminspeksi', 'data'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private function getHeader(string $type): array
|
private function getHeader(string $type): array
|
||||||
{
|
{
|
||||||
return self::HEADERS[$type] ?? [];
|
return self::HEADERS[$type] ?? [];
|
||||||
@@ -1338,14 +1478,14 @@ private function deleteOfFile($filePath)
|
|||||||
$data,
|
$data,
|
||||||
'hub_cadeb',
|
'hub_cadeb',
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
'hub_cadeb_penghuni' => [
|
'hub_cadeb_penghuni' => [
|
||||||
$data['hub_cadeb_penghuni'] => $this->getFieldData(
|
$data['hub_cadeb_penghuni'] => $this->getFieldData(
|
||||||
$data,
|
$data,
|
||||||
'hub_cadeb_penghuni',
|
'hub_cadeb_penghuni',
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|
||||||
'kordinat_lng' => $data['kordinat_lng'] ?? null,
|
'kordinat_lng' => $data['kordinat_lng'] ?? null,
|
||||||
@@ -1407,23 +1547,23 @@ private function deleteOfFile($filePath)
|
|||||||
$data = $request->all();
|
$data = $request->all();
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
foreach ($data['nama_bagunan'] as $index => $bangunan) {
|
// foreach ($data['nama_bangunan'] as $index => $bangunan) {
|
||||||
$bangunanData = [
|
// $bangunanData = [
|
||||||
'bangunan' => $bangunan,
|
// 'bangunan' => $bangunan,
|
||||||
'kategori' => []
|
// 'kategori' => []
|
||||||
];
|
// ];
|
||||||
|
|
||||||
foreach ($data['spek_kategori_bangunan'] as $kategoriIndex => $kategori) {
|
// foreach ($data['spek_kategori_bangunan'] as $kategoriIndex => $kategori) {
|
||||||
if (isset($data['spek_bangunan'][$kategori])) {
|
// if (isset($data['spek_bangunan'][$kategori])) {
|
||||||
$bangunanData['kategori'][] = [
|
// $bangunanData['kategori'][] = [
|
||||||
'kategori' => $kategori,
|
// 'kategori' => $kategori,
|
||||||
'spesifikasi' => $data['spek_bangunan'][$kategori]
|
// 'spesifikasi' => $data['spek_bangunan'][$kategori]
|
||||||
];
|
// ];
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
$result[] = $bangunanData;
|
// $result[] = $bangunanData;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'bangunan' => [
|
'bangunan' => [
|
||||||
@@ -1459,7 +1599,10 @@ private function deleteOfFile($filePath)
|
|||||||
'gol_mas_sekitar' => $data['gol_mas_sekitar'] ?? null,
|
'gol_mas_sekitar' => $data['gol_mas_sekitar'] ?? null,
|
||||||
'tingkat_keramaian' => $data['tingkat_keramaian'] ?? null,
|
'tingkat_keramaian' => $data['tingkat_keramaian'] ?? null,
|
||||||
'terletak_diarea' => $data['terletak_diarea'] ?? null,
|
'terletak_diarea' => $data['terletak_diarea'] ?? null,
|
||||||
'disekitar_lokasi' => $data['disekitar_lokasi'] ?? null,
|
'disekitar_lokasi' => $data['disekitar_lokasi'] === 'yes' ? [
|
||||||
|
'kondisi' => $data['kondisi_bagunan_disekitar_lokasi'] ?? null,
|
||||||
|
'sifat' => $data['sifat_bagunan_disekitar_lokasi'] ?? null,
|
||||||
|
] : $data['disekitar_lokasi'],
|
||||||
'kondisi_bangunan_sekitar' => $data['kondisi_bangunan_sekitar'] ?? null,
|
'kondisi_bangunan_sekitar' => $data['kondisi_bangunan_sekitar'] ?? null,
|
||||||
'sifat_bangunan_sekitar' => $data['sifat_bangunan_sekitar'] ?? null,
|
'sifat_bangunan_sekitar' => $data['sifat_bangunan_sekitar'] ?? null,
|
||||||
'dekat_makam' => $data['dekat_makam'] ?? null,
|
'dekat_makam' => $data['dekat_makam'] ?? null,
|
||||||
@@ -1917,7 +2060,6 @@ private function deleteOfFile($filePath)
|
|||||||
'luas_unit',
|
'luas_unit',
|
||||||
true
|
true
|
||||||
),
|
),
|
||||||
'jenis_unit' => $data['jenis_unit'] ?? null,
|
|
||||||
'kondisi_unit' => $data['kondisi_unit'] ?? null,
|
'kondisi_unit' => $data['kondisi_unit'] ?? null,
|
||||||
'posisi_unit' => $data['posisi_unit'] ?? null,
|
'posisi_unit' => $data['posisi_unit'] ?? null,
|
||||||
'lantai' => $data['lantai'] ?? null,
|
'lantai' => $data['lantai'] ?? null,
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class FormSurveyorRequest extends FormRequest
|
|||||||
'kondisi_bangunan' => 'nullable',
|
'kondisi_bangunan' => 'nullable',
|
||||||
'sifat_bangunan' => 'required|array',
|
'sifat_bangunan' => 'required|array',
|
||||||
'sifat_bangunan_input' => 'nullable|array',
|
'sifat_bangunan_input' => 'nullable|array',
|
||||||
'nama_bagunan' => 'required',
|
'nama_bagunan' => 'required|nullable',
|
||||||
'spek_kategori_bangunan.*' => 'required',
|
'spek_kategori_bangunan.*' => 'required',
|
||||||
'spek_bangunan.*' => 'required',
|
'spek_bangunan.*' => 'required',
|
||||||
'sarana_pelengkap' => 'required',
|
'sarana_pelengkap' => 'required',
|
||||||
@@ -122,7 +122,6 @@ class FormSurveyorRequest extends FormRequest
|
|||||||
'luas_unit' => 'required',
|
'luas_unit' => 'required',
|
||||||
'luas_unit_sesuai' => 'nullable',
|
'luas_unit_sesuai' => 'nullable',
|
||||||
'luas_unit_tidak_sesuai' => 'nullable',
|
'luas_unit_tidak_sesuai' => 'nullable',
|
||||||
'jenis_unit' => 'required|array',
|
|
||||||
'kondisi_unit' => 'required|array',
|
'kondisi_unit' => 'required|array',
|
||||||
'posisi_unit' => 'required|array',
|
'posisi_unit' => 'required|array',
|
||||||
'lantai' => 'required|array',
|
'lantai' => 'required|array',
|
||||||
@@ -150,8 +149,8 @@ class FormSurveyorRequest extends FormRequest
|
|||||||
'tingkat_keramaian' => 'nullable',
|
'tingkat_keramaian' => 'nullable',
|
||||||
'terletak_diarea' => 'nullable',
|
'terletak_diarea' => 'nullable',
|
||||||
'disekitar_lokasi' => 'nullable',
|
'disekitar_lokasi' => 'nullable',
|
||||||
'kondisi_bangunan_sekitar' => 'nullable',
|
'kondisi_bagunan_disekitar_lokasi' => 'nullable',
|
||||||
'sifat_bangunan_sekitar' => 'nullable',
|
'sifat_bagunan_disekitar_lokasi' => 'nullable',
|
||||||
'dekat_makam' => 'nullable',
|
'dekat_makam' => 'nullable',
|
||||||
'jarak_makam' => 'nullable',
|
'jarak_makam' => 'nullable',
|
||||||
'nama_makam' => 'nullable',
|
'nama_makam' => 'nullable',
|
||||||
@@ -521,7 +520,7 @@ class FormSurveyorRequest extends FormRequest
|
|||||||
'jenis_asset_tidak_sesuai' => 'nullable',
|
'jenis_asset_tidak_sesuai' => 'nullable',
|
||||||
'alamat_sesuai' => 'required',
|
'alamat_sesuai' => 'required',
|
||||||
'alamat_tidak_sesuai' => 'nullable',
|
'alamat_tidak_sesuai' => 'nullable',
|
||||||
|
|
||||||
'hub_cadeb' => 'required',
|
'hub_cadeb' => 'required',
|
||||||
'hub_cadeb_sesuai' => 'nullable',
|
'hub_cadeb_sesuai' => 'nullable',
|
||||||
'hub_cadeb_tidak_sesuai' => 'nullable',
|
'hub_cadeb_tidak_sesuai' => 'nullable',
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class Inspeksi extends Model
|
|||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*/
|
*/
|
||||||
protected $fillable = ['data_form', 'foto_form', 'denah_form','permohonan_id', 'name', 'status', 'authorized_status', 'authorized_at', 'authorized_by', 'created_by', 'updated_by', 'deleted_by','jenis_jaminan_id'];
|
protected $fillable = ['data_form', 'foto_form', 'denah_form','permohonan_id', 'name', 'status', 'authorized_status', 'authorized_at', 'authorized_by', 'created_by', 'updated_by', 'deleted_by','jenis_jaminan_id','data_pembanding'];
|
||||||
|
|
||||||
public function permohonan()
|
public function permohonan()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,4 +23,8 @@ class Regions extends Model
|
|||||||
public function teams(){
|
public function teams(){
|
||||||
return $this->hasMany(Teams::class, 'regions_id', 'id');
|
return $this->hasMany(Teams::class, 'regions_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function penilaiTeam(){
|
||||||
|
return $this->hasMany(PenilaianTeam::class, 'team_id', 'id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,13 +51,12 @@
|
|||||||
@php
|
@php
|
||||||
|
|
||||||
$sortedTeamsActivity = $teamsActivity->sortBy(function ($item) {
|
$sortedTeamsActivity = $teamsActivity->sortBy(function ($item) {
|
||||||
return $item->team->penilaianTeam
|
return $item->team->regions->penilaiTeam
|
||||||
->filter(function ($penilaianTeam) use ($item) {
|
->filter(function ($penilaiTeam) use ($item) {
|
||||||
return $penilaianTeam->user_id == $item->user->id;
|
return $penilaiTeam->user_id == $item->user->id;
|
||||||
})
|
})
|
||||||
->count();
|
->count();
|
||||||
});
|
});
|
||||||
|
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
@foreach ($sortedTeamsActivity as $index => $item)
|
@foreach ($sortedTeamsActivity as $index => $item)
|
||||||
@@ -75,9 +74,9 @@
|
|||||||
<th class="min-w-[150px]">
|
<th class="min-w-[150px]">
|
||||||
<span class="text-base text-gray-900 font-normal">
|
<span class="text-base text-gray-900 font-normal">
|
||||||
@php
|
@php
|
||||||
$totalTasks = $item->team->penilaianTeam
|
$totalTasks = $item->team->regions->penilaiTeam
|
||||||
->filter(function ($penilaianTeam) use ($item) {
|
->filter(function ($penilaiTeam) use ($item) {
|
||||||
return $penilaianTeam->user_id == $item->user->id;
|
return $penilaiTeam->user_id == $item->user->id;
|
||||||
})
|
})
|
||||||
->count();
|
->count();
|
||||||
@endphp
|
@endphp
|
||||||
@@ -208,7 +207,7 @@
|
|||||||
tanggal_kunjungan: {
|
tanggal_kunjungan: {
|
||||||
title: 'Tgl Kunjungan',
|
title: 'Tgl Kunjungan',
|
||||||
render: (item, data) =>
|
render: (item, data) =>
|
||||||
`${formatDateFromISO(data.tanggal_kunjungan) || ''}`,
|
`${formatDateFromISO(data.waktu_penilaian) || ''}`,
|
||||||
},
|
},
|
||||||
progress: {
|
progress: {
|
||||||
title: 'Progress',
|
title: 'Progress',
|
||||||
@@ -222,6 +221,7 @@
|
|||||||
return `${mulai.getDate()}-${mulai.getMonth() + 1}-${mulai.getFullYear()} - ${selesai.getDate()}-${selesai.getMonth() + 1}-${selesai.getFullYear()}`
|
return `${mulai.getDate()}-${mulai.getMonth() + 1}-${mulai.getFullYear()} - ${selesai.getDate()}-${selesai.getMonth() + 1}-${selesai.getFullYear()}`
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
paparan: {
|
paparan: {
|
||||||
title: 'Paparan',
|
title: 'Paparan',
|
||||||
render: (item, data) => `${data.paparan || ''}`,
|
render: (item, data) => `${data.paparan || ''}`,
|
||||||
|
|||||||
@@ -8,47 +8,52 @@
|
|||||||
<label class="form-label max-w-56">Luas Bagunan</label>
|
<label class="form-label max-w-56">Luas Bagunan</label>
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
|
|
||||||
@if (isset($permohonan->debiture->documents))
|
@if (isset($permohonan->debiture->documents))
|
||||||
@foreach ($permohonan->debiture->documents as $item)
|
@foreach ($permohonan->debiture->documents as $item)
|
||||||
@php
|
@php
|
||||||
$luas = $item->detail;
|
$luas = $item->detail;
|
||||||
$details = json_decode($luas[0]->details, true);
|
$details = json_decode($luas[0]->details, true);
|
||||||
$luas_bangunan = isset($details['luas_bangunan']) ? $details['luas_bangunan'] : 'N/A';
|
$luas_bangunan = isset($details['luas_bangunan']) ? $details['luas_bangunan'] : 'N/A';
|
||||||
@endphp
|
@endphp
|
||||||
<input type="hidden" name="luas_bangunan_sesuai" class="input" value="{{ $luas_bangunan }}">
|
<input type="hidden" name="luas_bangunan_sesuai" class="input" value="{{ $luas_bangunan }}">
|
||||||
<p class="text-2sm text-gray-700">{{ $luas_bangunan }} m<sup>2</sup></p>
|
<p class="text-2sm text-gray-700">{{ $luas_bangunan }} m<sup>2</sup></p>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
@endif
|
@endif
|
||||||
<div class="flex flex-wrap items-baseline w-full">
|
<div class="flex flex-wrap items-baseline w-full">
|
||||||
<div class="grid grid-cols-2 md:grid-cols-3 gap-4 mt-2">
|
<div class="grid grid-cols-2 md:grid-cols-3 gap-4 mt-2">
|
||||||
<label class="form-label flex items-center gap-3 text-nowrap">
|
<label class="form-label flex items-center gap-3 text-nowrap">
|
||||||
<input type="radio"
|
<input type="radio"
|
||||||
onclick="toggleFieldVisibility('luas_tanah_bagunan', 'luas_tanah_bagunan_tidak_sesuai', ['tidak sesuai'])"
|
onclick="toggleFieldVisibility('luas_tanah_bagunan', 'luas_tanah_bagunan_tidak_sesuai', ['tidak sesuai'])"
|
||||||
class="radio" name="luas_tanah_bagunan" value="sesuai"
|
class="radio" name="luas_tanah_bagunan" value="sesuai"
|
||||||
{{ old('luas_tanah_bagunan', $forminspeksi['bangunan']['luas_tanah_bagunan'] ?? '') == 'sesuai' ? 'checked' : '' }}>
|
{{ old('luas_tanah_bagunan', isset($forminspeksi['bangunan']['luas_tanah_bagunan']['sesuai'])) ? 'checked' : '' }}>
|
||||||
<span class="ml-2">Sesuai</span>
|
<span class="ml-2">Sesuai</span>
|
||||||
</label>
|
</label>
|
||||||
<label class="form-label flex items-center gap-2.5 text-nowrap">
|
<label class="form-label flex items-center gap-2.5 text-nowrap">
|
||||||
<input type="radio" class="radio" name="luas_tanah_bagunan"
|
<input type="radio" class="radio" name="luas_tanah_bagunan"
|
||||||
onclick="toggleFieldVisibility('luas_tanah_bagunan', 'luas_tanah_bagunan_tidak_sesuai', ['tidak sesuai'])"
|
onclick="toggleFieldVisibility('luas_tanah_bagunan', 'luas_tanah_bagunan_tidak_sesuai', ['tidak sesuai'])"
|
||||||
value="tidak sesuai"
|
value="tidak sesuai"
|
||||||
{{ old('luas_tanah_bagunan', $forminspeksi['bangunan']['luas_tanah_bagunan'] ?? '') == 'tidak sesuai' ? 'checked' : '' }}>
|
{{ old('luas_tanah_bagunan', isset($forminspeksi['bangunan']['luas_tanah_bagunan']['tidak sesuai'])) ? 'checked' : '' }}>
|
||||||
<span class="ml-2">Tidak Sesuai</span>
|
<span class="ml-2">Tidak Sesuai</span>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
<div id="luas_tanah_bagunan_tidak_sesuai" class="flex items-baseline gap-2"
|
||||||
|
style="{{ isset($forminspeksi['bangunan']['luas_tanah_bagunan']['tidak_sesuai']) ? '' : 'display: none;' }}">
|
||||||
|
<input type="text" id="analisa_bangunan_tidak_sesuai"
|
||||||
|
name="luas_tanah_bagunan_tidak_sesuai" class="input w-full"
|
||||||
|
placeholder="Masukan Luas Bangunan Tidak Sesuai..."
|
||||||
|
value="{{ old('luas_tanah_bagunan_tidak_sesuai', $forminspeksi['bangunan']['luas_tanah_bagunan']['tidak_sesuai'] ?? '') }}">
|
||||||
|
<button type="button" class="btn btn-md btn-primary"
|
||||||
|
onclick="updateAnalisa('analisa_bangunan')">
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="luas_tanah_bagunan_tidak_sesuai" class="flex items-baseline gap-2"
|
|
||||||
style="{{ old('luas_tanah_bagunan_bagunan', $forminspeksi['bangunan']['luas_tanah_bagunan_bagunan'] ?? '') == 'tidak sesuai' ? '' : 'display: none;' }}">
|
|
||||||
<input type="text"id="analisa_bangunan_tidak_sesuai" name="luas_tanah_bagunan_tidak_sesuai" class="input w-full"
|
|
||||||
placeholder="Masukan Luas Bangunan Tidak Sesuai..."
|
|
||||||
value="{{ old('luas_tanah_bagunan_tidak_sesuai', $forminspeksi['bangunan']['luas_tanah_bagunan_tidak_sesuai'] ?? '') }}">
|
|
||||||
<button type="button" class="btn btn-md btn-primary" onclick="updateAnalisa('analisa_bangunan')">Save</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
<em id="error-luas_tanah_bagunan" class="alert text-danger text-sm"></em>
|
||||||
</div>
|
</div>
|
||||||
<em id="error-luas_tanah_bagunan" class="alert text-danger text-sm"></em>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Jenis Bangunan -->
|
<!-- Jenis Bangunan -->
|
||||||
@@ -62,15 +67,14 @@
|
|||||||
<input class="checkbox" name="jenis_bangunan[]" type="checkbox"
|
<input class="checkbox" name="jenis_bangunan[]" type="checkbox"
|
||||||
value="{{ $item->name }}"
|
value="{{ $item->name }}"
|
||||||
{{ old('jenis_bangunan') == $item->name || isset($forminspeksi['bangunan']['jenis_bangunan']) == $item->name ? 'checked' : '' }}
|
{{ old('jenis_bangunan') == $item->name || isset($forminspeksi['bangunan']['jenis_bangunan']) == $item->name ? 'checked' : '' }}
|
||||||
onclick="toggleCheckboxVisibility('jenis_bangunan', 'jenis_bangunan_lainnya', ['lainnya'])"
|
onclick="toggleCheckboxVisibility('jenis_bangunan', 'jenis_bangunan_lainnya', ['lainnya'])" />
|
||||||
/>
|
|
||||||
{{ $item->name }}
|
{{ $item->name }}
|
||||||
</label>
|
</label>
|
||||||
@if (strcasecmp($item->name, 'Lainnya') == 0)
|
@if (strcasecmp($item->name, 'Lainnya') == 0)
|
||||||
<input id="jenis_bangunan_lainnya" type="text" style="display: none;"
|
<input id="jenis_bangunan_lainnya" type="text" style="display: none;"
|
||||||
name="jenis_bangunan_lainnya" class="input w-full mt-2"
|
name="jenis_bangunan_lainnya" class="input w-full mt-2"
|
||||||
placeholder="Masukkan lainnya..." />
|
placeholder="Masukkan lainnya..." />
|
||||||
@endif
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@@ -160,7 +164,7 @@
|
|||||||
@if ($spek->spek_kategori_bangunan_id == $item->id)
|
@if ($spek->spek_kategori_bangunan_id == $item->id)
|
||||||
<label class="form-label flex items-center gap-2.5">
|
<label class="form-label flex items-center gap-2.5">
|
||||||
<input class="checkbox"
|
<input class="checkbox"
|
||||||
name="spek_bangunan[{{ $item->name }}][]"
|
name="spek_bangunan[{{ $item->name }}][]"
|
||||||
type="checkbox" value="{{ $spek->name }}" />
|
type="checkbox" value="{{ $spek->name }}" />
|
||||||
{{ $spek->name }}
|
{{ $spek->name }}
|
||||||
</label>
|
</label>
|
||||||
@@ -196,16 +200,28 @@
|
|||||||
<div class="flex flex-col items-start gap-4">
|
<div class="flex flex-col items-start gap-4">
|
||||||
@if (isset($saranaPelengkap))
|
@if (isset($saranaPelengkap))
|
||||||
@foreach ($saranaPelengkap as $item)
|
@foreach ($saranaPelengkap as $item)
|
||||||
|
@php
|
||||||
|
$isChecked = false;
|
||||||
|
$inputValue = '';
|
||||||
|
|
||||||
|
if (isset($forminspeksi['bangunan']['sarana_pelengkap'])) {
|
||||||
|
foreach ($forminspeksi['bangunan']['sarana_pelengkap'] as $key => $value) {
|
||||||
|
if ($key === $item->name) {
|
||||||
|
$isChecked = true;
|
||||||
|
$inputValue = $value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@endphp
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||||
<label class="form-label max-w-56 gap-2.5" style="width: 500px">
|
<label class="form-label max-w-56 gap-2.5" style="width: 500px">
|
||||||
<input class="checkbox" name="sarana_pelengkap[]" type="checkbox"
|
<input class="checkbox" name="sarana_pelengkap[]" type="checkbox"
|
||||||
value="{{ $item->name }}"
|
value="{{ $item->name }}" {{ $isChecked ? 'checked' : '' }} />
|
||||||
{{ in_array($item->name, old('sarana_pelengkap', $forminspeksi['bangunan']['sarana_pelengkap'] ?? [])) ? 'checked' : '' }} />
|
|
||||||
{{ $item->name }}
|
{{ $item->name }}
|
||||||
</label>
|
</label>
|
||||||
<input type="text" name="sarana_pelengkap_input[]" class="input w-full"
|
<input type="text" name="sarana_pelengkap_input[]" class="input w-full"
|
||||||
id="bentukTanahInput" placeholder="Masukkan {{ $item->name }}..."
|
placeholder="Masukkan {{ $item->name }}..." value="{{ $inputValue }}">
|
||||||
value="{{ old('sarana_pelengkap_input.' . $loop->index, $forminspeksi['bangunan']['sarana_pelengkap_input'][$loop->index] ?? '') }}">
|
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
@endif
|
@endif
|
||||||
@@ -213,6 +229,7 @@
|
|||||||
<em id="error-sarana_pelengkap" class="alert text-danger text-sm"></em>
|
<em id="error-sarana_pelengkap" class="alert text-danger text-sm"></em>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
@php
|
@php
|
||||||
$jaminanId = $dokumen->jenisJaminan->id;
|
$jaminanId = $dokumen->jenisJaminan->id;
|
||||||
$currentInspeksi = $inspeksiData[$jaminanId] ?? null;
|
$currentInspeksi = $inspeksiData[$jaminanId] ?? null;
|
||||||
|
|
||||||
$tanahBangunanTypes = ['KAPAL', 'PESAWAT', 'KENDARAAN', 'ALAT BERAT'];
|
$tanahBangunanTypes = ['KAPAL', 'PESAWAT', 'KENDARAAN', 'ALAT BERAT'];
|
||||||
|
|
||||||
$href = [
|
$href = [
|
||||||
[
|
[
|
||||||
'label' => 'form inspeksi',
|
'label' => 'form inspeksi',
|
||||||
@@ -57,7 +57,14 @@
|
|||||||
<div class="card-group flex items-center flex-wrap sm:flex-nowrap justify-between py-4 gap-2.5">
|
<div class="card-group flex items-center flex-wrap sm:flex-nowrap justify-between py-4 gap-2.5">
|
||||||
<div class="flex items-center gap-3.5">
|
<div class="flex items-center gap-3.5">
|
||||||
<div class="relative size-[50px] shrink-0">
|
<div class="relative size-[50px] shrink-0">
|
||||||
<!-- SVG code remains the same -->
|
<svg class="w-full h-full stroke-brand-clarity fill-light" fill="none" height="48"
|
||||||
|
viewBox="0 0 44 48" width="44" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M16 2.4641C19.7128 0.320509 24.2872 0.320508 28 2.4641L37.6506 8.0359C41.3634 10.1795 43.6506 14.141 43.6506 18.4282V29.5718C43.6506 33.859 41.3634 37.8205 37.6506 39.9641L28 45.5359C24.2872 47.6795 19.7128 47.6795 16 45.5359L6.34937 39.9641C2.63655 37.8205 0.349365 33.859 0.349365 29.5718V18.4282C0.349365 14.141 2.63655 10.1795 6.34937 8.0359L16 2.4641Z" fill=""></path>
|
||||||
|
<path d="M16.25 2.89711C19.8081 0.842838 24.1919 0.842837 27.75 2.89711L37.4006 8.46891C40.9587 10.5232 43.1506 14.3196 43.1506 18.4282V29.5718C43.1506 33.6804 40.9587 37.4768 37.4006 39.5311L27.75 45.1029C24.1919 47.1572 19.8081 47.1572 16.25 45.1029L6.59937 39.5311C3.04125 37.4768 0.849365 33.6803 0.849365 29.5718V18.4282C0.849365 14.3196 3.04125 10.5232 6.59937 8.46891L16.25 2.89711Z" stroke=""></path>
|
||||||
|
</svg>
|
||||||
|
<div class="absolute leading-none left-2/4 top-2/4 -translate-y-2/4 -translate-x-2/4">
|
||||||
|
<i class="ki-filled ki-additem text-2xl text-brand"></i>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-2.5">
|
<div class="flex items-center gap-2.5">
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
|||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
@include('lpj::assetsku.includenya')
|
@include('lpj::assetsku.includenya')
|
||||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||||
<div class="card min-w-full">
|
<div class="card min-w-full">
|
||||||
<div class="card min-w-full">
|
<div class="card min-w-full">
|
||||||
@@ -142,7 +142,8 @@
|
|||||||
<div class="w-full grid gap-5">
|
<div class="w-full grid gap-5">
|
||||||
<img id="foto_denah-preview"
|
<img id="foto_denah-preview"
|
||||||
src="{{ isset($formDenah['foto_denah']) ? asset('storage/' . old('foto_denah', $formDenah['foto_denah'])) : '' }}"
|
src="{{ isset($formDenah['foto_denah']) ? asset('storage/' . old('foto_denah', $formDenah['foto_denah'])) : '' }}"
|
||||||
alt="Gambar foto_denah" style="{{ isset($formDenah['foto_denah']) ? 'width: 30rem;' : 'display: none;' }}">
|
alt="Gambar foto_denah"
|
||||||
|
style="{{ isset($formDenah['foto_denah']) ? 'width: 30rem;' : 'display: none;' }}">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -150,9 +151,7 @@
|
|||||||
<input type="file"
|
<input type="file"
|
||||||
value="{{ old('foto_denah', isset($formDenah['foto_denah']) ? $formDenah['foto_denah'] : '') }}"
|
value="{{ old('foto_denah', isset($formDenah['foto_denah']) ? $formDenah['foto_denah'] : '') }}"
|
||||||
name="foto_denah" class="file-input file-input-bordered w-full "
|
name="foto_denah" class="file-input file-input-bordered w-full "
|
||||||
accept="image/*"
|
accept="image/*" onchange="previewImage(this, 'foto_denah-preview')">
|
||||||
onchange="previewImage(this, 'foto_denah-preview')"
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -178,29 +177,32 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<em id="error-luas" class="alert text-danger text-sm"></em>
|
<em id="error-luas" class="alert text-danger text-sm"></em>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-end gap-2" style="margin-right: 20px; margin-top: 20px">
|
<div class="flex justify-end gap-2" style="margin-right: 20px; margin-top: 20px">
|
||||||
<button type="button" class="btn btn-success" id="saveButton" onclick="submitDenah()">
|
<button type="button" class="btn btn-success" id="saveButton" onclick="submitDenah()">
|
||||||
<span id="saveButtonText">Save</span>
|
<span id="saveButtonText">Save</span>
|
||||||
<div class="spinner-border spinner-border-sm text-light" role="status" style="display: none;"
|
|
||||||
id="saveButtonSpinner">
|
|
||||||
<span class="visually-hidden">Loading...</span>
|
|
||||||
</div>
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="loadingOverlay" class="fixed inset-0 bg-black bg-opacity-50 hidden items-center justify-center z-50">
|
||||||
|
<div class="bg-white p-4 rounded-lg">
|
||||||
|
<div class="loader"></div>
|
||||||
|
<p class="mt-2 text-center">Sedang memproses...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script>
|
<script>
|
||||||
function previewImage(input, previewId) {
|
function previewImage(input, previewId) {
|
||||||
if (input.files && input.files[0]) {
|
if (input.files && input.files[0]) {
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
reader.onload = function(e) {
|
reader.onload = function(e) {
|
||||||
@@ -213,15 +215,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function submitDenah() {
|
function submitDenah() {
|
||||||
|
const loadingOverlay = document.getElementById('loadingOverlay');
|
||||||
|
loadingOverlay.classList.remove('hidden');
|
||||||
|
loadingOverlay.classList.add('flex');
|
||||||
|
|
||||||
const formElement = $('#formDenah')[0];
|
const formElement = $('#formDenah')[0];
|
||||||
const formData = new FormData(formElement);
|
const formData = new FormData(formElement);
|
||||||
|
|
||||||
// Disable the button and show the spinner
|
|
||||||
$('#saveButton').prop('disabled', true);
|
|
||||||
$('#saveButtonText').hide();
|
|
||||||
$('#saveButtonSpinner').show();
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '{{ route('surveyor.storeDenah') }}',
|
url: '{{ route('surveyor.storeDenah') }}',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
@@ -233,9 +233,24 @@
|
|||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
window.location.href =
|
Swal.fire({
|
||||||
'{{ route('surveyor.show', ['id' => $permohonan->id]) }}?form=denah';
|
title: 'Berhasil!',
|
||||||
toastrSuccessBuild(response.message);
|
text: response.message,
|
||||||
|
icon: 'success',
|
||||||
|
confirmButtonText: 'OK'
|
||||||
|
}).then((response) => {
|
||||||
|
if (response.isConfirmed) {
|
||||||
|
window.location.href =
|
||||||
|
'{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Error!',
|
||||||
|
text: response.message || 'Terjadi kesalahan',
|
||||||
|
icon: 'error',
|
||||||
|
confirmButtonText: 'OK'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
console.log(response);
|
console.log(response);
|
||||||
},
|
},
|
||||||
@@ -255,13 +270,32 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
complete: function() {
|
complete: function() {
|
||||||
// Re-enable the button and hide the spinner
|
loadingOverlay.classList.add('hidden');
|
||||||
$('#saveButton').prop('disabled', false);
|
loadingOverlay.classList.remove('flex');
|
||||||
$('#saveButtonText').show();
|
|
||||||
$('#saveButtonSpinner').hide();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
<style>
|
||||||
|
.loader {
|
||||||
|
border: 4px solid #f3f3f3;
|
||||||
|
border-radius: 50%;
|
||||||
|
border-top: 4px solid #3498db;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
animation: spin 1s linear infinite;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
0% {
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -76,19 +76,32 @@
|
|||||||
<label class="form-label max-w-56">Batas batas</label>
|
<label class="form-label max-w-56">Batas batas</label>
|
||||||
<div class="flex flex-wrap items-baseline w-full">
|
<div class="flex flex-wrap items-baseline w-full">
|
||||||
<div class="grid grid-cols-1 gap-4 items-center w-full">
|
<div class="grid grid-cols-1 gap-4 items-center w-full">
|
||||||
|
|
||||||
@if (isset($arahMataAngin))
|
@if (isset($arahMataAngin))
|
||||||
@foreach ($arahMataAngin as $item)
|
@foreach ($arahMataAngin as $item)
|
||||||
|
@php
|
||||||
|
$isChecked = false;
|
||||||
|
$inputValue = '';
|
||||||
|
|
||||||
|
if (isset($forminspeksi['fakta']['batas_batas'])) {
|
||||||
|
foreach ($forminspeksi['fakta']['batas_batas'] as $key => $value) {
|
||||||
|
if ($key === $item->name) {
|
||||||
|
$isChecked = true;
|
||||||
|
$inputValue = $value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@endphp
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||||
<label class="form-label max-w-56 gap-2.5" style="width: 500px">
|
<label class="form-label max-w-56 gap-2.5" style="width: 500px">
|
||||||
<input class="checkbox" name="batas_batas[]" type="checkbox"
|
<input class="checkbox" name="batas_batas[]" type="checkbox"
|
||||||
value="{{ $item->name }}"
|
value="{{ $item->name }}"
|
||||||
{{ in_array($item->name, old('batas_batas', $forminspeksi['fakta']['batas_batas'] ?? [])) ? 'checked' : '' }} />
|
{{ $isChecked ? 'checked' : '' }} />
|
||||||
{{ $item->name }}
|
{{ $item->name }}
|
||||||
</label>
|
</label>
|
||||||
<input type="text" name="batas_batas_input[]" class="input w-full"
|
<input type="text" name="batas_batas_input[]" class="input w-full"
|
||||||
id="bentukTanahInput" placeholder="Masukkan Batas {{ $item->name }}..."
|
placeholder="Masukkan Batas {{ $item->name }}..."
|
||||||
value="{{ old('batas_batas_input.' . $loop->index, $forminspeksi['fakta']['batas_batas_input'][$loop->index] ?? '') }}">
|
value="{{ $inputValue }}">
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
@endif
|
@endif
|
||||||
@@ -98,6 +111,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||||
<label class="form-label max-w-56">Kondisi lain terkait lingkungan</label>
|
<label class="form-label max-w-56">Kondisi lain terkait lingkungan</label>
|
||||||
<div class="flex flex-wrap items-baseline w-full" id="kondisi-lingkungan-container">
|
<div class="flex flex-wrap items-baseline w-full" id="kondisi-lingkungan-container">
|
||||||
|
|||||||
@@ -585,8 +585,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
|
<div id="loadingOverlay" class="fixed inset-0 bg-black bg-opacity-50 hidden items-center justify-center z-50">
|
||||||
|
<div class="bg-white p-4 rounded-lg">
|
||||||
|
<div class="loader"></div>
|
||||||
|
<p class="mt-2 text-center">Sedang memproses...</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Modal Kamera -->
|
<!-- Modal Kamera -->
|
||||||
@@ -598,17 +602,16 @@
|
|||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script>
|
<script>
|
||||||
function submitFoto() {
|
function submitFoto() {
|
||||||
|
const loadingOverlay = document.getElementById('loadingOverlay');
|
||||||
|
loadingOverlay.classList.remove('hidden');
|
||||||
|
loadingOverlay.classList.add('flex');
|
||||||
|
|
||||||
const formElement = $('#formFoto')[0];
|
const formElement = $('#formFoto')[0];
|
||||||
const formData = new FormData(formElement);
|
const formData = new FormData(formElement);
|
||||||
// for (const [key, value] of formData.entries()) {
|
// for (const [key, value] of formData.entries()) {
|
||||||
// console.log(`Key: ${key}, Value: ${value}`);
|
// console.log(`Key: ${key}, Value: ${value}`);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Disable the button and show the spinner
|
|
||||||
$('#saveButtonFoto').prop('disabled', true);
|
|
||||||
$('#saveButtonFotoText').hide();
|
|
||||||
$('#saveButtonSpinner').show();
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '{{ route('surveyor.storeFoto') }}',
|
url: '{{ route('surveyor.storeFoto') }}',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
@@ -621,12 +624,27 @@
|
|||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
// window.location.href =
|
Swal.fire({
|
||||||
// '{{ route('surveyor.show', ['id' => $permohonan->id]) }}?form=foto';
|
title: 'Berhasil!',
|
||||||
toastrSuccessBuild(response.message);
|
text: response.message,
|
||||||
|
icon: 'success',
|
||||||
|
confirmButtonText: 'OK'
|
||||||
|
}).then((response) => {
|
||||||
|
if (response.isConfirmed) {
|
||||||
|
window.location.href =
|
||||||
|
'{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Error!',
|
||||||
|
text: response.message || 'Terjadi kesalahan',
|
||||||
|
icon: 'error',
|
||||||
|
confirmButtonText: 'OK'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
console.log(response);
|
console.log(response);
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
error: function(xhr, status, error) {
|
error: function(xhr, status, error) {
|
||||||
@@ -645,9 +663,8 @@
|
|||||||
},
|
},
|
||||||
complete: function() {
|
complete: function() {
|
||||||
// Re-enable the button and hide the spinner
|
// Re-enable the button and hide the spinner
|
||||||
$('#saveButtonFoto').prop('disabled', false);
|
loadingOverlay.classList.add('hidden');
|
||||||
$('#saveButtonFotoText').show();
|
loadingOverlay.classList.remove('flex');
|
||||||
$('#saveButtonSpinner').hide();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -655,6 +672,28 @@
|
|||||||
@include('lpj::surveyor.js.camera-editor')
|
@include('lpj::surveyor.js.camera-editor')
|
||||||
@endpush
|
@endpush
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.loader {
|
||||||
|
border: 4px solid #f3f3f3;
|
||||||
|
border-radius: 50%;
|
||||||
|
border-top: 4px solid #3498db;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
animation: spin 1s linear infinite;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
0% {
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -37,12 +37,20 @@
|
|||||||
<span id="saveButtonText">Save</span>
|
<span id="saveButtonText">Save</span>
|
||||||
<div class="spinner-border spinner-border-sm text-light" role="status" style="display: none;"
|
<div class="spinner-border spinner-border-sm text-light" role="status" style="display: none;"
|
||||||
id="saveButtonSpinner">
|
id="saveButtonSpinner">
|
||||||
<span class="visually-hidden">Loading...</span>
|
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Loading Overlay -->
|
||||||
|
<div id="loadingOverlay" class="fixed inset-0 bg-black bg-opacity-50 hidden items-center justify-center z-50">
|
||||||
|
<div class="bg-white p-4 rounded-lg">
|
||||||
|
<div class="loader"></div>
|
||||||
|
<p class="mt-2 text-center">Sedang memproses...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@@ -118,14 +126,14 @@
|
|||||||
|
|
||||||
|
|
||||||
function submitData() {
|
function submitData() {
|
||||||
|
|
||||||
|
const loadingOverlay = document.getElementById('loadingOverlay');
|
||||||
|
loadingOverlay.classList.remove('hidden');
|
||||||
|
loadingOverlay.classList.add('flex');
|
||||||
|
|
||||||
const formElement = $('#formInspeksi')[0];
|
const formElement = $('#formInspeksi')[0];
|
||||||
const formData = new FormData(formElement);
|
const formData = new FormData(formElement);
|
||||||
|
|
||||||
// Disable the button and show the spinner
|
|
||||||
$('#saveButton').prop('disabled', true);
|
|
||||||
$('#saveButtonText').hide();
|
|
||||||
$('#saveButtonSpinner').show();
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '{{ route('surveyor.store') }}',
|
url: '{{ route('surveyor.store') }}',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
@@ -136,12 +144,26 @@
|
|||||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
// if (response.success) {
|
if (response.success) {
|
||||||
// toastrSuccessBuild(response.message)
|
Swal.fire({
|
||||||
// window.location.href =
|
title: 'Berhasil!',
|
||||||
// '{{ route('surveyor.show', ['id' => $permohonan->id]) }}?form=inspeksi';
|
text: response.message,
|
||||||
// }
|
icon: 'success',
|
||||||
|
confirmButtonText: 'OK'
|
||||||
|
}).then((response) => {
|
||||||
|
if (response.isConfirmed) {
|
||||||
|
window.location.href =
|
||||||
|
'{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Error!',
|
||||||
|
text: response.message || 'Terjadi kesalahan',
|
||||||
|
icon: 'error',
|
||||||
|
confirmButtonText: 'OK'
|
||||||
|
});
|
||||||
|
}
|
||||||
console.log(response);
|
console.log(response);
|
||||||
},
|
},
|
||||||
error: function(xhr, status, error) {
|
error: function(xhr, status, error) {
|
||||||
@@ -160,9 +182,8 @@
|
|||||||
},
|
},
|
||||||
complete: function() {
|
complete: function() {
|
||||||
// Re-enable the button and hide the spinner
|
// Re-enable the button and hide the spinner
|
||||||
$('#saveButton').prop('disabled', false);
|
loadingOverlay.classList.add('hidden');
|
||||||
$('#saveButtonText').show();
|
loadingOverlay.classList.remove('flex');
|
||||||
$('#saveButtonSpinner').hide();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -239,10 +260,9 @@
|
|||||||
success: function(response) {
|
success: function(response) {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
if (response.jenis_asset) {
|
window.location.href =
|
||||||
window.location.href =
|
'{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
|
||||||
'{{ route('surveyor.show', ['id' => $permohonan->id]) }}?form=inspeksi';
|
|
||||||
}
|
|
||||||
toastrSuccessBuild(response.message);
|
toastrSuccessBuild(response.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -260,3 +280,34 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.loader {
|
||||||
|
border: 4px solid #f3f3f3;
|
||||||
|
border-radius: 50%;
|
||||||
|
border-top: 4px solid #3498db;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
animation: spin 1s linear infinite;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
0% {
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.scrollable-x-auto {
|
||||||
|
overflow-x: auto;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table {
|
||||||
|
min-width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -169,25 +169,38 @@
|
|||||||
<span class="ml-2">Telah ada bangunan</span>
|
<span class="ml-2">Telah ada bangunan</span>
|
||||||
</label>
|
</label>
|
||||||
<div class="flex w-full items-center gap-4">
|
<div class="flex w-full items-center gap-4">
|
||||||
|
|
||||||
<div id="disekitar_lokasi_sesuai" class="grid grid-cols-2 gap-4 mt-5 mb-5"
|
<div id="disekitar_lokasi_sesuai" class="grid grid-cols-2 gap-4 mt-5 mb-5"
|
||||||
style="display: none;">
|
style="{{ old('disekitar_lokasi', $forminspeksi['lingkungan']['disekitar_lokasi'] ?? '') == 'ya' ? '' : 'display: none;' }}">
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<label for="" class="text-sm text-gray-700">Kondisi bangunan</label>
|
<label for="" class="text-sm text-gray-700">Kondisi bangunan</label>
|
||||||
|
|
||||||
|
@php
|
||||||
|
$kondisi = ['Cukup', 'Baik', 'Kurang'];
|
||||||
|
@endphp
|
||||||
|
|
||||||
<select class="select" name="kondisi_bagunan_disekitar_lokasi" id="">
|
<select class="select" name="kondisi_bagunan_disekitar_lokasi" id="">
|
||||||
<option value="">pilih kondisi</option>
|
<option value="">pilih kondisi</option>
|
||||||
<option value="Cukup">Cukup</option>
|
@foreach ($kondisi as $item)
|
||||||
<option value="Baik">Baik</option>
|
<option value="{{ $item }}"
|
||||||
<option value="Kurang">Kurang</option>
|
{{ old('kondisi_bagunan_disekitar_lokasi', $forminspeksi['lingkungan']['disekitar_lokasi'] ?? '') == $item ? 'selected' : '' }}>
|
||||||
|
{{ $item }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<label for="" class="text-sm text-gray-700">Sifat bangunan</label>
|
<label for="" class="text-sm text-gray-700">Sifat bangunan</label>
|
||||||
|
@php
|
||||||
|
$sifat = ['Permanen', 'Semi Permanen', 'Tidak Permanen'];
|
||||||
|
@endphp
|
||||||
<select class="select" name="sifat_bagunan_disekitar_lokasi" id="">
|
<select class="select" name="sifat_bagunan_disekitar_lokasi" id="">
|
||||||
<option value="">pilih sifat bagunan</option>
|
<option value="">pilih sifat bagunan</option>
|
||||||
<option value="Permanen">Permanen</option>
|
@foreach ($sifat as $item)
|
||||||
<option value="Semi Permanen">Semi Permanen</option>
|
<option value="{{ $item }}"
|
||||||
<option value="Tidak Permanen">Tidak Permanen</option>
|
{{ old('sifat_bagunan_disekitar_lokasi', $forminspeksi['lingkungan']['disekitar_lokasi'] ?? '') == $item ? 'selected' : '' }}>
|
||||||
|
{{ $item }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
style="{{ old('luas_tanah', isset($forminspeksi['tanah']['luas_tanah']['tidak sesuai'])) ? '' : 'display: none;' }}">
|
style="{{ old('luas_tanah', isset($forminspeksi['tanah']['luas_tanah']['tidak sesuai'])) ? '' : 'display: none;' }}">
|
||||||
<input id="analisa_tanah_tidak_sesuai" type="text" name="luas_tanah_tidak_sesuai"
|
<input id="analisa_tanah_tidak_sesuai" type="text" name="luas_tanah_tidak_sesuai"
|
||||||
class="input w-full" placeholder="Masukan Luas Tanah"
|
class="input w-full" placeholder="Masukan Luas Tanah"
|
||||||
value="{{ old('luas_tanah_tidak_sesuai', $forminspeksi['tanah']['luas_tanah_tidak_sesuai'] ?? '') }}">
|
value="{{ old('luas_tanah_tidak_sesuai', $forminspeksi['tanah']['luas_tanah']['tidak sesuai'] ?? '') }}">
|
||||||
<button type="button" class="btn btn-md btn-primary"
|
<button type="button" class="btn btn-md btn-primary"
|
||||||
onclick="updateAnalisa('analisa_tanah')">Save</button>
|
onclick="updateAnalisa('analisa_tanah')">Save</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -85,6 +85,7 @@
|
|||||||
</label>
|
</label>
|
||||||
|
|
||||||
<!-- Select dropdown untuk "Tidak Sesuai" -->
|
<!-- Select dropdown untuk "Tidak Sesuai" -->
|
||||||
|
|
||||||
<div id="hadap_mata_angin_tidak_sesuai" class="flex items-baseline gap-2"
|
<div id="hadap_mata_angin_tidak_sesuai" class="flex items-baseline gap-2"
|
||||||
style="{{ old('hadap_mata_angin', isset($forminspeksi['tanah']['hadap_mata_angin']['tidak sesuai'])) ? '' : 'display: none;' }}">
|
style="{{ old('hadap_mata_angin', isset($forminspeksi['tanah']['hadap_mata_angin']['tidak sesuai'])) ? '' : 'display: none;' }}">
|
||||||
<select class="input w-full
|
<select class="input w-full
|
||||||
@@ -94,7 +95,7 @@
|
|||||||
@if (isset($arahMataAngin))
|
@if (isset($arahMataAngin))
|
||||||
@foreach ($arahMataAngin as $item)
|
@foreach ($arahMataAngin as $item)
|
||||||
<option value="{{ $item->name }}"
|
<option value="{{ $item->name }}"
|
||||||
{{ old('hadap_mata_angin_tidak_sesuai', $forminspeksi['tanah']['hadap_mata_angin_tidak_sesuai'] ?? '') == $item->name ? 'selected' : '' }}>
|
{{ old('hadap_mata_angin_tidak_sesuai', $forminspeksi['tanah']['hadap_mata_angin']['tidak sesuai'] ?? '') == $item->name ? 'selected' : '' }}>
|
||||||
{{ $item->name }}
|
{{ $item->name }}
|
||||||
</option>
|
</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
@@ -233,14 +234,14 @@
|
|||||||
<label class="form-label flex items-center gap-2.5 text-nowrap">
|
<label class="form-label flex items-center gap-2.5 text-nowrap">
|
||||||
<input class="checkbox" name="posisi_kavling[]" type="checkbox"
|
<input class="checkbox" name="posisi_kavling[]" type="checkbox"
|
||||||
value="{{ $item->name }}"
|
value="{{ $item->name }}"
|
||||||
{{ in_array($item->name, old('posisi_kavling', $forminspeksi['tanah']['posisi_kavling'] ?? [])) ? 'checked' : '' }}
|
{{ in_array($item->name, old('posisi_kavling', $forminspeksi['tanah']['posisi_kavling']['posisi_kavling'] ?? [])) ? 'checked' : '' }}
|
||||||
onclick="toggleCheckboxVisibility('posisi_kavling', 'posisi_kavling_lainnya', ['Lainnya'])" />
|
onclick="toggleCheckboxVisibility('posisi_kavling', 'posisi_kavling_lainnya', ['Lainnya'])" />
|
||||||
{{ $item->name }}
|
{{ $item->name }}
|
||||||
</label>
|
</label>
|
||||||
@if (strcasecmp($item->name, 'Lainnya') == 0)
|
@if (strcasecmp($item->name, 'Lainnya') == 0)
|
||||||
<input id="posisi_kavling_lainnya" type="text" style="display: none;"
|
<input id="posisi_kavling_lainnya" type="text" style="display: none;"
|
||||||
name="posisi_kavling_lainnya" class="input w-full mt-2"
|
name="posisi_kavling_lainnya" class="input w-full mt-2"
|
||||||
placeholder="Masukkan Posisi Kavling lainnya..." />
|
placeholder="Masukkan Posisi Kavling lainnya..." value="{{ old('posisi_kavling_lainnya', $forminspeksi['tanah']['posisi_kavling']['lainnya'] ?? '') }}" />
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|||||||
Reference in New Issue
Block a user