addded notification
This commit is contained in:
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events\Teller;
|
||||||
|
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
|
||||||
|
class NotifyDeposit implements ShouldBroadcast
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
public $cawangan;
|
||||||
|
public $kodlaluan;
|
||||||
|
public $jenis;
|
||||||
|
|
||||||
|
public function __construct($jenis,$cawangan,$kodlaluan)
|
||||||
|
{
|
||||||
|
$this->jenis = $jenis;
|
||||||
|
$this->cawangan = $cawangan;
|
||||||
|
$this->kodlaluan = $kodlaluan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return ['notify-deposit'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function broadcastAs()
|
||||||
|
{
|
||||||
|
return 'deposit-event';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Events\Teller\NotifyDeposit;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class EventTriggerController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function TellerCash(){
|
||||||
|
event(new NotifyDeposit("pendahuluan",Auth::user()->cawangan,Auth::user()->name));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1295,140 +1295,16 @@ class KhazanahController extends Controller
|
|||||||
{
|
{
|
||||||
$peti_besi_terkini=Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url').'/api/daftarVault/'.$auth_user['cawangan'])->json();
|
$peti_besi_terkini=Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url').'/api/daftarVault/'.$auth_user['cawangan'])->json();
|
||||||
}
|
}
|
||||||
|
$response_data = $request->except('_token');
|
||||||
$amount = $request->amt;
|
$test = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url').'/api/test/serahantunai/'.$auth_user['cawangan'],$response_data)->json();
|
||||||
|
|
||||||
$tarikh=$request->tarikh;
|
if($test == 'success'){
|
||||||
$kodlaluan=$request->teller;
|
event(new PendahuluanSerahan("Lulus","serahan",$auth_user['cawangan'],$request->teller));
|
||||||
|
return redirect()->route('khazanah.serahan');
|
||||||
$kurang=$request->amt;
|
}else{
|
||||||
$nota=$request->nota;
|
return redirect()->route('khazanah.serahan')->with('error','Permohonan tidak berjaya! Permohonan Semula perlu melebihi 1 minit.');
|
||||||
$kodcaw=$auth_user['cawangan'];
|
}
|
||||||
$tambahT = 0;
|
|
||||||
$kurangvault = $request->amt;
|
|
||||||
|
|
||||||
$addTunai=Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url').'/api/add/addTunai/'.$auth_user['cawangan'],[
|
|
||||||
'kodcaw'=>$kodcaw,
|
|
||||||
'kodlaluan'=>$kodlaluan,
|
|
||||||
'tambah'=>$tambahT,
|
|
||||||
'kurang'=>$kurang,
|
|
||||||
'nota'=>$nota]);
|
|
||||||
|
|
||||||
$getTunai=Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/GetCurrentTunai/'.$auth_user['cawangan'],['kodlaluan' => $kodlaluan])->json();
|
|
||||||
|
|
||||||
if(sizeof($getTunai) == 0)
|
|
||||||
{
|
|
||||||
// dd($getTunai);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$getTunai2=Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/GetCurrentTunai/'.$auth_user['cawangan'],['kodlaluan' => $kodlaluan])->json();
|
|
||||||
$bakiAwalT=$getTunai2['bakiawal'];
|
|
||||||
$keluarT=$getTunai2['keluar'];
|
|
||||||
$baki=$getTunai2['baki'];
|
|
||||||
$tambahT=$getTunai2['tambah'];
|
|
||||||
$kurangT=$getTunai2['kurang'];
|
|
||||||
$masukT=$getTunai2['masuk'];
|
|
||||||
|
|
||||||
$serahanakhir = $kurang;
|
|
||||||
$tambah_T=0;$kurang_T=0;$baki_AwalT=0.0;
|
|
||||||
|
|
||||||
if($tambahT==0)
|
|
||||||
$tambah_T=0;
|
|
||||||
|
|
||||||
else
|
|
||||||
$tambah_T=$tambahT;
|
|
||||||
|
|
||||||
|
|
||||||
if($kurangT==0)
|
|
||||||
$kurang_T=$kurang;
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$kurang=$kurang+$kurangT;
|
|
||||||
$kurang_T=$kurang;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($bakiAwalT==0)
|
|
||||||
$baki_AwalT=0;
|
|
||||||
|
|
||||||
else
|
|
||||||
$baki_AwalT=$bakiAwalT;
|
|
||||||
|
|
||||||
//$bakiAkhirT=$baki_AwalT+$tambah_T+$masukT-$keluarT-$kurang_T; //untuk kegunaan urgent
|
|
||||||
$bakiAkhirT = $baki - $serahanakhir;
|
|
||||||
|
|
||||||
$updateTunai=Http::withOptions(['verify' => config('app.api_verify')])->put( config('api.url').'/api/updateTunai/'.$auth_user['cawangan'], [
|
|
||||||
'kodlaluan'=>$kodlaluan,
|
|
||||||
'tambah'=>$tambah_T,
|
|
||||||
'kurang'=>$kurang_T,
|
|
||||||
'bakiakhir'=>$bakiAkhirT
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
|
||||||
$latestVault=Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/VaultController/'.$auth_user['cawangan'])->json();
|
|
||||||
|
|
||||||
$masukV=$latestVault[0]['masuk'];
|
|
||||||
$keluarV=$latestVault[0]['keluar'];
|
|
||||||
$pendahuluanV=$latestVault[0]['pendahuluan'];
|
|
||||||
$serahanV=$latestVault[0]['serahan'];
|
|
||||||
$bakiAwalV=$latestVault[0]['bakiawal'];
|
|
||||||
$totpanjar = $latestVault[0]['totpanjar'];
|
|
||||||
|
|
||||||
|
|
||||||
$masuk_V = 0;$pendahuluan_V = 0;$keluar_V = 0;$serahan_V = 0;
|
|
||||||
|
|
||||||
if($masukV == 0)
|
|
||||||
{
|
|
||||||
$masuk_V = 0 + $kurangvault;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$masuk_V = $masukV + $kurangvault;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($keluarV == 0)
|
|
||||||
$keluar_V = 0;
|
|
||||||
|
|
||||||
else
|
|
||||||
$keluar_V=$keluarV;
|
|
||||||
|
|
||||||
|
|
||||||
if($pendahuluanV == 0)
|
|
||||||
$pendahuluan_V = 0;
|
|
||||||
|
|
||||||
else
|
|
||||||
$pendahuluan_V = $pendahuluanV;
|
|
||||||
|
|
||||||
|
|
||||||
if($serahanV == 0)
|
|
||||||
$serahan_V = 0;
|
|
||||||
|
|
||||||
else
|
|
||||||
$serahan_V = $serahanV;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$GetLatestBakiTunai=Http::withOptions(['verify' => config('app.api_verify')])->get( config('api.url').'/api/getLatestBaki/'.$auth_user['cawangan'])->json();
|
|
||||||
$sumBaki=$GetLatestBakiTunai;
|
|
||||||
|
|
||||||
|
|
||||||
$bakiAkhirV = $bakiAwalV - $keluar_V + $masuk_V + $pendahuluan_V - $serahan_V - $totpanjar;
|
|
||||||
|
|
||||||
$BakiEOD=$bakiAkhirV;
|
|
||||||
//$BakiEOD=$bakiAkhirV+$sumBaki;
|
|
||||||
|
|
||||||
$updateVault=Http::withOptions(['verify' => config('app.api_verify')])->put( config('api.url').'/api/UpdateVault/'.$auth_user['cawangan'],[
|
|
||||||
'masuk'=>$masuk_V,
|
|
||||||
'keluar'=>$keluar_V,
|
|
||||||
'bakiawal'=>$bakiAwalV,
|
|
||||||
'bakiakhir'=>$bakiAkhirV,
|
|
||||||
'bakieod'=>$BakiEOD
|
|
||||||
]);
|
|
||||||
|
|
||||||
//--FINAL RESULT...KENA RIDERECT KE PAGE SEBELUMNYA..
|
|
||||||
|
|
||||||
return $this->denominasicalculationserahan($request);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Vendored
+19
@@ -94,3 +94,22 @@ span#basic-hargaemas {
|
|||||||
padding: 5px 10px;
|
padding: 5px 10px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes heartbeat {
|
||||||
|
0% {
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
30% {
|
||||||
|
transform: scale(1.2);
|
||||||
|
}
|
||||||
|
60% {
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.heartbeat {
|
||||||
|
animation: heartbeat 1s infinite;
|
||||||
|
}
|
||||||
|
|||||||
Vendored
+16
@@ -0,0 +1,16 @@
|
|||||||
|
class SubscribePusher {
|
||||||
|
constructor(subscribe, event, apikey) {
|
||||||
|
this.subscribe = subscribe;
|
||||||
|
this.event = event;
|
||||||
|
this.apikey = apikey;
|
||||||
|
}
|
||||||
|
|
||||||
|
channel_subscribe() {
|
||||||
|
let channel = pusher.subscribe(this.subscribe);
|
||||||
|
channel.bind(this.event, function(data){
|
||||||
|
callback(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SubscribePusher;
|
||||||
Vendored
+19
@@ -434,6 +434,17 @@ async function openuptambahdanserah(e)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$.ajax({
|
||||||
|
method: "GET",
|
||||||
|
url: "{{ route('event.tellercash') }}",
|
||||||
|
success:function(data){
|
||||||
|
console.log('successfull trigger');
|
||||||
|
},
|
||||||
|
error: function(xhRequest, ajaxOptions, thrownError){
|
||||||
|
console.log(xhRequest,thrownError);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method:"POST",
|
method:"POST",
|
||||||
url: api_url + '/api/requestTeller/' + kodcaw,
|
url: api_url + '/api/requestTeller/' + kodcaw,
|
||||||
@@ -589,6 +600,14 @@ function tambahdanserahanfunc(e)
|
|||||||
if(id == "serahanmodal")
|
if(id == "serahanmodal")
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
method: "GET",
|
||||||
|
url: "{{ route('event.tellercash') }}",
|
||||||
|
success:function(data){
|
||||||
|
console.log('successfull trigger');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method:"POST",
|
method:"POST",
|
||||||
url: api_url + '/api/requestTeller/' + kodcaw,
|
url: api_url + '/api/requestTeller/' + kodcaw,
|
||||||
|
|||||||
Vendored
+75
@@ -0,0 +1,75 @@
|
|||||||
|
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 requestApi = (url, method, datarequest, callback) => {
|
||||||
|
$.ajax({
|
||||||
|
method: method,
|
||||||
|
url: url,
|
||||||
|
data: datarequest,
|
||||||
|
success: function(data) {
|
||||||
|
callback(data);
|
||||||
|
},
|
||||||
|
error: function(xhRequest, ajaxOptions, thrownError) {
|
||||||
|
console.error("Request failed:", xhRequest, thrownError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
if(!button){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.classList.add('btn-danger');
|
||||||
|
button.classList.add('heartbeat');
|
||||||
|
}
|
||||||
|
|
||||||
|
let notify_khazanah_main = () =>{
|
||||||
|
requestApi(api + '/api/requestTeller/get/' + kodcaw,"GET",{}, (response) =>{
|
||||||
|
let countModal = 0;
|
||||||
|
let countSerahan = 0;
|
||||||
|
|
||||||
|
response.forEach((req) => {
|
||||||
|
if (req.modal !== 0) {
|
||||||
|
countModal++;
|
||||||
|
} else if (req.serahan !== 0) {
|
||||||
|
countSerahan++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let notify_pendahuluan = () =>{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
let notify_serahan = () =>{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -255,6 +255,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<a href="{{ url('menu') }}"
|
<a href="{{ url('menu') }}"
|
||||||
|
id="btn-khazanah"
|
||||||
class="btn {{ $countkhazanah > 0 ? 'btn-danger' : 'btn-info' }} btn-lg btn-block mb-3">Khazanah</a>
|
class="btn {{ $countkhazanah > 0 ? 'btn-danger' : 'btn-info' }} btn-lg btn-block mb-3">Khazanah</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
@@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
<a href="{{ url('khazanahtebus') }}" class="btn {{ count($listserah) > 0 ? 'btn-danger' : 'btn-info' }} mb-4 mx-2 btn-lg col-5 text-center">Penyelesaian Pem. <span class="badge badge-light">{{ count($listserah) }}</span></a>
|
<a href="{{ url('khazanahtebus') }}" class="btn {{ count($listserah) > 0 ? 'btn-danger' : 'btn-info' }} mb-4 mx-2 btn-lg col-5 text-center">Penyelesaian Pem. <span class="badge badge-light">{{ count($listserah) }}</span></a>
|
||||||
|
|
||||||
<a href="{{ url('pendahuluan') }}" class="btn {{ $countmodal > 0 ? 'btn-danger' : 'btn-info' }} mb-4 mx-2 btn-lg col-5 text-center">Pendahuluan <span class="badge badge-light">{{ $countmodal }}</span></a>
|
<a id="btn-pend" href="{{ url('pendahuluan') }}" class="btn {{ $countmodal > 0 ? 'btn-danger' : 'btn-info' }} mb-4 mx-2 btn-lg col-5 text-center">Pendahuluan <span class="badge badge-light">{{ $countmodal }}</span></a>
|
||||||
|
|
||||||
<a href="{{ url('serahan') }}" class="btn {{ $countserahan > 0 ? 'btn-danger' : 'btn-info' }} mb-4 mx-2 btn-lg col-5 text-center">Serahan <span class="badge badge-light">{{ $countserahan }}</span></a>
|
<a id="btn-ser" href="{{ url('serahan') }}" class="btn {{ $countserahan > 0 ? 'btn-danger' : 'btn-info' }} mb-4 mx-2 btn-lg col-5 text-center">Serahan <span class="badge badge-light">{{ $countserahan }}</span></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -49,6 +49,10 @@
|
|||||||
{{-- Pusher --}}
|
{{-- Pusher --}}
|
||||||
<script src="{{ asset('js/pusher.min.js') }}"></script>
|
<script src="{{ asset('js/pusher.min.js') }}"></script>
|
||||||
|
|
||||||
|
@if(Auth::user()->role_harian == 'khazanah')
|
||||||
|
<script type="module" src="{{ asset('js/notification.js') }}"></script>
|
||||||
|
@endif
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function startTime() {
|
function startTime() {
|
||||||
var today = new Date();
|
var today = new Date();
|
||||||
|
|||||||
@@ -471,4 +471,8 @@ Route::get('supports/driver/mykad-reader/download',['as'=>'mykadreader.driver.do
|
|||||||
return Storage::disk('supports')->download('MykadReaderDriver.zip');
|
return Storage::disk('supports')->download('MykadReaderDriver.zip');
|
||||||
}])->middleware('auth','teller');
|
}])->middleware('auth','teller');
|
||||||
|
|
||||||
|
/* Event Trigger */
|
||||||
|
Route::get('/event/tellercash',['as'=>'event.tellercash','uses'=>'EventTriggerController@TellerCash'])->middleware('auth');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user