added baki lelong and rugi lelong
This commit is contained in:
@@ -38,6 +38,8 @@ class HomeController extends Controller
|
||||
->get(config('api.url_koop') . '/portal/customer/info', ['ic' => $authUser['icno']])
|
||||
->json();
|
||||
|
||||
$customerLelong = $this->getCustomerInfoLelong($authUser['icno']);
|
||||
|
||||
// ['gadai' => $customer_gadai, 'lelong' => $customer_lelong] = $customerInfo;
|
||||
$customer_gadai = array_merge(
|
||||
$customer_pkb['gadai'] ?? [],
|
||||
@@ -48,7 +50,7 @@ class HomeController extends Controller
|
||||
$customer_pkb['lelong'] ?? [],
|
||||
$customer_koop['lelong'] ?? []
|
||||
);
|
||||
|
||||
|
||||
// only get lelong that is harga jualan that is not null or 0
|
||||
$customer_lelong = array_filter($customer_lelong, fn($x) => $x['hargajualan'] != null && $x['hargajualan'] != 0);
|
||||
|
||||
@@ -62,7 +64,7 @@ class HomeController extends Controller
|
||||
|
||||
$bilangan = sizeof($customer_gadai) + sizeOf($customer_lelong);
|
||||
|
||||
return view('includes.buffer', compact('bilangan', 'sixMonths', 'total', 'bilanganLelong', 'homeUrl'));
|
||||
return view('includes.buffer', compact('bilangan', 'sixMonths', 'total', 'bilanganLelong', 'homeUrl','customerLelong'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,6 +85,7 @@ class HomeController extends Controller
|
||||
->get(config('api.url_koop') . '/portal/customer/info', ['ic' => $authUser['icno']])
|
||||
->json();
|
||||
|
||||
$customerLelong = $this->getCustomerInfoLelong($authUser['icno']);
|
||||
// ['gadai' => $customer_gadai, 'lelong' => $customer_lelong] = $customerInfo;
|
||||
|
||||
$customer_gadai = array_merge(
|
||||
@@ -108,6 +111,33 @@ class HomeController extends Controller
|
||||
|
||||
$bilangan = sizeof($customer_gadai) + sizeOf($customer_lelong);
|
||||
|
||||
return view('includes.home', compact('bilangan', 'sixMonths', 'total', 'bilanganLelong', 'pembiayaan'));
|
||||
return view('includes.home', compact('bilangan', 'sixMonths', 'total', 'bilanganLelong', 'pembiayaan','customerLelong'));
|
||||
}
|
||||
|
||||
private function getCustomerInfoLelong($icno){
|
||||
$customerLelong = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get(config('api.url') . '/portal/customer/info/lelong', ['ic' => $icno])
|
||||
->json();
|
||||
|
||||
$customerLelongKoop = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get(config('api.url_koop') . '/portal/customer/info/lelong', ['ic' => $icno])
|
||||
->json();
|
||||
|
||||
// Extract data with null safety
|
||||
$bakiLelong = isset($customerLelong['success']) && $customerLelong['success']
|
||||
? ($customerLelong['data']['bakilelong'] ?? 0) : 0;
|
||||
$rugiLelong = isset($customerLelong['success']) && $customerLelong['success']
|
||||
? ($customerLelong['data']['rugilelong'] ?? 0) : 0;
|
||||
|
||||
$bakiKoop = isset($customerLelongKoop['success']) && $customerLelongKoop['success']
|
||||
? ($customerLelongKoop['data']['bakilelong'] ?? 0) : 0;
|
||||
$rugiKoop = isset($customerLelongKoop['success']) && $customerLelongKoop['success']
|
||||
? ($customerLelongKoop['data']['rugilelong'] ?? 0) : 0;
|
||||
|
||||
// Calculate totals
|
||||
$totalBakiLelong = $bakiLelong + $bakiKoop;
|
||||
$totalRugiLelong = $rugiLelong + $rugiKoop;
|
||||
|
||||
return ['rugilelong' => $totalRugiLelong, 'bakilelong' => $totalBakiLelong];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
@props([
|
||||
'title' => '',
|
||||
'subtitle' => '',
|
||||
'icon' => '',
|
||||
'iconState' => 'info',
|
||||
'cardBackgroundState' => 'white',
|
||||
'link' => '#',
|
||||
])
|
||||
|
||||
<div class="col-xl-3 col-lg-6" >
|
||||
<div class="card card-stats mb-4 mb-xl-0 {{ 'bg-'.$cardBackgroundState}}">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h6 class="card-title text-uppercase mb-0 {{ $cardBackgroundState == 'white' ? 'text-muted' : 'text-white' }}">{{ $title }}</h6>
|
||||
<span class="h5 font-weight-bold mb-0 {{ $cardBackgroundState == 'white' ? 'text-black' : 'text-white' }}">{{ $subtitle }}</span>
|
||||
</div>
|
||||
<div class="col-auto text-center">
|
||||
<a href="{{ $link }}">
|
||||
<div class="icon icon-shape bg-{{ $iconState }} rounded-circle shadow text-center">
|
||||
<i class="{{ $icon }}"></i>
|
||||
</div>
|
||||
</a>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -90,6 +90,21 @@
|
||||
@endif
|
||||
<br>
|
||||
|
||||
<div class="d-flex justify-content-center mb-4">
|
||||
<x-dashboard-card-small
|
||||
title="Baki Lelong"
|
||||
:subtitle="number_format($customerLelong['bakilelong'] ?? 0, 2)"
|
||||
icon="fas fa-chart-bar"
|
||||
iconState="danger"
|
||||
/>
|
||||
<x-dashboard-card-small
|
||||
title="Rugi Lelong"
|
||||
:subtitle="number_format($customerLelong['rugilelong'] ?? 0, 2)"
|
||||
icon="fas fa-chart-bar"
|
||||
iconState="warning"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@if (request()->get('filter') == 'pembiayaan-akan-dilelong')
|
||||
<x-dashboard-notification>
|
||||
<x-dashboard-notification.item content="1. Sekiranya Lelongan Anda Dalam Tempoh Kontrak Lanjutan (Mencapai 12 Bulan), Urusan Penebusan Hanya Dibenarkan Di Kaunter Cawangan Selewatnya-lewatnya 3 Hari Sebelum Tarikh Lelong." />
|
||||
|
||||
Reference in New Issue
Block a user