Merge pull request 'feature/senior-officer' (#138) from feature/senior-officer into staging
Reviewed-on: #138
This commit is contained in:
@@ -89,13 +89,16 @@ class LaporanPenilaiJaminanController extends Controller
|
||||
$userTeam = TeamsUsers::with('team')->firstWhere('user_id', $user->id);
|
||||
$regionId = $userTeam?->team->regions_id;
|
||||
}
|
||||
|
||||
$paramsSearch = null;
|
||||
// dd($startDate);
|
||||
// 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');
|
||||
$paramsSearch = json_decode($search);
|
||||
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%')
|
||||
->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%')
|
||||
@@ -104,10 +107,14 @@ class LaporanPenilaiJaminanController extends Controller
|
||||
->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%')
|
||||
->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||
|
||||
// Split search term by comma to allow multiple statuses
|
||||
if (!empty($paramsSearch->tanggal_awal) && !empty($paramsSearch->tanggal_akhir)) {
|
||||
$q->whereBetween('tanggal_permohonan', [$paramsSearch->tanggal_awal, $paramsSearch->tanggal_akhir]);
|
||||
}
|
||||
|
||||
|
||||
$statusKeywords = explode(',', $search);
|
||||
foreach ($statusKeywords as $keyword) {
|
||||
$q->orWhere('status', 'LIKE', '%' . trim($keyword) . '%');
|
||||
$q->orWhereRelation('penilai', 'type_penilai', 'LIKE', '%' . trim($keyword) . '%');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -167,6 +167,23 @@ class SurveyorController extends Controller
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validatedData = $request->all();
|
||||
|
||||
$fotoTypes = [
|
||||
'foto_gistaru',
|
||||
'foto_bhumi',
|
||||
'foto_argis_region',
|
||||
'foto_tempat',
|
||||
'foto_sentuh_tanahku',
|
||||
'upload_gs'
|
||||
];
|
||||
|
||||
// Hapus data foto dari $validatedData
|
||||
foreach ($fotoTypes as $fotoType) {
|
||||
if (isset($validatedData[$fotoType])) {
|
||||
unset($validatedData[$fotoType]);
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->inspeksiService->storeInspeksi($validatedData, $request->input('type'), $request);
|
||||
|
||||
if ($result['success']) {
|
||||
@@ -2028,9 +2045,9 @@ class SurveyorController extends Controller
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||
// abort(403, 'Sorry! You are not allowed to view users.');
|
||||
}
|
||||
// if (is_null($this->user) || !$this->user->can('debitur.view')) {
|
||||
// abort(403, 'Sorry! You are not allowed to view users.');
|
||||
// }
|
||||
|
||||
$query = Permohonan::query();
|
||||
$query = $query->orderBy('nomor_registrasi', 'desc');
|
||||
@@ -2099,7 +2116,7 @@ class SurveyorController extends Controller
|
||||
|
||||
public function dataForDatatablesData(Request $request, $type)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('jenis_aset.view')) {
|
||||
if (is_null(auth()->user()) || !$this->user->can('jenis_aset.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||
}
|
||||
|
||||
@@ -2818,4 +2835,73 @@ class SurveyorController extends Controller
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function uploadFileFoto(Request $request, $url)
|
||||
{
|
||||
|
||||
// dd($request->all());
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))
|
||||
->where('dokument_id', $request->input('dokument_id'))
|
||||
->first();
|
||||
|
||||
$fotoTypes = [
|
||||
'foto_gistaru',
|
||||
'foto_bhumi',
|
||||
'foto_argis_region',
|
||||
'foto_tempat',
|
||||
'foto_sentuh_tanahku',
|
||||
'upload_gs'
|
||||
];
|
||||
|
||||
if (!in_array($url, $fotoTypes)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Invalid key for upload'
|
||||
], 400);
|
||||
}
|
||||
|
||||
|
||||
$existingData = $inspeksi ? json_decode($inspeksi->data_form, true) : [];
|
||||
$existingData = $existingData ?? [];
|
||||
|
||||
|
||||
$factData = $existingData;
|
||||
if ($request->hasFile('file')) {
|
||||
$file = $request->file('file');
|
||||
$filePath = $file->store('uploads', 'public');
|
||||
$uploadedPath = str_replace('public/', '', $filePath);
|
||||
|
||||
|
||||
$factData[$url] = $uploadedPath;
|
||||
|
||||
|
||||
$existingData = $factData;
|
||||
if ($inspeksi) {
|
||||
$inspeksi->data_form = json_encode($existingData);
|
||||
$inspeksi->save();
|
||||
} else {
|
||||
Inspeksi::create([
|
||||
'permohonan_id' => $request->input('permohonan_id'),
|
||||
'dokument_id' => $request->input('document_id'),
|
||||
'data_form' => json_encode($existingData),
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'No file uploaded for the given key'
|
||||
], 400);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Berhasil upload file foto',
|
||||
'data' => [
|
||||
'key' => $url,
|
||||
'path' => $factData[$url] ?? null
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,44 +10,50 @@ class SaveFormInspesksiService
|
||||
public function storeInspeksi(array $validatedData, string $type, Request $request)
|
||||
{
|
||||
try {
|
||||
$processedData = $this->getActionSpecificRules($validatedData, $type, $request);
|
||||
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))
|
||||
->where('dokument_id', $request->input('dokument_id'))
|
||||
->first();
|
||||
|
||||
if ($inspeksi) {
|
||||
// Jika data sudah ada, merge dengan data yang baru
|
||||
$existingData = json_decode($inspeksi->data_form, true) ?: [];
|
||||
|
||||
if (isset($existingData['signature']) && !isset($processedData['signature'])) {
|
||||
$processedData['signature'] = $existingData['signature'];
|
||||
}
|
||||
|
||||
$mergedData = $this->arrayMergeRecursive($existingData, $processedData);
|
||||
|
||||
// Update record
|
||||
$inspeksi->update([
|
||||
'data_form' => json_encode($mergedData),
|
||||
'name' => $request->input('type')
|
||||
]);
|
||||
|
||||
$responseData = $mergedData;
|
||||
} else {
|
||||
// Jika belum ada data, buat record baru
|
||||
$inspeksi = Inspeksi::create([
|
||||
$inspeksi = Inspeksi::firstOrNew(
|
||||
[
|
||||
'permohonan_id' => $request->input('permohonan_id'),
|
||||
'dokument_id' => $request->input('dokument_id'),
|
||||
'data_form' => json_encode($processedData),
|
||||
'name' => $request->input('type')
|
||||
]);
|
||||
'dokument_id' => $request->input('dokument_id')
|
||||
]
|
||||
);
|
||||
|
||||
$responseData = $processedData;
|
||||
$inspeksi->name = $request->input('type');
|
||||
|
||||
$processedData = $this->getActionSpecificRules($validatedData, $type, $request, $inspeksi);
|
||||
|
||||
// Merge data lama dengan data baru
|
||||
$existingData = json_decode($inspeksi->data_form, true) ?: [];
|
||||
|
||||
$fotoTypes = [
|
||||
'foto_gistaru',
|
||||
'foto_bhumi',
|
||||
'foto_argis_region',
|
||||
'foto_tempat',
|
||||
'foto_sentuh_tanahku',
|
||||
'upload_gs'
|
||||
];
|
||||
|
||||
foreach ($fotoTypes as $fotoType) {
|
||||
if (isset($existingData[$fotoType])) {
|
||||
$processedData[$fotoType] = $existingData[$fotoType];
|
||||
}
|
||||
}
|
||||
|
||||
$mergedData = $this->arrayMergeRecursive($existingData, $processedData);
|
||||
|
||||
if (isset($existingData['signature']) && !isset($processedData['signature'])) {
|
||||
$mergedData['signature'] = $existingData['signature'];
|
||||
}
|
||||
|
||||
$inspeksi->data_form = json_encode($mergedData);
|
||||
$inspeksi->save();
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'message' => 'Data berhasil disimpan',
|
||||
];
|
||||
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return [
|
||||
'success' => false,
|
||||
@@ -58,7 +64,7 @@ class SaveFormInspesksiService
|
||||
}
|
||||
|
||||
|
||||
private function getActionSpecificRules($data, $action, $request): array
|
||||
private function getActionSpecificRules($data, $action, $request, $inspeksi): array
|
||||
{
|
||||
$allowedActions = [
|
||||
'apartemen-kantor' => 'getUnitData',
|
||||
@@ -95,7 +101,7 @@ class SaveFormInspesksiService
|
||||
if (isset($allowedActions[$act])) {
|
||||
$method = $allowedActions[$act];
|
||||
|
||||
$actionRules = $this->$method($data, $request);
|
||||
$actionRules = $this->$method($data, $request, $inspeksi);
|
||||
$rules = array_merge($rules, $actionRules);
|
||||
|
||||
// Cek apakah act memerlukan asset description rules
|
||||
@@ -374,7 +380,7 @@ class SaveFormInspesksiService
|
||||
}
|
||||
|
||||
|
||||
private function getFactData($data, $request): array
|
||||
private function getFactData($data, $request, $inspeksi): array
|
||||
{
|
||||
$factData = [
|
||||
'fakta' => [
|
||||
@@ -400,44 +406,16 @@ class SaveFormInspesksiService
|
||||
];
|
||||
|
||||
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))->where('dokument_id', $request->input('dokument_id'))->first();
|
||||
|
||||
|
||||
$fotoTypes = [
|
||||
'foto_gistaru',
|
||||
'foto_bhumi',
|
||||
'foto_argis_region',
|
||||
'foto_tempat',
|
||||
'foto_sentuh_tanahku',
|
||||
'upload_gs'
|
||||
];
|
||||
|
||||
if ($inspeksi) {
|
||||
$dataForm = json_decode($inspeksi->data_form, true);
|
||||
foreach ($fotoTypes as $fotoType) {
|
||||
// Jika ada file baru diupload
|
||||
if ($request->hasFile($fotoType)) {
|
||||
$factData[$fotoType] = $this->updateOrDeleteFile($dataForm, $request, $fotoType) ?: null;
|
||||
} else {
|
||||
$factData[$fotoType] = $dataForm[$fotoType] ?? null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($fotoTypes as $fotoType) {
|
||||
$factData[$fotoType] = $this->updateOrDeleteFile($data, $request, $fotoType) ?: null;
|
||||
}
|
||||
}
|
||||
|
||||
return $factData;
|
||||
}
|
||||
|
||||
private function getRapData($data, $request): array
|
||||
private function getRapData($data, $request, $inspeksi): array
|
||||
{
|
||||
|
||||
$inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))
|
||||
->where('dokument_id', $request->input('dokument_id'))
|
||||
->first();
|
||||
|
||||
$dataForm = json_decode($inspeksi->data_form, true);
|
||||
|
||||
$perizinanData = isset($dataForm['perizinan']) ? $dataForm['perizinan'] : [];
|
||||
@@ -966,14 +944,14 @@ class SaveFormInspesksiService
|
||||
];
|
||||
}
|
||||
|
||||
private function arrayMergeRecursive($arr1, $arr2)
|
||||
private function arrayMergeRecursive(array $arr1, array $arr2): array
|
||||
{
|
||||
foreach ($arr2 as $key => $value) {
|
||||
if ($key === 'signature' && isset($arr1['signature'])) {
|
||||
// Jika key adalah signature, gabungkan secara spesifik
|
||||
$arr1['signature'] = array_merge($arr1['signature'], $value);
|
||||
// Gabungkan 'signature' secara spesifik
|
||||
$arr1['signature'] = array_merge_recursive((array) $arr1['signature'], (array) $value);
|
||||
} elseif (is_array($value) && isset($arr1[$key]) && is_array($arr1[$key])) {
|
||||
// Rekursif untuk key lainnya
|
||||
// Rekursif untuk elemen array
|
||||
$arr1[$key] = $this->arrayMergeRecursive($arr1[$key], $value);
|
||||
} else {
|
||||
// Ganti nilai lama dengan nilai baru
|
||||
@@ -981,12 +959,8 @@ class SaveFormInspesksiService
|
||||
}
|
||||
}
|
||||
|
||||
// Bersihkan key lama yang tidak ada di array baru
|
||||
foreach ($arr1 as $key => $value) {
|
||||
if (!array_key_exists($key, $arr2) && $key !== 'signature') {
|
||||
unset($arr1[$key]);
|
||||
}
|
||||
}
|
||||
// Hapus key lama yang tidak ada di array baru kecuali 'signature'
|
||||
$arr1 = array_intersect_key($arr1, $arr2 + ['signature' => true]);
|
||||
|
||||
return $arr1;
|
||||
}
|
||||
@@ -1010,7 +984,7 @@ class SaveFormInspesksiService
|
||||
throw new Exception("Invalid file upload for {$fileKey}");
|
||||
}
|
||||
} elseif (isset($data[$fileKey]) && $data[$fileKey]) {
|
||||
return $data[$fileKey];
|
||||
return $data[$fileKey] ?? null;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,45 +5,45 @@
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
@push('styles')
|
||||
<style>
|
||||
.dropdown {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
}
|
||||
@push('styles')
|
||||
<style>
|
||||
.dropdown {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.dropdowns-content {
|
||||
display: none;
|
||||
position: absolute;
|
||||
background-color: white;
|
||||
min-width: 224px;
|
||||
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
|
||||
z-index: 1;
|
||||
margin-top: 0;
|
||||
/* Hilangkan jarak antara tombol dan dropdown */
|
||||
}
|
||||
.dropdowns-content {
|
||||
display: none;
|
||||
position: absolute;
|
||||
background-color: white;
|
||||
min-width: 224px;
|
||||
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
|
||||
z-index: 1;
|
||||
margin-top: 0;
|
||||
/* Hilangkan jarak antara tombol dan dropdown */
|
||||
}
|
||||
|
||||
.dropdown:hover .dropdowns-content {
|
||||
display: block;
|
||||
}
|
||||
.dropdown:hover .dropdowns-content {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Tambahkan hover untuk elemen dropdown agar tidak hilang */
|
||||
.dropdowns-content:hover {
|
||||
display: block;
|
||||
}
|
||||
/* Tambahkan hover untuk elemen dropdown agar tidak hilang */
|
||||
.dropdowns-content:hover {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.dropdowns-content a {
|
||||
color: black;
|
||||
padding: 12px 16px;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
}
|
||||
.dropdowns-content a {
|
||||
color: black;
|
||||
padding: 12px 16px;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.dropdowns-content a:hover {
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
.dropdowns-content a:hover {
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||
<div class="card border border-agi-100 card-grid min-w-full" data-datatable="false" data-datatable-page-size="10"
|
||||
data-datatable-state-save="false" id="laporan-penilai-jaminan-table"
|
||||
@@ -76,9 +76,8 @@
|
||||
<div class="flex">
|
||||
<!-- Custom dropdown for status filter -->
|
||||
<div class="dropdown" data-dropdown="true" data-dropdown-trigger="click">
|
||||
<button
|
||||
class="dropdowns-toggle btn btn-light inline-flex justify-between w-full items-center">
|
||||
Pilih Status
|
||||
<button class="dropdowns-toggle btn btn-light inline-flex justify-between w-full items-center">
|
||||
Pilih Type Laporan
|
||||
<i class="ki-outline ki-down dropdown-open:hidden">
|
||||
</i>
|
||||
<i class="ki-outline ki-up hidden dropdown-open:block">
|
||||
@@ -96,9 +95,16 @@
|
||||
</label>
|
||||
</div>
|
||||
<!-- Dinamis Status dari Backend -->
|
||||
@php
|
||||
$status_laporan = ['Standar', 'Sederhana', 'Memo', 'Resume', 'Call Report', 'RAP'];
|
||||
@endphp
|
||||
@php
|
||||
$status_laporan = [
|
||||
'Standar',
|
||||
'Sederhana',
|
||||
'Memo',
|
||||
'Resume',
|
||||
'Call Report',
|
||||
'RAP',
|
||||
];
|
||||
@endphp
|
||||
@foreach ($status_laporan as $item)
|
||||
<div class="menu-item">
|
||||
<label class="menu-link flex items-center px-4 py-2 text-sm text-gray-700">
|
||||
@@ -216,10 +222,15 @@
|
||||
const dataTableOptions = {
|
||||
apiEndpoint: apiUrl,
|
||||
pageSize: 5,
|
||||
params: {
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
},
|
||||
order: [{
|
||||
column: 'nomor_registrasi',
|
||||
dir: 'asc'
|
||||
}],
|
||||
|
||||
columns: {
|
||||
select: {
|
||||
render: (item, data, context) => {
|
||||
@@ -292,7 +303,8 @@
|
||||
},
|
||||
},
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
let dataTable = new KTDataTable(element, dataTableOptions);
|
||||
@@ -312,14 +324,20 @@
|
||||
const tanggalAwal = tanggalAwalInput.value;
|
||||
const tanggalAkhir = tanggalAkhirInput.value;
|
||||
|
||||
if (tanggalAwal && tanggalAkhir) {
|
||||
// Reload the table with date filters
|
||||
dataTable.setParameter('tanggal_awal', tanggalAwal);
|
||||
dataTable.setParameter('tanggal_akhir', tanggalAkhir);
|
||||
dataTable.reload();
|
||||
} else {
|
||||
alert('Mohon isi tanggal awal dan tanggal akhir');
|
||||
let filters = {};
|
||||
if (searchInput.value) {
|
||||
filters.search = searchInput.value;
|
||||
}
|
||||
|
||||
if (tanggalAwal) {
|
||||
filters.tanggal_awal = tanggalAwal
|
||||
}
|
||||
|
||||
if (tanggalAkhir) {
|
||||
filters.tanggal_akhir = tanggalAkhir
|
||||
}
|
||||
|
||||
dataTable.search(filters);
|
||||
}
|
||||
|
||||
// Status filter functionality
|
||||
@@ -342,9 +360,11 @@
|
||||
.map(checkbox => checkbox.value);
|
||||
|
||||
if (selectedStatuses.length === 0) {
|
||||
dataTable.setParameter('status', null);
|
||||
dataTable.search('');
|
||||
console.log(selectedStatuses);
|
||||
} else {
|
||||
dataTable.setParameter('status', selectedStatuses);
|
||||
dataTable.search(selectedStatuses.join(','), true);
|
||||
console.log(selectedStatuses);
|
||||
}
|
||||
|
||||
dataTable.reload();
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<form id="dataPembandingForm" method="POST" enctype="multipart/form-data" class="grid gap-5">
|
||||
@csrf
|
||||
<input type="hidden" name="permohonan_id" value="{{ $permohonan->id }}">
|
||||
<input type="hidden" name="type" value="tanah">
|
||||
|
||||
<input type="hidden" name="dokument_id" value="{{ request('dokument') }}">
|
||||
<input type="hidden" name="nomor_registrasi" value="{{ $permohonan->nomor_registrasi }}">
|
||||
<div class="card">
|
||||
@@ -29,9 +29,12 @@
|
||||
@php
|
||||
$dokumentName = $dokumen->jenisJaminan->name;
|
||||
$formKategori = json_decode($dokumen->jenisJaminan->form_kategori, true);
|
||||
$kategoriArray = is_array($formKategori) ? $formKategori : [$formKategori];
|
||||
$kategoriUnik = array_unique($kategoriArray);
|
||||
@endphp
|
||||
<input type="hidden" name="action"
|
||||
value="{{ is_array($formKategori) ? implode(',', $formKategori) : $formKategori }}">
|
||||
<input type="hidden" name="type" value="{{ implode(',', $kategoriUnik) }}">
|
||||
@if (!in_array(strtoupper($dokumentName), $tanahBangunanTypes))
|
||||
@include('lpj::surveyor.components.pembanding-tanah-bangunan-unit')
|
||||
@else
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
<input id="inputGistaru" type="file" name="upload_gs"
|
||||
class="file-input file-input-bordered w-full"
|
||||
accept=".jpg,.jpeg,.png,.gif,.bmp,.tiff,.tif,.webp,.svg"
|
||||
onchange="previewImage(this, 'upload-gs-preview')">
|
||||
onchange="uploadFile(this, 'upload-gs-preview', 'upload_gs')">
|
||||
|
||||
<img id="upload-gs-preview"
|
||||
src="{{ asset('storage/' . (isset($forminspeksi['upload_gs']) ? $forminspeksi['upload_gs'] : '')) }}"
|
||||
@@ -146,7 +146,8 @@
|
||||
<input id="inputGistaru" type="file" name="foto_sentuh_tanahku"
|
||||
class="file-input file-input-bordered w-full"
|
||||
accept=".jpg,.jpeg,.png,.gif,.bmp,.tiff,.tif,.webp,.svg"
|
||||
onchange="previewImage(this, 'sentuh_tanahku-preview')">
|
||||
onchange="uploadFile(this, 'sentuh_tanahku-preview', 'foto_sentuh_tanahku')"
|
||||
>
|
||||
|
||||
<img id="sentuh_tanahku-preview"
|
||||
src="{{ asset('storage/' . (isset($forminspeksi['foto_sentuh_tanahku']) ? $forminspeksi['foto_sentuh_tanahku'] : '')) }}"
|
||||
@@ -169,7 +170,7 @@
|
||||
<input id="inputGistaru" type="file" name="foto_gistaru"
|
||||
class="file-input file-input-bordered w-full"
|
||||
accept=".jpg,.jpeg,.png,.gif,.bmp,.tiff,.tif,.webp,.svg"
|
||||
onchange="previewImage(this, 'gistaru-preview')">
|
||||
onchange="uploadFile(this, 'gistaru-preview', 'foto_gistaru')">
|
||||
|
||||
<img id="gistaru-preview"
|
||||
src="{{ asset('storage/' . (isset($forminspeksi['foto_gistaru']) ? $forminspeksi['foto_gistaru'] : '')) }}"
|
||||
@@ -197,7 +198,7 @@
|
||||
<input id="inputBhumi" type="file" name="foto_bhumi"
|
||||
class="file-input file-input-bordered w-full "
|
||||
accept=".jpg,.jpeg,.png,.gif,.bmp,.tiff,.tif,.webp,.svg"
|
||||
onchange="previewImage(this, 'bhumi-preview')">
|
||||
onchange="uploadFile(this, 'bhumi-preview', 'foto_bhumi')">
|
||||
<img id="bhumi-preview"
|
||||
src="{{ asset('storage/' . (isset($forminspeksi['foto_bhumi']) ? $forminspeksi['foto_bhumi'] : '')) }}"
|
||||
alt="Foto Bhumi" class="mt-2 max-w-full h-auto"
|
||||
@@ -210,97 +211,191 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
<span class="form-label">Blad Tata Ruang Perdaerah</span>
|
||||
</label>
|
||||
<div class="input-group w-full flex gap-2">
|
||||
<input class="name_rute" type="hidden" name="name_rute" value="rute">
|
||||
<div class="w-full">
|
||||
<input id="inputArgisRegion" type="file" name="foto_argis_region"
|
||||
class="file-input file-input-bordered w-full"
|
||||
accept=".jpg,.jpeg,.png,.gif,.bmp,.tiff,.tif,.webp,.svg"
|
||||
onchange="previewImage(this, 'argis-region-preview')">
|
||||
<img id="argis-region-preview"
|
||||
src="{{ asset('storage/' . (isset($forminspeksi['foto_argis_region']) ? $forminspeksi['foto_argis_region'] : '')) }}"
|
||||
alt="Foto Argis Region" class="mt-2 max-w-full h-auto"
|
||||
style="{{ isset($forminspeksi['foto_argis_region']) ? '' : 'display: none;' }} max-width: 30rem;">
|
||||
</div>
|
||||
<
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Upload Photo Button -->
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5" style="margin-top: 20px">
|
||||
<label for="" class="form-label max-w-56 text-sm font-medium text-gray-700">Upload Peta</label>
|
||||
<div class="w-full grid gap-5">
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
<span class="form-label">Blad Tata Ruang Perdaerah</span>
|
||||
</label>
|
||||
<div class="input-group w-full flex gap-2">
|
||||
<input id="foto_tempat" type="file" name="foto_tempat"
|
||||
class="file-input file-input-bordered w-full"
|
||||
accept=".jpg,.jpeg,.png,.gif,.bmp,.tiff,.tif,.webp,.svg"
|
||||
onchange="previewImage(this, 'foto_tempat-preview')">
|
||||
<button type="button" id="btnCamera" class="btn btn-light" data-modal-toggle="#cameraModal">
|
||||
<i class="ki-outline ki-abstract-33"></i> Camera
|
||||
</button>
|
||||
<input class="name_rute" type="hidden" name="name_rute" value="rute">
|
||||
<div class="w-full">
|
||||
<input id="inputArgisRegion" type="file" name="foto_argis_region"
|
||||
class="file-input file-input-bordered w-full"
|
||||
accept=".jpg,.jpeg,.png,.gif,.bmp,.tiff,.tif,.webp,.svg"
|
||||
onchange="uploadFile(this, 'argis-region-preview', 'foto_argis_region')">
|
||||
<img id="argis-region-preview"
|
||||
src="{{ asset('storage/' . (isset($forminspeksi['foto_argis_region']) ? $forminspeksi['foto_argis_region'] : '')) }}"
|
||||
alt="Foto Argis Region" class="mt-2 max-w-full h-auto"
|
||||
style="{{ isset($forminspeksi['foto_argis_region']) ? '' : 'display: none;' }} max-width: 30rem;">
|
||||
</div>
|
||||
< </div>
|
||||
</div>
|
||||
@php
|
||||
$fotoTempat = $forminspeksi['foto_tempat'] ?? null;
|
||||
$fotoSrc = '';
|
||||
|
||||
if (is_array($fotoTempat)) {
|
||||
$fotoSrc = asset('storage/' . $fotoTempat[0]);
|
||||
} elseif (!empty($fotoTempat)) {
|
||||
$fotoSrc = asset('storage/' . $fotoTempat);
|
||||
}
|
||||
@endphp
|
||||
|
||||
<img id="foto_tempat-preview" src="{{ $fotoSrc ?: '' }}"
|
||||
alt="Foto Tempat" class="mt-2 max-w-full h-auto"
|
||||
style="max-width: 30rem; {{ $fotoSrc ? '' : 'display: none;' }}">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- Upload Photo Button -->
|
||||
|
||||
<!-- Notes Section -->
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5" style="margin-top: 20px">
|
||||
<label for="" class="form-label max-w-56 text-sm font-medium text-gray-700">Upload
|
||||
Peta</label>
|
||||
<div class="w-full grid gap-5">
|
||||
<div class="input-group w-full flex gap-2">
|
||||
<input id="foto_tempat" type="file" name="foto_tempat"
|
||||
class="file-input file-input-bordered w-full"
|
||||
accept=".jpg,.jpeg,.png,.gif,.bmp,.tiff,.tif,.webp,.svg"
|
||||
onchange="uploadFile(this, 'foto_tempat-preview', 'foto_tempat')">
|
||||
<button type="button" id="btnCamera" class="btn btn-light"
|
||||
data-modal-toggle="#cameraModal">
|
||||
<i class="ki-outline ki-abstract-33"></i> Camera
|
||||
</button>
|
||||
</div>
|
||||
@php
|
||||
$fotoTempat = $forminspeksi['foto_tempat'] ?? null;
|
||||
$fotoSrc = '';
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5" style="margin-top: 20px">
|
||||
if (is_array($fotoTempat)) {
|
||||
$fotoSrc = asset('storage/' . $fotoTempat[0]);
|
||||
} elseif (!empty($fotoTempat)) {
|
||||
$fotoSrc = asset('storage/' . $fotoTempat);
|
||||
}
|
||||
@endphp
|
||||
|
||||
<label class="form-label lg:form-label max-w-56 ">Catatan yang Perlu Diperhatikan
|
||||
</label>
|
||||
<div class="w-full">
|
||||
<div id="keterangan-container" class="flex items-baseline flex-wrap gap-2.5 w-full">
|
||||
@if (!empty($forminspeksi['fakta']['keterangan']) && is_array($forminspeksi['fakta']['keterangan']))
|
||||
@foreach ($forminspeksi['fakta']['keterangan'] as $index => $item)
|
||||
<img id="foto_tempat-preview" src="{{ $fotoSrc ?: '' }}" alt="Foto Tempat"
|
||||
class="mt-2 max-w-full h-auto"
|
||||
style="max-width: 30rem; {{ $fotoSrc ? '' : 'display: none;' }}">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Notes Section -->
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5" style="margin-top: 20px">
|
||||
|
||||
<label class="form-label lg:form-label max-w-56 ">Catatan yang Perlu Diperhatikan
|
||||
</label>
|
||||
<div class="w-full">
|
||||
<div id="keterangan-container" class="flex items-baseline flex-wrap gap-2.5 w-full">
|
||||
@if (!empty($forminspeksi['fakta']['keterangan']) && is_array($forminspeksi['fakta']['keterangan']))
|
||||
@foreach ($forminspeksi['fakta']['keterangan'] as $index => $item)
|
||||
<div class="keterangan flex items-center gap-2 mt-2 textarea-group w-full">
|
||||
<textarea name="keterangan[]" class="textarea mt-2" placeholder="Masukkan catatan penting" rows="10">{{ old("keterangan.$index", $item) }}</textarea>
|
||||
<button class="btn btn-danger btn-sm remove-btn" type="button"
|
||||
style="display: none;">
|
||||
<i class="ki-outline ki-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
@endforeach
|
||||
@else
|
||||
<div class="keterangan flex items-center gap-2 mt-2 textarea-group w-full">
|
||||
<textarea name="keterangan[]" class="textarea mt-2" placeholder="Masukkan catatan penting" rows="10">{{ old("keterangan.$index", $item) }}</textarea>
|
||||
<textarea name="keterangan[]" class="textarea mt-2" placeholder="Masukkan catatan penting" rows="10"></textarea>
|
||||
<button class="btn btn-danger btn-sm remove-btn" type="button"
|
||||
style="display: none;">
|
||||
<i class="ki-outline ki-trash"></i>
|
||||
</button>
|
||||
<em id="error-keterangan" class="alert text-danger text-sm"></em>
|
||||
</div>
|
||||
@endforeach
|
||||
@else
|
||||
<div class="keterangan flex items-center gap-2 mt-2 textarea-group w-full">
|
||||
<textarea name="keterangan[]" class="textarea mt-2" placeholder="Masukkan catatan penting" rows="10"></textarea>
|
||||
<button class="btn btn-danger btn-sm remove-btn" type="button" style="display: none;">
|
||||
<i class="ki-outline ki-trash"></i>
|
||||
</button>
|
||||
<em id="error-keterangan" class="alert text-danger text-sm"></em>
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
</div>
|
||||
<button type="button" onclick="addClonableItem('keterangan-container', 'keterangan')"
|
||||
class="btn btn-primary btn-sm mt-5 ">
|
||||
<i class="ki-outline ki-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
<button type="button" onclick="addClonableItem('keterangan-container', 'keterangan')"
|
||||
class="btn btn-primary btn-sm mt-5 ">
|
||||
<i class="ki-outline ki-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@include('lpj::surveyor.components.modal-kamera')
|
||||
@include('lpj::surveyor.components.modal-kamera')
|
||||
|
||||
@push('scripts')
|
||||
@include('lpj::surveyor.js.camera-editor')
|
||||
@endpush
|
||||
@push('scripts')
|
||||
<script stype="text/javascript">
|
||||
function uploadFile(inputElement, previewElement, url) {
|
||||
// Ambil file dari elemen input
|
||||
const file = inputElement.files[0];
|
||||
|
||||
|
||||
if (!file) {
|
||||
Swal.fire({
|
||||
icon: 'warning',
|
||||
title: 'Tidak ada file yang dipilih.',
|
||||
toast: true,
|
||||
position: 'top-end',
|
||||
showConfirmButton: false,
|
||||
timer: 1500
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (inputElement.files && file) {
|
||||
var reader = new FileReader();
|
||||
reader.onload = function(e) {
|
||||
$('#' + previewElement).attr('src', e.target.result).show();
|
||||
}
|
||||
reader.readAsDataURL(inputElement.files[0]);
|
||||
} else {
|
||||
$('#' + previewElement).hide();
|
||||
}
|
||||
|
||||
// Buat FormData untuk mengirim file
|
||||
const formData = new FormData();
|
||||
|
||||
const dokument = "{{ request('dokument') }}";
|
||||
const permohonan = "{{ $permohonan->id }}";
|
||||
formData.append('file', file);
|
||||
formData.append('dokument_id', dokument);
|
||||
formData.append('permohonan_id', permohonan);
|
||||
|
||||
$.ajax({
|
||||
url: '/surveyor/upload-file-foto/' + url,
|
||||
type: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
},
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(response) {
|
||||
|
||||
|
||||
if (response.success) {
|
||||
// Tampilkan pesan sukses
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: response.message || 'File berhasil diunggah!',
|
||||
toast: true,
|
||||
position: 'top-end',
|
||||
showConfirmButton: false,
|
||||
timer: 1500
|
||||
});
|
||||
|
||||
// Perbarui elemen preview
|
||||
$(previewElement).attr('src', response.data.path).show();
|
||||
$(inputElement).data('file-name', response.data.file_name);
|
||||
} else {
|
||||
// Tampilkan pesan kesalahan dari server
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: response.message || 'Gagal mengunggah file!',
|
||||
toast: true,
|
||||
position: 'top-end',
|
||||
showConfirmButton: false,
|
||||
timer: 1500
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
|
||||
|
||||
// Tampilkan pesan kesalahan
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: xhr.responseJSON?.message || 'Terjadi kesalahan saat mengunggah file.',
|
||||
toast: true,
|
||||
position: 'top-end',
|
||||
showConfirmButton: false,
|
||||
timer: 1500
|
||||
});
|
||||
console.error(`Error: ${error}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@include('lpj::surveyor.js.camera-editor')
|
||||
@endpush
|
||||
|
||||
@@ -517,6 +517,19 @@
|
||||
showLoadingSwal('Mengirim data ke server...');
|
||||
const form = document.querySelector('form');
|
||||
const formData = new FormData(form);
|
||||
|
||||
const fotoFields = [
|
||||
'foto_gistaru',
|
||||
'foto_bhumi',
|
||||
'foto_argis_region',
|
||||
'foto_tempat',
|
||||
'foto_sentuh_tanahku',
|
||||
'upload_gs'
|
||||
];
|
||||
|
||||
fotoFields.forEach((field) => {
|
||||
formData.delete(field);
|
||||
});
|
||||
$.ajax({
|
||||
url: '{{ route('surveyor.store') }}',
|
||||
type: 'POST',
|
||||
|
||||
@@ -599,6 +599,8 @@ Route::middleware(['auth'])->group(function () {
|
||||
Route::put('store-proses-survey/{id}', [SurveyorController::class, 'storeProsesSurvey'])->name('storeProsesSurvey');
|
||||
Route::post('save-edited-image/', [SurveyorController::class, 'saveEditedImage'])->name('saveEditedImage');
|
||||
|
||||
Route::post('upload-file-foto/{url}', [SurveyorController::class, 'uploadFileFoto'])->name('uploadFileFoto');
|
||||
|
||||
});
|
||||
|
||||
Route::name('penilai.')->prefix('penilai')->group(function () {
|
||||
|
||||
Reference in New Issue
Block a user