add report ubah rugi dan ubah home add totalbid

This commit is contained in:
Nur Izzati Zulkifli
2023-03-15 12:33:08 +08:00
parent 1a4ee0aa3e
commit 68f1e90aef
5 changed files with 439 additions and 14 deletions
+148 -1
View File
@@ -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');
}
+14 -1
View File
@@ -354,6 +354,7 @@
<th>Batch Lelong</th>
<th>Tarikh Lelong</th>
<th>Cawangan</th>
<th>Jumlah Bidaan (RM)</th>
<th>Jumlah Bayaran (RM)</th>
<th>Jenis Bayaran</th>
<th>Status Bayaran</th>
@@ -384,7 +385,19 @@
@endforelse
@endforeach
</td>
<td class="text-right">
@foreach($lel['detailsinfo'] as $details)
<a href=""></a>
<span class="m-2">
</span><br>
@forelse($details['listwinner'] as $winner)
{{ number_format($winner['totalBid'], 2, '.', ',') }}
<br>
@empty
- <br>
@endforelse
@endforeach
</td>
<td class="text-right">
@foreach($lel['detailsinfo'] as $details)
<a href=""></a>
@@ -82,7 +82,9 @@
</div>
</div>
</form>
<div class="mb-3">
<a href=" {{ route('lelong.reportcajrugilelong',[$lelongid,$cawid,$cajlelong]) }}" class="btn btn-outline-success">Muat Turun PDF</a>
</div>
<label class="col-6 col-form-label text-left"><b>Caj Lelong : {{$cajlelong}}%</b></label>
<form id="editrugilelong" action="{{route('lelong.editcajrugilelong')}}" method="POST">
@csrf
@@ -100,12 +102,12 @@
<th>Nilai Marhun Asal (RM)</th>
<th>Pembiayaan (RM)</th>
<th>Keuntungan (RM)</th>
<th style="background-color: crimson">Caj Lelong (RM)</th>
<th>Harga Asas (RM)</th>
<th>Harga Jual (RM)</th>
<th style="background-color: crimson">Rugi Lelong (RM)</th>
<th style="background-color: crimson">Caj Lelong Asal (RM)</th>
<th style="background-color: crimson">Baki/(Rugi) Asal (RM)</th>
<th style="background-color: rgb(20, 220, 20)">Caj Lelong Baru (RM)</th>
<th style="background-color: rgb(20, 220, 20)">Rugi Lelong Baru (RM)</th>
<th style="background-color: rgb(20, 220, 20)">Baki/(Rugi) Baru (RM)</th>
{{-- <th>Tindakan</th> --}}
</tr>
</thead>
@@ -125,7 +127,7 @@
<td align = 'right'>{{ number_format($marhun['pinjaman'], 2, '.', ',') }}</td>
<td align = 'right'>{{ number_format($marhun['bakiupah'], 2, '.', ',') }}</td>
{{-- <td align = 'right'>{{ number_format($marhun['cajlelong'], 2, '.', ',') }}</td> --}}
<td align = 'right'><b>{{ number_format($marhun['cajlelong'], 2, '.', ',') }}</b></td>
<td align = 'right'>{{ number_format($marhun['hargaasas'], 2, '.', ',') }}</td>
<td align = 'right'>{{ number_format($marhun['hargajual'], 2, '.', ',') }}</td>
@php
@@ -141,6 +143,7 @@
$bakilelong += $marhun['baki'];
}
@endphp
<td align = 'right'><b>{{ number_format($marhun['cajlelong'], 2, '.', ',') }}</b></td>
<td align = 'right'><b>@if($marhun['baki'] > 0)
{{number_format($marhun['baki'], 2, '.', ',')}}
@elseif($marhun['baki'] < 0 )
@@ -172,19 +175,14 @@
<td align = 'right'><b>{{ number_format($total_nilaimarhun, 2, '.', ',') }}</b></td>
<td align = 'right'><b>{{ number_format($total_pinjaman, 2, '.', ',') }}</b></td>
<td align = 'right'><b>{{ number_format($total_bakiupah, 2, '.', ',') }}</b></td>
<td align = 'right'><b>{{ number_format($total_cazlelong, 2, '.', ',') }}</b></td>
<td align = 'right'><b>{{ number_format($total_hargaasas, 2, '.', ',') }}</b></td>
<td align = 'right'><b>{{ number_format($total_hargajual, 2, '.', ',') }}</b></td>
<td align = 'right'><b>{{ number_format($total_cazlelong, 2, '.', ',') }}</b></td>
<td align = 'right'><b>@if($total_bakilelong > 0)
{{ number_format($total_bakilelong, 2, '.', ',') }}
@else
({{number_format(-($total_bakilelong), 2, '.', ',')}})
@endif</b></td>
{{-- <td align = 'right'><b>@if($bakilelong > 0)
{{ number_format($bakilelong, 2, '.', ',') }}
@else
({{number_format(-($bakilelong), 2, '.', ',')}})
@endif</b></td> --}}
<td align = 'right'><b>{{ number_format($total_cajlelnew, 2, '.', ',') }}</b></td>
<td align = 'right'><b>@if($total_rugilelongnew > 0)
{{ number_format($total_rugilelongnew, 2, '.', ',') }}
@@ -199,7 +197,13 @@
<div class="form-group row">
<label class="col-6 col-form-label text-right"></label>
<div class="col-12" align = "right">
<button type="submit" class="btn btn-success">Kemaskini</button>
@foreach($lelong->cawangan as $data)
@if($data->pivot->export_data_sts == "SUCCESS")
{{-- <td class="text-success">Selesai Export</td> --}}
@else
<button type="submit" class="btn btn-success">Kemaskini</button>
@endif
@endforeach
</div>
</div>
</form>
@@ -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: '<i class="fas fa-download"></i>',
action: function(e, dt, node, config) {
$("#exportform").submit();
}
}
]
});
@@ -0,0 +1,251 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<style>
#sim {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size:10px;
border-collapse: collapse;
width: 100%;
}
#sim td {padding:3px 5px 3px 5px; padding-right:10px;}, #sim th {
border: 1px solid;
padding: 1px;
text-align: left;
}
#sim tr:nth-child(even){}
#sim tr:hover {}
#sim2 th {
text-align: center;
border: 0px solid;
table-layout:auto;
color: black;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
}
* {
box-sizing: border-box;
}
.row {
margin-right:-5px;
margin-right:-5px;
}
.column {
float: right;
width: 100%;
padding: 5px;
}
/* Clearfix (clear floats) */
.row::after {
content: "";
clear: both;
display: table;
}
table {
border-collapse: collapse;
border-spacing: 0;
width: 200%;
border: 0px solid #ddd;
}
td {
text-align: right;
padding: 16px;
}
th{
text-align: center;
padding: 16px;
}
tr:nth-child(even) {
}
.font{
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size:12px;
}
</style>
<style>
/** Define now the real margins of every page in the PDF **/
body {
margin-top: 1cm;
/* margin-left: 2cm; */
/* margin-right: 2cm; */
margin-bottom: 2cm;
}
/** Define the header rules **/
header {
position: fixed;
top: -1cm;
left: 0cm;
right: 0cm;
height: 0cm;
/** Extra personal styles **/
/* background-color: #eaeaea; */
color: black;
text-align: center;
line-height: 1.5cm;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size:15px;
}
/** Define the footer rules **/
footer {
position: fixed;
bottom: 0cm;
left: 0cm;
right: 0cm;
height: 2cm;
/** Extra personal styles **/
/* background-color: #eaeaea; */
color: black;
text-align: center;
line-height: 1.5cm;
}
footer .pagenum:before {
content: counter(page);
}
</style>
<body>
<header>
@foreach($datacaw as $data)
<div class="class="font><u><b><h5>SENARAI PERUBAHAN RUGI LELONG: {{$data['caw_name']}}</h5></b></u></div>
@endforeach
</header>
<footer>
<div class="pagenum-container"><span class="pagenum"></span></div>
</footer>
@foreach ($arrayinfo as $laporan)
<div class="font">Batch Lelong: {{ $laporan['laporan']['lelong_id']}} </div>
{{-- <td><b>Fasa Lelong: {{ $laporan['laporan']['fasa']}} <b></td> --}}
<div class="font">Tarikh Lelong : @php
$myDateTime = DateTime::createFromFormat('Y-m-d', $laporan['laporan']['tarikh_lelong'] );
$datez = $myDateTime->format('d-m-Y');
echo($datez);
@endphp</div>
@endforeach
<div class="font">Caj Lelong: {{$cajlelong}}% </div>
<br>
<table cellspacing="0" cellpadding="5" style="float:right;" border="1" width="100%" height="80" align="left" id="sim">
<thead class="bg-primary text-white">
<tr>
<th>No</th>
<th>No Rujukan</th>
{{-- <th>Nama Pelanggan</th> --}}
<th>Tempoh</th>
<th>Berat (gm)</th>
<th>Nilai Marhun Asal (RM)</th>
<th>Pembiayaan (RM)</th>
<th>Keuntungan (RM)</th>
<th>Harga Asas (RM)</th>
<th>Harga Jual (RM)</th>
<th >Caj Lelong Asal (RM)</th>
<th >Baki/(Rugi) Asal (RM)</th>
<th >Caj Lelong Baru (RM)</th>
<th>Baki/(Rugi) Baru (RM)</th>
{{-- <th>Tindakan</th> --}}
</tr>
</thead>
<tbody>
@php
$rugilelong = 0;
$bakilelong = 0;
@endphp
@foreach ($arraymarhun as $index=> $marhun)
<tr>
<td>{{$loop->iteration}}</td>
<td align = 'left' style="white-space: nowrap;"> <input type="hidden" name="lelongbid_id[]" value="{{ $marhun['lelongbid_id']}}"><input type="hidden" name="norujukan[]" value="{{ $marhun['norujukan']}}">{{ $marhun['norujukan']}}</td>
{{-- <td align = 'left' style="white-space: nowrap;">{{ $marhun['nama']['nama']}}</td> --}}
<td>{{ number_format($marhun['tempoh'], 2, '.', ',') }}</td>
<td align = 'right'>{{ number_format($marhun['berat'], 2, '.', ',') }}</td>
<td align = 'right'>{{ number_format($marhun['nilaimarhun'], 2, '.', ',') }}</td>
<td align = 'right'>{{ number_format($marhun['pinjaman'], 2, '.', ',') }}</td>
<td align = 'right'>{{ number_format($marhun['bakiupah'], 2, '.', ',') }}</td>
{{-- <td align = 'right'>{{ number_format($marhun['cajlelong'], 2, '.', ',') }}</td> --}}
<td align = 'right'>{{ number_format($marhun['hargaasas'], 2, '.', ',') }}</td>
<td align = 'right'>{{ number_format($marhun['hargajual'], 2, '.', ',') }}</td>
@php
$rugi = 0;
$baki = 0;
if(strpos($marhun['baki'], '-') !== false)
{
$baki = -$marhun['baki'];
$bakilelong += $marhun['baki'];
}
else {
$baki = $marhun['baki'];
$bakilelong += $marhun['baki'];
}
@endphp
<td align = 'right'><b>{{ number_format($marhun['cajlelong'], 2, '.', ',') }}</b></td>
<td align = 'right'><b>@if($marhun['baki'] > 0)
{{number_format($marhun['baki'], 2, '.', ',')}}
@elseif($marhun['baki'] < 0 )
({{number_format(-($marhun['baki']), 2, '.', ',')}})
@endif</b>
</td>
<td align = 'right'><b><input type="hidden" name="cajlelongnew[]" value="{{ $marhun['cajlelongnew']}}">{{ number_format($marhun['cajlelongnew'], 2, '.', ',') }}</b></td>
<td align = 'right'><b>@if($marhun['rugilelongnew'] > 0)
<input type="hidden" name="rugilelongnew[]" value="{{ $marhun['rugilelongnew']}}">
{{ number_format($marhun['rugilelongnew'], 2, '.', ',') }}
@else
<input type="hidden" name="rugilelongnew[]" value="{{$marhun['rugilelongnew']}}">
({{number_format(-($marhun['rugilelongnew']), 2, '.', ',')}})
@endif</b></td>
{{-- <td class="text-center">
<input type="checkbox" aria-label="Checkbox for following text input" id="checkboxdata[]" name="checkboxdata[]" value="{{ $marhun['norujukan'] }}">
</td> --}}
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<td colspan="3"><b>JUMLAH KESELURUHAN</b></td>
<td align = 'right'><b><b>{{ number_format($total_berat, 2, '.', ',') }}</b></td>
<td align = 'right'><b>{{ number_format($total_nilaimarhun, 2, '.', ',') }}</b></td>
<td align = 'right'><b>{{ number_format($total_pinjaman, 2, '.', ',') }}</b></td>
<td align = 'right'><b>{{ number_format($total_bakiupah, 2, '.', ',') }}</b></td>
<td align = 'right'><b>{{ number_format($total_hargaasas, 2, '.', ',') }}</b></td>
<td align = 'right'><b>{{ number_format($total_hargajual, 2, '.', ',') }}</b></td>
<td align = 'right'><b>{{ number_format($total_cazlelong, 2, '.', ',') }}</b></td>
<td align = 'right'><b>@if($total_bakilelong > 0)
{{ number_format($total_bakilelong, 2, '.', ',') }}
@else
({{number_format(-($total_bakilelong), 2, '.', ',')}})
@endif</b></td>
<td align = 'right'><b>{{ number_format($total_cajlelnew, 2, '.', ',') }}</b></td>
<td align = 'right'><b>@if($total_rugilelongnew > 0)
{{ number_format($total_rugilelongnew, 2, '.', ',') }}
@else
({{number_format(-($total_rugilelongnew), 2, '.', ',')}})
@endif</b></td>
</tr>
</tfoot>
</table>
</body>
+1
View File
@@ -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']);