update report using relation, fix error jana notis 30 hari

This commit is contained in:
Amirah22
2022-11-08 09:53:47 +08:00
parent 3d614dd677
commit 3a2128cff7
6 changed files with 70 additions and 65 deletions
@@ -81,7 +81,6 @@ class ReportCawanganController extends Controller
->where('lelongbid.lelong_id', $lelong_id)
->where('lelongbid.kodcaw','=',$user['kodcaw'])
->get()->toArray();
// dd($brglelongcaw);
$keuntungan=0;
$total_hargaasas = 0;
+8 -44
View File
@@ -89,23 +89,12 @@ class ReportController extends Controller
$arrayinfo = [];
$lelongid = Lelong::join('cawangan_lelong','lelong.id','=','cawangan_lelong.lelong_id')
->join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
->where('cawangan_lelong.lelong_id','=',$lelong_id)
->where('cawangan.caw_code', $kodcaw)
->select('lelong_id','tarikh_lelong','lelong.fasa')
->groupBy('lelong_id')
->get()->toArray();
$test = Lelong::with(['cawangan','lelongBid'])
->find($lelong_id);
foreach($lelongid as $laporan)
{
$details = CawanganLelong::join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
->where('lelong_id',$laporan['lelong_id'])
->where('cawangan.caw_code', $kodcaw)
->get()
->toArray();
array_push($arrayinfo,['laporan' => $laporan,'details' => $details]);
}
$cawangan = $test->cawangan;
$lelong_bid = $test->lelongBid;
$keuntungan=0;
@@ -113,39 +102,14 @@ class ReportController extends Controller
$total_berat = 0;
$marhun = LelongBid::join('cawangan', 'lelongbid.caw_id', '=', 'cawangan.id')
->where('lelong_id','=',$lelong_id)
->where('lelongbid.kodcaw', $kodcaw);
$arraynorujukan = $marhun->pluck('norujukan')->toArray();
$datasimulasi = $marhun->get();
foreach($datasimulasi as $index=>$totharga){
$total_hargaasas = $lelong_bid->sum('hargaasas');
$total_berat = $lelong_bid->sum('berat');
$total_hargaasas = $total_hargaasas + $totharga['hargaasas'];
$total_berat = $total_berat + $totharga['berat'];
}
$marhuns = Gadai::on($datasimulasi[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan)
->get()->toArray();
// dd($marhuns);
foreach($marhuns as $index1=>$upah)
{
$listsag = Gadai::on($datasimulasi[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan)
->where('nokp','=',$upah['nokp'])
->get();
}
$marhuns[$index1]['listsag'] = $listsag;
$pdf = PDF::loadView('pdf.listlelong',compact('arrayinfo','marhuns','lelong_id','keuntungan','total_hargaasas',
'total_berat','datasimulasi'))
$pdf = PDF::loadView('pdf.listlelong',compact('cawangan','lelong_bid','total_hargaasas','total_berat'))
->setPaper('a4', 'potrait');
return $pdf->download('Senarai Barang Lelong.pdf');
+20 -4
View File
@@ -31,6 +31,8 @@ use App\Models\CawanganLelong;
use App\Models\LelongBid;
use App\Models\LelongBidMarhun;
use App\Models\LelKarat;
use App\Models\Customer;
use DateTime;
@@ -282,15 +284,28 @@ class TamatKontController extends Controller
foreach($getsurat as $index1=>$surats)
{
$senarai = Gadai::on($user->kodcaw)
// join('cawangan', 'gadai.kodcaw', '=', 'cawangan.caw_code')
$customer = Customer::where('kpbaru','=',$surats['nokp'])
->orWhere('kplama','=',$surats['nokp'])
->get();
$listsag = Gadai::on($user->kodcaw)
->where('norujukan', $surats['norujukan'])
->get();
$ktlhbyr = $surats['hargajualan']-$surats['bakihargajualan'];
// foreach($listsag as $index=>$listing){
// $bayaran = $listing['hargajualan'] - $listing['bakihargajualan'];
// }
// $ktlhbyr = $surats['hargajualan']-$surats['bakihargajualan'];
$getsurat[$index1]['list_norujukan'] = $senarai;
$getsurat[$index1]['nama'] = $customer;
$getsurat[$index1]['ktlhbyr'] = $ktlhbyr;
}
@@ -303,7 +318,8 @@ class TamatKontController extends Controller
't_gadais',
't_anggaran',
'bil_lelongcaw',
'ktlhbyr'));
'ktlhbyr'
));
+5
View File
@@ -61,4 +61,9 @@ class Cawangan extends Model
return $this->hasMany(LelongBid::class, 'caw_id', 'id');
}
// public function lelong()
// {
// return $this->belongsToMany(Lelong::class, 'cawangan_lelong', 'caw_id', 'lelong_id');
// }
}
+33 -12
View File
@@ -46,6 +46,7 @@
<th>Bil</th>
<th>No Rujukan</th>
<th>No Kad Pengenalan</th>
<th>No Telefon</th>
<th>Tempoh</th>
<th>Berat (gm)</th>
<th>Pembiayaan (RM)</th>
@@ -54,22 +55,42 @@
<th>Keuntungan Telah Bayar (RM)</th>
</tr>
</thead>
@foreach($getsurat as $surat)
@foreach($getsurat as $index1=> $notis)
<tr>
<td>{{ $loop->iteration }}</td>
<td>{{ $surat['list_norujukan'][0]['norujukan'] }}</td>
<td>{{ $surat['list_norujukan'][0]['nokp'] }}</td>
<td>{{ $surat['list_norujukan'][0]['tempoh'] }}</td>
<td>{{ $surat['list_norujukan'][0]['berat'] }}</td>
<td>{{ $surat['list_norujukan'][0]['pinjaman'] }}</td>
<td>{{ $surat['list_norujukan'][0]['bakipjm'] }}</td>
<td>{{ $surat['list_norujukan'][0]['bakiupah'] }}</td>
<td>{{ $notis['norujukan'] }}</td>
<td>{{ $notis['nokp'] }}</td>
<td>6{{ $notis['nama'][0]['telefon'] }}</td>
<td>{{ $notis['tempoh'] }}</td>
<td>{{ $notis['berat'] }}</td>
<td>{{ $notis['pinjaman'] }}</td>
<td>{{ $notis['bakipjm'] }}</td>
<td>{{ $notis['bakiupah'] }}</td>
<td>{{ number_format($notis['ktlhbyr'] , 2, '.', ',')}}</td>
<td>{{ number_format($surat['ktlhbyr'] , 2, '.', ',')}}</td>
@endforeach
</tr>
@endforeach
{{-- @foreach($getsurat as $surat)
<tr>
<td>{{ $loop->iteration }}</td>
<td>{{ $surat['list_norujukan'][0]['norujukan'] }}</td>
<td>{{ $surat['list_norujukan'][0]['nokp'] }}</td>
<td>60{{ $surat['list_norujukan'][0]['telefon'] }}</td>
<td>{{ $surat['list_norujukan'][0]['tempoh'] }}</td>
<td>{{ $surat['list_norujukan'][0]['berat'] }}</td>
<td>{{ $surat['list_norujukan'][0]['pinjaman'] }}</td>
<td>{{ $surat['list_norujukan'][0]['bakipjm'] }}</td>
<td>{{ $surat['list_norujukan'][0]['bakiupah'] }}</td>
<td>{{ number_format($surat['ktlhbyr'] , 2, '.', ',')}}</td>
</tr>
@endforeach --}}
</div>
</div>
+4 -4
View File
@@ -86,7 +86,7 @@ tr:nth-child(even) {
</tr>
</table>
<table cellspacing="" cellpadding="5" text-align="left" border="0" height="25" align="left" id="sim">
{{-- <table cellspacing="" cellpadding="5" text-align="left" border="0" height="25" align="left" id="sim">
<thead>
<br>
<tr>
@@ -105,7 +105,7 @@ tr:nth-child(even) {
@endforeach
</tr>
</thead>
</table>
</table> --}}
<br>
@@ -121,14 +121,14 @@ tr:nth-child(even) {
</tr>
</thead>
@foreach ($marhuns as $index=> $details)
@foreach ($lelong_bid as $index=> $details)
<tr>
<td width="5%" align="center">{{ $loop->iteration }} </td>
<td width="14%" align="center">{{ $details['norujukan']}}</td>
<td width="14%" align="center">{{ $details['marhun']}}</td>
<td width="17%" align="center">{{ number_format($details['berat'], 2, '.', ',') }}</td>
<td>{{ $datasimulasi[$index]['hargaasas'] }}</td>
<td width="17%" align="center">{{ number_format($details['hargaasas'], 2, '.', ',') }}</td>
</tr>
@endforeach