fix customer api

This commit is contained in:
Afiq Zakwan Hamdan
2021-06-14 13:53:48 +08:00
parent 5c041a23cd
commit 7ebbb29eba
3 changed files with 63 additions and 63 deletions
+61 -61
View File
@@ -18,49 +18,49 @@ class CustomerController extends Controller
public function showAllCustomers()
{
$cawangan_all = Cawangan::on('mysql7')->get();
$customer_all = [];
foreach($cawangan_all as $index=>$cawangan){
$customer = Customer::on($cawangan['mysql'])->get();
if($customer != null){
array_push($customer_all,$customer);
}
}
return response()->json($customer_all);
// $cawangan_all = Cawangan::on('mysql7')->get();
// $customer_all = [];
// foreach($cawangan_all as $index=>$cawangan){
$customer = Customer::on('mysql7')->get();
// if($customer != null){
// array_push($customer_all,$customer);
// }
// }
return response()->json($customer);
}
public function getLatestCustomer($kodcaw){
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
// $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$customer = Customer::on($cawangan['mysql'])->orderBy('tarikhdaftar','desc')->orderBy('nosiri','desc')->first();
$customer = Customer::on('mysql7')->orderBy('tarikhdaftar','desc')->orderBy('nosiri','desc')->first();
return response()->json($customer);
}
public function showAllCustomersByCawangan($kodcaw)
{
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
// $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$customer = Customer::on($cawangan['mysql'])->get();
$customer = Customer::on('mysql7')->get();
return response()->json($customer);
}
public function showOneCustomerByIC($ic){
$cawangan_all = Cawangan::on('mysql7')->get();
$customer_all = [];
foreach($cawangan_all as $index=>$cawangan){
$customer = Customer::on($cawangan['mysql'])
// $cawangan_all = Cawangan::on('mysql7')->get();
// $customer_all = [];
// foreach($cawangan_all as $index=>$cawangan){
$customer = Customer::on('mysql7')
->where('kplama','=',$ic)
->orWhere('kpbaru','=',$ic)
->first();
if($customer != null){
array_push($customer_all,$customer);
}
}
// if($customer != null){
// array_push($customer_all,$customer);
// }
// }
return response()->json($customer_all);
return response()->json($customer);
}
public function showOneCustomerByICMobile($ic){
@@ -297,9 +297,9 @@ class CustomerController extends Controller
public function getLaporanCustomers($kodcaw, $tarikh)
{
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
// $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$gadai = Customer::on($cawangan['mysql'])
$gadai = Customer::on('mysql7')
->where('tarikhdaftar','=',$tarikh)
->orderBy('tarikhdaftar', 'desc')
->get();
@@ -313,7 +313,7 @@ class CustomerController extends Controller
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$customer = Customer::on($cawangan['mysql'])->create([
$customer = Customer::on('mysql7')->create([
'kodcaw' => $request->kodcaw,
'tarikhdaftar' => $current->toDateString(),
'nopelanggan' => $request->nopelanggan,
@@ -346,15 +346,15 @@ class CustomerController extends Controller
}
public function customerUpdate($nokp,Request $request){
$cawangan_all = Cawangan::on('mysql7')->get();
foreach($cawangan_all as $index=>$cawangan){
$customer = Customer::on($cawangan['mysql'])
->where('kplama','=',$nokp)
->orWhere('kpbaru','=',$nokp)
->first();
if($customer != null){
// $cawangan_all = Cawangan::on('mysql7')->get();
// foreach($cawangan_all as $index=>$cawangan){
// $customer = Customer::on($cawangan['mysql'])
// ->where('kplama','=',$nokp)
// ->orWhere('kpbaru','=',$nokp)
// ->first();
// if($customer != null){
$poskod = Poskod::on('mysql7')->where('poskod','=',$request->poskod)->first();
$customer_update = Customer::on($cawangan['mysql'])
$customer_update = Customer::on('mysql7')
->where('kplama','=',$nokp)
->orWhere('kpbaru','=',$nokp)
->update(array(
@@ -366,22 +366,22 @@ class CustomerController extends Controller
'telefon' => $request->telefon1,
'telefon2' => $request->telefon2
));
}
}
// }
// }
return response()->json($customer_update, 200);
}
public function customerUpdateKaunter($nokp,Request $request){
$cawangan_all = Cawangan::on('mysql7')->get();
foreach($cawangan_all as $index=>$cawangan){
$customer = Customer::on($cawangan['mysql'])
->where('kplama','=',$nokp)
->orWhere('kpbaru','=',$nokp)
->first();
if($customer != null){
// $cawangan_all = Cawangan::on('mysql7')->get();
// foreach($cawangan_all as $index=>$cawangan){
// $customer = Customer::on($cawangan['mysql'])
// ->where('kplama','=',$nokp)
// ->orWhere('kpbaru','=',$nokp)
// ->first();
// if($customer != null){
$poskod = Poskod::on('mysql7')->where('poskod','=',$request->poskod)->first();
$customer_update = Customer::on($cawangan['mysql'])
$customer_update = Customer::on('mysql7')
->where('kplama','=',$nokp)
->orWhere('kpbaru','=',$nokp)
->update(array(
@@ -391,23 +391,23 @@ class CustomerController extends Controller
'noakaun' => $request->noakaun,
'nota' => $request->nota
));
}
}
// }
// }
return response()->json($customer_update, 200);
}
public function customerUpdateKhazanah($nokp,Request $request){
$cawangan_all = Cawangan::on('mysql7')->get();
foreach($cawangan_all as $index=>$cawangan){
$customer = Customer::on($cawangan['mysql'])
->where('kplama','=',$nokp)
->orWhere('kpbaru','=',$nokp)
->first();
if($customer != null){
// $cawangan_all = Cawangan::on('mysql7')->get();
// foreach($cawangan_all as $index=>$cawangan){
// $customer = Customer::on($cawangan['mysql'])
// ->where('kplama','=',$nokp)
// ->orWhere('kpbaru','=',$nokp)
// ->first();
// if($customer != null){
$poskod = Poskod::on('mysql7')->where('poskod','=',$request->poskod)->first();
$customer_update = Customer::on($cawangan['mysql'])
$customer_update = Customer::on('mysql7')
->where('kplama','=',$nokp)
->orWhere('kpbaru','=',$nokp)
->update(array(
@@ -422,8 +422,8 @@ class CustomerController extends Controller
'koddaerah' => $poskod['koddaerah'],
'kodnegeri' => $poskod['kodnegeri']
));
}
}
// }
// }
return response()->json($customer_update, 200);
}
@@ -498,7 +498,7 @@ class CustomerController extends Controller
{
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
Customer::on($cawangan['mysql'])->where('kplama','=',$nokp)->orWhere('kpbaru','=',$nokp)->delete();
Customer::on('mysql7')->where('kplama','=',$nokp)->orWhere('kpbaru','=',$nokp)->delete();
return response('Deleted Successfully', 200);
}
@@ -558,10 +558,10 @@ class CustomerController extends Controller
public function insertAkaunBankMobile(Request $request)
{
$cawangan_all = Cawangan::on('mysql7')->get();
foreach($cawangan_all as $index=>$cawangan)
{
$customer = Customer::on($cawangan['mysql'])
// $cawangan_all = Cawangan::on('mysql7')->get();
// foreach($cawangan_all as $index=>$cawangan)
// {
$customer = Customer::on('mysql7')
->where('kplama','=',$request->nokp)
->orWhere('kpbaru','=',$request->nokp)
->first();
@@ -572,7 +572,7 @@ class CustomerController extends Controller
$customer->noakaun = $request->noakaun;
$customer->save();
}
}
// }
return response()->json($customer, 200);
}
+1 -1
View File
@@ -60,7 +60,7 @@ class LaporanController extends Controller
$bilangan_gadai = Gadai::on($cawangan['mysql'])->where('t_gadai','=',$request->tarikh)->count();
$bilangan_tebus = Tebus::on($cawangan['mysql'])->where('t_tebus','=',$request->tarikh)->count();
$bilangan_ansuran = Transaction::on('mysql7')->whereRaw('DATE(created_at) = ?',[$request->tarikh])->where([['trans_type','=','A'],['kodcaw','=',$request->kodcaw]])->count();
$bilangan_customer_baru = Customer::on($cawangan['mysql'])->where('tarikhdaftar','=',$request->tarikh)->count();
$bilangan_customer_baru = Customer::on('mysql7')->where('tarikhdaftar','=',$request->tarikh)->count();
//c
/* Sistem */
+1 -1
View File
@@ -842,7 +842,7 @@ class TebusController extends Controller
$yuranTlama = imbangdugalama::on($cawangan['mysql'])
->sum('yuran_t');
$yuranbaru = Customer::on($cawangan['mysql'])
$yuranbaru = Customer::on('mysql7')
->where('tarikhdaftar','>','2013-12-31')
->whereYear('tarikhdaftar','<',$current->year)
->sum('yuranahli');