66 lines
2.7 KiB
PHP
66 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Http\Request;
|
|
|
|
class AccountStatementController extends Controller
|
|
{
|
|
/**
|
|
* Display the bank statement view with mock data.
|
|
*
|
|
* @return \Illuminate\View\View
|
|
*/
|
|
public function showStatement(Request $request)
|
|
{
|
|
|
|
|
|
$gadaian = Http::get(config('api.url').'/api/gadai/norujukan/'.'KB2240919-0004')->json()[0][0];
|
|
$transaction = Http::get(config('api.url').'/portal/transaksipelanggan',['norujukan' => 'KB2240919-0004'])->json();
|
|
$cawangan=Http::get(config('api.url').'/api/cawangan/detail/'. $gadaian['kodcaw'])->json()[0];
|
|
$customer = Http::get(config('api.url') . '/api/customers/' . $gadaian['nokp'])->json();
|
|
$poskod = Http::get(config('api.url') . '/api/poskod/' . $customer['poskod'])->json();
|
|
|
|
$accountHolder = [
|
|
'name' => $customer['nama'],
|
|
'address' => $customer['alamat1'] . '<br>' . $customer['alamat2'],
|
|
'city_state_zip' => $customer['poskod'] . ', ' . $poskod['daerah']['namadaerah'] . ', ' . $poskod['negeri']['negeri'],
|
|
];
|
|
|
|
|
|
$bankDetails = [
|
|
'name' => 'PERMODALAN KELANTAN BERHAD',
|
|
'address' => $cawangan['alamat1'] . '<br>' . $cawangan['alamat2'],
|
|
'email' => 'firstcitizensbank@domain.com',
|
|
'branch' => $cawangan['namacaw'],
|
|
];
|
|
|
|
|
|
// Calculate total pages (e.g., 10 transactions per page + one row for header/footer on page 1)
|
|
// This is a rough estimate; the Blade file will handle the actual print pagination using CSS.
|
|
|
|
$transaction_count = count(array_filter($transaction, fn($trans) => $trans['trans_type'] == 'A'));
|
|
$totalPages = ceil($transaction_count / 10);
|
|
|
|
$ansuranTransaction = array_values(array_filter($transaction, fn($trans) => $trans['trans_type'] == 'A'));
|
|
$originLoan = $gadaian['pinjaman'];
|
|
$bakipinjaman = $originLoan;
|
|
$ansuranTransaction = array_map(function($trans) use(&$bakipinjaman) {
|
|
$bakipinjaman -= $trans['bayaran_pembiayaan'];
|
|
return array_merge($trans, ['bakipinjaman' => $bakipinjaman]);
|
|
}, $ansuranTransaction);
|
|
|
|
$tebusTransaction = array_values(array_filter($transaction, fn($trans) => $trans['trans_type'] == 'T'))[0];
|
|
|
|
|
|
|
|
return view('accounts-statements', compact('tebusTransaction','ansuranTransaction','transaction_count','gadaian','transaction','accountHolder', 'bankDetails'));
|
|
}
|
|
|
|
/**
|
|
* Helper function to format currency.
|
|
* In a real app, this would be a Blade helper or filter.
|
|
* We'll format it directly in the view for simplicity in this example.
|
|
*/
|
|
} |