update all controller frontend for kadar anggota koperasi
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
|
||||
class NotifikasiAnggota implements ShouldBroadcast
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $nokp;
|
||||
public $status; // DILULUSKAN atau DITOLAK
|
||||
public $siri;
|
||||
public $komen;
|
||||
public $tagoperasi;
|
||||
|
||||
public function __construct($nokp, $status, $siri, $komen, $tagoperasi = null)
|
||||
{
|
||||
$this->nokp = $nokp;
|
||||
$this->status = strtoupper($status); // pastikan huruf besar DILULUSKAN/DITOLAK
|
||||
$this->komen = $komen;
|
||||
$this->tagoperasi = $tagoperasi;
|
||||
}
|
||||
|
||||
public function broadcastOn()
|
||||
{
|
||||
return ['notice-anggota'];
|
||||
}
|
||||
|
||||
public function broadcastAs()
|
||||
{
|
||||
return 'my-anggota';
|
||||
}
|
||||
|
||||
public function broadcastWith()
|
||||
{
|
||||
return [
|
||||
'noic' => $this->nokp,
|
||||
'status' => $this->status, // ikut format API updateAnggota
|
||||
'komen' => $this->komen,
|
||||
'tagoperasi' => $this->tagoperasi,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
use Twilio\Rest\Client;
|
||||
use App\Komoditi;
|
||||
use App\Events\Dashboard\PelangganNotify;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
@@ -24,7 +25,7 @@ class CustomersController extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->customerService = New CustomerService();
|
||||
$this->customerService = new CustomerService();
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
@@ -38,84 +39,246 @@ class CustomersController extends Controller
|
||||
$api_url = config('api.url');
|
||||
$auth_user = Auth::user();
|
||||
$idtype = 'nokp';
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/' . $auth_user['cawangan'])->json();
|
||||
$bank = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/bank')->json();
|
||||
$pekerjaan = Http::withOptions(['verify' => config('app.api_verify')])->get($api_url . '/api/pekerjaan')->json();
|
||||
$blacklist_search = false;
|
||||
|
||||
return view('customers.' . $cawangan_info['version'] . '.index',compact('search','blacklist_search','cawangan_info','bank','api_url','idtype','pekerjaan'));
|
||||
return view('customers.' . $cawangan_info['version'] . '.index', compact('search', 'blacklist_search', 'cawangan_info', 'bank', 'api_url', 'idtype', 'pekerjaan'));
|
||||
}
|
||||
|
||||
public function info(Request $request){
|
||||
public function info(Request $request)
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
$api_url = config('api.url');
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
||||
|
||||
$customer_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customers/'. Session::get('noic'))->json();
|
||||
// dd($customer_info);
|
||||
$pekerjaan = Http::withOptions(['verify' => config('app.api_verify')])->get($api_url . '/api/pekerjaan')->json();
|
||||
// 🔹 Panggil maklumat cawangan
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/cawangan/' . $auth_user['cawangan'])
|
||||
->json();
|
||||
|
||||
// 🔹 Panggil maklumat pelanggan (customer)
|
||||
$customer_info = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/customers/' . Session::get('noic'))
|
||||
->json();
|
||||
|
||||
// 🔹 Panggil maklumat pekerjaan
|
||||
$pekerjaan = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/pekerjaan')
|
||||
->json();
|
||||
|
||||
$komoditi = Komoditi::first();
|
||||
$min_komoditi = $komoditi['min_komoditi'];
|
||||
|
||||
$bakilelong = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/bakilelong/cawangan/' . $auth_user['cawangan'] . '/' . Session::get('noic') . '/baki')->json();
|
||||
$rugilelong = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/bakilelong/cawangan/' . $auth_user['cawangan'] . '/' . Session::get('noic') . '/rugi')->json();
|
||||
// 🔹 Panggil baki lelong
|
||||
$bakilelong = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/bakilelong/cawangan/' . $auth_user['cawangan'] . '/' . Session::get('noic') . '/baki')
|
||||
->json();
|
||||
|
||||
// 🔹 Panggil rugi lelong
|
||||
$rugilelong = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/bakilelong/cawangan/' . $auth_user['cawangan'] . '/' . Session::get('noic') . '/rugi')
|
||||
->json();
|
||||
|
||||
// 🔹 Reset session sementara
|
||||
$request->session()->forget('page_reload');
|
||||
$request->session()->forget('norujukan');
|
||||
|
||||
$customer_page = ($cawangan_info['version'] == 'v1') ? 'customers.v1.info' : 'customers.v2.info';
|
||||
$customer_page = ($cawangan_info['version'] == 'v1')
|
||||
? 'customers.v1.info'
|
||||
: 'customers.v2.info';
|
||||
|
||||
$getApprovalError = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/getApproval',[
|
||||
'kodcaw' => $auth_user['cawangan'],
|
||||
'teller' => $auth_user['name'],
|
||||
])->json();
|
||||
// Logik papar butang "Assign sebagai Anggota"
|
||||
$showAssignAnggotaBtn = false;
|
||||
$noic = Session::get('noic');
|
||||
|
||||
if($request->tebus_auto_tawarruq_berjaya === 'true'){
|
||||
if (!empty($customer_info)) {
|
||||
|
||||
// 🔹 Panggil API anggota
|
||||
$anggota_info = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/customer/anggota', [
|
||||
'noic' => $noic
|
||||
])
|
||||
->json();
|
||||
|
||||
// 🔹 Semak jika ada data anggota dan belum di-tag sebagai anggota
|
||||
$isAnggotaExist = isset($anggota_info) && !empty($anggota_info) && !isset($anggota_info['message']);
|
||||
|
||||
if ($isAnggotaExist && isset($customer_info['tag_anggota']) && $customer_info['tag_anggota'] == 0) {
|
||||
$showAssignAnggotaBtn = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Return ke view
|
||||
$getApprovalError = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/getApproval', [
|
||||
'kodcaw' => $auth_user['cawangan'],
|
||||
'teller' => $auth_user['name'],
|
||||
])
|
||||
->json();
|
||||
|
||||
if ($request->tebus_auto_tawarruq_berjaya === 'true') {
|
||||
$request->session()->flash('activate_tab', 'SAG_baru');
|
||||
}
|
||||
|
||||
return view($customer_page,compact('cawangan_info','api_url','customer_info','bakilelong','rugilelong','min_komoditi','pekerjaan','getApprovalError'));
|
||||
return view($customer_page, compact(
|
||||
'cawangan_info',
|
||||
'api_url',
|
||||
'customer_info',
|
||||
'bakilelong',
|
||||
'rugilelong',
|
||||
'min_komoditi',
|
||||
'pekerjaan',
|
||||
'getApprovalError',
|
||||
'showAssignAnggotaBtn'
|
||||
));
|
||||
}
|
||||
|
||||
public function search(Request $request){
|
||||
// dd($request->all());
|
||||
|
||||
public function search(Request $request)
|
||||
{
|
||||
$noic = $request->noic;
|
||||
$idtype = $request->customerIDType;
|
||||
Session::put('noic', $noic);
|
||||
|
||||
$api_url = config('api.url');
|
||||
$auth_user = Auth::user();
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
||||
$bank = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/bank')->json();
|
||||
$customer_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customers/'. $noic)->json();
|
||||
$pekerjaan = Http::withOptions(['verify' => config('app.api_verify')])->get($api_url . '/api/pekerjaan')->json();
|
||||
|
||||
$blacklist = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customer/blacklist',[
|
||||
'nokp' => $noic
|
||||
])->json();
|
||||
// if($customers_info){
|
||||
// $customer_info = $customers_info[0];
|
||||
// }else{
|
||||
// $customer_info = $customers_info;
|
||||
// }
|
||||
// Dapatkan maklumat asas
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/cawangan/' . $auth_user['cawangan'])
|
||||
->json();
|
||||
|
||||
$bank = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/bank')
|
||||
->json();
|
||||
|
||||
$customer_info = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/customers/' . $noic)
|
||||
->json();
|
||||
|
||||
$pekerjaan = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/pekerjaan')
|
||||
->json();
|
||||
|
||||
$blacklist = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/customer/blacklist', ['nokp' => $noic])
|
||||
->json();
|
||||
|
||||
// Reset session lama
|
||||
$request->session()->forget('page_reload');
|
||||
$request->session()->forget('norujukan');
|
||||
|
||||
$blacklist_search = false;
|
||||
$search = true;
|
||||
if($customer_info){
|
||||
if($blacklist){
|
||||
|
||||
// SEMAK STATUS ANGGOTA DAN PELANGGAN
|
||||
$isAnggota = false;
|
||||
$isPelanggan = false;
|
||||
$isNewCustomer = false;
|
||||
$showAssignAnggotaBtn = false;
|
||||
$showDaftarPelangganBtn = false;
|
||||
|
||||
// Semak dalam sistem anggota
|
||||
$anggota_info = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get(config('api.url') . '/api/customer/anggota', [
|
||||
'noic' => $noic
|
||||
])
|
||||
->json();
|
||||
|
||||
// ✅ Semak betul-betul jika ada rekod anggota
|
||||
if (!empty($anggota_info) && isset($anggota_info['data']) && !empty($anggota_info['data'])) {
|
||||
$isAnggota = true;
|
||||
} elseif (isset($anggota_info['noic']) && !empty($anggota_info['noic'])) {
|
||||
$isAnggota = true;
|
||||
}
|
||||
|
||||
if ($customer_info && isset($customer_info['id'])) {
|
||||
$isPelanggan = true;
|
||||
}
|
||||
|
||||
// ✅ Tentukan butang mana nak paparkan (logik diperbetulkan)
|
||||
if ($isPelanggan && !$isAnggota) {
|
||||
// Pelanggan dah berdaftar tapi bukan anggota koperasi
|
||||
$showAssignAnggotaBtn = true;
|
||||
} elseif ($isAnggota && !$isPelanggan) {
|
||||
// Anggota koperasi tapi belum berdaftar sebagai pelanggan
|
||||
$showDaftarPelangganBtn = true;
|
||||
} elseif (!$isAnggota && !$isPelanggan) {
|
||||
// Bukan anggota dan bukan pelanggan (pelanggan baru)
|
||||
$showDaftarPelangganBtn = true;
|
||||
$isNewCustomer = true;
|
||||
}
|
||||
|
||||
// 🔍 Debug log untuk semak nilai sebenar
|
||||
Log::info('DEBUG CUSTOMER STATUS', [
|
||||
'noic' => $noic,
|
||||
'isAnggota' => $isAnggota,
|
||||
'isPelanggan' => $isPelanggan,
|
||||
'isNewCustomer' => $isNewCustomer,
|
||||
'showAssignAnggotaBtn' => $showAssignAnggotaBtn,
|
||||
'showDaftarPelangganBtn' => $showDaftarPelangganBtn,
|
||||
]);
|
||||
|
||||
// PROSES PAPARAN MENGIKUT HASIL CARIAN
|
||||
if ($customer_info) {
|
||||
// Ada maklumat pelanggan
|
||||
if ($blacklist) {
|
||||
$blacklist_search = true;
|
||||
return view('customers.' . $cawangan_info['version'] .'.index',compact('blacklist_search','customer_info','search','noic','cawangan_info','bank','api_url','idtype'));
|
||||
}else{
|
||||
Session::put('customer_info',$customer_info);
|
||||
return redirect()->route('customer_info')->with( ['customer_info' => $customer_info,'cawangan_info'=>$cawangan_info,'api_url'=>$api_url]);
|
||||
return view('customers.' . $cawangan_info['version'] . '.index', compact(
|
||||
'blacklist_search',
|
||||
'customer_info',
|
||||
'search',
|
||||
'noic',
|
||||
'cawangan_info',
|
||||
'bank',
|
||||
'api_url',
|
||||
'idtype',
|
||||
'isAnggota',
|
||||
'isPelanggan',
|
||||
'isNewCustomer',
|
||||
'showAssignAnggotaBtn',
|
||||
'showDaftarPelangganBtn',
|
||||
'auth_user'
|
||||
));
|
||||
} else {
|
||||
// Simpan dalam session & redirect ke paparan info pelanggan
|
||||
Session::put('customer_info', $customer_info);
|
||||
return redirect()->route('customer_info')->with([
|
||||
'customer_info' => $customer_info,
|
||||
'cawangan_info' => $cawangan_info,
|
||||
'api_url' => $api_url,
|
||||
'isAnggota' => $isAnggota,
|
||||
'isPelanggan' => $isPelanggan,
|
||||
'isNewCustomer' => $isNewCustomer,
|
||||
'showAssignAnggotaBtn' => $showAssignAnggotaBtn,
|
||||
'showDaftarPelangganBtn' => $showDaftarPelangganBtn,
|
||||
'auth_user' => $auth_user
|
||||
]);
|
||||
}
|
||||
}else{
|
||||
if($blacklist){
|
||||
} else {
|
||||
// Tiada customer dalam sistem
|
||||
if ($blacklist) {
|
||||
$blacklist_search = true;
|
||||
return view('customers.' . $cawangan_info['version'] . '.index',compact('blacklist_search','customer_info','search','noic','cawangan_info','bank','api_url','idtype','pekerjaan'));
|
||||
}else{
|
||||
return view('customers.' . $cawangan_info['version'] . '.index',compact('blacklist_search','customer_info','search','noic','cawangan_info','bank','api_url','idtype','pekerjaan'));
|
||||
}
|
||||
|
||||
return view('customers.' . $cawangan_info['version'] . '.index', compact(
|
||||
'blacklist_search',
|
||||
'customer_info',
|
||||
'search',
|
||||
'noic',
|
||||
'cawangan_info',
|
||||
'bank',
|
||||
'api_url',
|
||||
'idtype',
|
||||
'pekerjaan',
|
||||
'isAnggota',
|
||||
'isPelanggan',
|
||||
'isNewCustomer',
|
||||
'showAssignAnggotaBtn',
|
||||
'showDaftarPelangganBtn',
|
||||
'auth_user'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,9 +286,9 @@ class CustomersController extends Controller
|
||||
public function cari(Request $request)
|
||||
{
|
||||
$api_url = config('api.url');
|
||||
$customers_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customers/'. $request->icno)->json();
|
||||
$customers_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customers/' . $request->icno)->json();
|
||||
|
||||
if(sizeof($customers_info) > 0)
|
||||
if (sizeof($customers_info) > 0)
|
||||
return $customers_info;
|
||||
else
|
||||
return response(["no-data"], 200);
|
||||
@@ -149,60 +312,58 @@ class CustomersController extends Controller
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
if($request->idtype == 'nokp'){
|
||||
if ($request->idtype == 'nokp') {
|
||||
$nokpbaru = $request->noic;
|
||||
$nokplama = '';
|
||||
}elseif($request->idtype == 'passport'){
|
||||
} elseif ($request->idtype == 'passport') {
|
||||
$nokpbaru = '';
|
||||
$nokplama = $request->noic;
|
||||
}
|
||||
if($request->warganegara){
|
||||
if ($request->warganegara) {
|
||||
$warganegara = 'Y';
|
||||
}else{
|
||||
} else {
|
||||
$warganegara = 'N';
|
||||
}
|
||||
if($request->bumiputera){
|
||||
if ($request->bumiputera) {
|
||||
$bumiputera = 'Y';
|
||||
}else{
|
||||
} else {
|
||||
$bumiputera = 'N';
|
||||
}
|
||||
if($request->jantina == 'Lelaki'){
|
||||
if ($request->jantina == 'Lelaki') {
|
||||
$jantina = 'L';
|
||||
}elseif($request->jantina == 'Perempuan'){
|
||||
} elseif ($request->jantina == 'Perempuan') {
|
||||
$jantina = 'P';
|
||||
}
|
||||
$split_date = explode('/',$request->tarikh_lahir);
|
||||
$split_date = explode('/', $request->tarikh_lahir);
|
||||
|
||||
$tarikh_lahir = $split_date[2].'-'.$split_date[1].'-'.$split_date[0];
|
||||
$tarikh_lahir = $split_date[2] . '-' . $split_date[1] . '-' . $split_date[0];
|
||||
$tarikhlahir = Carbon::parse($tarikh_lahir);
|
||||
$auth_user = Auth::user();
|
||||
$latest_customer = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customers/latest/' . $auth_user['cawangan'])->json();
|
||||
|
||||
if($latest_customer == null){
|
||||
if ($latest_customer == null) {
|
||||
$nosiri_latest = 1;
|
||||
}
|
||||
else{
|
||||
$nosiri_latest = $latest_customer['nosiri']+1;
|
||||
} else {
|
||||
$nosiri_latest = $latest_customer['nosiri'] + 1;
|
||||
}
|
||||
|
||||
$count = sprintf("%08d", $nosiri_latest);
|
||||
|
||||
$no_pelanggan = $request->bangsa . substr($request->noic,6,2).'-'.$count;
|
||||
$no_pelanggan = $request->bangsa . substr($request->noic, 6, 2) . '-' . $count;
|
||||
$detail_poskod = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/poskod/' . $request->poskod)->json();
|
||||
|
||||
if(empty($detail_poskod)){
|
||||
if (empty($detail_poskod)) {
|
||||
|
||||
$detail_poskod = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->post(config('api.url') . '/api/poskod', [
|
||||
'poskod' => $request->poskod,
|
||||
'koddaerah' => $request->koddaerah,
|
||||
'kodnegeri' => $request->kodnegeri,
|
||||
'user' => auth()->user(),
|
||||
])->json();
|
||||
|
||||
->post(config('api.url') . '/api/poskod', [
|
||||
'poskod' => $request->poskod,
|
||||
'koddaerah' => $request->koddaerah,
|
||||
'kodnegeri' => $request->kodnegeri,
|
||||
'user' => auth()->user(),
|
||||
])->json();
|
||||
}
|
||||
|
||||
$customer_info = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url') . '/api/customers/create/'. $auth_user['cawangan'],[
|
||||
$customer_info = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url') . '/api/customers/create/' . $auth_user['cawangan'], [
|
||||
'kodcaw' => $auth_user['cawangan'],
|
||||
'nopelanggan' => $no_pelanggan,
|
||||
'nokpbaru' => $nokpbaru,
|
||||
@@ -224,61 +385,117 @@ class CustomersController extends Controller
|
||||
'teller' => $auth_user['name'],
|
||||
'telefon2' => $request->alternate_phone,
|
||||
'nosiri' => $nosiri_latest,
|
||||
'nota'=>$request->nota,
|
||||
'kodkerja'=>$request->pekerjaan,
|
||||
'nota_pekerjaan'=>$request->nota_pekerjaan,
|
||||
'notaarcc'=>$request->notaarcc,
|
||||
'tujuangadai'=>$request->tujuan_gadai,
|
||||
'nota' => $request->nota,
|
||||
'kodkerja' => $request->pekerjaan,
|
||||
'nota_pekerjaan' => $request->nota_pekerjaan,
|
||||
'notaarcc' => $request->notaarcc,
|
||||
'tujuangadai' => $request->tujuan_gadai,
|
||||
]);
|
||||
|
||||
Session::put('customer_info', $customer_info);
|
||||
Session::put('noic', $request->noic);
|
||||
|
||||
event(new PelangganNotify('lulus',$auth_user['cawangan']));
|
||||
return redirect()->route('customer_info')->with( ['customer_info' => $customer_info] );
|
||||
event(new PelangganNotify('lulus', $auth_user['cawangan']));
|
||||
return redirect()->route('customer_info')->with(['customer_info' => $customer_info]);
|
||||
}
|
||||
|
||||
public function getOTP(Request $request){
|
||||
public function getOTP(Request $request)
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
$expired = Carbon::now();
|
||||
$expired = new Carbon();
|
||||
$expired = $expired->addHours(24);
|
||||
$currentDateTime = Carbon::now();
|
||||
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/' . $auth_user['cawangan'])->json();
|
||||
$nama_cawangan = $cawangan_info["details_caw"];
|
||||
|
||||
$nokp = $request->noic_otp;
|
||||
$customer = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/api/customers/'.$nokp)->json();
|
||||
$recipient = '6'.$customer['telefon'];
|
||||
$customer = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customers/' . $nokp)->json();
|
||||
$recipient = '6' . $customer['telefon'];
|
||||
// $recipient = '60189025461';
|
||||
//pembinaan token
|
||||
function token($length) {
|
||||
function token($length)
|
||||
{
|
||||
$characters = array(
|
||||
"A","B","C","D","E","F","G","H","J","K","L","M",
|
||||
"N","P","Q","R","S","T","U","V","W","X","Y","Z",
|
||||
"a","b","c","d","e","f","g","h","i","j","k","m",
|
||||
"n","o","p","q","r","s","t","u","v","w","x","y","z",
|
||||
"1","2","3","4","5","6","7","8","9");
|
||||
"A",
|
||||
"B",
|
||||
"C",
|
||||
"D",
|
||||
"E",
|
||||
"F",
|
||||
"G",
|
||||
"H",
|
||||
"J",
|
||||
"K",
|
||||
"L",
|
||||
"M",
|
||||
"N",
|
||||
"P",
|
||||
"Q",
|
||||
"R",
|
||||
"S",
|
||||
"T",
|
||||
"U",
|
||||
"V",
|
||||
"W",
|
||||
"X",
|
||||
"Y",
|
||||
"Z",
|
||||
"a",
|
||||
"b",
|
||||
"c",
|
||||
"d",
|
||||
"e",
|
||||
"f",
|
||||
"g",
|
||||
"h",
|
||||
"i",
|
||||
"j",
|
||||
"k",
|
||||
"m",
|
||||
"n",
|
||||
"o",
|
||||
"p",
|
||||
"q",
|
||||
"r",
|
||||
"s",
|
||||
"t",
|
||||
"u",
|
||||
"v",
|
||||
"w",
|
||||
"x",
|
||||
"y",
|
||||
"z",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9"
|
||||
);
|
||||
if ($length < 0 || $length > count($characters)) return null;
|
||||
shuffle($characters);
|
||||
return implode("", array_slice($characters, 0, $length));
|
||||
}
|
||||
|
||||
$otp_token = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/otp/' . $nokp) ->json();
|
||||
$otp_token_used = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/otp/used/' . $nokp) ->json();
|
||||
$otp_token = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/otp/' . $nokp)->json();
|
||||
$otp_token_used = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/otp/used/' . $nokp)->json();
|
||||
|
||||
if (is_array($otp_token) || is_object($otp_token)){
|
||||
if($otp_token){
|
||||
if (is_array($otp_token) || is_object($otp_token)) {
|
||||
if ($otp_token) {
|
||||
return response(['error' => "OTP Akaun Telah Di Jana"]);
|
||||
}else{
|
||||
if (is_array($otp_token_used) || is_object($otp_token_used)){
|
||||
if($otp_token_used){
|
||||
} else {
|
||||
if (is_array($otp_token_used) || is_object($otp_token_used)) {
|
||||
if ($otp_token_used) {
|
||||
return response(['error' => "Pelanggan Sudah Mendaftar Pada Customer Portal"]);
|
||||
}else{
|
||||
} else {
|
||||
$random = token(6);
|
||||
|
||||
$otp_baru = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url'). '/api/otp/generateotp/' . $nokp,[
|
||||
$otp_baru = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url') . '/api/otp/generateotp/' . $nokp, [
|
||||
'otptoken' => $random,
|
||||
'expired' => $expired,
|
||||
'kodcaw' => $auth_user['cawangan']
|
||||
@@ -286,12 +503,12 @@ class CustomersController extends Controller
|
||||
// $message = "Your OTP code is " . $random;
|
||||
$message = 'AR-RAHN PKB ' . $nama_cawangan . ' : OTP: ' . $random . ' ' . $currentDateTime . '. AR-RAHN CARELINE CENTRE 1300-22-4343';
|
||||
$this->sendWhatsAppMessage($message, $recipient);
|
||||
return response()->json(['otp'=>$random]);
|
||||
return response()->json(['otp' => $random]);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
$random = token(6);
|
||||
|
||||
$otp_baru = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url'). '/api/otp/generateotp/' . $nokp,[
|
||||
$otp_baru = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url') . '/api/otp/generateotp/' . $nokp, [
|
||||
'otptoken' => $random,
|
||||
'expired' => $expired,
|
||||
'kodcaw' => $auth_user['cawangan']
|
||||
@@ -299,17 +516,17 @@ class CustomersController extends Controller
|
||||
// $message = "Your OTP code is " . $random;
|
||||
$message = 'AR-RAHN PKB ' . $nama_cawangan . ' : OTP: ' . $random . ' ' . $currentDateTime . '. AR-RAHN CARELINE CENTRE 1300-22-4343';
|
||||
$this->sendWhatsAppMessage($message, $recipient);
|
||||
return response()->json(['otp'=>$random]);
|
||||
return response()->json(['otp' => $random]);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if (is_array($otp_token_used) || is_object($otp_token_used)){
|
||||
if($otp_token_used){
|
||||
} else {
|
||||
if (is_array($otp_token_used) || is_object($otp_token_used)) {
|
||||
if ($otp_token_used) {
|
||||
return response(['error' => "Pelanggan Sudah Mendaftar Pada Customer Portal"]);
|
||||
}else{
|
||||
} else {
|
||||
$random = token(6);
|
||||
|
||||
$otp_baru = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url'). '/api/otp/generateotp/' . $nokp,[
|
||||
$otp_baru = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url') . '/api/otp/generateotp/' . $nokp, [
|
||||
'otptoken' => $random,
|
||||
'expired' => $expired,
|
||||
'kodcaw' => $auth_user['cawangan']
|
||||
@@ -317,12 +534,12 @@ class CustomersController extends Controller
|
||||
// $message = "Your OTP code is " . $random;
|
||||
$message = 'AR-RAHN PKB ' . $nama_cawangan . ' : OTP: ' . $random . ' ' . $currentDateTime . '. AR-RAHN CARELINE CENTRE 1300-22-4343';
|
||||
$this->sendWhatsAppMessage($message, $recipient);
|
||||
return response()->json(['otp'=>$random]);
|
||||
return response()->json(['otp' => $random]);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
$random = token(6);
|
||||
|
||||
$otp_baru = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url'). '/api/otp/generateotp/' . $nokp,[
|
||||
$otp_baru = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url') . '/api/otp/generateotp/' . $nokp, [
|
||||
'otptoken' => $random,
|
||||
'expired' => $expired,
|
||||
'kodcaw' => $auth_user['cawangan']
|
||||
@@ -330,23 +547,36 @@ class CustomersController extends Controller
|
||||
// $message = "Your OTP code is " . $random;
|
||||
$message = 'AR-RAHN PKB ' . $nama_cawangan . ' : OTP: ' . $random . ' ' . $currentDateTime . '. AR-RAHN CARELINE CENTRE 1300-22-4343';
|
||||
$this->sendWhatsAppMessage($message, $recipient);
|
||||
return response()->json(['otp'=>$random]);
|
||||
return response()->json(['otp' => $random]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function sendWhatsAppMessage(string $message, string $recipient)
|
||||
{
|
||||
$status = Http::withOptions(['verify' => config('app.api_verify')])->get('http://gateway.onewaysms.com.my:10001/api.aspx',[
|
||||
$status = Http::withOptions(['verify' => config('app.api_verify')])->get('http://gateway.onewaysms.com.my:10001/api.aspx', [
|
||||
'apiusername' => 'APIUK330HDAFO',
|
||||
'apipassword' => 'APIUK330HDAFOUK330',
|
||||
'senderid' => 'INFO',
|
||||
'mobileno' => $recipient,
|
||||
'message'=> $message,
|
||||
'languagetype'=> 1
|
||||
'message' => $message,
|
||||
'languagetype' => 1
|
||||
]);
|
||||
|
||||
return ($status);
|
||||
}
|
||||
|
||||
public function assignAnggota(Request $request)
|
||||
{
|
||||
$noic = $request->noic;
|
||||
|
||||
$response = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->put(config('api.url') . '/api/customers/' . $noic . '/assign-anggota');
|
||||
|
||||
if ($response->successful()) {
|
||||
return redirect()->back()->with('success', 'Pelanggan berjaya ditandakan sebagai anggota koperasi.');
|
||||
} else {
|
||||
return redirect()->back()->with('error', 'Gagal mengemaskini status anggota. Sila cuba semula.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,7 @@ namespace App\Http\Controllers;
|
||||
use App\Events\OperasiNotice;
|
||||
use App\Events\StatusLiked;
|
||||
use App\Events\NotifikasiKelulusan;
|
||||
use App\Events\NotifikasiAnggota;
|
||||
use App\Events\Dashboard\KomoditiNotify;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -25,31 +26,29 @@ class OperasiController extends Controller
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function kelulusan(Request $request){
|
||||
public function kelulusan(Request $request)
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
$api_url = config('api.url');
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/' . $auth_user['cawangan'])->json();
|
||||
|
||||
$kelulusan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/ListOperasi/')->json();
|
||||
|
||||
$arraykelulusan = [];
|
||||
|
||||
|
||||
foreach($kelulusan as $index=>$lulus)
|
||||
{
|
||||
foreach($lulus['kelulusanall'] as $index=>$kel)
|
||||
{
|
||||
array_push($arraykelulusan,["cawangan" => $lulus['cawangan'], "cawangankod" => $lulus['cawangankod'],"namateller" => $kel['teller'], 'siri' => $kel['siri'] , "norujukan" => $kel['norujukan'], 'pinjaman' => $kel['jumpinj'],'komen' => $kel['komen'], 'nilaimarhun' => ($kel['nilaimarhun'] ?? '-'), 'berat' => ($kel['berat'] ?? '-'),'margin' => ($kel['margin'] ?? '-'), 'status' => ($kel['status'] ?? '-'), 'pelulus' => $kel['pelulus']]);
|
||||
foreach ($kelulusan as $index => $lulus) {
|
||||
foreach ($lulus['kelulusanall'] as $index => $kel) {
|
||||
array_push($arraykelulusan, ["cawangan" => $lulus['cawangan'], "cawangankod" => $lulus['cawangankod'], "namateller" => $kel['teller'], 'siri' => $kel['siri'], "norujukan" => $kel['norujukan'], 'pinjaman' => $kel['jumpinj'], 'komen' => $kel['komen'], 'nilaimarhun' => ($kel['nilaimarhun'] ?? '-'), 'berat' => ($kel['berat'] ?? '-'), 'margin' => ($kel['margin'] ?? '-'), 'status' => ($kel['status'] ?? '-'), 'pelulus' => $kel['pelulus']]);
|
||||
}
|
||||
|
||||
foreach($lulus['kelulusanMohonid'] as $index=>$mohon)
|
||||
{
|
||||
array_push($arraykelulusan,["mohonid" => true,"ansuran" => $mohon['ansuran'],"cawangan" => $lulus['cawangan'], "cawangankod" => $lulus['cawangankod'],"namateller" => $mohon['teller'], 'recno' => $mohon['recno'] , "norujukan" => $mohon['norujukan'], 'pinjaman' => $mohon['pinjaman'],'komen' => $mohon['katalaluan'], 'nilaimarhun' => ($mohon['nilaimarhun'] ?? '-'), 'berat' => ($mohon['berat'] ?? '-'),'margin' => ($mohon['margin'] ?? '-'), 'status' => ($mohon['mohon'] ?? '-')]);
|
||||
foreach ($lulus['kelulusanMohonid'] as $index => $mohon) {
|
||||
array_push($arraykelulusan, ["mohonid" => true, "ansuran" => $mohon['ansuran'], "cawangan" => $lulus['cawangan'], "cawangankod" => $lulus['cawangankod'], "namateller" => $mohon['teller'], 'recno' => $mohon['recno'], "norujukan" => $mohon['norujukan'], 'pinjaman' => $mohon['pinjaman'], 'komen' => $mohon['katalaluan'], 'nilaimarhun' => ($mohon['nilaimarhun'] ?? '-'), 'berat' => ($mohon['berat'] ?? '-'), 'margin' => ($mohon['margin'] ?? '-'), 'status' => ($mohon['mohon'] ?? '-')]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return view('operasi.kelulusan',compact('cawangan_info','api_url','arraykelulusan'));
|
||||
return view('operasi.kelulusan', compact('cawangan_info', 'api_url', 'arraykelulusan'));
|
||||
}
|
||||
|
||||
public function getkelulusan(Request $request)
|
||||
@@ -59,16 +58,13 @@ class OperasiController extends Controller
|
||||
|
||||
$norujukan = $request->norujukan;
|
||||
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/' . $auth_user['cawangan'])->json();
|
||||
|
||||
$kelulusan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/SenaraiDahLulus/' . $auth_user['cawangan'] . '/' . $norujukan)->json();
|
||||
|
||||
if(sizeof($kelulusan) > 0)
|
||||
{
|
||||
if (sizeof($kelulusan) > 0) {
|
||||
$kelulusan = $kelulusan[0]['masalulus'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$kelulusan = '';
|
||||
}
|
||||
|
||||
@@ -84,21 +80,20 @@ class OperasiController extends Controller
|
||||
$norujukan = $request->norujukan;
|
||||
|
||||
|
||||
if($request->pembatalan == null)
|
||||
{
|
||||
if(!$request->taglulus){
|
||||
$updatelulus = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/UpdateKelulusanKomen/' . $request->kodcaw . '/' . $norujukan,[
|
||||
if ($request->pembatalan == null) {
|
||||
if (!$request->taglulus) {
|
||||
$updatelulus = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/UpdateKelulusanKomen/' . $request->kodcaw . '/' . $norujukan, [
|
||||
"komen" => $request->komenkelulusan,
|
||||
'siri' => $request->siri
|
||||
])->json();
|
||||
|
||||
$updatelulus = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/UpdateKelulusan/' . $request->kodcaw . '/' . $norujukan,[
|
||||
$updatelulus = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/UpdateKelulusan/' . $request->kodcaw . '/' . $norujukan, [
|
||||
'sahkan' => 1,
|
||||
'namaoperasi' => $request->namaoperasi,
|
||||
'siri' => $request->siri
|
||||
])->json();
|
||||
}else{
|
||||
$updatelulus = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/UpdateHapusAnsuran',[
|
||||
} else {
|
||||
$updatelulus = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/UpdateHapusAnsuran', [
|
||||
'siri' => $request->siri,
|
||||
"kodcaw" => $request->kodcaw,
|
||||
"norujukan" => $request->norujukan,
|
||||
@@ -108,26 +103,23 @@ class OperasiController extends Controller
|
||||
}
|
||||
|
||||
|
||||
if($updatelulus)
|
||||
{
|
||||
event(new NotifikasiKelulusan($norujukan,"lulus",$request->siri,$request->komenkelulusan,$request->teller));
|
||||
if ($updatelulus) {
|
||||
event(new NotifikasiKelulusan($norujukan, "lulus", $request->siri, $request->komenkelulusan, $request->teller));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!$request->taglulus){
|
||||
$updatelulus = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/UpdateKelulusanKomen/' . $request->kodcaw . '/' . $norujukan,[
|
||||
} else {
|
||||
if (!$request->taglulus) {
|
||||
$updatelulus = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/UpdateKelulusanKomen/' . $request->kodcaw . '/' . $norujukan, [
|
||||
"komen" => $request->komenkelulusan,
|
||||
'siri' => $request->siri
|
||||
])->json();
|
||||
|
||||
$updatelulus = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/UpdateKelulusan/' . $request->kodcaw . '/' . $norujukan,[
|
||||
$updatelulus = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/UpdateKelulusan/' . $request->kodcaw . '/' . $norujukan, [
|
||||
'sahkan' => 2,
|
||||
'namaoperasi' => $request->namaoperasi,
|
||||
'siri' => $request->siri
|
||||
])->json();
|
||||
}else{
|
||||
$updatelulus = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/UpdateHapusAnsuran',[
|
||||
} else {
|
||||
$updatelulus = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/UpdateHapusAnsuran', [
|
||||
'siri' => $request->siri,
|
||||
"kodcaw" => $request->kodcaw,
|
||||
"norujukan" => $request->norujukan,
|
||||
@@ -136,18 +128,100 @@ class OperasiController extends Controller
|
||||
])->json();
|
||||
}
|
||||
|
||||
if($updatelulus)
|
||||
{
|
||||
event(new NotifikasiKelulusan($norujukan,"batal",$request->siri,$request->komenkelulusan,$request->teller));
|
||||
if ($updatelulus) {
|
||||
event(new NotifikasiKelulusan($norujukan, "batal", $request->siri, $request->komenkelulusan, $request->teller));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return response()->json($updatelulus,200);
|
||||
return response()->json($updatelulus, 200);
|
||||
}
|
||||
|
||||
public function updatekelulusananggota(Request $request)
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
$api_url = config('api.url');
|
||||
|
||||
// Data asas
|
||||
$nokp = $request->nokp;
|
||||
$kodcaw = $request->kodcaw;
|
||||
$komen = $request->komenkelulusan;
|
||||
$namaoperasi = $request->namaoperasi;
|
||||
$taglulus = $request->taglulus; // contoh: 'Y' = lulus, 'N' = batal
|
||||
|
||||
// 1️⃣ Tentukan status kelulusan
|
||||
$status = ($taglulus == 'Y') ? 1 : 2; // 1 = Lulus, 2 = Batal/Tolak
|
||||
|
||||
try {
|
||||
// 2️⃣ Panggil API baru — ikut route baru dengan {kodcaw}
|
||||
$endpoint = $api_url . '/api/UpdateKelulusanAnggota/' . $kodcaw;
|
||||
|
||||
$payload = [
|
||||
'nokp' => $nokp,
|
||||
'komenkelulusan' => $komen,
|
||||
'namaoperasi' => $namaoperasi,
|
||||
'sahkan' => $status
|
||||
];
|
||||
|
||||
Log::info('Menghantar permintaan ke API UpdateKelulusanAnggota', [
|
||||
'endpoint' => $endpoint,
|
||||
'payload' => $payload
|
||||
]);
|
||||
|
||||
$response = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->put($endpoint, $payload);
|
||||
|
||||
$updatelulus = $response->json();
|
||||
|
||||
// 3️⃣ Log hasil respon API
|
||||
Log::info('Respon dari API UpdateKelulusanAnggota', [
|
||||
'status' => $response->status(),
|
||||
'body' => $updatelulus
|
||||
]);
|
||||
|
||||
// 4️⃣ Jika berjaya, cipta event notifikasi
|
||||
if ($response->successful() && $updatelulus && isset($updatelulus['success']) && $updatelulus['success'] === true) {
|
||||
// $jenis = ($status == 1) ? 'lulus' : 'batal';
|
||||
// event(new NotifikasiAnggota($nokp, $jenis, null, $komen, $namaoperasi));
|
||||
|
||||
$statusText = ($status == 1) ? 'DILULUSKAN' : 'DITOLAK';
|
||||
event(new NotifikasiAnggota($nokp, $statusText, $komen, $namaoperasi));
|
||||
|
||||
|
||||
Log::info('Event NotifikasiAnggota dispatched', [
|
||||
'nokp' => $nokp,
|
||||
'komen' => $komen,
|
||||
'namaoperasi' => $namaoperasi
|
||||
]);
|
||||
} else {
|
||||
Log::warning('Gagal kemas kini kelulusan anggota', [
|
||||
'nokp' => $nokp,
|
||||
'kodcaw' => $kodcaw,
|
||||
'response' => $updatelulus
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json($updatelulus, $response->status());
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Ralat UpdateKelulusanAnggota (frontend)', [
|
||||
'message' => $e->getMessage(),
|
||||
'line' => $e->getLine()
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Ralat semasa menghantar kelulusan anggota.',
|
||||
'error' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function createkelulusan(Request $request)
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
@@ -158,14 +232,13 @@ class OperasiController extends Controller
|
||||
|
||||
$norujukan = $request->norujukan;
|
||||
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/' . $auth_user['cawangan'])->json();
|
||||
|
||||
$getsiri = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/ListLatestLulus/'. $auth_user['cawangan'] . '/' . $norujukan)->json();
|
||||
$getsiri = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/ListLatestLulus/' . $auth_user['cawangan'] . '/' . $norujukan)->json();
|
||||
|
||||
if(isset($getsiri['siri']))
|
||||
{
|
||||
if (isset($getsiri['siri'])) {
|
||||
$siri = $getsiri['siri'] + 1;
|
||||
}else{
|
||||
} else {
|
||||
$siri = 1;
|
||||
}
|
||||
|
||||
@@ -185,57 +258,110 @@ class OperasiController extends Controller
|
||||
|
||||
])->json();
|
||||
|
||||
event(new StatusLiked($auth_user['cawangan'],$auth_user['name']));
|
||||
event(new StatusLiked($auth_user['cawangan'], $auth_user['name']));
|
||||
|
||||
return response()->json($siri,201);
|
||||
return response()->json($siri, 201);
|
||||
}
|
||||
|
||||
|
||||
public function createkelulusanAnggota(Request $request)
|
||||
{
|
||||
try {
|
||||
$auth_user = Auth::user();
|
||||
$api_url = config('api.url');
|
||||
$current = Carbon::now();
|
||||
|
||||
Log::info('createkelulusanAnggota', $request->all());
|
||||
|
||||
// Dapatkan maklumat cawangan
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/cawangan/' . $auth_user['cawangan'])
|
||||
->json();
|
||||
|
||||
// Generate siri baru
|
||||
$getsiri = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->get($api_url . '/api/ListLatestLulus/' . $auth_user['cawangan'] . '/anggota')
|
||||
->json();
|
||||
|
||||
$siri = isset($getsiri['siri']) ? $getsiri['siri'] + 1 : 1;
|
||||
|
||||
// Hantar ke API
|
||||
$createlulus = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->post($api_url . '/api/CreateKelulusanAnggota/' . $auth_user['cawangan'] . '/roles/operasi', [
|
||||
'komen' => $request->komen,
|
||||
'date_mohon' => $current->toDateString(),
|
||||
'siri' => $siri,
|
||||
'nokp' => $request->nokp,
|
||||
'teller' => $request->teller,
|
||||
'peloperasi' => 'operasi'
|
||||
])
|
||||
->json();
|
||||
|
||||
event(new StatusLiked($auth_user['cawangan'], $auth_user['name']));
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Permohonan kelulusan anggota berjaya dihantar.',
|
||||
'siri' => $siri,
|
||||
'data' => $createlulus,
|
||||
], 201);
|
||||
|
||||
Log::info('🛰️ API CreateKelulusanAnggota Response:', [
|
||||
'status' => $response->status(),
|
||||
'body' => $response->body(),
|
||||
]);
|
||||
} catch (\Throwable $th) {
|
||||
Log::error('❌ createkelulusanAnggota error: ' . $th->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => $th->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function mintakatalaluansemula(Request $request)
|
||||
{
|
||||
|
||||
if(Hash::check($request->passsemula, Auth::user()->password))
|
||||
{
|
||||
if (Hash::check($request->passsemula, Auth::user()->password)) {
|
||||
return "True";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function parameter()
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
$api_url = config('api.url');
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/' . $auth_user['cawangan'])->json();
|
||||
|
||||
return view('operasi.parameter',compact('cawangan_info','api_url'));
|
||||
return view('operasi.parameter', compact('cawangan_info', 'api_url'));
|
||||
}
|
||||
|
||||
public function hargaemas()
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
$api_url = config('api.url');
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/' . $auth_user['cawangan'])->json();
|
||||
$harga_emas = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/harga_emas/')->json();
|
||||
|
||||
return view('operasi.hargaemas',compact('cawangan_info','api_url','harga_emas'));
|
||||
return view('operasi.hargaemas', compact('cawangan_info', 'api_url', 'harga_emas'));
|
||||
}
|
||||
|
||||
public function margin(){
|
||||
public function margin()
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
$api_url = config('api.url');
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/' . $auth_user['cawangan'])->json();
|
||||
$margin_pembiayaan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/maxpinjaman')->json();
|
||||
return view('operasi.margin_pembiayaan',compact('cawangan_info','api_url','margin_pembiayaan'));
|
||||
return view('operasi.margin_pembiayaan', compact('cawangan_info', 'api_url', 'margin_pembiayaan'));
|
||||
}
|
||||
|
||||
public function kelulusanrekodlepas()
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
$api_url = config('api.url');
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/' . $auth_user['cawangan'])->json();
|
||||
|
||||
//declare array baru
|
||||
$arraykelulusan = [];
|
||||
@@ -243,29 +369,36 @@ class OperasiController extends Controller
|
||||
$kelulusan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/ListOperasiKelulusan/')->json();
|
||||
|
||||
|
||||
foreach($kelulusan as $index=>$k)
|
||||
{
|
||||
foreach($k['kelulusanall'] as $index1=>$kel)
|
||||
{
|
||||
$komen = explode("|",$kel['komen']);
|
||||
foreach ($kelulusan as $index => $k) {
|
||||
foreach ($k['kelulusanall'] as $index1 => $kel) {
|
||||
$komen = explode("|", $kel['komen']);
|
||||
|
||||
$results=array_search("",$komen,true);
|
||||
if($results !== false) {
|
||||
$results = array_search("", $komen, true);
|
||||
if ($results !== false) {
|
||||
unset($komen[$results]);
|
||||
}
|
||||
|
||||
array_push($arraykelulusan,['norujukan' => $kel['norujukan'], 'pinjaman' => $kel['jumpinj'], 'nilaimarhun' => ($komen[1] ?? $kel['nilaimarhun'] ?? '-'), 'berat' => ($komen[2] ?? $kel['berat'] ?? '-'),'margin' => ($komen[3] ?? $kel['margin'] ?? '-'), 'komen' => ($komen[0] ?? $kel['komen'] ?? '-'), 'status' => ($kel['status'] ?? '-'), 'pelulus' => $kel['operasi'],]);
|
||||
|
||||
array_push($arraykelulusan, ['norujukan' => $kel['norujukan'], 'pinjaman' => $kel['jumpinj'], 'nilaimarhun' => ($komen[1] ?? $kel['nilaimarhun'] ?? '-'), 'berat' => ($komen[2] ?? $kel['berat'] ?? '-'), 'margin' => ($komen[3] ?? $kel['margin'] ?? '-'), 'komen' => ($komen[0] ?? $kel['komen'] ?? '-'), 'status' => ($kel['status'] ?? '-'), 'pelulus' => $kel['operasi'],]);
|
||||
}
|
||||
}
|
||||
|
||||
return view('operasi.rekodtelahlulus',compact('cawangan_info','api_url','arraykelulusan'));
|
||||
|
||||
return view('operasi.rekodtelahlulus', compact('cawangan_info', 'api_url', 'arraykelulusan'));
|
||||
}
|
||||
|
||||
public function notifyKomoditi()
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
event(new KomoditiNotify('lulus',$auth_user['cawangan']));
|
||||
event(new KomoditiNotify('lulus', $auth_user['cawangan']));
|
||||
}
|
||||
|
||||
public function kelulusananggota(Request $request)
|
||||
{
|
||||
$auth_user = Auth::user();
|
||||
$api_url = config('api.url');
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/' . $auth_user['cawangan'])->json();
|
||||
|
||||
$arraykelulusan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/list/approval/anggota')->json();
|
||||
|
||||
return view('operasi.kelulusan_anggota', compact('cawangan_info', 'api_url', 'arraykelulusan'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Imports;
|
||||
|
||||
use App\Anggota;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
|
||||
class AnggotaImport implements ToModel
|
||||
{
|
||||
/**
|
||||
* @param array $row
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Model|null
|
||||
*/
|
||||
public function model(array $row)
|
||||
{
|
||||
return new Anggota([
|
||||
//
|
||||
'noic' => $row['noic'],
|
||||
'nama' => $row['nama'],
|
||||
'status' => $row['status'] ?? 'aktif',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user