add module konfirmasibank
This commit is contained in:
0
Http/Controllers/.gitkeep
Normal file
0
Http/Controllers/.gitkeep
Normal file
149
Http/Controllers/KonfirmasiBankController.php
Normal file
149
Http/Controllers/KonfirmasiBankController.php
Normal file
@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\KonfirmasiBank\Http\Controllers;
|
||||
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Modules\KonfirmasiBank\DataTables\ViewAccountDataTable;
|
||||
use Modules\KonfirmasiBank\Entities\ViewAccount;
|
||||
use Dompdf\Dompdf;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\View;
|
||||
class KonfirmasiBankController extends Controller
|
||||
{
|
||||
public $user;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware(function ($request, $next) {
|
||||
$this->user = Auth::guard('web')->user();
|
||||
return $next($request);
|
||||
});
|
||||
|
||||
addVendor('chained-select');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(ViewAccountDataTable $dataTable)
|
||||
{
|
||||
|
||||
if (is_null($this->user) || !$this->user->can('konfirmasibank.read')) {
|
||||
abort(403, 'Sorry !! You are Unauthorized to view any master data !');
|
||||
}
|
||||
|
||||
return $dataTable->render('konfirmasibank::index');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
----- export pdf -----
|
||||
*/
|
||||
public function export(Request $request) {
|
||||
if (is_null($this->user) || !$this->user->can('konfirmasibank.report')) {
|
||||
abort(403, 'Sorry !! You are Unauthorized to view any master data !');
|
||||
}
|
||||
|
||||
$account = explode("," , $request['acc_no']);
|
||||
|
||||
$ViewAccount = new ViewAccount;
|
||||
$data = [];
|
||||
$DataAccounts = [];
|
||||
$DataPinjaman = [];
|
||||
$DataLimit = [];
|
||||
$ListAccount = $ViewAccount->getAccount($request['cus_no'],$account,$request['kode_cabang'],$request['periode']);
|
||||
|
||||
foreach ($ListAccount as $key1 => $account) {
|
||||
$DataAccounts[$key1]['ACCOUNT_NUMBER'] = $account->ACCOUNT_NUMBER;
|
||||
$DataAccounts[$key1]['CUSTOMER_NO'] = $account->CUSTOMER_NO;
|
||||
$DataAccounts[$key1]['CURRENCY'] = $account->CURRENCY;
|
||||
$DataAccounts[$key1]['PRODUCT'] = $account->PRODUCT;
|
||||
$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'] = $account->MATURITY_DATE;
|
||||
$ListBunga =$ViewAccount->getInterest($account->ARRANGEMENT_ID);
|
||||
$ListTenor =$ViewAccount->getTerm($account->ARRANGEMENT_ID);
|
||||
foreach ($ListBunga as $bunga) {
|
||||
if (strpos($bunga->ID ,$account->ARRANGEMENT_ID) !== false) {
|
||||
$DataAccounts[$key1]['FIXED_RATE'] = $bunga->FIXED_RATE;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$ListPinjaman =$ViewAccount->getPinjaman($ListAccount[0]->CUSTOMER_NO);
|
||||
$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;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$DataProducts = [];
|
||||
$ListLimits = $ViewAccount->getLimit($request['cus_no'],$request['periode']);
|
||||
|
||||
$data['DataAccounts'] = $DataAccounts;
|
||||
$data['DataPinjaman'] = $pinjaman;
|
||||
$data['DataLimit'] = $ListLimits;
|
||||
|
||||
$currentDate = Carbon::now();
|
||||
$formattedDate = $currentDate->format('Y-m-d');
|
||||
|
||||
$html = View::make('konfirmasibank::exportPdf', ['data' => $data])->render();
|
||||
|
||||
$pdf = new Dompdf();
|
||||
$pdf->loadHtml($html);
|
||||
|
||||
// Mengatur jenis kertas
|
||||
$pdf->setPaper('f4', 'landscape')->set_option('defaultFont', 'Arial');
|
||||
|
||||
// Render HTML menjadi PDF
|
||||
$pdf->render();
|
||||
|
||||
// Keluarkan file PDF ke browser
|
||||
$pdf->stream('"Konfirmasi_bank_"'.$ListPinjaman[0]->SHORT_NAME.'"'. $formattedDate.'".pdf"');
|
||||
|
||||
// $pdf->render();
|
||||
// return $pdf->stream('Konfirmasi_bank_"'.$ListPinjaman[0]->SHORT_NAME.'"'. $formattedDate.'""');
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
0
Http/Middleware/.gitkeep
Normal file
0
Http/Middleware/.gitkeep
Normal file
0
Http/Requests/.gitkeep
Normal file
0
Http/Requests/.gitkeep
Normal file
Reference in New Issue
Block a user