From 62b908a314eac6fec5025db7bcfc5b2e9058df8b Mon Sep 17 00:00:00 2001 From: KhatamNugraha Date: Mon, 25 Sep 2023 13:35:45 +0700 Subject: [PATCH] update query export data --- Entities/ViewAccount.php | 23 +++++++---- Http/Controllers/KonfirmasiBankController.php | 39 ++++--------------- Resources/views/exportPdf.blade.php | 8 ++-- 3 files changed, 26 insertions(+), 44 deletions(-) diff --git a/Entities/ViewAccount.php b/Entities/ViewAccount.php index 5a1f0fe..64a87b3 100644 --- a/Entities/ViewAccount.php +++ b/Entities/ViewAccount.php @@ -53,7 +53,7 @@ class ViewAccount extends Model if($arrAccount == null){ //dd('1'); $data = DB::connection("db2")->table("STG_DB.VW_ACCOUNT") - ->select( 'CUSTOMER_NO', 'ACCOUNT_NUMBER','SHORT_NAME','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE',DB::raw('MAX(WORKING_BALANCE) AS WORKING_BALANCE')) + ->select( 'CUSTOMER_NO', 'ACCOUNT_NUMBER','SHORT_NAME','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE',DB::raw('MAX(WORKING_BALANCE) AS WORKING_BALANCE'),DB::raw('MAX(CATEGORY) AS CATEGORY')) ->where('CUSTOMER_NO',$cif) ->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%") ->whereBetween('OPENING_DATE', [$startDate, $endDate]) @@ -78,14 +78,21 @@ class ViewAccount extends Model - public function getAccount($cus_no,$account,$kodecabang,$periode){ + public function getAccount($cif ,$arrAccount, $kodecabang, $startDate, $endDate){ - $data = []; - $data = DB::connection("db2")->table("STG_DB.VW_ACCOUNTS") - ->select( 'ACCOUNT_NUMBER','CUSTOMER_NO','CURRENCY',DB::raw('MAX(CATEGORY) AS CATEGORY'),'SHORT_TITLE',DB::raw('MAX(BATCH_DATE) AS BATCH_DATE'),'PRODUCT','COMPANY_NAME','ARRANGEMENT_ID','MATURITY_DATE',DB::raw('MAX(WORKING_BALANCE) AS WORKING_BALANCE')) - ->where('CUSTOMER_NO',$cus_no)->whereIn('ACCOUNT_NUMBER',$account) - ->groupBy('ACCOUNT_NUMBER' , 'CUSTOMER_NO','CURRENCY','SHORT_TITLE','PRODUCT','COMPANY_NAME','ARRANGEMENT_ID','MATURITY_DATE') - ->get(); + $today = Carbon::now(); + $currentYear = $today->format("Y"); + $pastYear = $today->subYear(3)->format('Y'); + $uppercaseKodeCabang = Str::upper($kodecabang); + + $data = DB::connection("db2")->table("STG_DB.VW_ACCOUNT") + ->select( 'CUSTOMER_NO', 'ACCOUNT_NUMBER','SHORT_NAME','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE',DB::raw('MAX(WORKING_BALANCE) AS WORKING_BALANCE'),DB::raw('MAX(CATEGORY) AS CATEGORY')) + ->where('CUSTOMER_NO',$cif) + ->whereIn('ACCOUNT_NUMBER', $arrAccount) + ->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%") + ->whereBetween('OPENING_DATE', [$startDate, $endDate]) + ->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660']) + ->groupBy('CUSTOMER_NO','ACCOUNT_NUMBER','SHORT_NAME','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE'); return $data; } diff --git a/Http/Controllers/KonfirmasiBankController.php b/Http/Controllers/KonfirmasiBankController.php index 14a994d..40aaa37 100644 --- a/Http/Controllers/KonfirmasiBankController.php +++ b/Http/Controllers/KonfirmasiBankController.php @@ -77,6 +77,7 @@ $Accounts = $Account->getSearchAccount($request->cif,$arrAccount,$request->kodecabang,$request->startDate,$request->endDate)->get(); + foreach ($Accounts as $key => $account) { $Arrangement = $Account->getAAaccount($account->CUSTOMER_NO,$account->ACCOUNT_NUMBER); @@ -120,13 +121,15 @@ $arrAccount = explode("," , $request['acc_no']); + $ViewAccount = new ViewAccount; $data = []; $DataAccounts = []; $DataPinjaman = []; $DataLimit = []; $DataAA = []; - $ListAccount = $ViewAccount->getSearchAccount($request['cus_no'],$arrAccount,$request['kode_cabang'],$request->startDate,$request->endDate)->get(); + $ListAccount = $ViewAccount->getAccount($request['cus_no'],$arrAccount,$request['kode_cabang'],$request->startDate,$request->endDate)->get(); + $GetCustomer = $ViewAccount->getCustomer($request['cus_no'])->first(); @@ -141,7 +144,7 @@ } $DataAccounts[$key1]['ACCOUNT_NUMBER'] = $account->ACCOUNT_NUMBER; $DataAccounts[$key1]['CUSTOMER_NO'] = $account->CUSTOMER_NO; - // $DataAccounts[$key1]['STREET'] = $account->STREET; + $DataAccounts[$key1]['SHORT_NAME'] = $account->SHORT_NAME; // $DataAccounts[$key1]['RESIDENCE'] = $account->RESIDENCE; //$DataAccounts[$key1]['ADDRESS'] = $account->ADDRESS; $DataAccounts[$key1]['CURRENCY'] = $account->CURRENCY; @@ -150,8 +153,8 @@ $DataAccounts[$key1]['COMPANY_NAME'] = $account->COMPANY_NAME; $DataAccounts[$key1]['WORKING_BALANCE'] = $account->WORKING_BALANCE; // $DataAccounts[$key1]['BATCH_DATE'] = $account->BATCH_DATE; - $DataAccounts[$key1]['MATURITY_DATE'] = $MaturityDate ?? '-'; - $DataAccounts[$key1]['ARRANGEMENT_ID'] = $AAID ?? '-'; + $DataAccounts[$key1]['MATURITY_DATE'] = $MaturityDate ?? 'NIHIL'; + $DataAccounts[$key1]['ARRANGEMENT_ID'] = $AAID ?? 'NIHIL'; $ListBunga =$ViewAccount->getInterest($AAID ?? ''); $ListTenor =$ViewAccount->getTerm($AAID ?? ''); foreach ($ListBunga as $bunga) { @@ -173,44 +176,18 @@ $pinjaman = []; foreach ($ListPinjaman as $key => $item) { - // $ListTenor =$ViewAccount->getTerm($item->ARRANGEMENT_ID); - // $ListBunga =$ViewAccount->getInterest($item->ARRANGEMENT_ID); - // $ListCategory =$ViewAccount->getCategory($item->CATEGORY); - // $pinjaman[$key]['CUSTOMER'] = $item->CUSTOMER; - // $pinjaman[$key]['SHORT_NAME'] = $item->SHORT_NAME; - // $pinjaman[$key]['STREET'] = $item->STREET; - // $pinjaman[$key]['ADDRESS'] = $item->ADDRESS; $pinjaman[$key]['COMPANY_NAME'] = $item->COMPANY_NAME; $pinjaman[$key]['CURRENCY'] = $item->CURRENCY; $pinjaman[$key]['PRODUCT_LINE'] = $item->PRODUCT_LINE; $pinjaman[$key]['PRODUCT'] = $item->PRODUCT; $pinjaman[$key]['WORKING_BALANCE'] = $item->WORKING_BALANCE; - // $pinjaman[$key]['BATCH_DATE'] = $item->OPENING_DATE; $pinjaman[$key]['MATURITY_DATE'] = $item->MATURITY_DATE; $pinjaman[$key]['ARRANGEMENT_ID'] = $item->ARRANGEMENT_ID; $pinjaman[$key]['FIXED_RATE'] = $item->FIXED_RATE; $pinjaman[$key]['TERM'] = $item->TERM; $pinjaman[$key]['CATEGORY'] = $item->CATEGORY; - - // foreach ($ListBunga as $bunga) { - // if (strpos($bunga->ID ,$item->ARRANGEMENT_ID) !== false) { - // $pinjaman[$key]['FIXED_RATE'] = $bunga->FIXED_RATE; - // } - // } - - // foreach ($ListTenor as $tenor) { - // if (strpos($tenor->ID ,$item->ARRANGEMENT_ID) !== false) { - // $pinjaman[$key]['TERM'] = $tenor->TERM; - // } - // } - // foreach ($ListCategory as $category) { - // if ($category->ID == $item->CATEGORY) { - // $pinjaman[$key]['CATEGORY'] = $category->SHORT_NAME; - // } - // } } - // dd($pinjaman); $ListLimits = $ViewAccount->getLimit($request['cus_no'],$request['periode']); $fasilitas = Fasilitas::where('nomor_cif',$request['cus_no'] )->where('status',1)->get(); @@ -226,8 +203,6 @@ $data['DataSigner'] = $signer; $data['DataCustomer'] = $GetCustomer ?? ''; $data['localDate'] = $tanggalIndonesia; - //DD($data); - // DD($data); $html = View::make('konfirmasibank::exportPdf', ['data' => $data])->render(); $pdf = new Dompdf(); diff --git a/Resources/views/exportPdf.blade.php b/Resources/views/exportPdf.blade.php index 0ea237d..0dccc1c 100644 --- a/Resources/views/exportPdf.blade.php +++ b/Resources/views/exportPdf.blade.php @@ -12,7 +12,7 @@ .content { padding: 2rem; - padding-top:120px + padding-top:150px } .space1 { @@ -91,9 +91,9 @@ @foreach ($data['DataAccounts'] as $val) {{ $i++ }} - {{ $val['ACCOUNT_NUMBER'] }} + {{ $val['ACCOUNT_NUMBER'] }} {{ $val['COMPANY_NAME'] }} - {{ $val['PRODUCT'] }} + {{ $val['SHORT_NAME'] }} {{ $val['CURRENCY'] }} {{ $val['WORKING_BALANCE'] }} {{ $val['TERM'] }} @@ -180,7 +180,7 @@ {{ $limit->SHORT_NAME }} {{ $limit->COMPANY_NAME }} {{ $limit->ACCOUNT_TYPE }} - {{ $limit->LIMIT_CURRENCY }} + {{ $limit->LIMIT_CURRENCY }} {{ $limit->AVAIL_AMT }} {{ $term }} D {{ $limit->LIMIT_PERCENTAGE }}