Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b5bffd0b34 |
@@ -3990,7 +3990,7 @@ class KhazanahController extends Controller
|
||||
|
||||
}
|
||||
|
||||
public function cetakLaporanGadaiUjrah(Request $request){
|
||||
public function cetakLaporanGadaiUjrah(Request $request){
|
||||
|
||||
$api_url = config('api.url');
|
||||
$auth_user = Auth::user();
|
||||
@@ -4012,12 +4012,21 @@ class KhazanahController extends Controller
|
||||
$hingga_date = $split_date[2] . '-' . $split_date[1] . '-' . $split_date[0];
|
||||
}
|
||||
|
||||
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/api/gadailaporanRangeDate/'. $auth_user['cawangan'] ,['mula' => $mula_date,'akhir' => $hingga_date])->json();
|
||||
$reportGadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/api/gadailaporanRangeDate/'. $auth_user['cawangan'] ,['mula' => $mula_date,'akhir' => $hingga_date])->json();
|
||||
$gadai = $reportGadai['gadai'];
|
||||
$statistik =$reportGadai['statistik'];
|
||||
$reportPembiayaan= $statistik['reportPembiayaan'];
|
||||
$reportLoanAmount=$statistik['reportLoanAmount'];
|
||||
$reportMarhunValue=$statistik['reportMarhunValue'];
|
||||
$reportMarhunMargin=$statistik['reportMarhunMargin'];
|
||||
$reportCustomerJob=$statistik['reportCustomerJob'];
|
||||
$reportCustomerRace=$statistik['reportCustomerRace'];
|
||||
// dd($reportCustomerRace);
|
||||
|
||||
$cawangan=Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/cawangan/detail/'.$auth_user['cawangan'])->json();
|
||||
$cawangan_detail=$cawangan[0];
|
||||
|
||||
return view('print.laporan_gadaian_ujrah', compact('gadai','cawangan_detail','tarikh_cetak','mula_date','api_url','hingga_date'));
|
||||
return view('print.laporan_gadaian_ujrah', compact('gadai','cawangan_detail','tarikh_cetak','mula_date','api_url','hingga_date','statistik','reportPembiayaan','reportLoanAmount','reportMarhunValue','reportMarhunMargin','reportCustomerJob','reportCustomerRace','reportCustomerRace'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<li class="breadcrumb-item"><a href="{{ route('laporan') }}">Laporan</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Pembiayaan</li>
|
||||
</ol>
|
||||
</nav>
|
||||
</nav>
|
||||
|
||||
<div class="card-body text-center">
|
||||
<div class="row form-group">
|
||||
@@ -22,7 +22,7 @@
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-">
|
||||
<div class="col-md-12">
|
||||
<form action="{{ route('gadaianujrah.laporancetak') }}" target="_blank" method="post">
|
||||
@csrf
|
||||
<div class="input-group mb-3">
|
||||
@@ -86,7 +86,8 @@
|
||||
var tablegadai = $('#myTable').DataTable({
|
||||
"ordering": false
|
||||
});
|
||||
$(document).ready( function () {
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#datemula').datepicker({
|
||||
format: 'dd-mm-yyyy'
|
||||
});
|
||||
@@ -99,7 +100,7 @@
|
||||
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 today_date = current_year + '-' + current_month + '-' + current_date;
|
||||
|
||||
$.ajax({
|
||||
method:'get',
|
||||
@@ -108,18 +109,46 @@
|
||||
mula:today_date,
|
||||
akhir:today_date,
|
||||
},
|
||||
success: function(gadai){
|
||||
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_date = split_date[2] + '-' + split_date[1] + '-' + split_date[0];
|
||||
|
||||
var mula = mula_date;
|
||||
|
||||
@@ -130,7 +159,7 @@
|
||||
{
|
||||
var input_date = hinggainput;
|
||||
var split_date = input_date.split('-');
|
||||
var hingga_date = split_date[2] + '-' +split_date[1]+'-'+split_date[0];
|
||||
var hingga_date = split_date[2] + '-' + split_date[1] + '-' + split_date[0];
|
||||
|
||||
var akhir = hingga_date;
|
||||
|
||||
@@ -139,7 +168,7 @@
|
||||
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 today_date = current_year + '-' + current_month + '-' + current_date;
|
||||
|
||||
var akhir = today_date;
|
||||
}
|
||||
@@ -151,7 +180,18 @@
|
||||
mula:mula,
|
||||
akhir:akhir,
|
||||
},
|
||||
success: function(gadai){
|
||||
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);
|
||||
}
|
||||
});
|
||||
@@ -160,7 +200,7 @@
|
||||
$('#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 hingga_date = split_date[2] + '-' + split_date[1] + '-' + split_date[0];
|
||||
|
||||
var akhir = hingga_date;
|
||||
|
||||
@@ -171,7 +211,7 @@
|
||||
{
|
||||
var input_date = mulainput;
|
||||
var split_date = input_date.split('-');
|
||||
var mula_date = split_date[2] + '-' +split_date[1]+'-'+split_date[0];
|
||||
var mula_date = split_date[2] + '-' + split_date[1] + '-' + split_date[0];
|
||||
|
||||
var mula = mula_date;
|
||||
|
||||
@@ -189,7 +229,18 @@
|
||||
mula:mula,
|
||||
akhir:akhir,
|
||||
},
|
||||
success: function(gadai){
|
||||
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);
|
||||
}
|
||||
});
|
||||
@@ -208,55 +259,72 @@
|
||||
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){
|
||||
total_pinjaman += Number(gadai['pinjaman']);
|
||||
total_nm += Number(gadai['nilaimarhun']);
|
||||
total_berat += Number(gadai['berat']);
|
||||
total_onepercent += Number(gadai['onepercent']*12);
|
||||
total_ujrah += Number(gadai['ujrah']*12);
|
||||
|
||||
if (gadai['tagbaru'] == 0) {
|
||||
|
||||
var upah12 = gadai['upah12'];
|
||||
|
||||
} else {
|
||||
|
||||
var upah12 = gadai['ujrah']*12 + gadai['onepercent']*12;
|
||||
|
||||
}
|
||||
|
||||
total_upah12 += Number(upah12) ;
|
||||
|
||||
tablegadai.row.add([
|
||||
counter,
|
||||
gadai['nama'],
|
||||
gadai['nokp'],
|
||||
gadai['t_gadai'],
|
||||
gadai['norujukan'],
|
||||
formatter.format(gadai['pinjaman']),
|
||||
formatter.format(gadai['ujrah']*12),
|
||||
formatter.format(gadai['onepercent']*12),
|
||||
formatter.format(upah12),
|
||||
formatter.format(gadai['nilaimarhun']),
|
||||
formatter.format(gadai['berat'])
|
||||
]).draw();
|
||||
$('#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)));
|
||||
$('#berattotal').text(formatter.format(total_berat.toFixed(2)));
|
||||
$('#onepercenttotal').text(formatter.format(total_onepercent.toFixed(2)));
|
||||
$('#ujrahtotal').text(formatter.format(total_ujrah.toFixed(2)));
|
||||
// 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 = counter + 1;
|
||||
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
|
||||
|
||||
@endsection
|
||||
Reference in New Issue
Block a user