diff --git a/app/Http/Controllers/LelongController.php b/app/Http/Controllers/LelongController.php index 0c4e1fd9..0e725d60 100644 --- a/app/Http/Controllers/LelongController.php +++ b/app/Http/Controllers/LelongController.php @@ -27,6 +27,7 @@ use App\Models\LelongBidder; use App\Models\LelongBidMarhun; use App\Models\LelKarat; use App\Models\LelKarat_temp; +use Carbon\Carbon; use Carbon\Carbon; @@ -324,6 +325,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) { diff --git a/app/Http/Controllers/MarhunController.php b/app/Http/Controllers/MarhunController.php index ac7340fb..1907ba44 100644 --- a/app/Http/Controllers/MarhunController.php +++ b/app/Http/Controllers/MarhunController.php @@ -102,7 +102,29 @@ class MarhunController extends Controller $emasall = JenisEmas::all(); return view('marhun.marhun',compact('marhun','lelongbid','karatall','emasall')); - } + } + + + public function exportmarhundetails(Request $request) + { + $lelongbid = LelongBid::where('id','=',$request->lelongbid)->first(); + $marhun = LelongBidMarhun::where('lelongbid_id','=',$request->lelongbid)->get(); + + $karatall = JenisKarat::all(); + $emasall = JenisEmas::all(); + + + + $pdf = PDF::loadView('pdf.marhundetails',compact('marhun', + 'lelongbid', + 'karatall', + + 'emasall'))->setPaper('a4', 'landscape'); + + return $pdf->download('Senarai Lelong Details.pdf'); + + + } } \ No newline at end of file diff --git a/app/Http/Controllers/SimulasiController.php b/app/Http/Controllers/SimulasiController.php index aeba9a3f..aa431ee1 100644 --- a/app/Http/Controllers/SimulasiController.php +++ b/app/Http/Controllers/SimulasiController.php @@ -27,6 +27,11 @@ use App\Models\LelongBid; use App\Models\LelongBidMarhun; use App\Models\LelKarat; + + + + + class SimulasiController extends Controller { /** @@ -462,6 +467,182 @@ 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'); + + + } } \ No newline at end of file diff --git a/resources/views/includes/sidebar.blade.php b/resources/views/includes/sidebar.blade.php index bd5decd1..b220e2d0 100644 --- a/resources/views/includes/sidebar.blade.php +++ b/resources/views/includes/sidebar.blade.php @@ -52,9 +52,14 @@ --}} @endhasrole @hasrole('pengurus-cawangan') - {{--
{{ $message }}
@endif -