Merge remote-tracking branch 'origin/prod-kopkb' into annur-rebate

This commit is contained in:
nurafrinaalimi16
2026-09-01 11:08:05 +08:00
66 changed files with 10790 additions and 4036 deletions
+81
View File
@@ -0,0 +1,81 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
class updateImbangDuga extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'update:imbangduga {--all : all zone} {--1 : update zone 1} {--2 : update zone 2} {--3 : update zone3}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
if($this->option('all')){
$zone = 'all';
}else if($this->option('1')){
$zone = '1';
}else if ($this->option('2')){
$zone = '2';
}else if ($this->option('3')){
$zone = '3';
}
$monthly = Carbon::now();
$monthly = new Carbon();
$previousmonth = $monthly->subMonthsNoOverflow()->endOfMonth();
$tahun = $previousmonth->year;
$month = $previousmonth->month;
$response = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/reports/updateigall',[
'month' => $month,
'year' => $tahun,
]);
if ($response->successful()) {
$data = $response->json();
Log::info('Imbang Duga update successful', [
'month' => $month,
'year' => $tahun,
'data' => $data
]);
$this->info('Imbang Duga update successful');
} else {
Log::error('API error', [
'url' => $response->effectiveUri(),
'status' => $response->status(),
'body' => $response->body()
]);
}
}
}
+36
View File
@@ -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';
}
}
+46
View File
@@ -0,0 +1,46 @@
<?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 $komen;
public $tagoperasi;
public function __construct($nokp, $status, $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,
];
}
}
+3 -2
View File
@@ -11,15 +11,16 @@ class NotifikasiKelulusan implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $norujukan,$kelulusan,$siri,$komen,$teller;
public $norujukan,$kelulusan,$siri,$komen,$teller,$tagoperasi;
public function __construct($norujukan,$kelulusan,$siri,$komen,$teller)
public function __construct($norujukan,$kelulusan,$siri,$komen,$teller,$tagoperasi = null)
{
$this->norujukan = $norujukan;
$this->kelulusan = $kelulusan;
$this->siri = $siri;
$this->komen = $komen;
$this->teller = $teller;
$this->tagoperasi = $tagoperasi;
}
public function broadcastOn()
+490 -39
View File
@@ -308,6 +308,16 @@ class CallCenterController extends Controller
$bycawnotisperingatan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/bycawnotisperingatan/'.$kodcaw.'/'.$notisid)->json();
return view('callcenter.pdfbycawdetailnotisperingatan', compact('cawangan_info','bycawnotisperingatan','kodcaw','notisid','cawangan_detail','tarikh_cetak'));
}
elseif($request->type == 'excel')
{
$current = Carbon::now();
$current = new Carbon();
$tarikh_cetak = $current->toDateString();
$cawangan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/cawangan/detail/'.$kodcaw)->json();
$cawangan_detail=$cawangan[0];
$bycawnotisperingatan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/arcc/bycawnotisperingatan/'.$kodcaw.'/'.$notisid)->json();
return view('callcenter.notisperingatanpertama_excel', compact('cawangan_info','bycawnotisperingatan','kodcaw','notisid','cawangan_detail','tarikh_cetak'));
}
return view('callcenter.bycawdetailnotisperingatan',compact('cawangan_info','bycawnotisperingatan','kodcaw','notisid'));
}
@@ -327,7 +337,23 @@ class CallCenterController extends Controller
}
}
public function search(Request $request){
public function pelanggannew()
{
$search = false;
$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();
$bank = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/bank')->json();
if($auth_user->roles == 'admin'){
return view('admin.customer_index',compact('search','cawangan_info','bank','api_url','idtype','auth_user'));
}else{
return view('callcenter.indexnama',compact('search','cawangan_info','bank','api_url','idtype','auth_user'));
}
}
public function search(Request $request){
// dd($request->all());
$noic = $request->noic;
$idtype = $request->customerIDType;
@@ -355,6 +381,112 @@ class CallCenterController extends Controller
}
}
public function searchnama(Request $request)
{
$noic = $request->noic;
$kodcaw = $request->cawangan;
Session::put('noic', $noic);
Session::put('kodcaw', $kodcaw);
$api_url = config('api.url');
$request->session()->forget('page_reload');
$request->session()->forget('norujukan');
if (empty($noic)) {
return redirect()->route('arcc.pelanggannew')->with('failed', 'Maaf, Tiada Data Pelanggan...');
}
// ======================
// 1️⃣ Kalau isi NOIC sahaja
// ======================
if ($noic && !$kodcaw) {
$customersWithGadai = [];
// Ambil semua cawangan
$cawanganList = Http::withOptions(['verify' => config('app.api_verify')])
->get($api_url . '/api/cawangan')
->json();
if (is_array($cawanganList)) {
foreach ($cawanganList as $caw) {
$kod = $caw['kodcaw'];
// Check customer di cawangan tu
$customer = Http::withOptions(['verify' => config('app.api_verify')])
->get($api_url . '/api/customers/' . $noic, ['kodcaw' => $kod])
->json();
if (!empty($customer)) {
// Check rekod gadai
$nokp = !empty($customer['kpbaru']) ? $customer['kpbaru'] : (!empty($customer['kplama']) ? $customer['kplama'] : $noic);
$gadaiData = Http::withOptions(['verify' => config('app.api_verify')])
->get($api_url . '/arcc/rekodgadai', [
'nokp' => $nokp,
'kodcaw' => $kod
])
->json();
// dump($gadaiData);
if (!empty($gadaiData['data']) && $gadaiData['status'] === true) {
$customersWithGadai[] = [
'nama' => $customer['nama'] ?? '-',
'kpbaru' => $customer['kpbaru'] ?? null,
'kplama' => $customer['kplama'] ?? null,
'customer' => $customer,
'kodcaw' => $kod,
'nama_cawangan' => $caw['details_caw'] ?? $kod,
// 'rekod_gadai' => $gadaiData
];
}
}
}
}
// dd(true);
// Kalau lebih 1 → pilih pelanggan
if (count($customersWithGadai) >= 1) {
Session::put('customer_list', $customersWithGadai);
return redirect()->route('arcc.pilihpelanggan');
}
return redirect()->route('arcc.pelanggannew')->with('failed', 'Maaf, Tiada Data Pelanggan...');
}
// ======================
// 2️⃣ Kalau isi NOIC + Cawangan
// ======================
if ($noic && $kodcaw) {
$customer_info = Http::withOptions(['verify' => config('app.api_verify')])
->get($api_url . '/api/customers/' . $noic, ['kodcaw' => $kodcaw])
->json();
// Check sama ada $customer_info bukan null dan ada data penting seperti 'nama' (atau key lain)
if ($customer_info && !empty($customer_info['nama'])) {
Session::put('customer_info_arcc', $customer_info);
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
->get($api_url . '/api/cawangan/' . $kodcaw)
->json();
return redirect()->route('arcc.customer_info_nama', [
'customer_info' => $customer_info,
'cawangan_info' => $cawangan_info,
'api_url' => $api_url
]);
}
// Jika tiada data pelanggan di cawangan tu
return redirect()->route('arcc.pelanggan')->with('failed', 'Maaf, Tiada Data Pelanggan di cawangan ini.');
}
// Boleh tambah kes lain (Nama sahaja, Nama + Cawangan) kalau nak
}
public function info(Request $request){
$auth_user = Auth::user();
$api_url = config('api.url');
@@ -372,6 +504,54 @@ class CallCenterController extends Controller
return view('callcenter.' . $cawangan_info['version'] . '.info',compact('cawangan_info','api_url','customer_info','bakilelong','rugilelong','negeri'));
}
public function infonama(Request $request)
{
$auth_user = Auth::user();
$api_url = Session::get('api_url_arcc', config('api.url'));
$cawangan_info = Session::get('cawangan_info_arcc');
$customer_info = Session::get('customer_info_arcc');
// Kalau data kosong, fallback panggil API
if (!$cawangan_info) {
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
->get($api_url . '/api/cawangan/' . Session::get('kodcaw'))
->json();
}
if (!$customer_info) {
$customer_info = Http::withOptions(['verify' => config('app.api_verify')])
->get($api_url . '/api/customers/' . Session::get('noic'))
->json();
$customer_info = $response['data'] ?? [];
}
$bakilelong = Http::withOptions(['verify' => config('app.api_verify')])
->get($api_url . '/api/bakilelong/cawangan/' . Session::get('kodcaw') . '/' . Session::get('noic') . '/baki')
->json();
$rugilelong = Http::withOptions(['verify' => config('app.api_verify')])
->get($api_url . '/api/bakilelong/cawangan/' . Session::get('kodcaw') . '/' . Session::get('noic') . '/rugi')
->json();
$negeri = Http::withOptions(['verify' => config('app.api_verify')])
->get($api_url . '/api/negeri/')
->json();
$request->session()->forget('page_reload');
$request->session()->forget('norujukan');
return view('callcenter.' . $cawangan_info['version'] . '.info', compact(
'cawangan_info',
'api_url',
'customer_info',
'bakilelong',
'rugilelong',
'negeri'
));
}
public function notisperingatankedua(Request $request){
$auth_user = Auth::user();
$api_url = config('api.url');
@@ -831,50 +1011,83 @@ class CallCenterController extends Controller
{
$auth_user = Auth::user();
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $request->norujukan)->json();
$norujukan = $request->norujukan;
$gadai = Http::withOptions(['verify' => config('app.api_verify')])
->get(config('api.url') . '/api/gadai/norujukan/' . $norujukan)
->json();
if(sizeof($gadai) > 0)
{
$history = $gadai[0][0]['historygadaian'];
$dahtebus = $gadai[0][0]['sttebus'];
$norujukan = $gadai[0][0]['norujukan'];
}
$count = 0;
$arrayhist = [];
while($history != "0" && $history != '' || $dahtebus == 'T')
{
if($history != "0" && $history != '')
{
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $history)->json();
$tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/listpenebusanhistory/'. $gadai[0][0]['kodcaw'],[
"norujukan" => $history
])->json();
if (sizeof($gadai) > 0) {
$history = $gadai[0][0]['historygadaian'];
$dahtebus = $gadai[0][0]['sttebus'];
$kodcaw = $gadai[0][0]['kodcaw'];
// Kalau belum ada history, ambil rekod asal sahaja
if ($dahtebus == 'T') {
$tebusList = Http::withOptions(['verify' => config('app.api_verify')])
->get(config('api.url') . '/api/listpenebusanhistory/' . $kodcaw, [
'norujukan' => $norujukan
])
->json();
if(sizeof($gadai) > 0)
{
if($history == $gadai[0][0]['historygadaian'])
$history = 0;
else{
array_push($arrayhist,["tagbaru" => ((isset($gadai[0][0]['tagbaru'])) ? $gadai[0][0]['tagbaru'] : 0),"hargajualan" => ((isset($gadai[0][0]['hargajualan'])) ? $gadai[0][0]['hargajualan'] : ''), "pinjaman" => ((isset($tebus[0])) ? $tebus[0]['pinjaman'] : 0),"norujukan" => $history,"jenistebus" => ((isset($tebus[0])) ? $tebus[0]['jenistebus'] : 0),"jbg" => ((isset($tebus[0])) ? $tebus[0]['jbg'] : 0),"t_tebus" => ((isset($tebus[0])) ? $tebus[0]['t_tebus'] : 0)]);
$history = $gadai[0][0]['historygadaian'];
$tebus = collect($tebusList)->firstWhere('norujukan', $norujukan);
$arrayhist[] = [
"tagbaru" => $gadai[0][0]['tagbaru'] ?? 0,
"hargajualan" => $gadai[0][0]['hargajualan'] ?? '',
"pinjaman" => $tebus['pinjaman'] ?? 0,
"norujukan" => $norujukan,
"jenistebus" => $tebus['jenistebus'] ?? 0,
"jbg" => $tebus['jbg'] ?? 0,
"t_tebus" => $tebus['t_tebus'] ?? 0,
"bayaran_keuntungan" => $tebus['bayaran_keuntungan'] ?? 0,
"bayaran_pembiayaan" => $tebus['bayaran_pembiayaan'] ?? 0,
"duit_masuk" => $tebus['duit_masuk'] ?? 0,
"trans_type" => $tebus['trans_type'] ?? 0,
];
} else {
// Loop ke belakang (rekod lepas-lepas)
while ($history != "0" && $history != '') {
$prevGadai = Http::withOptions(['verify' => config('app.api_verify')])
->get(config('api.url') . '/api/gadai/norujukan/' . $history)
->json();
$prevKodcaw = $prevGadai[0][0]['kodcaw'] ?? null;
if (!$prevKodcaw) break;
$tebusList = Http::withOptions(['verify' => config('app.api_verify')])
->get(config('api.url') . '/api/listpenebusanhistory/' . $prevKodcaw, [
'norujukan' => $history
])
->json();
$tebus = collect($tebusList)->firstWhere('norujukan', $history);
$arrayhist[] = [
"tagbaru" => $prevGadai[0][0]['tagbaru'] ?? 0,
"hargajualan" => $prevGadai[0][0]['hargajualan'] ?? '',
"pinjaman" => $tebus['pinjaman'] ?? 0,
"norujukan" => $history,
"jenistebus" => $tebus['jenistebus'] ?? 0,
"jbg" => $tebus['jbg'] ?? 0,
"t_tebus" => $tebus['t_tebus'] ?? 0,
"bayaran_keuntungan" => $tebus['bayaran_keuntungan'] ?? 0,
"bayaran_pembiayaan" => $tebus['bayaran_pembiayaan'] ?? 0,
"duit_masuk" => $tebus['duit_masuk'] ?? 0,
"trans_type" => $tebus['trans_type'] ?? 0,
];
$nextHistory = $prevGadai[0][0]['historygadaian'] ?? '0';
// Elakkan infinite loop
if ($nextHistory == $history) {
break;
}
$history = $nextHistory;
}
$count++;
}
else{
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $norujukan)->json();
$tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/listpenebusanhistory/'. $gadai[0][0]['kodcaw'],[
"norujukan" => $norujukan
])->json();
array_push($arrayhist,["tagbaru" => ((isset($gadai[0][0]['tagbaru'])) ? $gadai[0][0]['tagbaru'] : 0), "hargajualan" => ((isset($gadai[0][0]['hargajualan'])) ? $gadai[0][0]['hargajualan'] : ''),"pinjaman" => ((isset($tebus[0])) ? $tebus[0]['pinjaman'] : 0),"norujukan" => $norujukan,"jenistebus" => ((isset($tebus[0])) ? $tebus[0]['jenistebus'] : 0),"jbg" => ((isset($tebus[0])) ? $tebus[0]['jbg'] : 0),"t_tebus" => ((isset($tebus[0])) ? $tebus[0]['t_tebus'] : 0)]);
break;
}
}
@@ -923,4 +1136,242 @@ class CallCenterController extends Controller
$pertambahpinjaman = 0.80;
return view('callcenter.' . $cawangan_info['version'] . '.index',compact('cawangan_info','api_url','gadai','marhun','nama','nilaihargasemasa','pertambahpinjaman'));
}
public function pilihPelanggan()
{
if (!Session::has('customer_list')) {
return redirect()->route('arcc.pelanggan')->with('failed', 'Tiada pelanggan untuk dipilih.');
}
$kodcaw = Session::get('kodcaw'); // Ambil dari sesi
$cawangan_info = null;
// Kalau kodcaw ada, baru ambil cawangan_info
if ($kodcaw) {
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
->get(config('api.url') . '/api/cawangan/' . $kodcaw)
->json();
// dd($cawangan_info );
}
return view('callcenter.pilihpelanggan', compact('cawangan_info'));
}
public function pilihPelangganProceed(Request $request)
{
$customerData = $request->input('customer');
$kodcaw = $request->input('kodcaw');
if ($customerData) {
$customer = json_decode(base64_decode($customerData), true);
// Merge data penuh supaya flat & senang guna di Blade
$customer_info = array_merge(
$customer['customer'] ?? $customer, // kalau ada sub-array 'customer', ambil dia
[
'kodcaw' => $customer['kodcaw'] ?? $kodcaw,
'nama_cawangan' => $customer['nama_cawangan'] ?? '',
]
);
// Simpan dalam session
Session::put('customer_info_arcc', $customer_info);
Session::put('kodcaw', $kodcaw);
Session::put('noic', $customer_info['kpbaru'] ?? $customer_info['kplama']);
$api_url = config('api.url');
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
->get($api_url . '/api/cawangan/' . $kodcaw)->json();
// Simpan juga dalam session
Session::put('cawangan_info_arcc', $cawangan_info);
Session::put('api_url_arcc', $api_url);
return redirect()->route('arcc.customer_info');
}
return redirect()->route('arcc.pelanggan')->with('failed', 'Pelanggan tidak sah dipilih.');
}
public function ajaxSearchCustomer(Request $request)
{
$search = strtolower($request->query('search', ''));
$customers = collect(session('customer_list', []))
->filter(function ($customer) use ($search) {
return strpos(strtolower($customer['nama']), $search) !== false ||
strpos(strtolower($customer['nokp']), $search) !== false;
});
return view('callcenter.partials.customertable', ['customers' => $customers])->render();
}
public function cariannama(Request $request)
{
$nama = $request->nama;
$api_url = config('api.url');
if (empty($nama)) {
return redirect()->route('arcc.pelanggan')->with('failed', 'Maaf, Tiada Data Pelanggan...');
}
session(['last_search' => $request->all()]);
// Clear session lama
$request->session()->forget(['page_reload', 'norujukan']);
// 1. Call API carian nama
$customers = Http::withOptions(['verify' => config('app.api_verify')])
->get($api_url . '/api/customers', ['nama' => $nama])
->json();
if (!is_array($customers) || empty($customers)) {
return redirect()->route('arcc.pelanggannew')->with('failed', 'Tiada pelanggan dijumpai.');
}
// 2. Ambil senarai cawangan
$cawanganList = Http::withOptions(['verify' => config('app.api_verify')])
->get($api_url . '/api/cawangan')
->json();
if (!is_array($cawanganList) || empty($cawanganList)) {
return redirect()->route('arcc.pelanggan')->with('failed', 'Tiada senarai cawangan.');
}
// 3. Kumpul semua IC (kpbaru / kplama) dari senarai customer
$nokpList = collect($customers)
->map(function ($customer) {
return $customer['kpbaru'] ?? $customer['kplama'] ?? null;
})
->filter()
->unique()
->values()
->toArray();
$customersWithGadai = collect();
foreach ($cawanganList as $caw) {
$kod = $caw['kodcaw'];
$response = Http::withOptions(['verify' => config('app.api_verify')])
->post($api_url . '/arcc/rekodgadai-batch', [
'nokp_list' => $nokpList,
'kodcaw' => $kod
]);
if ($response->failed()) {
continue;
}
$data = $response->json();
if (!empty($data['data']) && is_array($data['data'])) {
foreach ($data['data'] as $rekod) {
$customer = collect($customers)->first(function ($c) use ($rekod) {
return ($c['kpbaru'] ?? $c['kplama']) === $rekod['nokp'];
});
if ($customer) {
$customersWithGadai->put(
$customer['kpbaru'] ?? $customer['kplama'], // guna IC as key
[
'nama' => $customer['nama'] ?? '-',
'kpbaru' => $customer['kpbaru'] ?? null,
'kplama' => $customer['kplama'] ?? null,
'customer' => $customer,
'kodcaw' => $kod,
'nama_cawangan' => $caw['details_caw'] ?? $kod
]
);
}
}
}
}
$customersWithGadai = $customersWithGadai
->sortBy('nama') // sort ikut nama A→Z
->values(); // reset key semula
// 5. Return ikut result
if ($customersWithGadai->count() > 1) {
Session::put('customer_list', $customersWithGadai);
return redirect()->route('arcc.pilihpelanggannama');
} elseif ($customersWithGadai->count() === 1) {
$singleCustomer = $customersWithGadai->first();
Session::put('customer_info_arcc', $singleCustomer['customer']);
return redirect()->route('arcc.customer_info', [
'customer_info' => $singleCustomer['customer'],
'cawangan_info' => [
'kodcaw' => $singleCustomer['kodcaw'],
'nama_cawangan' => $singleCustomer['nama_cawangan']
],
'api_url' => $api_url
]);
}
return redirect()->route('arcc.pelanggannew')->with('failed', 'Tiada pelanggan dengan rekod gadai.');
}
public function pilihPelanggannama()
{
if (!Session::has('customer_list')) {
return redirect()->route('arcc.pelanggan')->with('failed', 'Tiada pelanggan untuk dipilih.');
}
$kodcaw = Session::get('kodcaw'); // Ambil dari sesi
$cawangan_info = null;
// Kalau kodcaw ada, baru ambil cawangan_info
if ($kodcaw) {
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
->get(config('api.url') . '/api/cawangan/' . $kodcaw)
->json();
// dd($cawangan_info );
}
return view('callcenter.pilihpelanggannama', compact('cawangan_info'));
}
public function pilihPelangganProceednama(Request $request)
{
$customerData = $request->input('customer');
$kodcaw = $request->input('kodcaw');
if ($customerData) {
$customer = json_decode(base64_decode($customerData), true);
// Merge data penuh supaya flat & senang guna di Blade
$customer_info = array_merge(
$customer['customer'] ?? $customer, // kalau ada sub-array 'customer', ambil dia
[
'kodcaw' => $customer['kodcaw'] ?? $kodcaw,
'nama_cawangan' => $customer['nama_cawangan'] ?? '',
]
);
// Simpan dalam session
Session::put('customer_info_arcc', $customer_info);
Session::put('kodcaw', $kodcaw);
Session::put('noic', $customer_info['kpbaru'] ?? $customer_info['kplama']);
$api_url = config('api.url');
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])
->get($api_url . '/api/cawangan/' . $kodcaw)->json();
// Simpan juga dalam session
Session::put('cawangan_info_arcc', $cawangan_info);
Session::put('api_url_arcc', $api_url);
return redirect()->route('arcc.customer_info');
}
return redirect()->route('arcc.pelanggan')->with('failed', 'Pelanggan tidak sah dipilih.');
}
}
+335 -105
View File
@@ -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,80 +39,241 @@ 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';
// Logik papar butang "Assign sebagai Anggota"
$showAssignAnggotaBtn = false;
$noic = Session::get('noic');
if($request->tebus_auto_tawarruq_berjaya === 'true'){
if (!empty($customer_info)) {
$anggota_info = Http::withOptions(['verify' => config('app.api_verify')])
->get($api_url . '/api/customer/anggota', [
'noic' => $noic
])
->json();
$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;
}
}
$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'));
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,
// ]);
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'
));
}
}
@@ -119,9 +281,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);
@@ -145,60 +307,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,
@@ -220,60 +380,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,
'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']
@@ -281,12 +498,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']
@@ -294,17 +511,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']
@@ -312,12 +529,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']
@@ -325,23 +542,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
@@ -0,0 +1,63 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Services\CustomerService;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Auth;
use Carbon\Carbon;
use PDO;
class HapusAnsuranController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function createApproval(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();
$norujukan = $request->norujukan;
$komen = $request->komen;
$marg = $request->margin;
$ber = $request->berat;
$nm = $request->nilaimarhun;
$status = $request->status;
$jumpinjam = $request->jumpinjam;
$teller = $request->teller;
$ansuran = $request->ansuran;
// Get the approval data
$approvalData = Http::withOptions(['verify' => config('app.api_verify')])
->get($api_url . '/api/hapusansuran/create', [
'cawangan' => $auth_user['cawangan'],
"norujukan" => $norujukan,
"komen" => $komen,
"margin" => $marg,
"berat" => $ber,
"nilaimarhun" => $nm,
"status" => $status,
"jumpinjam" => $jumpinjam,
"teller" => $teller,
"ansuran" => $ansuran,
])
->json();
if (isset($approvalData['status']) && $approvalData['status'] === 'success') {
Session::flash('success', 'Kelulusan berjaya dibuat.');
return redirect()->route('operasi.kelulusan');
} else {
Session::flash('error', 'Gagal membuat kelulusan. Sila cuba lagi.');
return redirect()->back();
}
}
}
+152 -19
View File
@@ -13,6 +13,7 @@ use App\Events\NotifikasiKelulusan;
use App\Events\NotifikasiUbahHapus;
use App\Events\NotifikasiAGH;
use App\Events\NotifikasiPetiBesi;
use App\Events\AutoSerahan;
use App\User;
use App\Cawangan;
@@ -215,7 +216,11 @@ class KhazanahController extends Controller
$denominasi=$denominasi[0];
}
return view('khazanah.pendahuluanserahanmain',compact('cawangan_info','listgldetail','denominasi'));
$proses = Http::withOptions(['verify' => config('app.api_verify')])->get( config('api.url_koop') .'/api/autoserahan/checkapproval',[
'pc_name' => $auth_user['name']
])->json();
return view('khazanah.pendahuluanserahanmain',compact('cawangan_info','listgldetail','denominasi','proses'));
}
@@ -570,15 +575,9 @@ class KhazanahController extends Controller
{
$auth_user = Auth::user();
$api_url = config('api.url');
$norujukan = $request->norujukan;
$pelulus = $request->pelulus;
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
$getlulus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/GetLulus/'. $auth_user['cawangan'],['norujukan' => $norujukan])->json();
if($request->khazanah != null)
{
if($request->batal != null)
@@ -587,22 +586,32 @@ class KhazanahController extends Controller
$updatelulus = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/UpdateKelulusan/kepohonan/' . $auth_user['cawangan'] . '/' . $norujukan,[
"pembatalan" => $request->batal,
"komen" => $request->komenubahhapus,
"khazanah" => $request->khazanah
"khazanah" => $request->khazanah,
"recno" => isset($request->recno) ? $request->recno : null,
])->json();
if($updatelulus)
{
event(new NotifikasiUbahHapus($norujukan,"batal",$request->komenubahhapus,$request->teller));
if(isset($request->tagoperasi) && $request->tagoperasi == 1){
event(new NotifikasiKelulusan($norujukan,"batal",$request->recno,$request->komenubahhapus,$request->teller));
}else{
event(new NotifikasiUbahHapus($norujukan,"batal",$request->komenubahhapus,$request->teller));
}
}
}else{
$updatelulus = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/UpdateKelulusan/kepohonan/' . $auth_user['cawangan'] . '/' . $norujukan,[
"khazanah" => $request->khazanah
"khazanah" => $request->khazanah,
"recno" => isset($request->recno) ? $request->recno : null,
])->json();
if($updatelulus)
{
event(new NotifikasiUbahHapus($norujukan,"lulus","tiada",$request->teller));
if(isset($request->tagoperasi) && $request->tagoperasi == 1){
event(new NotifikasiKelulusan($norujukan,"lulus",$request->recno,$request->komenubahhapus,$request->teller,1));
}else{
event(new NotifikasiUbahHapus($norujukan,"lulus","tiada",$request->teller));
}
}
}
}
@@ -3072,7 +3081,9 @@ class KhazanahController extends Controller
$cawangan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/cawangan/detail/'.$auth_user['cawangan'])->json();
$cawangan_detail=$cawangan[0];
return view('print.laporan_pendahuluanserahan', compact('pendser','cawangan_detail','tarikh_cetak','mula_date','hingga_date','api_url'));
$jenisLaporan = $request->radpendser;
return view('print.laporan_pendahuluanserahan', compact('pendser','cawangan_detail','tarikh_cetak','mula_date','hingga_date','api_url','jenisLaporan'));
}
public function laporanDenominasi()
@@ -4117,9 +4128,13 @@ class KhazanahController extends Controller
if($request->radaktif === 'aktif')
{
$stokaudit = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/api/stokauditkhas/aktif/'. $auth_user['cawangan'],
// $stokaudit = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/api/stokauditkhas/aktif/'. $auth_user['cawangan'],
$stokaudit = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/api/stokauditkhasbynorujukan/aktif/'. $auth_user['cawangan'],
['daritempoh' => $daritempoh, 'hinggatempoh' => $hinggatempoh])->json();
return view('print.laporan_stokauditkhas', compact('stokaudit','cawangan_detail','tarikh_cetak','daritempoh','hinggatempoh','api_url','cawangan_info'));
$stokaudit = collect($stokaudit)->sortByDesc('norujukan')->values()->all();
// dd($stokaudit);
// return view('print.laporan_stokauditkhas', compact('stokaudit','cawangan_detail','tarikh_cetak','daritempoh','hinggatempoh','api_url','cawangan_info'));
return view('print.laporan_stokauditkhasbysag', compact('stokaudit','cawangan_detail','tarikh_cetak','daritempoh','hinggatempoh','api_url','cawangan_info'));
}
}
@@ -4137,11 +4152,13 @@ class KhazanahController extends Controller
$cawangan=Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url').'/api/cawangan/detail/'.$auth_user['cawangan'])->json();
$cawangan_detail=$cawangan[0];
$stokaudit = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/api/stokauditkhas/aktif/'. $auth_user['cawangan'],['daritempoh' => $daritempoh, 'hinggatempoh' => $hinggatempoh])->json();
// $stokaudit = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/api/stokauditkhas/aktif/'. $auth_user['cawangan'],['daritempoh' => $daritempoh, 'hinggatempoh' => $hinggatempoh])->json();
$stokaudit = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/api/stokauditkhasbynorujukan/aktif/'. $auth_user['cawangan'],['daritempoh' => $daritempoh, 'hinggatempoh' => $hinggatempoh])->json();
$stokaudit = collect($stokaudit)->sortByDesc('norujukan')->values()->all();
if($request->type == 'excel')
{
return view('excel.excel_stokauditkhas', compact('stokaudit','cawangan_detail','tarikh_cetak','daritempoh','hinggatempoh','api_url','cawangan_info'));
// return view('excel.excel_stokauditkhas', compact('stokaudit','cawangan_detail','tarikh_cetak','daritempoh','hinggatempoh','api_url','cawangan_info'));
return view('excel.excel_stokauditkhasbysag', compact('stokaudit','cawangan_detail','tarikh_cetak','daritempoh','hinggatempoh','api_url','cawangan_info'));
}
elseif($request->type == 'whatsapp')
{
@@ -4160,8 +4177,11 @@ class KhazanahController extends Controller
}
else
{
$stokaudit = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/api/stokauditkhas/aktif/'. $auth_user['cawangan'],['daritempoh' => $daritempoh, 'hinggatempoh' => $hinggatempoh])->json();
return view('pdf.pdf_stokauditkhas', compact('stokaudit','cawangan_detail','tarikh_cetak','daritempoh','hinggatempoh','api_url','cawangan_info'));
// $stokaudit = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/api/stokauditkhas/aktif/'. $auth_user['cawangan'],['daritempoh' => $daritempoh, 'hinggatempoh' => $hinggatempoh])->json();
$stokaudit = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/api/stokauditkhasbynorujukan/aktif/'. $auth_user['cawangan'],['daritempoh' => $daritempoh, 'hinggatempoh' => $hinggatempoh])->json();
$stokaudit = collect($stokaudit)->sortByDesc('norujukan')->values()->all();
// return view('pdf.pdf_stokauditkhas', compact('stokaudit','cawangan_detail','tarikh_cetak','daritempoh','hinggatempoh','api_url','cawangan_info'));
return view('pdf.pdf_stokauditkhasbysag', compact('stokaudit','cawangan_detail','tarikh_cetak','daritempoh','hinggatempoh','api_url','cawangan_info'));
}
}
@@ -4291,4 +4311,117 @@ class KhazanahController extends Controller
$val = preg_replace('/\.(?=.*\.)/', '', $val);
return floatval($val);
}
public function AutoSerahan(Request $request)
{
if(isset($request->do_delete) && $request->do_delete == true){
$teller = $request->teller;
if ($teller !== html_entity_decode($teller, ENT_QUOTES | ENT_HTML5, 'UTF-8'))
$teller = html_entity_decode($teller, ENT_QUOTES | ENT_HTML5, 'UTF-8');
$call_approval_v3 = Http::withOptions(['verify' => config('app.api_verify')])
->post(config('api.url_koop') . '/api/autoserahan/delete', [
'recno' => $request->recno,
'version' => 'v3',
'kodcaw' => $request->kodcaw,
'teller' => $teller,
'amaun' => $request->amaun,
])->json();
return response()->json([
'status' => 'success',
'message' => 'Approval process completed successfully',
'id' => $call_approval_v3['id'],
]);
}
$teller = $request->arraysend['teller'];
if ($teller !== html_entity_decode($teller, ENT_QUOTES | ENT_HTML5, 'UTF-8'))
$teller = html_entity_decode($teller, ENT_QUOTES | ENT_HTML5, 'UTF-8');
// 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' => $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',
'action' => 'create',
'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' => $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();
$call_set_approval_v3 = Http::withOptions(['verify' => config('app.api_verify')])
->put(config('api.url_koop') . '/api/autoserahan/setapproval', [
'jenis' => 'create',
'id' => $call_approval_v3['id'],
'deno_id' => $call_approval_v2['denoid']
])->json();
// Step 3: Check if both API v3 and API v2 were successful
if ($call_approval_v2['status'] === 'success' && $call_approval_v3['status'] === 'success' && $call_set_approval_v3['status'] === 'success') {
event(new AutoSerahan("Operasi",$call_approval_v3['id'],$request->arraysend['kodcaw'],$teller));
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);
}
}
}
+238 -78
View File
@@ -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;
@@ -16,6 +17,7 @@ use Illuminate\Support\Facades\Hash;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
class OperasiController extends Controller
{
@@ -24,26 +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'] ?? '-')]);
}
}
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)
@@ -53,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 = '';
}
@@ -78,49 +80,148 @@ class OperasiController extends Controller
$norujukan = $request->norujukan;
if($request->pembatalan == null)
{
$updatelulus = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/UpdateKelulusanKomen/' . $request->kodcaw . '/' . $norujukan,[
"komen" => $request->komenkelulusan,
'siri' => $request->siri
])->json();
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,[
'sahkan' => 1,
'namaoperasi' => $request->namaoperasi,
'siri' => $request->siri
])->json();
if($updatelulus)
{
event(new NotifikasiKelulusan($norujukan,"lulus",$request->siri,$request->komenkelulusan,$request->teller));
$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', [
'siri' => $request->siri,
"kodcaw" => $request->kodcaw,
"norujukan" => $request->norujukan,
'namaoperasi' => $request->namaoperasi,
'sahkan' => 1,
])->json();
}
}
else
{
$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,[
'sahkan' => 2,
'namaoperasi' => $request->namaoperasi,
'siri' => $request->siri
])->json();
if($updatelulus)
{
event(new NotifikasiKelulusan($norujukan,"batal",$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, [
"komen" => $request->komenkelulusan,
'siri' => $request->siri
])->json();
$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', [
'siri' => $request->siri,
"kodcaw" => $request->kodcaw,
"norujukan" => $request->norujukan,
'namaoperasi' => $request->namaoperasi,
'sahkan' => 2,
])->json();
}
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();
@@ -131,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;
}
@@ -158,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 = [];
@@ -216,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'));
}
}
+24
View File
@@ -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',
]);
}
}
+6 -1
View File
@@ -287,7 +287,12 @@ class ImbangdugaServices
foreach($response as $variable=>$res)
{
if($variable !== 'recno' && $variable !== 'kodcaw' && $variable !== 'tarikh' && $variable !== 'totalharta' && $variable !== 'totaltanggungan' && $variable !== 'tagtally' && $variable !== 'created_at' && $variable !== 'updated_at'){
$imbangdugadata = ImbangDuga::orderBy('glcode')->where('variable',$variable)->orWhere('single_var',$variable)->first()->toArray();
//$imbangdugadata = ImbangDuga::orderBy('glcode')->where('variable',$variable)->orWhere('single_var',$variable)->first()->toArray();
if($variable == 'bakilelong'){
$imbangdugadata = ImbangDuga::orderBy('glcode')->where([['single_var',$variable],['variable',$variable]])->first()->toArray();
}else{
$imbangdugadata = ImbangDuga::orderBy('glcode')->where('variable',$variable)->orWhere('single_var',$variable)->first()->toArray();
}
if($imbangdugadata['jenis'] == 'harta'){
array_push($array_harta,['glcode' => $imbangdugadata['glcode'],'descpt' => $imbangdugadata['descpt'],'amaun' => $res]);
}else{
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class AutoSerah extends Component
{
/**
* Create a new component instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\View\View|string
*/
public function render()
{
return view('components.auto-serah');
}
}