fixing export pdf

This commit is contained in:
KhatamNugraha
2024-02-22 08:47:31 +07:00
parent 3c8cce3921
commit 48aa12d23d
2 changed files with 4 additions and 200 deletions

View File

@ -103,26 +103,6 @@
$Accounts = $Account->getSearchAccount($request->cif,$arrAccount,$request->kodecabang, $dateCore)->get();
// $product = '';
// foreach ($Accounts as $key => $account) {
// $Arrangement = $Account->getAAaccount($request->cif , $account->ACCOUNT_NUMBER)->first();
// $data[$key]['CUSTOMER_NO'] = $account->CUSTOMER_NO;
// $data[$key]['INACTIV_MARKER'] = $account->INACTIV_MARKER;
// $data[$key]['ACCOUNT_NUMBER'] = $account->ACCOUNT_NUMBER;
// $data[$key]['COMPANY_NAME'] = $account->COMPANY_NAME;
// $data[$key]['SHORT_TITLE'] = $account->SHORT_TITLE;
// $data[$key]['WORKING_BALANCE'] = $account->WORKING_BALANCE;
// $data[$key]['SHORT_NAME'] = $account->SHORT_NAME;
// $data[$key]['CURRENCY'] = $account->CURRENCY;
// $data[$key]['BATCH_DATE'] = $account->BATCH_DATE;
// $data[$key]['OPENING_DATE'] = '';
// $data[$key]['MATURITY_DATE'] = '';
// $data[$key]['PRODUCT'] = '';
// }
return json_encode($Accounts );
}
@ -136,11 +116,6 @@
abort(403, 'Sorry !! You are Unauthorized to view any master data !');
}
$arrAccount = explode("," , $request['acc_no']);
$startDate = Carbon::parse($request['startDate']);
$dateCore = $startDate->subDays(2);
@ -342,177 +317,6 @@
}
public function exportWord(Request $request){
//ob_start();
$currentDate = Carbon::now();
$arrAccount = explode("," , $request['acc_no']);
$startDate = Carbon::parse($request['startDate']);
$dateCore = $startDate->subDays(2);
$ViewAccount = new ViewAccount;
$data = [];
$DataAccounts = [];
$DataPinjaman = [];
$DataLimit = [];
$DataAA = [];
$listAccount = $ViewAccount->getAccount($request['cus_no'],$arrAccount,$request['kode_cabang'], $dateCore)->get();
$GetCustomer = $ViewAccount->getCustomer($request['cus_no'])->first();
// dd( $Arrangement);
$MaturityDate = '';
$product = '';
$AAID= '';
foreach ($listAccount as $key1 => $account) {
//$Arrangement = $ViewAccount->getAAaccount($account->CUSTOMER_NO,$account->ACCOUNT_NUMBER);
$Arrangement = $ViewAccount->getAAaccount($request['cus_no'] , $account->ACCOUNT_NUMBER)->first();
$DataAccounts[$key1]['SHORT_NAME'] = $account->SHORT_NAME;
$DataAccounts[$key1]['OPENING_DATE'] = $account->OPENING_DATE;
$DataAccounts[$key1]['WORKING_BALANCE'] = $account->WORKING_BALANCE;
$DataAccounts[$key1]['TERM'] = $Arrangement->TERM ?? 'NIHIL';
$DataAccounts[$key1]['FIXED_RATE'] = $Arrangement->FIXED_RATE ?? 'NIHIL';
$DataAccounts[$key1]['MATURITY_DATE'] = $Arrangement->MATURITY_DATE ?? 'NIHIL' ;
}
$ListPinjaman =$ViewAccount->getPinjaman($request['cus_no'],$arrAccount , $dateCore )->get();
foreach ($ListPinjaman as $key2 => $pinjaman) {
//$Arrangement = $ViewAccount->getAAaccount($request['cus_no'] , $account->ACCOUNT_NUMBER)->first();
$DataPinjaman[$key2]['JENIS_PINJAMAN'] = $pinjaman->PRODUCT_LINE;
$DataPinjaman[$key2]['TGL_REALISASI'] = $pinjaman->START_DATE;
$DataPinjaman[$key2]['SALDO'] = $pinjaman->WORKING_BALANCE;
$DataPinjaman[$key2]['JANGKA_WAKTU'] = $pinjaman->TERM ?? 'NIHIL';
$DataPinjaman[$key2]['FIXED_RATE'] = $pinjaman->FIXED_RATE ?? 'NIHIL';
$DataPinjaman[$key2]['MATURITY_DATE'] = $pinjaman->MATURITY_DATE ?? 'NIHIL' ;
$DataPinjaman[$key2]['KET'] = '';
}
$signer = Signer::where('id', $request['signer'])->where('status',1)->first();
$currentDate = Carbon::now();
$tanggalIndonesia = $currentDate->locale('id')->isoFormat('D MMMM YYYY');
$GetCustomer = $ViewAccount->getCustomer($request['cus_no'])->first();
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection(array('marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 2500, 'marginBottom' => 600) );
$header = array('size' => 10, 'bold' => false);
$styleTable = array('borderSize' => 2, 'borderColor' => '00000');
$styleFirstRow = array('bgColor' => 'CCCCCC','cellMargin' => 0, 'spaceBefore' => 0,'spaceAfter' => 0,'spacing' => 0);
$styleCell = array('valign' => 'center','spaceBefore' => 0,'spaceAfter' => 0,'spacing' => 0, 'bgColor' => 'CCCCCC');
$styleCellBTLR = array('valign' => 'center', 'textDirection' => \PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR);
$fontStyle = array('align' => 'center', 'size' => 10, );
$section->addText(htmlspecialchars('NOMOR : --------------------------'), $fontStyle);
$section->addText(htmlspecialchars('TANGGAL : --------------------------'), $fontStyle);
$section->addTextBreak(1);
$section->addText(htmlspecialchars($GetCustomer->STREET), $fontStyle);
$section->addText(htmlspecialchars($GetCustomer->ADDRESS), $fontStyle);
$section->addText(htmlspecialchars('Sesuai dengan surat saudara Nomor --------------------------- tanggal ----------------------- dengan ini kami sampaikan data data nasabah sesuai permintaan saudara sebagai berikut :'), $fontStyle);
$section->addText(htmlspecialchars('NAMA NASABAH : '.$GetCustomer->SHORT_NAME.''), $fontStyle);
$section->addText(htmlspecialchars('NOMOR CIF : '.$GetCustomer->CUSTOMER_NO.''), $fontStyle);
$section->addTextBreak(1);
// $phpWord->addTableStyle('Fancy Table', $styleTable, $styleFirstRow);
$section->addText(htmlspecialchars('SIMPANAN NASABAH YANG BERSANGKUTAN PADA BANK'), $header);
$section->addText(htmlspecialchars("{$tanggalIndonesia}"), $header);
$table = $section->addTable(array('borderSize' => 6, 'fontSize' =>10, 'borderColor' => 'black', 'width' => 10500, 'unit' => TblWidth::TWIP));
$table->addRow(300);
$table->addCell(600, $styleCell)->addText(htmlspecialchars("NO"), $fontStyle, array('align' => 'center','spaceAfter'=>0));
$table->addCell(2000, $styleCell)->addText(htmlspecialchars('JENIS REKENING'), $fontStyle,array('align' => 'center','spaceAfter'=>0));
$table->addCell(1500, $styleCell)->addText(htmlspecialchars('TGL REALISASI'), $fontStyle,array('align' => 'center','spaceAfter'=>0));
$table->addCell(1000, $styleCell)->addText(htmlspecialchars('SALDO'), $fontStyle,array('align' => 'center','spaceAfter'=>0));
$table->addCell(1500, $styleCell)->addText(htmlspecialchars('JANGKA WAKTU'), $fontStyle,array('align' => 'center','spaceAfter'=>0));
$table->addCell(1000, $styleCell)->addText(htmlspecialchars('SUKU BUNGA'), $fontStyle,array('align' => 'center','spaceAfter'=>0));
$table->addCell(1500, $styleCell)->addText(htmlspecialchars('TGL JT TEMPO'), $fontStyle,array('align' => 'center','spaceAfter'=>0));
$table->addCell(1000, $styleCell)->addText(htmlspecialchars('KET'), $fontStyle,array('align' => 'center','spaceAfter'=>0));
$no = 1;
foreach ($DataAccounts as $key1 => $value1) {
$rupiah = $this->convertToRupiah($value1['WORKING_BALANCE']);
$table->addRow();
$table->addCell(600)->addText(htmlspecialchars($no++), $fontStyle, array('align' => 'center','spaceAfter'=>0));
$table->addCell(2000)->addText(htmlspecialchars(" {$value1['SHORT_NAME']}"), array('align' => 'left','spaceAfter'=>0));
$table->addCell(1500)->addText(htmlspecialchars(" {$value1['OPENING_DATE']}"), array('align' => 'center','spaceAfter'=>0));
$table->addCell(1000)->addText(htmlspecialchars(" {$rupiah}"), array('align' => 'left','spaceAfter'=>0));
$table->addCell(1500)->addText(htmlspecialchars(" {$value1['TERM']}"), array('align' => 'center','spaceAfter'=>0));
$table->addCell(1000)->addText(htmlspecialchars(" {$value1['FIXED_RATE']}"), array('align' => 'center','spaceAfter'=>0));
$table->addCell(1500)->addText(htmlspecialchars(" {$value1['MATURITY_DATE']}"), array('align' => 'center','spaceAfter'=>0));
$table->addCell(1000)->addText(htmlspecialchars(""), array('align' => 'center','spaceAfter'=>0));
}
// 3. Table Pinjaman
$section->addTextBreak(1);
$section->addText(htmlspecialchars('PINJAMAN YANG DIBERIKAN BANK KEPADA NASABAH'), $header);
$section->addText(htmlspecialchars("{$tanggalIndonesia}"), $header);
$table2 = $section->addTable(array('borderSize' => 6, 'fontSize' =>10, 'borderColor' => 'black', 'width' => 10500, 'unit' => TblWidth::TWIP));
$table2->addRow(300);
$table2->addCell(600, $styleCell)->addText(htmlspecialchars("NO"), $fontStyle, array('align' => 'center','spaceAfter'=>0));
$table2->addCell(2000, $styleCell)->addText(htmlspecialchars('JENIS REKENING'), $fontStyle, array('align' => 'center'));
$table2->addCell(1500, $styleCell)->addText(htmlspecialchars('TGL REALISASI'), $fontStyle, array('align' => 'center'));
$table2->addCell(1000, $styleCell)->addText(htmlspecialchars('SALDO'), $fontStyle, array('align' => 'center'));
$table2->addCell(1500, $styleCell)->addText(htmlspecialchars('JANGKA WAKTU'), $fontStyle, array('align' => 'center'));
$table2->addCell(1000, $styleCell)->addText(htmlspecialchars('SUKU BUNGA'), $fontStyle, array('align' => 'center'));
$table2->addCell(1500, $styleCell)->addText(htmlspecialchars('TGL JT TEMPO'), $fontStyle, array('align' => 'center'));
$table2->addCell(1000, $styleCell)->addText(htmlspecialchars('KET'), $fontStyle, array('align' => 'center'));
$no = 1;
foreach ($DataPinjaman as $key2 => $value2) {
$rupiah = $this->convertToRupiah($value2['SALDO']);
$table2->addRow();
$table2->addCell(600)->addText(htmlspecialchars($no++), $fontStyle, array('align' => 'center'));
$table2->addCell(1500)->addText(htmlspecialchars(" {$value2['JENIS_PINJAMAN']}"), array('align' => 'center'));
$table2->addCell(1000)->addText(htmlspecialchars(" {$value2['TGL_REALISASI']}"), array('align' => 'center'));
$table2->addCell(1500)->addText(htmlspecialchars(" {$rupiah}"), array('align' => 'right'));
$table2->addCell(1000)->addText(htmlspecialchars(" {$value2['JANGKA_WAKTU']}"), array('align' => 'center'));
$table2->addCell(1500)->addText(htmlspecialchars(" {$value2['FIXED_RATE']}"), array('align' => 'center'));
$table2->addCell(1500)->addText(htmlspecialchars(" {$value2['MATURITY_DATE']}"), array('align' => 'center'));
$table2->addCell(1000)->addText(htmlspecialchars(""));
}
//Table Signature
$section->addTextBreak(1);
$section->addText(htmlspecialchars('Demikian data ini kami sampaikan agar dapat digunakan sebagaimana mestinya'), $header);
$signatureStyle = array('size'=>10, 'align' =>'center' );
$table3 = $section->addTable(array('width' => 2000, 'unit' => 'pct', 'align' => 'left'));
$table3->addRow(1000);
$table3->addCell(2000)->addText(htmlspecialchars(''));
$table3->addCell(2000)->addText(htmlspecialchars(''), $signatureStyle);
$table3->addRow();
$table3->addCell(2000)->addText(htmlspecialchars('Frangky'), array('marginLeft' => 600,'size'=>10, ));
$table3->addCell(2000)->addText(htmlspecialchars('Sifera Officer'), $signatureStyle);
$table3->addRow();
$table3->addCell(2000)->addText(htmlspecialchars('Director'), array('marginLeft' => 600,'size'=>10, ));
$table3->addCell(2000)->addText(htmlspecialchars('Executive Officer'), $signatureStyle);
$filename = 'KonfirmasiBank_'.$currentDate->format('YmdHis').'.docx';
// Create writer to convert document to xml
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save($filename);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$filename);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($filename));
flush();
readfile($filename);
unlink($filename); // deletes the temporary file
$objWriter->save($filename);
}
public function convertToRupiah($amount)
{