adding audit customer

This commit is contained in:
hafifierahman
2022-07-26 22:14:01 +08:00
parent b0f4eafb99
commit 1abdfe524a
5 changed files with 200 additions and 22 deletions
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class AuditCustomer extends Model
{
protected $table = 'audit_customer';
protected $connection = 'mysql7';
protected $fillable = [
'aid',
'username',
'old_data',
'new_data',
'kodcaw',
'created_at',
'updated_at',
'customer_name',
'customer_nokp',
];
}
+68 -18
View File
@@ -10,10 +10,13 @@ use App\Lelong;
use App\Cawangan;
use App\Poskod;
use App\Blacklist;
use App\AuditCustomer;
use Illuminate\Http\Request;
use Carbon\Carbon;
use DB;
class CustomerController extends Controller
{
@@ -373,26 +376,73 @@ class CustomerController extends Controller
}
public function customerUpdateKhazanah($nokp,Request $request){
$poskod = Poskod::on('mysql7')->where('poskod','=',$request->poskod)->first();
DB::connection('mysql7')->beginTransaction();
$customer_update = Customer::on('mysql7')
->where('kplama','=',$nokp)
->orWhere('kpbaru','=',$nokp)
->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']
));
try{
$poskod = DB::connection('mysql7')->table('poskod')->where('poskod','=',$request->poskod)->first();
$customer_info = DB::connection('mysql7')->table('customer')
->select('kodcaw','tarikhdaftar','nopelanggan','kpbaru','kplama','nama','t_lahir','jantina','alamat1','poskod')
->where('kplama','=',$nokp)
->orWhere('kpbaru','=',$nokp)
->get()->toArray();
$old_data = json_encode($customer_info);
$customer_update = DB::connection('mysql7')
->table('customer')
->where('kplama','=',$nokp)
->orWhere('kpbaru','=',$nokp)
->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
));
if($customer_update)
{
$customer_info_new = DB::connection('mysql7')->table('customer')
->select('kodcaw','tarikhdaftar','nopelanggan','kpbaru','kplama','nama','t_lahir','jantina','alamat1','poskod')
->where('kplama','=',$nokp)
->orWhere('kpbaru','=',$nokp)
->get()->toArray();
$new_data = json_encode($customer_info_new);
$audit_customer = DB::connection('mysql7')
->table('audit_customer')
->insert([
'username' => $request->namakhazanah,
'old_data' => $old_data,
'new_data' => $new_data,
'kodcaw' => $request->kodcaw,
'created_at' => Carbon::now()->toDateTimeString(),
'updated_at' => Carbon::now()->toDateTimeString(),
'customer_name' => $request->nama,
'customer_nokp' => $nokp,
]);
}
DB::connection('mysql7')->commit();
return response()->json($customer_update, 200);
}catch (\Exception $e) {
DB::connection('mysql7')->rollback();
return response()->json($e->getMessage(),400);
}
return response()->json($customer_update, 200);
}
public function customerUpdateAdmin(Request $request){
+100 -2
View File
@@ -802,6 +802,89 @@ class LelongController extends Controller
}
}
public function getSenaraiBatchNoTuntutBaki($kodcaw,Request $request)
{
$current = Carbon::now();
$current = new Carbon();
$arraybatch = [];
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$batchleltuntutbaki = BatchLel::on($cawangan['mysql'])
->selectRaw('count(lel.norujukan) as bilangan,batchlel.batchno as batchno,lel.t_lelong as tarikhlelong')
->leftJoin('lelong as lel', 'lel.batchno', '=', 'batchlel.batchno')
->leftJoin('gadai as gad', 'gad.norujukan', '=', 'lel.norujukan')
->whereNotNull('gad.upah12')
->whereNotNull('lel.hargajual')
->whereNull('lel.trkhtuntut')
->where('lel.baki','>',0)
->groupBy('batchlel.batchno')
->get()->toArray();
$batchlelrugi = BatchLel::on($cawangan['mysql'])
->selectRaw('count(lel.norujukan) as bilangan,batchlel.batchno as batchno,lel.t_lelong as tarikhlelong')
->leftJoin('lelong as lel', 'lel.batchno', '=', 'batchlel.batchno')
->leftJoin('gadai as gad', 'gad.norujukan', '=', 'lel.norujukan')
->whereNotNull('gad.upah12')
->whereNotNull('lel.hargajual')
->whereNull('lel.trkhtuntut')
->where('lel.baki','<',0)
->groupBy('batchlel.batchno')
->get()->toArray();
$batchnosama = [];
if(sizeof($batchleltuntutbaki) > 0 && sizeof($batchlelrugi) > 0)
{
foreach($batchleltuntutbaki as $index=>$bl)
{
foreach($batchlelrugi as $index=>$rl)
{
if($bl['batchno'] == $rl['batchno'])
{
array_push($arraybatch,['batchno' => $bl['batchno'], 'bilangantuntutbaki' => $bl['bilangan'], 'bilanganrugi' => $rl['bilangan'],'tarikhlelong' => $bl['tarikhlelong']]);
array_push($batchnosama,$bl['batchno']);
}
}
}
}
$countsama = 0;
foreach($batchleltuntutbaki as $index=>$bl)
{
if($batchnosama)
{
$dif=array_intersect($bl,$batchnosama);
if(!$dif)
{
array_push($arraybatch,['batchno' => $bl['batchno'], 'bilangantuntutbaki' => $bl['bilangan'], 'bilanganrugi' => 0,'tarikhlelong' => $bl['tarikhlelong']]);
}
}
}
foreach($batchlelrugi as $index=>$br)
{
if($batchnosama)
{
$dif=array_intersect($br,$batchnosama);
if(!$dif)
{
array_push($arraybatch,['batchno' => $br['batchno'], 'bilangantuntutbaki' => 0, 'bilanganrugi' => $br['bilangan'],'tarikhlelong' => $br['tarikhlelong']]);
}
}
}
return response()->json($arraybatch);
}
public function getSenaraiTuntutBaki($kodcaw,Request $request){
$current = Carbon::now();
@@ -812,16 +895,31 @@ class LelongController extends Controller
$bulanlepas = $current->subMonth()->toDateString();
$lelong = Lelong::on($cawangan['mysql'])
if($request->jenis == 'tuntutbaki')
{
$lelong = Lelong::on($cawangan['mysql'])
->select('lelong.t_lelong','lelong.norujukan','gadai.nokp','gadai.bakipjm','lelong.bakiupah','lelong.t_jual','lelong.cajlelong','lelong.baki','lelong.cajlain','lelong.gst_hj','lelong.gst_cl','lelong.hargajual')
->leftJoin('gadai', 'gadai.norujukan', '=', 'lelong.norujukan')
->where('baki','>',0)
->where('lelong.t_lelong','>=',$bulanlepas)
->where('batchno',$request->batchno)
->whereNotNull('t_jual')
->whereNull('trkhtuntut')
->orderBy('gadai.t_gadai','asc')
->orderBy('gadai.sirig','asc')
->where('gadai.taglel','=', 1);
}else{
$lelong = Lelong::on($cawangan['mysql'])
->select('lelong.t_lelong','lelong.norujukan','gadai.nokp','gadai.bakipjm','lelong.bakiupah','lelong.t_jual','lelong.cajlelong','lelong.baki','lelong.cajlain','lelong.gst_hj','lelong.gst_cl','lelong.hargajual')
->leftJoin('gadai', 'gadai.norujukan', '=', 'lelong.norujukan')
->where('baki','<',0)
->where('batchno',$request->batchno)
->whereNotNull('t_jual')
->whereNull('trkhtuntut')
->orderBy('gadai.t_gadai','asc')
->orderBy('gadai.sirig','asc')
->where('gadai.taglel','=', 1);
}
$lelonglist = $lelong->get();
foreach($lelonglist as $index=>$lel)
+8 -2
View File
@@ -1121,7 +1121,7 @@ class TebusController extends Controller
->sum('upahdibayar');
$upahlelong = Lelong::on($cawangan['mysql'])
->where([['t_jual','<=',$request->tarikh],['t_jual','>','2013-12-31']])
->where([['t_jual','<=',$request->tarikh],['t_jual','>','2013-12-31'],['t_jual','<=','2022-07-24']])
->whereYear('t_jual','=',$current->year)
->sum('bakiupah');
@@ -1708,7 +1708,13 @@ class TebusController extends Controller
// dd($ansuran);
$total = ($keuntungan + $keuntunganreducing + $ansuran + $bukanansuran);
$upahlelong = Lelong::on($cawangan['mysql'])
->where([['t_jual','<=',$request->tarikh],['t_jual','>','2022-07-24']])
->whereYear('t_jual','=',$current->year)
->sum('bakiupah');
$total = ($keuntungan + $keuntunganreducing + $ansuran + $bukanansuran + $upahlelong);
}
+1
View File
@@ -267,6 +267,7 @@ $router->group(['prefix'=>'api'], function () use ($router){
$router->get('senaraibatch/aktif/{kodcaw}/{fasa}',['uses'=>'LelongController@getSenaraiLelongAktif']);
$router->get('senaraibatch/laporan/{kodcaw}/{fasa}',['uses'=>'LelongController@getSenaraiBatchNoAktif']);
$router->get('details/notislelong/{kodcaw}',['uses'=>'LelongController@DetailsNotisLelong']);
$router->get('senaraituntutbaki/aktif_batch/{kodcaw}/',['uses'=>'LelongController@getSenaraiBatchNoTuntutBaki']);
$router->get('senaraituntutbaki/laporan/{kodcaw}',['uses'=>'LelongController@getSenaraiTuntutBaki']);