export to pdf

simulasi keseluruhan
notis lelong
This commit is contained in:
Amirah22
2022-01-26 14:46:24 +08:00
parent 15c4c79945
commit eefc3e803a
8 changed files with 653 additions and 129 deletions
+13
View File
@@ -26,6 +26,7 @@ use App\Models\LelongBid;
use App\Models\LelongBidMarhun;
use App\Models\LelKarat;
use App\Models\LelKarat_temp;
use Carbon\Carbon;
class LelongController extends Controller
{
@@ -321,6 +322,18 @@ class LelongController extends Controller
->with('success','Create Lelong Berjaya');
}
public function exportnotis($id)
{
$currentdate = Carbon::now();
$currentdate = $currentdate->toDateString();
$lelong = Lelong::where('id','=',$id)->first();
$lelongbid = LelongBid::where('lelong_id','=',$lelong->id)->get();
// return view('pdf.notislelong',compact('currentdate','lelongbid')); //page for editing
$pdf = PDF::loadView('pdf.notislelong',compact('currentdate','lelongbid'));
return $pdf->download('Notis Lelong.pdf');
}
public function delete($id)
{
+176 -2
View File
@@ -27,6 +27,11 @@ use App\Models\LelongBid;
use App\Models\LelongBidMarhun;
use App\Models\LelKarat;
class SimulasiController extends Controller
{
/**
@@ -463,11 +468,180 @@ class SimulasiController extends Controller
}
// PDF SIMULASI KESELURUHAN SEMUA CAWANGAN
public function export(Request $request)
{
$simulasi_id = $request->simulasiid;
$simulasi = Simulasi::where('id','=',$request->simulasiid)->first();
$cawangansim = CawanganSimulasi::where('simulasi_id','=',$request->simulasiid)->get();
$simkarat = SimKarat::where('simulasi_id','=',$request->simulasiid)->get();
$arraydata = [];
$arraycaw = [];
$data = [];
$total_marhun = 0;
$total_berat = 0;
$total_nmarhun = 0;
$total_pinjaman = 0;
$total_upah = 0;
$total_hargaasas = 0;
$total_cazlelong = 0;
$total_rugilelong = 0;
$total_bakilelong = 0;
$total24Kgb = 0;
$total24K = 0;
$total23k = 0;
$total22K = 0;
$total21K = 0;
$total20K = 0;
$total18Kp = 0;
$total18K = 0;
$total14Kp = 0;
$total14K = 0;
$total9K = 0;
foreach($cawangansim as $cawsim)
{
$cawangan = Cawangan::where('id','=',$cawsim->caw_id)->first();
$databid = SimulasiBid::where('simulasi_id','=',$simulasi_id)->get();
$packet = 0;
$berat = 0;
$nilai_marhun = 0;
$pinjaman =0;
$upah = 0;
$hargaasas = 0;
$cajlelong = 0;
$rugilelong = 0;
$bakilelong = 0;
foreach($databid as $bid)
{
$marhun = SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)->get();
$berat = $berat + $bid->berat;
$nilai_marhun = $nilai_marhun + ($marhun->sum('n_marhun'));
$pinjaman =$pinjaman + $bid->pinjaman;
$upah = $upah + $bid->upah;
$hargaasas = $hargaasas + $bid->hargaasas;
$cajlelong = $cajlelong + $bid->cajlelong;
if($bid->baki > 0)
{
$bakilelong = $bakilelong + $bid->baki;
}
else
{
$rugilelong = $rugilelong - $bid->baki;
}
$total24Kgb += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','24.0Kgb')
->sum('berat');
$total24K += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','24.0K')
->sum('berat');
$total23k += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','23.0K')
->sum('berat');
$total22K += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','22.0K')
->sum('berat');
$total21K += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','21.0K')
->sum('berat');
$total20K += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','20.0K')
->sum('berat');
$total18Kp += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','18.0Kp')
->sum('berat');
$total18K += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','18.0K')
->sum('berat');
$total14Kp += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','14.0Kp')
->sum('berat');
$total14K += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','14.0K')
->sum('berat');
$total9K += SimulasiBidMarhun::where('simulasibid_id','=',$bid->id)
->where('karat','=','9.0K')
->sum('berat');
}
array_push($arraycaw,[
'cawangan'=>$cawangan->caw_name,
't_lelong'=>$simulasi->tarikh_lelong,
'bil_marhun'=>sizeof($databid),
'berat'=>$berat,
'n_marhun'=>$nilai_marhun,
'pinjaman'=>$pinjaman,
'upah'=>0,
'hargaasas'=>$hargaasas,
'cajlelong'=>$cajlelong,
'rugilelong'=>$rugilelong,
'bakilelong'=>$bakilelong,
]);
$total_marhun = $total_marhun + sizeof($databid);
$total_berat = $total_berat + $berat;
$total_nmarhun = $total_nmarhun + $nilai_marhun;
$total_pinjaman = $total_pinjaman + $pinjaman;
$total_upah = $total_upah + 0;
$total_hargaasas = $total_hargaasas + $hargaasas;
$total_cazlelong = $total_cazlelong + $cajlelong;
$total_rugilelong = $total_rugilelong + $rugilelong;
$total_bakilelong = $total_bakilelong + $bakilelong;
}
$pdf = PDF::loadView('pdf.simrpt2',compact('arraycaw',
'total_marhun',
'total_berat',
'total_nmarhun',
'total_pinjaman',
'total_upah',
'total_hargaasas',
'total_cazlelong',
'total_rugilelong',
'total_bakilelong',
'total24Kgb',
'total24K',
'total23k',
'total22K',
'total21K',
'total20K',
'total18Kp',
'total18K',
'total14Kp',
'total14K',
'total9K',
'simkarat',
'simulasi_id',
'databid'))->setPaper('a4', 'landscape');
return $pdf->download('Simulasi Keseluruhan.pdf');
$pdf = PDF::loadView('pdf.simrpt2');
return $pdf->download('Taraf.pdf');
}
}