Merge branch 'staging' of https://git.putrakuningan.com/daengdeni/lpj into tender
This commit is contained in:
@@ -81,6 +81,7 @@ use Modules\Lpj\Http\Requests\SurveyorRequest;
|
|||||||
use Modules\Lpj\Http\Requests\FormSurveyorRequest;
|
use Modules\Lpj\Http\Requests\FormSurveyorRequest;
|
||||||
use Modules\Lpj\Emails\SendJadwalKunjunganEmail;
|
use Modules\Lpj\Emails\SendJadwalKunjunganEmail;
|
||||||
use App\Helpers\Lpj;
|
use App\Helpers\Lpj;
|
||||||
|
use Modules\Lpj\Models\Authorization;
|
||||||
|
|
||||||
class SurveyorController extends Controller
|
class SurveyorController extends Controller
|
||||||
{
|
{
|
||||||
@@ -366,7 +367,7 @@ class SurveyorController extends Controller
|
|||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'message' => 'Data berhasil disimpan',
|
'message' => 'Data berhasil disimpan',
|
||||||
'file' => $newFoto
|
'path' => $newFoto[0]['path'],
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1073,7 +1074,12 @@ class SurveyorController extends Controller
|
|||||||
|
|
||||||
// Pastikan input adalah array dan index valid
|
// Pastikan input adalah array dan index valid
|
||||||
if (is_array($inputValue) && isset($inputValue[$index])) {
|
if (is_array($inputValue) && isset($inputValue[$index])) {
|
||||||
$pembanding[$field] = $inputValue[$index];
|
$value = $inputValue[$index];
|
||||||
|
// Format hanya untuk harga, harga_diskon, dan total
|
||||||
|
if (in_array($field, ['harga', 'harga_diskon', 'total'])) {
|
||||||
|
$value = preg_replace('/[^0-9]/', '', $value); // Hapus karakter non-angka
|
||||||
|
}
|
||||||
|
$pembanding[$field] = $value;
|
||||||
} else {
|
} else {
|
||||||
$pembanding[$field] = null;
|
$pembanding[$field] = null;
|
||||||
}
|
}
|
||||||
@@ -1178,6 +1184,9 @@ class SurveyorController extends Controller
|
|||||||
if ($request->filled($field)) {
|
if ($request->filled($field)) {
|
||||||
$newValue = $request->input($field);
|
$newValue = $request->input($field);
|
||||||
|
|
||||||
|
if (in_array($field, ['harga', 'harga_diskon', 'total'])) {
|
||||||
|
$newValue = preg_replace('/[^0-9]/', '', $newValue);
|
||||||
|
}
|
||||||
// Fields untuk tanah
|
// Fields untuk tanah
|
||||||
if (in_array($field, ['luas_tanah'])) {
|
if (in_array($field, ['luas_tanah'])) {
|
||||||
// Pastikan struktur array ada sebelum diakses
|
// Pastikan struktur array ada sebelum diakses
|
||||||
@@ -1327,7 +1336,9 @@ class SurveyorController extends Controller
|
|||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
if ($request->filled($field)) {
|
if ($request->filled($field)) {
|
||||||
$newValue = $request->input($field);
|
$newValue = $request->input($field);
|
||||||
|
if (in_array($field, ['harga', 'harga_diskon', 'total'])) {
|
||||||
|
$newValue = preg_replace('/[^0-9]/', '', $newValue);
|
||||||
|
}
|
||||||
// Fields untuk alamat dalam asset
|
// Fields untuk alamat dalam asset
|
||||||
if (in_array($field, ['address', 'village_code', 'district_code', 'city_code', 'province_code'])) {
|
if (in_array($field, ['address', 'village_code', 'district_code', 'city_code', 'province_code'])) {
|
||||||
|
|
||||||
@@ -3532,7 +3543,7 @@ class SurveyorController extends Controller
|
|||||||
: 'lpj::surveyor.components.print-out.main';
|
: 'lpj::surveyor.components.print-out.main';
|
||||||
|
|
||||||
// Generate PDF
|
// Generate PDF
|
||||||
$pdf = PDF::loadView($templateView, compact('permohonan', 'basicData', 'forminspeksi','alamat'));
|
$pdf = PDF::loadView($templateView, compact('permohonan', 'basicData', 'forminspeksi', 'alamat'));
|
||||||
$pdf->setPaper('A4', 'portrait');
|
$pdf->setPaper('A4', 'portrait');
|
||||||
|
|
||||||
// Tentukan nama file PDF
|
// Tentukan nama file PDF
|
||||||
|
|||||||
@@ -42,11 +42,12 @@
|
|||||||
: null;
|
: null;
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
{{ !empty($bentukTanah) ? implode(', ', $bentukTanah) : 'Data tidak tersedia' }}
|
{{ !empty($bentukTanah) ? implode(', ', $bentukTanah) : '' }}
|
||||||
|
|
||||||
@if (in_array('Lainnya', $bentukTanah) && $lainnya)
|
@if (!empty($bentukTanah) && in_array('Lainnya', $bentukTanah) && !is_null($lainnya))
|
||||||
({{ $lainnya }})
|
({{ $lainnya }})
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
@@ -97,19 +98,16 @@
|
|||||||
<td>:</td>
|
<td>:</td>
|
||||||
<td style="padding: 2px; vertical-align: top;">
|
<td style="padding: 2px; vertical-align: top;">
|
||||||
@php
|
@php
|
||||||
$posisiKavling = isset($forminspeksi['tanah']['posisi_kavling']['posisi_kavling'])
|
$posisiKavling = $forminspeksi['tanah']['posisi_kavling']['posisi_kavling'] ?? [];
|
||||||
? $forminspeksi['tanah']['posisi_kavling']['posisi_kavling']
|
$lainnya = $forminspeksi['tanah']['posisi_kavling']['lainnya'] ?? null;
|
||||||
: [];
|
|
||||||
$lainnya = isset($forminspeksi['tanah']['posisi_kavling']['lainnya'])
|
|
||||||
? $forminspeksi['tanah']['posisi_kavling']['lainnya']
|
|
||||||
: null;
|
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
{{ !empty($posisiKavling) ? implode(', ', $posisiKavling) : '' }}
|
{{ !empty($posisiKavling) ? implode(', ', $posisiKavling) : '' }}
|
||||||
|
|
||||||
@if (in_array('Lainnya', $posisiKavling) && $lainnya)
|
@if (!empty($posisiKavling) && in_array('Lainnya', $posisiKavling) && !empty($lainnya))
|
||||||
({{ $lainnya }})
|
({{ $lainnya }})
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@@ -134,13 +132,14 @@
|
|||||||
<td style="padding: 2px; vertical-align: top;">
|
<td style="padding: 2px; vertical-align: top;">
|
||||||
@php
|
@php
|
||||||
$kondisiFisikTanah = $forminspeksi['tanah']['kondisi_fisik_tanah']['kondisi_fisik_tanah'][0] ?? '-';
|
$kondisiFisikTanah = $forminspeksi['tanah']['kondisi_fisik_tanah']['kondisi_fisik_tanah'][0] ?? '-';
|
||||||
$lainnya = $forminspeksi['tanah']['kondisi_fisik_tanah']['lainnya'];
|
$lainnya = $forminspeksi['tanah']['kondisi_fisik_tanah']['lainnya'] ?? null;
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
{{ $kondisiFisikTanah }}
|
{{ $kondisiFisikTanah }}
|
||||||
@if ($kondisiFisikTanah === 'Lainnya' && $lainnya)
|
@if ($kondisiFisikTanah === 'Lainnya' && !empty($lainnya))
|
||||||
({{ $lainnya }})
|
({{ $lainnya }})
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -182,7 +182,7 @@
|
|||||||
@endphp
|
@endphp
|
||||||
<td style="width: 100%; vertical-align: top; text-align: center" colspan="2"
|
<td style="width: 100%; vertical-align: top; text-align: center" colspan="2"
|
||||||
class="photo-item border">
|
class="photo-item border">
|
||||||
<p style="font-weight: medium; font-size: 10px">{{ $category }} -
|
<p style="font-weight: medium; font-size: 10px">Lainnya -
|
||||||
|
|
||||||
@isset($subcategory)
|
@isset($subcategory)
|
||||||
@if (trim($subcategory) !== '')
|
@if (trim($subcategory) !== '')
|
||||||
@@ -206,7 +206,7 @@
|
|||||||
$imagePath = storage_path('app/public/' . $item['path']);
|
$imagePath = storage_path('app/public/' . $item['path']);
|
||||||
@endphp
|
@endphp
|
||||||
<td style="width: 50%; vertical-align: top; text-align: center" class="photo-item border">
|
<td style="width: 50%; vertical-align: top; text-align: center" class="photo-item border">
|
||||||
<p style="font-weight: medium; font-size: 10px">{{ $category }} -
|
<p style="font-weight: medium; font-size: 10px">Lainnya -
|
||||||
|
|
||||||
@isset($subcategory)
|
@isset($subcategory)
|
||||||
@if (trim($subcategory) !== '')
|
@if (trim($subcategory) !== '')
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
<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">Harga Penawaran</label>
|
<label class="form-label max-w-56">Harga Penawaran</label>
|
||||||
<div class="flex flex-wrap items-baseline w-full">
|
<div class="flex flex-wrap items-baseline w-full">
|
||||||
<span>Rp. {{ $item['harga'] }}</span>
|
<span>{{ isset($item['harga']) ? formatRupiah($item['harga']) : '' }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -321,7 +321,7 @@
|
|||||||
@if ($key == 'luas_tanah' || $key == 'luas_bangunan')
|
@if ($key == 'luas_tanah' || $key == 'luas_bangunan')
|
||||||
{{ $data[$key] ?? '-' }} m²
|
{{ $data[$key] ?? '-' }} m²
|
||||||
@elseif($key == 'harga' || $key == 'harga_diskon')
|
@elseif($key == 'harga' || $key == 'harga_diskon')
|
||||||
Rp. {{ $data[$key] ?? 0 }}
|
{{ formatRupiah($data[$key]) ?? 0 }}
|
||||||
@elseif($key == 'kordinat')
|
@elseif($key == 'kordinat')
|
||||||
@php
|
@php
|
||||||
$lat = $data['kordinat_lat'] ?? null;
|
$lat = $data['kordinat_lat'] ?? null;
|
||||||
|
|||||||
@@ -125,8 +125,8 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Format currency untuk input harga
|
// Format currency untuk input harga
|
||||||
if (name.includes('harga') || name.includes('total') || name.includes('diskon')) {
|
if (name.includes('diskon')) {
|
||||||
element.value = value ? value.toString() : '0';
|
element.value = value || '0';
|
||||||
} else {
|
} else {
|
||||||
element.value = value || '';
|
element.value = value || '';
|
||||||
}
|
}
|
||||||
@@ -364,16 +364,16 @@
|
|||||||
input.value = '';
|
input.value = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.classList.contains('currency')) {
|
if (input.classList.contains('currency-format')) {
|
||||||
input.addEventListener('input', function() {
|
input.addEventListener('input', function() {
|
||||||
|
handleCurrencyInput(this);
|
||||||
|
|
||||||
|
// Calculate prices if needed
|
||||||
// Special handling for price-related inputs
|
|
||||||
if (input.name.includes('harga_pembanding') ||
|
if (input.name.includes('harga_pembanding') ||
|
||||||
input.name.includes('diskon_pembanding')) {
|
input.name.includes('diskon_pembanding')) {
|
||||||
const inputs = document.getElementsByName(input.name);
|
const inputs = document.getElementsByName(input.name);
|
||||||
const index = Array.from(inputs).indexOf(this);
|
const index = Array.from(inputs).indexOf(this);
|
||||||
calculatePrices(index);
|
calculatePrices('pembanding', index);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -382,7 +382,7 @@
|
|||||||
if (input.name.includes('diskon_pembanding')) {
|
if (input.name.includes('diskon_pembanding')) {
|
||||||
input.addEventListener('input', function() {
|
input.addEventListener('input', function() {
|
||||||
let value =
|
let value =
|
||||||
this.value = value.toString();
|
this.value = value.toString();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -394,7 +394,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function handleCurrencyInput(input) {
|
||||||
|
const value = input.value.replace(/[^\d]/g, '');
|
||||||
|
input.value = formatCurrency(value);
|
||||||
|
}
|
||||||
|
|
||||||
function removeColumn() {
|
function removeColumn() {
|
||||||
if (columnCount > 1) {
|
if (columnCount > 1) {
|
||||||
@@ -445,6 +448,13 @@
|
|||||||
ensureLocationEventListeners();
|
ensureLocationEventListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initializeCurrencyFormat() {
|
||||||
|
document.querySelectorAll('.currency-format').forEach(input => {
|
||||||
|
input.addEventListener('input', function() {
|
||||||
|
formatCurrency(this);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function initializeFirstPembandingListeners() {
|
function initializeFirstPembandingListeners() {
|
||||||
const firstProvinceSelect = document.getElementById('province_code_pembanding');
|
const firstProvinceSelect = document.getElementById('province_code_pembanding');
|
||||||
@@ -658,5 +668,18 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
// Initialize currency format for existing inputs
|
||||||
|
document.querySelectorAll('.currency-format').forEach(input => {
|
||||||
|
input.addEventListener('input', function() {
|
||||||
|
handleCurrencyInput(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Format initial values if they exist
|
||||||
|
if (input.value) {
|
||||||
|
input.value = formatCurrency(input.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
|||||||
@@ -176,7 +176,7 @@
|
|||||||
<input type="hidden" name="nomor_registrasi" value="{{ $permohonan->nomor_registrasi }}">
|
<input type="hidden" name="nomor_registrasi" value="{{ $permohonan->nomor_registrasi }}">
|
||||||
|
|
||||||
|
|
||||||
<div class="card border border-agi-100 bg-white rounded-lg shadow-md">
|
<div class="card border border-agi-100 rounded-lg shadow-md">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class=" py-4 flex items-center justify-between">
|
<div class=" py-4 flex items-center justify-between">
|
||||||
<h1 class="text-md font-medium text-gray-900">Upload Foto</h1>
|
<h1 class="text-md font-medium text-gray-900">Upload Foto</h1>
|
||||||
@@ -273,10 +273,11 @@
|
|||||||
Dropzone.autoDiscover = false;
|
Dropzone.autoDiscover = false;
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
let myDropzone = null;
|
let myDropzone = null;
|
||||||
|
let uploadQueue = 0;
|
||||||
|
let uploadBatch = [];
|
||||||
|
|
||||||
function initDropzone(selector, paramName) {
|
function initDropzone(selector, paramName) {
|
||||||
try {
|
try {
|
||||||
// Pastikan elemen ada sebelum membuat Dropzone
|
|
||||||
const dropzoneElement = document.querySelector(selector);
|
const dropzoneElement = document.querySelector(selector);
|
||||||
if (!dropzoneElement) {
|
if (!dropzoneElement) {
|
||||||
console.error(`Dropzone element not found: ${selector}`);
|
console.error(`Dropzone element not found: ${selector}`);
|
||||||
@@ -286,11 +287,10 @@
|
|||||||
myDropzone = new Dropzone(selector, {
|
myDropzone = new Dropzone(selector, {
|
||||||
url: "{{ route('surveyor.storeFoto') }}",
|
url: "{{ route('surveyor.storeFoto') }}",
|
||||||
paramName: paramName,
|
paramName: paramName,
|
||||||
maxFilesize: 10,
|
maxFilesize: 30,
|
||||||
acceptedFiles: 'image/*',
|
acceptedFiles: 'image/*',
|
||||||
uploadMultiple: false,
|
uploadMultiple: false,
|
||||||
parallelUploads: 1,
|
parallelUploads: 1,
|
||||||
maxFiles: 10,
|
|
||||||
autoProcessQueue: true,
|
autoProcessQueue: true,
|
||||||
dictDefaultMessage: 'Seret foto atau klik untuk unggah',
|
dictDefaultMessage: 'Seret foto atau klik untuk unggah',
|
||||||
|
|
||||||
@@ -304,101 +304,41 @@
|
|||||||
param_name: paramName,
|
param_name: paramName,
|
||||||
nomor_registrasi: '{{ $permohonan->nomor_registrasi ?? '' }}',
|
nomor_registrasi: '{{ $permohonan->nomor_registrasi ?? '' }}',
|
||||||
},
|
},
|
||||||
error: function(file, response) {
|
|
||||||
Swal.fire({
|
addedfiles: function(files) {
|
||||||
icon: 'error',
|
uploadQueue += files.length;
|
||||||
title: 'Upload Gagal',
|
uploadBatch = Array.from(files);
|
||||||
text: response.message || 'Error tidak diketahui'
|
if (files.length > 0) showLoadingOverlay();
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
error: function(file, response) {
|
||||||
|
handleUploadComplete(file, false, response.message);
|
||||||
|
},
|
||||||
success: function(file, response) {
|
success: function(file, response) {
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
Swal.fire({
|
const fileData = {
|
||||||
icon: 'success',
|
path: response.path || file.path,
|
||||||
title: 'Upload Berhasil',
|
name: file.name,
|
||||||
toast: true,
|
description: '',
|
||||||
position: 'top-end',
|
category: 'lainnya',
|
||||||
showConfirmButton: false,
|
sub: '',
|
||||||
timer: 1500
|
param_name: paramName
|
||||||
});
|
};
|
||||||
updatePhotoGallery();
|
|
||||||
|
addEditAndDeleteButtons(file, fileData);
|
||||||
|
handleUploadComplete(file, true);
|
||||||
|
} else {
|
||||||
|
handleUploadComplete(file, false, response.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
// var myDropzone = this;
|
// var myDropzone = this;
|
||||||
var loadingIndicator = $(`
|
loadExistingPhotos(this, paramName);
|
||||||
<div class="loading-overlay" style="
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background: rgba(255,255,255,0.7);
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
z-index: 1000;
|
|
||||||
">
|
|
||||||
<div class="loader"></div>
|
|
||||||
</div>
|
|
||||||
`);
|
|
||||||
|
|
||||||
var $dropzoneElement = $(selector);
|
|
||||||
$dropzoneElement.css('position', 'relative');
|
|
||||||
$dropzoneElement.append(loadingIndicator);
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: "{{ route('surveyor.getFoto') }}",
|
|
||||||
method: 'GET',
|
|
||||||
data: {
|
|
||||||
permohonan_id: {{ $permohonan->id ?? 0 }},
|
|
||||||
dokument_id: '{{ request('dokument') ?? '' }}',
|
|
||||||
param_name: paramName
|
|
||||||
},
|
|
||||||
headers: {
|
|
||||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
|
||||||
},
|
|
||||||
beforeSend: function() {
|
|
||||||
loadingIndicator.show();
|
|
||||||
},
|
|
||||||
success: function(response) {
|
|
||||||
if (response.fotos && response.fotos.length) {
|
|
||||||
response.fotos.forEach(function(foto) {
|
|
||||||
var mockFile = {
|
|
||||||
name: foto.name,
|
|
||||||
size: foto.size || 12345,
|
|
||||||
originalPath: foto.path
|
|
||||||
};
|
|
||||||
|
|
||||||
myDropzone.emit("addedfile", mockFile);
|
|
||||||
myDropzone.emit("thumbnail", mockFile,
|
|
||||||
foto.path);
|
|
||||||
myDropzone.emit("complete", mockFile);
|
|
||||||
addEditAndDeleteButtons(mockFile, {
|
|
||||||
path: foto.path,
|
|
||||||
name: foto.name,
|
|
||||||
description: foto
|
|
||||||
.description || '',
|
|
||||||
category: foto.category ||
|
|
||||||
'lainnya',
|
|
||||||
sub: foto.sub || '',
|
|
||||||
param_name: paramName
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function(xhr, status, error) {
|
|
||||||
console.error('Gagal memuat foto:', error);
|
|
||||||
},
|
|
||||||
complete: function() {
|
|
||||||
loadingIndicator.hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return myDropzone;
|
return myDropzone;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Dropzone initialization error:', error);
|
console.error('Dropzone initialization error:', error);
|
||||||
@@ -406,29 +346,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updatePhotoGallery() {
|
function loadExistingPhotos(dropzone, paramName) {
|
||||||
const gallery = document.querySelector('#upload-dropzone');
|
showLoadingOverlay();
|
||||||
|
|
||||||
if (!myDropzone) {
|
|
||||||
console.error('Dropzone is not initialized');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
gallery.innerHTML = `
|
|
||||||
<div style="
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background: rgba(255,255,255,0.7);
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
z-index: 1000;">
|
|
||||||
<div class="loader"></div>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{{ route('surveyor.getFoto') }}",
|
url: "{{ route('surveyor.getFoto') }}",
|
||||||
@@ -436,15 +355,13 @@
|
|||||||
data: {
|
data: {
|
||||||
permohonan_id: {{ $permohonan->id ?? 0 }},
|
permohonan_id: {{ $permohonan->id ?? 0 }},
|
||||||
dokument_id: '{{ request('dokument') ?? '' }}',
|
dokument_id: '{{ request('dokument') ?? '' }}',
|
||||||
param_name: 'upload_foto'
|
param_name: paramName
|
||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
if (response.fotos && response.fotos.length) {
|
if (response.fotos && response.fotos.length) {
|
||||||
gallery.innerHTML = '';
|
|
||||||
|
|
||||||
response.fotos.forEach(function(foto) {
|
response.fotos.forEach(function(foto) {
|
||||||
var mockFile = {
|
var mockFile = {
|
||||||
name: foto.name,
|
name: foto.name,
|
||||||
@@ -452,33 +369,119 @@
|
|||||||
originalPath: foto.path
|
originalPath: foto.path
|
||||||
};
|
};
|
||||||
|
|
||||||
myDropzone.emit("addedfile", mockFile);
|
dropzone.emit("addedfile", mockFile);
|
||||||
myDropzone.emit("thumbnail", mockFile, foto.path);
|
dropzone.emit("thumbnail", mockFile, foto.path);
|
||||||
myDropzone.emit("complete", mockFile);
|
dropzone.emit("complete", mockFile);
|
||||||
addEditAndDeleteButtons(mockFile, {
|
addEditAndDeleteButtons(mockFile, {
|
||||||
path: foto.path,
|
path: foto.path,
|
||||||
name: foto.name,
|
name: foto.name,
|
||||||
description: foto.description || '',
|
description: foto.description || '',
|
||||||
category: foto.category || 'lainnya',
|
category: foto.category || 'lainnya',
|
||||||
sub: foto.sub || '',
|
sub: foto.sub || '',
|
||||||
param_name: 'upload_foto'
|
param_name: paramName
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
gallery.innerHTML = '<p>Tidak ada foto yang ditemukan.</p>';
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(xhr, status, error) {
|
error: function(xhr, status, error) {
|
||||||
console.error('Gagal memuat foto:', error);
|
console.error('Gagal memuat foto:', error);
|
||||||
gallery.innerHTML = '<p>Gagal memuat foto. Silakan coba lagi.</p>';
|
showErrorMessage('Gagal memuat foto yang ada');
|
||||||
},
|
},
|
||||||
complete: function() {
|
complete: function() {
|
||||||
gallery.innerHTML = gallery.innerHTML.includes('loader') ? '' : gallery
|
hideLoadingOverlay();
|
||||||
.innerHTML;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleUploadComplete(file, isSuccess, errorMessage = null) {
|
||||||
|
uploadQueue--;
|
||||||
|
const index = uploadBatch.indexOf(file);
|
||||||
|
if (index > -1) {
|
||||||
|
uploadBatch.splice(index, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show individual error if any
|
||||||
|
if (!isSuccess && errorMessage) {
|
||||||
|
showErrorMessage(errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If all uploads are complete
|
||||||
|
if (uploadQueue === 0) {
|
||||||
|
hideLoadingOverlay();
|
||||||
|
|
||||||
|
// Show final status message
|
||||||
|
const totalFiles = uploadBatch.length + 1; // +1 for current file
|
||||||
|
if (totalFiles === 1) {
|
||||||
|
// Single file upload
|
||||||
|
if (isSuccess) {
|
||||||
|
showSuccessMessage('Foto berhasil diupload');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Multiple files upload
|
||||||
|
showSuccessMessage(`${totalFiles} foto berhasil diupload`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset batch
|
||||||
|
uploadBatch = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function showLoadingOverlay() {
|
||||||
|
const overlay = document.querySelector('.loading-overlay');
|
||||||
|
if (!overlay) {
|
||||||
|
// Buat elemen overlay
|
||||||
|
const loadingOverlay = document.createElement('div');
|
||||||
|
loadingOverlay.className = 'loading-overlay';
|
||||||
|
loadingOverlay.style.cssText = `
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: rgba(0, 0, 0, 0.5);
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
z-index: 9999;
|
||||||
|
`;
|
||||||
|
|
||||||
|
// Tambahkan loader di dalam overlay
|
||||||
|
loadingOverlay.innerHTML = '<div class="loader"></div>';
|
||||||
|
|
||||||
|
// Tambahkan overlay ke dalam <body>
|
||||||
|
document.body.appendChild(loadingOverlay);
|
||||||
|
} else {
|
||||||
|
// Tampilkan overlay jika sudah ada
|
||||||
|
overlay.style.display = 'flex';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function hideLoadingOverlay() {
|
||||||
|
const overlay = document.querySelector('.loading-overlay');
|
||||||
|
if (overlay) overlay.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
function showSuccessMessage(message) {
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'success',
|
||||||
|
title: message,
|
||||||
|
toast: true,
|
||||||
|
position: 'top-end',
|
||||||
|
showConfirmButton: false,
|
||||||
|
timer: 1500
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function showErrorMessage(message) {
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'error',
|
||||||
|
title: 'Upload Gagal',
|
||||||
|
text: message || 'Error tidak diketahui'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Inisialisasi Dropzone untuk elemen awal dengan pengecekan
|
// Inisialisasi Dropzone untuk elemen awal dengan pengecekan
|
||||||
function safeInitDropzone(selector, paramName) {
|
function safeInitDropzone(selector, paramName) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -492,15 +495,12 @@
|
|||||||
// Inisialisasi dropzone untuk elemen awal
|
// Inisialisasi dropzone untuk elemen awal
|
||||||
safeInitDropzone('#upload-dropzone', 'upload_foto');
|
safeInitDropzone('#upload-dropzone', 'upload_foto');
|
||||||
|
|
||||||
|
|
||||||
// Event listener untuk menambah lantai
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let fotoObjekJaminan = @json($fotoObjekJaminan);
|
let fotoObjekJaminan = @json($fotoObjekJaminan);
|
||||||
|
|
||||||
// Fungsi untuk membuka modal dan mengatur data
|
// Fungsi untuk membuka modal dan mengatur data
|
||||||
function openEditDataModal(file, response) {
|
window.openEditDrawer = function(file, response) {
|
||||||
// Mengisi data input berdasarkan respons
|
// Mengisi data input berdasarkan respons
|
||||||
document.getElementById('editDataFilePath').value = response.path || '';
|
document.getElementById('editDataFilePath').value = response.path || '';
|
||||||
document.getElementById('editDataName').value = response.name || '';
|
document.getElementById('editDataName').value = response.name || '';
|
||||||
@@ -567,12 +567,10 @@
|
|||||||
cssMaxHeight: 500
|
cssMaxHeight: 500
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// openModal('editPhotoModal');
|
// openModal('editPhotoModal');
|
||||||
}
|
}
|
||||||
|
|
||||||
function addEditAndDeleteButtons(file, response) {
|
window.addEditAndDeleteButtons = function(file, response) {
|
||||||
|
|
||||||
const filePreviewElement = file.previewElement;
|
const filePreviewElement = file.previewElement;
|
||||||
|
|
||||||
@@ -592,7 +590,8 @@
|
|||||||
editButton.style.cursor = 'pointer';
|
editButton.style.cursor = 'pointer';
|
||||||
editButton.setAttribute("data-drawer-toggle", "#drawer_2_2");
|
editButton.setAttribute("data-drawer-toggle", "#drawer_2_2");
|
||||||
editButton.onclick = function() {
|
editButton.onclick = function() {
|
||||||
openEditDataModal(file, response);
|
// e.preventDefault();
|
||||||
|
openEditDrawer(file, response);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Tombol Hapus
|
// Tombol Hapus
|
||||||
|
|||||||
@@ -391,7 +391,7 @@
|
|||||||
value="{{ $inspectionData['asset']['harga'] ?? '' }}">
|
value="{{ $inspectionData['asset']['harga'] ?? '' }}">
|
||||||
</td>
|
</td>
|
||||||
<td class="px-4 py-2">
|
<td class="px-4 py-2">
|
||||||
<input type="text" name="harga_pembanding[]" class="input currency">
|
<input type="text" name="harga_pembanding[]" class="input currency-format">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -34,35 +34,23 @@
|
|||||||
|
|
||||||
|
|
||||||
function formatCurrency(value, isDiskon = false) {
|
function formatCurrency(value, isDiskon = false) {
|
||||||
// Konversi value ke string, pastikan bukan null/undefined
|
// Ensure the value is a valid number
|
||||||
let stringValue = value === null || value === undefined ? '' : String(value);
|
const numericValue = parseFloat(value);
|
||||||
|
if (isNaN(numericValue)) {
|
||||||
// Ganti koma dengan titik untuk memastikan parsing numerik
|
return 0;
|
||||||
stringValue = stringValue.replace(/,/g, '.');
|
|
||||||
|
|
||||||
// Hapus karakter non-numerik kecuali titik
|
|
||||||
let numericValue = stringValue.replace(/[^\d.]/g, '');
|
|
||||||
|
|
||||||
// Parse nilai numerik
|
|
||||||
const parsedValue = parseFloat(numericValue);
|
|
||||||
|
|
||||||
if (isDiskon) {
|
|
||||||
// Format untuk diskon
|
|
||||||
return isNaN(parsedValue) ? '' : parsedValue.toLocaleString('id-ID', {
|
|
||||||
minimumFractionDigits: 0,
|
|
||||||
maximumFractionDigits: 2
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// Format untuk mata uang tanpa desimal
|
|
||||||
return isNaN(parsedValue) ? '' : parsedValue.toLocaleString('id-ID', {
|
|
||||||
minimumFractionDigits: 0,
|
|
||||||
maximumFractionDigits: 0
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Format the number with commas for thousands separators
|
||||||
|
const formattedValue = numericValue.toLocaleString('id-ID', {
|
||||||
|
style: 'currency',
|
||||||
|
currency: 'IDR', // Indonesian Rupiah
|
||||||
|
minimumFractionDigits: isDiskon ? 2 : 0, // Include decimals for discounts
|
||||||
|
maximumFractionDigits: isDiskon ? 2 : 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
return formattedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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();
|
||||||
@@ -338,172 +326,171 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateAnalisa(params) {
|
function updateAnalisa(params) {
|
||||||
const inputMap = {
|
const inputMap = {
|
||||||
jenis_asset: 'jenis_asset_tidak_sesuai',
|
jenis_asset: 'jenis_asset_tidak_sesuai',
|
||||||
analisa_tanah: 'analisa_tanah_tidak_sesuai',
|
analisa_tanah: 'analisa_tanah_tidak_sesuai',
|
||||||
analisa_unit: 'analisa_luas_unit_tidak_sesuai',
|
analisa_unit: 'analisa_luas_unit_tidak_sesuai',
|
||||||
analisa_bangunan: 'analisa_bangunan_tidak_sesuai',
|
analisa_bangunan: 'analisa_bangunan_tidak_sesuai',
|
||||||
};
|
};
|
||||||
|
|
||||||
// Pastikan elemen ID ada di inputMap
|
// Pastikan elemen ID ada di inputMap
|
||||||
if (!inputMap[params]) {
|
if (!inputMap[params]) {
|
||||||
console.error('Parameter tidak valid:', params);
|
console.error('Parameter tidak valid:', params);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ambil nilai berdasarkan parameter
|
||||||
|
const inputValue = document.getElementById(inputMap[params]).value;
|
||||||
|
const data = {
|
||||||
|
[params === 'jenis_asset' ? 'jenis_asset' : params.replace('analisa_', 'luas_')]: inputValue,
|
||||||
|
types: params
|
||||||
|
};
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '{{ route('surveyor.update_analisa', ['id' => $permohonan->id]) }}',
|
||||||
|
type: 'POST',
|
||||||
|
data: data,
|
||||||
|
headers: {
|
||||||
|
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
console.log(response);
|
||||||
|
if (response.success) {
|
||||||
|
// window.location.href =
|
||||||
|
// '{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
|
||||||
|
toastrSuccessBuild(response.message);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
console.error('Terjadi error:', error);
|
||||||
|
console.log('Status:', status);
|
||||||
|
console.log('Response:', xhr.responseText);
|
||||||
|
if (xhr.responseJSON.message) {
|
||||||
|
toastrErrorBuild(xhr.responseJSON.message);
|
||||||
|
} else {
|
||||||
|
toastrErrorBuild('Terjadi kesalahan');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateAlamatFields(status) {
|
||||||
|
// Ambil elemen formulir
|
||||||
|
const addressForm = document.getElementById('alamat_form');
|
||||||
|
const inputs = addressForm.querySelectorAll('input, select');
|
||||||
|
const addressInput = document.getElementById('address');
|
||||||
|
|
||||||
|
if (status === 'sesuai') {
|
||||||
|
addressInput.value = "{{ $dokumen->address ?? '' }}";
|
||||||
|
inputs.forEach(element => {
|
||||||
|
if (element.tagName === 'INPUT') {
|
||||||
|
element.setAttribute('readonly', true);
|
||||||
|
} else if (element.tagName === 'SELECT') {
|
||||||
|
element.setAttribute('disabled', true);
|
||||||
|
element.classList.add('disabled-input')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
addressForm.style.display = 'grid';
|
||||||
|
addressForm.disabled = true;
|
||||||
|
addressForm.classList.add('disabled-input')
|
||||||
|
|
||||||
|
|
||||||
|
} else if (status === 'tidak sesuai') {
|
||||||
|
addressForm.style.display = 'grid';
|
||||||
|
|
||||||
|
addressForm.removeAttribute('disabled');
|
||||||
|
addressForm.classList.remove('disabled-input')
|
||||||
|
const formInspeksi = @json($forminspeksi ?? '');
|
||||||
|
const addressInput = document.getElementById('address');
|
||||||
|
|
||||||
|
if (formInspeksi && formInspeksi.asset && formInspeksi.asset.alamat) {
|
||||||
|
if (formInspeksi.asset.alamat['tidak sesuai'] && formInspeksi.asset.alamat['tidak sesuai'].address) {
|
||||||
|
addressInput.value = formInspeksi.asset.alamat['tidak sesuai'].address;
|
||||||
|
} else if (formInspeksi.asset.alamat['sesuai'] && formInspeksi.asset.alamat['sesuai'].address) {
|
||||||
|
addressInput.value = formInspeksi.asset.alamat['sesuai'].address;
|
||||||
|
} else {
|
||||||
|
addressInput.value = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ambil nilai berdasarkan parameter
|
inputs.forEach(element => {
|
||||||
const inputValue = document.getElementById(inputMap[params]).value;
|
if (element.tagName === 'INPUT') {
|
||||||
const data = {
|
element.removeAttribute('readonly');
|
||||||
[params === 'jenis_asset' ? 'jenis_asset' : params.replace('analisa_', 'luas_')]: inputValue,
|
} else if (element.tagName === 'SELECT') {
|
||||||
types: params
|
element.removeAttribute('disabled');
|
||||||
};
|
element.classList.remove('disabled-input')
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: '{{ route('surveyor.update_analisa', ['id' => $permohonan->id]) }}',
|
|
||||||
type: 'POST',
|
|
||||||
data: data,
|
|
||||||
headers: {
|
|
||||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
|
||||||
},
|
|
||||||
success: function(response) {
|
|
||||||
console.log(response);
|
|
||||||
if (response.success) {
|
|
||||||
// window.location.href =
|
|
||||||
// '{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
|
|
||||||
toastrSuccessBuild(response.message);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function(xhr, status, error) {
|
|
||||||
console.error('Terjadi error:', error);
|
|
||||||
console.log('Status:', status);
|
|
||||||
console.log('Response:', xhr.responseText);
|
|
||||||
if (xhr.responseJSON.message) {
|
|
||||||
toastrErrorBuild(xhr.responseJSON.message);
|
|
||||||
} else {
|
|
||||||
toastrErrorBuild('Terjadi kesalahan');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateAlamatFields(status) {
|
function toggleFieldVisibility(fieldName, inputId, visibleValues = []) {
|
||||||
// Ambil elemen formulir
|
const selectedValue = $(`[name="${fieldName}"]:checked`).val();
|
||||||
const addressForm = document.getElementById('alamat_form');
|
const inputField = $(`#${inputId}`);
|
||||||
const inputs = addressForm.querySelectorAll('input, select');
|
|
||||||
const addressInput = document.getElementById('address');
|
|
||||||
|
|
||||||
if (status === 'sesuai') {
|
if (visibleValues.includes(selectedValue)) {
|
||||||
addressInput.value = "{{ $dokumen->address ?? '' }}";
|
inputField.show();
|
||||||
inputs.forEach(element => {
|
} else {
|
||||||
if (element.tagName === 'INPUT') {
|
inputField.hide().val('');
|
||||||
element.setAttribute('readonly', true);
|
|
||||||
} else if (element.tagName === 'SELECT') {
|
|
||||||
element.setAttribute('disabled', true);
|
|
||||||
element.classList.add('disabled-input')
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
addressForm.style.display = 'grid';
|
|
||||||
addressForm.disabled = true;
|
|
||||||
addressForm.classList.add('disabled-input')
|
|
||||||
|
|
||||||
|
|
||||||
} else if (status === 'tidak sesuai') {
|
|
||||||
addressForm.style.display = 'grid';
|
|
||||||
|
|
||||||
addressForm.removeAttribute('disabled');
|
|
||||||
addressForm.classList.remove('disabled-input')
|
|
||||||
const formInspeksi = @json($forminspeksi ?? '');
|
|
||||||
const addressInput = document.getElementById('address');
|
|
||||||
|
|
||||||
if (formInspeksi && formInspeksi.asset && formInspeksi.asset.alamat) {
|
|
||||||
if (formInspeksi.asset.alamat['tidak sesuai'] && formInspeksi.asset.alamat['tidak sesuai'].address) {
|
|
||||||
addressInput.value = formInspeksi.asset.alamat['tidak sesuai'].address;
|
|
||||||
} else if (formInspeksi.asset.alamat['sesuai'] && formInspeksi.asset.alamat['sesuai'].address) {
|
|
||||||
addressInput.value = formInspeksi.asset.alamat['sesuai'].address;
|
|
||||||
} else {
|
|
||||||
addressInput.value = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inputs.forEach(element => {
|
|
||||||
if (element.tagName === 'INPUT') {
|
|
||||||
element.removeAttribute('readonly');
|
|
||||||
} else if (element.tagName === 'SELECT') {
|
|
||||||
element.removeAttribute('disabled');
|
|
||||||
element.classList.remove('disabled-input')
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function toggleFieldVisibility(fieldName, inputId, visibleValues = []) {
|
|
||||||
const selectedValue = $(`[name="${fieldName}"]:checked`).val();
|
function toggleCheckboxVisibility(fieldName, inputId, visibleValues = []) {
|
||||||
|
const selectedValues = $(`[name="${fieldName}[]"]:checked`)
|
||||||
|
.map(function() {
|
||||||
|
return $(this).val().toLowerCase(); // Konversi nilai ke huruf kecil
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const inputField = $(`#${inputId}`);
|
||||||
|
|
||||||
|
// Cek apakah salah satu nilai yang dipilih cocok dengan visibleValues
|
||||||
|
const shouldShow = visibleValues.some(value => selectedValues.includes(value.toLowerCase()));
|
||||||
|
|
||||||
|
if (shouldShow) {
|
||||||
|
inputField.show();
|
||||||
|
} else {
|
||||||
|
inputField.hide().val('');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function toggleMultipleFields(fieldName, mappings) {
|
||||||
|
// Ambil semua nilai checkbox yang dicentang
|
||||||
|
const selectedValues = $(`[name="${fieldName}[]"]:checked`)
|
||||||
|
.map(function() {
|
||||||
|
return $(this).val().toLowerCase(); // Konversi nilai ke huruf kecil
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
// Iterasi melalui setiap mapping
|
||||||
|
for (const [key, inputId] of Object.entries(mappings)) {
|
||||||
const inputField = $(`#${inputId}`);
|
const inputField = $(`#${inputId}`);
|
||||||
|
|
||||||
if (visibleValues.includes(selectedValue)) {
|
// Tampilkan input jika nilai yang relevan dipilih
|
||||||
|
if (selectedValues.includes(key.toLowerCase())) {
|
||||||
inputField.show();
|
inputField.show();
|
||||||
} else {
|
} else {
|
||||||
inputField.hide().val('');
|
inputField.hide().val(''); // Sembunyikan dan reset nilai
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function toggleCheckboxVisibility(fieldName, inputId, visibleValues = []) {
|
function toggleAlamatVisibility(idSesuai, idTidakSesuai, selectedValue) {
|
||||||
const selectedValues = $(`[name="${fieldName}[]"]:checked`)
|
// Ambil elemen berdasarkan ID
|
||||||
.map(function() {
|
const alamatSesuai = document.getElementById(idSesuai);
|
||||||
return $(this).val().toLowerCase(); // Konversi nilai ke huruf kecil
|
const alamatTidakSesuai = document.getElementById(idTidakSesuai);
|
||||||
})
|
|
||||||
.get();
|
|
||||||
|
|
||||||
const inputField = $(`#${inputId}`);
|
// Periksa nilai yang dipilih dan tampilkan elemen yang sesuai
|
||||||
|
if (selectedValue === 'sesuai') {
|
||||||
// Cek apakah salah satu nilai yang dipilih cocok dengan visibleValues
|
alamatSesuai.style.display = 'grid'; // Tampilkan "Alamat Sesuai"
|
||||||
const shouldShow = visibleValues.some(value => selectedValues.includes(value.toLowerCase()));
|
alamatTidakSesuai.style.display = 'none'; // Sembunyikan "Alamat Tidak Sesuai"
|
||||||
|
} else if (selectedValue === 'tidak sesuai') {
|
||||||
if (shouldShow) {
|
alamatSesuai.style.display = 'none'; // Sembunyikan "Alamat Sesuai"
|
||||||
inputField.show();
|
alamatTidakSesuai.style.display = 'grid'; // Tampilkan "Alamat Tidak Sesuai"
|
||||||
} else {
|
|
||||||
inputField.hide().val('');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function toggleMultipleFields(fieldName, mappings) {
|
|
||||||
// Ambil semua nilai checkbox yang dicentang
|
|
||||||
const selectedValues = $(`[name="${fieldName}[]"]:checked`)
|
|
||||||
.map(function() {
|
|
||||||
return $(this).val().toLowerCase(); // Konversi nilai ke huruf kecil
|
|
||||||
})
|
|
||||||
.get();
|
|
||||||
|
|
||||||
// Iterasi melalui setiap mapping
|
|
||||||
for (const [key, inputId] of Object.entries(mappings)) {
|
|
||||||
const inputField = $(`#${inputId}`);
|
|
||||||
|
|
||||||
// Tampilkan input jika nilai yang relevan dipilih
|
|
||||||
if (selectedValues.includes(key.toLowerCase())) {
|
|
||||||
inputField.show();
|
|
||||||
} else {
|
|
||||||
inputField.hide().val(''); // Sembunyikan dan reset nilai
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function toggleAlamatVisibility(idSesuai, idTidakSesuai, selectedValue) {
|
|
||||||
// Ambil elemen berdasarkan ID
|
|
||||||
const alamatSesuai = document.getElementById(idSesuai);
|
|
||||||
const alamatTidakSesuai = document.getElementById(idTidakSesuai);
|
|
||||||
|
|
||||||
// Periksa nilai yang dipilih dan tampilkan elemen yang sesuai
|
|
||||||
if (selectedValue === 'sesuai') {
|
|
||||||
alamatSesuai.style.display = 'grid'; // Tampilkan "Alamat Sesuai"
|
|
||||||
alamatTidakSesuai.style.display = 'none'; // Sembunyikan "Alamat Tidak Sesuai"
|
|
||||||
} else if (selectedValue === 'tidak sesuai') {
|
|
||||||
alamatSesuai.style.display = 'none'; // Sembunyikan "Alamat Sesuai"
|
|
||||||
alamatTidakSesuai.style.display = 'grid'; // Tampilkan "Alamat Tidak Sesuai"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user