fix(surveyor): perbaikan luas tanah, bangunan, unit not found

This commit is contained in:
majid
2025-03-04 09:36:15 +07:00
parent 5c4eb4eebb
commit e12114c3e4
6 changed files with 105 additions and 50 deletions

View File

@@ -27,39 +27,39 @@
function formatNumber(input) {
// Ambil posisi kursor saat ini
const cursorPosition = input.selectionStart;
// Ambil posisi kursor saat ini
const cursorPosition = input.selectionStart;
// Ambil nilai input tanpa "m²" dan karakter non-angka
let value = input.value.replace(/[^\d]/g, '');
// Ambil nilai input tanpa "m²" dan karakter non-angka
let value = input.value.replace(/[^\d]/g, '');
// Update nilai input dengan format angka dan "m²"
input.value = value ? value + ' m²' : 'm²';
// Update nilai input dengan format angka dan "m²"
input.value = value ? value + ' m²' : 'm²';
// Atur posisi kursor di depan "m²"
input.setSelectionRange(cursorPosition, cursorPosition);
}
// Atur posisi kursor di depan "m²"
input.setSelectionRange(cursorPosition, cursorPosition);
}
function formatCurrency(value, isDiskon = false) {
// Ensure the value is a valid number
const numericValue = parseFloat(value);
if (isNaN(numericValue)) {
return 0;
// Ensure the value is a valid number
const numericValue = parseFloat(value);
if (isNaN(numericValue)) {
return 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;
}
// 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) {
if (input.files && input.files[0]) {
var reader = new FileReader();
@@ -352,9 +352,24 @@
const inputValue = document.getElementById(inputMap[params]).value;
const data = {
[params === 'jenis_asset' ? 'jenis_asset' : params.replace('analisa_', 'luas_')]: inputValue,
types: params
types: params,
...(document.getElementById('jenis_legalistas_jaminan_bangunan_id') && {
jenis_legalistas_jaminan_bangunan_id: document.getElementById(
'jenis_legalistas_jaminan_bangunan_id').value
}),
...(document.getElementById('jenis_legalistas_jaminan_tanah_id') && {
jenis_legalistas_jaminan_tanah_id: document.getElementById('jenis_legalistas_jaminan_tanah_id')
.value
}),
...(document.getElementById('jenis_legalistas_jaminan_unit_id') && {
jenis_legalistas_jaminan_unit_id: document.getElementById('jenis_legalistas_jaminan_unit_id')
.value
})
};
console.log(data);
$.ajax({
url: '{{ route('surveyor.update_analisa', ['id' => $permohonan->id]) }}',
type: 'POST',
@@ -505,9 +520,9 @@
function handleCurrencyInput(input) {
const value = input.value.replace(/[^\d]/g, '');
input.value = formatCurrency(value);
}
const value = input.value.replace(/[^\d]/g, '');
input.value = formatCurrency(value);
}
function cleanCurrencyValue(value) {
return value.replace(/[^\d]/g, '');