diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php index ab8f95a..3f28a59 100644 --- a/app/Http/Controllers/CustomerController.php +++ b/app/Http/Controllers/CustomerController.php @@ -63,6 +63,23 @@ class CustomerController extends Controller return response()->json($customer); } + public function showOneCustomerByICAdmin(Request $request){ + + // $cawangan_all = Cawangan::on('mysql7')->get(); + // $customer_all = []; + // foreach($cawangan_all as $index=>$cawangan){ + $customer = Customer::on('mysql7') + ->where('kplama','=',$request->ic) + ->orWhere('kpbaru','=',$request->ic) + ->first(); + // if($customer != null){ + // array_push($customer_all,$customer); + // } + // } + + return response()->json($customer); + } + public function showOneCustomerByICMobile($ic){ $cawangan_all = Cawangan::on('mysql7')->get(); @@ -428,6 +445,88 @@ class CustomerController extends Controller return response()->json($customer_update, 200); } + public function customerUpdateAdmin(Request $request){ + $poskod = Poskod::on('mysql7')->where('poskod','=',$request->poskod)->first(); + + if($request->ic_asal != $request->icno){ + + $existing_customer = Customer::on('mysql7') + ->where('kplama','=',$request->icno) + ->orWhere('kpbaru','=',$request->icno) + ->get(); + + if($existing_customer->isEmpty()){ + $cawangan_all = Cawangan::on('mysql7')->get(); + foreach($cawangan_all as $index=> $cawangan){ + $gadai = Gadai::on($cawangan['mysql'])->where('nokp',$request->ic_asal)->update([ + 'nokp'=>$request->icno + ]); + } + + $data_asal = $customer_update = Customer::on('mysql7') + ->where('kplama','=',$request->ic_asal) + ->orWhere('kpbaru','=',$request->ic_asal) + ->first(); + + if($data_asal['kpbaru'] != null){ + $customer_update = Customer::on('mysql7') + ->where('kplama','=',$request->ic_asal) + ->orWhere('kpbaru','=',$request->ic_asal) + ->update(array( + 'kpbaru' => $request->icno, + 'telefon' => $request->telefon1, + 'telefon2' => $request->telefon2, + 'kodbank' => $request->kodbank, + 'noakaun' => $request->noakaun, + 'nota' => $request->nota, + 'nama' => $request->nama, + 'alamat1' => $request->alamat, + 'poskod' => $request->poskod, + 'koddaerah' => $poskod['koddaerah'], + 'kodnegeri' => $poskod['kodnegeri'] + )); + }else{ + $customer_update = Customer::on('mysql7') + ->where('kplama','=',$request->ic_asal) + ->orWhere('kpbaru','=',$request->ic_asal) + ->update(array( + 'kplama' => $request->icno, + 'telefon' => $request->telefon1, + 'telefon2' => $request->telefon2, + 'kodbank' => $request->kodbank, + 'noakaun' => $request->noakaun, + 'nota' => $request->nota, + 'nama' => $request->nama, + 'alamat1' => $request->alamat, + 'poskod' => $request->poskod, + 'koddaerah' => $poskod['koddaerah'], + 'kodnegeri' => $poskod['kodnegeri'] + )); + } + }else{ + return response()->json('existing'); + } + }else if($request->ic_asal == $request->icno){ + $customer_update = Customer::on('mysql7') + ->where('kplama','=',$request->icno) + ->orWhere('kpbaru','=',$request->icno) + ->update(array( + 'telefon' => $request->telefon1, + 'telefon2' => $request->telefon2, + 'kodbank' => $request->kodbank, + 'noakaun' => $request->noakaun, + 'nota' => $request->nota, + 'nama' => $request->nama, + 'alamat1' => $request->alamat, + 'poskod' => $request->poskod, + 'koddaerah' => $poskod['koddaerah'], + 'kodnegeri' => $poskod['kodnegeri'] + )); + } + + return response()->json($customer_update, 200); + } + public function listNorujukanMobile($nokp){ $cawangan_all = Cawangan::on('mysql7')->get(); $array_norujukan = []; diff --git a/app/Http/Controllers/GadaiController.php b/app/Http/Controllers/GadaiController.php index f7df114..b3f71e5 100644 --- a/app/Http/Controllers/GadaiController.php +++ b/app/Http/Controllers/GadaiController.php @@ -529,11 +529,17 @@ class GadaiController extends Controller public function barcodeScan($kodcaw,$norujukan){ $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); - $gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->update(array( - 'semakbarcode'=>'Lulus' - )); + $dahscan = Gadai::on($cawangan['mysql'])->where([['norujukan','=',$norujukan],['semakbarcode','Lulus']])->first(); - return response()->json($gadai,200); + if($dahscan){ + return response()->json('scanned'); + }else{ + $gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->update([ + 'semakbarcode'=>'Lulus' + ]); + + return response()->json('success'); + } } public function checkSerahGadaian(Request $request){ diff --git a/app/Http/Controllers/LaporanController.php b/app/Http/Controllers/LaporanController.php index 53b42ff..9381385 100644 --- a/app/Http/Controllers/LaporanController.php +++ b/app/Http/Controllers/LaporanController.php @@ -58,7 +58,7 @@ class LaporanController extends Controller //b - $bilangan_gadai = Gadai::on($cawangan['mysql'])->where('t_gadai','=',$request->tarikh)->count(); + $bilangan_gadai = Gadai::on($cawangan['mysql'])->where('t_gadai','=',$request->tarikh)->where('pinjaman','>',0)->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('mysql7')->where([['tarikhdaftar','=',$request->tarikh],['kodcaw',$request->kodcaw]])->count(); @@ -256,7 +256,7 @@ class LaporanController extends Controller $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first(); $laporan_terkumpul = []; - $gadai = Gadai::on($cawangan['mysql'])->where([['t_gadai','>=',$request->mula],['t_gadai','<=',$request->akhir]]); + $gadai = Gadai::on($cawangan['mysql'])->where([['t_gadai','>=',$request->mula],['t_gadai','<=',$request->akhir]])->where('pinjaman','>',0); $tebus = Tebus::on($cawangan['mysql'])->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]]); diff --git a/app/Http/Controllers/LelongController.php b/app/Http/Controllers/LelongController.php index 6bedf89..ea6992d 100644 --- a/app/Http/Controllers/LelongController.php +++ b/app/Http/Controllers/LelongController.php @@ -249,12 +249,12 @@ class LelongController extends Controller } }else{ $bakilelong = Lelong::on($cawangan['mysql']) - ->where('t_jual','>=',$request->mula) - ->where('t_jual','<=',$request->hingga) - ->where(function($query) use ($tarikhbaru){ - $query->whereNull('trkhtuntut') - ->orWhere('trkhtuntut','>',$tarikhbaru); - }) + ->where('trkhtuntut','>=',$request->mula) + ->where('trkhtuntut','<=',$request->hingga) + // ->where(function($query) use ($tarikhbaru){ + // $query->whereNull('trkhtuntut') + // ->orWhere('trkhtuntut','>',$tarikhbaru); + // }) ->where('baki','>=',0) ->sum('baki'); } @@ -263,13 +263,13 @@ class LelongController extends Controller ->sum('bayaran'); $rugilelong = Lelong::on($cawangan['mysql']) - ->where('t_jual','>=',$request->mula) - ->where('t_jual','<=',$request->hingga) - ->where(function($query) use ($tarikhbaru) - { - $query->whereNull('trkhtuntut') - ->orWhere('trkhtuntut','>',$tarikhbaru); - }) + ->where('trkhtuntut','>=',$request->mula) + ->where('trkhtuntut','<=',$request->hingga) + //->where(function($query) use ($tarikhbaru) + //{ + // $query->whereNull('t_jual') + // ->orWhere('t_jual','>',$tarikhbaru); + //}) ->where('baki','<',0) ->sum('baki'); diff --git a/app/Http/Controllers/PanjarController.php b/app/Http/Controllers/PanjarController.php index 6e1de5f..6583daa 100644 --- a/app/Http/Controllers/PanjarController.php +++ b/app/Http/Controllers/PanjarController.php @@ -195,13 +195,6 @@ class PanjarController extends Controller ->sum('bayaran'); - - if($kodcaw == 'APM') - { - $perubatan = $perubatan - 10; - $baikidanselenggara = $baikidanselenggara - 10; - } - $arraycalculation = ['bds' => $baikidanselenggara, 'perubatan' => $perubatan, 'keraian' => $keraian]; return response()->json($arraycalculation); diff --git a/app/Http/Controllers/TebusController.php b/app/Http/Controllers/TebusController.php index 08e1499..e08ce36 100644 --- a/app/Http/Controllers/TebusController.php +++ b/app/Http/Controllers/TebusController.php @@ -580,10 +580,17 @@ class TebusController extends Controller public function tagterimaupdate($kodcaw,$norujukan){ $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); + $dahscan = Tebus::on($cawangan['mysql'])->where([['norujukan','=',$norujukan],['tagterima',1]])->first(); - $update_inoutmar = Tebus::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->update(array( - 'tagterima' => 1 - )); + if($dahscan){ + return response()->json('scanned'); + }else{ + $update_inoutmar = Tebus::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->update(array( + 'tagterima' => 1 + )); + + return response()->json('success'); + } } public function checkSerahTebus(Request $request){ @@ -1034,7 +1041,6 @@ class TebusController extends Controller $penghutangkaki = imbangdugalama::on($cawangan['mysql']) ->sum('penghutang'); - return response()->json($penghutangkaki,200); } @@ -1204,4 +1210,35 @@ class TebusController extends Controller return response($rebet); } + public function getUpahLamaToday($kodcaw,$norujukan) + { + $current = Carbon::now(); + $current = new Carbon(); + + $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); + + $listadvansur = Advansur::on($cawangan['mysql']) + ->where('norujukan','=',$norujukan) + ->where('tarikh','=',$current->toDateString()) + ->orderBy('tarikh','desc') + ->get(); + + if(sizeof($listadvansur) > 0) + return response(1); + else + return response(0); + } + + public function removeUpahLamaToday($kodcaw,$norujukan) + { + $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); + + $removed = Advansur::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->delete(); + + if($removed) + return response(1); + else + return response(0); + } + } diff --git a/app/Http/Controllers/TunaiController.php b/app/Http/Controllers/TunaiController.php index b4f9725..ded94ed 100644 --- a/app/Http/Controllers/TunaiController.php +++ b/app/Http/Controllers/TunaiController.php @@ -272,6 +272,20 @@ class TunaiController extends Controller return response()->json($requestteller); } + public function getRequestTellerLaporanSerahanBerkala($kodcaw,Request $request) + { + + $current = Carbon::now(); + $current = new Carbon(); + + $requestteller=RequestTeller::on('mysql7') + ->where([['kodcaw','=',$kodcaw],['update','=',1],['serahan','>',0],['kodlaluan','=',$request->teller],['tarikh','=',$current->toDateString()]]) + ->orderBy('recno','desc') + ->first(); + + return response()->json($requestteller); + } + public function getRequestTellerByDate($kodcaw,Request $request) { diff --git a/config/database.php b/config/database.php index afbd7f8..eebc494 100644 --- a/config/database.php +++ b/config/database.php @@ -125,7 +125,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql10' => [ 'driver' => 'mysql', @@ -138,7 +137,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql11' => [ 'driver' => 'mysql', @@ -151,7 +149,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql12' => [ @@ -165,7 +162,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql13' => [ 'driver' => 'mysql', @@ -178,7 +174,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql14' => [ 'driver' => 'mysql', @@ -191,7 +186,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql15' => [ @@ -205,7 +199,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql16' => [ 'driver' => 'mysql', @@ -218,7 +211,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql17' => [ @@ -232,7 +224,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql18' => [ 'driver' => 'mysql', @@ -245,7 +236,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql19' => [ 'driver' => 'mysql', @@ -258,7 +248,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql20' => [ 'driver' => 'mysql', @@ -271,7 +260,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql21' => [ 'driver' => 'mysql', @@ -284,7 +272,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql22' => [ @@ -298,7 +285,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql23' => [ 'driver' => 'mysql', @@ -311,7 +297,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql24' => [ @@ -325,7 +310,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql25' => [ @@ -339,7 +323,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql26' => [ 'driver' => 'mysql', @@ -352,7 +335,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql27' => [ 'driver' => 'mysql', @@ -365,7 +347,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql28' => [ @@ -379,7 +360,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql29' => [ 'driver' => 'mysql', @@ -392,7 +372,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql30' => [ 'driver' => 'mysql', @@ -405,7 +384,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql31' => [ 'driver' => 'mysql', @@ -418,7 +396,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql32' => [ 'driver' => 'mysql', @@ -431,7 +408,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], 'mysql33' => [ 'driver' => 'mysql', @@ -444,7 +420,6 @@ return [ 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, - 'unix_socket' => env('UNIX_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'), ], ], ]; diff --git a/routes/web.php b/routes/web.php index 960123f..15c0016 100644 --- a/routes/web.php +++ b/routes/web.php @@ -36,6 +36,8 @@ $router->group(['prefix'=>'api'], function () use ($router){ $router->put('customers/update/khazanah/{nokp}', ['uses' => 'CustomerController@customerUpdateKhazanah']); $router->get('customers/laporan/{kodcaw}/{tarikh}',['uses'=>'CustomerController@getLaporanCustomers']); $router->get('customers/latest/{kodcaw}',['uses'=>'CustomerController@getLatestCustomer']); + $router->put('customers/information/update/admin', ['uses' => 'CustomerController@customerUpdateAdmin']); + $router->get('admin/customers/nokp/search',['uses'=>'CustomerController@showOneCustomerByICAdmin']); //Gadai API $router->get('gadai',['uses'=>'GadaiController@showAllGadais']); @@ -214,6 +216,8 @@ $router->group(['prefix'=>'api'], function () use ($router){ $router->get('advansurdetailsrange/{kodcaw}',['uses'=>'TebusController@advansurdetailsRange']); $router->post('ansuran/create/{kodcaw}',['uses'=>'TebusController@createAdvansur']); $router->get('advansur/{kodcaw}/{norujukan}',['uses'=>'TebusController@getAdvansurUpah']); + $router->get('upahlamatoday/{kodcaw}/{norujukan}',['uses'=>'TebusController@getUpahLamaToday']); + $router->post('removeupahlamatoday/{kodcaw}/{norujukan}',['uses'=>'TebusController@removeUpahLamaToday']); //POLIS API $router->get('polis/get/',['uses'=>'PolisController@getPolis']); @@ -294,6 +298,7 @@ $router->group(['prefix'=>'api'], function () use ($router){ $router->post('requestTeller/{kodcaw}',['uses' => 'TunaiController@createRequestTeller']); $router->get('requestTeller/get/{kodcaw}',['uses' => 'TunaiController@getRequestTeller']); $router->get('requestTeller/getlaporan/{kodcaw}',['uses' => 'TunaiController@getRequestTellerLaporanSerahan']); + $router->get('requestTeller/getlaporanberkala/{kodcaw}',['uses' => 'TunaiController@getRequestTellerLaporanSerahanBerkala']); $router->get('requestTeller/get/{kodcaw}/date',['uses' => 'TunaiController@getRequestTellerByDate']); $router->put('requestTeller/update/{kodcaw}',['uses' => 'TunaiController@updateRequestTeller']); $router->put('requestTeller/batal/{kodcaw}',['uses' => 'TunaiController@batalRequestTeller']);