fix kemaskini button aliran tunai v3

This commit is contained in:
fifi97
2021-05-10 00:15:53 +08:00
parent bd232b3201
commit 6e1e785216
2 changed files with 59 additions and 92 deletions
+28 -12
View File
@@ -1428,12 +1428,10 @@ class AliranTunaiController extends Controller
$addtunai = Http::get(config('api.url') . '/api/getAddTunai/' . $auth_user['cawangan'] . '/kodlaluan/',['kodlaluan' => $auth_user['name']])->json(); $addtunai = Http::get(config('api.url') . '/api/getAddTunai/' . $auth_user['cawangan'] . '/kodlaluan/',['kodlaluan' => $auth_user['name']])->json();
// $current->toDateString()
$gadai = Http::get(config('api.url'). '/api/gadai/laporan/'. $auth_user['cawangan'] .'/'. $current->toDateString())->json(); $gadai = Http::get(config('api.url'). '/api/gadai/laporan/'. $auth_user['cawangan'] .'/'. $current->toDateString())->json();
$tebus = Http::get(config('api.url'). '/api/tebus/laporan/'. $auth_user['cawangan'] .'/'. $current->toDateString())->json(); $tebus = Http::get(config('api.url'). '/api/tebus/laporan/'. $auth_user['cawangan'] .'/'. $current->toDateString())->json();
$ansuran = Http::get(config('api.url'). '/api/ansuran/laporan/'. $auth_user['cawangan'],['tarikh' => $current->toDateString()])->json(); $ansuran = Http::get(config('api.url'). '/api/ansuran/laporan/'. $auth_user['cawangan'],['tarikh' => $current->toDateString()])->json();
$requestkodlaluan = Http::get(config('api.url').'/api/get/pengguna/'.$auth_user['cawangan'],["namateller" => Auth::user()->name ])->json();
$advansur = Http::get(config('api.url').'/api/AnsuranByTarikh/'.$auth_user['cawangan'],['kodlaluan' => Auth::user()->name ])->json(); $advansur = Http::get(config('api.url').'/api/AnsuranByTarikh/'.$auth_user['cawangan'],['kodlaluan' => Auth::user()->name ])->json();
$totalserahan = 0; $totalserahan = 0;
@@ -1455,16 +1453,31 @@ class AliranTunaiController extends Controller
$totalgadaibarcodescanned = 0; $totalgadaibarcodescanned = 0;
foreach($gadai as $index1=>$gad) foreach($gadai as $index1=>$gad)
{ {
if($gad['semakbarcode'] === 'LULUS') if($gad['teller'] === Auth::user()->name)
{
if($gad['semakbarcode'] === 'LULUS')
$totalgadaibarcodescanned += $gad['pinjaman'];
$totalgadai += $gad['pinjaman']; $totalgadai += $gad['pinjaman'];
}
} }
$totaltebus = 0; $totaltebus = 0;
$totalgadaibarcodescanned = 0; $totaltebusbarcodescanned = 0;
foreach($tebus as $index1=>$teb) foreach($tebus as $index1=>$teb)
{ {
if($teb['tagterima'] === 1){ if($teb['teller'] === Auth::user()->name)
{
if($teb['tagterima'] === 1){
if($teb['jenistebus'] === 'S')
{
$totaltebusbarcodescanned += $teb['pinjaman'] + $teb['bakiupah'];
}else{
$totaltebusbarcodescanned += $teb['bakipjm'];
}
}
if($teb['jenistebus'] === 'S') if($teb['jenistebus'] === 'S')
{ {
$totaltebus += $teb['pinjaman'] + $teb['bakiupah']; $totaltebus += $teb['pinjaman'] + $teb['bakiupah'];
@@ -1472,12 +1485,14 @@ class AliranTunaiController extends Controller
$totaltebus += $teb['bakipjm']; $totaltebus += $teb['bakipjm'];
} }
} }
} }
$totalansuran = 0; $totalansuran = 0;
foreach($ansuran as $index1=>$ans) foreach($ansuran as $index1=>$ans)
{ {
$totalansuran += $ans['duit_masuk']; if($ans['teller'] === Auth::user()->name)
$totalansuran += $ans['duit_masuk'];
} }
$totalupahlama = 0; $totalupahlama = 0;
@@ -1487,16 +1502,17 @@ class AliranTunaiController extends Controller
} }
$penebusan = floatval($totaltebus) + floatval($totalansuran) + floatval($totalupahlama); $penebusan = floatval($totaltebus) + floatval($totalansuran) + floatval($totalupahlama);
$penebusanbarcodescanned = floatval($totaltebusbarcodescanned) + floatval($totalansuran) + floatval($totalupahlama);
$gadaian = floatval($totalgadai); $gadaian = floatval($totalgadai);
$bakisemasa = floatval($bakiawal) + floatval($totalpendahuluan) + floatval($penebusan) - (floatval($gadaian) + floatval($totalserahan)); $bakisemasa = floatval($bakiawal) + floatval($totalpendahuluan) + floatval($penebusan) - (floatval($gadaian) + floatval($totalserahan));
$errorpendahuluan = false; $errorserahan = false; $errorpenebusan = false; $errorgadaian = false; $errorbaki = false; $errorpendahuluan = false; $errorserahan = false; $errorpenebusan = false; $errorgadaian = false; $errorbaki = false;
if(number_format($penebusan,2) !== number_format($masuk,2)) if(number_format($penebusanbarcodescanned,2) !== number_format($masuk,2))
$errorpenebusan = true; $errorpenebusan = true;
if(number_format($bakisemasa,2) !== number_format($baki,2)) if(number_format(round($bakisemasa,1),2) !== number_format(round($baki,1),2))
$errorbaki = true; $errorbaki = true;
if(number_format($totalpendahuluan,2) != number_format($pendahuluan,2)) if(number_format($totalpendahuluan,2) != number_format($pendahuluan,2))
@@ -1505,14 +1521,14 @@ class AliranTunaiController extends Controller
if(number_format($totalserahan,2) != number_format($serahan,2)) if(number_format($totalserahan,2) != number_format($serahan,2))
$errorserahan = true; $errorserahan = true;
if(number_format($gadaian,2) != number_format($keluar,2)) if(number_format($totalgadaibarcodescanned,2) != number_format($keluar,2))
$errorgadaian = true; $errorgadaian = true;
if($errorbaki === false) if($errorpenebusan === false && $errorgadaian === false && $errorbaki === false)
{ {
return response('sama'); return response('sama');
}else{ }else{
$arraykemaskini = ['pendahuluan' => round($totalpendahuluan,2),'serahan' => round($totalserahan,2), 'penebusan' => round($penebusan,2), 'gadaian' => round($gadaian,2), 'bakisemasa' => round($bakisemasa,2)]; $arraykemaskini = ['pendahuluan' => round($totalpendahuluan,2),'serahan' => round($totalserahan,2), 'penebusan' => round($totaltebusbarcodescanned,2), 'gadaian' => round($totalgadaibarcodescanned,2), 'bakisemasa' => round($bakisemasa,1)];
return response()->json($arraykemaskini); return response()->json($arraykemaskini);
} }
} }
+31 -80
View File
@@ -283,37 +283,6 @@
var tele = "{{ $auth_user['name'] }}"; var tele = "{{ $auth_user['name'] }}";
// function kemaskiniupah()
// {
// $.ajax({
// type: 'get',
// url: "{{ route('kemaskini.upah') }}",
// // data: { "namateller" : tele },
// success: function(data){
// console.log(data);
// if(data == 1)
// {
// Swal.fire({
// icon: 'success',
// title: 'Kemaskini!',
// text: 'Proses Kemaskini!'
// }).then(function() {
// location.reload();
// });
// }else{
// Swal.fire({
// icon: 'warning',
// title: 'Peringatan',
// text: 'Telah Dikemaskini!'
// });
// }
// }
// });
// }
function periksaalirantunai() function periksaalirantunai()
{ {
@@ -321,7 +290,6 @@
type: 'get', type: 'get',
url: "{{ route('periksa.alirantunai') }}", url: "{{ route('periksa.alirantunai') }}",
success: function(balasbalik){ success: function(balasbalik){
console.log(balasbalik);
if(balasbalik == 'sama') if(balasbalik == 'sama')
{ {
Swal.fire({ Swal.fire({
@@ -332,60 +300,43 @@
}else{ }else{
Swal.fire({ $.ajax({
title: 'Kemaskini aliran tunai?', type: 'get',
html: url: "{{ route('kemaskini.alirantunai') }}",
'<div class="col-12"><h4 class="btn btn-success col-12 mr-2 font-weight-bold">Pendahuluan : RM ' + formatter.format(balasbalik['pendahuluan']) + '</h4>' + data: { "bakiakhir" : balasbalik['bakisemasa'],
'<h4 class="btn btn-danger col-12 font-weight-bold">Serahan : RM ' + formatter.format(balasbalik['serahan']) + '</h4></div>' + "pendahuluan" : balasbalik['pendahuluan'],
'<div class="col-12"><h4 class="btn btn-success col-12 mr-2 font-weight-bold">Tebus : RM ' + formatter.format(balasbalik['penebusan']) + '</h4>' + "serahan" : balasbalik['serahan'],
'<h4 class="btn btn-danger col-12 font-weight-bold">Gadai : RM ' + formatter.format(balasbalik['gadaian']) + '</h4></div>' + "gadaian" : balasbalik['gadaian'],
'<h4 class="btn btn-info font-weight-bold col-12">Baki : RM ' + formatter.format(balasbalik['bakisemasa']) + '</h4>', "penebusan" : balasbalik['penebusan']
showCancelButton: true, },
confirmButtonText: `Kemaskini`, success: function(balas){
cancelButtonText: 'Batal' if(balas == 'berjaya')
}).then((result) => { {
Swal.fire({
if (result.isConfirmed) { icon: 'success',
$.ajax({ title: 'Berjaya',
type: 'get', text: 'Kemaskini Berjaya!',
url: "{{ route('kemaskini.alirantunai') }}", closeOnClickOutside: false
data: { "bakiakhir" : balasbalik['bakisemasa'], }).then(function() {
"pendahuluan" : balasbalik['pendahuluan'], location.reload();
"serahan" : balasbalik['serahan'], });
"gadaian" : balasbalik['gadaian'],
"penebusan" : balasbalik['penebusan']
},
success: function(balas){
console.log(balas);
if(balas == 'berjaya')
{
Swal.fire({
icon: 'success',
title: 'Berjaya',
text: 'Kemaskini Berjaya!',
closeOnClickOutside: false
}).then(function() {
location.reload();
});
}else{ }else{
Swal.fire({ Swal.fire({
icon: 'danger', icon: 'danger',
title: 'Tidak Berjaya', title: 'Tidak Berjaya',
text: 'Kemaskini tidak berjaya!', text: 'Kemaskini tidak berjaya!',
closeOnClickOutside: false closeOnClickOutside: false
}).then(function() { }).then(function() {
location.reload(); location.reload();
});
}
}
}); });
} }
});
}
});
} }
} }
}
}); });
} }