added autoserahan
This commit is contained in:
@@ -5,7 +5,7 @@ use App\Events\AutoSerahan;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
class AutoSerahanController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
@@ -15,12 +15,18 @@ class AutoSerahanController extends Controller
|
||||
'page' => request('page', 1) // Get current page from request
|
||||
])->json();
|
||||
|
||||
|
||||
// Extract pagination details
|
||||
$items = $response['data'] ?? []; // Data array
|
||||
$total = $response['total'] ?? 0; // Total items
|
||||
$perPage = $response['per_page'] ?? 10; // Items per page
|
||||
$currentPage = $response['current_page'] ?? 1; // Current page
|
||||
|
||||
$items = array_map(function ($item) {
|
||||
$item['cawangan_name'] = $this->CawanganKod($item['kodcaw']);
|
||||
return $item;
|
||||
}, $items);
|
||||
|
||||
// Create Laravel paginator
|
||||
$list = new LengthAwarePaginator($items, $total, $perPage, $currentPage, [
|
||||
'path' => request()->url(), // Current URL
|
||||
@@ -39,6 +45,59 @@ class AutoSerahanController extends Controller
|
||||
'sendApproval' => 'ACCEPTED',
|
||||
'operasi_name' => auth()->user()->name,
|
||||
])->json();
|
||||
Log::debug($response);
|
||||
if($response['approve_status'] == 'approved'){
|
||||
$approvalserahan = Http::get(config('api.url_koop') . '/api/autoserahan/get', [
|
||||
'id' => $request->id,
|
||||
'kodcaw' => $request->kodcaw
|
||||
])->json();
|
||||
|
||||
if($approvalserahan['action'] == 'create'){
|
||||
$pendahuluan = Http::put(config('api.url_koop') . '/api/autoserahan/pendahuluan', [
|
||||
'id' => $request->id,
|
||||
'kodcaw' => $request->kodcaw,
|
||||
'teller' => $request->teller,
|
||||
'amaun' => $request->amaun,
|
||||
'denopendser_id' => $approvalserahan['denopendser_id_v3']
|
||||
])->json();
|
||||
|
||||
$serahan = Http::put(config('api.url_pkb') . '/api/autoserahan/serahan', [
|
||||
'id' => $request->id,
|
||||
'kodcaw' => $request->kodcaw,
|
||||
'teller' => $request->teller,
|
||||
'amaun' => $request->amaun,
|
||||
'denopendser_id' => $approvalserahan['denopendser_id_v2']
|
||||
])->json();
|
||||
Log::error($serahan);
|
||||
|
||||
$call_set_approval_v3 = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->put(config('api.url_koop') . '/api/autoserahan/setapproval', [
|
||||
'id' => $request->id,
|
||||
'jenis' => 'rewrite',
|
||||
'gldetail_id' => $serahan['gldetail_id']
|
||||
])->json();
|
||||
}else{
|
||||
$pendahuluan = Http::put(config('api.url_koop') . '/api/autoserahan/delete/pendahuluan', [
|
||||
'array_approval' => $approvalserahan,
|
||||
'kodcaw' => $request->kodcaw,
|
||||
'teller' => $request->teller,
|
||||
'amaun' => $request->amaun,
|
||||
])->json();
|
||||
|
||||
Log::info($pendahuluan);
|
||||
|
||||
$serahan = Http::put(config('api.url_pkb') . '/api/autoserahan/delete/serahan', [
|
||||
'array_approval' => $approvalserahan,
|
||||
'kodcaw' => $request->kodcaw,
|
||||
'teller' => $request->teller,
|
||||
'amaun' => $request->amaun,
|
||||
])->json();
|
||||
|
||||
Log::info($serahan);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if($response['status'] == 'success'){
|
||||
event(new AutoSerahan("Lulus",$request->id,$request->kodcaw,$request->teller));
|
||||
@@ -68,4 +127,11 @@ class AutoSerahanController extends Controller
|
||||
return redirect()->route('autoserahan')->with('error', 'Serahan rejected failed');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function CawanganKod($kodcaw) {
|
||||
$cawangan = Http::get(config('api.url_koop') . '/api/cawangan/' . $kodcaw)->json();
|
||||
|
||||
return $cawangan['details_caw'] ?? 'Undefined';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user