newcommit

This commit is contained in:
hayatie
2024-04-16 15:26:30 +08:00
parent bdb86d29b8
commit df6ffb203e
13 changed files with 238 additions and 146 deletions
@@ -0,0 +1,60 @@
<?php
namespace App\Http\Controllers\API\v1\Voter;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Util;
use App\Voter;
class AttendanceController extends Controller
{
//
public function __invoke(Request $request, $id)
{
$this->validateRequest($request, $id);
$this->updateAttendance($request, $id);
return response()->json([
'status' => 'success',
'message' => 'Kehadiran anda telah disahkan.'
]);
}
private function validateRequest($request, $id)
{
$this->validate($request, [
'name' => [
'required',
Rule::unique('voter')->ignore($id)->where(function($query){
$query->where('election_id', Util::getCurrentElection());
})
],
'no_kp' => [
'required',
Rule::unique('voter')->ignore($id)->where(function($query){
$query->where('election_id', Util::getCurrentElection());
})
],
'unit' => 'required',
'no_anggota' => [
'required',
Rule::unique('voter')->ignore($id)->where(function($query){
$query->where('election_id', Util::getCurrentElection());
})
],
'kehadiran' => 'required'
]);
}
private function updateAttendance($request, $id)
{
$voter = $request->all();
Voter::find($id)->update($voter);
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
<?php <?php
return [ return [
'message' => 'KoPKB : %s is your TAC to log in to your myKoPKB Member account. It will expire in 5 minutes.', 'message' => 'KoPKB : %s is your TAC to log in to your myKoPKB Member account. It will expire in 3 minutes.',
'minutes' => 3 'minutes' => 3
]; ];
@@ -0,0 +1,35 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddKehadiranToVoterTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('voter', function (Blueprint $table) {
//
$table->integer('kehadiran');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('voter', function (Blueprint $table) {
//
$table->dropColumn('kehadiran');
});
}
}
@@ -21,9 +21,9 @@
<a href="#">Jawatan</a> <a href="#">Jawatan</a>
</router-link> </router-link>
<router-link :to="{name: 'Manage Partylist'}" v-if="data.user.role==1" tag="li"> <!-- <router-link :to="{name: 'Manage Partylist'}" v-if="data.user.role==1" tag="li">
<a href="#">Manage Partylist</a> <a href="#">Manage Partylist</a>
</router-link> </router-link> -->
<router-link :to="{name: 'Manage Voter'}" v-if="data.user.role==1" tag="li"> <router-link :to="{name: 'Manage Voter'}" v-if="data.user.role==1" tag="li">
<a href="#">Anggota Koperasi</a> <a href="#">Anggota Koperasi</a>
@@ -33,6 +33,10 @@
<a href="#">Calon</a> <a href="#">Calon</a>
</router-link> </router-link>
<router-link :to="{name: 'Kehadiran Calon'}" v-if="data.user.role==1" tag="li">
<a href="#">Kehadiran</a>
</router-link>
</ul> </ul>
<ul class="nav navbar-right navbar-nav"> <ul class="nav navbar-right navbar-nav">
<li class="dropdown"> <li class="dropdown">
@@ -34,7 +34,7 @@
<label for="position_id">Jawatan</label> <label for="position_id">Jawatan</label>
<select class="form-control" v-model="position_id" name="position_id" required> <select class="form-control" v-model="position_id" name="position_id" required>
<option value="0" disabled>--- Pilih Jawatan ---</option> <option value="0" disabled>--- Pilih Jawatan ---</option>
<option v-for="position in data.positions" :value="position.id">{{ position.name }}</option> <option v-for="position in data.positions" :key="position.id" :value="position.id">{{ position.name }}</option>
</select> </select>
</div> </div>
@@ -49,7 +49,7 @@
<label for="partylist_id">Partylist</label> <label for="partylist_id">Partylist</label>
<select class="form-control" name="partylist_id" :value="nominee.partylist_id"> <select class="form-control" name="partylist_id" :value="nominee.partylist_id">
<option value="">--- Select Partylist (Optional) ---</option> <option value="">--- Select Partylist (Optional) ---</option>
<option v-for="partylist in data.partylists" :value="partylist.id">{{ partylist.name}}</option> <option v-for="partylist in data.partylists" :key="partylist.id" :value="partylist.id">{{ partylist.name }}</option>
</select> </select>
</div> </div>
@@ -34,7 +34,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for="nominee in nominees"> <tr v-for="nominee in nominees" :key="nominee.id">
<td> <td>
<img :alt="nominee.name" :src="createBase64ImageUrl(nominee.photo)" class="thumbnail" <img :alt="nominee.name" :src="createBase64ImageUrl(nominee.photo)" class="thumbnail"
style="height: 60px;width: 60px;"> style="height: 60px;width: 60px;">
@@ -56,7 +56,7 @@
<button class="btn btn-danger" @click="util.showModal(nominee.id)" id=nominee.id> <button class="btn btn-danger" @click="util.showModal(nominee.id)" id=nominee.id>
<i class="fa fa-trash"></i> Padam <i class="fa fa-trash"></i> Padam
</button> </button>
</td>
</tr> </tr>
<tr v-if="nominees.length < 1"> <tr v-if="nominees.length < 1">
<td colspan="7">No Calon</td> <td colspan="7">No Calon</td>
@@ -3,134 +3,84 @@
<div class="col-md-12"> <div class="col-md-12">
<h3 class="text-center">Pendaftaran Kehadiran</h3> <h3 class="text-center">Pendaftaran Kehadiran</h3>
<hr /> <hr />
<ul class="list-group"> <form @submit.prevent="edit()" id="edit_form">
<li class="list-group-item"><b>No. Kad Pengenalan : </b>{{ data.user.no_kp }}</li> <div class="form-group">
<li class="list-group-item"><b>No. Anggota : </b>{{ data.user.no_anggota }}</li> <label for="name">Nama : </label>
<li class="list-group-item"><b>Nama : </b>{{ data.user.name }}</li> <input type="text" name="name" class="form-control" readonly :value="data.user.name" required />
<li class="list-group-item"><b>Unit : </b>{{ data.user.unit }}</li>
<li class="list-group-item" v-if="data.election.status == 1">
<center><router-link :to="{ name: 'Maklumat Calon', query: { position_id: position_id } }"
class="btn btn-primary">
SAYA TERIMA
</router-link></center>
</li>
</ul>
<div v-if="hasVoted()">
<hr />
<h4>Maklumat Undian</h4>
<hr />
<ul class="list-group">
<li class="list-group-item" v-for="result in data.result">
<b>{{ getPosition(result.position_id) }} : </b>{{ getNominee(result.nominee_id) }}
</li>
</ul>
</div>
</div>
<!-- <div class="col-md-8">
<h4>Maklumat Calon</h4>
<hr />
<small>Click Picture to see details</small>
<div class="panel panel-primary" v-for="position in data.positions">
<div class="panel-heading">{{ position.name }}</div>
<div class="panel-body table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Partylist</th>
<th>Unit</th>
</tr>
</thead>
<tbody>
<tr v-for="(nominee, i) in data.nominees" v-if="nominee.position_id == position.id">
<td><img @click="view(i)" :src="data.storageURL + nominee.image" class="thumbnail"
style="height: 60px;width: 60px;" />
</td>
<td>{{ nominee.name }}</td>
<td>{{ getPartylist(nominee.partylist_id) }}</td>
<td>{{ nominee.unit }}</td>
</tr>
</tbody>
</table>
</div> </div>
</div>
<modal id="nominee-information-modal" aClass="primary"> <div class="form-group">
<modal-header>{{ header }}</modal-header> <label for="no_kp">No. Kad Pengenalan :</label>
<modal-body> <input type="text" name="no_kp" class="form-control" readonly :value="data.user.no_kp" required />
<div class="row"> </div>
<div class="col-md-3">
<img :src="data.storageURL + x.image" style="height: 150px; width: 150px" class="thumbnail" />
</div>
<div class="col-md-9" style="margin-left: 5px;">
<h3><strong><em>"{{ x.motto }}"</em></strong></h3>
<b> Name : </b>{{ x.name }}<br />
<b> Unit : </b>{{ x.unit }}<br />
<b> Partylist : </b>{{ getPartylist(x.partylist_id) }}<br />
<hr />
{{ x.description }}
</div>
</div>
</modal-body>
<modal-footer>
<button data-dismiss="modal" class="btn btn-default">Close</button>
</modal-footer>
</modal>
</div> --> <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 />
</div>
<div class="form-group">
<label for="no_anggota">Unit : </label>
<input type="text" name="unit" class="form-control" readonly :value="data.user.unit" required />
</div>
<div class="form-group">
<label for="role">Kehadiran :</label>
<select class="form-control" id="kehadiran" name="kehadiran" value="" required>
<option value="1">Fizikal</option>
<option value="2">Maya</option>
</select>
</div>
<div>
<p> <i>*Elaun akan diberikan setelah pengundi membuat pengesahan kehadiran</i></p>
<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>
</form>
</div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
created: function () {
//console.log(this)
},
data: function () { data: function () {
return { return {
x: {} loading: false
} }
}, },
methods: { methods: {
hasVoted: function () { // refreshUser: function () {
return this.data.result.length > 0; // var vm = this;
}, // axios.get(config.API + 'voter/' + this.data.user.id)
// .then(response => {
// vm.data.user = response.data;
// })
// },
getPartylist: function (id) { edit: function () {
let partylists = this.data.partylists; if (this.loading) return;
for (var i in partylists) this.loading = true;
if (partylists[i]['id'] == id) return partylists[i]['name']; var vm = this;
return 'No Partylist'; this.util.notify('Adding Attendance', 'loading');
}, axios.put(config.API + 'attendance/' + this.data.user.id, $('#edit_form').serialize())
.then(response => {
getPosition: function (id) { $.notifyClose();
let positions = this.data.positions; vm.loading = false;
for (var i in positions) if (vm.util.showResult(response, 'success')) {
if (positions[i].id == id) return positions[i].name; vm.refreshUser();
return ''; vm.$router.push({ name: 'Voter Home' });
}, }
})
getNominee: function (id) { .catch(error => {
let nominees = this.data.nominees; $.notifyClose();
for (var i in nominees) vm.loading = false;
if (nominees[i]['id'] == id) return nominees[i].name; vm.util.showResult(error, 'error')
return ''; })
},
view: function (index) {
this.x = this.data.nominees[index];
this.util.showModal('#nominee-information-modal');
}
},
computed: {
header: function () {
return this.x.name + ' for ' + this.getPosition(this.x.position_id);
} }
} }
} }
@@ -7,28 +7,25 @@
<li class="list-group-item" v-for="position in data.positions"> <li class="list-group-item" v-for="position in data.positions">
<b>{{ position.name }} : </b> <b>{{ position.name }} : </b>
</li> </li>
<ul class="list-group"> <ul class="list-group">
<li class="list-group-item" v-for="nominee_id in selected[0].nominee_id"> <li class="list-group-item" v-for="nominee_id in selected[0].nominee_id">
<b> - {{ getSelectedNomineeName(nominee_id) }}</b> <b> - {{ getSelectedNomineeName(nominee_id) }}</b>
</li>
</ul>
<!-- <ul class="list-group">
<li class="list-group-item" v-for="result in data.result">
<b>{{ getPosition(result.position_id) }} : </b>{{ getNominee(result.nominee_id) }}
</li> </li>
</ul> --> </ul>
<li class="list-group-item"> <li class="list-group-item">
<center> <center>
<button class="btn btn-success" @click="util.showModal('#vote-modal')">Submit Vote</button> <button class="btn btn-success" @click="util.showModal('#vote-modal')">Hantar</button>
<button class="btn btn-default" @click="reset()">Reset</button> <!-- <button class="btn btn-default" @click="reset()">Reset</button> -->
</center> </center>
</li> </li>
</ul> </ul>
</div> </div>
<div class="col-md-8"> <div class="col-md-8">
<h4>Pilih Calon</h4> <h4>Pilih Calon</h4>
<div class="alert alert-warning " role="alert">
Boleh mengundi (2) calon sahaja!
</div>
<hr /> <hr />
<div class="panel panel-info" v-for="position in data.positions"> <div class="panel panel-info" v-for="position in data.positions">
<div class="panel-heading">{{ position.name }}</div> <div class="panel-heading">{{ position.name }}</div>
@@ -36,9 +33,10 @@
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
<tr> <tr>
<th></th>
<th>Bil.</th>
<th></th> <th></th>
<th>Nama</th> <th>Nama</th>
<th>No. Anggota</th>
<th>Unit</th> <th>Unit</th>
</tr> </tr>
</thead> </thead>
@@ -47,8 +45,11 @@
:key="nominee.id"> :key="nominee.id">
<td><input type="checkbox" :id="nominee.id" @change="vote(position.id, nominee.id)" /> <td><input type="checkbox" :id="nominee.id" @change="vote(position.id, nominee.id)" />
</td> </td>
<td>{{ nominee.no_calon }}</td>
<td><img @click="view(i)" :src="createBase64ImageUrl(nominee.photo)" class="thumbnail"
style="height: 60px;width: 60px;" />
</td>
<td>{{ nominee.name }}</td> <td>{{ nominee.name }}</td>
<td>{{ nominee.no_anggota }}</td>
<td>{{ nominee.unit }}</td> <td>{{ nominee.unit }}</td>
</tr> </tr>
</tbody> </tbody>
@@ -62,17 +63,17 @@
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">MyKoPKB </h5> <h5 class="modal-title" id="exampleModalLabel"></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<h3>Nota: You can only vote once, so vote wisely.</h3> <h5>Nota: Sila pastikan anda telah membuat undian dengan betul.</h5>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button>
<button type="button" class="btn btn-primary" @click="submit()">Submit Vote</button> <button type="button" class="btn btn-primary" @click="submit()">Hantar</button>
</div> </div>
</div> </div>
</div> </div>
@@ -132,7 +133,7 @@ export default {
if (vm.util.showResult(response, 'success')) { if (vm.util.showResult(response, 'success')) {
vm.data.result = response.data.result; vm.data.result = response.data.result;
vm.$router.push({ name: 'Voter Home' }); vm.$router.push({ name: 'Voter Home' });
$('.modal').modal('hide'); $('.modal').modal('hide');
} }
}) })
.catch(error => { .catch(error => {
@@ -176,9 +177,9 @@ export default {
console.log(this.selected[0]) console.log(this.selected[0])
}, },
getSelectedNomineeName: function(id) { getSelectedNomineeName: function (id) {
return this.getNominee(id); return this.getNominee(id);
}, },
getName: function (id) { getName: function (id) {
let positions = this.data.positions; let positions = this.data.positions;
@@ -194,7 +195,7 @@ export default {
let positions = this.data.positions; let positions = this.data.positions;
let nominees = this.data.nominees; let nominees = this.data.nominees;
for (var i in nominees) for (var i in nominees)
if (nominees[i]['id']==id) return nominees[i].name; if (nominees[i]['id'] == id) return nominees[i].name;
return ''; return '';
}, },
@@ -211,6 +212,15 @@ export default {
return 'No Partylist'; return 'No Partylist';
}, },
view: function (index) {
this.x = this.data.nominees[index];
this.util.showModal('#nominee-information-modal');
},
createBase64ImageUrl: function (base64ImageData) {
return "data:image/png;base64," + base64ImageData;
}
// uncheck: function (checkedName) { // uncheck: function (checkedName) {
// this.checkedName = this.checkedNames.filter(name => name !== checkedName); // this.checkedName = this.checkedNames.filter(name => name !== checkedName);
// } // }
@@ -16,10 +16,14 @@
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<router-link :to="{name: 'Voter Home'}" tag="li" exact> <router-link :to="{name: 'Voter Home'}" tag="li" exact>
<a href="#">Laman Utama </a> <a href="#">Laman Utama</a>
</router-link> </router-link>
<router-link :to="{name: 'Attendance'}" tag="li" exact> <router-link :to="{name: 'Mat'}" tag="li" exact>
<a href="#">MAT27</a>
</router-link>
<router-link :to="{name: 'Attendance'}" tag="li" exact>
<a href="#">Kehadiran</a> <a href="#">Kehadiran</a>
</router-link> </router-link>
+25 -1
View File
@@ -4,6 +4,7 @@ import VoterVerification from './components/demo/voter/verification.vue';
import VoterHome from './components/demo/voter/index.vue'; import VoterHome from './components/demo/voter/index.vue';
import Home from './components/demo/voter/home/index.vue'; import Home from './components/demo/voter/home/index.vue';
import Mat from './components/demo/voter/home/mat.vue';
import Vote from './components/demo/voter/home/vote.vue'; import Vote from './components/demo/voter/home/vote.vue';
import Result from './components/demo/voter/home/result.vue'; import Result from './components/demo/voter/home/result.vue';
import Attendance from './components/demo/voter/home/attendance.vue'; import Attendance from './components/demo/voter/home/attendance.vue';
@@ -32,6 +33,9 @@ import AdminIndex from './components/demo/admin/index.vue';
import ManageVoterIndex from './components/demo/admin/voter/index.vue'; import ManageVoterIndex from './components/demo/admin/voter/index.vue';
import ManageVoterAdd from './components/demo/admin/voter/add.vue'; import ManageVoterAdd from './components/demo/admin/voter/add.vue';
import ManageVoterEdit from './components/demo/admin/voter/edit.vue'; import ManageVoterEdit from './components/demo/admin/voter/edit.vue';
import KehadiranCalon from './components/demo/admin/voter/kehadiran.vue';
import ViewKehadiranCalon from './components/demo/admin/voter/viewkehadiran.vue';
import ManageNominee from './components/demo/admin/nominee/nominee.vue'; import ManageNominee from './components/demo/admin/nominee/nominee.vue';
import ManageNomineeIndex from './components/demo/admin/nominee/index.vue'; import ManageNomineeIndex from './components/demo/admin/nominee/index.vue';
@@ -44,6 +48,8 @@ import AdminIndex from './components/demo/admin/index.vue';
import ManageAccountPassword from './components/demo/admin/admin/password.vue'; import ManageAccountPassword from './components/demo/admin/admin/password.vue';
import ManageAccountAdd from './components/demo/admin/admin/add.vue'; import ManageAccountAdd from './components/demo/admin/admin/add.vue';
const default_component = { const default_component = {
template: '<div>Not found: {{ $route.path }}</div>' template: '<div>Not found: {{ $route.path }}</div>'
} }
@@ -60,6 +66,12 @@ export default [
name: 'Voter Home' name: 'Voter Home'
}, },
{
path: 'mat27',
component: Mat,
name: 'Mat'
},
{ {
path: 'vote', path: 'vote',
component: Vote, component: Vote,
@@ -208,7 +220,19 @@ export default [
path: 'edit/:id', path: 'edit/:id',
component: ManageVoterEdit, component: ManageVoterEdit,
name: 'Edit Voter' name: 'Edit Voter'
} },
{
path: 'kehadiran',
component: KehadiranCalon,
name: 'Kehadiran Calon'
},
{
path: 'viewkehadiran',
component: ViewKehadiranCalon,
name: 'Calon Hadir'
},
] ]
}, },
+5
View File
@@ -29,6 +29,11 @@ Route::prefix('v1')->group(function(){ //Version 1 of my Rest API
Route::get('election/information', 'API\v1\Election\InformationController'); Route::get('election/information', 'API\v1\Election\InformationController');
Route::post('election/vote', 'API\v1\Election\VoteController')->middleware('isvoted'); Route::post('election/vote', 'API\v1\Election\VoteController')->middleware('isvoted');
Route::get('election/result', 'API\v1\Election\ResultController')->middleware('has_voted'); Route::get('election/result', 'API\v1\Election\ResultController')->middleware('has_voted');
});
Route::prefix('attendance')->group(function(){
Route::put('{id}', 'API\v1\Voter\AttendanceController');
}); });
//Admins API //Admins API