diff --git a/app/Http/Controllers/AdminPageController.php b/app/Http/Controllers/AdminPageController.php index 527197a..cafc158 100644 --- a/app/Http/Controllers/AdminPageController.php +++ b/app/Http/Controllers/AdminPageController.php @@ -1137,7 +1137,7 @@ class AdminPageController extends Controller $upahToday = $upahToday + $upah_tebus_today + $upah_today; - $ansuran_today = TransaksiKeuntungan::on('mysql7')->where([['tarikh_bayaran','>=',$harini . ' 00:00:00'],['tarikh_bayaran','<=',$harini . ' 23:59:59']])->sum('bayaran_keuntungan'); + $ansuran_today = TransaksiKeuntungan::on('mysql7')->where([['tarikh_bayaran','>=',$harini . ' 00:00:00'],['tarikh_bayaran','<=',$harini . ' 23:59:59']])->where('kodcaw','=',$request->kodcaw)->sum('bayaran_keuntungan'); $upahToday = $upahToday + $ansuran_today; diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php index c0474dc..4e38b3d 100644 --- a/app/Http/Controllers/CustomerController.php +++ b/app/Http/Controllers/CustomerController.php @@ -695,4 +695,45 @@ class CustomerController extends Controller return response()->json($dataCustomer); } + + + public function AdminsearchCustomerByName(Request $request) + { + $nama = strtoupper($request->nama); + + if(empty($nama)) + { + $customer = []; + }else{ + $customer = Customer::on('mysql7') + ->where('nama','like',$nama.'%') + ->orWhere('nama','like','%'.$nama) + ->orWhere('nama','like','%'.$nama.'%') + ->take(3) + ->get(); + } + + return response()->json($customer); + } + + public function AdminsearchCustomerByIC(Request $request) + { + if(isset($request->kodcaw)) + { + $customer = Customer::on('mysql7') + ->where([['kplama','like',$request->ic.'%'],['kodcaw','=',$request->kodcaw]]) + ->orWhere([['kpbaru','like',$request->ic.'%'],['kodcaw','=',$request->kodcaw]]) + ->take(3) + ->get(); + }else{ + $customer = Customer::on('mysql7') + ->where('kplama','like',$request->ic.'%') + ->orWhere('kpbaru','like',$request->ic.'%') + ->take(3) + ->get(); + } + + + return response()->json($customer); + } } diff --git a/app/Http/Controllers/LaporanController.php b/app/Http/Controllers/LaporanController.php index 971b114..b03d07f 100644 --- a/app/Http/Controllers/LaporanController.php +++ b/app/Http/Controllers/LaporanController.php @@ -23,6 +23,7 @@ use App\Audit; use Carbon\Carbon; use DateTime; +use DB; class LaporanController extends Controller { @@ -145,12 +146,38 @@ class LaporanController extends Controller $gadaiDataKaunter = Gadai::on($cawangan['mysql'])->whereIn('norujukan',$total_keuntunganbukanansuran_data_kaunter)->whereNotNull('hargajualan')->pluck('norujukan'); + $keuntunganbukanansuran_kaunter_query = TransaksiKeuntungan::on('mysql7') + ->selectRaw('sum(keuntungan_rebet) as sum') ->whereIn('norujukan',$gadaiDataKaunter) - ->whereDate('tarikh_bayaran','=',$request->tarikh); + ->whereDate('tarikh_bayaran','=',$request->tarikh) + ->where('kodcaw','=',$request->kodcaw) + ->where('bayaran_pembiayaan','>', 0) + ->groupby('norujukan') + ->pluck('sum'); + // ->sum('sum'); + $sum = 0; + $countsum = 0; + foreach($keuntunganbukanansuran_kaunter_query as $quer) + { + $sum += $quer; + $countsum++; + } + - $total_keuntunganbukanansuran_kaunter = $keuntunganbukanansuran_kaunter_query->sum('keuntungan_rebet'); - $bil_keuntunganbukanansuran_kaunter = $keuntunganbukanansuran_kaunter_query->count(); + // $total_keuntunganbukanansuran_kaunter = $keuntunganbukanansuran_kaunter_query->sum('keuntungan_rebet'); + + // $bil_keuntunganbukanansuran_kaunter = $keuntunganbukanansuran_kaunter_query->count(); + + + + $total_keuntunganbukanansuran_kaunter = $sum; + + $bil_keuntunganbukanansuran_kaunter = $countsum; + + + + // dd($total_keuntunganbukanansuran_kaunter); // $total_keuntunganbukanansuran = 0; @@ -245,6 +272,8 @@ class LaporanController extends Controller $upahsimpankaunter = $keuntungan_kaunter + $upahtebus + $upahlelong + $upahansurKaunter + $total_keuntunganbukanansuran_kaunter; + + // dd($keuntungan_kaunter,$upahtebus,$upahlelong,$upahansurKaunter,$total_keuntunganbukanansuran_kaunter,$upahsimpankaunter); $keuntungansebenarkaunter = $total_keuntunganansuran_kaunter; $upahsimpanonline = $upahansurOnline; diff --git a/app/Http/Controllers/PolisController.php b/app/Http/Controllers/PolisController.php index 3087f7c..c10e7e3 100644 --- a/app/Http/Controllers/PolisController.php +++ b/app/Http/Controllers/PolisController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\Polis; use App\Cawangan; +use App\LookupAlasan; use Illuminate\Http\Request; use Carbon\Carbon; @@ -77,4 +78,29 @@ class PolisController extends Controller return response()->json($polis); } + + public function LookupAlasan(Request $request) + { + $harini = Carbon::now(); + $harini = new Carbon; + + + $alasan = LookupAlasan::on('mysql7') + ->get(); + + return response()->json($alasan); + + } + + public function LaporanPolis(Request $request){ + + $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first(); + + $polis = Polis::on($cawangan['mysql']) + ->where('komen1','=',$request->alasan) + ->where('tarikh','=',$request->tarikh) + ->get(); + + return response()->json($polis); + } } \ No newline at end of file diff --git a/app/Http/Controllers/TebusController.php b/app/Http/Controllers/TebusController.php index 9b79047..1b62b80 100644 --- a/app/Http/Controllers/TebusController.php +++ b/app/Http/Controllers/TebusController.php @@ -660,10 +660,14 @@ class TebusController extends Controller ->whereNotNull('hargajualan'); $tebustawarruqansuran = Tebus::on($cawangan['mysql']) + ->select('tebus.bakiupah','tebus.norujukan') ->join('gadai as gad','gad.norujukan','=','tebus.norujukan') ->where('t_tebus','=',$request->tarikh) ->whereNotNull('hargajualan') - ->where('hargajualan','<>','bakihargajualan'); + ->where('hargajualan','<>','bakihargajualan') + ->get()->toArray(); + + // dd($tebustawarruqansuran); // $totalpenebusantawarruq = ($tebustawarruq->sum('tebus.pinjaman') - $tebustawarruqansuran->sum('gad.pinjaman')) + $tebustawarruqansuran->sum('gad.bakipjm'); $totalpenebusantawarruq = $tebustawarruq->sum('tebus.pinjaman'); @@ -671,6 +675,8 @@ class TebusController extends Controller $totalrebatetawarruq = $tebustawarruq->sum('tebus.rebate'); $totalkeuntungantawarruq = $tebustawarruq->sum('tebus.bakiupah'); + // dd($totalkeuntunganarrahn,$totalkeuntungantawarruq); + $array_penebusan = ['bilarrahn' => $bilpenebusanarrahn, 'totalarrahn' => $totalpenebusanarrahn, 'keuntunganarrahn' => $totalkeuntunganarrahn, 'biltawarruq' => $bilpenebusantawarruq, 'totaltawarruq' => $totalpenebusantawarruq,'totalrebate' => $totalrebatetawarruq,'keuntungantawarruq' => $totalkeuntungantawarruq]; return response()->json($array_penebusan); diff --git a/app/LookupAlasan.php b/app/LookupAlasan.php new file mode 100644 index 0000000..6b098d1 --- /dev/null +++ b/app/LookupAlasan.php @@ -0,0 +1,28 @@ +group(['prefix'=>'api'], function () use ($router){ $router->get('getwakil/{kodcaw}/status/{status}',['uses' => 'TebusController@getWakilbyStatus']); $router->get('lookupwakil',['uses' => 'TebusController@LookupWakil']); + //API ALASAN + $router->get('lookupalasan',['uses' => 'PolisController@LookupAlasan']); + $router->get('polis/laporan',['uses' => 'PolisController@LaporanPolis']); + + //update tagterima Tebus