44b1d847bc
Co-authored-by: ISMAIL MASSERAN <topaz@ISMAILs-Macbook.local> Co-authored-by: nurafrinaalimi16 <nurafrinaalimi16@gmail.com> Co-authored-by: ISMAIL MASSERAN <topaz@Mac.dlinkrouter.local> Reviewed-on: #17 Co-authored-by: ismailmasseran <ismail@koppkb.com> Co-committed-by: ismailmasseran <ismail@koppkb.com>
330 lines
12 KiB
PHP
330 lines
12 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('content')
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="card">
|
|
<nav aria-label="breadcrumb">
|
|
<ol class="breadcrumb pb-3">
|
|
<li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
|
|
<li class="breadcrumb-item"><a href="{{ route('laporan') }}">Laporan</a></li>
|
|
<li class="breadcrumb-item active" aria-current="page">Pembiayaan</li>
|
|
</ol>
|
|
</nav>
|
|
|
|
<div class="card-body text-center">
|
|
<div class="row form-group">
|
|
<div class="col-md-2">
|
|
</div>
|
|
<div class="col-md-10">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<form action="{{ route('gadaianujrah.laporancetak') }}" target="_blank" method="post">
|
|
@csrf
|
|
<div class="input-group mb-3">
|
|
<div class="input-group-prepend ml-3">
|
|
<span class="input-group-text" id="basic-addon1">Mula</span>
|
|
</div>
|
|
<input type="text" class="form-control col-4" placeholder="Pilih Tarikh" aria-label="Tarikh" id="datemula" name="datemula" aria-describedby="basic-addon1">
|
|
|
|
<div class="input-group-prepend ml-2 ">
|
|
<span class="input-group-text" id="basic-addon1">Hingga</span>
|
|
</div>
|
|
<input type="text" class="form-control col-4" placeholder="Pilih Tarikh" aria-label="Tarikh" id="datehingga" name="datehingga" aria-describedby="basic-addon1">
|
|
|
|
|
|
<input type="submit" class="btn btn-primary ml-md-5" id="submit_button" name="submit_button" value="Cetak">
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<table class="table table-striped table-hover" id="myTable">
|
|
<thead class="thead-dark">
|
|
<tr>
|
|
<th>Bil</th>
|
|
<th>Nama</th>
|
|
<th>No K/P</th>
|
|
<th>Tarikh Pembiayaan</th>
|
|
<th>No Rujukan</th>
|
|
<th>Pembiayaan (RM)</th>
|
|
<th>Keuntungan Lain-lain Caj (RM) </th>
|
|
<th>Keuntungan 1% (RM)</th>
|
|
<th>Jumlah Keuntungan (RM)</th>
|
|
<th>Nilai Marhun (RM)</th>
|
|
<th>Berat (g)</th>
|
|
</tr>
|
|
</thead>
|
|
<tfoot class="thead-dark">
|
|
<th colspan="5">TOTAL</th>
|
|
<th id="pinjamantotal"></th>
|
|
<th id="ujrahtotal"></th>
|
|
<th id="onepercenttotal"></th>
|
|
<th id="upah12total"></th>
|
|
<th id="nmtotal"></th>
|
|
<th id="berattotal"></th>
|
|
</tfoot>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
var api_url = "{{ api_url_for_browser() }}";
|
|
var kodcaw = "<?php echo $cawangan_info['kodcaw'] ?>";
|
|
|
|
var tablegadai = $('#myTable').DataTable({
|
|
"ordering": false
|
|
});
|
|
|
|
$(document).ready(function () {
|
|
$('#datemula').datepicker({
|
|
format: 'dd-mm-yyyy'
|
|
});
|
|
$('#datehingga').datepicker({
|
|
format: 'dd-mm-yyyy'
|
|
});
|
|
|
|
//current time
|
|
var current = new Date();
|
|
var current_date = current.getDate();
|
|
var current_month = current.getMonth()+1;
|
|
var current_year = current.getFullYear();
|
|
var today_date = current_year + '-' + current_month + '-' + current_date;
|
|
|
|
$.ajax({
|
|
method:'get',
|
|
url: api_url + '/api/gadailaporanRangeDate/'+ kodcaw,
|
|
data:{
|
|
mula:today_date,
|
|
akhir:today_date,
|
|
},
|
|
success: function(response){
|
|
console.log('=== RESPONSE PENUH ===');
|
|
console.log('Type:', typeof response);
|
|
console.log('Is Array:', Array.isArray(response));
|
|
console.log('Response:', response);
|
|
|
|
// Check jika response adalah array terus
|
|
var gadai;
|
|
if (Array.isArray(response)) {
|
|
gadai = response;
|
|
} else if (response.gadai && Array.isArray(response.gadai)) {
|
|
gadai = response.gadai;
|
|
} else {
|
|
gadai = [];
|
|
}
|
|
|
|
console.log('=== DATA GADAI ===');
|
|
console.log('Jumlah rekod:', gadai.length);
|
|
console.log('Data gadai:', gadai);
|
|
|
|
if(gadai.length > 0) {
|
|
console.log('Contoh rekod pertama:', gadai[0]);
|
|
console.log('Field yang ada:', Object.keys(gadai[0]));
|
|
}
|
|
|
|
gadaitable(gadai);
|
|
},
|
|
error: function(xhr, status, error) {
|
|
console.error('Error AJAX:', error);
|
|
console.error('Status:', status);
|
|
console.error('Response:', xhr.responseText);
|
|
}
|
|
});
|
|
});
|
|
|
|
$('#datemula').change(function(){
|
|
//mula
|
|
var input_date = this.value;
|
|
var split_date = input_date.split('-');
|
|
var mula_date = split_date[2] + '-' + split_date[1] + '-' + split_date[0];
|
|
|
|
var mula = mula_date;
|
|
|
|
//current time
|
|
var hinggainput = $('#datehingga').val();
|
|
|
|
if(hinggainput != '')
|
|
{
|
|
var input_date = hinggainput;
|
|
var split_date = input_date.split('-');
|
|
var hingga_date = split_date[2] + '-' + split_date[1] + '-' + split_date[0];
|
|
|
|
var akhir = hingga_date;
|
|
|
|
}else{
|
|
var current = new Date();
|
|
var current_date = current.getDate();
|
|
var current_month = current.getMonth()+1;
|
|
var current_year = current.getFullYear();
|
|
var today_date = current_year + '-' + current_month + '-' + current_date;
|
|
|
|
var akhir = today_date;
|
|
}
|
|
|
|
$.ajax({
|
|
method:'get',
|
|
url: api_url + '/api/gadailaporanRangeDate/'+ kodcaw,
|
|
data:{
|
|
mula:mula,
|
|
akhir:akhir,
|
|
},
|
|
success: function(response){
|
|
console.log('Response datemula:', response);
|
|
|
|
var gadai;
|
|
if (Array.isArray(response)) {
|
|
gadai = response;
|
|
} else if (response.gadai && Array.isArray(response.gadai)) {
|
|
gadai = response.gadai;
|
|
} else {
|
|
gadai = [];
|
|
}
|
|
|
|
gadaitable(gadai);
|
|
}
|
|
});
|
|
});
|
|
|
|
$('#datehingga').change(function(){
|
|
var input_date = this.value;
|
|
var split_date = input_date.split('-');
|
|
var hingga_date = split_date[2] + '-' + split_date[1] + '-' + split_date[0];
|
|
|
|
var akhir = hingga_date;
|
|
|
|
//current time
|
|
var mulainput = $('#datemula').val();
|
|
|
|
if(mulainput != '')
|
|
{
|
|
var input_date = mulainput;
|
|
var split_date = input_date.split('-');
|
|
var mula_date = split_date[2] + '-' + split_date[1] + '-' + split_date[0];
|
|
|
|
var mula = mula_date;
|
|
|
|
}else{
|
|
|
|
var dulu_date = '2017-01-01';
|
|
|
|
var mula = dulu_date;
|
|
}
|
|
|
|
$.ajax({
|
|
method:'get',
|
|
url: api_url + '/api/gadailaporanRangeDate/'+ kodcaw,
|
|
data:{
|
|
mula:mula,
|
|
akhir:akhir,
|
|
},
|
|
success: function(response){
|
|
console.log('Response datehingga:', response);
|
|
|
|
var gadai;
|
|
if (Array.isArray(response)) {
|
|
gadai = response;
|
|
} else if (response.gadai && Array.isArray(response.gadai)) {
|
|
gadai = response.gadai;
|
|
} else {
|
|
gadai = [];
|
|
}
|
|
|
|
gadaitable(gadai);
|
|
}
|
|
});
|
|
});
|
|
|
|
const formatter = new Intl.NumberFormat('en-US', {
|
|
minimumFractionDigits: 2
|
|
});
|
|
|
|
function gadaitable(data){
|
|
var counter = 1;
|
|
var total_pinjaman = 0;
|
|
var total_upah12 = 0;
|
|
var total_nm = 0;
|
|
var total_berat = 0;
|
|
var total_onepercent = 0;
|
|
var total_ujrah = 0;
|
|
|
|
tablegadai.clear().draw();
|
|
|
|
// Semak jika data kosong
|
|
if(!data || data.length === 0) {
|
|
console.log('Tiada data untuk dipaparkan');
|
|
return;
|
|
}
|
|
|
|
// TAMBAH INI: Log structure data pertama
|
|
console.log('=== STRUKTUR DATA ===');
|
|
console.log('Data pertama:', data[0]);
|
|
console.log('Keys yang ada:', Object.keys(data[0]));
|
|
|
|
$.each(data,function(index,gadai){
|
|
// Log setiap item untuk debug
|
|
console.log('Item ' + index + ':', gadai);
|
|
|
|
// Validasi data sebelum gunakan
|
|
var pinjaman = gadai['pinjaman'] ? Number(gadai['pinjaman']) : 0;
|
|
var nilaimarhun = gadai['nilaimarhun'] ? Number(gadai['nilaimarhun']) : 0;
|
|
var berat = gadai['berat'] ? Number(gadai['berat']) : 0;
|
|
var onepercent = gadai['onepercent'] ? Number(gadai['onepercent']) : 0;
|
|
var ujrah = gadai['ujrah'] ? Number(gadai['ujrah']) : 0;
|
|
|
|
console.log('Nilai processed:', {pinjaman, nilaimarhun, berat, onepercent, ujrah});
|
|
|
|
total_pinjaman += pinjaman;
|
|
total_nm += nilaimarhun;
|
|
total_berat += berat;
|
|
total_onepercent += (onepercent * 12);
|
|
total_ujrah += (ujrah * 12);
|
|
|
|
var upah12 = 0;
|
|
if (gadai['tagbaru'] == 0) {
|
|
upah12 = gadai['upah12'] ? Number(gadai['upah12']) : 0;
|
|
} else {
|
|
upah12 = (ujrah * 12) + (onepercent * 12);
|
|
}
|
|
|
|
total_upah12 += upah12;
|
|
|
|
// Pastikan semua nilai ada sebelum add row
|
|
tablegadai.row.add([
|
|
counter,
|
|
gadai['nama'] || '-',
|
|
gadai['nokp'] || '-',
|
|
gadai['t_gadai'] || '-',
|
|
gadai['norujukan'] || '-',
|
|
formatter.format(pinjaman),
|
|
formatter.format(ujrah * 12),
|
|
formatter.format(onepercent * 12),
|
|
formatter.format(upah12),
|
|
formatter.format(nilaimarhun),
|
|
formatter.format(berat)
|
|
]).draw(false);
|
|
|
|
counter++;
|
|
});
|
|
|
|
// Update total selepas loop selesai
|
|
$('#pinjamantotal').text(formatter.format(total_pinjaman.toFixed(2)));
|
|
$('#upah12total').text(formatter.format(total_upah12.toFixed(2)));
|
|
$('#nmtotal').text(formatter.format(total_nm.toFixed(2)));
|
|
$('#berattotal').text(formatter.format(total_berat.toFixed(2)));
|
|
$('#onepercenttotal').text(formatter.format(total_onepercent.toFixed(2)));
|
|
$('#ujrahtotal').text(formatter.format(total_ujrah.toFixed(2)));
|
|
}
|
|
</script>
|
|
@endsection |