fix(surveyor/penilai): perbaikkan data pembanding dan tambah tombol freaze di penilai

This commit is contained in:
majid
2025-03-05 05:15:50 +07:00
parent ad3ef0883b
commit f1f345707a
9 changed files with 117 additions and 109 deletions

View File

@@ -653,7 +653,7 @@ class PenilaiController extends Controller
'permohonan_id' => 'required|integer', 'permohonan_id' => 'required|integer',
'document_id' => 'required|integer', 'document_id' => 'required|integer',
'inspeksi_id' => 'required|integer', 'inspeksi_id' => 'required|integer',
'kertas_kerja' => 'required|file|mimes:pdf,doc,docx,xls,xlsx,xlsx', 'kertas_kerja' => 'required|file|mimes:pdf',
]); ]);
try { try {

View File

@@ -448,6 +448,7 @@ class PermohonanController extends Controller
'nomor_registrasi' => 'required', 'nomor_registrasi' => 'required',
'reschedule_note' => 'required', 'reschedule_note' => 'required',
'reschedule_date' => 'required', 'reschedule_date' => 'required',
'keterangan' => 'required'
]); ]);
DB::beginTransaction(); DB::beginTransaction();

View File

@@ -2479,6 +2479,11 @@ class SurveyorController extends Controller
: ($data['hadap_mata_angin_tidak_sesuai'] ?? null); : ($data['hadap_mata_angin_tidak_sesuai'] ?? null);
$hadap_mata_angin[$hadap_mata_angin_key] = $hasil_hadap_mata_angin; $hadap_mata_angin[$hadap_mata_angin_key] = $hasil_hadap_mata_angin;
$tusuk_sate_key = ($data['tusuk_sate'] ?? null) === 'Ya' ? 'Ya' : 'Tidak';
$tusuk_sate = [];
$tusuk_sate[$tusuk_sate_key] = $data['tusuk_sate_ya'] ?? null;
return [ return [
'tanah' => [ 'tanah' => [
@@ -2505,7 +2510,7 @@ class SurveyorController extends Controller
'lainnya' 'lainnya'
), ),
'tusuk_sate' => $data['tusuk_sate'] ?? null, 'tusuk_sate' => $tusuk_sate,
'lockland' => $data['lockland'] ?? null, 'lockland' => $data['lockland'] ?? null,
'kondisi_fisik_tanah' => $this->getFieldData( 'kondisi_fisik_tanah' => $this->getFieldData(
$data, $data,
@@ -3620,6 +3625,8 @@ class SurveyorController extends Controller
// Generate PDF // Generate PDF
$pdf = PDF::loadView($templateView, compact('permohonan', 'basicData', 'forminspeksi', 'alamat')); $pdf = PDF::loadView($templateView, compact('permohonan', 'basicData', 'forminspeksi', 'alamat'));
$pdf = view($templateView, compact('permohonan', 'basicData', 'forminspeksi', 'alamat'));
$pdf->setPaper('A4', 'portrait'); $pdf->setPaper('A4', 'portrait');
// Tentukan nama file PDF // Tentukan nama file PDF
@@ -3681,6 +3688,7 @@ class SurveyorController extends Controller
'permohonan_id' => 'required|exists:permohonan,id', 'permohonan_id' => 'required|exists:permohonan,id',
'rejected_note' => 'required|string|max:255', 'rejected_note' => 'required|string|max:255',
'nomor_registrasi' => 'required|string', 'nomor_registrasi' => 'required|string',
'keterangan' => 'required|string',
]); ]);
// Memulai transaksi // Memulai transaksi

View File

@@ -194,9 +194,15 @@
if (data.status === 'survey-completed' || data.status === 'proses-laporan' || data.status === 'paparan' || data.status === 'proses-paparan' || data.status === 'paparan' || data.status == 'revisi-laporan' || data.status === 'done' || data.status === 'revisi-paparan') { if (data.status === 'survey-completed' || data.status === 'proses-laporan' || data.status === 'paparan' || data.status === 'proses-paparan' || data.status === 'paparan' || data.status == 'revisi-laporan' || data.status === 'done' || data.status === 'revisi-paparan') {
return ` return `
<div class="flex flex-nowrap justify-center gap-1.5"> <div class="flex flex-nowrap justify-center gap-1.5">
<a class="btn btn-sm btn-outline btn-info" href="penilai/${data.id}/show"> <a class="btn btn-sm btn-icon btn-clear btn-info" href="penilai/${data.id}/show">
<i class="ki-outline ki-eye"></i> <i class="ki-outline ki-eye"></i>
</a> </a>
<button type="button"
class="btn btn-sm btn-icon btn-clear btn-warning"
onclick="surveyorFreeze('${data.id}', '${data.nomor_registrasi}', '${data.debiture?.name}')"
title="Freeze SLA">
<i class="ki-filled ki-arrow-circle-right"></i>
</button>
</div>`; </div>`;
} else { } else {
return `<div class="flex flex-nowrap justify-center"> return `<div class="flex flex-nowrap justify-center">
@@ -221,6 +227,57 @@
</script> </script>
<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 showLoadingSwal(message, duration = 5000) { function showLoadingSwal(message, duration = 5000) {
Swal.fire({ Swal.fire({
title: message, title: message,

View File

@@ -400,17 +400,13 @@
onclick="uploadKertasKerja({{ $permohonan->id }}, '{{ $documentId }}', '{{ $inspeksiId }}', '{{ $jenisJaminanId }}')">Upload</button> onclick="uploadKertasKerja({{ $permohonan->id }}, '{{ $documentId }}', '{{ $inspeksiId }}', '{{ $jenisJaminanId }}')">Upload</button>
</div> </div>
</div> </div>
{{-- <div class="form-group flex items-baseline flex-wrap"> <div class="flex justify-between items-center">
@if ($permohonan->penilai->kertas_kerja)
@if ($jenisJaminanId) <span data-modal-dismiss="true" class="btn btn-warning btn-outline"
<a class="btn btn-outline btn-primary w-full" onclick="viewPDF('{{ Storage::url($permohonan->penilai->kertas_kerja) }}')"><i
href="{{ route('penilai.export.kertas-kerja') }}?permohonanId={{ $permohonan->id }}&documentId={{ $documentId }}&inspeksiId={{ $inspeksiId }}&jaminanId={{ $jenisJaminanId }}"> class="ki-filled ki-eye mr-2"></i>Lihat Kertas Kerja</span>
Export Kertas Kerja @endif
</a> </div>
@else
<p class="text-red-500">Tidak ada dokumen yang memiliki jenis jaminan.</p>
@endif
</div> --}}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
@@ -420,6 +416,7 @@
</div> </div>
@endsection @endsection
@include('lpj::component.pdfviewer')
<script> <script>
function seletSederhanaStandart(permohonanId, documentId, inspeksiId, jaminanId, fasilitasKredit, statusBayar) { function seletSederhanaStandart(permohonanId, documentId, inspeksiId, jaminanId, fasilitasKredit, statusBayar) {

View File

@@ -209,10 +209,10 @@
<a onclick="surveyorRescheduleJadwalSurvey( <a onclick="surveyorRescheduleJadwalSurvey(
${data.id}, ${data.id},
${data.penilaian.id}, ${data.penilaian.id},
${data.nomor_registrasi}, '${data.nomor_registrasi}',
${data.debiture.name}, '${data.debiture ? data.debiture.name.replace(/'/g, "\\'") : ""}',
${data.penilaian.waktu_penilaian}, '${data.penilaian.waktu_penilaian}',
${JSON.stringify(data.penilaian.rejected_note)} '${data.penilaian.rejected_note ? JSON.stringify(data.penilaian.rejected_note).replace(/'/g, "\\'").replace(/"/g, '&quot;') : '{}'}'
)" class="delete btn btn-sm btn-outline btn-light" title="Reschedule Jadwal Survey"> )" class="delete btn btn-sm btn-outline btn-light" title="Reschedule Jadwal Survey">
<i class="ki-filled ki-calendar-remove"></i> <i class="ki-filled ki-calendar-remove"></i>
</a>`; </a>`;
@@ -379,7 +379,8 @@
nomor_registrasi: noReg, nomor_registrasi: noReg,
permohonan_id: permohonanId, permohonan_id: permohonanId,
reschedule_date: rescheduleDate, reschedule_date: rescheduleDate,
reschedule_note: rescheduleNote reschedule_note: rescheduleNote,
keterangan: rejectedNote
}; };
$.ajax({ $.ajax({

View File

@@ -79,42 +79,38 @@
let columnCount = 1; let columnCount = 1;
// Fungsi calculate prices yang diperbaiki // Fungsi calculate prices yang diperbaiki
function calculatePrices(type = 'main', index = null) { function calculatePrices(type = 'main', index = null) {
let hargaInput, diskonInput, totalInput, hargaDiskonInput, hargaPenawaranInput; let hargaInput, diskonInput, totalInput, hargaDiskonInput;
// Tentukan input berdasarkan tipe (main atau pembanding) // Tentukan input berdasarkan tipe (main atau pembanding)
if (type === 'main') { if (type === 'main') {
hargaPenawaranInput = document.querySelector('input[name="harga_penawaran"]'); // hargaPenawaranInput = document.querySelector('input[name="harga_penawaran"]');
hargaInput = document.querySelector('input[name="harga"]'); hargaInput = document.querySelector('input[name="harga"]');
diskonInput = document.querySelector('input[name="diskon"]'); diskonInput = document.querySelector('input[name="diskon"]');
totalInput = document.querySelector('input[name="total"]'); totalInput = document.querySelector('input[name="total"]');
hargaDiskonInput = document.querySelector('input[name="harga_diskon"]');
} else { } else {
// Untuk pembanding, gunakan array input dengan index
const hargaPenawarans = document.getElementsByName('harga_penawaran_pembanding[]');
const hargaInputs = document.getElementsByName('harga_pembanding[]'); const hargaInputs = document.getElementsByName('harga_pembanding[]');
const diskonInputs = document.getElementsByName('diskon_pembanding[]'); const diskonInputs = document.getElementsByName('diskon_pembanding[]');
const totalInputs = document.getElementsByName('total_pembanding[]'); const totalInputs = document.getElementsByName('total_pembanding[]');
const hargaDiskonInputs = document.getElementsByName('harga_diskon_pembanding[]');
// Pastikan index valid // Pastikan index valid
if (index !== null && index < hargaInputs.length) { if (index !== null && index < hargaInputs.length) {
hargaPenawaranInput = hargaPenawarans[index] // hargaPenawaranInput = hargaPenawarans[index]
hargaInput = hargaInputs[index]; hargaInput = hargaInputs[index];
diskonInput = diskonInputs[index]; diskonInput = diskonInputs[index];
totalInput = totalInputs[index]; totalInput = totalInputs[index];
hargaDiskonInput = hargaDiskonInputs[index]; // hargaDiskonInput = hargaDiskonInputs[index];
} else { } else {
return; // Keluar jika index tidak valid return; // Keluar jika index tidak valid
} }
} }
// Validasi input // Validasi input
if (!hargaPenawaranInput || !hargaInput || !diskonInput || !totalInput || !hargaDiskonInput) { if (!hargaInput || !diskonInput || !totalInput) {
return; return;
} }
// Ambil nilai numerik dari input
const hargaPenawaran = parseFloat(hargaPenawaranInput.value.replace(/[^\d]/g, '') || '0');
const harga = parseFloat(hargaInput.value.replace(/[^\d]/g, '') || '0'); const harga = parseFloat(hargaInput.value.replace(/[^\d]/g, '') || '0');
let diskonInput_value = diskonInput.value.replace(',', '.'); let diskonInput_value = diskonInput.value.replace(',', '.');
let diskon = parseFloat(diskonInput_value.replace(/[^\d.]/g, '') || '0'); let diskon = parseFloat(diskonInput_value.replace(/[^\d.]/g, '') || '0');
@@ -123,13 +119,15 @@
// Batasi diskon maksimal 100% // Batasi diskon maksimal 100%
diskon = Math.min(diskon, 100); diskon = Math.min(diskon, 100);
const total = harga; const total = harga;
const hargaPermeterSetelahDiskon = harga - (harga * (diskon / 100)) const hargaPermeterSetelahDiskon = harga - (harga * (diskon / 100))
const hargaSetelahDiskon = hargaPenawaran - (hargaPenawaran * (diskon / 100));
console.log(hargaPermeterSetelahDiskon);
// Update nilai dengan format currency // Update nilai dengan format currency
totalInput.value = formatCurrency(hargaPermeterSetelahDiskon.toString()); totalInput.value = formatCurrency(hargaPermeterSetelahDiskon.toString());
hargaDiskonInput.value = formatCurrency(hargaSetelahDiskon.toString());
} }
@@ -217,7 +215,7 @@
'telepon_pembanding[]': currentData.telepon, 'telepon_pembanding[]': currentData.telepon,
'penawaran_pembanding[]': currentData.penawaran, 'penawaran_pembanding[]': currentData.penawaran,
'tanggal_pembanding[]': currentData.tanggal, 'tanggal_pembanding[]': currentData.tanggal,
'harga_penawaran_pembanding[]':currentData.harga_penawaran // 'harga_penawaran_pembanding[]':currentData.harga_penawaran
}; };
@@ -267,15 +265,15 @@
function initializePriceCalculation() { function initializePriceCalculation() {
// Event listener untuk input utama // Event listener untuk input utama
const mainHargaInput = document.querySelector('input[name="harga"]'); 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"]'); const mainDiskonInput = document.querySelector('input[name="diskon"]');
if (mainHargaInput) { if (mainHargaInput) {
mainHargaInput.addEventListener('input', () => calculatePrices('main')); mainHargaInput.addEventListener('input', () => calculatePrices('main'));
} }
if (mainHargaPenawaranInput) { // if (mainHargaPenawaranInput) {
mainHargaPenawaranInput.addEventListener('input', () => calculatePrices('main')); // mainHargaPenawaranInput.addEventListener('input', () => calculatePrices('main'));
} // }
if (mainDiskonInput) { if (mainDiskonInput) {
mainDiskonInput.addEventListener('input', () => calculatePrices('main')); mainDiskonInput.addEventListener('input', () => calculatePrices('main'));
@@ -283,7 +281,7 @@
// Event listener untuk input pembanding // Event listener untuk input pembanding
const pembandingHargaInputs = document.getElementsByName('harga_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[]'); const pembandingDiskonInputs = document.getElementsByName('diskon_pembanding[]');
@@ -291,9 +289,9 @@
pembandingHargaInputs.forEach((input, index) => { pembandingHargaInputs.forEach((input, index) => {
input.addEventListener('input', () => calculatePrices('pembanding', index)); input.addEventListener('input', () => calculatePrices('pembanding', index));
}); });
pembandingHargaPenawaranInput.forEach((input, index) => { // pembandingHargaPenawaranInput.forEach((input, index) => {
input.addEventListener('input', () => calculatePrices('pembanding', index)); // input.addEventListener('input', () => calculatePrices('pembanding', index));
}); // });
pembandingDiskonInputs.forEach((input, index) => { pembandingDiskonInputs.forEach((input, index) => {
input.addEventListener('input', () => calculatePrices('pembanding', index)); input.addEventListener('input', () => calculatePrices('pembanding', index));

View File

@@ -114,7 +114,7 @@
@endphp @endphp
<td class="px-4 py-2"> <td class="px-4 py-2">
<input type="text" name="luas_tanah" class="input " <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>
<td class="px-4 py-2"> <td class="px-4 py-2">
@@ -188,7 +188,7 @@
</td> </td>
</tr> </tr>
<tr> {{-- <tr>
<td class="px-4 py-2">Harga Penawaran/ Transaksi(Rp)</td> <td class="px-4 py-2">Harga Penawaran/ Transaksi(Rp)</td>
<td class="px-4 py-2"> <td class="px-4 py-2">
<input type="text" name="harga_penawaran" class="input currency-format" <input type="text" name="harga_penawaran" class="input currency-format"
@@ -197,7 +197,7 @@
<td class="px-4 py-2"> <td class="px-4 py-2">
<input type="text" name="harga_penawaran_pembanding[]" class="input currency-format"> <input type="text" name="harga_penawaran_pembanding[]" class="input currency-format">
</td> </td>
</tr> </tr> --}}
<tr> <tr>
@@ -412,11 +412,11 @@
</tr> </tr>
<tr class="bg-gray-100"> <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>
<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"> <td class="px-4 py-2">
<input type="text" name="harga" class="input currency-format" <input type="text" name="harga" class="input currency-format"
value="{{ $inspectionData['asset']['harga'] ?? '' }}"> value="{{ $inspectionData['asset']['harga'] ?? '' }}">
@@ -448,8 +448,8 @@
</td> </td>
</tr> </tr>
<tr style=""> {{-- <tr style="">
<td class="px-4 py-2"></td> <td class="px-4 py-2">Harga Setelah Diskon</td>
<td class="px-4 py-2"> <td class="px-4 py-2">
<input type="text" name="total" class="input currency" <input type="text" name="total" class="input currency"
value="{{ $inspectionData['asset']['total'] ?? '' }}" readonly> value="{{ $inspectionData['asset']['total'] ?? '' }}" readonly>
@@ -457,15 +457,15 @@
<td class="px-4 py-2"> <td class="px-4 py-2">
<input type="text" name="total_pembanding[]" class="input currency-format" readonly> <input type="text" name="total_pembanding[]" class="input currency-format" readonly>
</td> </td>
</tr> </tr> --}}
<tr> <tr>
<td class="px-4 py-2">Harga Setelah Diskon</td> <td class="px-4 py-2">Harga Setelah Diskon</td>
<td class="px-4 py-2"> <td class="px-4 py-2">
<input type="text" name="harga_diskon" class="input currency-format" readonly <input type="text" name="total" class="input currency-format" readonly
value="{{ $inspectionData['asset']['harga_diskon'] ?? '' }}"> value="{{ $inspectionData['asset']['total'] ?? '' }}">
</td> </td>
<td class="px-4 py-2"> <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"> class="input currency-format">
</td> </td>
</tr> </tr>

View File

@@ -104,56 +104,6 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script> <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<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) { function approveReschedule(penilaianId, permohonanId, noReg, debitur, reschedule_date, reschedule_note) {
Swal.fire({ Swal.fire({
@@ -223,7 +173,8 @@
_token: token, _token: token,
permohonan_id: permohonanId, permohonan_id: permohonanId,
nomor_registrasi: noReg, nomor_registrasi: noReg,
rejected_note: rejectResult.value rejected_note: rejectResult.value,
keterangan: rejectResult.value
} }
$.ajax({ $.ajax({
url: useURL, url: useURL,
@@ -642,12 +593,7 @@
title="Lihat Form Inspeksi"> title="Lihat Form Inspeksi">
<i class="ki-outline ki-eye"></i> <i class="ki-outline ki-eye"></i>
</a> </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>
`; `;
} }
} }