added event and call
This commit is contained in:
committed by
Hafifie PKB
parent
6f52b6256f
commit
d79c367d48
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
|
||||||
|
class AutoSerahan implements ShouldBroadcast
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
public $pengesahan;
|
||||||
|
public $cawangan;
|
||||||
|
public $kodlaluan;
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
public function __construct($pengesahan,$id,$cawangan,$kodlaluan)
|
||||||
|
{
|
||||||
|
$this->pengesahan = $pengesahan;
|
||||||
|
$this->id = $id;
|
||||||
|
$this->cawangan = $cawangan;
|
||||||
|
$this->kodlaluan = $kodlaluan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return ['autoserahan-notice'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function broadcastAs()
|
||||||
|
{
|
||||||
|
return 'autoserahan-event';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4286,4 +4286,76 @@ class KhazanahController extends Controller
|
|||||||
$val = preg_replace('/\.(?=.*\.)/', '', $val);
|
$val = preg_replace('/\.(?=.*\.)/', '', $val);
|
||||||
return floatval($val);
|
return floatval($val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function AutoSerahan(Request $request)
|
||||||
|
{
|
||||||
|
// Step 1: Call API v3 First
|
||||||
|
$call_approval_v3 = Http::withOptions(['verify' => config('app.api_verify')])
|
||||||
|
->post(config('api.url_koop') . '/api/autoserahan/create', [
|
||||||
|
'kodcaw' => $request->arraysend['kodcaw'],
|
||||||
|
'teller' => $request->arraysend['teller'],
|
||||||
|
'amaun' => $request->arraysend['amaun'],
|
||||||
|
'txtring1' => $request->arraysend['ambilanring1'],
|
||||||
|
'txtring5' => $request->arraysend['ambilanring5'],
|
||||||
|
'txtring10' => $request->arraysend['ambilanring10'],
|
||||||
|
'txtring20' => $request->arraysend['ambilanring20'],
|
||||||
|
'txtring50' => $request->arraysend['ambilanring50'],
|
||||||
|
'txtring100' => $request->arraysend['ambilanring100'],
|
||||||
|
'txtsen1' => $request->arraysend['ambilansen1'],
|
||||||
|
'txtsen5' => $request->arraysend['ambilansen5'],
|
||||||
|
'txtsen10' => $request->arraysend['ambilansen10'],
|
||||||
|
'txtsen20' => $request->arraysend['ambilansen20'],
|
||||||
|
'txtsen50' => $request->arraysend['ambilansen50'],
|
||||||
|
'jenis' => 'pendahuluan',
|
||||||
|
'version' => 'v3',
|
||||||
|
])->json();
|
||||||
|
|
||||||
|
// Check if API v3 was successful before proceeding
|
||||||
|
if (!isset($call_approval_v3['id']) || $call_approval_v3['status'] !== 'success') {
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'failed',
|
||||||
|
'message' => 'API v3 failed. Cannot proceed to API v2.',
|
||||||
|
'error' => $call_approval_v3
|
||||||
|
], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 2: Call API v2 using response from API v3
|
||||||
|
$call_approval_v2 = Http::withOptions(['verify' => config('app.api_verify')])
|
||||||
|
->post(config('api.url_pkb') . '/api/autoserahan/create', [
|
||||||
|
'id' => $call_approval_v3['id'], // Use ID from API v3 response
|
||||||
|
'kodcaw' => $request->arraysend['kodcaw'],
|
||||||
|
'teller' => $request->arraysend['teller'],
|
||||||
|
'amaun' => $request->arraysend['amaun'],
|
||||||
|
'txtring1' => $request->arraysend['ambilanring1'],
|
||||||
|
'txtring5' => $request->arraysend['ambilanring5'],
|
||||||
|
'txtring10' => $request->arraysend['ambilanring10'],
|
||||||
|
'txtring20' => $request->arraysend['ambilanring20'],
|
||||||
|
'txtring50' => $request->arraysend['ambilanring50'],
|
||||||
|
'txtring100' => $request->arraysend['ambilanring100'],
|
||||||
|
'txtsen1' => $request->arraysend['ambilansen1'],
|
||||||
|
'txtsen5' => $request->arraysend['ambilansen5'],
|
||||||
|
'txtsen10' => $request->arraysend['ambilansen10'],
|
||||||
|
'txtsen20' => $request->arraysend['ambilansen20'],
|
||||||
|
'txtsen50' => $request->arraysend['ambilansen50'],
|
||||||
|
'jenis' => 'serahan',
|
||||||
|
'version' => 'v2',
|
||||||
|
])->json();
|
||||||
|
|
||||||
|
// Step 3: Check if both API v3 and API v2 were successful
|
||||||
|
if ($call_approval_v2['status'] === 'success' && $call_approval_v3['status'] === 'success') {
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'success',
|
||||||
|
'message' => 'Approval process completed successfully',
|
||||||
|
'id' => $call_approval_v3['id'],
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'failed',
|
||||||
|
'message' => 'One of the approvals failed',
|
||||||
|
], 400);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
return [
|
return [
|
||||||
'url' => env('API_URL')
|
'url' => env('API_URL'),
|
||||||
|
'url_koop' => env('API_URL_KOOP','http://localhost:8000'),
|
||||||
|
'url_pkb' => env('API_URL_PKB','http://localhost:8000'),
|
||||||
];
|
];
|
||||||
@@ -393,6 +393,7 @@
|
|||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
let SwalPengesahan = '';
|
||||||
|
|
||||||
if(jenisserahan == 'biasa')
|
if(jenisserahan == 'biasa')
|
||||||
{
|
{
|
||||||
@@ -406,7 +407,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
Swal.fire({
|
let SwalPengesahan = Swal.fire({
|
||||||
title: 'Tunggu Pengesahan Daripada Operasi.',
|
title: 'Tunggu Pengesahan Daripada Operasi.',
|
||||||
icon: 'info',
|
icon: 'info',
|
||||||
width: 600,
|
width: 600,
|
||||||
@@ -448,7 +449,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sendRequest(arraysend,jenisserahan){
|
function sendRequest(arraysend,jenisserahan){
|
||||||
|
|
||||||
if(jenisserahan == 'biasa'){
|
if(jenisserahan == 'biasa'){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@@ -503,6 +503,60 @@
|
|||||||
error: function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
console.log(textStatus, errorThrown);
|
console.log(textStatus, errorThrown);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
let approvalid = '';
|
||||||
|
$.ajax({
|
||||||
|
method: 'post',
|
||||||
|
url: '{{ route("khazanah.autoserahan") }}',
|
||||||
|
data: {
|
||||||
|
"_token": "{{ csrf_token() }}",
|
||||||
|
'arraysend': arraysend
|
||||||
|
},
|
||||||
|
success:function(e){
|
||||||
|
approvalid = e.id;
|
||||||
|
Swal.update({
|
||||||
|
text: 'Menunggu Pengesahan Daripada Operasi!',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var pusher = new Pusher("{{ env('PUSHER_APP_KEY') }}", {
|
||||||
|
cluster: 'ap1',
|
||||||
|
encrypted: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var channel = pusher.subscribe('autoserahan-notice');
|
||||||
|
channel.bind('autoserahan-event', function(data) {
|
||||||
|
console.log(data);
|
||||||
|
if(data.pengesahan === 'Lulus' && data.id == approvalid && data.cawangan == kodcaw && data.kodlaluan == teller)
|
||||||
|
{
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'success',
|
||||||
|
title: 'Auto Serahan Berjaya',
|
||||||
|
text: 'Operasi berjaya meluluskan Auto Serahan!'
|
||||||
|
}).then(function(){
|
||||||
|
location.reload();
|
||||||
|
});
|
||||||
|
}else if(data.pengesahan == 'Batal' && data.id == approvalid && data.cawangan == kodcaw && data.kodlaluan == teller){
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'error',
|
||||||
|
title: 'Auto Serahan Dibatalkan',
|
||||||
|
text: 'Operasi membatalkan Auto Serahan!'
|
||||||
|
}).then(function(){
|
||||||
|
location.reload();
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'error',
|
||||||
|
title: 'Auto Serahan Mengalami Ralat',
|
||||||
|
text: 'Auto Serahan tidak berjaya!'
|
||||||
|
}).then(function(){
|
||||||
|
location.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -161,6 +161,8 @@ Route::post('/permohonan/simpan',['as'=>'permohonan.simpan','uses' => 'KhazanahC
|
|||||||
Route::get('/permohonan/status/{mohonid}',['as'=>'permohonan.status','uses' => 'KhazanahController@StatusPermohonan'])->middleware('auth','khazanah');
|
Route::get('/permohonan/status/{mohonid}',['as'=>'permohonan.status','uses' => 'KhazanahController@StatusPermohonan'])->middleware('auth','khazanah');
|
||||||
Route::post('/permohonan/cit',['as'=>'permohonan.cit','uses' => 'KhazanahController@CITPermohonan'])->middleware('auth','khazanah');
|
Route::post('/permohonan/cit',['as'=>'permohonan.cit','uses' => 'KhazanahController@CITPermohonan'])->middleware('auth','khazanah');
|
||||||
Route::post('/permohonan/download',['as'=>'permohonan.download','uses' => 'KhazanahController@DownloadFiles'])->middleware('auth','khazanah');
|
Route::post('/permohonan/download',['as'=>'permohonan.download','uses' => 'KhazanahController@DownloadFiles'])->middleware('auth','khazanah');
|
||||||
|
Route::post('/khazanah/autoserahan',['as'=>'khazanah.autoserahan','uses'=>'KhazanahController@AutoSerahan'])->middleware('auth','khazanah');
|
||||||
|
|
||||||
|
|
||||||
Route::post('/kakitangan/harian',['as'=>'kakitangan.harian','uses'=>'KakitanganController@kakitanganHarian'])->middleware('auth','khazanah');
|
Route::post('/kakitangan/harian',['as'=>'kakitangan.harian','uses'=>'KakitanganController@kakitanganHarian'])->middleware('auth','khazanah');
|
||||||
Route::get('/lelong',['as'=>'lelong','uses'=>'LelongController@lelong']);
|
Route::get('/lelong',['as'=>'lelong','uses'=>'LelongController@lelong']);
|
||||||
|
|||||||
Reference in New Issue
Block a user