From c4388321aaa7ec205f197e630b0f84ef1ba2dc21 Mon Sep 17 00:00:00 2001 From: hafifierahman Date: Fri, 8 Nov 2024 22:00:17 +0800 Subject: [PATCH] finished notification --- .../Controllers/AliranTunaiController.php | 53 ++ app/Http/Controllers/KhazanahController.php | 10 +- public/js/Class/SubscribePusher.js | 8 +- public/js/main.js | 4 +- public/js/notification.js | 85 ++- resources/views/aliran_tunai/index.blade.php | 10 + .../laporan/laporanrekodteller.blade.php | 546 ++++++++++++++++++ resources/views/layouts/app.blade.php | 7 +- routes/web.php | 1 + 9 files changed, 688 insertions(+), 36 deletions(-) create mode 100644 resources/views/aliran_tunai/laporan/laporanrekodteller.blade.php diff --git a/app/Http/Controllers/AliranTunaiController.php b/app/Http/Controllers/AliranTunaiController.php index b31b784..2e0d19d 100644 --- a/app/Http/Controllers/AliranTunaiController.php +++ b/app/Http/Controllers/AliranTunaiController.php @@ -624,5 +624,58 @@ class AliranTunaiController extends Controller return view('aliran_tunai.laporan.laporanalirantunai',compact('tarikh_cetak','cawangan_info','cawangan','api_url','cawangan_detail','addtunai','alirantunai','teller')); } + public function LaporanTunaiTeller(Request $request){ + + + $auth_user = Auth::user(); + $api_url = config('api.url'); + + $current = Carbon::now(); + $current = new Carbon(); + + $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]; + + $tarikh_cetak = $current->toDateString(); + + $array_requestteller = []; + //wang Syilling Initialize + $rekodsen1 = 0; $rekodsen5 = 0; $rekodsen10 = 0; + $rekodsen20 = 0; $rekodsen50 = 0; + + //Wang Ringgit Initialize + $rekodring1 = 0; $rekodring5 = 0; $rekodring10 = 0; + $rekodring20 = 0; $rekodring50 = 0; $rekodring100 = 0; + + $requestteller = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/requestTeller/getrekod/'.$auth_user['cawangan'],["teller" => Auth::user()->name,"recno" => $request->recno ])->json(); + if($requestteller[0]['modal'] != 0){ + $jenisserah = 'pendahuluan'; + }else{ + $jenisserah = 'serahan'; + } + + foreach($requestteller as $index => $reqtel) + { + $rekodsen1 += $reqtel['txtsen1']; + $rekodsen5 += $reqtel['txtsen5']; + $rekodsen10 += $reqtel['txtsen10']; + $rekodsen20 += $reqtel['txtsen20']; + $rekodsen50 += $reqtel['txtsen50']; + + $rekodring1 += $reqtel['txtring1']; + $rekodring5 += $reqtel['txtring5']; + $rekodring10 += $reqtel['txtring10']; + $rekodring20 += $reqtel['txtring20']; + $rekodring50 += $reqtel['txtring50']; + $rekodring100 += $reqtel['txtring100']; + } + + array_push($array_requestteller,[ "rekodsen1" => $rekodsen1,"rekodsen5" => $rekodsen5,"rekodsen10" => $rekodsen10,"rekodsen20" => $rekodsen20,"rekodsen50" => $rekodsen50 + ,"rekodring1" => $rekodring1,"rekodring5" => $rekodring5,"rekodring10" => $rekodring10,"rekodring20" => $rekodring20,"rekodring50" => $rekodring50,"rekodring100" => $rekodring100]); + + return view('aliran_tunai.laporan.laporanrekodteller',compact('tarikh_cetak','cawangan_info','cawangan','api_url','cawangan_detail','array_requestteller','jenisserah')); + } + } diff --git a/app/Http/Controllers/KhazanahController.php b/app/Http/Controllers/KhazanahController.php index b5b1eaf..d8ac351 100644 --- a/app/Http/Controllers/KhazanahController.php +++ b/app/Http/Controllers/KhazanahController.php @@ -28,6 +28,7 @@ use Carbon\Carbon; use PDF; use DateTime; use App\Helper; +use Log; class KhazanahController extends Controller { @@ -744,8 +745,9 @@ class KhazanahController extends Controller { if($request->jenismodal === 'perubatan') { - $listUser=User::where('name','=',$request->tuntutan)->get(); - $totalsebenar = floatval($listUser[0]->perubatan_asal) - floatval($updatepanjar['bakiperubatan']); + $listUser = User::where('name','=',$request->tuntutan)->first(); + $listUser = optional($listUser)->toArray(); + $totalsebenar = floatval($listUser['perubatan_asal']) - floatval($updatepanjar['totalperubatan']); User::where('cawangan','=',$auth_user['cawangan']) ->where('name','=',$request->tuntutan) ->update(array( @@ -779,9 +781,7 @@ class KhazanahController extends Controller { $listUser = User::where('name','=',$updatepanjar['tuntutoleh'])->first(); $listUser = optional($listUser)->toArray(); - - $totalsebenar = floatval($listUser['perubatan_asal']) + $updatepanjar['bakiperubatan']; - + $totalsebenar = floatval($listUser['perubatan_asal']) - floatval($updatepanjar['totalperubatan']); User::where('cawangan','=',$auth_user['cawangan']) ->where('name','=',$updatepanjar['tuntutoleh']) ->update(array( diff --git a/public/js/Class/SubscribePusher.js b/public/js/Class/SubscribePusher.js index 7778361..ec27795 100644 --- a/public/js/Class/SubscribePusher.js +++ b/public/js/Class/SubscribePusher.js @@ -3,14 +3,18 @@ class SubscribePusher { this.subscribe = subscribe; this.event = event; this.apikey = apikey; + this.pusher = new Pusher(this.apikey, { + cluster: 'ap1', // Replace 'your_cluster' with the actual cluster of your Pusher app + }); } - channel_subscribe() { - let channel = pusher.subscribe(this.subscribe); + channel_subscribe(callback) { + let channel = this.pusher.subscribe(this.subscribe); channel.bind(this.event, function(data){ callback(data); }); } } + export default SubscribePusher; \ No newline at end of file diff --git a/public/js/main.js b/public/js/main.js index d40633b..32041b6 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -436,7 +436,7 @@ async function openuptambahdanserah(e) { $.ajax({ method: "GET", - url: "{{ route('event.tellercash') }}", + url: event_tellercash, success:function(data){ console.log('successfull trigger'); }, @@ -602,7 +602,7 @@ function tambahdanserahanfunc(e) $.ajax({ method: "GET", - url: "{{ route('event.tellercash') }}", + url: event_tellercash, success:function(data){ console.log('successfull trigger'); } diff --git a/public/js/notification.js b/public/js/notification.js index c585000..5655959 100644 --- a/public/js/notification.js +++ b/public/js/notification.js @@ -1,10 +1,40 @@ import NotifyKhazanah from './Class/SubscribePusher.js'; - let channel = 'notify-deposit'; let event = 'deposit-event'; -let apikey = "{{ env('PUSHER_APP_KEY') }}"; -let api = "{{ config('api.url') }}"; -let kodcaw = "{{ Auth::user()->kodcaw }}"; +let apikey = window.apikey; + +const Toast = Swal.mixin({ + toast: true, + position: 'top-end', + showConfirmButton: false, + timer: 5000, + timerProgressBar: true, + didOpen: (toast) => { + toast.addEventListener('mouseenter', Swal.stopTimer) + toast.addEventListener('mouseleave', Swal.resumeTimer) + } +}) + +const notify = new NotifyKhazanah(channel,event,apikey); +notify.channel_subscribe((data) => { + console.log(data); + Toast.fire({ + icon: 'info', + title: 'Permohonan Kelulusan Wang Tunai Teller!' + }); + const currentPath = window.location.pathname; + + if (currentPath === "/home") { + notify_main(); + } else if (currentPath === "/menu") { + notify_khazanah_main(); + }else if(currentPath === '/pendahuluan'){ + notify_pendahuluan(); + }else if(currentPath === '/serahan'){ + notify_serahan(); + } + +}); let requestApi = (url, method, datarequest, callback) => { $.ajax({ @@ -20,25 +50,6 @@ let requestApi = (url, method, datarequest, callback) => { }); }; -let triggerPage = () =>{ - const notify = new NotifyKhazanah(channel,event,apikey); - notify.channel_subscribe((data) => { - console.log(data); - - const currentPath = window.location.pathname; - - if (currentPath === "/home") { - notify_main(); - } else if (currentPath === "/menu") { - notify_khazanah_main(); - }else if(currentPath === '/pendahuluan'){ - notify_pendahuluan(); - }else if(currentPath === '/serahan'){ - notify_serahan(); - } - - }); -} let notify_main = () =>{ const button = document.getElementById("btn-khazanah"); @@ -52,7 +63,7 @@ let notify_main = () =>{ } let notify_khazanah_main = () =>{ - requestApi(api + '/api/requestTeller/get/' + kodcaw,"GET",{}, (response) =>{ + requestApi(window.api + '/api/requestTeller/get/' + window.kodcaw,"GET",{}, (response) =>{ let countModal = 0; let countSerahan = 0; @@ -63,13 +74,35 @@ let notify_khazanah_main = () =>{ countSerahan++; } }); + + let btn_serahan = document.getElementById('btn-ser'); + let btn_pendahuluan = document.getElementById('btn-pend'); + let span_element_ser = btn_serahan.querySelector('span'); + let span_element_pend = btn_pendahuluan.querySelector('span'); + + if(!btn_serahan.classList.contains('btn-danger') && countSerahan > 0){ + btn_serahan.classList.add('btn-danger'); + span_element_ser.innerText = countSerahan; + } + + if(!btn_pendahuluan.classList.contains('btn-danger') && countModal > 0){ + btn_pendahuluan.classList.add('btn-danger'); + span_element_pend.innerText = countModal; + } + }); } let notify_pendahuluan = () =>{ - + timer_reload(); } let notify_serahan = () =>{ - + timer_reload(); +} + +let timer_reload = () =>{ + setTimeout(() => { + window.location.reload(); + }, 3000); } diff --git a/resources/views/aliran_tunai/index.blade.php b/resources/views/aliran_tunai/index.blade.php index a8dedd0..b19e2ea 100644 --- a/resources/views/aliran_tunai/index.blade.php +++ b/resources/views/aliran_tunai/index.blade.php @@ -214,6 +214,7 @@ Debit (RM) Kredit (RM) Nota + Tindakan @@ -225,6 +226,7 @@ {{ number_format($at['tambah'],2) }} {{ number_format($at['kurang'],2) }} {{ $at['nota'] }} + @endforeach @endif @@ -602,8 +604,16 @@ }); } + function rekodprint(recno){ + + let urlroute = '{{ route("laporan.tunaiteller") }}'; + urlroute += '?recno=' + encodeURIComponent(recno); + window.open(urlroute, '_blank'); + } + let pusherenv = "{{ env('PUSHER_APP_KEY') }}"; let laporanroute = "{{ route('laporan.serahantellerberkala') }}"; + let event_tellercash = "{{ route('event.tellercash') }}"; @endsection diff --git a/resources/views/aliran_tunai/laporan/laporanrekodteller.blade.php b/resources/views/aliran_tunai/laporan/laporanrekodteller.blade.php new file mode 100644 index 0000000..5ed231c --- /dev/null +++ b/resources/views/aliran_tunai/laporan/laporanrekodteller.blade.php @@ -0,0 +1,546 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
Laporan Pemeriksaan Wang Peti Besi (Cash Box)
+ + + + + +
+ + + + +
ID {{ (Auth::user()->name) ? Auth::user()->name : ''}} Jenis {{ strtoupper($jenisserah) }}
Tarikh Laporan {{ $tarikh_cetak }} Tarikh Cetak {{ $tarikh_cetak }}
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
RMKUANTITIJUMLAH (RM)
RM100{{ $array_requestteller[0]['rekodring100'] }}@php $totalsemua = 0; $total = ($array_requestteller[0]['rekodring100'] * 100); $totalsemua += $total; echo number_format($total,2); @endphp
RM 50{{ $array_requestteller[0]['rekodring50'] }}@php $total = ($array_requestteller[0]['rekodring50'] * 50); $totalsemua += $total; echo number_format($total,2); @endphp
RM 20{{ $array_requestteller[0]['rekodring20'] }}@php $total = ($array_requestteller[0]['rekodring20'] * 20); $totalsemua += $total; echo number_format($total,2); @endphp
RM 10{{ $array_requestteller[0]['rekodring10'] }}@php $total = ($array_requestteller[0]['rekodring10'] * 10); $totalsemua += $total; echo number_format($total,2); @endphp
RM 5{{ $array_requestteller[0]['rekodring5'] }}@php $total = ($array_requestteller[0]['rekodring5'] * 5); $totalsemua += $total; echo number_format($total,2); @endphp
RM 1.00{{ $array_requestteller[0]['rekodring1'] }}@php $total = ($array_requestteller[0]['rekodring1'] * 1); $totalsemua += $total; echo number_format($total,2); @endphp
RM 0.50{{ $array_requestteller[0]['rekodsen50'] }}@php $total = ($array_requestteller[0]['rekodsen50'] * 0.5); $totalsemua += $total; echo number_format($total,2); @endphp
RM 0.20{{ $array_requestteller[0]['rekodsen20'] }}@php $total = ($array_requestteller[0]['rekodsen20'] * 0.2); $totalsemua += $total; echo number_format($total,2); @endphp
RM0.10{{ $array_requestteller[0]['rekodsen10'] }}@php $total = ($array_requestteller[0]['rekodsen10'] * 0.1); $totalsemua += $total; echo number_format($total,2); @endphp
RM 0.05{{ $array_requestteller[0]['rekodsen5'] }}@php $total = ($array_requestteller[0]['rekodsen5'] * 0.05); $totalsemua += $total; echo number_format($total,2); @endphp
RM 0.01{{ $array_requestteller[0]['rekodsen1'] }}@php $total = ($array_requestteller[0]['rekodsen1'] * 0.01); $totalsemua += $total; echo number_format($total,2); @endphp
JUMLAH (RM){{ number_format($totalsemua,2) }}
+ +
CATATAN:
@if($jenisserah == 'pendahuluan') + Pendahuluan daripada peti besi + @else + Serahan kepada peti besi + @endif + ialah sebanyak RM {{ number_format($totalsemua,2) }} +
+
+ + + + + + + + + + + + + + + + +
.................................................................. ..................................................................
DI SEMAK DI SAHKAN
+ \ No newline at end of file diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index f01e6e3..cc68dc2 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -49,7 +49,12 @@ {{-- Pusher --}} - @if(Auth::user()->role_harian == 'khazanah') + @if(Auth::user()->roles == 'ppc' || Auth::user()->roles == 'pc') + @endif diff --git a/routes/web.php b/routes/web.php index 64560a4..21ebbb4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -87,6 +87,7 @@ Route::get('/daftar_marhun',['as'=>'daftar_marhun','uses'=>'MarhunController@ind Route::get('/penebusan/{norujukan}',['as'=>'penebusan','uses' => 'PenebusanController@index'])->middleware('auth'); Route::get('/lelongan/{norujukan}',['as'=>'lelongan','uses' => 'LelongController@index'])->middleware('auth','teller'); Route::get('/aliran_tunai','AliranTunaiController@index')->middleware('auth','teller'); +Route::get('/aliran_tunai/laporantunaiteller',['as'=>'laporan.tunaiteller','uses' => 'AliranTunaiController@LaporanTunaiTeller'])->middleware('auth','teller'); Route::get('/aliran_tunai/laporanserahan',['as'=>'laporan.serahanteller','uses' => 'AliranTunaiController@LaporanSerahan'])->middleware('auth','teller'); Route::get('/aliran_tunai/laporanserahanberkala',['as'=>'laporan.serahantellerberkala','uses' => 'AliranTunaiController@LaporanSerahanBerkala'])->middleware('auth','teller'); Route::get('/aliran_tunai/laporanalirantunai/{teller}',['as'=>'laporan.alirantunai','uses' => 'AliranTunaiController@LaporanAliranTunai'])->middleware('auth','teller');