fix pdf kehadiran

This commit is contained in:
nurafrinaalimi16
2024-04-30 13:07:08 +08:00
parent c270f4306d
commit 032a1066ff
3 changed files with 39 additions and 28 deletions
+7 -11
View File
@@ -16,25 +16,21 @@ class KehadiranController extends Controller
public function index($id) public function index($id)
{ {
// //
$kehadiranAll = $this->getKehadiranAll($id);
$totalkehadiranAll = Voter::where('kehadiran','!=', 0)->count();
$votes = Voter::where('election_id', $id)->count();
$voters = \App\Voter::where('election_id', $id)->get(); $voters = \App\Voter::where('election_id', $id)->get();
$pdf = App::make('dompdf.wrapper'); $pdf = App::make('dompdf.wrapper');
$pdf->loadView('report.kehadiran-pdf', compact('voters')); $pdf->loadView('report.kehadiran-pdf', compact('voters', 'kehadiranAll', 'totalkehadiranAll', 'votes'));
return $pdf->stream(); return $pdf->stream();
} }
protected function getKehadiranString($kehadiran) private function getKehadiranAll($id)
{ {
// Map integer values to corresponding string representations return \App\Voter::where('kehadiran','!=', 0)->get();
switch ($kehadiran) {
case 1:
return 'Fizikal';
case 2:
return 'Maya';
default:
return '-';
}
} }
/** /**
@@ -5,21 +5,20 @@
<i class="fa fa-refresh"></i> Kemaskini Pengundi <i class="fa fa-refresh"></i> Kemaskini Pengundi
</button> </button>
<router-link class="btn btn-info" :to="{ name: 'Fizikal' }" > <router-link class="btn btn-info" :to="{ name: 'Fizikal' }">
Fizikal Fizikal
</router-link> </router-link>
<router-link class="btn btn-info" :to="{ name: 'Maya' }" > <router-link class="btn btn-info" :to="{ name: 'Maya' }">
Maya Maya
</router-link> </router-link>
<!-- <a class="btn btn-warning" :href="getPDFKehadiranurl()">Muat Turun PDF</a> -->
<!-- <button class="btn btn-primary" @click="downloadPDF()">
<i class="fa fa-download"></i> Muat Turun PDF
</button> -->
<a class="pdf-button-container btn btn-warning" :href="getPDFKehadiranurl(1)"><i class="fa fa-download"></i> Muat Turun PDF</a>
<!-- <a class="btn btn-warning" :href="getPDFKehadiranurl(1)">Muat Turun PDF</a> -->
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
@@ -65,6 +64,12 @@
</div> </div>
</template> </template>
<style>
.pdf-button-container {
text-align: right;
}
</style>
<script> <script>
export default { export default {
@@ -110,7 +115,12 @@ export default {
} }
}, },
getPDFKehadiranurl(Id) {
// Construct and return the URL based on the item ID
return `/kehadiranpdf/${Id}`;
}
}, },
watch: { watch: {
@@ -154,10 +164,7 @@ export default {
return totalMembers === 0 ? 0 : ((totalAttendance / totalMembers) * 100).toFixed(2); return totalMembers === 0 ? 0 : ((totalAttendance / totalMembers) * 100).toFixed(2);
}, },
getPDFKehadiranurl() {
// Construct and return the URL based on the item ID
return `/kehadiranpdf/1`;
}
} }
} }
+10 -2
View File
@@ -1,7 +1,7 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<h5>Kehadiran Anggota Koperasi</h5> <h3>Kehadiran Anggota Koperasi</h3>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped table-condensed"> <table class="table table-striped table-condensed">
<thead> <thead>
@@ -43,6 +43,10 @@
{{-- @endif --}} {{-- @endif --}}
@endforeach @endforeach
<tr>
<td colspan="2"><b>Peratus Kehadiran</b></td>
<td><b>{{ ($totalkehadiranAll / $votes) * 100 }}%</b></td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>
@@ -54,7 +58,7 @@
<!-- Verified By column --> <!-- Verified By column -->
<div class="container mt-4"> <div class="container mt-4">
<div class="row"> <div class="signature-section row">
<div class="col-md-12"> <div class="col-md-12">
<div class="table-responsive"> <div class="table-responsive">
<table> <table>
@@ -75,6 +79,10 @@
<style> <style>
/* Style for table body */ /* Style for table body */
.signature-section{
margin-top: 80px;
}
.table tbody td { .table tbody td {
border-bottom: 1px solid #ddd; border-bottom: 1px solid #ddd;
padding: 8px; padding: 8px;