Merge with feature/aiman/pampasan/sempornaV2
This commit is contained in:
@@ -131,6 +131,20 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if($pampasan)
|
||||
<div class="bg-white p-3 my-3">
|
||||
<div class="border text-center p-2 mx-auto" style="border: 2px solid red !important; width: 209px;">
|
||||
<span class="text-danger font-weight-bold">PAMPASAN</span>
|
||||
</div>
|
||||
<div class="text-center mt-2">
|
||||
<a href="{{ route('pampasan.surat', $gadai['norujukan']) }}" target="_blank"
|
||||
class="btn surat-perjanjian-btn" data-norujukan="{{ $gadai['norujukan'] }}" title="Lihat Surat" style="background-color: red; color: white; border: 2px solid red;">
|
||||
<i class="fas fa-file-alt fa-lg"></i> Cetak Surat Perjanjian
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="card" id="infomarhun">
|
||||
<div class="card-body">
|
||||
<table id="tablemarhun" class="table table-striped table-hover table-bordered text-center">
|
||||
@@ -1082,6 +1096,28 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Modal Surat Agreement -->
|
||||
<div class="modal fade" id="suratModal" tabindex="-1" role="dialog" aria-labelledby="suratModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="suratModalLabel">Surat Agreement</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body" id="surat-content" style="font-family: 'Times New Roman', Times, serif;">
|
||||
<!-- Surat content will be injected here -->
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Batal</button>
|
||||
<button type="button" class="btn btn-primary" id="btnPrintSurat">Cetak & Teruskan</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
let elem_jenisAT = $('#jenisAT').remove();
|
||||
@@ -1152,6 +1188,7 @@
|
||||
var percent_mora = 0;
|
||||
var pinjaman_teller = 0;
|
||||
var pinjaman_pelulus = 0;
|
||||
var pampasan = @json($pampasan);
|
||||
|
||||
|
||||
|
||||
@@ -1365,6 +1402,10 @@
|
||||
}
|
||||
});
|
||||
|
||||
if(pampasan != null){
|
||||
$('#jumlahupah').val(pampasan.untung);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
method:'GET',
|
||||
url: api + '/api/upahrebettawarruq/' + kodcaw + '/' + norujukan,
|
||||
@@ -1395,7 +1436,18 @@
|
||||
dataType: 'json',
|
||||
async:false,
|
||||
success:function(harga_tebus){
|
||||
$('#perludibayar').val(formatter.format(harga_tebus));
|
||||
if(pampasan != null){
|
||||
let pembiayaan = safeMoneyParse(pampasan.pembiayaan);
|
||||
let untung = safeMoneyParse(pampasan.untung);
|
||||
|
||||
$('#perludibayar').val(formatter.format(pembiayaan + untung));
|
||||
|
||||
$('#duitPelanggan').val(formatter.format(pembiayaan + untung));
|
||||
|
||||
$('#duitPelanggan').prop('readonly', true);
|
||||
}else {
|
||||
$('#perludibayar').val(formatter.format(harga_tebus));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1753,8 +1805,129 @@
|
||||
|
||||
let teller = "{{ Auth::user()->name }}";
|
||||
|
||||
function bayaransemua()
|
||||
async function getPampasanByNorujukan(norujukan) {
|
||||
|
||||
const params = new URLSearchParams({
|
||||
kodcaw: kodcaw,
|
||||
status: 'all'
|
||||
});
|
||||
|
||||
try {
|
||||
const pampasanListResponse = await fetch(`{{ config('api.url') }}/api/palsu/laporan?${params}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
if (!pampasanListResponse.ok) {
|
||||
throw new Error(`HTTP error! status: ${pampasanListResponse.status}`);
|
||||
}
|
||||
|
||||
const pampasanListData = await pampasanListResponse.json();
|
||||
const pampasanList = pampasanListData.filter(pampasan => pampasan.norujukan === norujukan);
|
||||
const pampasan = pampasanList.length === 0 ? null : pampasanList.pop();
|
||||
|
||||
return pampasan;
|
||||
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch pampasan data:', error);
|
||||
throw new Error("Something wrong with API");
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function for safe money parsing
|
||||
const safeMoneyParse = (value) => {
|
||||
const parsed = parseFloat(value);
|
||||
return isNaN(parsed) ? 0 : Math.round(parsed * 100) / 100; // Round to 2 decimal places
|
||||
};
|
||||
|
||||
async function checkWangPetiBesiEnoughForTuntutanPampasan(pampasan) {
|
||||
const currentDate = new Date().toISOString().split('T')[0];
|
||||
let wangpetibesi = await fetch(api + '/api/TunaiDiTangan/' + kodcaw + '?tarikh=' + currentDate).then(response => response.json());
|
||||
|
||||
const nilaimarhun = safeMoneyParse(pampasan.nilaimarhun);
|
||||
const pembiayaan = safeMoneyParse(pampasan.pembiayaan);
|
||||
const untung = safeMoneyParse(pampasan.untung);
|
||||
|
||||
const jumlahpampasan = safeMoneyParse(nilaimarhun - pembiayaan - untung);
|
||||
|
||||
const balancewangpetibesiafterdeduct = wangpetibesi - jumlahpampasan < 0 ? false : true;
|
||||
|
||||
if(! balancewangpetibesiafterdeduct){
|
||||
Swal.fire({
|
||||
title: 'Peringatan',
|
||||
html: `
|
||||
<p>Wang peti besi tidak mencukupi untuk proses tuntutan pampasan</p>
|
||||
<br>
|
||||
<div style="text-align: left; margin: 0 auto; display: inline-block;">
|
||||
<strong>Wang Peti Besi:</strong> RM ${formatter.format(wangpetibesi)}<br><br>
|
||||
<strong>Jumlah Diperlukan:</strong> RM ${formatter.format(jumlahpampasan)}<br><br>
|
||||
<strong>Kekurangan:</strong> <span style="color: red;">RM ${formatter.format(jumlahpampasan - wangpetibesi)}</span>
|
||||
</div>
|
||||
`,
|
||||
icon: 'warning'
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
async function bayaransemua()
|
||||
{
|
||||
// Instantiate pampasan using the JavaScript function
|
||||
const pampasan = await getPampasanByNorujukan(norujukan);
|
||||
|
||||
if(pampasan != null){
|
||||
if(pampasan && !pampasan.hasOwnProperty('agreement_printed_at')){
|
||||
Swal.fire({
|
||||
title: 'Peringatan',
|
||||
text: 'Sila print surat perjanjian',
|
||||
icon: 'warning'
|
||||
});
|
||||
return; // Exit early if agreement not printed
|
||||
}
|
||||
|
||||
const isEnough = await checkWangPetiBesiEnoughForTuntutanPampasan(pampasan);
|
||||
|
||||
if(! isEnough){
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(pampasan != null){
|
||||
const result = await Swal.fire({
|
||||
title: 'Pengesahan Proses Tuntutan Pampasan',
|
||||
html: `
|
||||
<div style="text-align: left; margin: 20px 0; min-width: 500px;">
|
||||
<p><strong>Sila pastikan wang untuk proses tuntutan pampasan adalah mencukupi.</strong></p>
|
||||
<br>
|
||||
<p style="color: #d33; font-weight: bold;">⚠️ Proses tidak dapat diundur</p>
|
||||
<p style="color: #d33;">⚠️ Short wang teller atau peti besi akan ditanggung oleh anda</p>
|
||||
<br>
|
||||
<p>Adakah anda ingin meneruskan proses ini?</p>
|
||||
</div>
|
||||
`,
|
||||
icon: 'question',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Ya, Teruskan',
|
||||
cancelButtonText: 'Batal',
|
||||
allowOutsideClick: false,
|
||||
allowEscapeKey: false,
|
||||
width: '600px'
|
||||
});
|
||||
|
||||
if (!result.isConfirmed) {
|
||||
return; // Exit if user cancels
|
||||
}
|
||||
}
|
||||
|
||||
$("#terima_transaksi").prop('disabled', true);
|
||||
// Swal.fire({
|
||||
// title: 'Memuatkan...',
|
||||
@@ -3204,7 +3377,7 @@
|
||||
///////////
|
||||
}
|
||||
|
||||
//Bayaran Semua function end file
|
||||
|
||||
}
|
||||
|
||||
function gadaiautotawarruq()
|
||||
@@ -4466,7 +4639,6 @@ return true;
|
||||
};
|
||||
}(jQuery));
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user