Merge branch 'amirah' into 'main'

excel jana notis

See merge request online-sistem1/lelong!147
This commit is contained in:
Nur Izzati Zulkifli
2022-08-07 08:56:43 +00:00
3 changed files with 72 additions and 70 deletions
+43 -44
View File
@@ -186,64 +186,63 @@ class NotisController extends Controller
public function listnotis(Request $request){
$lelong_id = $request->lelong_id;
$user = Auth::user();
$caw = Cawangan::where('caw_code','=',$user->kodcaw)
->first();
$lelong_id = $request->lelong_id;
$senarai = LelongBid::where('lelongbid.kodcaw','=',$user->kodcaw)
->where('lelongbid.lelong_id', $lelong_id);
$arraysenarai = $senarai->pluck('norujukan')->toArray();
$datasenarai = $senarai->get();
$gadaicaw = Gadai::on($datasenarai[0]['kodcaw'])->whereIn('norujukan',$arraysenarai)
->where('gadai.kodcaw','=',$user->kodcaw)
->get()->toArray();
$bayaran=0;
foreach($gadaicaw as $index1=>$pay)
{
$bayaran = $pay['hargajualan'] - $pay['bakihargajualan'];
$arraydetails = [];
$caw = Cawangan::where('caw_code','=',$user->kodcaw)
->first();
$lelong_id = $lelong_id;
$marhun = LelongBid::join('cawangan', 'lelongbid.caw_id', '=', 'cawangan.id')
->where('lelong_id','=',$lelong_id)
->where('lelongbid.kodcaw','=',$user->kodcaw);
$arraynorujukan = $marhun->pluck('norujukan')->toArray();
$datalelong = $marhun->get();
$marhuns = Gadai::on($datalelong[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan)
->select('nokp')
->groupBy('nokp')
->get();
// dd($marhuns);
$arraysag = [];
foreach($marhuns as $index1=>$cal){
$customer = Customer::where('kpbaru','=',$cal['nokp'])
->orWhere('kplama','=',$cal['nokp'])
->get();
$listsag = Gadai::on($datalelong[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan)
->where('nokp','=',$cal['nokp'])
->get();
// dd($listgadai);
foreach($listsag as $index=>$listing){
$bayaran = $listing['hargajualan'] - $listing['bakihargajualan'];
}
$marhuns[$index1]['nama'] = $customer;
$marhuns[$index1]['listsag'] = $listsag;
// dd($marhuns[$index1]['nama']);
}
$gadaicaw2 = Gadai::on($datasenarai[0]['kodcaw'])->whereIn('norujukan',$arraysenarai)
->where('gadai.kodcaw','=',$user->kodcaw);
$arraycustomer = $gadaicaw2->pluck('nokp')->toArray();
$datacustomer = $gadaicaw2->get();
// dd($gadaicaw2);
$customer = Customer::query()
->whereIn('kpbaru',$arraycustomer)
->orWhereIn('kplama',$arraycustomer)
->get()->toArray();
// $customer[$index1]['listsag'] = $listsag;
// ->join('customer', function ($join) {
// $join->on('gadai.nokp', '=', 'customer.kpbaru')->orOn('gadai.nokp', '=', 'customer.kplama');
// })
// ->where('gadai.kodcaw','=',$user->kodcaw)
// ->where('lelongbid.lelong_id', $lelong_id)
// ->get()->toArray();
// $payment[$index1]['payment'] = $payment;
// $payment[$index1]['bayaran_keuntungan'] = $bayaran;
if($request->type == 'excel')
{
return view('excel.listnotis_excel',compact('gadaicaw','caw','lelong_id','bayaran','customer'));
return view('excel.listnotis_excel',compact('marhuns','lelong_id','bayaran','listsag','caw'));
}
else
{
$pdf = PDF::loadView('pdf.listnotis',compact('gadaicaw','caw','lelong_id','bayaran'))
$pdf = PDF::loadView('pdf.listnotis',compact('marhuns','lelong_id','bayaran','listsag','caw'))
->setPaper('a4', 'potrait');
return $pdf->download('Senarai Notis.pdf');
+15 -14
View File
@@ -63,28 +63,29 @@
<tr>
<th align="left">No</th>
<th align="left">Nama</th>
<th align="left">No KP</th>
<th align="left">No Rujukan</th>
<th align="left">No Telefon</th>
<th align="left">Tempoh</th>
<th align="left">No KP</th>
<th align="left">Pembiayaan</th>
<th align="left">Keuntungan 6 Bulan</th>
<th align="left">Bayaran Telah Dibuat</th>
</tr>
</thead>
@foreach($customer as $index1=> $pay)
<tr>
<td align="left">{{ $loop->iteration }} </td>
<td align="left">{{ $pay['nama']}}</td>
<td align="left">{{ $gadaicaw[$index1]['norujukan'] }}</td>
<td align="left">6{{ $pay['telefon']}}</td>
<td align="left">{{ $gadaicaw[$index1]['tempoh'] }}</td>
<td align="left">{{ $gadaicaw[$index1]['nokp'] }}</td>
<td align="left">{{ number_format($gadaicaw[$index1]['pinjaman'], 2, '.', ',')}}</td>
<td align="left">{{ number_format($gadaicaw[$index1]['bakiupah'], 2, '.', ',')}}</td>
<td align="left">{{ number_format($bayaran, 2, '.', ',')}}</td>
@foreach($marhuns as $index1=> $notis)
<tr>
<td>{{ $loop->iteration }} </td>
<td>@foreach($notis['nama'] as $data){{ $data['nama']}}<br>@endforeach</td>
<td>{{ $notis['nokp']}}</td>
<td>@foreach($notis['listsag'] as $item){{ $item['norujukan']}}, <br>@endforeach</td>
<td>@foreach($notis['nama'] as $data)6{{ $data['telefon']}}<br>@endforeach</td>
<td>@foreach($notis['listsag'] as $item){{ $item['tempoh']}}, <br>@endforeach</td>
<td>@foreach($notis['listsag'] as $item){{ number_format($item['pinjaman'], 2, '.', ',')}}, <br>@endforeach</td>
<td>@foreach($notis['listsag'] as $item){{ number_format($item['bakiupah'], 2, '.', ',')}}, <br>@endforeach</td>
<td>{{ number_format($bayaran, 2, '.', ',')}}<br></td>
@endforeach
@endforeach
</div>
@@ -97,7 +98,7 @@
var table2excel = new Table2Excel();
table2excel.export(document.querySelectorAll("#customers"),'senarai_notis');
setTimeout(function(){ window.close() }, 1000);
setTimeout(function(){ window.close() }, 10);
});
+14 -12
View File
@@ -91,26 +91,28 @@ tr:nth-child(even) {
<thead>
<tr>
<th>No</th>
<th>No Kp</th>
<th>No Rujukan</th>
<th>JGB</th>
<th>No Kp</th>
<th>Pembiayaan</th>
<th>Keuntungan 6 Bulan</th>
<th>Bayaran Telah Dibuat</th>
</tr>
</thead>
@foreach($gadaicaw as $index1=> $pay)
<tr>
<td align="left">{{ $loop->iteration }} </td>
<td align="left">{{ $pay['norujukan']}}</td>
<td align="left">{{ $pay['tempoh']}}</td>
<td align="left">{{ $pay['nokp']}}</td>
<td align="left">{{ number_format($pay['pinjaman'], 2, '.', ',')}}</td>
<td align="left">{{ number_format($pay['bakiupah'], 2, '.', ',')}}</td>
<td align="left">{{ number_format($bayaran, 2, '.', ',')}}</td>
</tr>
@endforeach
@foreach($marhuns as $index1=> $notis)
<tr>
<td>{{ $loop->iteration }} </td>
<td>{{ $notis['nokp']}}</td>
{{-- <td style='word-wrap'>{{ $notis['nama']['nama']}}</td> --}}
<td>@foreach($notis['listsag'] as $item){{ $item['norujukan']}}<br>@endforeach</td>
<td>@foreach($notis['listsag'] as $item){{ $item['tempoh']}}<br>@endforeach</td>
<td>@foreach($notis['listsag'] as $item){{ number_format($item['pinjaman'], 2, '.', ',')}}<br>@endforeach</td>
<td>@foreach($notis['listsag'] as $item){{ number_format($item['bakiupah'], 2, '.', ',')}}<br>@endforeach</td>
<td>{{ number_format($bayaran, 2, '.', ',')}}<br></td>
@endforeach
</table>
</div>