add record password di web n customer contr

This commit is contained in:
Ain Izazi
2024-12-26 08:52:17 +08:00
parent 44f632638b
commit 630b606520
2 changed files with 67 additions and 49 deletions
+63 -48
View File
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Audit;
use App\Marhun;
use App\BankMaster;
use App\Customer;
@@ -49,7 +50,7 @@ class CustomerController extends Controller
}
public function showOneCustomerByICAdmin(Request $request){
$customer = Customer::on('mysql7')
->where('kplama','=',$request->ic)
->orWhere('kpbaru','=',$request->ic)
@@ -111,7 +112,7 @@ class CustomerController extends Controller
}
}
}
return response()->json($gadai_all);
}
@@ -142,7 +143,7 @@ class CustomerController extends Controller
}
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
if($status == 'belum_tebus'){
$gadai = Gadai::on($cawangan['mysql'])
->where([['sttebus','=',$gadai_status],['nokp','=',$ic]])
@@ -165,7 +166,7 @@ class CustomerController extends Controller
$gadai[0]['datatuntut'] = $tuntutbaki;
}
}
}
}
return response()->json($gadai);
}
@@ -202,7 +203,7 @@ class CustomerController extends Controller
}
}
}
return response()->json($gadai_all);
}
@@ -227,7 +228,7 @@ class CustomerController extends Controller
));
}
}
return $barang;
}
@@ -259,10 +260,10 @@ class CustomerController extends Controller
'tarikhgadai' => $gd->t_gadai,
'hargajualan' => $gd->hargajualan,
'bakihargajualan' => $gd->bakihargajualan,
'barang' => $this->marhun($cawangan, $gd->norujukan) ?? ' tiada data',
));
'barang' => $this->marhun($cawangan, $gd->norujukan) ?? ' tiada data',
));
}
}
elseif($gd->sttebus == 'T')
{
array_push($sttebus_T, array(
@@ -270,22 +271,22 @@ class CustomerController extends Controller
'pembiayaan' => number_format($gd->pinjaman,2),
'tarikhgadai' => $gd->t_gadai,
'hargajualan' => $gd->hargajualan,
'bakihargajualan' => $gd->bakihargajualan,
'barang' => $this->marhun($cawangan, $gd->norujukan) ?? ' tiada data',
'bakihargajualan' => $gd->bakihargajualan,
'barang' => $this->marhun($cawangan, $gd->norujukan) ?? ' tiada data',
));
}
elseif($gd->sttebus == 'L')
{
{
array_push($sttebus_L, array(
'norujukan' => $gd->norujukan,
'pembiayaan' => number_format($gd->pinjaman,2),
'tarikhgadai' => $gd->t_gadai,
'hargajualan' => $gd->hargajualan,
'bakihargajualan' => $gd->bakihargajualan,
'barang' => $this->marhun($cawangan, $gd->norujukan) ?? ' tiada data',
'bakihargajualan' => $gd->bakihargajualan,
'barang' => $this->marhun($cawangan, $gd->norujukan) ?? ' tiada data',
));
}
}
}
}
else
@@ -308,7 +309,7 @@ class CustomerController extends Controller
->where([['tarikhdaftar','=',$tarikh],['kodcaw',$kodcaw]])
->orderBy('tarikhdaftar', 'desc')
->get();
return response()->json($gadai);
}
@@ -364,7 +365,7 @@ class CustomerController extends Controller
'telefon' => $request->telefon1,
'telefon2' => $request->telefon2
));
return response()->json($customer_update, 200);
}
@@ -408,7 +409,7 @@ class CustomerController extends Controller
->get()->toArray();
$new_data = json_encode($customer_info_new);
$audit_customer = DB::connection('mysql7')
->table('audit_customer')
->insert([
@@ -431,11 +432,11 @@ class CustomerController extends Controller
DB::connection('mysql7')->rollback();
return response()->json($e->getMessage(),400);
}
}
}
public function customerUpdateKhazanah($nokp,Request $request){
DB::connection('mysql7')->beginTransaction();
try{
@@ -476,7 +477,7 @@ class CustomerController extends Controller
->get()->toArray();
$new_data = json_encode($customer_info_new);
$audit_customer = DB::connection('mysql7')
->table('audit_customer')
->insert([
@@ -490,7 +491,7 @@ class CustomerController extends Controller
'customer_nokp' => $nokp,
]);
}
DB::connection('mysql7')->commit();
@@ -500,8 +501,8 @@ class CustomerController extends Controller
DB::connection('mysql7')->rollback();
return response()->json($e->getMessage(),400);
}
}
}
public function customerUpdateAdmin(Request $request){
@@ -521,12 +522,12 @@ class CustomerController extends Controller
'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)
@@ -601,7 +602,7 @@ class CustomerController extends Controller
return response()->json($array_norujukan);
}
public function countNorujukanMobile($nokp){
$cawangan_all = Cawangan::on('mysql7')->get();
$bilangan_sag = 0;
@@ -615,7 +616,7 @@ class CustomerController extends Controller
public function getGadaiDetailMobile(Request $request)
{
$array_norujukan = $request->norujukan;
$array_norujukan = $request->norujukan;
$array_kodcaw = $request->kodcaw;
$array_gadai = [];
$gadai_payment = [];
@@ -660,7 +661,7 @@ class CustomerController extends Controller
return response('Deleted Successfully', 200);
}
public function akaunBankMobile($nokp)
{
$customer_detail = [];
@@ -672,7 +673,7 @@ class CustomerController extends Controller
->where('kplama','=',$nokp)
->orWhere('kpbaru','=',$nokp)
->rightJoin('online_arrahn.bank', 'bank.id', '=', 'customer.kodbank')
->first();
->first();
if(!empty($customer))
{
@@ -680,14 +681,14 @@ class CustomerController extends Controller
$customer_detail['namabank'] = $customer['name'];
$customer_detail['kodbank'] = $customer['id'];
return response()->json($customer_detail);
}
}
else
{
return $customer_detail;
}
}
}
public function bankListMobile()
{
$bank_array = [];
@@ -702,32 +703,32 @@ class CustomerController extends Controller
{
array_push($bank_array, array(
'kodbank' => $banklist->id,
'namabank' => $banklist->name,
));
'namabank' => $banklist->name,
));
}
return response()->json($bank_array);
}
else
{
return response()->json('Data Not Found');
}
}
}
}
public function insertAkaunBankMobile(Request $request)
{
$customer = Customer::on('mysql7')
$customer = Customer::on('mysql7')
->where('kplama','=',$request->nokp)
->orWhere('kpbaru','=',$request->nokp)
->first();
if(!empty($customer))
{
{
$customer->kodbank = $request->kodbank;
$customer->noakaun = $request->noakaun;
$customer->save();
$customer->save();
}
return response()->json($customer, 200);
}
@@ -761,7 +762,7 @@ class CustomerController extends Controller
}
public function blacklistCustomer(Request $request){
$blacklist = Blacklist::where('nokp',$request->nokp)->first();
return response()->json($blacklist);
@@ -778,8 +779,8 @@ class CustomerController extends Controller
->select('kodcaw')
->where('nokp', '=', $ic)
->first();
if($customer)
if($customer)
array_push($custcawangan,['kodcaw' => $customer['kodcaw'], 'namacawangan' => $cawangan['details_caw']]);
}
@@ -805,9 +806,9 @@ class CustomerController extends Controller
return response()->json($dataCustomer);
}
public function AdminsearchCustomerByName(Request $request)
{
{
$nama = strtoupper($request->nama);
if(empty($nama))
@@ -821,12 +822,12 @@ class CustomerController extends Controller
->take(3)
->get();
}
return response()->json($customer);
}
public function AdminsearchCustomerByIC(Request $request)
{
{
if(isset($request->kodcaw))
{
$customer = Customer::on('mysql7')
@@ -841,8 +842,22 @@ class CustomerController extends Controller
->take(3)
->get();
}
return response()->json($customer);
}
public function changepassword(Request $request, $kodcaw, $id) {
$current = Carbon::now();
// log::info ($request->name);
$audit = new Audit();
$audit->users = $request->nama;
$audit->actions = "Tukar Kata Laluan";
// $audit->new_data = json_encode($request->new_password);
$audit->kodcaw = $kodcaw;
$audit->created_at = $current;
$audit->updated_at = $current;
$audit->save();
}
}
+4 -1
View File
@@ -41,7 +41,7 @@ $router->group(['prefix'=>'api'], function () use ($router){
$router->get('/', 'PayableUjrahBranchController@index');
$router->post('/', 'PayableUjrahBranchController@create');
$router->post('/sync-status', 'PayableUjrahBranchController@syncStatus');
});
});
//Customer API
$router->get('customers',['uses'=>'CustomerController@showAllCustomers']);
@@ -61,6 +61,9 @@ $router->group(['prefix'=>'api'], function () use ($router){
$router->get('customer/blacklist',['uses'=>'CustomerController@blacklistCustomer']);
$router->get('customer/eachcawangan/{ic}',['uses'=>'CustomerController@showCustomerByEachCawangan']);
//Change Password
$router->post('changepassword/{kodcaw}/{id}',['uses'=>'CustomerController@changepassword']);
//Gadai API
$router->get('gadai',['uses'=>'GadaiController@showAllGadais']);
$router->get('gadai/{noic}',['uses'=>'GadaiController@showOneGadai']);