formatted open vote
This commit is contained in:
parent
0c5b31b459
commit
70283bdcb4
@ -12,6 +12,17 @@ class votes {
|
||||
}
|
||||
return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result;
|
||||
}
|
||||
|
||||
public static function get_graph_bt_to_user_overall_by_time ($timespan = 84600,$returnasjson = true){
|
||||
$result = array();
|
||||
$res = \DBD\UVOTE_DATA_GRAPH_BT_TO_USER_OVERALL_BY_TIME::QQ(array($timespan, \SYSTEM\SECURITY\Security::getUser()->id));
|
||||
while ($row = $res->next()){
|
||||
$result[] = array( 0 => $row['day'],
|
||||
'class_match' => $row['class_match'] / ($row['class_match']+$row['class_mismatch']+1),
|
||||
'class_mismatch' => $row['class_mismatch'] / ($row['class_match']+$row['class_mismatch']+1));
|
||||
}
|
||||
return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result;
|
||||
}
|
||||
|
||||
public static function getAllVotesOfGroup($groupid){
|
||||
return \DBD\UVOTE_GENERATE_VOTELIST::QA(array($groupid));}
|
||||
|
||||
19
uVote/dbd/qq/UVOTE_DATA_GRAPH_BT_TO_USER_OVERALL_BY_TIME.php
Normal file
19
uVote/dbd/qq/UVOTE_DATA_GRAPH_BT_TO_USER_OVERALL_BY_TIME.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace DBD;
|
||||
|
||||
class UVOTE_DATA_GRAPH_BT_TO_USER_OVERALL_BY_TIME extends \SYSTEM\DB\QP {
|
||||
protected static function query(){
|
||||
return new \SYSTEM\DB\QQuery(get_class(),
|
||||
//pg
|
||||
'',
|
||||
//mys
|
||||
'SELECT
|
||||
DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(a.`timestamp`) - MOD(UNIX_TIMESTAMP(a.`timestamp`),?)),"%Y/%m/%d %H:%i:%s") as day,
|
||||
SUM(CASE WHEN a.choice = c.bt_choice THEN 1 ELSE 0 END) class_match,
|
||||
SUM(CASE WHEN a.choice = c.bt_choice THEN 0 ELSE 1 END) class_mismatch
|
||||
FROM uvote_data as a
|
||||
LEFT JOIN (Select choice, poll_ID FROM uvote_data WHERE user_ID = ? GROUP BY choice LIMIT 1) b ON a.poll_ID = b.poll_ID
|
||||
LEFT JOIN uvote_votes as c ON a.poll_ID = c.ID
|
||||
WHERE bt_choice
|
||||
GROUP BY day;'
|
||||
);}}
|
||||
@ -1,5 +1,6 @@
|
||||
|
||||
<div class="progress" style="height: 20px; width: 350px; border-style: solid; border-width: 1px;">
|
||||
<h5>${bulletin_bars_title}</h5>
|
||||
Ergebnis uVote
|
||||
<div class="progress" style="height: 20px; width: 350px;">
|
||||
<div class="bar bar-success" style="width: ${vote_yes_perc}%;">${vote_yes_perc}%</div>
|
||||
<div class="bar bar-danger" style="width: ${vote_no_perc}%;">${vote_no_perc}%</div>
|
||||
<div class="bar bar-info" style="width: ${vote_ent_perc}%;">${vote_ent_perc}%</div>
|
||||
|
||||
@ -1,39 +1,34 @@
|
||||
<img src="${frontend_logos}logo2.png" style="" width="35%"/>
|
||||
<br>
|
||||
</br>
|
||||
<table>
|
||||
<div style="float:right">
|
||||
${voice_weight}
|
||||
</div>
|
||||
<tr>
|
||||
Ergebnis uVote
|
||||
${bars_user}
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
Ergebnis Bundestag
|
||||
${bars_bt}
|
||||
</tr>
|
||||
<br>
|
||||
|
||||
|
||||
<tr>
|
||||
${bars_party}
|
||||
</tr>
|
||||
<tr>
|
||||
${choice_party}
|
||||
</tr>
|
||||
</table>
|
||||
<div style="float: left;">
|
||||
<div style="float: left;">
|
||||
|
||||
<div style="float: right;">
|
||||
<div>
|
||||
${vote_buttons}
|
||||
<div style="float: right;">
|
||||
<img src="${frontend_logos}icon_urn_${vote_class}.png"/>
|
||||
</div>
|
||||
<div style="floa: right">
|
||||
${vote_buttons}
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
${voice_weight}
|
||||
</div>
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
<div style="">
|
||||
|
||||
<div>
|
||||
|
||||
${bars_user}
|
||||
</div>
|
||||
<div>
|
||||
|
||||
${bars_bt}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="float: left;">
|
||||
${icons_party}
|
||||
${choice_party}
|
||||
</div>
|
||||
<img src="${frontend_logos}logo2.png" style="" width="35%"/>
|
||||
|
||||
|
||||
<!--<div class="btn" id="test">
|
||||
test
|
||||
|
||||
@ -39,12 +39,17 @@ class default_bulletin extends SYSTEM\PAGE\Page {
|
||||
private function choice_party (){
|
||||
$result = '';
|
||||
$party_votes = votes::get_barsperparty($this->poll_ID);
|
||||
|
||||
// $vote['bt_vote_class'] = $this->tablerow_class($vote['bt_choice']);
|
||||
foreach($party_votes as $pv){
|
||||
|
||||
$result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/vote_bt.tpl'),
|
||||
array( 'party' => $pv['party'],
|
||||
'choice' => $this->get_party_per_poll($pv['choice']),
|
||||
'choice_class' => $this->tablerow_class($pv['choice'])));
|
||||
'choice_class' => $this->tablerow_class($pv['choice']),
|
||||
'party_yes' => round($pv['votes_pro']/$pv['total']*100,0),
|
||||
'party_no' => round($pv['votes_contra']/$pv['total']*100,0),
|
||||
'party_ent' => round(($pv['nr_attending'] - $pv['votes_pro'] - $pv['votes_contra'])/$pv['total']*100,0)));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
@ -72,6 +77,11 @@ class default_bulletin extends SYSTEM\PAGE\Page {
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function icons_party(){
|
||||
$vars = array();
|
||||
return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/icons_table_parties.tpl'), $vars);
|
||||
}
|
||||
|
||||
private function bars_bt(){
|
||||
$vars = votes::get_bar_bt_per_poll($this->poll_ID);
|
||||
if (!$vars['bt_total']){
|
||||
@ -121,14 +131,13 @@ class default_bulletin extends SYSTEM\PAGE\Page {
|
||||
size="3">Enthaltung</font></a>';}
|
||||
$classes = array('','','');
|
||||
switch($user_poll){
|
||||
case 1: $classes = array('btn-success','',''); break;
|
||||
case 2: $classes = array('','btn-danger',''); break;
|
||||
case 3: $classes = array('','','btn-info'); break;
|
||||
case 1: $classes = array('btn-success disabled','btn-danger','btn-info'); break;
|
||||
case 2: $classes = array('btn-success','btn-danger disabled','btn-info'); break;
|
||||
case 3: $classes = array('btn-success','btn-danger','btn-info disabled'); break;
|
||||
default: array('','','');
|
||||
}
|
||||
|
||||
return '
|
||||
<h5>Ändere deine Stimme hier ab</h5>
|
||||
return ' <h5>Ändere deine Stimme hier ab</h5>
|
||||
<a class="btn '.$classes[0].' btn-default btnvote_yes"
|
||||
style="width: 70px"
|
||||
poll_ID="${poll_ID}"><font
|
||||
@ -159,9 +168,10 @@ class default_bulletin extends SYSTEM\PAGE\Page {
|
||||
$user_vote = votes::getUserPollData($this->poll_ID);
|
||||
|
||||
$vars = array();
|
||||
$vars['choice_party'] = $this->choice_party();
|
||||
$vars['choice_party'] = '';
|
||||
$vars['voice_weight'] = $vars['bars_user'] = $vars['bars_bt'] = '';
|
||||
$vars['bars_party'] = 'Erst nach der Abgabe deiner Stimme werden dir die daten angezeigt';
|
||||
$vars['bars_party'] = '';
|
||||
$vars['icons_party'] = '';
|
||||
$vars['vote_class'] = $this->vote_choice();
|
||||
$vars['js'] = $this->js();
|
||||
$vars['css'] = $this->css();
|
||||
@ -169,14 +179,19 @@ class default_bulletin extends SYSTEM\PAGE\Page {
|
||||
$vars['vote_buttons'] = $this->vote_buttons($poll_expired,$user_vote);
|
||||
// $vars['p_fields'] = $this->p_fields();
|
||||
if($user_vote){
|
||||
$vars['bars_party'] = $poll_expired ? '' : $this->bars_party();
|
||||
$vars['icons_party'] = $this->icons_party();
|
||||
$vars['choice_party'] = $this->choice_party();
|
||||
$vars['bars_party'] = $this->bars_party();
|
||||
$vars['bars_user'] = $this->bars_user();
|
||||
$vars['bars_bt'] = $this->bars_bt();
|
||||
$vars['voice_weight'] = $this->voice_weight();
|
||||
}
|
||||
|
||||
$vars['poll_ID'] = $this->poll_ID; //put it here - so its filled in!
|
||||
$vars['frontend_logos'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).'api.php?call=img&cat=frontend_logos&id=';
|
||||
$vars['frontend_logos'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).'api.php?call=img&cat=frontend_logos&id=';
|
||||
$vars = array_merge($vars, \SYSTEM\locale::getStrings(DBD\locale_string::VALUE_CATEGORY_MAINPAGE));
|
||||
$vars = array_merge($vars, \SYSTEM\locale::getStrings(150));
|
||||
$vars = array_merge($vars, \SYSTEM\locale::getStrings(100));
|
||||
|
||||
$vars = array_merge($vars,votes::get_voteinfo($this->poll_ID));
|
||||
return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/bulletin.tpl'),$vars);
|
||||
|
||||
7
uVote/page/default_bulletin/icons_table_parties.tpl
Normal file
7
uVote/page/default_bulletin/icons_table_parties.tpl
Normal file
@ -0,0 +1,7 @@
|
||||
<div style="width: 500px; float: left">
|
||||
<div style="float: left"><img src="${frontend_logos}icon_urn.png" width="30"/></div>
|
||||
<div style="float: left"></div>
|
||||
<div style="margin-left: 50px; float: left"><img src="${frontend_logos}icon_urn_pro.png" width="30"/></div>
|
||||
<div style="margin-left: 15px; float: left"><img src="${frontend_logos}icon_urn_con.png" width="30"/></div>
|
||||
<div style="margin-left: 15px; float: left"><img src="${frontend_logos}icon_urn_ent.png" width="30"/></div>
|
||||
</div>
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
<div class="progress" style="height: 20px; width: 350px; border-style: solid; border-width: 1px;">
|
||||
Ergebnis Bundestag
|
||||
<div class="progress" style="height: 20px; width: 350px;">
|
||||
<div class="bar bar-success" style="width: ${bt_pro}%;">${bt_pro}%</div>
|
||||
<div class="bar bar-danger" style="width: ${bt_con}%;">${bt_con}%</div>
|
||||
<div class="bar bar-info" style="width: ${bt_ent}%;"><p>${bt_ent}%</p></div>
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
<div style="float: left; margin-right: 10px;">
|
||||
<img src="${frontend_logos}icon_${party}.png"/>
|
||||
<div class="progress" style="width: 50px; height: 20px;">
|
||||
<div class="bar bar-success" style="width: ${party_yes}%;"></div>
|
||||
<div class="bar bar-danger" style="width: ${party_no}%;"></div>
|
||||
<div class="bar bar-info" style="width: ${party_ent}%;"><p></p></div>
|
||||
<div style="width: 50px; height: 20px;">
|
||||
<div class="badge badge-success" style="">${party_yes}%</div>
|
||||
<div class="badge badge-danger" style="">${party_no}%</div>
|
||||
<div class="badge badge-info" style="">${party_ent}%</div>
|
||||
</div>
|
||||
${choice}
|
||||
</div>
|
||||
@ -1 +1,7 @@
|
||||
<img src="${frontend_logos}icon_${party}.png" width="30"/><span class="badge ${choice_class}">${choice}</span><br/>
|
||||
<div style="width: 500px; float: left">
|
||||
<div style="float: left"><img src="${frontend_logos}icon_${party}.png" width="30"/></div>
|
||||
<div style="margin-left: 5px; width: 20px; float: left"class="badge ${choice_class}">${choice}</div>
|
||||
<div style="margin-left: 5px; width: 20px; float: left"class="badge badge-success">${party_yes}%</div>
|
||||
<div style="margin-left: 5px; width: 20px; float: left"class="badge badge-important">${party_no}%</div>
|
||||
<div style="margin-left: 5px; width: 20px; float: left"class="badge badge-info">${party_ent}%</div>
|
||||
</div>
|
||||
@ -1,6 +1,5 @@
|
||||
<div class="row" style="margin: 0;">
|
||||
<div class="span6">
|
||||
<h3>${title}</h3>
|
||||
<div class="span6" style="float: right">
|
||||
Quelle: <a href="${iframe_link}">${iframe_link} </a>
|
||||
</div>
|
||||
<div class="span6" style="width: 50%;">
|
||||
|
||||
@ -265,6 +265,34 @@ function load_visualisation(id, timespan){
|
||||
first = true;
|
||||
data.addRow($.map(value, function(v) { if(first){first=false;return [new Date(v)];}else{return [parseFloat(v)];}}));});
|
||||
|
||||
console.log(data);
|
||||
var options = {title: id, aggregationTarget: 'category', selectionMode: 'multiple', curveType: 'function', /*focusTarget: 'category',*/ chartArea:{}, vAxis:{logScale: false}, interpolateNulls: false, width: "300", height: "250"};
|
||||
new google.visualization.LineChart(document.getElementById(id)).draw(data, options);
|
||||
});
|
||||
}
|
||||
function load_visualisation_urvote(id, timespan){
|
||||
$('img#loader').show();
|
||||
$.getJSON('./api.php?call=graph_bt_to_user_overall_by_time',function(json){
|
||||
if(!json || json.status != true || !json.result){
|
||||
$('img#loader').hide();
|
||||
return;
|
||||
}
|
||||
json = json.result;
|
||||
$('img#loader').hide();
|
||||
var data = new google.visualization.DataTable();
|
||||
first = true;
|
||||
$.each(json[0], function(key, value){
|
||||
if(first){
|
||||
data.addColumn('datetime',key);
|
||||
first = false;
|
||||
} else {
|
||||
data.addColumn('number',key);
|
||||
}
|
||||
});
|
||||
$.each(json, function(key, value){
|
||||
first = true;
|
||||
data.addRow($.map(value, function(v) { if(first){first=false;return [new Date(v)];}else{return [parseFloat(v)];}}));});
|
||||
|
||||
console.log(data);
|
||||
var options = {title: id, aggregationTarget: 'category', selectionMode: 'multiple', curveType: 'function', /*focusTarget: 'category',*/ chartArea:{}, vAxis:{logScale: false}, interpolateNulls: false, width: "300", height: "250"};
|
||||
new google.visualization.LineChart(document.getElementById(id)).draw(data, options);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user