pdf kehadiran
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use App\Voter;
|
||||
|
||||
class KehadiranController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index($id)
|
||||
{
|
||||
//
|
||||
$voters = \App\Voter::where('election_id', $id)->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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@
|
||||
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> -->
|
||||
@@ -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`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h5>Kehadiran Anggota Koperasi</h5>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Bil.</th>
|
||||
<th>Nama Anggota</th>
|
||||
<th>No. Kad Pengenalan</th>
|
||||
<th>No. Anggota</th>
|
||||
<th>Unit</th>
|
||||
<th>Kehadiran</th>
|
||||
<th>Tarikh/Masa</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($voters as $voter)
|
||||
<tr>
|
||||
{{-- <td>{{ $index + 1 }}</td> <!-- Display the serial number --> --}}
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $voter['name'] }}</td>
|
||||
<td>{{ $voter['no_kp'] }}</td>
|
||||
<td>{{ $voter['no_anggota'] }}</td>
|
||||
<td>{{ $voter['unit'] }}</td>
|
||||
<td> @php
|
||||
switch ($voter['kehadiran']) {
|
||||
case 1:
|
||||
echo 'Fizikal';
|
||||
break;
|
||||
case 2:
|
||||
echo 'Maya';
|
||||
break;
|
||||
default:
|
||||
echo '-';
|
||||
}
|
||||
@endphp</td>
|
||||
<td>{{ $voter['updated_at'] }}</td>
|
||||
</tr>
|
||||
|
||||
{{-- @if ($result->position_id == $position->id) --}}
|
||||
|
||||
{{-- @endif --}}
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Verified By column -->
|
||||
<div class="container mt-4">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="table-responsive">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="4"><b>Disahkan Oleh :</b></td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>...................................</b></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
/* Style for table body */
|
||||
.table tbody td {
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
/* Add space between specific columns */
|
||||
.table tbody td:nth-child(3),
|
||||
/* Unit column */
|
||||
.table tbody td:nth-child(4),
|
||||
/* Undian column */
|
||||
.table tbody td:nth-child(5) {
|
||||
/* Peratus (%) column */
|
||||
padding-right: 20px;
|
||||
/* Adjust this value as needed */
|
||||
}
|
||||
</style>
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
// Define the getKehadiranString function here
|
||||
function getKehadiranString(kehadiran) {
|
||||
switch (kehadiran) {
|
||||
case 1:
|
||||
return 'Fizikal';
|
||||
case 2:
|
||||
return 'Maya';
|
||||
default:
|
||||
return '-';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
Reference in New Issue
Block a user