fix(surveyor/penilai): perbaikkan data pembanding dan tambah tombol freaze di penilai
This commit is contained in:
@@ -79,42 +79,38 @@
|
||||
let columnCount = 1;
|
||||
// Fungsi calculate prices yang diperbaiki
|
||||
function calculatePrices(type = 'main', index = null) {
|
||||
let hargaInput, diskonInput, totalInput, hargaDiskonInput, hargaPenawaranInput;
|
||||
let hargaInput, diskonInput, totalInput, hargaDiskonInput;
|
||||
|
||||
// Tentukan input berdasarkan tipe (main atau pembanding)
|
||||
if (type === 'main') {
|
||||
hargaPenawaranInput = document.querySelector('input[name="harga_penawaran"]');
|
||||
// hargaPenawaranInput = document.querySelector('input[name="harga_penawaran"]');
|
||||
hargaInput = document.querySelector('input[name="harga"]');
|
||||
diskonInput = document.querySelector('input[name="diskon"]');
|
||||
totalInput = document.querySelector('input[name="total"]');
|
||||
hargaDiskonInput = document.querySelector('input[name="harga_diskon"]');
|
||||
} else {
|
||||
// Untuk pembanding, gunakan array input dengan index
|
||||
const hargaPenawarans = document.getElementsByName('harga_penawaran_pembanding[]');
|
||||
|
||||
const hargaInputs = document.getElementsByName('harga_pembanding[]');
|
||||
const diskonInputs = document.getElementsByName('diskon_pembanding[]');
|
||||
const totalInputs = document.getElementsByName('total_pembanding[]');
|
||||
const hargaDiskonInputs = document.getElementsByName('harga_diskon_pembanding[]');
|
||||
|
||||
|
||||
// Pastikan index valid
|
||||
if (index !== null && index < hargaInputs.length) {
|
||||
hargaPenawaranInput = hargaPenawarans[index]
|
||||
// hargaPenawaranInput = hargaPenawarans[index]
|
||||
hargaInput = hargaInputs[index];
|
||||
diskonInput = diskonInputs[index];
|
||||
totalInput = totalInputs[index];
|
||||
hargaDiskonInput = hargaDiskonInputs[index];
|
||||
// hargaDiskonInput = hargaDiskonInputs[index];
|
||||
} else {
|
||||
return; // Keluar jika index tidak valid
|
||||
}
|
||||
}
|
||||
|
||||
// Validasi input
|
||||
if (!hargaPenawaranInput || !hargaInput || !diskonInput || !totalInput || !hargaDiskonInput) {
|
||||
if (!hargaInput || !diskonInput || !totalInput) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Ambil nilai numerik dari input
|
||||
const hargaPenawaran = parseFloat(hargaPenawaranInput.value.replace(/[^\d]/g, '') || '0');
|
||||
const harga = parseFloat(hargaInput.value.replace(/[^\d]/g, '') || '0');
|
||||
let diskonInput_value = diskonInput.value.replace(',', '.');
|
||||
let diskon = parseFloat(diskonInput_value.replace(/[^\d.]/g, '') || '0');
|
||||
@@ -123,13 +119,15 @@
|
||||
// Batasi diskon maksimal 100%
|
||||
diskon = Math.min(diskon, 100);
|
||||
|
||||
|
||||
const total = harga;
|
||||
const hargaPermeterSetelahDiskon = harga - (harga * (diskon / 100))
|
||||
const hargaSetelahDiskon = hargaPenawaran - (hargaPenawaran * (diskon / 100));
|
||||
|
||||
console.log(hargaPermeterSetelahDiskon);
|
||||
|
||||
// Update nilai dengan format currency
|
||||
totalInput.value = formatCurrency(hargaPermeterSetelahDiskon.toString());
|
||||
hargaDiskonInput.value = formatCurrency(hargaSetelahDiskon.toString());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +215,7 @@
|
||||
'telepon_pembanding[]': currentData.telepon,
|
||||
'penawaran_pembanding[]': currentData.penawaran,
|
||||
'tanggal_pembanding[]': currentData.tanggal,
|
||||
'harga_penawaran_pembanding[]':currentData.harga_penawaran
|
||||
// 'harga_penawaran_pembanding[]':currentData.harga_penawaran
|
||||
|
||||
};
|
||||
|
||||
@@ -267,15 +265,15 @@
|
||||
function initializePriceCalculation() {
|
||||
// Event listener untuk input utama
|
||||
const mainHargaInput = document.querySelector('input[name="harga"]');
|
||||
const mainHargaPenawaranInput = document.querySelector('input[name="harga_penawaran"]');
|
||||
// const mainHargaPenawaranInput = document.querySelector('input[name="harga_penawaran"]');
|
||||
const mainDiskonInput = document.querySelector('input[name="diskon"]');
|
||||
|
||||
if (mainHargaInput) {
|
||||
mainHargaInput.addEventListener('input', () => calculatePrices('main'));
|
||||
}
|
||||
if (mainHargaPenawaranInput) {
|
||||
mainHargaPenawaranInput.addEventListener('input', () => calculatePrices('main'));
|
||||
}
|
||||
// if (mainHargaPenawaranInput) {
|
||||
// mainHargaPenawaranInput.addEventListener('input', () => calculatePrices('main'));
|
||||
// }
|
||||
|
||||
if (mainDiskonInput) {
|
||||
mainDiskonInput.addEventListener('input', () => calculatePrices('main'));
|
||||
@@ -283,7 +281,7 @@
|
||||
|
||||
// Event listener untuk input pembanding
|
||||
const pembandingHargaInputs = document.getElementsByName('harga_pembanding[]');
|
||||
const pembandingHargaPenawaranInput = document.getElementsByName('harga_penawaran_pembanding[]');
|
||||
// const pembandingHargaPenawaranInput = document.getElementsByName('harga_penawaran_pembanding[]');
|
||||
|
||||
|
||||
const pembandingDiskonInputs = document.getElementsByName('diskon_pembanding[]');
|
||||
@@ -291,9 +289,9 @@
|
||||
pembandingHargaInputs.forEach((input, index) => {
|
||||
input.addEventListener('input', () => calculatePrices('pembanding', index));
|
||||
});
|
||||
pembandingHargaPenawaranInput.forEach((input, index) => {
|
||||
input.addEventListener('input', () => calculatePrices('pembanding', index));
|
||||
});
|
||||
// pembandingHargaPenawaranInput.forEach((input, index) => {
|
||||
// input.addEventListener('input', () => calculatePrices('pembanding', index));
|
||||
// });
|
||||
|
||||
pembandingDiskonInputs.forEach((input, index) => {
|
||||
input.addEventListener('input', () => calculatePrices('pembanding', index));
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
@endphp
|
||||
<td class="px-4 py-2">
|
||||
<input type="text" name="luas_tanah" class="input "
|
||||
value="{{ $inspectionData['tanah']['luas_tanah']['sesuai'] ?? ($inspectionData['tanah']['luas_tanah']['tidak sesuai'] ?? '') }}">
|
||||
value="{{ $inspectionData['tanah']['luas_tanah']['sesuai'] ?? ($inspectionData['tanah']['luas_tanah']['tidak sesuai'] ?? '') }}">
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
|
||||
@@ -188,7 +188,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
{{-- <tr>
|
||||
<td class="px-4 py-2">Harga Penawaran/ Transaksi(Rp)</td>
|
||||
<td class="px-4 py-2">
|
||||
<input type="text" name="harga_penawaran" class="input currency-format"
|
||||
@@ -197,7 +197,7 @@
|
||||
<td class="px-4 py-2">
|
||||
<input type="text" name="harga_penawaran_pembanding[]" class="input currency-format">
|
||||
</td>
|
||||
</tr>
|
||||
</tr> --}}
|
||||
|
||||
|
||||
<tr>
|
||||
@@ -412,11 +412,11 @@
|
||||
</tr>
|
||||
|
||||
<tr class="bg-gray-100">
|
||||
<td colspan="3" class="px-4 py-2 font-semibold">Harga Per Meter</td>
|
||||
<td colspan="3" class="px-4 py-2 font-semibold">Harga</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="px-4 py-2">Harga</td>
|
||||
<td class="px-4 py-2">Harga Penawaran/ Transaksi(Rp)</td>
|
||||
<td class="px-4 py-2">
|
||||
<input type="text" name="harga" class="input currency-format"
|
||||
value="{{ $inspectionData['asset']['harga'] ?? '' }}">
|
||||
@@ -448,8 +448,8 @@
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="">
|
||||
<td class="px-4 py-2"></td>
|
||||
{{-- <tr style="">
|
||||
<td class="px-4 py-2">Harga Setelah Diskon</td>
|
||||
<td class="px-4 py-2">
|
||||
<input type="text" name="total" class="input currency"
|
||||
value="{{ $inspectionData['asset']['total'] ?? '' }}" readonly>
|
||||
@@ -457,15 +457,15 @@
|
||||
<td class="px-4 py-2">
|
||||
<input type="text" name="total_pembanding[]" class="input currency-format" readonly>
|
||||
</td>
|
||||
</tr>
|
||||
</tr> --}}
|
||||
<tr>
|
||||
<td class="px-4 py-2">Harga Setelah Diskon</td>
|
||||
<td class="px-4 py-2">
|
||||
<input type="text" name="harga_diskon" class="input currency-format" readonly
|
||||
value="{{ $inspectionData['asset']['harga_diskon'] ?? '' }}">
|
||||
<input type="text" name="total" class="input currency-format" readonly
|
||||
value="{{ $inspectionData['asset']['total'] ?? '' }}">
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
<input type="text" name="harga_diskon_pembanding[]" readonly
|
||||
<input type="text" name="total_pembanding[]" readonly
|
||||
class="input currency-format">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -104,56 +104,6 @@
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
|
||||
<script>
|
||||
function surveyorFreeze(permohonanId, noReg, debitur) {
|
||||
|
||||
Swal.fire({
|
||||
title: 'Apakah Anda yakin?',
|
||||
text: "Yakin akan Request Freeze dengan " + noReg + " untuk Debitur " + debitur +
|
||||
" ?",
|
||||
icon: 'warning',
|
||||
input: 'textarea',
|
||||
inputLabel: 'Keterangan',
|
||||
inputPlaceholder: 'Masukkan keterangan...',
|
||||
inputAttributes: {
|
||||
'aria-label': 'Masukkan keterangan'
|
||||
},
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Ya, Lanjutkan!',
|
||||
cancelButtonText: 'Batal',
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
const userMessage = result.value || ''; // Ambil pesan dari textarea
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
},
|
||||
});
|
||||
$.ajax({
|
||||
url: `/surveyor/storeFreeze/${permohonanId}`,
|
||||
type: 'POST',
|
||||
data: {
|
||||
message: userMessage
|
||||
},
|
||||
success: (response) => {
|
||||
Swal.fire('Berhasil!',
|
||||
response.message,
|
||||
'success').then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
console.log(response);
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Error:', error);
|
||||
Swal.fire('Gagal!', 'Terjadi kesalahan saat melakukan Freeze.',
|
||||
'error');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function approveReschedule(penilaianId, permohonanId, noReg, debitur, reschedule_date, reschedule_note) {
|
||||
Swal.fire({
|
||||
@@ -223,7 +173,8 @@
|
||||
_token: token,
|
||||
permohonan_id: permohonanId,
|
||||
nomor_registrasi: noReg,
|
||||
rejected_note: rejectResult.value
|
||||
rejected_note: rejectResult.value,
|
||||
keterangan: rejectResult.value
|
||||
}
|
||||
$.ajax({
|
||||
url: useURL,
|
||||
@@ -642,12 +593,7 @@
|
||||
title="Lihat Form Inspeksi">
|
||||
<i class="ki-outline ki-eye"></i>
|
||||
</a>
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-icon btn-clear btn-info"
|
||||
onclick="surveyorFreeze('${data.id}', '${data.nomor_registrasi}', '${data.debiture?.name}')"
|
||||
title="Freeze Survey">
|
||||
<i class="ki-filled ki-arrow-circle-right"></i>
|
||||
</button>
|
||||
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user