new push,

started disentangling api,
need to disentangle js!!!
This commit is contained in:
Naeltard 2015-10-07 21:40:20 +02:00
parent ed7a4312ea
commit ee288cb1ff
24 changed files with 555 additions and 436 deletions

View File

@ -23,22 +23,24 @@ class api_uvote extends \SYSTEM\API\api_system {
return votes::vote_accord_with_party($party);}
//graphs
public static function call_graph_bt_to_uvote_overall_by_time($timespan = 84600){
public static function call_graph_bt_to_uvote_overall_by_time($timespan = 592200){
return graphs::graph_bt_to_uvote_overall_by_time($timespan);}
public static function call_graph_bt_to_user_overall_by_time($timespan = 84600){
public static function call_graph_bt_to_user_overall_by_time($timespan = 592200){
return graphs::graph_bt_to_user_overall_by_time($timespan);}
public static function call_graph_party_to_user_overall_by_time_party_cdu($party = 'cdu', $timespan = 84600){
public static function call_graph_party_to_user_overall_by_time_party_cdu($party = 'cdu', $timespan = 592200){
return graphs::graph_party_to_user_overall_by_time($party, $timespan);}
public static function call_graph_party_to_user_overall_by_time_party_csu($party = 'csu', $timespan = 84600){
public static function call_graph_party_to_user_overall_by_time_party_csu($party = 'csu', $timespan = 592200){
return graphs::graph_party_to_user_overall_by_time($party, $timespan);}
public static function call_graph_party_to_user_overall_by_time_party_spd($party = 'spd', $timespan = 84600){
public static function call_graph_party_to_user_overall_by_time_party_spd($party = 'spd', $timespan = 592200){
return graphs::graph_party_to_user_overall_by_time($party, $timespan);}
public static function call_graph_party_to_user_overall_by_time_party_gruene($party = 'gruene', $timespan = 84600){
public static function call_graph_party_to_user_overall_by_time_party_gruene($party = 'gruene', $timespan = 592200){
return graphs::graph_party_to_user_overall_by_time($party, $timespan);}
public static function call_graph_party_to_user_overall_by_time_party_linke($party = 'linke', $timespan = 84600){
public static function call_graph_party_to_user_overall_by_time_party_linke($party = 'linke', $timespan = 592200){
return graphs::graph_party_to_user_overall_by_time($party, $timespan);}
public static function call_donut_party_to_user_overall(){
return graphs::donut_party_to_user_overall();}
//comments
public static function call_vote_action_comment($poll_ID, $c_choice, $c_txt, $c_src) {
return comments::write_comment($poll_ID, $c_choice, $c_txt, $c_src);}

133
uvote/api/votes/bars.php Normal file
View File

@ -0,0 +1,133 @@
<?php
class bars{
public static function get_user_choice_overall($user_ID){
$vars = \SQL\UVOTE_DATA_USER_CHOICE_OVERALL::Q1(array($user_ID));
$vars['user_total_total'] = $vars['user_total_pro'] + $vars['user_total_con'] + $vars['user_total_ent'];
$vars['user_total_pro_percentage'] = round($vars['user_total_pro']/$vars['user_total_total']*100+1);
$vars['user_total_con_percentage'] = round($vars['user_total_con']/$vars['user_total_total']*100+1);
$vars['user_total_ent_percentage'] = round($vars['user_total_ent']/$vars['user_total_total']*100+1);
return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/user_total.tpl'),$vars);
}
public static function user_per_party_overall(){
//$vars = votes::get_user_per_party_overall(array(\SYSTEM\SECURITY\Security::getUser()->id));
$result = '';
$con = new \SYSTEM\DB\Connection();
$res = $con->prepare( 'test',
'SELECT party, sum(case when uvote_data.choice = uvote_votes_per_party.choice then 1 else 0 end) class_MATCH,
sum(case when uvote_data.choice != uvote_votes_per_party.choice then 1 else 0 end) class_MISSMATCH
FROM uvote_data INNER JOIN uvote_votes_per_party
ON uvote_data.poll_ID = uvote_votes_per_party.poll_ID
WHERE user_ID = ? GROUP BY party;',
array(\SYSTEM\SECURITY\Security::getUser()->id));
$i = 0;
while($row = $res->next()){
$res2 = votes::vote_accord_with_party($row['party']);
$row['according_laws'] = self::build_according_law_html($res2, $row['party']);
$row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH'])*100,2);
$result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/urvoteparties.tpl'), $row);;
}
return $result;
}
public static function build_according_law_html($part, $party){
$part = json_decode($part, true);
$result = "<div class='row' style='overflow-x: scroll; overflow-y: hide; max-width: 600px; max-height: 600px;'><font color='black'><h6><i>Bei folgenden Gesetzen hast du genauso abgestimmt wie die ".$party.":</i></h6><hr>";
foreach ($part['result'] as $p){
$result .= $p['title']."<hr>";
}
$result .= "</font><hr><button id='close_popup' type='button' class='btn btn-primary'>schließen</button></div>";
new INFO($result);
return $result;
}
public static function user_per_party_by_choicetype($choice){
$bar = switchers::bar_class($choice);
$result = '';
$con = new \SYSTEM\DB\Connection();
$res = $con->prepare( 'user_to_party_by_choice',
'SELECT party, sum(case when uvote_data.choice = uvote_votes_per_party.choice then 1 else 0 end) class_MATCH,
sum(case when uvote_data.choice != uvote_votes_per_party.choice then 1 else 0 end) class_MISSMATCH
FROM uvote_data INNER JOIN uvote_votes_per_party
ON uvote_data.poll_ID = uvote_votes_per_party.poll_ID
WHERE user_ID = ? AND uvote_data.choice = ? GROUP BY party;',
array(\SYSTEM\SECURITY\Security::getUser()->id, $choice));
$i = 0;
while($row = $res->next()){
$row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH'])*100,2);
$row['bar'] = $bar;
$result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/urvoteparties_by_choice.tpl'), $row);;
}
if(empty($result)){
return 'Keine relevanten Daten verfügbar';
}
return $result;
}
public static function user_per_bt_by_choicetype($choice){
switch($choice){
case 1:
$bar = 'progress-bar-success';
$icon_type = 'pro';
break;
case 2:
$bar = 'progress-bar-danger';
$icon_type = 'con';
break;
case 3:
$bar = 'progress-bar-info';
$icon_type = 'ent';
break;
case 0:
$bar = 'progress-bar';
}
$result = '';
$con = new \SYSTEM\DB\Connection();
$res = $con->prepare( 'user_to_party_by_choice_bt',
'SELECT user_ID, sum(case when uvote_data.choice = uvote_votes.bt_choice then 1 else 0 end) class_MATCH,
sum(case when uvote_data.choice != uvote_votes.bt_choice then 1 else 0 end) class_MISSMATCH
FROM uvote_data INNER JOIN uvote_votes
ON uvote_data.poll_ID = uvote_votes.ID
WHERE user_ID = ? AND uvote_data.choice = ? GROUP by user_ID;',
array(\SYSTEM\SECURITY\Security::getUser()->id, $choice));
$i = 0;
while($row = $res->next()){
if(empty($row['class_MATCH'])){
return 'Keine relevanten Daten verfügbar <br>';
}
$row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH'])*100,2);
$row['bar'] = $bar;
$row['icon_type'] = $icon_type;
$result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/urvotebt_by_choice.tpl'), $row);;
}
if(empty($result)){
return 'Keine relevanten Daten verfügbar';
}
return $result;
}
public static function user_to_bt(){
//$vars = votes::get_user_per_party_overall($user_ID);
$result = '';
$con = new \SYSTEM\DB\Connection();
$res = $con->prepare( 'bt_to_user',
'SELECT sum(case when uvote_data.choice = uvote_votes.bt_choice then 1 else 0 end) class_MATCH,
sum(case when uvote_data.choice != uvote_votes.bt_choice then 1 else 0 end) class_MISSMATCH
FROM uvote_data LEFT JOIN uvote_votes
ON uvote_data.poll_ID = uvote_votes.ID
WHERE user_ID = ?;',
array(\SYSTEM\SECURITY\Security::getUser()->id));
while($row = $res->next()){
$row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH']+1)*100,2);
$result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/bt_to_user_overall.tpl'), $row);
}
return $result;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

View File

@ -27,9 +27,20 @@ class graphs {
public static function graph_party_to_user_overall_by_time ($party, $timespan, $returnasjson = true){
$result = array();
$res = \SQL\UVOTE_DATA_GRAPH_PARTY_TO_USER_OVERALL_BY_TIME::QQ(array($timespan, \SYSTEM\SECURITY\Security::getUser()->id, $party, \SYSTEM\SECURITY\Security::getUser()->id));
$total = \SQL\UVOTE_DATA_GRAPH_PARTY_TO_USER_OVERALL_BY_TIME_OVERMATCH::Q1(array($party, \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_match' => $row['class_match'] / $total['total']*100);
}
return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result;
}
public static function donut_party_to_user_overall ($returnasjson = true){
$result = array();
$res = \SQL\UVOTE_DATA_USER_TO_PARTIES_OVERALL::QQ(array(13));
while ($row = $res->next()){
$result[] = array( 0 => $row['party'],
'class_match' => $row['class_MATCH']);
}
return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result;
}

62
uvote/api/votes/lists.php Normal file
View File

@ -0,0 +1,62 @@
<?php
class lists{
public static function generate_votelist(){
$result = array('','');
$votes = votes::getAllVotesOfGroup(1);
foreach($votes as $vote){
$time_remain = strtotime($vote['time_end'])- microtime(true);
$time_span = strtotime($vote['time_end']) - strtotime($vote['time_start']);
$vote_count = votes::get_count_user_votes_per_poll($vote['ID']);
// $vote['title'] = utf8_encode($vote['title']);
$vote['time_left'] = round($time_remain/($time_span+1)*100,0);
$vote['time_done'] = 100-$vote['time_left'];
$vote['full_vote_btn'] = $time_remain > 0 ? 'Abstimmen' : 'Ansehen';
$vote['uv'] = $vote['bt'] = '';
$vote['uv_count'] = $vote_count['count'] > 4 ? $vote_count['count'] : '< 5';
$user_vote = votes::getUserPollData($vote['ID']);
$vote['vote_class'] = switchers::tablerow_class($user_vote);
if($user_vote){
//user vote
$vote['vote_class'] = switchers::tablerow_class($user_vote);
//bt vote
$party_votes = votes::get_barsperparty($vote['ID']);
$vote['bt_vote_class'] = switchers::tablerow_class($vote['bt_choice']);
foreach($party_votes as $pv){
$vote['bt'] .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/vote_bt.tpl'),
array( 'party' => $pv['party'],
'choice' => switchers::get_party_per_poll($pv['choice']),
'choice_class' => switchers::badge_class($pv['choice'])));
}
//uvote vote
$uvote = votes::get_users_choice_per_poll($vote['ID']);
$vote['uv_vote_class'] = count($uvote) > 0 ? switchers::tablerow_class($uvote[0]['choice']) : '';
foreach($uvote as $v){
$vote['uv'] .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/tpl/vote_uv.tpl'),
array( 'badge' => switchers::badge_class($v['choice']),
'perc' => $v['count'] > 0 ? round($v['count']/$vote_count['count']*100, 2) : 0));
}
}
//new panels:
$vote['panel_class'] = switchers::panel_class($user_vote);
if($time_remain > 0){
$result[0] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/vote.tpl'), $vote);
} else {
$result[1] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/vote.tpl'), $vote);
}
}
return $result[0].$result[1];
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

View File

@ -0,0 +1,71 @@
<?php
class switchers{
public static function get_party_per_poll($choice){
switch($choice){
case 1:
return 'PRO';
case 2:
return 'CON';
case 3:
return 'ENT';
default:
return 'NONE';
}
}
public static function tablerow_class($choice){
switch($choice){
case 1:
return 'pro';
case 2:
return 'con';
case 3:
return 'ent';
default:
return 'open';
}
}
public static function badge_class($choice){
switch($choice){
case 1:
return 'badge-success';
case 2:
return 'badge-danger';
case 3:
return 'badge-info';
default:
return '';
}
}
public static function panel_class($choice){
switch($choice){
case 1:
return 'panel-success';
case 2:
return 'panel-danger';
case 3:
return 'panel-info';
default:
return 'panel-default';
}
}
public static function bar_class($choice){
switch($choice){
case 1:
return 'progress-bar-success';
case 2:
return 'progress-bar-danger';
case 3:
return 'progress-bar-info';
case 0:
return 'progress-bar';
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

View File

@ -11,9 +11,7 @@ class votes {
$res = \SQL\UVOTE_DATA_COUNT_VOTES::QQ();
return $res;}
public static function get_user_choice_overall($user_ID){
return \SQL\UVOTE_DATA_USER_CHOICE_OVERALL::Q1(array($user_ID));
}
public static function get_user_choice_per_poll($poll_ID, $user_ID){
return \SQL\UVOTE_DATA_USER_CHOICE_PER_POLL::Q1(array($poll_ID, $user_ID));
@ -29,84 +27,8 @@ class votes {
$result = $res->next();
return $result['choice'];
}
public static function get_user_match_per_choice($choice){
switch($choice){
case 1:
$bar = 'progress-bar-success';
break;
case 2:
$bar = 'progress-bar-danger';
break;
case 3:
$bar = 'progress-bar-info';
break;
case 0:
$bar = 'progress-bar';
}
$result = '';
$con = new \SYSTEM\DB\Connection();
$res = $con->prepare( 'user_to_party_by_choice',
'SELECT party, sum(case when uvote_data.choice = uvote_votes_per_party.choice then 1 else 0 end) class_MATCH,
sum(case when uvote_data.choice != uvote_votes_per_party.choice then 1 else 0 end) class_MISSMATCH
FROM uvote_data INNER JOIN uvote_votes_per_party
ON uvote_data.poll_ID = uvote_votes_per_party.poll_ID
WHERE user_ID = ? AND uvote_data.choice = ? GROUP BY party;',
array(\SYSTEM\SECURITY\Security::getUser()->id, $choice));
$i = 0;
while($row = $res->next()){
$row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH'])*100,2);
$row['bar'] = $bar;
$result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/urvoteparties_by_choice.tpl'), $row);;
}
if(empty($result)){
return 'Keine relevanten Daten verfügbar';
}
return $result;
}
public static function get_user_match_per_choice_bt($choice){
switch($choice){
case 1:
$bar = 'progress-bar-success';
$icon_type = 'pro';
break;
case 2:
$bar = 'progress-bar-danger';
$icon_type = 'con';
break;
case 3:
$bar = 'progress-bar-info';
$icon_type = 'ent';
break;
case 0:
$bar = 'progress-bar';
}
$result = '';
$con = new \SYSTEM\DB\Connection();
$res = $con->prepare( 'user_to_party_by_choice_bt',
'SELECT user_ID, sum(case when uvote_data.choice = uvote_votes.bt_choice then 1 else 0 end) class_MATCH,
sum(case when uvote_data.choice != uvote_votes.bt_choice then 1 else 0 end) class_MISSMATCH
FROM uvote_data INNER JOIN uvote_votes
ON uvote_data.poll_ID = uvote_votes.ID
WHERE user_ID = ? AND uvote_data.choice = ? GROUP by user_ID;',
array(\SYSTEM\SECURITY\Security::getUser()->id, $choice));
$i = 0;
while($row = $res->next()){
if(empty($row['class_MATCH'])){
return 'Keine relevanten Daten verfügbar <br>';
}
$row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH'])*100,2);
$row['bar'] = $bar;
$row['icon_type'] = $icon_type;
$result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/urvotebt_by_choice.tpl'), $row);;
}
if(empty($result)){
return 'Keine relevanten Daten verfügbar';
}
return $result;
}
public static function get_barsperusers($poll_ID,$return_as_json = true){
$con = new \SYSTEM\DB\Connection();
//count
@ -153,11 +75,26 @@ class votes {
return $res;
}
public static function get_user_temp_votes($user_ID){
return \SQL\UVOTE_DATA_TEMP_VOTES::Q1(array($user_ID, $user_ID));}
public static function get_user_temp_votes(){
$vars = \SQL\UVOTE_DATA_TEMP_VOTES::Q1(array(\SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->id));
$v = $vars['voted'];
$nv = $vars['not_voted'];
print_r($vars, true);
return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/all_polls.tpl'),
array( 'vote_perc'=> round($v/(($nv+$v)*100+1), 2),
'no_vote_perc'=> round($nv/(($nv+$v)*100+1), 2),
'voted'=> $v,
'not_voted'=> $nv));}
public static function get_user_overall_votes($user_ID, $creationDate){
return \SQL\UVOTE_DATA_OVERALL_VOTES::Q1(array($user_ID, $user_ID, $user_ID, $creationDate));}
public static function get_user_overall_votes(){
$vars = \SQL\UVOTE_DATA_OVERALL_VOTES::Q1(array(\SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->creationDate));
$v = $vars['voted'] > 1 ? $vars['voted'] : 1;
$nv = $vars['not_voted'];
return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/overall_all_polls.tpl'),
array( 'vote_perc'=> round($v/($nv+$v)*100, 2),
'no_vote_perc'=> round($nv/($nv+$v)*100, 2),
'voted'=> $v,
'not_voted'=> $nv));}
public static function get_bar_bt_per_poll($poll_ID){
return \SQL\UVOTE_DATA_BT_PER_POLL::Q1(array($poll_ID));}

View File

@ -7,6 +7,10 @@ body {
border: 2px solid #ccc;
}*/
.popover{
max-width: 600px;
width: 600px;
}
.pro{
background: #5eb95e;
}

View File

@ -2,7 +2,6 @@
padding: 5px;
margin: 5px;
width: 100%;
border: solid lightgray 3px;
}
#vote_sub1 {

View File

@ -291,7 +291,6 @@ function load_visualisation_user_to_party_overall(id, party, timespan){
json = json.result;
$('img#loader').hide();
var data = new google.visualization.DataTable();
console.log(json);
first = true;
$.each(json[0], function(key, value){
if(first){
@ -306,8 +305,74 @@ function load_visualisation_user_to_party_overall(id, party, timespan){
data.addRow($.map(value, function(v) { if(first){first=false;return [new Date(v)];}else{return [parseFloat(v)];}}));});
var options = {title: 'Übereinstimmung mit ' + party, aggregationTarget: 'category', selectionMode: 'multiple', curveType: 'function', /*focusTarget: 'category',*/ chartArea:{}, vAxis:{logScale: false}, interpolateNulls: false, width: "800", height: "250"};
var options = { title: 'Übereinstimmung mit ' + party,
aggregationTarget: 'category',
selectionMode: 'multiple',
legend: 'none',
chartArea:{},
// vAxis:{logScale: false},
vAxis: {viewWindow: {min: 0, max: 100}},
lineWidth: 7,
interpolateNulls: false,
width: "800",
height: "250"};
new google.visualization.LineChart(document.getElementById(id)).draw(data, options);
});
}
function load_visualisation_user_to_parties_overall(id, timespan){
$('img#loader').show();
$.getJSON('./api.php?call=donut_party_to_user_overall',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();
console.log(json);
first = true;
$.each(json[0], function(key, value){
if(first){
data.addColumn('string',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 v;}else{return [parseFloat(v)];}}));});
var options = { title: 'Übereinstimmung mit den Fraktionen relativ zueinander',
titleTextStyle: {fontSize: 14, bold: 0, italic: 0},
pieSliceText: 'label',
legend: 'none',
colors: ['#000736', '#0022FF', '#33FF00', '#D2067A', '#F20101'],
pieHole: '0.4',
chartArea:{},
width: "500",
height: "400"};
new google.visualization.PieChart(document.getElementById(id)).draw(data, options);
});
}
function load_visualisation_user(id, timespan){
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['Work', 11],
['Eat', 2],
['Commute', 2],
['Watch TV', 2],
['Sleep', 7]
]);
var options = {
title: 'My Daily Activities',
pieHole: 0.4,
};
var chart = new google.visualization.PieChart(document.getElementById('donutchart'));
chart.draw(data, options);
}
}

View File

@ -1,3 +1,3 @@
<form class="navbar-form navbar-right" id="form_logout">
<button id="btn_logout" type="submit" class="btn btn-primary">Logout</button>
<form class="navbar-form navbar-right" id="form_logout" style="margin: 0; padding: 0;">
<button id="btn_logout" type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-log-out"></span>&nbsp;&nbsp;Logout</button>
</form>

View File

@ -1,34 +1,4 @@
<!--<form class="navbar-form pull-right" id="form_login">
<input class="span2" type="text" id="login_email" placeholder="E-Mail">
<input class="span2" type="password" id="login_password" placeholder="Passwort">
<button type="submit" class="btn">Login</button>
</form> -->
<form class="navbar-form navbar-right" id="form_login">
<!--<div class="control-group">
<div id="help-block"></div>
<input type="hidden" />
<div id="controls">
<input type="text"
size="20"
style=""
id="bt_login_user"
placeholder="${user_name_login}"
minlength="3" data-validation-minlength-message="${register_user_name_too_short}"
maxlength="16" data-validation-maxlength-message="${register_user_name_too_long}"
required data-validation-required-message="${register_user_name_required}"/>
</div>
<div id="controls2" style="float: right;margin-right: 20px;">
<input type="password"
size="20"
style=""
id="bt_login_password"
placeholder="${user_password_login}"
minlength="5" data-validation-minlength-message="${register_password_too_short}"
maxlength="16" data-validation-maxlength-message="${register_user_password_too_long}"
required data-validation-required-message="${register_user_password_required}"/>
</div>
</div>
-->
<div class="form-group">
<div id="help-block"></div>
<input type="text"
@ -48,5 +18,5 @@
maxlength="16" data-validation-maxlength-message="${register_user_password_too_long}"
required data-validation-required-message="${register_user_password_required}"/>
</div>
<button class="btn btn-primary" type="submit" id="login_submit">${login}</button>
<button class="btn btn-primary" type="submit" id="login_submit"><span class="glyphicon glyphicon-log-in"></span>&nbsp;&nbsp;${login}</button>
</form>

View File

@ -1,15 +1,8 @@
<div class="row">
<nav class="navbar navbar-default navbar-inverse">
<div class="container-fluid">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav" id="tabs_user_main">
<li class="active"><a href="#!start(user_main(u))">Abstimmen</a></li>
<li><a href="#!start(user_main(ur))">Auswerten</a></li>
<li><a href="#!start(user_main(my))">Mithelfen</a></li>
<div class="row" style="margin-bottom: 30px;">
<ul class="nav nav-pills" id="tabs_user_main" style=" text-align: center;">
<li class="active"><a href="#!start(user_main(u))"><span class="glyphicon glyphicon-edit"></span>&nbsp;Abstimmen</a></li>
<li><a href="#!start(user_main(ur))"><span class="glyphicon glyphicon-stats"></span>&nbsp;Auswerten</a></li>
<li><a href="#!start(user_main(my))"><span class="glyphicon glyphicon-cog"></span>&nbsp;Mithelfen</a></li>
<li><a data-toggle="modal" class="brand" href="#impressum" id="impressum"><font size="2">Impressum</font></a></li>
</ul>
${loginform}
</div>
</div>
</nav>
</div>

View File

@ -1,8 +1,3 @@
<nav class="navbar navbar-default navbar-inverse">
<div class="container-fluid">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
${loginform}
</div>
</div>
</nav>
<div class="row">
</div>

View File

@ -35,7 +35,23 @@
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div class="container" id="site-content" style="">
<div class="row">${menu}</div>
<div class="row">
<div class="col-md-6">
<img class="img-responsive" src="${frontend_logos}logo2.png"/>
</div>
<div class="col-md-6">
<img class="img-responsive" src="${frontend_logos}cover.png"/>
</div>
</div>
<div class="row"><hr></div>
<div class="row">
<div class="col-md-10">
${menu}
</div>
<div class="col-md-2">
${loginform}
</div>
</div>
<div class="row" id="user_main"></div>
</div>
</div>

View File

@ -6,16 +6,10 @@
</h4>
</div>
<div class="panel-body row">
<div class="col-md-6">
<img class="img-responsive" src="${frontend_logos}logo2.png" width="450"/>
</div>
<div class="col-md-6">
${welcome_text}
</div>
<div class="row">
<div class="col-md-6">
<form class="textbox" id="register_user_form">
<div class="control-group" id="register_username_control_group">
@ -96,12 +90,8 @@
</table>
<button class="btn btn-primary" type="submit"><i class="icon-ok icon-white"></i> ${register}</button>
</div>
</form>
</div>
<div class="col-md-6">
<img class="img-responsive" src="${frontend_logos}cover.png" width="450"/>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -1,5 +1,5 @@
Bundestag gesamt
<div class="row">
<div class="row">
<img class="img-responsive" src="${frontend_logos}icon_bt.png"/>
</div>
@ -8,7 +8,7 @@ Bundestag gesamt
<div class="progress-bar" style="width: ${match_percentage}%">${match_percentage}%</div>
</div>
</div>
</div>
<div class="row">
<div style="col-md-12">
<span class="badge badge-success">${class_MATCH} matches</span>

View File

@ -2,7 +2,7 @@
<div class="col-md-2">
<img src="${frontend_logos}icon_${party}.png"/>
</div>
<div class="col-md-10">
<div class="col-md-9">
<div class="progress">
<div class="progress-bar" style="width: ${match_percentage}%;"><a style="text-decoration: none; color: white;" class="urvoteparties_uvote_popover" data-content="${according_laws}">${match_percentage}%</a></div>
</div>
@ -13,10 +13,14 @@
<a class="urvoteparties_uvote_popover" data-content="${according_laws}">${match_percentage}%</a>
</span>
</td>
</tr>-->
</tr>-->
<div class="col-md-1 urvoteparties_uvote_popover" data-content="${according_laws}">
<span class="glyphicon glyphicon-question-sign"></span>
</div>
</div>
<script>
$(function (){ $(".urvoteparties_uvote_popover").popover({html: true});
});
</script>
});
</script>

View File

@ -1,9 +1,9 @@
<div id="statistics_uvote_users" class="row">
<div class="panel-group row" id="acc_1">
<div class="panel panel-default">
<div class="panel panel-default panel-info">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#acc_1" href="#acc_1_body">${urVote_title}</a>
${urVote_title}
</h4>
</div>
<div class="panel-body" id="acc_1_body">
@ -13,14 +13,14 @@
</div>
</div>
</div>
<div class="panel-group row" id="acc_2" style="padding-top: 10px;">
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-group row" id="acc_2" style="padding-top: 30px;">
<div class="panel panel-default panel-success">
<div class="panel-heading" data-toggle="collapse" data-parent="#acc_2" href="#acc_2_body">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#acc_2" href="#acc_2_body">Deine Daten</a>
<span class="glyphicon glyphicon-user"></span>&nbsp;&nbsp;&nbsp;Deine Daten
</h4>
</div>
<div id="acc_2_body" class="row panel-body panel-collapse">
<div id="acc_2_body" class="row panel-body panel-collapse collapse">
<div class="row">
<div class="col-md-6">
${basic_stats}
@ -36,65 +36,87 @@
</div>
</div>
<div class="panel-group row" id="acc_4" style="padding-top: 10px;">
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel panel-default panel-warning">
<div class="panel-heading" data-toggle="collapse" data-parent="#acc_4" href="#acc_4_body">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#acc_4" href="#acc_4_body">Bilanz: Fraktionen</a>
<span class="glyphicon glyphicon-th-large"></span>&nbsp;&nbsp;&nbsp;Bilanz: Fraktionen
</h4>
</div>
<div id="acc_4_body" class="row panel-body panel-collapse collapse">
<div class="col-md-6">
<br>
<br>
Gesamtübereinstimmung mit den Fraktionen im Bundestag<br>
<font size="1">auf %Angabe clicken für Details</font>
<br>
<br>
${choices_user_ID}
</div>
<div class="col-md-6">
${choices_bt_to_user}
<div id="donut_user_to_party_overall" class="row" style="padding: 0; margin: 0;"></div>
</div>
</div>
</div>
</div>
</div>
<div class="panel-group row" id="acc_5" style="padding-top: 10px;">
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel panel-default panel-warning">
<div class="panel-heading" data-toggle="collapse" data-parent="#acc_5" href="#acc_5_body">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#acc_5" href="#acc_5_body">Bilanz: Fraktionen nach Stimmverhalten</a>
<span class="glyphicon glyphicon-th"></span>&nbsp;&nbsp;&nbsp;Bilanz: Fraktionen nach Stimmverhalten
</h4>
</div>
<div id="acc_5_body" class="row panel-collapse collapse panel-body">
<div class="col-md-3">
<div class="col-md-4">
<img class="img-responsive" src="${frontend_logos}icon_urn_pro.png"/>
<h5>Übereinstimmung der pro Stimmen</h5>
${choices_user_ID_per_party_pro}
</div>
<div class="col-md-3">
<div class="col-md-4">
<img class="img-responsive" src="${frontend_logos}icon_urn_con.png"/>
<h5>Übereinstimmung der contra Stimmen</h5>
${choices_user_ID_per_party_con}
</div>
<div class="col-md-3">
<div class="col-md-4">
<img class="img-responsive" src="${frontend_logos}icon_urn_ent.png"/>
<h5>Übereinstimmung der Enthaltungen</h5>
${choices_user_ID_per_party_ent}
</div>
<div class="col-md-3">
<img class="img-responsive" src="${frontend_logos}icon_bt.png"/>
<h5>Übereinstimmung mit dem Bundestag</h5>
${choices_user_ID_per_bt_pro}
${choices_user_ID_per_bt_con}
${choices_user_ID_per_bt_ent}
</div>
</div>
</div>
</div>
<div class="row panel-group" id="acc_6" style="padding-top: 10px;">
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-group row" id="acc_7" style="padding-top: 10px;">
<div class="panel panel-default panel-warning">
<div class="panel-heading" data-toggle="collapse" data-parent="#acc_7" href="#acc_7_body">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#acc_6" href="#acc_6_body">Entwicklung: Fraktionen</a>
<span class="glyphicon glyphicon-list-alt"></span>&nbsp;&nbsp;&nbsp;Bilanz: Bundestag
</h4>
</div>
<div id="acc_7_body" class="row panel-body panel-collapse collapse">
<div class="col-md-6">
Bundestag gesamt
${choices_bt_to_user}
</div>
<div class="col-md-6">
Übereinstimmung mit dem Bundestag
<img class="img-responsive" src="${frontend_logos}icon_bt.png"/>
${choices_user_ID_per_bt_pro}
${choices_user_ID_per_bt_con}
${choices_user_ID_per_bt_ent}
</div>
</div>
</div>
</div>
<div class="row panel-group" id="acc_6" style="padding-top: 10px;">
<div class="panel panel-default panel-danger">
<div class="panel-heading" data-toggle="collapse" data-parent="#acc_6" href="#acc_6_body">
<h4 class="panel-title">
<span class="glyphicon glyphicon-random"></span>&nbsp;&nbsp;&nbsp;Entwicklung: Fraktionen
</h4>
</div>
<div id="acc_6_body" class="panel-body panel-collapse collapse">
@ -126,21 +148,21 @@
</div>
</div>
<div class="row panel-group" id="acc_3" style="padding-top: 10px;">
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel panel-default panel-primary">
<div class="panel-heading" data-toggle="collapse" data-parent="#acc_3" href="#acc_3_body">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#acc_3" href="#acc_3_body">community Statistik</a>
<span class="glyphicon glyphicon-globe"></span>&nbsp;&nbsp;&nbsp;community Statistik
</h4>
</div>
<div id="acc_3_body" class="panel-body panel-collapse collapse">
<div class="col-md-6">
<h5>Entscheidungsverhalten der uVote Community</h5>
<span style="">
${votes_all}
</span>
<span style=""> Wie oft die uVote Community
<br> insgesamt Dafür, Dagegen oder
<br> Enthaltung gestimmt hat.</span>
<span style="">
${votes_all}
</span>
<span style=""> Wie oft die uVote Community
<br> insgesamt Dafür, Dagegen oder
<br> Enthaltung gestimmt hat.</span>
</div>
<div class="col-md-6">
<h5>Entscheidungsverhalten des Bundestags</h5>
@ -164,7 +186,7 @@
<script type="text/javascript" language="JavaScript">load_visualisation_user_to_party_overall('graph_user_to_party_overall_spd', 'spd', 84600);</script>
<script type="text/javascript" language="JavaScript">load_visualisation_user_to_party_overall('graph_user_to_party_overall_gruene', 'gruene', 84600);</script>
<script type="text/javascript" language="JavaScript">load_visualisation_user_to_party_overall('graph_user_to_party_overall_linke', 'linke', 84600);</script>
<script type="text/javascript" language="JavaScript">load_visualisation_user_to_parties_overall('donut_user_to_party_overall', 84600);</script>

View File

@ -1,88 +1,6 @@
<?php
class user_main_analysis extends SYSTEM\PAGE\Page {
private function user_overall_votes (){
$vars = votes::get_user_overall_votes(\SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->creationDate);
$v = $vars['voted'] > 1 ? $vars['voted'] : 1;
$nv = $vars['not_voted'];
return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/overall_all_polls.tpl'),
array( 'vote_perc'=> round($v/($nv+$v)*100, 2),
'no_vote_perc'=> round($nv/($nv+$v)*100, 2),
'voted'=> $v,
'not_voted'=> $nv));
}
public static function user_temp_votes (){
$vars = votes::get_user_temp_votes(\SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->id);
$v = $vars['voted'];
$nv = $vars['not_voted'];
print_r($vars, true);
return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/all_polls.tpl'),
array( 'vote_perc'=> round($v/(($nv+$v)*100+1), 2),
'no_vote_perc'=> round($nv/(($nv+$v)*100+1), 2),
'voted'=> $v,
'not_voted'=> $nv));
}
private function user_to_bt(){
//$vars = votes::get_user_per_party_overall($user_ID);
$result = '';
$con = new \SYSTEM\DB\Connection();
$res = $con->prepare( 'bt_to_user',
'SELECT sum(case when uvote_data.choice = uvote_votes.bt_choice then 1 else 0 end) class_MATCH,
sum(case when uvote_data.choice != uvote_votes.bt_choice then 1 else 0 end) class_MISSMATCH
FROM uvote_data LEFT JOIN uvote_votes
ON uvote_data.poll_ID = uvote_votes.ID
WHERE user_ID = ?;',
array(\SYSTEM\SECURITY\Security::getUser()->id));
while($row = $res->next()){
$row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH']+1)*100,2);
$result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/bt_to_user_overall.tpl'), $row);
}
return $result;
$row['votes_cast'] = round(($row['class_MATCH']+$row['class_MISSMATCH']),2);
}
private function user_per_party_overall(){
//$vars = votes::get_user_per_party_overall(array(\SYSTEM\SECURITY\Security::getUser()->id));
$result = '';
$con = new \SYSTEM\DB\Connection();
$res = $con->prepare( 'test',
'SELECT party, sum(case when uvote_data.choice = uvote_votes_per_party.choice then 1 else 0 end) class_MATCH,
sum(case when uvote_data.choice != uvote_votes_per_party.choice then 1 else 0 end) class_MISSMATCH
FROM uvote_data INNER JOIN uvote_votes_per_party
ON uvote_data.poll_ID = uvote_votes_per_party.poll_ID
WHERE user_ID = ? GROUP BY party;',
array(\SYSTEM\SECURITY\Security::getUser()->id));
$i = 0;
while($row = $res->next()){
$res2 = votes::vote_accord_with_party($row['party']);
$row['according_laws'] = $this->build_according_law_html($res2, $row['party']);
$row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH'])*100,2);
$result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/urvoteparties.tpl'), $row);;
}
return $result;
}
private function user_per_party_by_choicetype($choice){
return votes::get_user_match_per_choice($choice);
}
private function user_per_bt_by_choicetype($choice){
return votes::get_user_match_per_choice_bt($choice);
}
public function build_according_law_html($part, $party){
$part = json_decode($part, true);
$result = "<div><font color='black'><h6><i>Bei folgenden Gesetzen hast du genauso abgestimmt wie die ".$party."':</i></h6><hr>";
foreach ($part['result'] as $p){
$result .= $p['title']."<hr>";
}
$result .= "</font></div>";
new INFO($result);
return $result;
}
private function votes_all(){
$votes = votes::get_all_votes();
$result = '';
@ -131,33 +49,35 @@ private function user_per_bt_by_choicetype($choice){
}
return $result;
}
public static function get_basic_stats(){
$vars = votes::get_user_choice_overall(\SYSTEM\SECURITY\Security::getUser()->id);
$vars['user_total_total'] = $vars['user_total_pro'] + $vars['user_total_con'] + $vars['user_total_ent'];
$vars['user_total_pro_percentage'] = round($vars['user_total_pro']/$vars['user_total_total']*100+1);
$vars['user_total_con_percentage'] = round($vars['user_total_con']/$vars['user_total_total']*100+1);
$vars['user_total_ent_percentage'] = round($vars['user_total_ent']/$vars['user_total_total']*100+1);
return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/user_total.tpl'),$vars);
}
public static function js(){
return array(\SYSTEM\WEBPATH(new \PPAGE(),'user_main_analysis/js/user_main_analysis.js'));}
public function html(){
$vars = array();
// $vars['poll_compare'] = $this->count_all_polls();
$vars['basic_stats'] = $this->get_basic_stats();
//second panel
$vars['basic_stats'] = bars::get_user_choice_overall(\SYSTEM\SECURITY\Security::getUser()->id);
$vars['user_temp_votes'] = votes::get_user_temp_votes();
$vars['user_overall_votes'] = votes::get_user_overall_votes();
//third panel
$vars['choices_user_ID'] = bars::user_per_party_overall();
//fourth panel
$vars['choices_user_ID_per_party_pro'] = bars::user_per_party_by_choicetype('1');
$vars['choices_user_ID_per_party_con'] = bars::user_per_party_by_choicetype('2');
$vars['choices_user_ID_per_party_ent'] = bars::user_per_party_by_choicetype('3');
//fifth panel
$vars['choices_bt_to_user'] = bars::user_to_bt();
$vars['choices_user_ID_per_bt_pro'] = bars::user_per_bt_by_choicetype('1');
$vars['choices_user_ID_per_bt_con'] = bars::user_per_bt_by_choicetype('2');
$vars['choices_user_ID_per_bt_ent'] = bars::user_per_bt_by_choicetype('3');
$vars['votes_all'] = $this->votes_all();
$vars['votes_all_bt'] = $this->votes_all_bt();
$vars['choices_user_ID'] = $this->user_per_party_overall();
$vars['choices_user_ID_per_party_pro'] = $this->user_per_party_by_choicetype('1');
$vars['choices_user_ID_per_party_con'] = $this->user_per_party_by_choicetype('2');
$vars['choices_user_ID_per_party_ent'] = $this->user_per_party_by_choicetype('3');
$vars['choices_user_ID_per_bt_pro'] = $this->user_per_bt_by_choicetype('1');
$vars['choices_user_ID_per_bt_con'] = $this->user_per_bt_by_choicetype('2');
$vars['choices_user_ID_per_bt_ent'] = $this->user_per_bt_by_choicetype('3');
$vars['choices_bt_to_user'] = $this->user_to_bt();
$vars['frontend_logos'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).'api.php?call=files&cat=frontend_logos&id=';
$vars['user_temp_votes'] = $this->user_temp_votes();
$vars['user_overall_votes'] = $this->user_overall_votes();
$vars['frontend_logos'] = './api.php?call=files&cat=frontend_logos&id=';
$vars = array_merge($vars, \SYSTEM\PAGE\text::tag('uvote'));
$vars = array_merge($vars, \SYSTEM\PAGE\text::tag('uvote_register'));
return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/user_main_analysis.tpl'),$vars);

View File

@ -1,7 +1,6 @@
<div class="row" style="padding-bottom: 30px;">
<div class="row panel-group" style="margin: 0; padding:0;">
<div class="panel panel-default">
<div class="panel panel-default panel-info">
<div class="panel-heading">
<h4 class="panel-title">
Willkommen auf uvote.eu!
@ -12,23 +11,29 @@
${welcome_text}
</div>
<div class="col-md-4">
${user_temp_votes}
<span class="badge badge-info">${user_count}</span> Nutzer auf uVote
<div class="row">
${user_temp_votes}
</div>
<div class="row">
<div class="col-md-2">
<br>
<span class="badge badge-info">${user_count}</span>
</div>
<div class="col-md-10">
<br>
Nutzer auf uVote
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row panel-group">
<div class="panel panel-default">
<div class="panel panel-default panel-info">
<div class="panel-heading">
<h4 class="panel-title">
Hier gehts zur Abstimmung
<span class="glyphicon glyphicon-th-list"></span>&nbsp;Hier gehts zur Abstimmung
</h4>
</div>
<div class="panel-body">

View File

@ -12,5 +12,6 @@
</div>
</div>
<hr>

View File

@ -1,119 +1,17 @@
<?php
class user_main_votelist extends SYSTEM\PAGE\Page {
private function get_party_per_poll($choice){
switch($choice){
case 1:
return 'PRO';
case 2:
return 'CON';
case 3:
return 'ENT';
default:
return 'NONE';
}
}
private static function tablerow_class($choice){
switch($choice){
case 1:
return 'pro';
case 2:
return 'con';
case 3:
return 'ent';
default:
return 'open';
}
}
private static function badge_class($choice){
switch($choice){
case 1:
return 'badge-success';
case 2:
return 'badge-danger';
case 3:
return 'badge-info';
default:
return '';
}
}
private function user_count(){
$vars = votes::get_user_count();
return $vars['count'];
}
public function generate_votelist(){
$result = array('','');
$votes = votes::getAllVotesOfGroup(1);
foreach($votes as $vote){
$time_remain = strtotime($vote['time_end'])- microtime(true);
$time_span = strtotime($vote['time_end']) - strtotime($vote['time_start']);
$vote_count = votes::get_count_user_votes_per_poll($vote['ID']);
// $vote['title'] = utf8_encode($vote['title']);
$vote['time_left'] = round($time_remain/($time_span+1)*100,0);
$vote['time_done'] = 100-$vote['time_left'];
$vote['full_vote_btn'] = $time_remain > 0 ? 'Abstimmen' : 'Ansehen';
$vote['uv'] = $vote['bt'] = '';
$vote['uv_count'] = $vote_count['count'] > 4 ? $vote_count['count'] : '< 5';
$user_vote = votes::getUserPollData($vote['ID']);
$vote['vote_class'] = $this->tablerow_class($user_vote);
if($user_vote){
//user vote
$vote['vote_class'] = $this->tablerow_class($user_vote);
//bt vote
$party_votes = votes::get_barsperparty($vote['ID']);
$vote['bt_vote_class'] = $this->tablerow_class($vote['bt_choice']);
foreach($party_votes as $pv){
$vote['bt'] .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/vote_bt.tpl'),
array( 'party' => $pv['party'],
'choice' => $this->get_party_per_poll($pv['choice']),
'choice_class' => $this->badge_class($pv['choice'])));
}
//uvote vote
$uvote = votes::get_users_choice_per_poll($vote['ID']);
$vote['uv_vote_class'] = count($uvote) > 0 ? $this->tablerow_class($uvote[0]['choice']) : '';
foreach($uvote as $v){
$vote['uv'] .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/tpl/vote_uv.tpl'),
array( 'badge' => self::badge_class($v['choice']),
'perc' => $v['count'] > 0 ? round($v['count']/$vote_count['count']*100, 2) : 0));
}
}
//new panels:
$vote['panel_class'] = self::panel_class($user_vote);
if($time_remain > 0){
$result[0] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/vote.tpl'), $vote);
} else {
$result[1] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/vote.tpl'), $vote);
}
}
return $result[0].$result[1];
}
public static function panel_class($choice){
switch($choice){
case 1:
return 'panel-success';
case 2:
return 'panel-danger';
case 3:
return 'panel-info';
default:
return 'panel-default';
}
}
public function html(){
$vars = array();
$vars['votelist'] = $this->generate_votelist();
$vars['votelist'] = lists::generate_votelist();
$vars['frontend_logos'] = './api.php?call=files&cat=frontend_logos&id=';
$vars['user_count'] = $this->user_count();
$vars['user_temp_votes'] = user_main_analysis::user_temp_votes();
$vars['user_temp_votes'] = votes::get_user_temp_votes();
$vars = array_merge($vars, \SYSTEM\PAGE\text::tag('uvote_register'));
$vars = array_merge($vars, \SYSTEM\PAGE\text::tag('uvote'));
return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/user_main_votelist.tpl'), $vars);

View File

@ -0,0 +1,8 @@
<?php
namespace SQL;
class UVOTE_DATA_GRAPH_PARTY_TO_USER_OVERALL_BY_TIME_OVERMATCH extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function mysql(){return
'SELECT COUNT(*) as total FROM uvote_votes_per_party LEFT JOIN uvote_data ON uvote_votes_per_party.poll_ID = uvote_data.poll_ID WHERE party = ? AND user_id = ?;'
;}}

View File

@ -0,0 +1,13 @@
<?php
namespace SQL;
class UVOTE_DATA_USER_TO_PARTIES_OVERALL extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function mysql(){return
'SELECT uvote_votes_per_party.party as party,
sum(case when uvote_data.choice = uvote_votes_per_party.choice then 1 else 0 end) class_MATCH,
sum(case when uvote_data.choice != uvote_votes_per_party.choice then 1 else 0 end) class_MISSMATCH
FROM uvote_data LEFT JOIN uvote_votes_per_party
ON uvote_data.poll_ID = uvote_votes_per_party.poll_ID
WHERE user_ID = ? AND uvote_votes_per_party.choice GROUP by party;'
;}}