diff --git a/Entities/Account.php b/Entities/Account.php index d8999c2..9bf4830 100644 --- a/Entities/Account.php +++ b/Entities/Account.php @@ -52,10 +52,10 @@ class Account extends Model ->join('STG_DB.COMPANY AS CP', 'AC.CO_CODE', '=', 'CP.ID') ->where('CUSTOMER_NO',$cif) ->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%") - // ->where('INACTIV_MARKER', NULL) + ->where('LIMIT_REF', NULL) ->where('AC.BATCH_DATE',$startDate) ->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660','101']) - ->groupBy('CUSTOMER_NO','ACCOUNT_NUMBER','SHORT_TITLE','SHORT_NAME','COMPANY_NAME') + ->groupBy('CUSTOMER_NO','ACCOUNT_NUMBER','SHORT_TITLE','SHORT_NAME','COMPANY_NAME','LIMIT_REF') ->limit(100); }else{ $data = DB::connection("db2")->table("STG_DB.ACCOUNT") @@ -78,11 +78,11 @@ class Account extends Model ->join('STG_DB.COMPANY AS CP', 'AC.CO_CODE', '=', 'CP.ID') ->where('CUSTOMER_NO',$cif) // ->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%") - // ->where('INACTIV_MARKER', NULL) + ->where('LIMIT_REF', NULL) ->where('AC.BATCH_DATE',$startDate) ->whereIn('AC.ACCOUNT_NUMBER', $arrAccount) //->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660','101']) - ->groupBy('CUSTOMER_NO','ACCOUNT_NUMBER','SHORT_TITLE','SHORT_NAME','COMPANY_NAME','CATEGORY') + ->groupBy('CUSTOMER_NO','ACCOUNT_NUMBER','SHORT_TITLE','SHORT_NAME','COMPANY_NAME','CATEGORY','LIMIT_REF') ->orderBy('SHORT_NAME', 'ASC') ->limit(100); return $data; @@ -208,6 +208,19 @@ class Account extends Model return $data; } + public function getAccountRK($cusNo,$date){ + $data = []; + $data = DB::connection("db2")->table("STG_DB.ACCOUNT AS AC") + ->select('AC.ACCOUNT_NUMBER','AC.CUSTOMER_NO','CT.SHORT_NAME','AC.WORKING_BALANCE','AC.CURRENCY','AC.SHORT_TITLE','AC.OPENING_DATE','AC.BATCH_DATE','AC.CATEGORY') + ->join('STG_DB.CATEGORY AS CT', 'AC.CATEGORY', '=', 'CT.ID') + ->where('AC.CUSTOMER_NO',$cusNo) + ->where('AC.BATCH_DATE',$date) + ->where('AC.LIMIT_REF', '<>' , 'NULL' ) + ->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660','101']) + ->limit(100); + return $data; + } + public function getLimit($cus_id,$periode){ $timestamp = strtotime($periode); // Format the timestamp into a date format diff --git a/Http/Controllers/KonfirmasiBankController.php b/Http/Controllers/KonfirmasiBankController.php index 75c02f2..f69a544 100644 --- a/Http/Controllers/KonfirmasiBankController.php +++ b/Http/Controllers/KonfirmasiBankController.php @@ -19,7 +19,7 @@ use Modules\Konfirmasibank\Entities\TermAmount; //use Dompdf\Dompdf; use PDF; - //use Dompdf\Options; + use Dompdf\Options; use Carbon\Carbon; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\IOFactory; @@ -333,13 +333,13 @@ $dateCore = $startDate->subDays(2); $Account = new Account; $data = []; - $DataAccounts = []; - $DataPinjaman = []; - $DataFasilitas = []; + $DataAccounts = []; + $DataPinjaman = []; + $DataFasilitas = []; + $DataRK = []; // dd($listAccount); $GetCustomer = $Account->getCustomer($request['cusNo'])->first(); $listAccount = $Account->getAccount($request['cusNo'], $arrAccount, $dateCore )->get(); - $dataAADepo = $Account->getAA($request['cusNo'],$arrAccount, $dateCore)->get(); foreach ($listAccount as $key1 => $account) { $dataAADepo = $Account->getAA($request['cusNo'],$account->ACCOUNT_NUMBER, $dateCore)->first(); @@ -382,6 +382,8 @@ } + + $Arrangement = $Account->getPinjaman($request['cusNo'], $dateCore)->get(); foreach ($Arrangement as $key2 => $pinjaman) { $balance = $Account->getSingleAccount($pinjaman->LINKED_APPL_ID,$startDate)->first(); @@ -398,8 +400,27 @@ $DataPinjaman[$key2]['ACCOUNT_NUMBER'] = $pinjaman->LINKED_APPL_ID; } - $fasilitas = Fasilitas::where('nomor_cif',$request['cusNo'] )->where('status',1)->get(); + $listAccountRK = $Account->getAccountRK($request['cusNo'], $dateCore )->get(); + foreach ($listAccountRK as $rk => $valRk) { + if ( $valRk->CATEGORY == '1003') { + $DataRK[$rk]['ACCOUNT_NUMBER'] = $valRk->ACCOUNT_NUMBER; + $DataRK[$rk]['OPENING_DATE'] = $valRk->OPENING_DATE; + $DataRK[$rk]['BATCH_DATE'] = $valRk->BATCH_DATE; + $DataRK[$rk]['CUSTOMER_NO'] = $valRk->CUSTOMER_NO; + $DataRK[$rk]['SHORT_NAME'] = $valRk->SHORT_NAME; + $DataRK[$rk]['CURRENCY'] = $valRk->CURRENCY; + $DataRK[$rk]['PRODUCT'] = $valRk->SHORT_TITLE; + $DataRK[$rk]['WORKING_BALANCE'] = $valRk->WORKING_BALANCE != null ? number_format($valRk->WORKING_BALANCE, 2, ',', '.') : 'NIHIL'; + $DataRK[$rk]['MATURITY_DATE'] = '' ; + $DataRK[$rk]['ARRANGEMENT_ID'] = ''; + $DataRK[$rk]['FIXED_RATE'] = ''; + $DataRK[$rk]['TERM'] = ''; + } + + } + + $fasilitas = Fasilitas::where('nomor_cif',$request['cusNo'] )->where('status',1)->get(); foreach ($fasilitas as $key3 => $val3) { $DataFasilitas[$key3]['jenis_fasilitas'] = $val3->jenis_fasilitas; $DataFasilitas[$key3]['start_date'] = $val3->start_date; @@ -424,6 +445,7 @@ $data['DataAccounts'] = $DataAccounts; $data['DataPinjaman'] = $DataPinjaman; + $data['DataRK'] = $DataRK ; $data['DataLimit'] = $ListLimits; $data['DataFasilitas']= $DataFasilitas; $data['DataSigner'] = $signer; @@ -437,13 +459,30 @@ // dd($data); $pdf = PDF::loadview('konfirmasibank::exportPdf',['data'=>$data]); + // Set page script to disable header on the first page + // Set options for DOMPDF as needed + $pdf->render(); - // $canvas = $domPdf->get_canvas(); - // $canvas->page_text(10, 10, "Page {PAGE_NUM} of {PAGE_COUNT}", null, 10, [0, 0, 0]); + $canvas = $pdf->get_canvas(); + $cpdf = $canvas->get_cpdf(); - // $font = Font_Metrics::get_font("helvetica", "bold"); - //$domPdf->get_canvas()->page_text(72, 18, "Header: {PAGE_NUM} of {PAGE_COUNT}", null, 6, array(0,0,0)); + $font = $pdf->getFontMetrics()->get_font("helvetica", "bold"); + + $firstPageId = $cpdf->getFirstPageId(); + $objects = $cpdf->objects; + $pages = array_filter($objects, function($v) { + return $v['t'] == 'page'; + }); + $number = 1; + foreach($pages as $pageId => $page) { + if(($pageId + 1) !== $firstPageId) { + $canvas->reopen_object($pageId + 1); + $canvas->text(72, 18, "Header: $number", $font, 6, array(0,0,0)); + $canvas->close_object(); + $number++; + } + } $exportTime = Carbon::now(); $filename = "Kobank_" . $request['cusNo'] .'_'.$exportTime->format('YmdHis'). '.PDF'; @@ -695,4 +734,4 @@ - } + } \ No newline at end of file diff --git a/Resources/views/exportPdf.blade.php b/Resources/views/exportPdf.blade.php index ba2853b..0f1116d 100644 --- a/Resources/views/exportPdf.blade.php +++ b/Resources/views/exportPdf.blade.php @@ -13,42 +13,6 @@ } - /** Define the header rules **/ - /* header { - position: fixed; - top: 0cm; - left: 0cm; - right: 0cm; - height: 6.5cm; - - } - - /** Define the footer rules **/ - /* footer { - position: fixed; - bottom: 0cm; - left: 0cm; - right: 0cm; - }, */ - - - /* table { - width: 100%; - border-collapse: collapse; - border: 1px solid #ddd; - } - th, td { - border: 1px solid #ddd; - padding: 3px; - font-size: 12px; - } - th { - background-color: #f2f2f2; - font-weight: bold; - } - tr:nth-child(even) { - background-color: #f2f2f2; - } */ .text-center{ text-align: center; @@ -75,7 +39,7 @@ border-collapse: collapse; } - .no-border-table, + .no-border-table, .no-border-table th, .no-border-table td, .no-border-table tr { @@ -95,20 +59,47 @@ text-align: center; position: fixed; margin-top: 1cm; + + } + .header { - top: 0px; + + position: fixed; + top: -60px; + left: 0px; + right: 0px; + height: 50px; + font-size: 20px !important; + background-color: #000; + color: white; + text-align: center; + line-height: 35px; } + + /* Hide header on first page */ + body:nth-child(1) .header { + display: none; + } + .footer { top: 23cm; } + .pagenum:before { content: counter(page); } + .flyleaf { + page-break-after: always; + } +
+