statistics for vote.tpl thx to rylon
This commit is contained in:
parent
4993da10e9
commit
ebaf058a70
@ -87,6 +87,9 @@ class votes {
|
||||
return \DBD\UVOTE_DATA_USER_TO_BT::QA(array($user_ID));
|
||||
}
|
||||
|
||||
public static function get_users_choice_per_poll($poll_ID){
|
||||
return \DBD\UVOTE_DATA_USERS_CHOICE_PER_POLL::QA(array($poll_ID));}
|
||||
|
||||
public static function get_voteinfo($poll_ID){
|
||||
$con = new \SYSTEM\DB\Connection(new \DBD\uVote());
|
||||
$res = $con->prepare( 'selVoteByID',
|
||||
@ -98,6 +101,11 @@ class votes {
|
||||
|
||||
public static function get_barsperparty($poll_ID){
|
||||
return \DBD\UVOTE_DATA_PARTY_PER_POLL::QA(array($poll_ID));}
|
||||
|
||||
public static function get_party_choice($poll_ID, $party){
|
||||
$res = \DBD\UVOTE_DATA_PARTY_CHOICE_PER_POLL::Q1(array($poll_ID, $party));
|
||||
return $res;
|
||||
}
|
||||
|
||||
public static function write_vote($poll_ID, $vote){
|
||||
if(!\SYSTEM\SECURITY\Security::isLoggedIn()){
|
||||
|
||||
11
uVote/dbd/qq/UVOTE_DATA_PARTY_CHOICE_PER_POLL.php
Normal file
11
uVote/dbd/qq/UVOTE_DATA_PARTY_CHOICE_PER_POLL.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace DBD;
|
||||
|
||||
class UVOTE_DATA_PARTY_CHOICE_PER_POLL extends \SYSTEM\DB\QP {
|
||||
protected static function query(){
|
||||
return new \SYSTEM\DB\QQuery(get_class(),
|
||||
//pg
|
||||
'',
|
||||
//mys
|
||||
'SELECT `choice` FROM `uvote_votes_per_party` WHERE `poll_ID` = ? AND `party` = ?;'
|
||||
);}}
|
||||
11
uVote/dbd/qq/UVOTE_DATA_USERS_CHOICE_PER_POLL.php
Normal file
11
uVote/dbd/qq/UVOTE_DATA_USERS_CHOICE_PER_POLL.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace DBD;
|
||||
|
||||
class UVOTE_DATA_USERS_CHOICE_PER_POLL extends \SYSTEM\DB\QP {
|
||||
protected static function query(){
|
||||
return new \SYSTEM\DB\QQuery(get_class(),
|
||||
//pg
|
||||
'',
|
||||
//mys
|
||||
'SELECT COUNT(*) as count, choice FROM uvote_data WHERE `poll_ID` = ? GROUP BY choice ORDER BY count DESC;'
|
||||
);}}
|
||||
@ -37,14 +37,42 @@ class default_page extends SYSTEM\PAGE\Page {
|
||||
foreach($votes as $vote){
|
||||
$time_remain = strtotime($vote['time_end'])- microtime(true);
|
||||
$time_span = strtotime($vote['time_end']) - strtotime($vote['time_start']);
|
||||
$vote['vote_class'] = $this->tablerow_class(votes::getUserPollData($vote['ID']));
|
||||
$vote['vote_class'] = $this->tablerow_class(votes::getUserPollData($vote['ID']));
|
||||
$vote['bt_vote_class'] = $this->tablerow_class($vote['bt_choice']);
|
||||
$vote['full_vote_btn'] = $time_remain > 0 ? 'Abstimmen' : 'Ansehen';
|
||||
$vote['time_left'] = round($time_remain/($time_span+1)*100,0);
|
||||
$vote['time_done'] = 100-$vote['time_left'];
|
||||
$cdu = votes::get_party_choice($vote['ID'], 'cdu');
|
||||
$vote['cdu'] = $this->get_party_per_poll($cdu['choice']);
|
||||
$vote['choice_class_cdu'] = $this->tablerow_class($cdu['choice']);
|
||||
$csu = votes::get_party_choice($vote['ID'], 'csu');
|
||||
$vote['csu'] = $this->get_party_per_poll($csu['choice']);
|
||||
$vote['choice_class_csu'] = $this->tablerow_class($csu['choice']);
|
||||
$spd = votes::get_party_choice($vote['ID'], 'spd');
|
||||
$vote['spd'] = $this->get_party_per_poll($spd['choice']);
|
||||
$vote['choice_class_spd'] = $this->tablerow_class($spd['choice']);
|
||||
$gruene = votes::get_party_choice($vote['ID'], 'gruene');
|
||||
$vote['gruene'] = $this->get_party_per_poll($gruene['choice']);
|
||||
$vote['choice_class_gruene'] = $this->tablerow_class($gruene['choice']);
|
||||
$linke = votes::get_party_choice($vote['ID'], 'linke');
|
||||
$vote['linke'] = $this->get_party_per_poll($linke['choice']);
|
||||
$vote['choice_class_linke'] = $this->tablerow_class($linke['choice']);
|
||||
|
||||
if($time_remain > 0){
|
||||
|
||||
$uvote = votes::get_users_choice_per_poll($vote['ID']);
|
||||
$vote['uv_vote_class'] = count($uvote) > 0 ? $this->tablerow_class($uvote[0]['choice']) : '';
|
||||
|
||||
$vote['uv_pro'] = $vote['uv_con'] = $vote['uv_ent'] = '<2';
|
||||
foreach($uvote as $v){
|
||||
switch($v['choice']){
|
||||
case 1: $vote['uv_pro'] = $v['count'] > 1 ? $v['count'] : '<2'; break;
|
||||
case 2: $vote['uv_con'] = $v['count'] > 1 ? $v['count'] : '<2'; break;
|
||||
case 3: $vote['uv_ent'] = $v['count'] > 1 ? $v['count'] : '<2'; break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
$vote['title'] = utf8_encode($vote['title']);
|
||||
|
||||
if($time_remain > 0){
|
||||
$result[0] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/vote.tpl'), $vote);
|
||||
} else {
|
||||
$result[1] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/vote.tpl'), $vote);
|
||||
@ -53,6 +81,23 @@ class default_page extends SYSTEM\PAGE\Page {
|
||||
return $result[0].$result[1];
|
||||
}
|
||||
|
||||
private function get_party_per_poll($choice){
|
||||
switch($choice){
|
||||
case 1:
|
||||
return 'PRO';
|
||||
case 2:
|
||||
return 'CON';
|
||||
case 3:
|
||||
return 'ENT';
|
||||
default:
|
||||
return 'NONE';
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function get_coverpage(){
|
||||
return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/cover.tpl'), array());}
|
||||
|
||||
|
||||
4
uVote/page/default_page/parties_on_vote.tpl
Normal file
4
uVote/page/default_page/parties_on_vote.tpl
Normal file
@ -0,0 +1,4 @@
|
||||
<td class="${bt_vote_class}" style="width: 80px; margin-top: 10px; border-left: 1px solid lightgray;">
|
||||
<img src="${frontend_logos}icon_${party}.png" width="30"/><span class="badge badge-success" style="float:right;">${choice}</span><br/>
|
||||
|
||||
</td>
|
||||
@ -6,17 +6,17 @@
|
||||
<a class="btn btn-primary btn-small btn_vote" style="float:right" poll_ID="${ID}">${full_vote_btn}</a>
|
||||
</td>
|
||||
<td class="${bt_vote_class}" style="width: 80px; margin-top: 10px; border-left: 1px solid lightgray;">
|
||||
<img src="${frontend_logos}icon_cdu.png" width="30"/><span class="badge badge-success" style="float:right;">123</span><br/>
|
||||
<img src="${frontend_logos}icon_csu.png" width="30"/><span class="badge badge-important" style="float:right;">123</span><br/>
|
||||
<img src="${frontend_logos}icon_spd.png" width="30"/><span class="badge" style="float:right;">123</span><br/>
|
||||
<img src="${frontend_logos}icon_gruene.png" width="30"/><span class="badge badge-success" style="float:right;">123</span><br/>
|
||||
<img src="${frontend_logos}icon_linke.png" width="30"/><span class="badge badge-important" style="float:right;">123</span>
|
||||
<img src="${frontend_logos}icon_cdu.png" width="30"/><span class="badge ${choice_class_cdu}" style="float:right;">${cdu}</span><br/>
|
||||
<img src="${frontend_logos}icon_csu.png" width="30"/><span class="badge ${choice_class_csu}" style="float:right;">${csu}</span><br/>
|
||||
<img src="${frontend_logos}icon_spd.png" width="30"/><span class="badge ${choice_class_spd}" style="float:right;">${spd}</span><br/>
|
||||
<img src="${frontend_logos}icon_gruene.png" width="30"/><span class="badge ${choice_class_gruene}" style="float:right;">${gruene}</span><br/>
|
||||
<img src="${frontend_logos}icon_linke.png" width="30"/><span class="badge ${choice_class_linke}" style="float:right;">${linke}</span>
|
||||
</td>
|
||||
<td class="" style="width: 30px; margin-top: 10px; border-left: 1px solid lightgray;">
|
||||
<td class="${uv_vote_class}" style="width: 30px; margin-top: 10px; border-left: 1px solid lightgray;">
|
||||
uv
|
||||
<span class="badge badge-success" style="float:right;">123</span>
|
||||
<span class="badge badge-important" style="float:right;">123</span>
|
||||
<span class="badge" style="float:right;">123</span>
|
||||
<span class="badge badge-success" style="float:right;">${uv_pro}</span>
|
||||
<span class="badge badge-important" style="float:right;">${uv_con}</span>
|
||||
<span class="badge" style="float:right;">${uv_ent}</span>
|
||||
</td>
|
||||
<td class="${vote_class}" style="width: 20px; margin-top: 10px; border-left: 1px solid lightgray;">
|
||||
</td>
|
||||
|
||||
@ -4,5 +4,5 @@
|
||||
</td>
|
||||
<td><span class="badge badge-success">${class_MATCH}</span></td>
|
||||
<td><span class="badge badge-important">${class_MISSMATCH}</span></td>
|
||||
<td><span class="badge">${match_percentage}</span></td>
|
||||
<td><span class="badge">${match_percentage}%</span></td>
|
||||
</tr>
|
||||
Loading…
x
Reference in New Issue
Block a user