feature/modal-online-pendahuluan
This commit is contained in:
@@ -2586,108 +2586,114 @@ class KhazanahController extends Controller
|
||||
}
|
||||
|
||||
//print lejer_AM
|
||||
public function cetak_lejer_am(Request $request)
|
||||
{
|
||||
public function cetak_lejer_am(Request $request)
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
$api_url = config('api.url');
|
||||
|
||||
$auth_user = Auth::user();
|
||||
$api_url = config('api.url');
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
||||
$cawangan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/cawangan/detail/'.$auth_user['cawangan'])->json();
|
||||
$cawangan_detail = $cawangan[0];
|
||||
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
||||
$cawangan=Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/cawangan/detail/'.$auth_user['cawangan'])->json();
|
||||
$cawangan_detail=$cawangan[0];
|
||||
$num = $request->num;
|
||||
$current = new Carbon();
|
||||
$tarikh_cetak = $current->toDateString();
|
||||
|
||||
$auth_user = Auth::user();
|
||||
$api_url = config('api.url');
|
||||
// fix: bagi default value supaya $tarikh_mula / $tarikh_akhir tak undefined
|
||||
$tarikh_mula = $tarikh_cetak;
|
||||
$tarikh_akhir = $tarikh_cetak;
|
||||
|
||||
$num=$request->num;
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
$tarikh_cetak = $current->toDateString();
|
||||
|
||||
if($request->datetimepicker1 == null){
|
||||
$tarikh_cetak = $current->toDateString();
|
||||
}else {
|
||||
$split_date = explode('-',$request->datetimepicker1);
|
||||
$tarikh_mula = $split_date[2] . '-' . $split_date[1] . '-' . $split_date[0];
|
||||
}
|
||||
|
||||
if($request->datetimepicker2 == null){
|
||||
$tarikh_cetak = $current->toDateString();
|
||||
}
|
||||
else{
|
||||
$split_date = explode('-',$request->datetimepicker2);
|
||||
$tarikh_akhir = $split_date[2] . '-' . $split_date[1] . '-' . $split_date[0];
|
||||
}
|
||||
|
||||
|
||||
$lejeramdata = Lejeram::orderBy('glcode')->get();
|
||||
$lejeram = array();
|
||||
$len = count($lejeramdata);
|
||||
$totalkredit = 0;
|
||||
$totaldebit = 0;
|
||||
|
||||
foreach($lejeramdata as $index => $lejer)
|
||||
{
|
||||
|
||||
|
||||
if($lejer->api_redirect != null)
|
||||
{
|
||||
${$lejer['variable']} = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). $lejer['api_redirect'] . $auth_user['cawangan'],['mula' => $tarikh_mula, 'hingga' => $tarikh_akhir])->json();
|
||||
|
||||
if($lejer->namadebit == null)
|
||||
{
|
||||
$debit = null;
|
||||
}else{
|
||||
if($lejer->oneVar == 1)
|
||||
{
|
||||
$debit = ${$lejer['variable']};
|
||||
}else{
|
||||
$debit = ${$lejer['variable']}[$lejer->namadebit];
|
||||
}
|
||||
|
||||
$totaldebit += floatval($debit);
|
||||
}
|
||||
|
||||
if($lejer->namakredit == null)
|
||||
{
|
||||
$kredit = null;
|
||||
}else{
|
||||
if($lejer->oneVar == 1)
|
||||
{
|
||||
$kredit = ${$lejer['variable']};
|
||||
}else{
|
||||
$kredit = ${$lejer['variable']}[$lejer->namakredit];
|
||||
}
|
||||
|
||||
$totalkredit += floatval($kredit);
|
||||
}
|
||||
|
||||
if(!($kredit == null && $debit == null))
|
||||
{
|
||||
array_push($lejeram,['glcode' => $lejer->glcode, 'descpt' => $lejer->descpt,'debit' => ($debit) ? $debit : 0,'kredit' => ($kredit) ? $kredit : 0]);
|
||||
}
|
||||
}else{
|
||||
array_push($lejeram,['glcode' => $lejer->glcode, 'descpt' => $lejer->descpt,'debit' => 0,'kredit' => 0]);
|
||||
}
|
||||
|
||||
if($index == $len-1)
|
||||
{
|
||||
$lejeram[0]['debit'] = $totalkredit;
|
||||
$lejeram[0]['kredit'] = $totaldebit;
|
||||
}
|
||||
}
|
||||
|
||||
$totalsamadebit = 0;
|
||||
$totalsamakredit = 0;
|
||||
foreach($lejeram as $index=>$lejer)
|
||||
{
|
||||
$totalsamadebit += floatval($lejer['debit']);
|
||||
$totalsamakredit += floatval($lejer['kredit']);
|
||||
}
|
||||
|
||||
return view('print.laporan_lejer_am',compact('cawangan','tarikh_cetak','cawangan_info', 'api_url','cawangan_detail','tarikh_akhir','tarikh_mula','lejeram','totalsamadebit','totalsamakredit'));
|
||||
if($request->datetimepicker1 != null){
|
||||
$split_date = explode('-', $request->datetimepicker1);
|
||||
$tarikh_mula = $split_date[2] . '-' . $split_date[1] . '-' . $split_date[0];
|
||||
}
|
||||
|
||||
if($request->datetimepicker2 != null){
|
||||
$split_date = explode('-', $request->datetimepicker2);
|
||||
$tarikh_akhir = $split_date[2] . '-' . $split_date[1] . '-' . $split_date[0];
|
||||
}
|
||||
|
||||
// ambil 'had' daripada modal_online melalui API (VaultController@CalculationModalOnlineLejer)
|
||||
$had_response = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/ModalOnlineLejer/' . $auth_user['cawangan'], [
|
||||
'mula' => $tarikh_mula,
|
||||
'hingga' => $tarikh_akhir,
|
||||
])->json();
|
||||
|
||||
$had_modal_online = $had_response['had'] ?? 0;
|
||||
|
||||
$lejeramdata = Lejeram::orderBy('glcode')->get();
|
||||
$lejeram = array();
|
||||
$len = count($lejeramdata);
|
||||
$totalkredit = 0;
|
||||
$totaldebit = 0;
|
||||
|
||||
foreach($lejeramdata as $index => $lejer)
|
||||
{
|
||||
if($lejer->api_redirect != null)
|
||||
{
|
||||
${$lejer['variable']} = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). $lejer['api_redirect'] . $auth_user['cawangan'], ['mula' => $tarikh_mula, 'hingga' => $tarikh_akhir])->json();
|
||||
|
||||
if($lejer->namadebit == null)
|
||||
{
|
||||
$debit = null;
|
||||
}else{
|
||||
if($lejer->oneVar == 1)
|
||||
{
|
||||
$debit = ${$lejer['variable']};
|
||||
}else{
|
||||
$debit = ${$lejer['variable']}[$lejer->namadebit];
|
||||
}
|
||||
|
||||
$totaldebit += floatval($debit);
|
||||
}
|
||||
|
||||
if($lejer->namakredit == null)
|
||||
{
|
||||
$kredit = null;
|
||||
}else{
|
||||
if($lejer->oneVar == 1)
|
||||
{
|
||||
$kredit = ${$lejer['variable']};
|
||||
}else{
|
||||
$kredit = ${$lejer['variable']}[$lejer->namakredit];
|
||||
}
|
||||
|
||||
// tambah 'had' modal_online khusus untuk Pendahuluan Daripada HQ
|
||||
if($lejer->glcode == '7000/102')
|
||||
{
|
||||
$kredit = floatval($kredit) + $had_modal_online;
|
||||
}
|
||||
|
||||
$totalkredit += floatval($kredit);
|
||||
}
|
||||
|
||||
if(!($kredit == null && $debit == null))
|
||||
{
|
||||
array_push($lejeram, ['glcode' => $lejer->glcode, 'descpt' => $lejer->descpt, 'debit' => ($debit) ? $debit : 0, 'kredit' => ($kredit) ? $kredit : 0]);
|
||||
}
|
||||
}else{
|
||||
array_push($lejeram, ['glcode' => $lejer->glcode, 'descpt' => $lejer->descpt, 'debit' => 0, 'kredit' => 0]);
|
||||
}
|
||||
|
||||
if($index == $len-1)
|
||||
{
|
||||
$lejeram[0]['debit'] = $totalkredit;
|
||||
$lejeram[0]['kredit'] = $totaldebit;
|
||||
}
|
||||
}
|
||||
|
||||
$totalsamadebit = 0;
|
||||
$totalsamakredit = 0;
|
||||
foreach($lejeram as $index => $lejer)
|
||||
{
|
||||
$totalsamadebit += floatval($lejer['debit']);
|
||||
$totalsamakredit += floatval($lejer['kredit']);
|
||||
}
|
||||
|
||||
return view('print.laporan_lejer_am', compact('cawangan','tarikh_cetak','cawangan_info', 'api_url','cawangan_detail','tarikh_akhir','tarikh_mula','lejeram','totalsamadebit','totalsamakredit'));
|
||||
}
|
||||
|
||||
public function laporan_tuntutbaki(Request $request)
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
|
||||
Reference in New Issue
Block a user