From 68f1e90aef13b6504157c59f72056713d2176235 Mon Sep 17 00:00:00 2001 From: Nur Izzati Zulkifli Date: Wed, 15 Mar 2023 12:33:08 +0800 Subject: [PATCH] add report ubah rugi dan ubah home add totalbid --- app/Http/Controllers/LelongController.php | 149 ++++++++++- resources/views/home.blade.php | 15 +- .../lelong/senaraiubahrugilelongnew.blade.php | 37 ++- .../views/pdf/pdfcajrugilelong.blade.php | 251 ++++++++++++++++++ routes/web.php | 1 + 5 files changed, 439 insertions(+), 14 deletions(-) create mode 100644 resources/views/pdf/pdfcajrugilelong.blade.php diff --git a/app/Http/Controllers/LelongController.php b/app/Http/Controllers/LelongController.php index 08cbc750..d8d01624 100644 --- a/app/Http/Controllers/LelongController.php +++ b/app/Http/Controllers/LelongController.php @@ -7210,7 +7210,30 @@ class LelongController extends Controller ->toArray(); array_push($arrayinfo,['laporan' => $laporan,'details' => $details]); } - return view('lelong.senaraiubahrugilelongnew',compact('arraymarhun','marhuns','lelongid','cawid','arrayinfo','total_berat', + + //check button kemaskini + + $lelong = Lelong::with(['cawangan', 'lelongBidJual'])->find($lelongid); + $allCawangan = $lelong->cawangan->keyBy('caw_code'); + $lelongBid = $lelong->lelongBidJual->where('caw_id', '=', $cawid)->groupBy('kodcaw'); + // dd( $lelongBid); + + foreach ($lelongBid as $index => $lelong_bid) { + foreach ($allCawangan as $data => $cawangan) { + if ($data == $index) { + $cawangan['lelongBid'] = $lelong_bid; + } + } + } + + foreach ($lelong->cawangan as $index => $caw) { + $allLelongBid = $caw->lelongBid->where('caw_id', '=', $cawid)->count(); + $settlePayment = $caw->lelongBid->where('status_payment', 1)->where('caw_id', '=', $cawid)->count(); + + $lelong->cawangan[$index]['lelong_laku'] = $allLelongBid; + $lelong->cawangan[$index]['selesai_bayar'] = $settlePayment; + } + return view('lelong.senaraiubahrugilelongnew',compact('lelong','arraymarhun','marhuns','lelongid','cawid','arrayinfo','total_berat', 'total_pinjaman', 'total_upah', 'total_hargaasas', @@ -7260,6 +7283,130 @@ class LelongController extends Controller } + public function reportcajrugilelong(Request $request){ + $total_berat = 0; + $total_pinjaman = 0; + $total_upah = 0; + $total_hargaasas = 0; + $total_bakiupah = 0; + $total_nilaimarhun = 0; + $keuntungan = 0; + $bakilelong = 0; + $total_cazlelong = 0; + $total_bakilelong = 0; + $total_hargajual = 0; + $total_cajlelnew = 0; + $total_rugilelongnew = 0; + $newcajlel= 0; + $newbaki = 0; + $lelongid = $request->lelongid; + $cawid = $request->cawid; + $cajlelong = $request->cajlelong; + // dd($cajlelong); + + $lelonglel = Lelong::with('cawangan')->find($lelongid); + + $cawanganDetail = $lelonglel->cawangan->find($cawid); + + $marhuns = LelongBid::where('caw_id', '=', $cawid) + ->where('lelong_id', '=', $lelongid) + ->where('status_jual', '=', 1) + ->where('baki', '<', 0.00) + ->get(); + // dd($marhuns); + $arraymarhun = []; + foreach ($marhuns as $index1=> $cal) { + $cajlel = $cal['hargajual'] * ($cajlelong/100) ; + $cajlelnew = round($cajlel, 1, 1); + // dd($cajlelnew); + $rugilelongnew = $cal['hargajual'] - $cal['pinjaman'] - $cal['bakiupah'] - $cajlelnew; + // dd($rugilelongnew); + //cajlelong baru + if($rugilelongnew < 0){ + $newbaki = $cajlelnew + $rugilelongnew; + if($newbaki > 0) + { + $newcajlel = $newbaki; + $newbaki = 0; + } + else { + $newcajlel = 0; + // $newbaki = 0; + } + }elseif($rugilelongnew > 0){ + $newcajlel = $cajlelnew; + $newbaki = $rugilelongnew; + } + + array_push($arraymarhun,[ + 'norujukan' => $cal['norujukan'], + 'lelongbid_id' => $cal['id'], + 'tempoh' => $cal['jbg'], + 'berat' => $cal['berat'], + 'nilaimarhun' => $cal['nilaimarhun'], + 'hargaasas' => $cal['hargaasas'], + 'hargajual' => $cal['hargajual'], + 'pinjaman' => $cal['pinjaman'], + 'bakiupah' => $cal['bakiupah'], + 'cajlelong' => $cajlelnew, + 'baki' => $rugilelongnew, + 'cajlelongnew' => $newcajlel, + 'rugilelongnew' => $newbaki, + ]); + $total_berat = $total_berat + $cal['berat']; + $total_pinjaman = $total_pinjaman + $cal['pinjaman']; + $total_hargaasas = $total_hargaasas + $cal['hargaasas']; + $total_nilaimarhun = $total_nilaimarhun + $cal['nilaimarhun']; + $total_bakiupah = $total_bakiupah + $cal['bakiupah']; + $total_cazlelong = $total_cazlelong + $cajlelnew; + $total_bakilelong = $total_bakilelong + $rugilelongnew; + $total_hargajual = $total_hargajual + $cal['hargajual']; + $total_cajlelnew = $total_cajlelnew + $newcajlel; + $total_rugilelongnew = $total_rugilelongnew + $newbaki; + + } + + $arrayinfo = []; + + $lelong_id = Lelong::join('cawangan_lelong','lelong.id','=','cawangan_lelong.lelong_id') + ->where('cawangan_lelong.lelong_id','=',$lelongid) + ->select('lelong_id','tarikh_lelong','lelong.fasa') + ->groupBy('lelong_id') + ->get()->toArray(); + + + foreach($lelong_id as $laporan) + { + $details = CawanganLelong::join('cawangan','cawangan_lelong.caw_id','=','cawangan.id') + ->where('lelong_id',$laporan['lelong_id']) + ->where('caw_id',$cawid) + ->get() + ->toArray(); + array_push($arrayinfo,['laporan' => $laporan,'details' => $details]); + } + $datacaw = Cawangan::where('id','=',$cawid) + ->get(); + + + $pdf = PDF::loadView('pdf.pdfcajrugilelong',compact('datacaw','arraymarhun','marhuns','lelongid','cawid','arrayinfo','total_berat', + 'total_pinjaman', + 'total_upah', + 'total_hargaasas', + 'total_bakiupah', + 'total_nilaimarhun', + 'lelonglel', + 'cawanganDetail', + 'total_cazlelong', + 'total_bakilelong', + 'total_hargajual', + 'total_cajlelnew', + 'total_rugilelongnew','cajlelong')) + ->setPaper('a4','potrait'); + + return $pdf->download('Laporan Perubahan Rugi Lelong.pdf'); + } + + diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index ac2c7230..93f4da47 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -354,6 +354,7 @@ Batch Lelong Tarikh Lelong Cawangan + Jumlah Bidaan (RM) Jumlah Bayaran (RM) Jenis Bayaran Status Bayaran @@ -384,7 +385,19 @@ @endforelse @endforeach - + + @foreach($lel['detailsinfo'] as $details) + + +
+ @forelse($details['listwinner'] as $winner) + {{ number_format($winner['totalBid'], 2, '.', ',') }} +
+ @empty + -
+ @endforelse + @endforeach + @foreach($lel['detailsinfo'] as $details) diff --git a/resources/views/lelong/senaraiubahrugilelongnew.blade.php b/resources/views/lelong/senaraiubahrugilelongnew.blade.php index 0db9f7a3..f088ba9a 100644 --- a/resources/views/lelong/senaraiubahrugilelongnew.blade.php +++ b/resources/views/lelong/senaraiubahrugilelongnew.blade.php @@ -82,7 +82,9 @@ - +
+ Muat Turun PDF +
@csrf @@ -100,12 +102,12 @@ Nilai Marhun Asal (RM) Pembiayaan (RM) Keuntungan (RM) - Caj Lelong (RM) Harga Asas (RM) Harga Jual (RM) - Rugi Lelong (RM) + Caj Lelong Asal (RM) + Baki/(Rugi) Asal (RM) Caj Lelong Baru (RM) - Rugi Lelong Baru (RM) + Baki/(Rugi) Baru (RM) {{-- Tindakan --}} @@ -125,7 +127,7 @@ {{ number_format($marhun['pinjaman'], 2, '.', ',') }} {{ number_format($marhun['bakiupah'], 2, '.', ',') }} {{-- {{ number_format($marhun['cajlelong'], 2, '.', ',') }} --}} - {{ number_format($marhun['cajlelong'], 2, '.', ',') }} + {{ number_format($marhun['hargaasas'], 2, '.', ',') }} {{ number_format($marhun['hargajual'], 2, '.', ',') }} @php @@ -141,6 +143,7 @@ $bakilelong += $marhun['baki']; } @endphp + {{ number_format($marhun['cajlelong'], 2, '.', ',') }} @if($marhun['baki'] > 0) {{number_format($marhun['baki'], 2, '.', ',')}} @elseif($marhun['baki'] < 0 ) @@ -172,19 +175,14 @@ {{ number_format($total_nilaimarhun, 2, '.', ',') }} {{ number_format($total_pinjaman, 2, '.', ',') }} {{ number_format($total_bakiupah, 2, '.', ',') }} - {{ number_format($total_cazlelong, 2, '.', ',') }} {{ number_format($total_hargaasas, 2, '.', ',') }} {{ number_format($total_hargajual, 2, '.', ',') }} + {{ number_format($total_cazlelong, 2, '.', ',') }} @if($total_bakilelong > 0) {{ number_format($total_bakilelong, 2, '.', ',') }} @else ({{number_format(-($total_bakilelong), 2, '.', ',')}}) @endif - {{-- @if($bakilelong > 0) - {{ number_format($bakilelong, 2, '.', ',') }} - @else - ({{number_format(-($bakilelong), 2, '.', ',')}}) - @endif --}} {{ number_format($total_cajlelnew, 2, '.', ',') }} @if($total_rugilelongnew > 0) {{ number_format($total_rugilelongnew, 2, '.', ',') }} @@ -199,7 +197,13 @@
- + @foreach($lelong->cawangan as $data) + @if($data->pivot->export_data_sts == "SUCCESS") + {{-- Selesai Export --}} + @else + + @endif + @endforeach
@@ -241,6 +245,15 @@ dom: 'Bfrtip', buttons: [ 'copy', 'csv', 'excel', 'pdf', 'print' + + { + className: 'btn btn-outline-secondary pl-4 pr-4 btn-sm export', + titleAttr: 'Eksport kpd CSV', + text: '', + action: function(e, dt, node, config) { + $("#exportform").submit(); + } + } ] }); diff --git a/resources/views/pdf/pdfcajrugilelong.blade.php b/resources/views/pdf/pdfcajrugilelong.blade.php new file mode 100644 index 00000000..18c3d331 --- /dev/null +++ b/resources/views/pdf/pdfcajrugilelong.blade.php @@ -0,0 +1,251 @@ + + + + + + + + +
+ @foreach($datacaw as $data) +
SENARAI PERUBAHAN RUGI LELONG: {{$data['caw_name']}}
+ @endforeach +
+ +
+
+
+ @foreach ($arrayinfo as $laporan) +
Batch Lelong: {{ $laporan['laporan']['lelong_id']}}
+ {{-- Fasa Lelong: {{ $laporan['laporan']['fasa']}} --}} +
Tarikh Lelong : @php + $myDateTime = DateTime::createFromFormat('Y-m-d', $laporan['laporan']['tarikh_lelong'] ); + $datez = $myDateTime->format('d-m-Y'); + echo($datez); + @endphp
+ + @endforeach +
Caj Lelong: {{$cajlelong}}%
+
+ + + + + + {{-- --}} + + + + + + + + + + + + {{-- --}} + + + + @php + $rugilelong = 0; + $bakilelong = 0; + @endphp + @foreach ($arraymarhun as $index=> $marhun) + + + + {{-- --}} + + + + + + {{-- --}} + + + + @php + $rugi = 0; + $baki = 0; + if(strpos($marhun['baki'], '-') !== false) + { + $baki = -$marhun['baki']; + $bakilelong += $marhun['baki']; + } + else { + $baki = $marhun['baki']; + $bakilelong += $marhun['baki']; + } + @endphp + + + + + + + {{-- --}} + + + @endforeach + + + + + + + + + + + + + + + + + +
NoNo RujukanNama PelangganTempohBerat (gm)Nilai Marhun Asal (RM)Pembiayaan (RM)Keuntungan (RM)Harga Asas (RM)Harga Jual (RM)Caj Lelong Asal (RM)Baki/(Rugi) Asal (RM)Caj Lelong Baru (RM)Baki/(Rugi) Baru (RM)Tindakan
{{$loop->iteration}} {{ $marhun['norujukan']}}{{ $marhun['nama']['nama']}}{{ number_format($marhun['tempoh'], 2, '.', ',') }}{{ number_format($marhun['berat'], 2, '.', ',') }}{{ number_format($marhun['nilaimarhun'], 2, '.', ',') }}{{ number_format($marhun['pinjaman'], 2, '.', ',') }}{{ number_format($marhun['bakiupah'], 2, '.', ',') }}{{ number_format($marhun['cajlelong'], 2, '.', ',') }}{{ number_format($marhun['hargaasas'], 2, '.', ',') }}{{ number_format($marhun['hargajual'], 2, '.', ',') }}{{ number_format($marhun['cajlelong'], 2, '.', ',') }}@if($marhun['baki'] > 0) + {{number_format($marhun['baki'], 2, '.', ',')}} + @elseif($marhun['baki'] < 0 ) + ({{number_format(-($marhun['baki']), 2, '.', ',')}}) + @endif + + {{ number_format($marhun['cajlelongnew'], 2, '.', ',') }}@if($marhun['rugilelongnew'] > 0) + + {{ number_format($marhun['rugilelongnew'], 2, '.', ',') }} + @else + + ({{number_format(-($marhun['rugilelongnew']), 2, '.', ',')}}) + @endif + +
JUMLAH KESELURUHAN{{ number_format($total_berat, 2, '.', ',') }}{{ number_format($total_nilaimarhun, 2, '.', ',') }}{{ number_format($total_pinjaman, 2, '.', ',') }}{{ number_format($total_bakiupah, 2, '.', ',') }}{{ number_format($total_hargaasas, 2, '.', ',') }}{{ number_format($total_hargajual, 2, '.', ',') }}{{ number_format($total_cazlelong, 2, '.', ',') }}@if($total_bakilelong > 0) + {{ number_format($total_bakilelong, 2, '.', ',') }} + @else + ({{number_format(-($total_bakilelong), 2, '.', ',')}}) + @endif{{ number_format($total_cajlelnew, 2, '.', ',') }}@if($total_rugilelongnew > 0) + {{ number_format($total_rugilelongnew, 2, '.', ',') }} + @else + ({{number_format(-($total_rugilelongnew), 2, '.', ',')}}) + @endif
+ + diff --git a/routes/web.php b/routes/web.php index 92ad29e5..c66f3f83 100644 --- a/routes/web.php +++ b/routes/web.php @@ -185,6 +185,7 @@ Route::group(['prefix'=>'lelong'], function () { Route::get('/ubahrugilelong/{lelongid}/{cawid}', ['as'=>'lelong.ubahrugilelong','uses'=>'LelongController@ubahrugilelong']); Route::post('/cajrugilelong', ['as'=>'lelong.cajrugilelong','uses'=>'LelongController@cajrugilelong']); Route::post('/editcajrugilelong', ['as'=>'lelong.editcajrugilelong','uses'=>'LelongController@editcajrugilelong']); + Route::get('/reportcajrugilelong/{lelongid}/{cawid}/{cajlelong}',['as'=>'lelong.reportcajrugilelong','uses'=>'LelongController@reportcajrugilelong']); }); Route::get('/showsimulasi/{id}',['as'=>'lelong.showsimulasi','uses'=>'LelongController@showsimulasi']);