add di function customer nota arcc
This commit is contained in:
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user