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)
{
//
$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();
$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();
}
protected function getKehadiranString($kehadiran)
private function getKehadiranAll($id)
{
// Map integer values to corresponding string representations
switch ($kehadiran) {
case 1:
return 'Fizikal';
case 2:
return 'Maya';
default:
return '-';
}
return \App\Voter::where('kehadiran','!=', 0)->get();
}
/**
@@ -5,21 +5,20 @@
<i class="fa fa-refresh"></i> Kemaskini Pengundi
</button>
<router-link class="btn btn-info" :to="{ name: 'Fizikal' }" >
Fizikal
<router-link class="btn btn-info" :to="{ name: 'Fizikal' }">
Fizikal
</router-link>
<router-link class="btn btn-info" :to="{ name: 'Maya' }" >
Maya
<router-link class="btn btn-info" :to="{ name: 'Maya' }">
Maya
</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">
<table class="table table-hover">
<thead>
@@ -65,6 +64,12 @@
</div>
</template>
<style>
.pdf-button-container {
text-align: right;
}
</style>
<script>
export default {
@@ -110,7 +115,12 @@ export default {
}
},
getPDFKehadiranurl(Id) {
// Construct and return the URL based on the item ID
return `/kehadiranpdf/${Id}`;
}
},
watch: {
@@ -154,10 +164,7 @@ export default {
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="row">
<div class="col-md-12">
<h5>Kehadiran Anggota Koperasi</h5>
<h3>Kehadiran Anggota Koperasi</h3>
<div class="table-responsive">
<table class="table table-striped table-condensed">
<thead>
@@ -43,6 +43,10 @@
{{-- @endif --}}
@endforeach
<tr>
<td colspan="2"><b>Peratus Kehadiran</b></td>
<td><b>{{ ($totalkehadiranAll / $votes) * 100 }}%</b></td>
</tr>
</tbody>
</table>
</div>
@@ -54,7 +58,7 @@
<!-- Verified By column -->
<div class="container mt-4">
<div class="row">
<div class="signature-section row">
<div class="col-md-12">
<div class="table-responsive">
<table>
@@ -75,6 +79,10 @@
<style>
/* Style for table body */
.signature-section{
margin-top: 80px;
}
.table tbody td {
border-bottom: 1px solid #ddd;
padding: 8px;