merge_ui
This commit is contained in:
@@ -31,7 +31,8 @@ class AddController extends Controller
|
|||||||
'name' => 'required|unique:users',
|
'name' => 'required|unique:users',
|
||||||
'email' => 'required|email|unique:users',
|
'email' => 'required|email|unique:users',
|
||||||
'password' => 'required',
|
'password' => 'required',
|
||||||
'confirm_password' => 'same:password'
|
'confirm_password' => 'same:password',
|
||||||
|
'role' => 'required'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,55 +32,80 @@ class VoteController extends Controller
|
|||||||
|
|
||||||
private function insertVote($request)
|
private function insertVote($request)
|
||||||
{
|
{
|
||||||
foreach ($request->vote as $key => $value) {
|
// dd($request->vote[0]['nominee_id']);
|
||||||
Result::updateOrCreate([
|
$votes = array_map(function($nominee_id) use($request){
|
||||||
|
return[
|
||||||
'voter_id' => Auth::id(),
|
'voter_id' => Auth::id(),
|
||||||
'election_id' => Util::getCurrentElection(),
|
'election_id' => Util::getCurrentElection(),
|
||||||
'position_id' => $value['position_id'],
|
'position_id' => $request->vote[0]['position_id'],
|
||||||
], ['nominee_id' => $value['nominee_id']]);
|
'nominee_id' => $nominee_id
|
||||||
|
];
|
||||||
|
|
||||||
|
},$request->vote[0]['nominee_id']);
|
||||||
|
|
||||||
|
foreach($votes as $vote){
|
||||||
|
Result::updateOrCreate([
|
||||||
|
'voter_id' => $vote['voter_id'],
|
||||||
|
'election_id' => $vote['election_id'],
|
||||||
|
'position_id' => $vote['position_id'],
|
||||||
|
'nominee_id' => $vote['nominee_id'],
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function validNominee($id, $position_id)
|
private function validNominee($id, $position_id)
|
||||||
{
|
{
|
||||||
return Nominee::where([
|
try{
|
||||||
['id', '=', $id],
|
$nominee = Nominee::where('position_id', '=', $position_id)->whereIn('id',$id)->count();
|
||||||
['position_id', '=', $position_id]
|
}catch(Exception $e){
|
||||||
])->count();
|
dd($id);
|
||||||
|
}
|
||||||
|
return $nominee;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isPositionExist($id)
|
private function isPositionExist($id)
|
||||||
{
|
{
|
||||||
return Position::where('id', $id)->count();
|
try{
|
||||||
|
return Position::where('id', $id)->count();
|
||||||
|
}catch(Exception $e){
|
||||||
|
dd($id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function voteAllPosition($request)
|
private function voteAllPosition($request)
|
||||||
{
|
{
|
||||||
$total_position = Position::where('election_id', Util::getCurrentElection())->count();
|
$total_position = Position::where('election_id', Util::getCurrentElection())->count();
|
||||||
$total_vote = count($request->vote);
|
$total_vote = !empty($request->vote) ? count($request->vote) : 0;
|
||||||
|
|
||||||
return $total_vote >= $total_position;
|
return $total_vote >= $total_position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function validateRequest($request)
|
private function validateRequest($request)
|
||||||
{
|
{
|
||||||
$result['status'] = 'failed';
|
$result['status'] = 'failed';
|
||||||
$vote = $request->vote;
|
$vote = $request->vote;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the user vote on all position
|
* Check if the user vote on all position
|
||||||
*/
|
*/
|
||||||
if (!$this->voteAllPosition($request)) {
|
if (!$this->voteAllPosition($request)) {
|
||||||
|
dd('test');
|
||||||
$result['message'] = 'You must vote on all position.';
|
$result['message'] = 'You must vote on all position.';
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($vote as $key => $value) {
|
foreach ($vote as $value) {
|
||||||
/**
|
/**
|
||||||
* Check if position_id and nominee_id has a value
|
* Check if position_id and nominee_id has a value
|
||||||
*/
|
*/
|
||||||
|
// dd($vote,$value);
|
||||||
if (empty($value['position_id']) || empty($value['nominee_id'])) {
|
if (empty($value['position_id']) || empty($value['nominee_id'])) {
|
||||||
|
|
||||||
|
dd($value,empty($value['position_id']),empty($value['nominee_id']));
|
||||||
$result['message'] = 'You must vote on all position.';
|
$result['message'] = 'You must vote on all position.';
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@@ -90,6 +115,7 @@ class VoteController extends Controller
|
|||||||
* Check if the Position you vote exists
|
* Check if the Position you vote exists
|
||||||
*/
|
*/
|
||||||
if (!$this->isPositionExist($value['position_id'])) {
|
if (!$this->isPositionExist($value['position_id'])) {
|
||||||
|
dd('test');
|
||||||
$result['message'] = 'Invalid Position.';
|
$result['message'] = 'Invalid Position.';
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@@ -97,8 +123,11 @@ class VoteController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Check if the Nominee you vote on certain position exists
|
* Check if the Nominee you vote on certain position exists
|
||||||
*/
|
*/
|
||||||
elseif (!$this->validNominee($value['nominee_id'], $value['position_id'])) {
|
// elseif (!$this->validNominee($value['nominee_id'], $value['position_id'])) {
|
||||||
|
elseif($this->validNominee($value['nominee_id'],$value['position_id']) <= 0){
|
||||||
|
|
||||||
$result['message'] = 'Invalid Nominee for '.Position::find($value['position_id'])->name.' position.';
|
$result['message'] = 'Invalid Nominee for '.Position::find($value['position_id'])->name.' position.';
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,7 +149,6 @@ class LoginController extends Controller
|
|||||||
$mobileno = '6' . $tele;
|
$mobileno = '6' . $tele;
|
||||||
$messages = sprintf(config('onewaysms.message'),$tac_token,$date);
|
$messages = sprintf(config('onewaysms.message'),$tac_token,$date);
|
||||||
|
|
||||||
var_dump($mobileno,$messages);
|
|
||||||
$parameter = [
|
$parameter = [
|
||||||
'apiusername' => env("ONEWAY_SMS_USERNAME"),
|
'apiusername' => env("ONEWAY_SMS_USERNAME"),
|
||||||
'apipassword' => env("ONEWAY_SMS_PASSWORD"),
|
'apipassword' => env("ONEWAY_SMS_PASSWORD"),
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ class User extends Authenticatable
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name', 'email', 'password',
|
'name', 'email', 'password', 'role'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -10,5 +10,5 @@ class Voter extends Authenticatable
|
|||||||
use HasApiTokens;
|
use HasApiTokens;
|
||||||
|
|
||||||
protected $table = 'voter';
|
protected $table = 'voter';
|
||||||
protected $fillable = ['name', 'no_kp', 'no_anggota','unit', 'election_id', 'alamat', 'telefon'];
|
protected $fillable = ['name', 'no_kp', 'no_anggota','unit', 'election_id', 'alamat', 'telefon', 'saham', 'yuran'];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'message' => 'KOPERASI : TAC: %s - %s NOMBOR TAC',
|
'message' => 'KoPKB : %s is your TAC to log in to your myKoPKB Member account. It will expire in 5 minutes.',
|
||||||
'minutes' => 5
|
'minutes' => 5
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class AddPhotoColumnToNomineeTable extends Migration
|
class AddPhotoColumnToNomineeTable extends Migration
|
||||||
{
|
{
|
||||||
@@ -14,9 +15,16 @@ class AddPhotoColumnToNomineeTable extends Migration
|
|||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::table('nominee', function (Blueprint $table) {
|
Schema::table('nominee', function (Blueprint $table) {
|
||||||
$table->binary('photo')->nullable();
|
|
||||||
$table->dropColumn('image');
|
$table->dropColumn('image');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (Schema::hasColumn('nominee', 'image_path')) {
|
||||||
|
Schema::table('nominee', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('image_path');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::statement("ALTER TABLE nominee ADD photo MEDIUMBLOB");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddRoleToUsersTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
$table->string('role', 60)->nullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
// DB::statement("ALTER TABLE nominee ADD photo MEDIUMBLOB");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
$table->dropColumn('role');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddSahamToVoterTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('voter', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
$table->decimal('saham', 9,2);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('voter', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
$table->dropColumn('saham');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddYuranToVoterTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('voter', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
$table->decimal('yuran', 9,2);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('voter', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
$table->dropColumn('yuran');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,62 +1,71 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<form id="add_form" @submit.prevent="add()">
|
<form id="add_form" @submit.prevent="add()">
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="name">Nama</label>
|
<label for="name">Nama</label>
|
||||||
<input type="text" name="name" class="form-control" required/>
|
<input type="text" name="name" class="form-control" required />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="email">Email</label>
|
<label for="email">Email</label>
|
||||||
<input type="email" name="email" class="form-control" required/>
|
<input type="email" name="email" class="form-control" required />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="password">Password</label>
|
<label for="password">Password</label>
|
||||||
<input type="password" name="password" class="form-control" required/>
|
<input type="password" name="password" class="form-control" required />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="confirm_password">Confirm Password</label>
|
<label for="confirm_password">Confirm Password</label>
|
||||||
<input type="password" name="confirm_password" class="form-control" required/>
|
<input type="password" name="confirm_password" class="form-control" required />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="submit" value="Submit" class="btn btn-info"/>
|
<label for="role">Role</label>
|
||||||
<router-link :to="{name: 'Manage Account'}" class="btn btn-default">Back</router-link>
|
<select class="form-control" id="role" name="role"
|
||||||
</div>
|
value="" required>
|
||||||
|
<option value="1">Admin</option>
|
||||||
|
<option value="2">Jawatankuasa Audit</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
</form>
|
<div class="form-group">
|
||||||
|
<input type="submit" value="Submit" class="btn btn-info" />
|
||||||
|
<router-link :to="{ name: 'Manage Account' }" class="btn btn-default">Back</router-link>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default{
|
export default {
|
||||||
data: () => ({
|
data: () => ({
|
||||||
loading: false
|
loading: false
|
||||||
}),
|
}),
|
||||||
|
|
||||||
methods:{
|
methods: {
|
||||||
add: function () {
|
add: function () {
|
||||||
if (this.loading || !this.isPasswordMatch()) return;
|
if (this.loading || !this.isPasswordMatch()) return;
|
||||||
var vm = this;
|
var vm = this;
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.util.notify('Adding Admin', 'loading');
|
this.util.notify('Adding Admin', 'loading');
|
||||||
axios.post(config.API+'admin', $('#add_form').serialize())
|
axios.post(config.API + 'admin', $('#add_form').serialize())
|
||||||
.then(response=>{
|
.then(response => {
|
||||||
vm.loading = false;
|
vm.loading = false;
|
||||||
$.notifyClose();
|
$.notifyClose();
|
||||||
if (vm.util.showResult(response, 'success')) {
|
if (vm.util.showResult(response, 'success')) {
|
||||||
vm.$router.push({name: 'Manage Account'});
|
vm.$router.push({ name: 'Manage Account' });
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error=>{
|
.catch(error => {
|
||||||
vm.loading = false;
|
vm.loading = false;
|
||||||
$.notifyClose();
|
$.notifyClose();
|
||||||
vm.util.showResult(error, 'error')
|
vm.util.showResult(error, 'error')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -65,6 +74,6 @@ export default{
|
|||||||
if (!isMatch) this.util.notify('Password not match', 'error');
|
if (!isMatch) this.util.notify('Password not match', 'error');
|
||||||
return isMatch;
|
return isMatch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -1,118 +1,142 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<h4>Undian terkini </h4>
|
<h4> Recent Elections</h4>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button class="btn btn-success" v-if="data.election.status == 1" @click="util.showModal('#start-election-modal')">Start Election</button>
|
<button class="btn btn-success" v-if="data.election.status == 1 && data.user.role==1"
|
||||||
|
@click="util.showModal('#start-election-modal')">Start Election</button>
|
||||||
<router-link :to="{name: 'Current Result'}" class="btn btn-info" v-if="data.election.status == 2">
|
|
||||||
View Results
|
|
||||||
</router-link>
|
|
||||||
|
|
||||||
<button class="btn btn-danger" v-if="data.election.status == 2" @click="util.showModal('#stop-election-modal')">End Election</button>
|
|
||||||
|
|
||||||
<label v-if="data.election.status == 2">Undian telah bermula {{ start_date }}</label>
|
<router-link :to="{ name: 'Current Result' }" class="btn btn-info" v-if="data.election.status == 2">
|
||||||
|
View Results
|
||||||
|
</router-link>
|
||||||
|
|
||||||
|
<button class="btn btn-danger" v-if="data.election.status == 2"
|
||||||
|
@click="util.showModal('#stop-election-modal')">End Election</button>
|
||||||
|
|
||||||
|
<label v-if="data.election.status == 2">Election has Started {{ start_date }}</label>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Election Name</th>
|
||||||
|
<th>Election Start</th>
|
||||||
|
<th>Election End</th>
|
||||||
|
<th>View</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="election in data.elections">
|
||||||
|
<td>{{ election.id }}</td>
|
||||||
|
<td>{{ election.name }}</td>
|
||||||
|
<td>{{ election.start }}</td>
|
||||||
|
<td>{{ election.end }}</td>
|
||||||
|
<td>
|
||||||
|
<router-link :to="{ name: 'Election Result', params: { election_id: election.id } }"
|
||||||
|
class="btn btn-info">View Result</router-link>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr v-if="data.elections.length < 1">
|
||||||
|
<td colspan="5">No elections yet</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form @submit.prevent="start" id="start_form">
|
||||||
|
<div class="modal fade" id="start-election-modal" tabindex="-1" role="dialog"
|
||||||
|
aria-labelledby="start-election-modal" aria-hidden="true">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="exampleModalLabel">Start Election</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">Election Name</label>
|
||||||
|
<input type="text" name="name" autocomplete="on" class="form-control" placeholder="(Optional)" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="password">Confirm Password</label>
|
||||||
|
<input type="password" name="password" class="form-control" required />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<input type="submit" class="btn btn-info" value="Start" />
|
||||||
|
<input type="button" data-dismiss="modal" class="btn btn-default" value="Cancel" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form @submit.prevent="stop" id="stop_form">
|
||||||
|
<div class="modal fade" id="stop-election-modal" tabindex="-1" role="dialog"
|
||||||
|
aria-labelledby="stop-election-modal" aria-hidden="true">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="exampleModalLabel">Stop Election</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">Election Name</label>
|
||||||
|
<input type="text" name="name" :value="data.election.name" autocomplete="on" class="form-control" placeholder="(Optional)" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="password">Confirm Password</label>
|
||||||
|
<input type="password" name="password" autocomplete="on" class="form-control" required />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<input type="submit" class="btn btn-info" value="Stop Election" />
|
||||||
|
<input type="button" data-dismiss="modal" class="btn btn-default" value="Cancel" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table table-hover">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>ID</th>
|
|
||||||
<th>Nama Pengundi</th>
|
|
||||||
<th>Undian Mula </th>
|
|
||||||
<th>Undian Tamat</th>
|
|
||||||
<th>Papar</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr v-for="election in data.elections">
|
|
||||||
<td>{{ election.id }}</td>
|
|
||||||
<td>{{ election.name }}</td>
|
|
||||||
<td>{{ election.start}}</td>
|
|
||||||
<td>{{ election.end}}</td>
|
|
||||||
<td>
|
|
||||||
<router-link :to="{name: 'Election Result', params:{election_id:election.id}}" class="btn btn-info">View Result</router-link></td>
|
|
||||||
</tr>
|
|
||||||
<tr v-if="data.elections.length < 1">
|
|
||||||
<td colspan="5">No elections yet</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form @submit.prevent="start" id="start_form">
|
|
||||||
<modal id="start-election-modal">
|
|
||||||
<modal-header>Start Election</modal-header>
|
|
||||||
<modal-body>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="name">Election Name</label>
|
|
||||||
<input type="text" name="name" class="form-control" placeholder="(Optional)"/>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="password">Confirm Password</label>
|
|
||||||
<input type="password" name="password" class="form-control" required/>
|
|
||||||
</div>
|
|
||||||
</modal-body>
|
|
||||||
<modal-footer>
|
|
||||||
<input type="submit" class="btn btn-info" value="Start"/>
|
|
||||||
<input type="button" data-dismiss="modal" class="btn btn-default" value="Cancel"/>
|
|
||||||
</modal-footer>
|
|
||||||
</modal>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<form @submit.prevent="stop" id="stop_form">
|
|
||||||
<modal id="stop-election-modal">
|
|
||||||
<modal-header>Stop Election</modal-header>
|
|
||||||
<modal-body>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="name">Election Name</label>
|
|
||||||
<input type="text" name="name" :value="data.election.name" class="form-control" placeholder="(Optional)"/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="password">Sahkan Kata Laluan</label>
|
|
||||||
<input type="password" name="password" class="form-control" required/>
|
|
||||||
</div>
|
|
||||||
</modal-body>
|
|
||||||
<modal-footer>
|
|
||||||
<input type="submit" class="btn btn-danger" value="Stop Election"/>
|
|
||||||
<input type="button" class="btn btn-default" data-dismiss="modal" value="Cancel"/>
|
|
||||||
</modal-footer>
|
|
||||||
</modal>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default{
|
export default {
|
||||||
data: ()=>({
|
data: () => ({
|
||||||
start_date: null
|
start_date: null
|
||||||
}),
|
}),
|
||||||
created: function () {
|
created: function () {
|
||||||
this.refreshElection();
|
this.refreshElection();
|
||||||
var vm = this;
|
var vm = this;
|
||||||
setInterval(()=>{
|
setInterval(() => {
|
||||||
vm.start_date = moment(vm.data.election.start).fromNow();
|
vm.start_date = moment(vm.data.election.start).fromNow();
|
||||||
},1000);
|
}, 1000);
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
stop: function () {
|
stop: function () {
|
||||||
var vm = this;
|
var vm = this;
|
||||||
this.util.hideModal('#stop-election-modal');
|
// this.util.hideModal('#stop-election-modal');
|
||||||
this.util.notify('Stopping Election', 'loading');
|
this.util.notify('Stopping Election', 'loading');
|
||||||
axios.post(config.API+'election/stop', $('#stop_form').serialize())
|
axios.post(config.API + 'election/stop', $('#stop_form').serialize())
|
||||||
.then(response=>{
|
.then(response => {
|
||||||
$.notifyClose();
|
$.notifyClose();
|
||||||
if (vm.util.showResult(response,'success')) {
|
if (vm.util.showResult(response, 'success')) {
|
||||||
vm.refreshElection();
|
vm.refreshElection();
|
||||||
vm.data.election =response.data.election;
|
vm.data.election = response.data.election;
|
||||||
vm.data.positions = [];
|
vm.data.positions = [];
|
||||||
vm.data.partylists = [];
|
vm.data.partylists = [];
|
||||||
vm.data.voters = [];
|
vm.data.voters = [];
|
||||||
@@ -120,7 +144,7 @@ export default{
|
|||||||
vm.data.results = [];
|
vm.data.results = [];
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error=>{
|
.catch(error => {
|
||||||
$.notifyClose();
|
$.notifyClose();
|
||||||
vm.util.showResult(error, 'error');
|
vm.util.showResult(error, 'error');
|
||||||
})
|
})
|
||||||
@@ -128,31 +152,32 @@ export default{
|
|||||||
|
|
||||||
start: function () {
|
start: function () {
|
||||||
var vm = this;
|
var vm = this;
|
||||||
this.util.hideModal('#start-election-modal');
|
// this.util.hideModal('#start-election-modal');
|
||||||
|
console.log('this');
|
||||||
this.util.notify('Loading please wait', 'loading');
|
this.util.notify('Loading please wait', 'loading');
|
||||||
axios.post(config.API+'election/start', $('#start_form').serialize())
|
axios.post(config.API + 'election/start', $('#start_form').serialize())
|
||||||
.then(response=>{
|
.then(response => {
|
||||||
$.notifyClose();
|
$.notifyClose();
|
||||||
if(vm.util.showResult(response, 'success')){
|
if (vm.util.showResult(response, 'success')) {
|
||||||
vm.refreshElection();
|
vm.refreshElection();
|
||||||
vm.data.election = response.data.election;
|
vm.data.election = response.data.election;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error=>{
|
.catch(error => {
|
||||||
$.notifyClose();
|
$.notifyClose();
|
||||||
vm.util.showResult(error, 'error');
|
vm.util.showResult(error, 'error');
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshElection: function(){
|
refreshElection: function () {
|
||||||
this.util.notify('Refreshing Election', 'loading');
|
this.util.notify('Refreshing Election', 'loading');
|
||||||
var vm = this;
|
var vm = this;
|
||||||
axios.get(config.API+'election')
|
axios.get(config.API + 'election')
|
||||||
.then(response=>{
|
.then(response => {
|
||||||
$.notifyClose();
|
$.notifyClose();
|
||||||
vm.data.elections = response.data;
|
vm.data.elections = response.data;
|
||||||
})
|
})
|
||||||
.catch(error=>{
|
.catch(error => {
|
||||||
$.notifyClose();
|
$.notifyClose();
|
||||||
vm.util.showResult(error, 'error');
|
vm.util.showResult(error, 'error');
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -14,22 +14,21 @@
|
|||||||
<div class="collapse navbar-collapse" id="myNavbar">
|
<div class="collapse navbar-collapse" id="myNavbar">
|
||||||
|
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
|
<!-- {{ users }} -->
|
||||||
<router-link :to="{name: 'Admin Home'}" tag="li" exact><a href="#">Home</a></router-link>
|
<router-link :to="{name: 'Admin Home'}" tag="li" exact><a href="#">Home</a></router-link>
|
||||||
|
<router-link :to="{name: 'Kemaskini Jawatan'}" v-if="data.user.role==1" tag="li">
|
||||||
<router-link :to="{name: 'Kemaskini Jawatan'}" tag="li">
|
|
||||||
<a href="#">Jawatan</a>
|
<a href="#">Jawatan</a>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
<router-link :to="{name: 'Manage Partylist'}" 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'}" 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>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
<router-link :to="{name: 'Maklumat Calon'}" tag="li">
|
<router-link :to="{name: 'Maklumat Calon'}" v-if="data.user.role==1" tag="li">
|
||||||
<a href="#">Calon</a>
|
<a href="#">Calon</a>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
@@ -75,9 +74,10 @@
|
|||||||
<script>
|
<script>
|
||||||
export default{
|
export default{
|
||||||
|
|
||||||
data: () =>({
|
// data: () =>({
|
||||||
loading: true
|
// loading: true,
|
||||||
}),
|
// users:{'roles' : 1},
|
||||||
|
// }),
|
||||||
|
|
||||||
created: function () {
|
created: function () {
|
||||||
this.util.setTitle('Voting System - Administrator');
|
this.util.setTitle('Voting System - Administrator');
|
||||||
|
|||||||
@@ -34,6 +34,16 @@
|
|||||||
<input type="text" name="telefon" class="form-control" required>
|
<input type="text" name="telefon" class="form-control" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="saham">Saham</label>
|
||||||
|
<input type="text" name="saham" class="form-control" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="yuran">Yuran</label>
|
||||||
|
<input type="text" name="yuran" class="form-control" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button type="submit" class="btn btn-success">Submit</button>
|
<button type="submit" class="btn btn-success">Submit</button>
|
||||||
<router-link :to="{name: 'Manage Voter'}" class="btn btn-default">Back</router-link>
|
<router-link :to="{name: 'Manage Voter'}" class="btn btn-default">Back</router-link>
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
<th>No. Kad Pengenalan</th>
|
<th>No. Kad Pengenalan</th>
|
||||||
<th>No. Anggota</th>
|
<th>No. Anggota</th>
|
||||||
<th>Unit</th>
|
<th>Unit</th>
|
||||||
|
<th>Saham</th>
|
||||||
|
<th>Yuran</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -29,6 +31,8 @@
|
|||||||
<td>{{ voter.no_kp }}</td>
|
<td>{{ voter.no_kp }}</td>
|
||||||
<td>{{ voter.no_anggota }}</td>
|
<td>{{ voter.no_anggota }}</td>
|
||||||
<td>{{ voter.unit }}</td>
|
<td>{{ voter.unit }}</td>
|
||||||
|
<td>{{ voter.saham }}</td>
|
||||||
|
<td>{{ voter.yuran }}</td>
|
||||||
<td>
|
<td>
|
||||||
<button class="btn btn-info" @click="edit(i)">
|
<button class="btn btn-info" @click="edit(i)">
|
||||||
<i class="fa fa-edit"></i> Edit
|
<i class="fa fa-edit"></i> Edit
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
<li class="list-group-item"><b>No. Anggota : </b>{{ data.user.no_anggota }}</li>
|
<li class="list-group-item"><b>No. Anggota : </b>{{ data.user.no_anggota }}</li>
|
||||||
<li class="list-group-item"><b>Nama : </b>{{ data.user.name }}</li>
|
<li class="list-group-item"><b>Nama : </b>{{ data.user.name }}</li>
|
||||||
<li class="list-group-item"><b>Unit : </b>{{ data.user.unit }}</li>
|
<li class="list-group-item"><b>Unit : </b>{{ data.user.unit }}</li>
|
||||||
|
<li class="list-group-item"><b>Saham : </b>{{ data.user.saham }}</li>
|
||||||
|
<li class="list-group-item"><b>Yuran : </b>{{ data.user.yuran }}</li>
|
||||||
<li class="list-group-item" v-if="data.election.status==1">
|
<li class="list-group-item" v-if="data.election.status==1">
|
||||||
<center>Undian belum bermula</center>
|
<center>Undian belum bermula</center>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -1,69 +1,89 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="row col-md-10 col-md-offset-1">
|
<div class="row col-md-10 col-md-offset-1">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<h4>Maklumat Undian</h4><hr/>
|
<h4>Maklumat Undian</h4>
|
||||||
<ul class="list-group">
|
<hr />
|
||||||
<li class="list-group-item" v-for="position in data.positions">
|
<ul class="list-group">
|
||||||
<b>{{ position.name }} : </b>{{ getName(position.id) }}
|
<li class="list-group-item" v-for="position in data.positions">
|
||||||
</li>
|
<b>{{ position.name }} : </b>{{ getName(position.id) }}
|
||||||
<li class="list-group-item">
|
</li>
|
||||||
<center>
|
|
||||||
<button class="btn btn-success" @click="util.showModal('#vote-modal')">Submit Vote</button>
|
<!-- <ul class="list-group">
|
||||||
<button class="btn btn-default" @click="reset()">Reset</button>
|
<li class="list-group-item" v-for="result in data.result">
|
||||||
</center>
|
<b>{{ getPosition(result.position_id) }} : </b>{{ getNominee(result.nominee_id) }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul> -->
|
||||||
</div>
|
|
||||||
<div class="col-md-8">
|
<li class="list-group-item">
|
||||||
<h4>Pilih Calon </h4><hr/>
|
<center>
|
||||||
<div class="panel panel-info" v-for="position in data.positions">
|
<button class="btn btn-success" @click="util.showModal('#vote-modal')">Submit Vote</button>
|
||||||
<div class="panel-heading">{{ position.name }}</div>
|
<button class="btn btn-default" @click="reset()">Reset</button>
|
||||||
<div class="panel-body table-responsive">
|
</center>
|
||||||
<table class="table table-hover">
|
</li>
|
||||||
<thead>
|
</ul>
|
||||||
<tr>
|
</div>
|
||||||
<th></th>
|
<div class="col-md-8">
|
||||||
<th>Nama</th>
|
<h4>Pilih Calon</h4>
|
||||||
<th>Partylist</th>
|
<hr />
|
||||||
<th>Unit</th>
|
<div class="panel panel-info" v-for="position in data.positions">
|
||||||
</tr>
|
<div class="panel-heading">{{ position.name }}</div>
|
||||||
</thead>
|
<div class="panel-body table-responsive">
|
||||||
<tbody>
|
<table class="table table-hover">
|
||||||
<tr v-for="nominee in data.nominees" v-if="nominee.position_id==position.id" @click="vote(position.id,nominee.id)">
|
<thead>
|
||||||
<td><input type="radio" :name="position.id" :id="nominee.id"/></td>
|
<tr>
|
||||||
<td>{{ nominee.name }}</td>
|
<th></th>
|
||||||
<td>{{ getPartylist(nominee.partylist_id) }}</td>
|
<th>Name</th>
|
||||||
<td>{{ nominee.unit }}</td>
|
<th>No. Anggota</th>
|
||||||
</tr>
|
<th>Unit</th>
|
||||||
</tbody>
|
</tr>
|
||||||
</table>
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="(nominee, index) in data.nominees" v-if="nominee.position_id == position.id"
|
||||||
|
:key="nominee.id">
|
||||||
|
<td><input type="checkbox" :id="nominee.id" @change="vote(position.id, nominee.id)" />
|
||||||
|
</td>
|
||||||
|
<td>{{ nominee.name }}</td>
|
||||||
|
<td>{{ nominee.no_anggota }}</td>
|
||||||
|
<td>{{ nominee.unit }}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal" id="vote-modal" tabindex="-2" role="dialog" aria-labelledby="exampleModalLabel"
|
||||||
|
aria-hidden="true">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="exampleModalLabel">AGM</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<h3>Nota: You can only vote once, so vote wisely.</h3>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
|
<button type="button" class="btn btn-primary" @click="submit()">Submit Vote</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<modal id="vote-modal">
|
|
||||||
<modal-header>UNDIAN</modal-header>
|
|
||||||
<modal-body>
|
|
||||||
<h3>Note: You can only vote once, so vote wisely.</h3>
|
|
||||||
</modal-body>
|
|
||||||
<modal-footer>
|
|
||||||
<button class="btn btn-success" @click="submit()">Submit Vote</button>
|
|
||||||
<button class="btn btn-default" data-dismiss="modal">Cancel</button>
|
|
||||||
</modal-footer>
|
|
||||||
</modal>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default{
|
export default {
|
||||||
created: function () {
|
created: function () {
|
||||||
if (this.data.result.length > 0 || this.data.election.status != 2)
|
if (this.data.result.length > 0 || this.data.election.status != 2)
|
||||||
this.$router.push({name: 'Voter Home'})
|
this.$router.push({ name: 'Voter Home' })
|
||||||
for (var i in this.data.positions) {
|
for (var i in this.data.positions) {
|
||||||
this.selected.push({
|
this.selected.push({
|
||||||
position_id: this.data.positions[i]['id'],
|
position_id: this.data.positions[i]['id'],
|
||||||
nominee_id: null,
|
nominee_id: [],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -71,39 +91,56 @@ export default{
|
|||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
selected: [],
|
selected: [],
|
||||||
name: {}
|
name: {},
|
||||||
|
selectedNominees: {
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
test: function () {
|
||||||
|
console.log('tab');
|
||||||
|
this.util.showModal('#vote-modal')
|
||||||
|
},
|
||||||
submit: function () {
|
submit: function () {
|
||||||
this.util.hideModal('#vote-modal');
|
if (Object.keys(this.selected).length === 0) {
|
||||||
if (this.hasNullVote()) return;
|
// No selections made
|
||||||
|
this.util.notify('Please select at least one nominee.', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var vm = this;
|
var vm = this;
|
||||||
this.util.notify('Submitting your vote, please wait...', 'loading');
|
this.util.notify('Submitting your vote, please wait...', 'loading');
|
||||||
let data = {};
|
console.log(this.selected)
|
||||||
data['vote'] = this.selected;
|
// Prepare data to send to the server
|
||||||
axios.post(config.API+'election/vote', data)
|
let data = {
|
||||||
.then(response=>{
|
vote: this.selected
|
||||||
$.notifyClose();
|
};
|
||||||
if (vm.util.showResult(response, 'success')){
|
|
||||||
vm.data.result = response.data.result;
|
|
||||||
vm.$router.push({name: 'Voter Home'});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Log the data to ensure it's correctly formatted
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
// Send a POST request to the server
|
||||||
|
axios.post(config.API + 'election/vote', data)
|
||||||
|
.then(response => {
|
||||||
|
$.notifyClose();
|
||||||
|
if (vm.util.showResult(response, 'success')) {
|
||||||
|
vm.data.result = response.data.result;
|
||||||
|
vm.$router.push({ name: 'Voter Home' });
|
||||||
|
$('.modal').modal('hide');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(error=>{
|
.catch(error => {
|
||||||
$.notifyClose();
|
$.notifyClose();
|
||||||
vm.util.showResult(error, 'error');
|
vm.util.showResult(error, 'error');
|
||||||
})
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
hasNullVote: function () {
|
hasNullVote: function () {
|
||||||
let selected = this.selected;
|
console.log('null' + this.selectedNominees);
|
||||||
for (var i in selected)
|
let selected = this.selectedNominees;
|
||||||
if (selected[i]['nominee_id'] == null){
|
for (var i in selected)
|
||||||
|
if (selected[i]['nominee_id'] == null) {
|
||||||
this.util.notify('You must vote on all position', 'error');
|
this.util.notify('You must vote on all position', 'error');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -111,42 +148,62 @@ export default{
|
|||||||
},
|
},
|
||||||
|
|
||||||
reset: function () {
|
reset: function () {
|
||||||
let selected = this.selected;
|
console.log(this.selectedNominees);
|
||||||
for (var i in selected){
|
let selected = this.selectedNominees;
|
||||||
$('#'+selected[i]['nominee_id']).selected(false);
|
for (var i in selected) {
|
||||||
|
$('#' + selected[i]['nominee_id']).selected(false);
|
||||||
selected[i]['nominee_id'] = null;
|
selected[i]['nominee_id'] = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
vote: function (position_id, nominee_id) {
|
vote: function (position_id, nominee_id) {
|
||||||
$('#'+nominee_id).selected();
|
if (!this.selected[0]['position_id']) {
|
||||||
for (var i in this.selected)
|
this.$set(this.selected[0], position_id, []);
|
||||||
if (this.selected[i]['position_id'] == position_id) {
|
}
|
||||||
this.selected[i]['nominee_id'] = nominee_id;
|
const index = this.selected[0]['nominee_id'].indexOf(nominee_id);
|
||||||
}
|
if (index === -1) {
|
||||||
|
// Nominee not found, add it
|
||||||
|
this.selected[0]['nominee_id'].push(nominee_id);
|
||||||
|
} else {
|
||||||
|
// Nominee found, remove it
|
||||||
|
this.selected[0]['nominee_id'].splice(index, 1);
|
||||||
|
}
|
||||||
|
console.log(this.selected[0])
|
||||||
},
|
},
|
||||||
|
|
||||||
getName: function (id) {
|
getName: function (id) {
|
||||||
let positions = this.data.positions;
|
let positions = this.data.positions;
|
||||||
let selected = this.selected;
|
let selected = this.selected;
|
||||||
for (var i in selected)
|
for (var i in selected)
|
||||||
if (selected[i]['position_id'] == id)
|
if (selected[i]['position_id'] == id)
|
||||||
return this.getNominee(selected[i]['nominee_id']);
|
return this.getNominee(selected[i]['nominee_id']);
|
||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
|
|
||||||
getNominee: function (id) {
|
getNominee: function (id) {
|
||||||
|
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 '';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// getNominee: function (id) {
|
||||||
|
// let nominees = this.data.nominees;
|
||||||
|
// for (var i in nominees)
|
||||||
|
// if (nominees[i]['id'] == id) return nominees[i]['name'];
|
||||||
|
// },
|
||||||
|
|
||||||
getPartylist: function (id) {
|
getPartylist: function (id) {
|
||||||
let partylists = this.data.partylists;
|
let partylists = this.data.partylists;
|
||||||
for (var i in partylists)
|
for (var i in partylists)
|
||||||
if (partylists[i]['id']==id) return partylists[i]['name'];
|
if (partylists[i]['id'] == id) return partylists[i]['name'];
|
||||||
return 'No Partylist';
|
return 'No Partylist';
|
||||||
}
|
},
|
||||||
|
|
||||||
|
// uncheck: function (checkedName) {
|
||||||
|
// this.checkedName = this.checkedNames.filter(name => name !== checkedName);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -27,12 +27,12 @@
|
|||||||
<a href="#">Pautan Zoom</a>
|
<a href="#">Pautan Zoom</a>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
<router-link :to="{name: 'Vote'}" v-if="data.election.status==2 && !hasVoted()" tag="li" exact>
|
<router-link :to="{name: 'Vote'}" v-if="data.election.status==2 && data.user.saham >= 500 && !hasVoted()" tag="li" exact>
|
||||||
<a href="#">Vote</a>
|
<a href="#">Undian</a>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
<router-link :to="{name: 'Result'}" v-if="data.election.status==2 && hasVoted()" tag="li">
|
<router-link :to="{name: 'Result'}" v-if="data.election.status==2 && hasVoted()" tag="li">
|
||||||
<a href="#">Results</a>
|
<a href="#">Keputusan</a>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head lang="en">
|
<head lang="en">
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>MyKoPKB == eVoting System</title>
|
<title>MyKoPKB == eVoting System</title>
|
||||||
@@ -10,32 +11,40 @@
|
|||||||
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="error"></div>
|
<div id="error"></div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
window.config = {
|
window.config = {
|
||||||
"API":"/api/v1/", //URL OF YOUR API LOCATED
|
"API": "/api/v1/", //URL OF YOUR API LOCATED
|
||||||
"baseURL":"/", //URL OF YOUR WEBSITE
|
"baseURL": "/", //URL OF YOUR WEBSITE
|
||||||
"storageURL":"{{ config('app.cloudinary_enabled') ? '' : '/storage/' }}", //URL WHERE YOUR IMAGES and OTHER FILEs stored
|
"storageURL": "{{ config('app.cloudinary_enabled') ? '' : '/storage/' }}", //URL WHERE YOUR IMAGES and OTHER FILEs stored
|
||||||
"debug": {{ env('APP_DEBUG') }}
|
"debug": {{ env('APP_DEBUG') }}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
|
||||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>
|
integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous">
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.1/axios.min.js" integrity="sha512-bZS47S7sPOxkjU/4Bt0zrhEtWx0y0CRkhEp8IckzK+ltifIIE9EMIMTuT/mEzoIMewUINruDBIR/jJnbguonqQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
</script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap-notify@3.1.3/bootstrap-notify.min.js" integrity="sha256-DRllCE/8rrevSAnSMWB4XO3zpr+3WaSuqUSNLD5NAzg=" crossorigin="anonymous"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/jquery-form@4.3.0/dist/jquery.form.min.js" integrity="sha256-3TKcZElR88BBIA6CeePJAGOsW1yIYf4lP8pI333YuZw=" crossorigin="anonymous"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.1/axios.min.js"
|
||||||
<script src="https://cdn.jsdelivr.net/npm/jquery-flot@0.8.3/jquery.flot.min.js"></script>
|
integrity="sha512-bZS47S7sPOxkjU/4Bt0zrhEtWx0y0CRkhEp8IckzK+ltifIIE9EMIMTuT/mEzoIMewUINruDBIR/jJnbguonqQ=="
|
||||||
<script src="https://cdn.jsdelivr.net/npm/jquery-flot@0.8.3/jquery.flot.pie.min.js"></script>
|
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/moment@2.29.1/moment.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap-notify@3.1.3/bootstrap-notify.min.js"
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue-router@3.4.9/dist/vue-router.min.js"></script>
|
integrity="sha256-DRllCE/8rrevSAnSMWB4XO3zpr+3WaSuqUSNLD5NAzg=" crossorigin="anonymous"></script>
|
||||||
<script src="/js/app.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/jquery-form@4.3.0/dist/jquery.form.min.js"
|
||||||
|
integrity="sha256-3TKcZElR88BBIA6CeePJAGOsW1yIYf4lP8pI333YuZw=" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/jquery-flot@0.8.3/jquery.flot.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/jquery-flot@0.8.3/jquery.flot.pie.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/moment@2.29.1/moment.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/vue-router@3.4.9/dist/vue-router.min.js"></script>
|
||||||
|
<script src="/js/app.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user