excel jana notis

This commit is contained in:
Amirah22
2022-08-07 16:55:18 +08:00
parent ba59a959de
commit 065fbeb44c
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');