add di function customer nota arcc

This commit is contained in:
Ain Izazi
2025-08-25 09:40:16 +08:00
parent c65fac89d5
commit b103299d4f
4 changed files with 131 additions and 2 deletions
+74 -1
View File
@@ -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);
}
}
}
@@ -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);
// }
}
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddNotaArccToCustomerTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('customer', function (Blueprint $table) {
$table->string('nota_arcc')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('customer', function (Blueprint $table) {
$table->dropColumn('nota_arcc');
});
}
}
+5 -1
View File
@@ -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']);