diff --git a/app/Http/Controllers/LelongController.php b/app/Http/Controllers/LelongController.php index e3dab427..e15a2510 100644 --- a/app/Http/Controllers/LelongController.php +++ b/app/Http/Controllers/LelongController.php @@ -620,6 +620,7 @@ class LelongController extends Controller $lelongbidmarhun->bil = $simbidmarhun->bil; $lelongbidmarhun->marhun = $simbidmarhun->marhun; $lelongbidmarhun->nota = $simbidmarhun->nota; + $lelongbidmarhun->old_marhun = $simbidmarhun->marhun; $lelongbidmarhun->old_karat = $simbidmarhun->karat; $lelongbidmarhun->old_berat = $simbidmarhun->berat; $lelongbidmarhun->old_harga = $simbidmarhun->harga; diff --git a/app/Http/Controllers/MarhunController.php b/app/Http/Controllers/MarhunController.php index e475e46f..e9b7b021 100644 --- a/app/Http/Controllers/MarhunController.php +++ b/app/Http/Controllers/MarhunController.php @@ -1730,10 +1730,11 @@ class MarhunController extends Controller $user = Auth::user(); - $cawangan = Pengesahan::join('users', 'pengesahan.diminta_oleh', 'users.id') - ->where('pengesahan.lelong_id', $id) + $cawangan = Pengesahan::where('pengesahan.lelong_id', $id) + ->where('pengesahan.status', 1) ->whereNotNull('pengesahan.disahkan_oleh') - ->select('pengesahan.diminta_oleh','pengesahan.disahkan_oleh', 'pengesahan.disahkan_pada', 'pengesahan.norujukan', 'pengesahan.lelong_id', 'users.id as user_id', 'users.name', 'users.username', 'users.kodcaw') + ->select('pengesahan.lelongbid_id','pengesahan.diminta_oleh','pengesahan.disahkan_oleh', 'pengesahan.disahkan_pada', 'pengesahan.norujukan', 'pengesahan.lelong_id') + ->orderBy('pengesahan.lelongbid_id') ->distinct() ->get(); // dd($cawangan); @@ -1741,6 +1742,7 @@ class MarhunController extends Controller foreach($cawangan as $index1=>$caw) { // dd($caw); + $getpengesahan = Cawangan::where('caw_code', $caw['kodcaw'])->first(); // dd($getpengesahan); @@ -1748,9 +1750,22 @@ class MarhunController extends Controller $getdimintaoleh = User::where('id', $caw['diminta_oleh'])->first(); // dd($getdisahkanoleh); - $cawangan[$index1]['namacaw'] = $getpengesahan['caw_name']; + // dd(/$caw['lelongbid_id']); + $status = Pengesahan::where('lelongbid_id', $caw['lelongbid_id']) + ->select('id as sahid','status_ubah', 'request_karat', 'request_berat', 'request_marhun') + ->get(); + // dump($status); + + // $marhun= LelongBidMarhun::where('lelongbid_id','=',$caw['lelongbid_id']) + // ->get(); + $marhuns = LelongBidMarhun::where('lelongbid_id', $caw['lelongbid_id']) + ->get()->toArray(); + // dd($marhuns); + // $cawangan[$index1]['namacaw'] = $getpengesahan['caw_name']; $cawangan[$index1]['disahkan_oleh'] = $getdisahkanoleh['name']; $cawangan[$index1]['diminta_oleh'] = $getdimintaoleh['name']; + $cawangan[$index1]['detailmarhun']=$status; + $cawangan[$index1]['detail']=$marhuns; } return view('pengesahan.listperubahanmutumarhun', compact('cawangan', 'id')); @@ -2386,5 +2401,7 @@ class MarhunController extends Controller } + + } diff --git a/app/Http/Controllers/NotisController.php b/app/Http/Controllers/NotisController.php index b4820721..fbce6251 100644 --- a/app/Http/Controllers/NotisController.php +++ b/app/Http/Controllers/NotisController.php @@ -183,7 +183,7 @@ class NotisController extends Controller $pdf = PDF::loadView('pdf.jananotis',compact('marhuns','lelong_id','lelongid','caw','tarikh_cetak','customer','listsag')) ->setPaper('a4', 'potrait'); - return $pdf->download('Penjanaan Notis Fasa 1: ID Lelong '.$lelong_id.'.pdf'); + return $pdf->download('Penjanaan Notis Fasa 1:Batch Lelong '.$lelong_id.'.pdf'); } @@ -386,7 +386,7 @@ class NotisController extends Controller $pdf = PDF::loadView('pdf.jananotisfasa2',compact('marhuns','lelong_id','lelongid','caw','tarikh_cetak','customer','listsag')) ->setPaper('a4', 'potrait'); - return $pdf->download('Penjanaan Notis Fasa 2: ID Lelong '.$lelong_id.'.pdf'); + return $pdf->download('Penjanaan Notis Fasa 2:Batch Lelong '.$lelong_id.'.pdf'); } diff --git a/app/Http/Controllers/PenggunaController.php b/app/Http/Controllers/PenggunaController.php index da6485aa..fe55e4e1 100644 --- a/app/Http/Controllers/PenggunaController.php +++ b/app/Http/Controllers/PenggunaController.php @@ -72,40 +72,51 @@ class PenggunaController extends Controller 'username' => 'required|string|unique:users' ]); - if ($validator->fails()) { - $errors = [ - 'success' => "error", - 'message' => $validator->errors() + // if ($validator->fails()) { + // $errors = [ + // 'success' => "error", + // 'message' => $validator->errors() - ]; + // ]; - return redirect()->route('pengguna.index') - ->with('message', 'Sila Masukkan Email Yang Sah'); } + // return redirect()->route('pengguna.index') + // ->with('message', 'Sila Masukkan Email Yang Sah'); } - $user = new User; - $user->name = $request->name; - $user->username = $request->username; - $user->kodcaw = $request->caw; - $user->status = 'active'; - $user->t_daftar = $currentdate; - $user->email = $request->email; - $user->email_verified_at = $currentdate; - $user->password = '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi'; //password - $user->user_type = 1; - $user->save(); + //check if user already existed + $check = User::where('username',$request->username) + ->orWhere('email',$request->email) + ->first(); - $allroles = Role::all()->pluck('name'); - $arraytaraf = []; - foreach($allroles as $index=>$taraf) { - $req = 'taraf'.$taraf; - if($request->$req) + if($check) { - array_push($arraytaraf,$taraf); + return redirect()->route('pengguna.index')->with('failed','Maaf, Nama Pengguna / Emel Berikut Telah Wujud !'); + } else { + $user = new User; + $user->name = $request->name; + $user->username = $request->username; + $user->kodcaw = $request->caw; + $user->status = 'active'; + $user->t_daftar = $currentdate; + $user->email = $request->email; + $user->email_verified_at = $currentdate; + $user->password = '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi'; //password + $user->user_type = 1; + $user->save(); + + $allroles = Role::all()->pluck('name'); + $arraytaraf = []; + foreach($allroles as $index=>$taraf) { + $req = 'taraf'.$taraf; + if($request->$req) + { + array_push($arraytaraf,$taraf); + } + } + $user->syncRoles($arraytaraf); + return redirect()->route('pengguna.index') + ->with('success', 'Pengguna Berjaya Disimpan'); } - } - $user->syncRoles($arraytaraf); - return redirect()->route('pengguna.index') - ->with('success', 'Pengguna Berjaya Disimpan'); + } public function store(Request $request) diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 7ffe9ca1..106353f2 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -33,6 +33,7 @@ use App\Models\Resit; use App\Models\Customer; use App\Models\LelongTebus; use App\Models\Pengesahan; +use App\Models\TransaksiKeuntungan; use Carbon\Carbon; @@ -649,10 +650,63 @@ class ReportController extends Controller ->setPaper('a4','potrait'); return $pdf->download('Laporan Simulasi Cawangan.pdf'); - + } + public function simulasireportbycust($simulasi_id, $cawid) + { + $keuntungan = 0; + $arraylistgadai = 0; + + $simulasilel = Simulasi::with('cawangan')->find($simulasi_id); + $cawname = Cawangan::where('id','=',$cawid)->first(); + + $cawanganDetail = $simulasilel->cawangan->find($cawid); + + $marhun = SimulasiBid::join('cawangan', 'simulasibid.caw_id', '=', 'cawangan.id') + ->where('simulasi_id','=',$simulasi_id) + ->where('caw_id','=',$cawid); + + $arraynorujukan = $marhun->pluck('norujukan')->toArray(); + $datasimulasi = $marhun->get(); + $marhuns = Gadai::on($datasimulasi[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan) + ->select('nokp') + ->groupBy('nokp')->get(); + // dd($datagadai); + $arraysag = []; + + foreach($marhuns as $index1=>$cal) + { + $customer = Customer::where('kpbaru','=',$cal['nokp']) + ->orWhere('kplama','=',$cal['nokp']) + ->first(); + // dd($customer); + + $listsag = Gadai::on($datasimulasi[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan) + ->where('nokp','=',$cal['nokp']) + ->get(); + // dd($listgadai); + foreach($listsag as $index=>$listing){ + $ktlhbyr = TransaksiKeuntungan::on('main')->where('norujukan','=',$listing['norujukan'])->sum('bayaran_keuntungan'); + // dd($ktlhbyr); + $total_untung_rebet = TransaksiKeuntungan::on('main')->where('norujukan','=',$listing['norujukan'])->sum('keuntungan_rebet'); + $total_untung_asal = TransaksiKeuntungan::on('main')->where('norujukan','=',$listing['norujukan'])->sum('bayaran_keuntungan'); + $beza_keuntungan = $total_untung_asal - $total_untung_rebet; + $keuntungan = bcdiv(($listing['tempoh']-$listing['tempohbayar'])*$listing['kadarupah']/100*$listing['bakipjm'],1,1)-$beza_keuntungan; + // dd($keuntungan); + $listsag[$index]['ktlhbyr'] = $ktlhbyr; + $listsag[$index]['keuntungan'] = $keuntungan; + } + $marhuns[$index1]['nama'] = $customer; + $marhuns[$index1]['listsag'] = $listsag; + + } + $pdf = PDF::loadView('pdf.simulasireportbycust',compact('simulasilel','cawanganDetail','marhuns','simulasi_id','cawid','ktlhbyr','cawname')) + ->setPaper('a4','potrait'); + + return $pdf->download('Laporan Simulasi Cawangan by Pelanggan.pdf'); + } public function lelongreport ($lelongid, $cawid){ @@ -770,33 +824,71 @@ class ReportController extends Controller // return view('lelong.senaraimarhun',compact('arraymarhun','marhuns','lelongid','cawid','arrayinfo')); } + public function lapubahmarhunlelong (){ - public function lapubahmarhunlelongindex (){ - - $arraydetails = []; - - $laporan= Pengesahan::join('lelongbidmarhun','pengesahan.lelongbidmarhun_id','=','lelongbidmarhun.id') - ->join('lelongbid','lelongbid.norujukan','=','pengesahan.norujukan') - ->select('pengesahan.norujukan','pengesahan.lelong_id','lelongbid.caw_id','pengesahan.diminta_pada','pengesahan.disahkan_oleh','pengesahan.disahkan_pada','pengesahan.diminta_oleh','pengesahan.status','pengesahan.status_ubah','lelongbidmarhun.old_karat','lelongbidmarhun.karat','lelongbidmarhun.old_berat','lelongbidmarhun.berat','lelongbid.kodcaw','lelongbid.norujukan','lelongbid.lelong_id') - ->whereNotNull('pengesahan.disahkan_oleh') - ->orderBy('pengesahan.id') + $arraydetails = []; + + $laporan= Lelong::join('cawangan_lelong','lelong.id','=','cawangan_lelong.lelong_id') + ->join('pengesahan','lelong.id','=','pengesahan.lelong_id') + ->select('cawangan_lelong.lelong_id','tarikh_lelong','lelong.fasa') + ->distinct() + ->orderBy('cawangan_lelong.lelong_id') ->get() ->toArray(); + // dd($laporan); - foreach($laporan as $lap) //stop here 01.09.2022 - { - $details = CawanganLelong ::join('cawangan','cawangan_lelong.caw_id','=','cawangan.id') - ->where('lelong_id',$lap['lelong_id']) - ->where('caw_id',$lap['caw_id']) + + foreach($laporan as $brg) + { + $details = CawanganLelong::join('cawangan','cawangan_lelong.caw_id','=','cawangan.id') + ->where('lelong_id', $brg['lelong_id']) ->distinct() ->orderBy('lelong_id') ->get() ->toArray(); - array_push($arraydetails, ['lap' =>$lap,'details' =>$details]); - - } + array_push($arraydetails,['brg' => $brg, 'detailsbrg' => $details ]); + } - return view('marhun.ubahmarhun', compact('laporan','arraydetails')); + + return view('marhun.ubahmarhuncaw', compact('arraydetails')); + + } + + + public function lapubahmarhunlelongindex ($lelong_id, $kodcaw){ + + $cawangan = Pengesahan::where('pengesahan.lelong_id', $lelong_id) + ->where('pengesahan.status', 1) + ->whereNotNull('pengesahan.disahkan_oleh') + ->select('pengesahan.lelongbid_id','pengesahan.diminta_oleh','pengesahan.disahkan_oleh', 'pengesahan.disahkan_pada', 'pengesahan.norujukan', 'pengesahan.lelong_id') + ->orderBy('pengesahan.lelongbid_id') + ->distinct() + ->get(); + + foreach($cawangan as $index1=>$caw) + { + + $getpengesahan = Cawangan::where('caw_code', $kodcaw)->first(); + + $getdisahkanoleh = User::where('id', $caw['disahkan_oleh'])->first(); + $getdimintaoleh = User::where('id', $caw['diminta_oleh'])->first(); + + $status = Pengesahan::where('lelongbid_id', $caw['lelongbid_id']) + ->select('id as sahid','status_ubah', 'request_karat', 'request_berat', 'request_marhun') + ->get(); + + + $marhuns = LelongBidMarhun::where('lelongbid_id', $caw['lelongbid_id']) + ->get() + ->toArray(); + $cawangan[$index1]['namacaw'] = $getpengesahan['caw_name']; + $cawangan[$index1]['disahkan_oleh'] = $getdisahkanoleh['name']; + $cawangan[$index1]['diminta_oleh'] = $getdimintaoleh['name']; + $cawangan[$index1]['detailmarhun']=$status; + $cawangan[$index1]['detail']=$marhuns; + } + + return view('marhun.ubahmarhun', compact('cawangan','lelong_id','getpengesahan')); } public function exportubahmarhun (){ diff --git a/app/Models/Lelong.php b/app/Models/Lelong.php index 63cf76b2..8f12511d 100644 --- a/app/Models/Lelong.php +++ b/app/Models/Lelong.php @@ -40,4 +40,9 @@ class Lelong extends Model { return $this->hasMany(LelKarat::class, 'lelong_id', 'id'); } + + public function pengesahan() + { + return $this->hasMany(Pengesahan::class,'lelong_id','id'); + } } diff --git a/app/Models/Pengesahan.php b/app/Models/Pengesahan.php index a3814af1..c8855205 100644 --- a/app/Models/Pengesahan.php +++ b/app/Models/Pengesahan.php @@ -23,7 +23,13 @@ class Pengesahan extends Model 'status_ubah' ]; - public function lelongbidmarhun(){ + public function lelongbidmarhun() + { return $this->belongsTo(LelongBidMarhun::class, 'lelongbidmarhun_id' , 'id'); } + + public function lelong() + { + return $this->belongsTo(Lelong::class,'lelong_id','id'); + } } diff --git a/database/migrations/2021_12_14_041557_create_lelongs_table.php b/database/migrations/2021_12_14_041557_create_lelongs_table.php index 82311997..1dc55c27 100644 --- a/database/migrations/2021_12_14_041557_create_lelongs_table.php +++ b/database/migrations/2021_12_14_041557_create_lelongs_table.php @@ -123,7 +123,8 @@ class CreateLelongsTable extends Migration $table->bigIncrements('id'); $table->unsignedBigInteger('lelongbid_id')->unsigned(); $table->decimal('bil', $precision = 3, $scale = 0); - $table->string('marhun'); + $table->string('old_marhun'); + $table->string('marhun'); $table->string('nota')->nullable(); $table->string('old_karat'); $table->string('karat'); diff --git a/resources/views/account/senarailelongan.blade.php b/resources/views/account/senarailelongan.blade.php index 78d07568..918cb77d 100644 --- a/resources/views/account/senarailelongan.blade.php +++ b/resources/views/account/senarailelongan.blade.php @@ -15,7 +15,7 @@ No - ID Lelong + Batch Lelong Tarikh Lelong Cawangan Fasa diff --git a/resources/views/home.blade copy 2.php b/resources/views/home.blade copy 2.php index f2422eb1..1bb08742 100644 --- a/resources/views/home.blade copy 2.php +++ b/resources/views/home.blade copy 2.php @@ -55,7 +55,7 @@ No - ID Lelong + Batch Lelong Cawangan Tarikh Lelong Harga Emas Asas @@ -138,7 +138,7 @@ No - ID Lelong + Batch Lelong T.Lelong Fasa Cawangan @@ -286,7 +286,7 @@ No - ID Lelong + Batch Lelong Tarikh Lelong Cawangan Status Export @@ -347,7 +347,7 @@ No - ID Lelong + Batch Lelong Tarikh Lelong {{-- Cawangan --}} Nama diff --git a/resources/views/home.blade copy.php b/resources/views/home.blade copy.php index 36e85f03..5fbbd5d6 100644 --- a/resources/views/home.blade copy.php +++ b/resources/views/home.blade copy.php @@ -32,7 +32,7 @@ No - ID Lelong + Batch Lelong T.Lelong Fasa Cawangan diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index b8c47e01..26f7991d 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -113,7 +113,7 @@ No - ID Lelong + Batch Lelong Cawangan Tarikh Lelong Harga Emas Asas @@ -196,7 +196,7 @@ No - ID Lelong + Batch Lelong T.Lelong Fasa Cawangan @@ -321,7 +321,7 @@ No - ID Lelong + Batch Lelong Tarikh Lelong Cawangan Status Export @@ -382,7 +382,7 @@ No - ID Lelong + Batch Lelong Tarikh Lelong {{-- Cawangan --}} Nama diff --git a/resources/views/home/senarailelongubahmutu.blade.php b/resources/views/home/senarailelongubahmutu.blade.php index 1d408c52..25011b97 100644 --- a/resources/views/home/senarailelongubahmutu.blade.php +++ b/resources/views/home/senarailelongubahmutu.blade.php @@ -16,7 +16,7 @@ No - ID Lelong + Batch Lelong Cawangan Tarikh Lelong Harga Emas Asas diff --git a/resources/views/home00.blade.php b/resources/views/home00.blade.php index edfcef44..3213870f 100644 --- a/resources/views/home00.blade.php +++ b/resources/views/home00.blade.php @@ -55,7 +55,7 @@ No - ID Lelong + Batch Lelong Cawangan Tarikh Lelong Harga Emas Asas @@ -138,7 +138,7 @@ No - ID Lelong + Batch Lelong T.Lelong Fasa Cawangan @@ -271,7 +271,7 @@ No - ID Lelong + Batch Lelong Tarikh Lelong Cawangan Status Export @@ -332,7 +332,7 @@ No - ID Lelong + Batch Lelong Tarikh Lelong {{-- Cawangan --}} Nama diff --git a/resources/views/homexxxx.blade.php b/resources/views/homexxxx.blade.php index b0f7f118..3035e448 100644 --- a/resources/views/homexxxx.blade.php +++ b/resources/views/homexxxx.blade.php @@ -55,7 +55,7 @@ No - ID Lelong + Batch Lelong Cawangan Tarikh Lelong Harga Emas Asas @@ -139,7 +139,7 @@ No - ID Lelong + Batch Lelong T.Lelong Fasa Cawangan @@ -263,7 +263,7 @@ No - ID Lelong + Batch Lelong Tarikh Lelong Cawangan Status Export @@ -326,7 +326,7 @@ No - ID Lelong + Batch Lelong Tarikh Lelong {{-- Cawangan --}} Nama diff --git a/resources/views/includes/sidebar.blade.php b/resources/views/includes/sidebar.blade.php index 1cdcde72..3bdea217 100644 --- a/resources/views/includes/sidebar.blade.php +++ b/resources/views/includes/sidebar.blade.php @@ -163,7 +163,7 @@