Merge branch 'finadev' of https://gitlab.com/erahn/voting into finadev
This commit is contained in:
@@ -11,6 +11,6 @@ class GetController extends Controller
|
||||
{
|
||||
public function __invoke()
|
||||
{
|
||||
return Voter::where('election_id', Util::getCurrentElection())->paginate(10);
|
||||
return Voter::where('election_id', Util::getCurrentElection())->paginate(50);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
<h4>Undian Terkini</h4>
|
||||
<div class="form-group">
|
||||
<button class="btn btn-success" v-if="data.election.status == 1 && data.user.role==1"
|
||||
@click="util.showModal('#start-election-modal')">Start Election</button>
|
||||
@click="util.showModal('#start-election-modal')">Mula Undian</button>
|
||||
|
||||
<router-link :to="{ name: 'Current Result' }" class="btn btn-info" v-if="data.election.status == 2">
|
||||
View Results
|
||||
Papar Keputusan
|
||||
</router-link>
|
||||
|
||||
<button class="btn btn-danger" v-if="data.election.status == 2"
|
||||
@click="util.showModal('#stop-election-modal')">End Election</button>
|
||||
@click="util.showModal('#stop-election-modal')">Tamat Undian</button>
|
||||
|
||||
<label v-if="data.election.status == 2">Election has Started {{ start_date }}</label>
|
||||
<label v-if="data.election.status == 2">Undian bermula {{ start_date }}</label>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<table class="table table-hover" id="position_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Bil.</th>
|
||||
<th>Nama Anggota</th>
|
||||
<th>No. Kad Pengenalan</th>
|
||||
<th>No. Anggota</th>
|
||||
@@ -27,6 +28,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(voter,i) in data.voters.data">
|
||||
<td>{{ i + 1 }}</td>
|
||||
<td>{{ voter.name }}</td>
|
||||
<td>{{ voter.no_kp }}</td>
|
||||
<td>{{ voter.no_anggota }}</td>
|
||||
|
||||
@@ -5,10 +5,16 @@
|
||||
<i class="fa fa-refresh"></i> Kemaskini Pengundi
|
||||
</button>
|
||||
|
||||
<button class="btn btn-primary" @click="downloadPDF()">
|
||||
<i class="fa fa-download"></i> Muat Turun PDF
|
||||
</button>
|
||||
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Bil.</th>
|
||||
<th>Nama Anggota</th>
|
||||
<th>No. Kad Pengenalan</th>
|
||||
<th>No. Anggota</th>
|
||||
@@ -18,21 +24,52 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(voter, i) in data.voters.data">
|
||||
<td>{{ voter.name }}</td>
|
||||
<td>{{ voter.no_kp }}</td>
|
||||
<td>{{ voter.no_anggota }}</td>
|
||||
<td>{{ voter.unit }}</td>
|
||||
<td>{{ getKehadiranString(voter.kehadiran) }}</td>
|
||||
<td>{{ voter.updated_at }}</td>
|
||||
</tr>
|
||||
<!-- <tr v-if="data.elections.length < 1">
|
||||
<td colspan="5">No elections yet</td>
|
||||
</tr> -->
|
||||
<!-- Display Fizikal attendees -->
|
||||
<template v-for="(voter, i) in data.voters.data">
|
||||
<tr v-if="voter.kehadiran === 1">
|
||||
<td>{{ i + 1 }}</td> <!-- Display the serial number -->
|
||||
<td>{{ voter.name }}</td>
|
||||
<td>{{ voter.no_kp }}</td>
|
||||
<td>{{ voter.no_anggota }}</td>
|
||||
<td>{{ voter.unit }}</td>
|
||||
<td>{{ getKehadiranString(voter.kehadiran) }}</td>
|
||||
<td>{{ voter.updated_at }}</td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
<!-- Display Maya attendees -->
|
||||
<template v-for="(voter, i) in data.voters.data">
|
||||
<tr v-if="voter.kehadiran === 2">
|
||||
<td>{{ i + 1 }}</td> <!-- Display the serial number -->
|
||||
<td>{{ voter.name }}</td>
|
||||
<td>{{ voter.no_kp }}</td>
|
||||
<td>{{ voter.no_anggota }}</td>
|
||||
<td>{{ voter.unit }}</td>
|
||||
<td>{{ getKehadiranString(voter.kehadiran) }}</td>
|
||||
<td>{{ voter.updated_at }}</td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
<template v-for="(voter, i) in data.voters.data">
|
||||
<tr v-if="voter.kehadiran === 0">
|
||||
<td>{{ i + 1 }}</td> <!-- Display the serial number -->
|
||||
<td>{{ voter.name }}</td>
|
||||
<td>{{ voter.no_kp }}</td>
|
||||
<td>{{ voter.no_anggota }}</td>
|
||||
<td>{{ voter.unit }}</td>
|
||||
<td>{{ getKehadiranString(voter.kehadiran) }}</td>
|
||||
<td>{{ voter.updated_at }}</td>
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Display attendance percentage -->
|
||||
<div class="text-right">
|
||||
<h5><b>{{ attendancePercentage }}% Kehadiran Pengundi</b></h5>
|
||||
</div>
|
||||
|
||||
<ul class="pagination" v-if="pages.length > 1">
|
||||
<router-link tag="li" v-for="page in pages" :key="page['pages']" :to="{ query: { page: page['page'] } }"
|
||||
:class="{ 'active': current_page == page['page'] }" exact>
|
||||
@@ -44,6 +81,10 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import html2canvas from 'html2canvas';
|
||||
import jsPDF from 'jspdf';
|
||||
|
||||
export default {
|
||||
data: function () {
|
||||
return {
|
||||
@@ -85,7 +126,18 @@ export default {
|
||||
default:
|
||||
return '-';
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
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');
|
||||
});
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
@@ -110,7 +162,26 @@ export default {
|
||||
|
||||
current_page: function () {
|
||||
return this.$route.query.page ? this.$route.query.page : 1;
|
||||
},
|
||||
|
||||
// Calculate total attendance percentage
|
||||
attendancePercentage() {
|
||||
// Count total members who attended physically (Fizikal)
|
||||
const fizikalCount = this.data.voters.data.reduce((total, voter) => {
|
||||
return voter.kehadiran === 1 ? total + 1 : total;
|
||||
}, 0);
|
||||
|
||||
// Count total members who attended virtually (Maya)
|
||||
const mayaCount = this.data.voters.data.reduce((total, voter) => {
|
||||
return voter.kehadiran === 2 ? total + 1 : total;
|
||||
}, 0);
|
||||
|
||||
// Calculate total attendance percentage
|
||||
const totalAttendance = fizikalCount + mayaCount;
|
||||
const totalMembers = this.data.voters.data.length;
|
||||
return totalMembers === 0 ? 0 : ((totalAttendance / totalMembers) * 100).toFixed(2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
@@ -16,7 +16,8 @@
|
||||
|
||||
<div class="form-group">
|
||||
<label for="no_anggota">No. Anggota : </label>
|
||||
<input type="text" name="no_anggota" class="form-control" readonly :value="data.user.no_anggota" required />
|
||||
<input type="text" name="no_anggota" class="form-control" readonly :value="data.user.no_anggota"
|
||||
required />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@@ -37,7 +38,8 @@
|
||||
<p> <i>*Pendaftaran online sehingga jam 10 pagi</i></p>
|
||||
</div>
|
||||
|
||||
<center><input type="submit" value="SAYA TERIMA" class="btn btn-primary" v-if="data.election.status==1"/></center>
|
||||
<center><input type="submit" value="SAYA TERIMA" class="btn btn-primary"
|
||||
v-if="data.election.status == 1 && data.user.kehadiran == 0" /></center>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -49,19 +51,24 @@
|
||||
export default {
|
||||
data: function () {
|
||||
return {
|
||||
loading: false
|
||||
loading: false,
|
||||
userSubmitted: false // Add a flag to track if the user has already submitted
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
// refreshUser: function () {
|
||||
|
||||
// var vm = this;
|
||||
// axios.get(config.API + 'voter/' + this.data.user.id)
|
||||
// .then(response => {
|
||||
// vm.data.user = response.data;
|
||||
// console.log(response.data)
|
||||
// })
|
||||
// },
|
||||
|
||||
|
||||
|
||||
edit: function () {
|
||||
if (this.loading) return;
|
||||
this.loading = true;
|
||||
@@ -72,8 +79,10 @@ export default {
|
||||
$.notifyClose();
|
||||
vm.loading = false;
|
||||
if (vm.util.showResult(response, 'success')) {
|
||||
vm.refreshUser();
|
||||
vm.$router.push({ name: 'Voter Home' });
|
||||
// vm.refreshUser();
|
||||
location.reload();
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
<template>
|
||||
<div class="row col-md-10 col-md-offset-1">
|
||||
<div class="col-md-12">
|
||||
|
||||
<!-- <h6 class="text-center">Pautan Zoom</h6> -->
|
||||
<div>
|
||||
<img :src="imageUrl" alt="background-img" class="background-img" @click="navigateToURL" />
|
||||
|
||||
</div><hr>
|
||||
|
||||
<!-- <div class="right-button">
|
||||
<button class="btn btn-info right-button">Lampiran Dokumen MAT ke-27/2023 >></button>
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
export default {
|
||||
|
||||
methods: {
|
||||
navigateToURL() {
|
||||
// Navigate to the desired URL
|
||||
window.open('https://linktr.ee/kopkb', '_blank');
|
||||
}
|
||||
},
|
||||
|
||||
created: function () {
|
||||
//console.log(this)
|
||||
},
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
x: {}
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
header: function () {
|
||||
return this.x.name + ' for ' + this.getPosition(this.x.position_id);
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
imageUrl: 'https://imagetolink.com/ib/0zxQzuS6tl.png'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
.background-img {
|
||||
/* Styles for the image */
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
|
||||
/* Ensure the image does not exceed container dimensions */
|
||||
max-width: 100%;
|
||||
max-height: 80vh;
|
||||
border-radius: 20px;
|
||||
}
|
||||
/* transform: translate(-50%, -50%); */
|
||||
|
||||
|
||||
|
||||
.right-button {
|
||||
|
||||
border-color: rgb(14, 14, 15);
|
||||
text-align: left; /* Align button content to the left */
|
||||
color: #fff;
|
||||
border-radius: 10px;
|
||||
cursor: pointer;
|
||||
/* padding: 15px ; */
|
||||
}
|
||||
|
||||
|
||||
|
||||
.right-button :hover {
|
||||
/* Button styles on hover */
|
||||
outline-color: #045415;
|
||||
|
||||
}
|
||||
</style>
|
||||
@@ -24,7 +24,7 @@
|
||||
<div class="col-md-8">
|
||||
<h4>Pilih Calon</h4>
|
||||
<div class="alert alert-warning " role="alert">
|
||||
Boleh mengundi (2) calon sahaja!
|
||||
Boleh mengundi <b> dua (2) calon</b> sahaja!
|
||||
</div>
|
||||
<hr />
|
||||
<div class="panel panel-info" v-for="position in data.positions">
|
||||
|
||||
Reference in New Issue
Block a user