fix customer api
This commit is contained in:
@@ -18,49 +18,49 @@ class CustomerController extends Controller
|
|||||||
|
|
||||||
public function showAllCustomers()
|
public function showAllCustomers()
|
||||||
{
|
{
|
||||||
$cawangan_all = Cawangan::on('mysql7')->get();
|
// $cawangan_all = Cawangan::on('mysql7')->get();
|
||||||
$customer_all = [];
|
// $customer_all = [];
|
||||||
foreach($cawangan_all as $index=>$cawangan){
|
// foreach($cawangan_all as $index=>$cawangan){
|
||||||
$customer = Customer::on($cawangan['mysql'])->get();
|
$customer = Customer::on('mysql7')->get();
|
||||||
if($customer != null){
|
// if($customer != null){
|
||||||
array_push($customer_all,$customer);
|
// array_push($customer_all,$customer);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return response()->json($customer_all);
|
return response()->json($customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLatestCustomer($kodcaw){
|
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);
|
return response()->json($customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showAllCustomersByCawangan($kodcaw)
|
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);
|
return response()->json($customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showOneCustomerByIC($ic){
|
public function showOneCustomerByIC($ic){
|
||||||
|
|
||||||
$cawangan_all = Cawangan::on('mysql7')->get();
|
// $cawangan_all = Cawangan::on('mysql7')->get();
|
||||||
$customer_all = [];
|
// $customer_all = [];
|
||||||
foreach($cawangan_all as $index=>$cawangan){
|
// foreach($cawangan_all as $index=>$cawangan){
|
||||||
$customer = Customer::on($cawangan['mysql'])
|
$customer = Customer::on('mysql7')
|
||||||
->where('kplama','=',$ic)
|
->where('kplama','=',$ic)
|
||||||
->orWhere('kpbaru','=',$ic)
|
->orWhere('kpbaru','=',$ic)
|
||||||
->first();
|
->first();
|
||||||
if($customer != null){
|
// if($customer != null){
|
||||||
array_push($customer_all,$customer);
|
// array_push($customer_all,$customer);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return response()->json($customer_all);
|
return response()->json($customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showOneCustomerByICMobile($ic){
|
public function showOneCustomerByICMobile($ic){
|
||||||
@@ -297,9 +297,9 @@ class CustomerController extends Controller
|
|||||||
|
|
||||||
public function getLaporanCustomers($kodcaw, $tarikh)
|
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)
|
->where('tarikhdaftar','=',$tarikh)
|
||||||
->orderBy('tarikhdaftar', 'desc')
|
->orderBy('tarikhdaftar', 'desc')
|
||||||
->get();
|
->get();
|
||||||
@@ -313,7 +313,7 @@ class CustomerController extends Controller
|
|||||||
|
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||||
|
|
||||||
$customer = Customer::on($cawangan['mysql'])->create([
|
$customer = Customer::on('mysql7')->create([
|
||||||
'kodcaw' => $request->kodcaw,
|
'kodcaw' => $request->kodcaw,
|
||||||
'tarikhdaftar' => $current->toDateString(),
|
'tarikhdaftar' => $current->toDateString(),
|
||||||
'nopelanggan' => $request->nopelanggan,
|
'nopelanggan' => $request->nopelanggan,
|
||||||
@@ -346,15 +346,15 @@ class CustomerController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function customerUpdate($nokp,Request $request){
|
public function customerUpdate($nokp,Request $request){
|
||||||
$cawangan_all = Cawangan::on('mysql7')->get();
|
// $cawangan_all = Cawangan::on('mysql7')->get();
|
||||||
foreach($cawangan_all as $index=>$cawangan){
|
// foreach($cawangan_all as $index=>$cawangan){
|
||||||
$customer = Customer::on($cawangan['mysql'])
|
// $customer = Customer::on($cawangan['mysql'])
|
||||||
->where('kplama','=',$nokp)
|
// ->where('kplama','=',$nokp)
|
||||||
->orWhere('kpbaru','=',$nokp)
|
// ->orWhere('kpbaru','=',$nokp)
|
||||||
->first();
|
// ->first();
|
||||||
if($customer != null){
|
// if($customer != null){
|
||||||
$poskod = Poskod::on('mysql7')->where('poskod','=',$request->poskod)->first();
|
$poskod = Poskod::on('mysql7')->where('poskod','=',$request->poskod)->first();
|
||||||
$customer_update = Customer::on($cawangan['mysql'])
|
$customer_update = Customer::on('mysql7')
|
||||||
->where('kplama','=',$nokp)
|
->where('kplama','=',$nokp)
|
||||||
->orWhere('kpbaru','=',$nokp)
|
->orWhere('kpbaru','=',$nokp)
|
||||||
->update(array(
|
->update(array(
|
||||||
@@ -366,22 +366,22 @@ class CustomerController extends Controller
|
|||||||
'telefon' => $request->telefon1,
|
'telefon' => $request->telefon1,
|
||||||
'telefon2' => $request->telefon2
|
'telefon2' => $request->telefon2
|
||||||
));
|
));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return response()->json($customer_update, 200);
|
return response()->json($customer_update, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function customerUpdateKaunter($nokp,Request $request){
|
public function customerUpdateKaunter($nokp,Request $request){
|
||||||
$cawangan_all = Cawangan::on('mysql7')->get();
|
// $cawangan_all = Cawangan::on('mysql7')->get();
|
||||||
foreach($cawangan_all as $index=>$cawangan){
|
// foreach($cawangan_all as $index=>$cawangan){
|
||||||
$customer = Customer::on($cawangan['mysql'])
|
// $customer = Customer::on($cawangan['mysql'])
|
||||||
->where('kplama','=',$nokp)
|
// ->where('kplama','=',$nokp)
|
||||||
->orWhere('kpbaru','=',$nokp)
|
// ->orWhere('kpbaru','=',$nokp)
|
||||||
->first();
|
// ->first();
|
||||||
if($customer != null){
|
// if($customer != null){
|
||||||
$poskod = Poskod::on('mysql7')->where('poskod','=',$request->poskod)->first();
|
$poskod = Poskod::on('mysql7')->where('poskod','=',$request->poskod)->first();
|
||||||
$customer_update = Customer::on($cawangan['mysql'])
|
$customer_update = Customer::on('mysql7')
|
||||||
->where('kplama','=',$nokp)
|
->where('kplama','=',$nokp)
|
||||||
->orWhere('kpbaru','=',$nokp)
|
->orWhere('kpbaru','=',$nokp)
|
||||||
->update(array(
|
->update(array(
|
||||||
@@ -391,23 +391,23 @@ class CustomerController extends Controller
|
|||||||
'noakaun' => $request->noakaun,
|
'noakaun' => $request->noakaun,
|
||||||
'nota' => $request->nota
|
'nota' => $request->nota
|
||||||
));
|
));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return response()->json($customer_update, 200);
|
return response()->json($customer_update, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function customerUpdateKhazanah($nokp,Request $request){
|
public function customerUpdateKhazanah($nokp,Request $request){
|
||||||
$cawangan_all = Cawangan::on('mysql7')->get();
|
// $cawangan_all = Cawangan::on('mysql7')->get();
|
||||||
foreach($cawangan_all as $index=>$cawangan){
|
// foreach($cawangan_all as $index=>$cawangan){
|
||||||
$customer = Customer::on($cawangan['mysql'])
|
// $customer = Customer::on($cawangan['mysql'])
|
||||||
->where('kplama','=',$nokp)
|
// ->where('kplama','=',$nokp)
|
||||||
->orWhere('kpbaru','=',$nokp)
|
// ->orWhere('kpbaru','=',$nokp)
|
||||||
->first();
|
// ->first();
|
||||||
if($customer != null){
|
// if($customer != null){
|
||||||
$poskod = Poskod::on('mysql7')->where('poskod','=',$request->poskod)->first();
|
$poskod = Poskod::on('mysql7')->where('poskod','=',$request->poskod)->first();
|
||||||
|
|
||||||
$customer_update = Customer::on($cawangan['mysql'])
|
$customer_update = Customer::on('mysql7')
|
||||||
->where('kplama','=',$nokp)
|
->where('kplama','=',$nokp)
|
||||||
->orWhere('kpbaru','=',$nokp)
|
->orWhere('kpbaru','=',$nokp)
|
||||||
->update(array(
|
->update(array(
|
||||||
@@ -422,8 +422,8 @@ class CustomerController extends Controller
|
|||||||
'koddaerah' => $poskod['koddaerah'],
|
'koddaerah' => $poskod['koddaerah'],
|
||||||
'kodnegeri' => $poskod['kodnegeri']
|
'kodnegeri' => $poskod['kodnegeri']
|
||||||
));
|
));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return response()->json($customer_update, 200);
|
return response()->json($customer_update, 200);
|
||||||
}
|
}
|
||||||
@@ -498,7 +498,7 @@ class CustomerController extends Controller
|
|||||||
{
|
{
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
$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);
|
return response('Deleted Successfully', 200);
|
||||||
}
|
}
|
||||||
@@ -558,10 +558,10 @@ class CustomerController extends Controller
|
|||||||
|
|
||||||
public function insertAkaunBankMobile(Request $request)
|
public function insertAkaunBankMobile(Request $request)
|
||||||
{
|
{
|
||||||
$cawangan_all = Cawangan::on('mysql7')->get();
|
// $cawangan_all = Cawangan::on('mysql7')->get();
|
||||||
foreach($cawangan_all as $index=>$cawangan)
|
// foreach($cawangan_all as $index=>$cawangan)
|
||||||
{
|
// {
|
||||||
$customer = Customer::on($cawangan['mysql'])
|
$customer = Customer::on('mysql7')
|
||||||
->where('kplama','=',$request->nokp)
|
->where('kplama','=',$request->nokp)
|
||||||
->orWhere('kpbaru','=',$request->nokp)
|
->orWhere('kpbaru','=',$request->nokp)
|
||||||
->first();
|
->first();
|
||||||
@@ -572,7 +572,7 @@ class CustomerController extends Controller
|
|||||||
$customer->noakaun = $request->noakaun;
|
$customer->noakaun = $request->noakaun;
|
||||||
$customer->save();
|
$customer->save();
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
return response()->json($customer, 200);
|
return response()->json($customer, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class LaporanController extends Controller
|
|||||||
$bilangan_gadai = Gadai::on($cawangan['mysql'])->where('t_gadai','=',$request->tarikh)->count();
|
$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_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_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
|
//c
|
||||||
/* Sistem */
|
/* Sistem */
|
||||||
|
|||||||
@@ -842,7 +842,7 @@ class TebusController extends Controller
|
|||||||
$yuranTlama = imbangdugalama::on($cawangan['mysql'])
|
$yuranTlama = imbangdugalama::on($cawangan['mysql'])
|
||||||
->sum('yuran_t');
|
->sum('yuran_t');
|
||||||
|
|
||||||
$yuranbaru = Customer::on($cawangan['mysql'])
|
$yuranbaru = Customer::on('mysql7')
|
||||||
->where('tarikhdaftar','>','2013-12-31')
|
->where('tarikhdaftar','>','2013-12-31')
|
||||||
->whereYear('tarikhdaftar','<',$current->year)
|
->whereYear('tarikhdaftar','<',$current->year)
|
||||||
->sum('yuranahli');
|
->sum('yuranahli');
|
||||||
|
|||||||
Reference in New Issue
Block a user