fix export

This commit is contained in:
KhatamNugraha
2024-05-29 08:45:05 +07:00
parent a757b4b123
commit fa207d010d
2 changed files with 68 additions and 22 deletions

View File

@ -101,12 +101,33 @@ class KonfirmasiBankController extends Controller
$data = [];
$Account = new Account();
$arrAccount = [];
$dataAccount = [];
$startDate = Carbon::parse($request->startDate);
$dateCore = $startDate->addDays(2)->format('m/d/Y');
$Accounts = $Account->getSearchAccount($request->cif, $arrAccount, $request->kodecabang, $dateCore)->get();
//$dateCore = $startDate->format('m/d/Y');
$Accounts = $Account->getSearchAccount($request->cif, $arrAccount, $request->kodecabang, $startDate)->get();
if ($Accounts->isEmpty()) {
$Accounts = $Account->getSearchAccount($request->cif, $arrAccount, $request->kodecabang, $startDate->subDays(1)->format('m/d/Y'))->get();
if($Accounts->isEmpty()){
$Accounts = $Account->getSearchAccount($request->cif, $arrAccount, $request->kodecabang, $startDate->subDays(2)->format('m/d/Y'))->get();
if ($Accounts->isEmpty()) {
$Accounts = $Account->getSearchAccount($request->cif, $arrAccount, $request->kodecabang, $startDate->subDays(3)->format('m/d/Y'))->get();
if ($Accounts->isEmpty()) {
$Accounts = $Account->getSearchAccount($request->cif, $arrAccount, $request->kodecabang, $startDate->subDays(4)->format('m/d/Y'))->get();
if ($Accounts->isEmpty()) {
$Accounts = $Account->getSearchAccount($request->cif, $arrAccount, $request->kodecabang, $startDate->subDays(5)->format('m/d/Y'))->get();
}
}
}
}
} else {
$Accounts = $Account->getSearchAccount($request->cif, $arrAccount, $request->kodecabang, $startDate)->get();
}
foreach ($Accounts as $key => $value) {
$data[$key]['ACCOUNT_NUMBER'] = $value->ACCOUNT_NUMBER;
$data[$key]['COMPANY_NAME'] = $value->COMPANY_NAME;
$data[$key]['SHORT_NAME'] = $value->SHORT_NAME;
@ -346,8 +367,9 @@ class KonfirmasiBankController extends Controller
public function export(Request $request)
{
$arrAccount = explode(",", $request['accNo']);
$startDate = Carbon::parse($request['startDate2']);
$dateCore = $startDate->addDays(2);
// $startDate = Carbon::parse($request['startDate2']);
// dd($tanggal1 );
$dateCore = Carbon::parse($request['startDate2']);;
// dd( $dateCore);
$Account = new Account();
$data = [];
@ -358,10 +380,31 @@ class KonfirmasiBankController extends Controller
$rekEscrow = [];
$DataAnjak = [];
$GetCustomer = $Account->getCustomer($request['cusNo'])->first();
$listAccount = $Account->getAccount($request['cusNo'], $arrAccount, $dateCore)->get();
// DD($listAccount);
$listAccount = $Account->getAccount($request['cusNo'], $arrAccount, $dateCore->format('m/d/Y'))->get();
try {
if ($listAccount->isEmpty()) {
$dateCore = $dateCore->subDays(1)->format('m/d/Y');
$listAccount = $Account->getAccount($request['cusNo'], $arrAccount, $dateCore)->get();
if($listAccount->isEmpty()){
$dateCore = $dateCore->subDays(2)->format('m/d/Y');
$listAccount = $Account->getAccount($request['cusNo'], $arrAccount, $dateCore)->get();
if ($listAccount->isEmpty()) {
$dateCore = $dateCore->subDays(3)->format('m/d/Y');
$listAccount = $Account->getAccount($request['cusNo'], $arrAccount, $dateCore)->get();
if ($listAccount->isEmpty()) {
$dateCore = $dateCore->subDays(4)->format('m/d/Y');
$listAccount = $Account->getAccount($request['cusNo'], $arrAccount, $dateCore)->get();
if ($listAccount->isEmpty()) {
$dateCore = $dateCore->subDays(5)->format('m/d/Y');
$listAccount = $Account->getAccount($request['cusNo'], $arrAccount, $dateCore)->get();
}
}
}
}
}
// try {
foreach ($listAccount as $key1 => $account) {
$dataAADepo = $Account->getArr($request['cusNo'], $account->ACCOUNT_NUMBER, $dateCore)->first();
@ -373,11 +416,12 @@ class KonfirmasiBankController extends Controller
$tglRenewal = $tanggal_1->format('d');
$tanggal_2 = date_create($dataAADepo->BASE_DATE);
$tenor = date_diff($tanggal_1, $tanggal_2);
$batchDate = $dateCore->format('Y-m-d');
$maturityDate = Carbon::createFromFormat('Y-m-d', $batchDate);
$batchDate = strtotime($dateCore);
$startDate = date("Y-m-d", $batchDate); // Tanggal mulai pinjaman
$maturityDate = Carbon::createFromFormat('Y-m-d', $startDate);
$tenorFix = $tenor->days >= 30 ? intval($tenor->days / 30) : 1;
$startDate = $batchDate; // Tanggal mulai pinjaman
$startDate = date("Y-m-d", $batchDate); // Tanggal mulai pinjaman
// // Konversi tanggal mulai ke objek Carbon
$tanggalMulai = Carbon::parse($startDate);
// // Hitung tanggal jatuh tempo dengan menambahkan durasi hari
@ -499,9 +543,9 @@ class KonfirmasiBankController extends Controller
$ListLimits = $Account->getLimit($request['cusNo'], $request['startDate2'])->get();
$signer = Signer::where('id', $request['signerId'])->where('status', 1)->get();
$batchDateSearch = Carbon::parse($request['startDate2']);
$batchDate = Carbon::parse($request['startDate2']);
$currentDate = Carbon::now();
$tanggalIndonesia = strtoupper($batchDateSearch->locale('id')->isoFormat('D MMMM YYYY')); // Mengubah seluruh string menjadi huruf besar
$tanggalIndonesia = strtoupper($batchDate->locale('id')->isoFormat('D MMMM YYYY')); // Mengubah seluruh string menjadi huruf besar
$today = strtoupper($currentDate->locale('id')->isoFormat('D MMMM YYYY'));
$letter = new Letters();
$infoSuratNew = $letter->where('no_cif', $request['cusNo'])->orderBy('id', 'DESC')->first();
@ -561,9 +605,9 @@ class KonfirmasiBankController extends Controller
return $pdf->stream($filename);
} catch (Exception $e) {
echo json_encode(['status' => 'error', 'message' => $e->getMessage()]);
}
// } catch (Exception $e) {
// echo json_encode(['status' => 'error', 'message' => $e->getMessage()]);
// }
// return false;