fix(surveyorr): perbaikan upload foto dan pembanding
This commit is contained in:
@@ -82,6 +82,7 @@ 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;
|
use Modules\Lpj\Models\Authorization;
|
||||||
|
|
||||||
class SurveyorController extends Controller
|
class SurveyorController extends Controller
|
||||||
{
|
{
|
||||||
public $user;
|
public $user;
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -291,7 +291,6 @@
|
|||||||
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',
|
||||||
|
|
||||||
@@ -430,28 +429,34 @@
|
|||||||
function showLoadingOverlay() {
|
function showLoadingOverlay() {
|
||||||
const overlay = document.querySelector('.loading-overlay');
|
const overlay = document.querySelector('.loading-overlay');
|
||||||
if (!overlay) {
|
if (!overlay) {
|
||||||
const dropzoneElement = document.querySelector('#upload-dropzone');
|
// Buat elemen overlay
|
||||||
const loadingOverlay = document.createElement('div');
|
const loadingOverlay = document.createElement('div');
|
||||||
loadingOverlay.className = 'loading-overlay';
|
loadingOverlay.className = 'loading-overlay';
|
||||||
loadingOverlay.style.cssText = `
|
loadingOverlay.style.cssText = `
|
||||||
position: absolute;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background: rgba(255,255,255,0.7);
|
background: rgba(0, 0, 0, 0.5);
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
z-index: 1000;
|
z-index: 9999;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
// Tambahkan loader di dalam overlay
|
||||||
loadingOverlay.innerHTML = '<div class="loader"></div>';
|
loadingOverlay.innerHTML = '<div class="loader"></div>';
|
||||||
dropzoneElement.appendChild(loadingOverlay);
|
|
||||||
|
// Tambahkan overlay ke dalam <body>
|
||||||
|
document.body.appendChild(loadingOverlay);
|
||||||
} else {
|
} else {
|
||||||
|
// Tampilkan overlay jika sudah ada
|
||||||
overlay.style.display = 'flex';
|
overlay.style.display = 'flex';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function hideLoadingOverlay() {
|
function hideLoadingOverlay() {
|
||||||
const overlay = document.querySelector('.loading-overlay');
|
const overlay = document.querySelector('.loading-overlay');
|
||||||
if (overlay) overlay.style.display = 'none';
|
if (overlay) overlay.style.display = 'none';
|
||||||
|
|||||||
@@ -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();
|
||||||
@@ -505,5 +493,4 @@
|
|||||||
alamatTidakSesuai.style.display = 'grid'; // Tampilkan "Alamat Tidak Sesuai"
|
alamatTidakSesuai.style.display = 'grid'; // Tampilkan "Alamat Tidak Sesuai"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user