update array data

This commit is contained in:
KhatamNugraha
2023-10-03 14:02:22 +07:00
parent 6272105c91
commit 909e89a6f8
4 changed files with 52 additions and 45 deletions

View File

@ -39,7 +39,8 @@ class ViewAccount extends Model
]; ];
public function getSearchAccount($cif ,$arrAccount, $kodecabang, $startDate){ public function getSearchAccount($cif ,$arrAccount, $kodecabang, $startDate){
// dd($cif ,$arrAccount, $kodecabang, $startDate);
// dd($cif ,$arrAccount, $kodecabang, $startDate);
$today = Carbon::now(); $today = Carbon::now();
$currentYear = $today->format("Y"); $currentYear = $today->format("Y");
$pastYear = $today->subYear(3)->format('Y'); $pastYear = $today->subYear(3)->format('Y');
@ -52,14 +53,14 @@ class ViewAccount extends Model
if($arrAccount == null){ if($arrAccount == null){
$data = DB::connection("db2")->table("STG_DB.VW_ACCOUNT") $data = DB::connection("db2")->table("STG_DB.VW_ACCOUNTS")
->select( 'CUSTOMER_NO', 'ACCOUNT_NUMBER','SHORT_NAME','BATCH_DATE','INACTIV_MARKER','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE',DB::raw('MAX(WORKING_BALANCE) AS WORKING_BALANCE'),DB::raw('MAX(CATEGORY) AS CATEGORY')) ->select('*')
->where('CUSTOMER_NO',$cif) ->where('CUSTOMER_NO',$cif)
->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%") ->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%")
->where('INACTIV_MARKER', NULL) ->where('INACTIV_MARKER', NULL)
->where('BATCH_DATE', 'LIKE', "%" .$startDate."%") ->where('BATCH_DATE', $startDate)
->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660']) ->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660']);
->groupBy('CUSTOMER_NO','ACCOUNT_NUMBER','SHORT_NAME','BATCH_DATE','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE','INACTIV_MARKER'); // ->groupBy('CUSTOMER_NO','ACCOUNT_NUMBER','SHORT_NAME','BATCH_DATE','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE','INACTIV_MARKER');
}else{ }else{
$data = DB::connection("db2")->table("STG_DB.VW_ACCOUNT") $data = DB::connection("db2")->table("STG_DB.VW_ACCOUNT")
->select('*') ->select('*')
@ -75,26 +76,25 @@ class ViewAccount extends Model
public function getAccount($cif ,$arrAccount, $kodecabang, $startDate){ public function getAccount($cif ,$arrAccount, $kodecabang, $startDate){
// dd($cif ,$arrAccount, $kodecabang, $startDate);
$uppercaseKodeCabang = Str::upper($kodecabang); $uppercaseKodeCabang = Str::upper($kodecabang);
$data = DB::connection("db2")->table("STG_DB.VW_ACCOUNT")
->select( 'CUSTOMER_NO', 'ACCOUNT_NUMBER','SHORT_NAME','BATCH_DATE','INACTIV_MARKER','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE',DB::raw('MAX(WORKING_BALANCE) AS WORKING_BALANCE'),DB::raw('MAX(CATEGORY) AS CATEGORY')) $data = DB::connection("db2")->table("STG_DB.VW_ACCOUNTS")
->select('*')
->where('CUSTOMER_NO',$cif) ->where('CUSTOMER_NO',$cif)
->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%") ->where('COMPANY_NAME', 'like', "%" .$uppercaseKodeCabang."%")
->where('INACTIV_MARKER', NULL) ->where('INACTIV_MARKER', NULL)
->where('BATCH_DATE', 'LIKE', "%" .$startDate."%") ->where('BATCH_DATE', 'like', "%" .$startDate."%")
->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660','101']) //->whereIn(DB::raw("LEFT(CATEGORY, 3)"),['100','600','660'])
->whereIn('ACCOUNT_NUMBER', $arrAccount) ->whereIn('ACCOUNT_NUMBER', $arrAccount);
->groupBy('CUSTOMER_NO','ACCOUNT_NUMBER','SHORT_NAME','BATCH_DATE','SHORT_TITLE','CURRENCY','COMPANY_NAME','OPENING_DATE','INACTIV_MARKER');
return $data; return $data;
} }
public function getAAaccount($cust){ public function getAAaccount($cust, $acc){
$data = []; $data = [];
$data = DB::connection("db2")->table("STG_DB.VW_AA_ARR")->select('ARRANGEMENT_ID','CATEGORY','CATEGORY_NAME','PRODUCT_LINE','PRODUCT','CUSTOMER','LINKED_APPL_ID','MATURITY_DATE') $data = DB::connection("db2")->table("STG_DB.VW_AA_ACCOUNT")->select('*')
// ->where('CUSTOMER', $cif) // ->where('CUSTOMER', $cif)
->where('CUSTOMER', $cust) ->where('CUSTOMER', $cust)
->where('CATEGORY', 3); ->where('LINKED_APPL_ID', $acc);
return $data; return $data;
} }

View File

@ -73,23 +73,23 @@
public function getData(Request $request) public function getData(Request $request)
{ {
$data = []; $data = [];
$Account = new ViewAccount; $Account = new ViewAccount;
$arrAccount = []; $arrAccount = [];
$startDate = Carbon::parse($request->startDate); $startDate = Carbon::parse($request->startDate);
// $endtDate = Carbon::parse($request->endDate); $dateCore = $startDate->subDays(2);
// $startDateCore = $startDate->subDays(2)->format("Y-m-d");
// $endDateCore = $endDate->subDays(2)->format("Y-m-d");
$Accounts = $Account->getSearchAccount($request->cif,$arrAccount,$request->kodecabang, $request->startDate)->get(); $Accounts = $Account->getSearchAccount($request->cif,$arrAccount,$request->kodecabang, $dateCore)->get();
$Arrangement = $Account->getAAaccount($request->cif)->get();
// $Arrangement = $Account->getAAaccount($request->cif)->get();
$maturityDate = ''; $maturityDate = '';
$aaID= ''; $aaID= '';
$product = ''; $product = '';
foreach ($Accounts as $key => $account) { foreach ($Accounts as $key => $account) {
$Arrangement = $Account->getAAaccount($request->cif , $account->ACCOUNT_NUMBER)->first();
$data[$key]['CUSTOMER_NO'] = $account->CUSTOMER_NO; $data[$key]['CUSTOMER_NO'] = $account->CUSTOMER_NO;
$data[$key]['INACTIV_MARKER'] = $account->INACTIV_MARKER; $data[$key]['INACTIV_MARKER'] = $account->INACTIV_MARKER;
@ -100,8 +100,8 @@
$data[$key]['SHORT_NAME'] = $account->SHORT_NAME; $data[$key]['SHORT_NAME'] = $account->SHORT_NAME;
$data[$key]['CURRENCY'] = $account->CURRENCY; $data[$key]['CURRENCY'] = $account->CURRENCY;
$data[$key]['OPENING_DATE'] = Carbon::parse($account->OPENING_DATE)->format('d-m-Y'); $data[$key]['OPENING_DATE'] = Carbon::parse($account->OPENING_DATE)->format('d-m-Y');
$data[$key]['MATURITY_DATE'] = $Arrangement[$key]->MATURITY_DATE ?? 'NIHIL'; $data[$key]['MATURITY_DATE'] = $Arrangement->MATURITY_DATE ?? 'NIHIL';
$data[$key]['PRODUCT'] = $Arrangement[$key]->PRODUCT ?? 'NIHIL'; $data[$key]['PRODUCT'] = $Arrangement->PRODUCT ?? 'NIHIL';
} }
@ -118,15 +118,18 @@
} }
$arrAccount = explode("," , $request['acc_no']); $arrAccount = explode("," , $request['acc_no']);
$ViewAccount = new ViewAccount; $ViewAccount = new ViewAccount;
$data = []; $data = [];
$DataAccounts = []; $DataAccounts = [];
$DataPinjaman = []; $DataPinjaman = [];
$DataLimit = []; $DataLimit = [];
$DataAA = []; $DataAA = [];
$listAccount = $ViewAccount->getAccount($request['cus_no'],$arrAccount,$request['kode_cabang'],$request->startDate)->get();
$listAccount = $ViewAccount->getAccount($request['cus_no'],$arrAccount,$request['kode_cabang'], $request['startDate'])->get();
$GetCustomer = $ViewAccount->getCustomer($request['cus_no'])->first(); $GetCustomer = $ViewAccount->getCustomer($request['cus_no'])->first();
$Arrangement = $ViewAccount->getAAaccount($request['cus_no'])->get();
// dd( $Arrangement); // dd( $Arrangement);
$MaturityDate = ''; $MaturityDate = '';
@ -134,23 +137,26 @@
$AAID= ''; $AAID= '';
foreach ($listAccount as $key1 => $account) { foreach ($listAccount as $key1 => $account) {
//$Arrangement = $ViewAccount->getAAaccount($account->CUSTOMER_NO,$account->ACCOUNT_NUMBER); //$Arrangement = $ViewAccount->getAAaccount($account->CUSTOMER_NO,$account->ACCOUNT_NUMBER);
$Arrangement = $ViewAccount->getAAaccount($request['cus_no'] , $account->ACCOUNT_NUMBER)->first();
$DataAccounts[$key1]['ACCOUNT_NUMBER'] = $account->ACCOUNT_NUMBER; $DataAccounts[$key1]['ACCOUNT_NUMBER'] = $account->ACCOUNT_NUMBER;
$DataAccounts[$key1]['CUSTOMER_NO'] = $account->CUSTOMER_NO; $DataAccounts[$key1]['CUSTOMER_NO'] = $account->CUSTOMER_NO;
$DataAccounts[$key1]['SHORT_NAME'] = $account->SHORT_NAME; $DataAccounts[$key1]['SHORT_NAME'] = $account->SHORT_NAME;
$DataAccounts[$key1]['CURRENCY'] = $account->CURRENCY; $DataAccounts[$key1]['CURRENCY'] = $account->CURRENCY;
$DataAccounts[$key1]['PRODUCT'] = $Arrangement->PRODUCT;
$DataAccounts[$key1]['PRODUCT'] = $product ?? '-';
$DataAccounts[$key1]['COMPANY_NAME'] = $account->COMPANY_NAME; $DataAccounts[$key1]['COMPANY_NAME'] = $account->COMPANY_NAME;
$DataAccounts[$key1]['WORKING_BALANCE'] = $account->WORKING_BALANCE; $DataAccounts[$key1]['WORKING_BALANCE'] = $account->WORKING_BALANCE;
$DataAccounts[$key1]['MATURITY_DATE'] = (count($Arrangement) > 0) ? date('d-m-Y',strtotime($Arrangement[$key1]->MATURITY_DATE)) : 'NIHIL' ; $DataAccounts[$key1]['MATURITY_DATE'] = $Arrangement->MATURITY_DATE ?? 'NIHIL' ;
$DataAccounts[$key1]['ARRANGEMENT_ID'] = (count($Arrangement) > 0) ? $Arrangement[$key1]->ARRANGEMENT_ID : 'NIHIL' ; $DataAccounts[$key1]['ARRANGEMENT_ID'] = $Arrangement->ARRANGEMENT_ID ?? 'NIHIL';
$DataAccounts[$key1]['FIXED_RATE'] = $Arrangement[$key1]->FIXED_RATE ?? 'NIHIL'; $DataAccounts[$key1]['FIXED_RATE'] = $Arrangement->FIXED_RATE ?? 'NIHIL';
$DataAccounts[$key1]['TERM'] = $Arrangement[$key1]->TERM ?? 'NIHIL'; $DataAccounts[$key1]['TERM'] = $Arrangement->TERM ?? 'NIHIL';
} }
$ListPinjaman =$ViewAccount->getPinjaman($request['cus_no'],$arrAccount )->get(); $ListPinjaman =$ViewAccount->getPinjaman($request['cus_no'],$arrAccount )->get();
$ListLimits = $ViewAccount->getLimit($request['cus_no'],$request['periode']); $ListLimits = $ViewAccount->getLimit($request['cus_no'],$request['periode']);
$fasilitas = Fasilitas::where('nomor_cif',$request['cus_no'] )->where('status',1)->get(); $fasilitas = Fasilitas::where('nomor_cif',$request['cus_no'] )->where('status',1)->get();
@ -158,7 +164,7 @@
$currentDate = Carbon::now(); $currentDate = Carbon::now();
$tanggalIndonesia = $currentDate->locale('id')->isoFormat('D MMMM YYYY'); $tanggalIndonesia = $currentDate->locale('id')->isoFormat('D MMMM YYYY');
$data['DataAccounts'] = $listAccount; $data['DataAccounts'] = $DataAccounts;
$data['DataPinjaman'] = $ListPinjaman; $data['DataPinjaman'] = $ListPinjaman;
$data['DataLimit'] = $ListLimits; $data['DataLimit'] = $ListLimits;
$data['DataFasilitas'] = $fasilitas; $data['DataFasilitas'] = $fasilitas;

View File

@ -112,14 +112,15 @@
@foreach ($data['DataAccounts'] as $val) @foreach ($data['DataAccounts'] as $val)
<tr class="space1"> <tr class="space1">
<td class="text-center space1">{{ $i++ }}</td> <td class="text-center space1">{{ $i++ }}</td>
<td class="space1">{{ $val->ACCOUNT_NUMBER }}</td> <td class="space1">{{ $val['ACCOUNT_NUMBER'] }}</td>
<td class="space1">{{ $val->COMPANY_NAME }}</td> <td class="space1">{{ $val['COMPANY_NAME'] }}</td>
<td class="space1">{{ $val->SHORT_NAME }}</td> <td class="space1">{{ $val['SHORT_NAME'] }}</td>
<td class="text-center space1 texet-center">{{ $val->CURRENCY }}</td> <td class="text-center space1 texet-center">{{ $val['CURRENCY'] }}</td>
<td class="space1">{{ $val->WORKING_BALANCE }}</td> <td class="space1">{{ $val['WORKING_BALANCE'] }}</td>
<td class="text-center space1">{{ $val->TERM ?? 'NIHIL'}}</td> <td class="text-center space1">{{ $val['TERM'] }} </td>
<td class="text-center space1">{{ $val->FIXED_RATE ?? 'NIHIL' }}</td> <td class="text-center space1">{{ $val['FIXED_RATE'] }}</td>
<td class="text-center space1">{{ $val->MATURITY_DATE ?? 'NIHIL' }}</td> <td class="text-center space1">{{ $val['MATURITY_DATE'] }}</td>
</tr> </tr>
@endforeach @endforeach
@else @else
@ -161,7 +162,7 @@
<td class="space1">{{ $pinjaman->WORKING_BALANCE }}</td> <td class="space1">{{ $pinjaman->WORKING_BALANCE }}</td>
<td class="text-center space1">{{ $pinjaman->TERM }}</td> <td class="text-center space1">{{ $pinjaman->TERM }}</td>
<td class="text-center space1">{{ $pinjaman->FIXED_RATE }}</td> <td class="text-center space1">{{ $pinjaman->FIXED_RATE }}</td>
<td class="center space1">{{ \Carbon\Carbon::parse($pinjaman->MATURITY_DATE)->format('d-m-Y') }}</td> <td class="center space1">{{ $pinjaman->MATURITY_DATE }}</td>
</tr> </tr>
@endforeach @endforeach
@else @else

View File

@ -42,9 +42,9 @@
</div> </div>
</div> </div>
<div class="row mb-3"> <div class="row mb-3">
<label for="colFormLabelSm" class="col-sm-2 col-form-label col-form-label-sm">Periode <span style="color:red">*</span></label> <label for="colFormLabelSm" class="col-sm-2 col-form-label col-form-label-sm">Tanggal <span style="color:red">*</span></label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="number" class="form-control form-control-sm" min="{{$data['pastYear']}}" max="{{$data['currentYear']}}" name="startDate" clear id="startDate" placeholder="Tanggal Mulai"> <input type="date" class="form-control form-control-sm" min="{{$data['pastYear']}}" max="{{$data['currentYear']}}" name="startDate" clear id="startDate" placeholder="Tanggal Mulai">
</div> </div>
{{-- <div class="col-sm-1"> {{-- <div class="col-sm-1">
<label for="colFormLabelSm" class="col-form-label col-form-label-sm">S/D</label> <label for="colFormLabelSm" class="col-form-label col-form-label-sm">S/D</label>