From 3b44cec5a2e503ac38cbd631e4d196f6f1b45d89 Mon Sep 17 00:00:00 2001 From: Ain Izazi Date: Mon, 25 Aug 2025 09:40:16 +0800 Subject: [PATCH] add di function customer nota arcc --- app/Http/Controllers/CallCenterController.php | 75 ++++++++++++++++++- app/Http/Controllers/CustomerController.php | 20 +++++ ...120937_add_nota_arcc_to_customer_table.php | 32 ++++++++ routes/web.php | 6 +- 4 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2025_08_10_120937_add_nota_arcc_to_customer_table.php diff --git a/app/Http/Controllers/CallCenterController.php b/app/Http/Controllers/CallCenterController.php index 543ea2d..4a8d890 100644 --- a/app/Http/Controllers/CallCenterController.php +++ b/app/Http/Controllers/CallCenterController.php @@ -1649,4 +1649,77 @@ class CallCenterController extends Controller -} + + public function customerUpdate($nokp,Request $request){ + $poskod = Poskod::on('mysql7')->where('poskod','=',$request->poskod)->first(); + $customer_update = Customer::on('mysql7') + ->where('kplama','=',$nokp) + ->orWhere('kpbaru','=',$nokp) + ->update(array( + 'nota_arcc'=>$request->nota_arcc, + )); + + return response()->json($customer_update, 200); + } + + + public function customerUpdateKaunter($nokp,$kodcaw, Request $request){ + $current = Carbon::now(); + + DB::connection('mysql7')->beginTransaction(); + + try{ + $poskod = Poskod::on('mysql7')->where('poskod','=',$request->poskod)->first(); + + $customer_info = DB::connection('mysql7')->table('customer') + ->select('kodcaw','kodkerja','nota_pekerjaan','nota_arcc','tarikhdaftar','nopelanggan','kpbaru','kplama','nama','t_lahir','jantina','poskod') + ->where('kplama','=',$nokp) + ->orWhere('kpbaru','=',$nokp) + ->get()->toArray(); + + + $old_data = json_encode($customer_info); + + $customer_update = Customer::on('mysql7') + ->where('kplama','=',$nokp) + ->orWhere('kpbaru','=',$nokp) + ->update(array( + 'nota_arcc' => $request->nota_arcc, + )); + + if($customer_update) + { + $customer_info_new = DB::connection('mysql7')->table('customer') + ->select('kodcaw','kodkerja','nota_pekerjaan','nota_arcc','tarikhdaftar','nopelanggan','kpbaru','kplama','nama','t_lahir','jantina','alamat1','poskod') + ->where('kplama','=',$nokp) + ->orWhere('kpbaru','=',$nokp) + ->get()->toArray(); + + $new_data = json_encode($customer_info_new); + + $audit_customer = DB::connection('mysql7') + ->table('audit_customer') + ->insert([ + 'username' => $request->namateller, + 'old_data' => $old_data, + 'new_data' => $new_data, + 'kodcaw' => $customer_info[0]->kodcaw, + 'created_at' => Carbon::now()->toDateTimeString(), + 'updated_at' => Carbon::now()->toDateTimeString(), + 'customer_name' => $customer_info[0]->nama, + 'customer_nokp' => $nokp, + ]); + } + + DB::connection('mysql7')->commit(); + + return response()->json($customer_update, 200); + + }catch (\Exception $e) { + DB::connection('mysql7')->rollback(); + return response()->json($e->getMessage(),400); + + } + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php index 46c1ae3..6080cac 100644 --- a/app/Http/Controllers/CustomerController.php +++ b/app/Http/Controllers/CustomerController.php @@ -362,6 +362,7 @@ class CustomerController extends Controller 'nota'=>$request->nota, 'kodkerja'=>$request->kodkerja, 'nota_pekerjaan'=>$request->nota_pekerjaan, + // 'nota_arcc'=>$request->nota_arcc, 'tujuangadai'=>$request->tujuangadai ]); @@ -390,6 +391,7 @@ class CustomerController extends Controller 'kodnegeri' => $poskod['kodnegeri'], 'kodkerja'=>$request->kodkerja, 'nota_pekerjaan'=>$request->nota_pekerjaan, + // 'nota_arcc'=>$request->nota_arcc, 'telefon' => $request->telefon1, 'telefon2' => $request->telefon2 )); @@ -424,6 +426,7 @@ class CustomerController extends Controller 'kodkerja' => $request->kodkerja, // 'nota_pekerjaan' => $request->nota_pekerjaan, 'nota_pekerjaan' => $request->kodkerja === '6' ? $request->nota_pekerjaan : null, + // 'nota_arcc' => $request->nota_arcc, 'noakaun' => $request->noakaun, 'nota' => $request->nota, 'alamat1' => $request->alamat, @@ -501,6 +504,7 @@ class CustomerController extends Controller 'kodbank' => $request->kodbank, 'kodkerja' => $request->kodkerja, 'nota_pekerjaan' => $request->nota_pekerjaan, + // 'nota_arcc' => $request->nota_arcc, 'noakaun' => $request->noakaun, 'nota' => $request->nota, 'nama' => $request->nama, @@ -999,4 +1003,20 @@ class CustomerController extends Controller return response()->json($results); } +// public function createNotaArcc($kodcaw, Request $request) +// { +// $current = Carbon::now(); + +// $customer = Customer::on('mysql7')->create([ +// 'kodcaw' => $kodcaw, +// 'tarikhdaftar' => $current->toDateString(), +// 'nota_arcc' => $request->nota_arcc, +// 'teller' => $request->teller, +// 'aktif' => 'A' +// ]); + +// return response()->json($customer, 201); +// } + + } diff --git a/database/migrations/2025_08_10_120937_add_nota_arcc_to_customer_table.php b/database/migrations/2025_08_10_120937_add_nota_arcc_to_customer_table.php new file mode 100644 index 0000000..b61c531 --- /dev/null +++ b/database/migrations/2025_08_10_120937_add_nota_arcc_to_customer_table.php @@ -0,0 +1,32 @@ +string('nota_arcc')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('customer', function (Blueprint $table) { + $table->dropColumn('nota_arcc'); + }); + } +} diff --git a/routes/web.php b/routes/web.php index fb4d452..d826ac1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -63,7 +63,11 @@ $router->group(['prefix'=>'api'], function () use ($router){ //arcc $router->get('customer/searchbyname',['uses'=>'CustomerController@searchByName']); // Route::get('/api/customers/searchbyname', [CustomerController::class, 'searchByName']); - + // $router->put('customers/update/{nokp}', ['uses' => 'CallCenterController@customerUpdate']); //kena tengok api ni + // $router->put('customers/update/kaunter/{nokp}/{kodcaw}', ['uses' => 'CallCenterController@customerUpdateKaunter']); + $router->put('callcenter/customers/update/{nokp}', ['uses' => 'CallCenterController@customerUpdate']); //kena tengok api ni + $router->put('callcenter/customers/update/kaunter/{nokp}/{kodcaw}', ['uses' => 'CallCenterController@customerUpdateKaunter']); + //Change Password $router->post('changepassword/{kodcaw}/{id}',['uses'=>'CustomerController@changepassword']);