diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php index afc772f..d672bb5 100644 --- a/app/Http/Controllers/CustomerController.php +++ b/app/Http/Controllers/CustomerController.php @@ -396,6 +396,7 @@ class CustomerController extends Controller // 'nota_arcc'=>$request->nota_arcc, 'telefon' => $request->telefon1, 'telefon2' => $request->telefon2, + 'telefon2' => $request->telefon2, )); return response()->json($customer_update, 200); @@ -420,6 +421,33 @@ class CustomerController extends Controller $customer->tag_anggota = 1; $customer->save(); + return response()->json([ + 'success' => true, + 'message' => 'Tag anggota berjaya dikemaskini.', + 'data' => $customer + ], 200); +} + } + + public function assignAnggota($noic, Request $request) +{ + // Semak sama ada pelanggan wujud + $customer = Customer::on('mysql7') + ->where('kpbaru', $noic) + ->orWhere('kplama', $noic) + ->first(); + + if (!$customer) { + return response()->json([ + 'success' => false, + 'message' => 'Pelanggan tidak dijumpai.' + ], 404); + } + + // Kemaskini tag_anggota + $customer->tag_anggota = 1; + $customer->save(); + return response()->json([ 'success' => true, 'message' => 'Tag anggota berjaya dikemaskini.', @@ -861,6 +889,14 @@ class CustomerController extends Controller } + public function anggotaKoperasi(Request $request){ + + $anggota = Anggota::where('noic',$request->noic)->first(); + + return response()->json($anggota); + } + + public function showCustomerByEachCawangan($ic) { $cawangan_all = Cawangan::on('mysql7')->get(); @@ -1102,6 +1138,27 @@ public function AdminsearchCustomerBySAG(Request $request) return response()->json($results); } + public function updateTagPdpa(Request $request) + { + $tarikh_cetak_pdpa = Carbon::now()->toDateString(); + + $no_ic = $request->input('no_ic'); + + $customer = Customer::where('kplama', $no_ic) + ->orWhere('kpbaru', $no_ic) + ->first(); + + if (!$customer) { + return response()->json(['error' => 'Customer not found.'], 404); + } + + $customer->tag_pdpa = $request->input('tag_pdpa'); + $customer->tarikh_cetak_pdpa = $tarikh_cetak_pdpa; + $customer->save(); + + return response()->json(['message' => 'Customer PDPA updated successfully.'], 200); + } + // public function createNotaArcc($kodcaw, Request $request) // { // $current = Carbon::now(); diff --git a/app/Http/Controllers/LaporanController.php b/app/Http/Controllers/LaporanController.php index 4c3320b..2b508c8 100644 --- a/app/Http/Controllers/LaporanController.php +++ b/app/Http/Controllers/LaporanController.php @@ -805,6 +805,7 @@ $date = new Carbon($request->tarikh); $tebus = Tebus::on($cawangan['mysql']) ->join('gadai as gad','gad.norujukan','=','tebus.norujukan') ->where([['t_tebus','>=',$request->mula],['t_tebus','<=',$request->akhir]]); + ->where([['t_tebus','>=',$request->mula],['t_tebus','<=',$request->akhir]]); $ansuran = Transaction::on('mysql7')->whereDate('created_at','>=',$request->mula)->whereDate('created_at','<=',$request->akhir)->where([['trans_type','=','A'],['kodcaw','=',$request->kodcaw]]); $bayaranonlinequery = Transaction::on('mysql7')->whereDate('created_at','>=',$request->mula)->whereDate('created_at','<=',$request->akhir)->where('teller','=','Online')->where('kodcaw',$request->kodcaw); @@ -835,14 +836,17 @@ $date = new Carbon($request->tarikh); ->where('trans.trans_type','=','A') ->where('trans.kodcaw','=',$request->kodcaw) // ->pluck('trans.norujukan'); + // ->pluck('trans.norujukan'); // ->groupBy('trans.id') ->sum('bayaran_keuntungan'); // dd($total_keuntunganansuran); + // dd($total_keuntunganansuran); // $total_ansuran = number_format($total_ansuran,2); $total_keuntungan = floatval($total_upah) + floatval($total_keuntunganansuran) + floatval($total_keuntungantebus); + //b $bilangan_gadai = $gadai->count(); $bilangan_tebus = $tebus->count(); @@ -850,6 +854,9 @@ $date = new Carbon($request->tarikh); //$bilangan_customer_baru = Customer::on('mysql7')->where([['tarikhdaftar','=',$request->tarikh],['kodcaw',$request->kodcaw]])->count() //$bilangan_customer_baru = Customer::on('mysql7')->where([['tarikhdaftar','>=',$request->mula],['tarikhdaftar','<=',$request->akhir]])->count(); $bilangan_customer_baru = Customer::on('mysql7')->whereBetween('tarikhdaftar', [$request->mula, $request->akhir])->where('kodcaw', $request->kodcaw)->count(); + //$bilangan_customer_baru = Customer::on('mysql7')->where([['tarikhdaftar','=',$request->tarikh],['kodcaw',$request->kodcaw]])->count() + //$bilangan_customer_baru = Customer::on('mysql7')->where([['tarikhdaftar','>=',$request->mula],['tarikhdaftar','<=',$request->akhir]])->count(); + $bilangan_customer_baru = Customer::on('mysql7')->whereBetween('tarikhdaftar', [$request->mula, $request->akhir])->where('kodcaw', $request->kodcaw)->count(); //f $data_lelong = Lelong::on($cawangan['mysql'])->where([['t_jual','>=',$request->mula],['t_jual','<=',$request->akhir]])->get(); @@ -975,7 +982,11 @@ $date = new Carbon($request->tarikh); ->where('trans.kodcaw',$request->kodcaw); // ->pluck('transaksi_keuntungan.norujukan'); + ->where('trans.kodcaw',$request->kodcaw); + // ->pluck('transaksi_keuntungan.norujukan'); + + // $gadaiDataKaunter = Gadai::on($cawangan['mysql'])->whereIn('norujukan',$total_keuntunganansuran_data_kaunter)->whereNotNull('hargajualan')->pluck('norujukan'); // $gadaiDataKaunter = Gadai::on($cawangan['mysql'])->whereIn('norujukan',$total_keuntunganansuran_data_kaunter)->whereNotNull('hargajualan')->pluck('norujukan'); // $keuntunganansuran_kaunter_query = TransaksiKeuntungan::on('mysql7') @@ -984,8 +995,17 @@ $date = new Carbon($request->tarikh); // ->whereDate('tarikh_bayaran','>=',$request->mula) // ->whereDate('tarikh_bayaran','<=',$request->akhir); //dd($keuntunganansuran_kaunter_query->get()->toArray()); + // $keuntunganansuran_kaunter_query = TransaksiKeuntungan::on('mysql7') + // ->whereIn('norujukan',$gadaiDataKaunter) + // ->where('kodcaw',$request->kodcaw) + // ->whereDate('tarikh_bayaran','>=',$request->mula) + // ->whereDate('tarikh_bayaran','<=',$request->akhir); + //dd($keuntunganansuran_kaunter_query->get()->toArray()); + $total_keuntunganansuran_kaunter = $total_keuntunganansuran_data_kaunter->sum('bayaran_keuntungan'); + //dd($total_keuntunganansuran_kaunter); + $bil_keuntunganansuran_kaunter = $total_keuntunganansuran_data_kaunter->count(); $total_keuntunganansuran_kaunter = $total_keuntunganansuran_data_kaunter->sum('bayaran_keuntungan'); //dd($total_keuntunganansuran_kaunter); $bil_keuntunganansuran_kaunter = $total_keuntunganansuran_data_kaunter->count();