From 11df759ffc44fb3e2b572b6e7a9253988b508ae2 Mon Sep 17 00:00:00 2001 From: nurafrinaalimi16 Date: Tue, 30 Apr 2024 10:59:58 +0800 Subject: [PATCH] pdf kehadiran --- app/Http/Controllers/KehadiranController.php | 105 +++++++++++++++++ .../components/demo/admin/voter/kehadiran.vue | 19 ++- .../views/report/kehadiran-pdf.blade.php | 109 ++++++++++++++++++ 3 files changed, 222 insertions(+), 11 deletions(-) create mode 100644 app/Http/Controllers/KehadiranController.php create mode 100644 resources/views/report/kehadiran-pdf.blade.php diff --git a/app/Http/Controllers/KehadiranController.php b/app/Http/Controllers/KehadiranController.php new file mode 100644 index 0000000..4621538 --- /dev/null +++ b/app/Http/Controllers/KehadiranController.php @@ -0,0 +1,105 @@ +get(); + + + $pdf = App::make('dompdf.wrapper'); + $pdf->loadView('report.kehadiran-pdf', compact('voters')); + return $pdf->stream(); + } + + protected function getKehadiranString($kehadiran) + { + // Map integer values to corresponding string representations + switch ($kehadiran) { + case 1: + return 'Fizikal'; + case 2: + return 'Maya'; + default: + return '-'; + } + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + // + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + // + } + + /** + * Display the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function show($id) + { + // + } + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + // + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + // + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + // + } +} diff --git a/resources/assets/js/components/demo/admin/voter/kehadiran.vue b/resources/assets/js/components/demo/admin/voter/kehadiran.vue index fc71bb3..eb877d2 100644 --- a/resources/assets/js/components/demo/admin/voter/kehadiran.vue +++ b/resources/assets/js/components/demo/admin/voter/kehadiran.vue @@ -13,6 +13,8 @@ Maya + + @@ -108,17 +110,7 @@ export default { } }, - // downloadPDF() { - // const table = document.getElementById('voterTable'); - - // html2canvas(table).then(canvas => { - // const imgData = canvas.toDataURL('image/png'); - // const pdf = new jsPDF(); - // pdf.addImage(imgData, 'PNG', 0, 0); - // pdf.save('kehadiran-pengundi.pdf'); - // }); - // }, - + }, watch: { @@ -160,6 +152,11 @@ export default { const totalAttendance = fizikalCount + mayaCount; const totalMembers = this.data.voters.data.length; return totalMembers === 0 ? 0 : ((totalAttendance / totalMembers) * 100).toFixed(2); + }, + + getPDFKehadiranurl() { + // Construct and return the URL based on the item ID + return `/kehadiranpdf/1`; } } diff --git a/resources/views/report/kehadiran-pdf.blade.php b/resources/views/report/kehadiran-pdf.blade.php new file mode 100644 index 0000000..cec1096 --- /dev/null +++ b/resources/views/report/kehadiran-pdf.blade.php @@ -0,0 +1,109 @@ +
+
+
+
Kehadiran Anggota Koperasi
+
+ + + + + + + + + + + + + + @foreach ($voters as $voter) + + {{-- --}} + + + + + + + + + + {{-- @if ($result->position_id == $position->id) --}} + + {{-- @endif --}} + @endforeach + +
Bil.Nama AnggotaNo. Kad PengenalanNo. AnggotaUnitKehadiranTarikh/Masa
{{ $index + 1 }} {{ $loop->iteration }}{{ $voter['name'] }}{{ $voter['no_kp'] }}{{ $voter['no_anggota'] }}{{ $voter['unit'] }} @php + switch ($voter['kehadiran']) { + case 1: + echo 'Fizikal'; + break; + case 2: + echo 'Maya'; + break; + default: + echo '-'; + } + @endphp{{ $voter['updated_at'] }}
+
+
+ +
+
+
+ + +
+
+
+
+ + + + + + + + + + +
Disahkan Oleh :
...................................
+
+
+
+
+ + + +@push('scripts') + +@endpush