438 lines
16 KiB
PHP
438 lines
16 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Carbon\Carbon;
|
|
|
|
class LelongController extends Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->middleware('auth');
|
|
}
|
|
|
|
public function index($norujukan)
|
|
{
|
|
$auth_user = Auth::user();
|
|
$api_url = config('api.url');
|
|
$cawangan_info = Http::get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
|
|
|
$gadaidetail = Http::get(config('api.url') . '/api/gadai/norujukan/'. $norujukan)->json();
|
|
$noic = $gadaidetail[0][0]['nokp'];
|
|
$customerdetail = Http::get(config('api.url') . '/api/customers/'. $noic)->json();
|
|
$nama = $customerdetail['nama'];
|
|
|
|
$lelong = Http::get(config('api.url') . '/api/lelong/cawangan/'. $auth_user['cawangan'] . '/' . $norujukan)->json();
|
|
|
|
if(sizeof($lelong) > 0)
|
|
{
|
|
$lelong = $lelong[0];
|
|
}
|
|
|
|
$gadai = $gadaidetail[0][0];
|
|
|
|
return view('lelongan.index',compact('cawangan_info','api_url','gadai','nama','lelong'));
|
|
}
|
|
|
|
public function lelong(){
|
|
$api_url = config('api.url');
|
|
$auth_user = Auth::user();
|
|
$cawangan_info = Http::get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
|
return view('khazanah.lelong',compact('cawangan_info','api_url'));
|
|
}
|
|
|
|
public function resittuntutbaki($norujukan){
|
|
|
|
$api_url = config('api.url');
|
|
$auth_user = Auth::user();
|
|
$current = Carbon::now();
|
|
$current = new Carbon();
|
|
|
|
$cawangan=Http::get(config('api.url').'/api/cawangan/detail/'.$auth_user['cawangan'])->json();
|
|
$cawangan_detail=$cawangan[0];
|
|
|
|
$lelong=Http::get(config('api.url').'/api/TuntutBaki/resit/' . $auth_user['cawangan'] . '/' . $norujukan)->json();
|
|
|
|
return view('print.resit_tuntutbaki', compact('cawangan_detail','api_url','lelong'));
|
|
|
|
}
|
|
|
|
// public function transaksituntutbaki(Request $request){
|
|
|
|
// $auth_user = Auth::user();
|
|
|
|
// $tuntutbaki = Http::post(config('api.url') . '/api/Tuntutbakisimpan/' . $auth_user['cawangan'], [
|
|
// 'batchno' => $request->batchno,
|
|
// 'jenis' => $request->jenis,
|
|
// 'norujukan' => $request->norujukan,
|
|
// 'teller' => $request->teller,
|
|
// 'bakipjm' => $request->bakipjm,
|
|
// 'bakiupah' => $request->bakiupah,
|
|
// 'cajlain' => $request->cajlain,
|
|
// 'cajlelong' => $request->cajlelong,
|
|
// 'jumlah' => $request->jumlah,
|
|
// 'nowakil' => $request->nowakil,
|
|
// 'hargajual' => $request->hargajual
|
|
// ])->json();
|
|
|
|
// $updatetuntutbaki = Http::put( config('api.url').'/api/tuntutbakiupdate/' . $auth_user['cawangan'] . '/' . $request->norujukan);
|
|
|
|
// $getTunai2=Http::get(config('api.url').'/api/GetCurrentTunai/'.$auth_user['cawangan'],['kodlaluan' => $request->teller])->json();
|
|
|
|
// $keluar = $getTunai2['keluar'];
|
|
// $baki = $getTunai2['baki'];
|
|
// $masuk = $getTunai2['masuk'];
|
|
// $bakiawal = $getTunai2['bakiawal'];
|
|
// $pendahuluan = $getTunai2['tambah'];
|
|
// $serahan = $getTunai2['kurang'];
|
|
|
|
// $bakiakhir = $baki;
|
|
|
|
// if($request->jenis == 'T'){
|
|
// $bakiakhir -= $request->jumlah;
|
|
// }
|
|
// else
|
|
// {
|
|
// $bakiakhir += -($request->jumlah);
|
|
// }
|
|
|
|
// //masuk dalam tunai aliran
|
|
// $updateTunai=Http::put( config('api.url').'/api/updateTunaiGT/'.$auth_user['cawangan'], [
|
|
// 'kodlaluan' => $request->teller,
|
|
// 'keluar' => $keluar,
|
|
// 'masuk' => $masuk,
|
|
// 'bakiakhir' => $bakiakhir
|
|
// ]);
|
|
|
|
// if($updatetuntutbaki)
|
|
// {
|
|
// return response('Berjaya');
|
|
// }else{
|
|
// return response('Gagal');
|
|
// }
|
|
// }
|
|
|
|
public function transaksituntutbaki(Request $request){
|
|
|
|
$auth_user = Auth::user();
|
|
|
|
$tuntutbaki = Http::post(config('api.url') . '/api/Tuntutbakisimpan/' . $auth_user['cawangan'], [
|
|
'batchno' => $request->batchno,
|
|
'jenis' => $request->jenis,
|
|
'norujukan' => $request->norujukan,
|
|
'teller' => $request->teller,
|
|
'bakipjm' => $request->bakipjm,
|
|
'bakiupah' => $request->bakiupah,
|
|
'cajlain' => $request->cajlain,
|
|
'cajlelong' => $request->cajlelong,
|
|
'jumlah' => $request->jumlah,
|
|
'nowakil' => $request->nowakil,
|
|
'hargajual' => $request->hargajual
|
|
])->json();
|
|
|
|
$updatetuntutbaki = Http::put( config('api.url').'/api/tuntutbakiupdate/' . $auth_user['cawangan'] . '/' . $request->norujukan);
|
|
|
|
$getTunai2=Http::get(config('api.url').'/api/GetCurrentTunai/'.$auth_user['cawangan'],['kodlaluan' => $request->teller])->json();
|
|
|
|
$keluar = $getTunai2['keluar'];
|
|
$baki = $getTunai2['baki'];
|
|
$masuk = $getTunai2['masuk'];
|
|
$bakiawal = $getTunai2['bakiawal'];
|
|
$pendahuluan = $getTunai2['tambah'];
|
|
$serahan = $getTunai2['kurang'];
|
|
|
|
$bakiakhir = $baki;
|
|
$jumlah_byr=$request->jumlah;
|
|
|
|
if($request->jenis == 'T')
|
|
{
|
|
$bakiakhir -= $request->jumlah;
|
|
|
|
|
|
|
|
$KOD_TUNAI='1000/010';
|
|
$BAKI_LELONG='7000/090';
|
|
|
|
$get_lejerTunai=Http::get(config('api.url').'/api/getGlejer/'.$auth_user['cawangan'],['glcode'=>$KOD_TUNAI])->json();
|
|
$hariIni_Tunai=$get_lejerTunai[0]['hariini'];
|
|
$kelmarin_Tunai=$get_lejerTunai[0]['kelmarin'];
|
|
$jumlah_Tunai=$get_lejerTunai[0]['jumlah'];
|
|
$kredit_Tunai=$get_lejerTunai[0]['kredit'];
|
|
$debit_Tunai=$get_lejerTunai[0]['debit'];
|
|
$recno_Tunai=$get_lejerTunai[0]['recno'];
|
|
|
|
|
|
$kredit_Tunai=$kredit_Tunai+$jumlah_byr;
|
|
$hariIni_Tunai=$debit_Tunai-$kredit_Tunai;
|
|
$kelmarin_Tunai=$jumlah_Tunai-$hariIni_Tunai;
|
|
$updateGlejer_Tunai=Http::put(config('api.url').'/api/kemasKiniGlejer/'.$auth_user['cawangan'],[
|
|
'recno'=>$recno_Tunai,
|
|
'debit'=>$debit_Tunai,
|
|
'kredit'=>$kredit_Tunai,
|
|
'hariini'=>$hariIni_Tunai,
|
|
'kelmarin' =>$kelmarin_Tunai,
|
|
|
|
]);
|
|
|
|
|
|
$get_KOD_BL=Http::get(config('api.url').'/api/getGlCode/'. $auth_user['cawangan'],['glcode'=>$BAKI_LELONG])->json();
|
|
|
|
$gl_cdetails_bl= $get_KOD_BL[0];
|
|
$keterangan_bl= $get_KOD_BL[0]['descpt']; //keterangan glcode
|
|
$actype_bl= $get_KOD_BL[0]['acttype'];
|
|
|
|
|
|
$get_current_GLejer_Baki_Lelong=Http::get(config('api.url').'/api/getGlejer/'. $auth_user['cawangan'],['glcode'=>$BAKI_LELONG])->json();
|
|
|
|
if(sizeof($get_current_GLejer_Baki_Lelong)==0)
|
|
{
|
|
$jumlah_bl=0.0;
|
|
|
|
$getGLedjer_bl_Semalam=Http::get(config('api.url').'/api/getSemalam_Glejer/'.$auth_user['cawangan'],['glcode'=>$BAKI_LELONG])->json();
|
|
if(sizeof($getGLedjer_bl_Semalam)==0)
|
|
{
|
|
$jumlah_bl=0.0;
|
|
}
|
|
else
|
|
{
|
|
|
|
$jumlahSemalam_bl=$getGLedjer_bl_Semalam[0]['jumlah'];
|
|
|
|
$hariIniSemalam_bl=$getGLedjer_bl_Semalam[0]['hariini'];
|
|
$jumlah_bl=$jumlahSemalam_bl+$hariIniSemalam_bl;
|
|
|
|
}
|
|
$jumlahBulan_ini_bl=0.0;
|
|
$get_GlejerBulan_Tahun_bl=Http::get(config('api.url').'/api/getLejerMonthYear/'.$auth_user['cawangan'],['glcode'=>$BAKI_LELONG])->json();
|
|
if( sizeof($get_GlejerBulan_Tahun_bl)==0)
|
|
{
|
|
$jumlahBulan_ini_bl=0.0;
|
|
}
|
|
else
|
|
{
|
|
|
|
$jumlahBulan_ini_bl=$get_GlejerBulan_Tahun_bl[0]['jumlah'];
|
|
$jumlahBulan_ini_bl=$jumlah_bl-$jumlahBulan_ini_bl;
|
|
|
|
}
|
|
|
|
|
|
$Jumlah_TahunIni_bl=0.0;
|
|
$get_Glejer_Tahun_bl=Http::get(config('api.url').'/api/getLejerYear/'.$auth_user['cawangan'],['glcode'=>$BAKI_LELONG])->json();
|
|
|
|
if(sizeof($get_Glejer_Tahun_bl)==0)
|
|
{
|
|
$Jumlah_TahunIni_bl=0.0;
|
|
}
|
|
else
|
|
{
|
|
$JumTahunIni_bl=$get_Glejer_Tahun_bl[0]['jumlah'];
|
|
$Jumlah_TahunIni_bl=$jumlah_bl-$JumTahunIni_bl;
|
|
|
|
}
|
|
|
|
|
|
$HariIni_bl=0.0;
|
|
$kelmarin_bl=$jumlah_bl-$HariIni_bl;
|
|
$daftarGlejer_bl=Http::post(config('api.url').'/api/daftarGlejer/'.$auth_user['cawangan'],[
|
|
|
|
'kodcaw'=>$auth_user['cawangan'],
|
|
'glcode'=>$BAKI_LELONG,
|
|
'descpt'=>$keterangan_bl,
|
|
'debit'=>$jumlah_byr,
|
|
'kredit'=>0.0,
|
|
'hariini'=>$HariIni_bl,
|
|
'kelmarin'=>$kelmarin_bl,
|
|
'jumlah'=>$jumlah_bl,
|
|
'bulanini'=>$jumlahBulan_ini_bl,
|
|
'tahunini'=>$Jumlah_TahunIni_bl,
|
|
'acttype'=> $actype_bl
|
|
|
|
]);
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
$hariIni_BL=$get_current_GLejer_Baki_Lelong[0]['hariini'];
|
|
$kelmarin_BL=$get_current_GLejer_Baki_Lelong[0]['kelmarin'];
|
|
$jumlah_BL= $get_current_GLejer_Baki_Lelong[0]['jumlah'];
|
|
$kredit_BL=$get_current_GLejer_Baki_Lelong[0]['kredit'];
|
|
$debit_BL= $get_current_GLejer_Baki_Lelong[0]['debit'];
|
|
$recno_BL=$get_current_GLejer_Baki_Lelong[0]['recno'];
|
|
|
|
$debit_BL=$debit_BL+$jumlah_byr;
|
|
$hariIni_Tunai=$debit_BL-$kredit_BL;
|
|
$kelmarin_BL=$jumlah_BL-$hariIni_BL;
|
|
|
|
$updateGlejer_BL=Http::put(config('api.url').'/api/kemasKiniGlejer/'.$auth_user['cawangan'],[
|
|
'recno'=>$recno_BL,
|
|
'debit'=>$debit_BL,
|
|
'kredit'=>$kredit_BL,
|
|
'hariini'=>$hariIni_BL,
|
|
'kelmarin' =>$kelmarin_BL,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
$bakiakhir += -($request->jumlah);
|
|
|
|
|
|
$KOD_TUNAI='1000/010';
|
|
$get_lejerTunai=Http::get(config('api.url').'/api/getGlejer/'.$auth_user['cawangan'],['glcode'=>$KOD_TUNAI])->json();
|
|
$hariIni_Tunai=$get_lejerTunai[0]['hariini'];
|
|
$kelmarin_Tunai=$get_lejerTunai[0]['kelmarin'];
|
|
$jumlah_Tunai=$get_lejerTunai[0]['jumlah'];
|
|
$kredit_Tunai=$get_lejerTunai[0]['kredit'];
|
|
$debit_Tunai=$get_lejerTunai[0]['debit'];
|
|
$recno_Tunai=$get_lejerTunai[0]['recno'];
|
|
|
|
|
|
$debit_Tunai=$debit_Tunai+$jumlah_byr;
|
|
$hariIni_Tunai=$debit_Tunai-$kredit_Tunai;
|
|
$kelmarin_Tunai=$jumlah_Tunai-$hariIni_Tunai;
|
|
$updateGlejer_Tunai=Http::put(config('api.url').'/api/kemasKiniGlejer/'.$auth_user['cawangan'],[
|
|
'recno'=>$recno_Tunai,
|
|
'debit'=>$debit_Tunai,
|
|
'kredit'=>$kredit_Tunai,
|
|
'hariini'=>$hariIni_Tunai,
|
|
'kelmarin' =>$kelmarin_Tunai,
|
|
|
|
]);
|
|
|
|
|
|
|
|
$RUGI_LELONG='3000/020';
|
|
|
|
$get_KOD_RL=Http::get(config('api.url').'/api/getGlCode/'. $auth_user['cawangan'],['glcode'=>$RUGI_LELONG])->json();
|
|
|
|
$gl_cdetails_rl= $get_KOD_RL[0];
|
|
$keterangan_rl= $get_KOD_RL[0]['descpt']; //keterangan glcode
|
|
$actype_rl= $get_KOD_RL[0]['acttype'];
|
|
|
|
|
|
$get_current_GLejer_Rugi_Lelong=Http::get(config('api.url').'/api/getGlejer/'. $auth_user['cawangan'],['glcode'=>$RUGI_LELONG])->json();
|
|
|
|
if(sizeof($get_current_GLejer_Rugi_Lelong)==0)
|
|
{
|
|
$jumlah_rl=0.0;
|
|
|
|
$getGLedjer_rl_Semalam=Http::get(config('api.url').'/api/getSemalam_Glejer/'.$auth_user['cawangan'],['glcode'=>$RUGI_LELONG])->json();
|
|
if(sizeof($getGLedjer_rl_Semalam)==0)
|
|
{
|
|
$jumlah_rl=0.0;
|
|
}
|
|
else
|
|
{
|
|
|
|
$jumlahSemalam_rl=$getGLedjer_rl_Semalam[0]['jumlah'];
|
|
|
|
$hariIniSemalam_rl=$getGLedjer_rl_Semalam[0]['hariini'];
|
|
$jumlah_rl=$jumlahSemalam_rl+$hariIniSemalam_rl;
|
|
|
|
}
|
|
$jumlahBulan_ini_rl=0.0;
|
|
$get_GlejerBulan_Tahun_rl=Http::get(config('api.url').'/api/getLejerMonthYear/'.$auth_user['cawangan'],['glcode'=>$RUGI_LELONG])->json();
|
|
if( sizeof($get_GlejerBulan_Tahun_rl)==0)
|
|
{
|
|
$jumlahBulan_ini_rl=0.0;
|
|
}
|
|
else
|
|
{
|
|
|
|
$jumlahBulan_ini_rl=$get_GlejerBulan_Tahun_rl[0]['jumlah'];
|
|
$jumlahBulan_ini_rl=$jumlah_rl-$jumlahBulan_ini_rl;
|
|
|
|
}
|
|
|
|
|
|
$Jumlah_TahunIni_rl=0.0;
|
|
$get_Glejer_Tahun_rl=Http::get(config('api.url').'/api/getLejerYear/'.$auth_user['cawangan'],['glcode'=>$RUGI_LELONG])->json();
|
|
|
|
if(sizeof($get_Glejer_Tahun_rl)==0)
|
|
{
|
|
$Jumlah_TahunIni_rl=0.0;
|
|
}
|
|
else
|
|
{
|
|
$JumTahunIni_rl=$get_Glejer_Tahun_rl[0]['jumlah'];
|
|
$Jumlah_TahunIni_rl=$jumlah_rl-$JumTahunIni_rl;
|
|
|
|
}
|
|
|
|
|
|
$HariIni_rl=0.0;
|
|
$kelmarin_rl=$jumlah_rl-$HariIni_rl;
|
|
$daftarGlejer_bl=Http::post(config('api.url').'/api/daftarGlejer/'.$auth_user['cawangan'],[
|
|
|
|
'kodcaw'=>$auth_user['cawangan'],
|
|
'glcode'=>$RUGI_LELONG,
|
|
'descpt'=>$keterangan_rl,
|
|
'debit'=>0.0,
|
|
'kredit'=>$jumlah_byr,
|
|
'hariini'=>$HariIni_rl,
|
|
'kelmarin'=>$kelmarin_rl,
|
|
'jumlah'=>$jumlah_rl,
|
|
'bulanini'=>$jumlahBulan_ini_rl,
|
|
'tahunini'=>$Jumlah_TahunIni_rl,
|
|
'acttype'=> $actype_rl
|
|
|
|
]);
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
$hariIni_RL=$get_current_GLejer_Rugi_Lelong[0]['hariini'];
|
|
$kelmarin_RL=$get_current_GLejer_Rugi_Lelong[0]['kelmarin'];
|
|
$jumlah_RL= $get_current_GLejer_Rugi_Lelong[0]['jumlah'];
|
|
$kredit_RL=$get_current_GLejer_Rugi_Lelong[0]['kredit'];
|
|
$debit_RL= $get_current_GLejer_Rugi_Lelong[0]['debit'];
|
|
$recno_RL=$get_current_GLejer_Rugi_Lelong[0]['recno'];
|
|
|
|
$kredit_RL=$kredit_RL+$jumlah_byr;
|
|
$hariIni_Tunai=$debit_RL-$kredit_RL;
|
|
$kelmarin_BL=$jumlah_RL-$hariIni_RL;
|
|
|
|
$updateGlejer_RL=Http::put(config('api.url').'/api/kemasKiniGlejer/'.$auth_user['cawangan'],[
|
|
'recno'=>$recno_RL,
|
|
'debit'=>$debit_RL,
|
|
'kredit'=>$kredit_RL,
|
|
'hariini'=>$hariIni_RL,
|
|
'kelmarin' =>$kelmarin_RL,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
//masuk dalam tunai aliran
|
|
$updateTunai=Http::put( config('api.url').'/api/updateTunaiGT/'.$auth_user['cawangan'], [
|
|
'kodlaluan' => $request->teller,
|
|
'keluar' => $keluar,
|
|
'masuk' => $masuk,
|
|
'bakiakhir' => $bakiakhir
|
|
]);
|
|
|
|
if($updatetuntutbaki)
|
|
{
|
|
return response('Berjaya');
|
|
}else{
|
|
return response('Gagal');
|
|
}
|
|
}
|
|
}
|