diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 838ba17..b4319bb 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -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]; } } diff --git a/resources/views/components/dashboard-card-small.blade.php b/resources/views/components/dashboard-card-small.blade.php new file mode 100644 index 0000000..39efd5d --- /dev/null +++ b/resources/views/components/dashboard-card-small.blade.php @@ -0,0 +1,29 @@ +@props([ + 'title' => '', + 'subtitle' => '', + 'icon' => '', + 'iconState' => 'info', + 'cardBackgroundState' => 'white', + 'link' => '#', +]) + +
+
+
+
+
+
{{ $title }}
+ {{ $subtitle }} +
+
+ +
+ +
+
+
+
+
+
+
+
diff --git a/resources/views/includes/home.blade.php b/resources/views/includes/home.blade.php index cd77d5e..c6bf5e1 100644 --- a/resources/views/includes/home.blade.php +++ b/resources/views/includes/home.blade.php @@ -90,6 +90,21 @@ @endif
+
+ + +
+ @if (request()->get('filter') == 'pembiayaan-akan-dilelong')