fix kerja

This commit is contained in:
Ain Izazi
2024-12-01 15:30:48 +08:00
parent 520ca5d92d
commit 36dad586c5
5 changed files with 112 additions and 51 deletions
+3 -1
View File
@@ -14,10 +14,12 @@ class AuditCustomer extends Model
'username', 'username',
'old_data', 'old_data',
'new_data', 'new_data',
'kodkerja',
'nota_pekerjaan',
'kodcaw', 'kodcaw',
'created_at', 'created_at',
'updated_at', 'updated_at',
'customer_name', 'customer_name',
'customer_nokp', 'customer_nokp',
]; ];
} }
+1
View File
@@ -60,6 +60,7 @@ class Customer extends Model
'tagperingatan', 'tagperingatan',
'kumpulan', 'kumpulan',
'telefon2', 'telefon2',
'nota_pekerjaan',
'tagpelanggan' 'tagpelanggan'
]; ];
+57 -49
View File
@@ -111,7 +111,7 @@ class CustomerController extends Controller
} }
} }
} }
return response()->json($gadai_all); return response()->json($gadai_all);
} }
@@ -142,7 +142,7 @@ class CustomerController extends Controller
} }
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
if($status == 'belum_tebus'){ if($status == 'belum_tebus'){
$gadai = Gadai::on($cawangan['mysql']) $gadai = Gadai::on($cawangan['mysql'])
->where([['sttebus','=',$gadai_status],['nokp','=',$ic]]) ->where([['sttebus','=',$gadai_status],['nokp','=',$ic]])
@@ -165,7 +165,7 @@ class CustomerController extends Controller
$gadai[0]['datatuntut'] = $tuntutbaki; $gadai[0]['datatuntut'] = $tuntutbaki;
} }
} }
} }
return response()->json($gadai); return response()->json($gadai);
} }
@@ -202,7 +202,7 @@ class CustomerController extends Controller
} }
} }
} }
return response()->json($gadai_all); return response()->json($gadai_all);
} }
@@ -227,7 +227,7 @@ class CustomerController extends Controller
)); ));
} }
} }
return $barang; return $barang;
} }
@@ -259,10 +259,10 @@ class CustomerController extends Controller
'tarikhgadai' => $gd->t_gadai, 'tarikhgadai' => $gd->t_gadai,
'hargajualan' => $gd->hargajualan, 'hargajualan' => $gd->hargajualan,
'bakihargajualan' => $gd->bakihargajualan, 'bakihargajualan' => $gd->bakihargajualan,
'barang' => $this->marhun($cawangan, $gd->norujukan) ?? ' tiada data', 'barang' => $this->marhun($cawangan, $gd->norujukan) ?? ' tiada data',
)); ));
} }
elseif($gd->sttebus == 'T') elseif($gd->sttebus == 'T')
{ {
array_push($sttebus_T, array( array_push($sttebus_T, array(
@@ -270,22 +270,22 @@ class CustomerController extends Controller
'pembiayaan' => number_format($gd->pinjaman,2), 'pembiayaan' => number_format($gd->pinjaman,2),
'tarikhgadai' => $gd->t_gadai, 'tarikhgadai' => $gd->t_gadai,
'hargajualan' => $gd->hargajualan, 'hargajualan' => $gd->hargajualan,
'bakihargajualan' => $gd->bakihargajualan, 'bakihargajualan' => $gd->bakihargajualan,
'barang' => $this->marhun($cawangan, $gd->norujukan) ?? ' tiada data', 'barang' => $this->marhun($cawangan, $gd->norujukan) ?? ' tiada data',
)); ));
} }
elseif($gd->sttebus == 'L') elseif($gd->sttebus == 'L')
{ {
array_push($sttebus_L, array( array_push($sttebus_L, array(
'norujukan' => $gd->norujukan, 'norujukan' => $gd->norujukan,
'pembiayaan' => number_format($gd->pinjaman,2), 'pembiayaan' => number_format($gd->pinjaman,2),
'tarikhgadai' => $gd->t_gadai, 'tarikhgadai' => $gd->t_gadai,
'hargajualan' => $gd->hargajualan, 'hargajualan' => $gd->hargajualan,
'bakihargajualan' => $gd->bakihargajualan, 'bakihargajualan' => $gd->bakihargajualan,
'barang' => $this->marhun($cawangan, $gd->norujukan) ?? ' tiada data', 'barang' => $this->marhun($cawangan, $gd->norujukan) ?? ' tiada data',
)); ));
} }
} }
} }
else else
@@ -308,7 +308,7 @@ class CustomerController extends Controller
->where([['tarikhdaftar','=',$tarikh],['kodcaw',$kodcaw]]) ->where([['tarikhdaftar','=',$tarikh],['kodcaw',$kodcaw]])
->orderBy('tarikhdaftar', 'desc') ->orderBy('tarikhdaftar', 'desc')
->get(); ->get();
return response()->json($gadai); return response()->json($gadai);
} }
@@ -344,6 +344,7 @@ class CustomerController extends Controller
'nosiri'=>$request->nosiri, 'nosiri'=>$request->nosiri,
'nota'=>$request->nota, 'nota'=>$request->nota,
'kodkerja'=>$request->kodkerja, 'kodkerja'=>$request->kodkerja,
'nota_pekerjaan'=>$request->nota_pekerjaan,
'tujuangadai'=>$request->tujuangadai 'tujuangadai'=>$request->tujuangadai
]); ]);
@@ -361,10 +362,12 @@ class CustomerController extends Controller
'poskod' => $request->poskod, 'poskod' => $request->poskod,
'koddaerah' => $poskod['koddaerah'], 'koddaerah' => $poskod['koddaerah'],
'kodnegeri' => $poskod['kodnegeri'], 'kodnegeri' => $poskod['kodnegeri'],
'kodkerja'=>$request->kodkerja,
'nota_pekerjaan'=>$request->nota_pekerjaan,
'telefon' => $request->telefon1, 'telefon' => $request->telefon1,
'telefon2' => $request->telefon2 'telefon2' => $request->telefon2
)); ));
return response()->json($customer_update, 200); return response()->json($customer_update, 200);
} }
@@ -376,7 +379,7 @@ class CustomerController extends Controller
$poskod = Poskod::on('mysql7')->where('poskod','=',$request->poskod)->first(); $poskod = Poskod::on('mysql7')->where('poskod','=',$request->poskod)->first();
$customer_info = DB::connection('mysql7')->table('customer') $customer_info = DB::connection('mysql7')->table('customer')
->select('kodcaw','tarikhdaftar','nopelanggan','kpbaru','kplama','nama','t_lahir','jantina','alamat1','poskod','telefon','telefon2') ->select('kodcaw','kodkerja','nota_pekerjaan','tarikhdaftar','nopelanggan','kpbaru','kplama','nama','t_lahir','jantina','alamat1','poskod','telefon','telefon2')
->where('kplama','=',$nokp) ->where('kplama','=',$nokp)
->orWhere('kpbaru','=',$nokp) ->orWhere('kpbaru','=',$nokp)
->get()->toArray(); ->get()->toArray();
@@ -391,6 +394,9 @@ class CustomerController extends Controller
'telefon' => $request->telefon1, 'telefon' => $request->telefon1,
'telefon2' => $request->telefon2, 'telefon2' => $request->telefon2,
'kodbank' => $request->kodbank, 'kodbank' => $request->kodbank,
'kodkerja' => $request->kodkerja,
// 'nota_pekerjaan' => $request->nota_pekerjaan,
'nota_pekerjaan' => $request->kodkerja === '6' ? $request->nota_pekerjaan : null,
'noakaun' => $request->noakaun, 'noakaun' => $request->noakaun,
'nota' => $request->nota, 'nota' => $request->nota,
'alamat1' => $request->alamat, 'alamat1' => $request->alamat,
@@ -402,13 +408,13 @@ class CustomerController extends Controller
if($customer_update) if($customer_update)
{ {
$customer_info_new = DB::connection('mysql7')->table('customer') $customer_info_new = DB::connection('mysql7')->table('customer')
->select('kodcaw','tarikhdaftar','nopelanggan','kpbaru','kplama','nama','t_lahir','jantina','alamat1','poskod','telefon','telefon2') ->select('kodcaw','kodkerja','nota_pekerjaan','tarikhdaftar','nopelanggan','kpbaru','kplama','nama','t_lahir','jantina','alamat1','poskod','telefon','telefon2')
->where('kplama','=',$nokp) ->where('kplama','=',$nokp)
->orWhere('kpbaru','=',$nokp) ->orWhere('kpbaru','=',$nokp)
->get()->toArray(); ->get()->toArray();
$new_data = json_encode($customer_info_new); $new_data = json_encode($customer_info_new);
$audit_customer = DB::connection('mysql7') $audit_customer = DB::connection('mysql7')
->table('audit_customer') ->table('audit_customer')
->insert([ ->insert([
@@ -431,11 +437,11 @@ class CustomerController extends Controller
DB::connection('mysql7')->rollback(); DB::connection('mysql7')->rollback();
return response()->json($e->getMessage(),400); return response()->json($e->getMessage(),400);
} }
} }
public function customerUpdateKhazanah($nokp,Request $request){ public function customerUpdateKhazanah($nokp,Request $request){
DB::connection('mysql7')->beginTransaction(); DB::connection('mysql7')->beginTransaction();
try{ try{
@@ -457,6 +463,8 @@ class CustomerController extends Controller
'telefon' => $request->telefon1, 'telefon' => $request->telefon1,
'telefon2' => $request->telefon2, 'telefon2' => $request->telefon2,
'kodbank' => $request->kodbank, 'kodbank' => $request->kodbank,
'kodkerja' => $request->kodkerja,
'nota_pekerjaan' => $request->nota_pekerjaan,
'noakaun' => $request->noakaun, 'noakaun' => $request->noakaun,
'nota' => $request->nota, 'nota' => $request->nota,
'nama' => $request->nama, 'nama' => $request->nama,
@@ -476,7 +484,7 @@ class CustomerController extends Controller
->get()->toArray(); ->get()->toArray();
$new_data = json_encode($customer_info_new); $new_data = json_encode($customer_info_new);
$audit_customer = DB::connection('mysql7') $audit_customer = DB::connection('mysql7')
->table('audit_customer') ->table('audit_customer')
->insert([ ->insert([
@@ -490,7 +498,7 @@ class CustomerController extends Controller
'customer_nokp' => $nokp, 'customer_nokp' => $nokp,
]); ]);
} }
DB::connection('mysql7')->commit(); DB::connection('mysql7')->commit();
@@ -500,8 +508,8 @@ class CustomerController extends Controller
DB::connection('mysql7')->rollback(); DB::connection('mysql7')->rollback();
return response()->json($e->getMessage(),400); return response()->json($e->getMessage(),400);
} }
} }
public function customerUpdateAdmin(Request $request){ public function customerUpdateAdmin(Request $request){
@@ -521,12 +529,12 @@ class CustomerController extends Controller
'nokp'=>$request->icno 'nokp'=>$request->icno
]); ]);
} }
$data_asal = $customer_update = Customer::on('mysql7') $data_asal = $customer_update = Customer::on('mysql7')
->where('kplama','=',$request->ic_asal) ->where('kplama','=',$request->ic_asal)
->orWhere('kpbaru','=',$request->ic_asal) ->orWhere('kpbaru','=',$request->ic_asal)
->first(); ->first();
if($data_asal['kpbaru'] != null){ if($data_asal['kpbaru'] != null){
$customer_update = Customer::on('mysql7') $customer_update = Customer::on('mysql7')
->where('kplama','=',$request->ic_asal) ->where('kplama','=',$request->ic_asal)
@@ -601,7 +609,7 @@ class CustomerController extends Controller
return response()->json($array_norujukan); return response()->json($array_norujukan);
} }
public function countNorujukanMobile($nokp){ public function countNorujukanMobile($nokp){
$cawangan_all = Cawangan::on('mysql7')->get(); $cawangan_all = Cawangan::on('mysql7')->get();
$bilangan_sag = 0; $bilangan_sag = 0;
@@ -615,7 +623,7 @@ class CustomerController extends Controller
public function getGadaiDetailMobile(Request $request) public function getGadaiDetailMobile(Request $request)
{ {
$array_norujukan = $request->norujukan; $array_norujukan = $request->norujukan;
$array_kodcaw = $request->kodcaw; $array_kodcaw = $request->kodcaw;
$array_gadai = []; $array_gadai = [];
$gadai_payment = []; $gadai_payment = [];
@@ -660,7 +668,7 @@ class CustomerController extends Controller
return response('Deleted Successfully', 200); return response('Deleted Successfully', 200);
} }
public function akaunBankMobile($nokp) public function akaunBankMobile($nokp)
{ {
$customer_detail = []; $customer_detail = [];
@@ -672,7 +680,7 @@ class CustomerController extends Controller
->where('kplama','=',$nokp) ->where('kplama','=',$nokp)
->orWhere('kpbaru','=',$nokp) ->orWhere('kpbaru','=',$nokp)
->rightJoin('online_arrahn.bank', 'bank.id', '=', 'customer.kodbank') ->rightJoin('online_arrahn.bank', 'bank.id', '=', 'customer.kodbank')
->first(); ->first();
if(!empty($customer)) if(!empty($customer))
{ {
@@ -680,14 +688,14 @@ class CustomerController extends Controller
$customer_detail['namabank'] = $customer['name']; $customer_detail['namabank'] = $customer['name'];
$customer_detail['kodbank'] = $customer['id']; $customer_detail['kodbank'] = $customer['id'];
return response()->json($customer_detail); return response()->json($customer_detail);
} }
else else
{ {
return $customer_detail; return $customer_detail;
} }
} }
} }
public function bankListMobile() public function bankListMobile()
{ {
$bank_array = []; $bank_array = [];
@@ -702,32 +710,32 @@ class CustomerController extends Controller
{ {
array_push($bank_array, array( array_push($bank_array, array(
'kodbank' => $banklist->id, 'kodbank' => $banklist->id,
'namabank' => $banklist->name, 'namabank' => $banklist->name,
)); ));
} }
return response()->json($bank_array); return response()->json($bank_array);
} }
else else
{ {
return response()->json('Data Not Found'); return response()->json('Data Not Found');
} }
} }
} }
public function insertAkaunBankMobile(Request $request) public function insertAkaunBankMobile(Request $request)
{ {
$customer = Customer::on('mysql7') $customer = Customer::on('mysql7')
->where('kplama','=',$request->nokp) ->where('kplama','=',$request->nokp)
->orWhere('kpbaru','=',$request->nokp) ->orWhere('kpbaru','=',$request->nokp)
->first(); ->first();
if(!empty($customer)) if(!empty($customer))
{ {
$customer->kodbank = $request->kodbank; $customer->kodbank = $request->kodbank;
$customer->noakaun = $request->noakaun; $customer->noakaun = $request->noakaun;
$customer->save(); $customer->save();
} }
return response()->json($customer, 200); return response()->json($customer, 200);
} }
@@ -761,7 +769,7 @@ class CustomerController extends Controller
} }
public function blacklistCustomer(Request $request){ public function blacklistCustomer(Request $request){
$blacklist = Blacklist::where('nokp',$request->nokp)->first(); $blacklist = Blacklist::where('nokp',$request->nokp)->first();
return response()->json($blacklist); return response()->json($blacklist);
@@ -778,8 +786,8 @@ class CustomerController extends Controller
->select('kodcaw') ->select('kodcaw')
->where('nokp', '=', $ic) ->where('nokp', '=', $ic)
->first(); ->first();
if($customer) if($customer)
array_push($custcawangan,['kodcaw' => $customer['kodcaw'], 'namacawangan' => $cawangan['details_caw']]); array_push($custcawangan,['kodcaw' => $customer['kodcaw'], 'namacawangan' => $cawangan['details_caw']]);
} }
@@ -805,9 +813,9 @@ class CustomerController extends Controller
return response()->json($dataCustomer); return response()->json($dataCustomer);
} }
public function AdminsearchCustomerByName(Request $request) public function AdminsearchCustomerByName(Request $request)
{ {
$nama = strtoupper($request->nama); $nama = strtoupper($request->nama);
if(empty($nama)) if(empty($nama))
@@ -821,12 +829,12 @@ class CustomerController extends Controller
->take(3) ->take(3)
->get(); ->get();
} }
return response()->json($customer); return response()->json($customer);
} }
public function AdminsearchCustomerByIC(Request $request) public function AdminsearchCustomerByIC(Request $request)
{ {
if(isset($request->kodcaw)) if(isset($request->kodcaw))
{ {
$customer = Customer::on('mysql7') $customer = Customer::on('mysql7')
@@ -841,7 +849,7 @@ class CustomerController extends Controller
->take(3) ->take(3)
->get(); ->get();
} }
return response()->json($customer); return response()->json($customer);
} }
+1 -1
View File
@@ -12,4 +12,4 @@ class PekerjaanController extends Controller
return response()->json($kerja); return response()->json($kerja);
} }
} }
@@ -0,0 +1,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddNotaPekerjaan extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function getActiveDB(){
$config_db = array_keys(config("database.connections"));
$db_connection = array_filter($config_db,function($connection){
try{
if($connection == 'mysql7')
return false;
$db = DB::connection($connection)->getPdo();
return true;
} catch(\Exception $e){
return false;
}
});
return $db_connection;
}
public function up()
{
Schema::connection('mysql7')->table('customer', function (Blueprint $table) {
$table->string('nota_pekerjaan')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('customer', function (Blueprint $table) {
$table->dropColumn('nota_pekerjaan');
});
}
}