diff --git a/app/Events/PendahuluanSerahan.php b/app/Events/PendahuluanSerahan.php index b82908e..c86feec 100644 --- a/app/Events/PendahuluanSerahan.php +++ b/app/Events/PendahuluanSerahan.php @@ -12,10 +12,12 @@ class PendahuluanSerahan implements ShouldBroadcast use Dispatchable, InteractsWithSockets, SerializesModels; public $pengesahan; + public $cawangan; - public function __construct($pengesahan) + public function __construct($pengesahan,$cawangan) { $this->pengesahan = $pengesahan; + $this->cawangan = $cawangan } public function broadcastOn() diff --git a/app/Http/Controllers/KhazanahController.php b/app/Http/Controllers/KhazanahController.php index c439723..b7d3a6a 100644 --- a/app/Http/Controllers/KhazanahController.php +++ b/app/Http/Controllers/KhazanahController.php @@ -1118,7 +1118,7 @@ class KhazanahController extends Controller ]); - event(new PendahuluanSerahan("Lulus")); + event(new PendahuluanSerahan("Lulus",$auth_user['cawangan'])); $updaterequest=Http::put(config('api.url').'/api/requestTeller/update/'. $auth_user['cawangan'],[ 'kodlaluan' => $request->teller, @@ -1198,7 +1198,7 @@ class KhazanahController extends Controller ]); - event(new PendahuluanSerahan("Lulus")); + event(new PendahuluanSerahan("Lulus",$auth_user['cawangan'])); $updaterequest=Http::put(config('api.url').'/api/requestTeller/update/'. $auth_user['cawangan'],[ 'kodlaluan' => $request->teller, @@ -2941,7 +2941,7 @@ class KhazanahController extends Controller 'kodlaluan'=>$kodlaluan ]); - event(new PendahuluanSerahan("Batal")); + event(new PendahuluanSerahan("Batal",$auth_user['cawangan'])); return response('Berjaya'); } diff --git a/public/js/main.js b/public/js/main.js index 64d4313..076dfa7 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -466,7 +466,7 @@ async function openuptambahdanserah(e) var channel = pusher.subscribe('pendahuluanserahan-notice'); channel.bind('penserahan-event', function(data) { - if(data.pengesahan === 'Lulus') + if(data.pengesahan === 'Lulus' && data.cawangan == kodcaw) { Swal.fire({ icon: 'success', @@ -631,7 +631,7 @@ function tambahdanserahanfunc(e) channel.bind('penserahan-event', function(data) { // let message = JSON.stringify(data); - if(data.pengesahan === 'Lulus') + if(data.pengesahan === 'Lulus' && data.cawangan == kodcaw) { Swal.fire({ icon: 'success', diff --git a/resources/views/homepage/penilai/home.blade.php b/resources/views/homepage/penilai/home.blade.php index 47557f2..80b4be8 100644 --- a/resources/views/homepage/penilai/home.blade.php +++ b/resources/views/homepage/penilai/home.blade.php @@ -630,33 +630,20 @@ }); - //TIME INTERVAL - let timerInterval; + var channel = pusher.subscribe('status-liked'); + channel.bind('my-event', function(data) { - timerInterval = setInterval(function(){ - $.ajax({ - method:'get', - url: "{{ route('teller.getkelulusan') }}", - data: { - "norujukan" : norujukan - }, - success:function(data){ - if(data != 0){ - clearInterval(timerInterval); - Swal.fire({ - icon: 'success', - title: 'Telah Disahkan' - }).then(function(){ - $("#print_submit_belum_serah").submit(); - }); - } - },error: function(xhr, status, error) { - var err = eval("(" + xhr.responseText + ")"); - alert(xhr.responseText); - } - }); - }, 3000); - + if(cawangan == data.cawangan) + { + Swal.fire({ + icon: 'success', + title: 'Telah Disahkan' + }).then(function(){ + $("#print_submit_belum_serah").submit(); + }); + } + + }); }else if (result.dismiss === Swal.DismissReason.cancel) { swalWithBootstrapButtons.fire(