third commit
This commit is contained in:
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class PetiBesiController extends Controller
|
||||
{
|
||||
// public function __construct()
|
||||
// {
|
||||
// $this->middleware('auth');
|
||||
// }
|
||||
|
||||
public function periksaAliranTunai(Request $request)
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
|
||||
$alirantunai = Http::get(config('api.url') . '/api/GetTunaiByTarikh/' . $request->kodcaw,['kodlaluan' => $request->teller, 'tarikh' => $request->tarikh])->json();
|
||||
|
||||
$keluar = $alirantunai['keluar'];
|
||||
$baki = $alirantunai['baki'];
|
||||
$masuk = $alirantunai['masuk'];
|
||||
$bakiawal = $alirantunai['bakiawal'];
|
||||
$pendahuluan = $alirantunai['tambah'];
|
||||
$serahan = $alirantunai['kurang'];
|
||||
|
||||
$addtunai = Http::get(config('api.url') . '/api/getAddTunaiDateKodlaluan/' . $request->kodcaw,['kodlaluan' => $request->teller, 'tarikh' => $request->tarikh])->json();
|
||||
$gadai = Http::get(config('api.url'). '/api/gadai/laporan/'. $request->kodcaw .'/'. $request->tarikh)->json();
|
||||
$tebus = Http::get(config('api.url'). '/api/tebus/laporan/'. $request->kodcaw .'/'. $request->tarikh)->json();
|
||||
$ansuran = Http::get(config('api.url'). '/api/ansuran/laporan/'. $request->kodcaw,['tarikh' => $request->tarikh])->json();
|
||||
$tuntutbaki = Http::get(config('api.url'). '/api/TuntutBakiTarikhTeller/'. $request->kodcaw,['teller' => $request->teller, 'tarikh' => $request->tarikh])->json();
|
||||
$advansur = Http::get(config('api.url').'/api/AdvansurSearchByTarikh/'.$request->kodcaw,['kodlaluan' => $request->teller, 'tarikh' => $request->tarikh ])->json();
|
||||
$lelong = Http::get(config('api.url').'/api/lelong/tarikh/'.$request->kodcaw,['tarikh' => $request->tarikh])->json();
|
||||
|
||||
$lelongan = 0;
|
||||
if(strtoupper($request->teller) === 'LELONG')
|
||||
{
|
||||
$lelongan = floatval($lelong);
|
||||
}else{
|
||||
$lelongan = 0;
|
||||
}
|
||||
|
||||
$totalserahan = 0;
|
||||
$totalpendahuluan = 0;
|
||||
foreach($addtunai as $index1=>$at)
|
||||
{
|
||||
if($at['tambah'] > 0)
|
||||
{
|
||||
$totalpendahuluan += $at['tambah'];
|
||||
}
|
||||
|
||||
if($at['kurang'] > 0)
|
||||
{
|
||||
$totalserahan += $at['kurang'];
|
||||
}
|
||||
}
|
||||
|
||||
$totalgadai = 0;
|
||||
$totalgadaibarcodescanned = 0;
|
||||
foreach($gadai as $index1=>$gad)
|
||||
{
|
||||
if($gad['teller'] === $request->teller)
|
||||
{
|
||||
if($gad['semakbarcode'] == 'Lulus')
|
||||
$totalgadaibarcodescanned += $gad['pinjaman'];
|
||||
|
||||
$totalgadai += $gad['pinjaman'];
|
||||
}
|
||||
}
|
||||
|
||||
$totaltebus = 0;
|
||||
$totaltebusbarcodescanned = 0;
|
||||
|
||||
foreach($tebus as $index1=>$teb)
|
||||
{
|
||||
if($teb['teller'] === $request->teller)
|
||||
{
|
||||
if($teb['tagterima'] === 1){
|
||||
if($teb['jenistebus'] === 'S')
|
||||
{
|
||||
$totaltebusbarcodescanned += $teb['gadaibakipjm'] + $teb['bakiupah'];
|
||||
}else{
|
||||
$totaltebusbarcodescanned += $teb['bakipjm'];
|
||||
}
|
||||
}
|
||||
|
||||
if($teb['jenistebus'] === 'S')
|
||||
{
|
||||
$totaltebus += $teb['gadaibakipjm'] + $teb['bakiupah'];
|
||||
}else{
|
||||
$totaltebus += $teb['bakipjm'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$totalansuran = 0;
|
||||
foreach($ansuran as $index1=>$ans)
|
||||
{
|
||||
if($ans['teller'] === $request->teller)
|
||||
$totalansuran += $ans['duit_masuk'];
|
||||
}
|
||||
|
||||
$totalupahlama = 0;
|
||||
foreach($advansur as $index1=>$upahlama)
|
||||
{
|
||||
$totalupahlama += $upahlama['upahDibayar'];
|
||||
}
|
||||
|
||||
$totaltuntutbaki = 0;
|
||||
$bakilelong = 0;
|
||||
$rugilelong = 0;
|
||||
foreach($tuntutbaki as $index1=>$tb)
|
||||
{
|
||||
if($tb['jenis'] == 'T')
|
||||
{
|
||||
$bakilelong += $tb['jumlah'];
|
||||
}else{
|
||||
$rugilelong += -($tb['jumlah']);
|
||||
}
|
||||
|
||||
$totaltuntutbaki += $tb['jumlah'];
|
||||
}
|
||||
|
||||
$penebusan = floatval($totaltebus) + floatval($totalansuran) + floatval($totalupahlama);
|
||||
$penebusanbarcodescanned = floatval($totaltebusbarcodescanned) + floatval($totalansuran) + floatval($totalupahlama);
|
||||
$gadaian = floatval($totalgadai);
|
||||
|
||||
if(strtoupper($request->teller) === 'LELONG'){
|
||||
$penebusanbarcodescanned = floatval($lelongan);
|
||||
$bakisemasa = floatval($bakiawal) + floatval($lelongan) - floatval($totalserahan);
|
||||
}else{
|
||||
$bakisemasa = floatval($bakiawal) + floatval($totalpendahuluan) + floatval($penebusan) - (floatval($gadaian) + floatval($totalserahan)) - floatval($totaltuntutbaki);
|
||||
}
|
||||
|
||||
$errorpendahuluan = false; $errorserahan = false; $errorpenebusan = false; $errorgadaian = false; $errorbaki = false;
|
||||
|
||||
if(number_format($penebusanbarcodescanned,2) !== number_format($masuk,2))
|
||||
$errorpenebusan = true;
|
||||
|
||||
if(number_format(round($bakisemasa,2),2) !== number_format(round($baki,2),2))
|
||||
$errorbaki = true;
|
||||
|
||||
if(number_format($totalpendahuluan,2) != number_format($pendahuluan,2))
|
||||
$errorpendahuluan = true;
|
||||
|
||||
if(number_format($totalserahan,2) != number_format($serahan,2))
|
||||
$errorserahan = true;
|
||||
|
||||
if(number_format($totalgadaibarcodescanned,2) != number_format($keluar,2))
|
||||
$errorgadaian = true;
|
||||
|
||||
if($errorpenebusan === false && $errorgadaian === false && $errorbaki === false)
|
||||
{
|
||||
return response('sama');
|
||||
}else{
|
||||
$arraykemaskini = ['pendahuluan' => round($totalpendahuluan,2),'serahan' => round($totalserahan,2), 'penebusan' => round($penebusanbarcodescanned,2), 'gadaian' => round($totalgadaibarcodescanned,2), 'bakisemasa' => round($bakisemasa,2),'bakiawal' => round($bakiawal,2)];
|
||||
return response()->json($arraykemaskini);
|
||||
}
|
||||
}
|
||||
|
||||
public function kemaskiniAliranTunai(Request $request)
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
|
||||
$alirantunai = Http::get(config('api.url') . '/api/GetTunaiByTarikh/' . $request->kodcaw,['kodlaluan' => $request->teller, 'tarikh' => $request->tarikh])->json();
|
||||
|
||||
$keluar = $alirantunai['keluar'];
|
||||
$baki = $alirantunai['baki'];
|
||||
$masuk = $alirantunai['masuk'];
|
||||
$bakiawal = $alirantunai['bakiawal'];
|
||||
$pendahuluan = $alirantunai['tambah'];
|
||||
$serahan = $alirantunai['kurang'];
|
||||
|
||||
$updateTunai = Http::put( config('api.url').'/api/updateTunaiGTByTarikh/'.$request->kodcaw, [
|
||||
'kodlaluan' => $request->teller,
|
||||
'tarikh' => $request->tarikh,
|
||||
'keluar'=> $request->gadaian,
|
||||
'masuk'=> $request->penebusan,
|
||||
'bakiakhir'=> $request->bakiakhir
|
||||
]);
|
||||
|
||||
if($updateTunai->status() == 200)
|
||||
{
|
||||
return response('berjaya');
|
||||
}else{
|
||||
return response('gagal');
|
||||
}
|
||||
}
|
||||
|
||||
public function AdminPetiBesi()
|
||||
{
|
||||
$api_url = config('api.url');
|
||||
$auth_user = Auth::user();
|
||||
|
||||
$cawangan_info = Http::get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
||||
$cawangan=Http::get(config('api.url').'/api/cawangan/detail/'.$auth_user['cawangan'])->json();
|
||||
$cawangan_detail=$cawangan[0];
|
||||
|
||||
$petibesi = Http::get(config('api.url') . '/api/VaultController/all/'. $auth_user['cawangan'])->json();
|
||||
|
||||
return view('petibesi.petibesi',compact('api_url','cawangan_info','auth_user','petibesi'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user