new headbanner

filter system
new api for poll
various small bugfixes
This commit is contained in:
Naeltard 2015-10-23 16:36:36 +02:00
parent 21766764cc
commit e8ff9b4c49
26 changed files with 341 additions and 66 deletions

View File

@ -41,7 +41,9 @@ class api_uvote extends \SYSTEM\API\api_system {
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();}
return graphs::donut_party_to_user_overall();}
public static function call_donut_party_to_community_overall(){
return graphs::donut_party_to_community_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);}
@ -60,7 +62,12 @@ class api_uvote extends \SYSTEM\API\api_system {
return stats_bilance_choice::basic_bilance_choice($cat);
}
}
public static function call_load_list($filter, $time){
return lists::generate_votelist($filter);
}
public static function call_load_list_text_search($text){
return lists::text_search($text);
}
}

View File

@ -55,5 +55,14 @@ class graphs {
}
return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result;
}
public static function donut_party_to_community_overall ($returnasjson = true){
$result = array();
$res = \SQL\UVOTE_DATA_COMMUNITY_TO_PARTIES_OVERALL::QQ(array());
while ($row = $res->next()){
$result[] = array( 0 => $row['party'],
'class_match' => $row['class_MATCH']);
}
return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result;
}
}

View File

@ -1,12 +1,20 @@
<?php
class lists{
public static function generate_votelist(){
public static function generate_votelist($filter){
$result = array('','');
$votes = votes::getAllVotesOfGroup(1);
if(!$filter){
$votes = votes::getAllVotesOfGroup(1);
}
else{
$votes = \SQL\UVOTE_GENERATE_VOTELIST_FILTERED::QA(array(1, $filter));
}
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_count = votes::get_count_user_votes_per_poll($vote['ID']);
$vote['votecount'] = $vote_count['count'];
$vote['tags'] = self::get_all_tags_of_vote($vote['ID']);
$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';
@ -14,6 +22,43 @@ class lists{
$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);
$vote['frontend_logos'] = './api.php?call=files&cat=frontend_logos&id=';
if($time_remain > 0){
$vote['statusmarker'] = 'aktuell';
$result[0] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/vote.tpl'), $vote);
} else {
$vote['statusmarker'] = 'vergangen';
$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 get_all_tags_of_vote($poll_ID){
$result = '';
$vars = \SQL\UVOTE_DATA_USER_TAGS_OF_VOTE::QA(array($poll_ID));
foreach ($vars as $tag){
$result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/tag.tpl'),$tag);
}
return $result;
}
public static function text_search($text){
$result = array('','');
$votes = \SQL\UVOTE_DATA_TEXT_SEARCH::QA(array($text));
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['votecount'] = $vote_count['count'];
$vote['tags'] = self::get_all_tags_of_vote($vote['ID']);
$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);
$vote['frontend_logos'] = './api.php?call=files&cat=frontend_logos&id=';
if($time_remain > 0){
$vote['statusmarker'] = 'aktuell';
$result[0] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/vote.tpl'), $vote);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Binary file not shown.

View File

@ -22,7 +22,6 @@ body {
#site-content {
padding: 0;
margin: 0;
margin-left: 35px;
}
#user_main {

View File

@ -1,8 +1,4 @@
#vote_main {
padding: 5px;
margin: 5px;
width: 100%;
}
#vote_sub1 {
float: left;

View File

@ -4,7 +4,7 @@
<li><a href="#!list"><span class="glyphicon glyphicon-edit"></span>&nbsp;Abstimmen</a></li>
<li><a href="#!analysis"><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 href="#!start(user_main(imp))"><span class="glyphicon glyphicon-tags"></span>&nbsp;Impressum</a></li>
<li style="float: right"><a href="#!start(user_main(imp))"><span class="glyphicon glyphicon-tags"></span>&nbsp;Impressum</a></li>
<li style="float: right">${loginform}</li>
</ul>
</div>

View File

@ -11,21 +11,14 @@
${js}
</head>
<body style="background: url(${frontend_logos}tapete.gif); background-attachment: fixed;">
<div class="main_container">
<div class="container" id="site-content">
<div class="row">
<div class="row">
<div class="col-md-12" style="border: #0088cc 2px ; padding: 0;">
<div class="row" style="margin-top: 15px;">
<div class="col-md-12">
<img class="img-responsive" src="${frontend_logos}logo.png" style="width: 100%"/>
</div>
</div>
</div>
<div class="row"><hr></div>
<div class="row">
${menu}
</div>
<font family="Raleway"><div class="row" id="user_main"></div></font>
<div class="row" style="margin-bottom: 15px;">${menu}</div>
<div class="row" id="user_main"></div>
</div>
</div>
</body>
</html>

View File

@ -71,7 +71,7 @@
</div>
</td>
</tr>
<tr>
<tr style="display: none;">
<th>${locale}</th>
<td>
<div id="change_user_locale">

View File

@ -78,6 +78,12 @@ $('#a_acc_12').click(function () {
$('#a_acc_7').click(function () {
$('#acc_7_body').load(load_visualisation_urvote('graph_user_to_party_overall_bt', 84600));
});
$('#a_acc_13').click(function () {
$('#acc_13_body').load(load_visualisation_user_to_parties_overall('donut_user_to_party_overall', 84600),
load_visualisation_bt_to_parties_overall('donut_bt_to_party_overall', 84600),
load_visualisation_community_to_parties_overall('donut_community_to_party_overall', 84600));
});
$('#a_acc_5').click(function () {
$('#acc_5_body').load(load_visualisation_user_to_party_overall('graph_user_to_party_overall_cdu', 'cdu', 84600),
load_visualisation_user_to_party_overall('graph_user_to_party_overall_csu', 'csu', 84600),
@ -89,8 +95,7 @@ $('#a_acc_5').click(function () {
function load_tab(set, cat, body){
$(body).load('./api.php?call=load_tab&set=' + set + '&cat=' + cat, function(){
if(set == 'bilance' && cat == 'user'){
load_visualisation_user_to_parties_overall('donut_user_to_party_overall', 84600);}
});
}
@ -230,7 +235,70 @@ function load_visualisation_user_to_parties_overall(id, timespan){
colors: ['#000736', '#0022FF', '#33FF00', '#D2067A', '#F20101'],
pieHole: '0.4',
chartArea:{},
width: "500",
width: "350",
height: "400"};
new google.visualization.PieChart(document.getElementById(id)).draw(data, options);
});
}
function load_visualisation_community_to_parties_overall(id, timespan){
$('img#loader').show();
$.getJSON('./api.php?call=donut_party_to_community_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();
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: "350",
height: "400"};
new google.visualization.PieChart(document.getElementById(id)).draw(data, options);
});
}
function load_visualisation_bt_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 = google.visualization.arrayToDataTable([
['party', 'seats'],
['cdu', 255],
['csu', 56],
['grüne', 63],
['linke', 64],
['spd', 193]
]);
var options = { title: 'Sitzverteilung im Plenum',
titleTextStyle: {fontSize: 14, bold: 0, italic: 0},
pieSliceText: 'label',
legend: 'none',
colors: ['#000736', '#0022FF', '#33FF00', '#D2067A', '#F20101'],
pieHole: '0.4',
chartArea:{},
width: "350",
height: "400"};
new google.visualization.PieChart(document.getElementById(id)).draw(data, options);
});

View File

@ -14,17 +14,3 @@
${analysis_math_user_to_party_overall}
</div>
</div>
<hr>
<div class="row" style="padding-top: 20px;">
<div class="col-md-8">
<h4>Relative Übereinstimmung</h4>
<hr>
<div id="donut_user_to_party_overall" class="row" style="padding: 0; margin: 0;"></div>
</div>
<div class="col-md-4" style="font-size: 10pt; border-left: #d9edf7 solid 2px">
<h4><span class="glyphicon glyphicon-info-sign"></span></h4>
${analysis_help_party_donut}
<h4><span class="glyphicon glyphicon-certificate"></span></h4>
${analysis_math_party_donut}
</div>
</div>

View File

@ -37,6 +37,47 @@
<div id="acc_2_body" class="row panel-body panel-collapse collapse"></div>
</div>
</div>
<div class="panel-group row" id="acc_13" style="padding-top: 10px;">
<div class="panel panel-default panel-info">
<div class="panel-heading" style="padding: 0">
<a id="a_acc_13" class="acc_toggle" data-toggle="collapse" data-parent="#acc_13" href="#acc_13_body">
<div style="width: 100%; height: 100%; padding: 10px;">
<h4 class="panel-title">
<span class="glyphicon glyphicon-globe"></span>&nbsp;&nbsp;&nbsp;Gesamtsituation
<i style="float: right" class="glyphicon glyphicon-circle-arrow-down"></i>
</h4>
</div>
</a>
</div>
<div id="acc_13_body" class="row panel-body panel-collapse collapse">
<div class="row" style="padding-top: 20px;">
<div class="col-md-4">
<h4>"Dein" Bundestag</h4>
<hr>
<div id="donut_user_to_party_overall" class="row" style="padding: 0; margin: 0;"></div>
</div>
<div class="col-md-4">
<h4>Der Bundestag</h4>
<hr>
<div id="donut_bt_to_party_overall" class="row" style="padding: 0; margin: 0;"></div>
</div>
<div class="col-md-4">
<h4>die uvote community</h4>
<hr>
<div id="donut_community_to_party_overall" class="row" style="padding: 0; margin: 0;"></div>
</div>
</div>
<div class="row">
<div class="col-md-12" style="font-size: 10pt; border-left: #d9edf7 solid 2px">
<h4><span class="glyphicon glyphicon-info-sign"></span></h4>
${analysis_help_party_donut}
<h4><span class="glyphicon glyphicon-certificate"></span></h4>
${analysis_math_party_donut}
</div>
</div>
</div>
</div>
</div>
<div class="panel-group row" id="acc_3" style="padding-top: 10px;">
<div class="panel panel-default panel-warning">
<div class="panel-heading" style="padding: 0">
@ -52,6 +93,8 @@
<div id="acc_3_body" class="row panel-body panel-collapse collapse"></div>
</div>
</div>
<div class="panel-group row" id="acc_4" style="padding-top: 10px;">
<div class="panel panel-default panel-warning">
<div class="panel-heading" style="padding: 0">
@ -187,7 +230,7 @@
<a id="a_acc_8" class="acc_toggle" data-toggle="collapse" data-parent="#acc_8" href="#acc_8_body">
<div style="width: 100%; height: 100%; padding: 10px;">
<h4 class="panel-title" style="">
<span class="glyphicon glyphicon-globe"></span>&nbsp;&nbsp;&nbsp;community Daten
<span class="glyphicon glyphicon-cloud"></span>&nbsp;&nbsp;&nbsp;community Daten
<i style="float: right" class="glyphicon glyphicon-circle-arrow-down"></i>
</h4>
</div>

View File

@ -1,2 +1,24 @@
function init_user_main_votelist(){
$('.acc_toggle').click(function(){
$(this).find('i').toggleClass('glyphicon-circle-arrow-down').toggleClass('glyphicon-circle-arrow-up');
});
$('.filter_btn').click(function () {
var filter = $(this).attr("value");
load_list(filter);
});
$('#btn_text_search').click(function () {
var text = $('#list_text_search').val();
load_list_text_search(text);
});
}
function load_list(filter){
$('#list_frame').load('./api.php?call=load_list&filter=' + filter + '&time=1', function(){
});
}
function load_list_text_search(text){
$('#list_frame').load('./api.php?call=load_list_text_search&text=%' + text + '%', function(){
});
}

View File

@ -0,0 +1 @@
<a><button value="${tag}" style="margin: 10px;" class="btn filter_btn btn-warning btn-sm">${tag}</button></a>

View File

@ -0,0 +1 @@
<label class="label label-warning" style="padding: 2px;"><font size="1">${tag}</font></label>&nbsp;&nbsp;

View File

@ -1,14 +1,52 @@
<div class="row panel-group row">
<div class="row panel-group row" style="">
<div class="panel panel-default panel-info">
<div class="panel-heading">
<h4 class="panel-title">
<span class="glyphicon glyphicon-th-list"></span>&nbsp;Hier gehts zur Abstimmung
<span class="glyphicon glyphicon-pencil"></span>&nbsp;Abstimmen
</h4>
</div>
<div class="panel-body">
${votelist}
${votelist_disclaimer}
</div>
</div>
</div>
</div>
<div class="panel-group row" id="filter_panel" style="margin-top: 15px;">
<div class="panel panel-default panel-warning">
<div class="panel-heading" style="padding: 0" >
<a id="a_filter_panel" class="acc_toggle" data-toggle="collapse" data-parent="#filter_panel" href="#filter_panel_body">
<div style="width: 100%; height: 100%; padding: 10px;">
<h4 class="panel-title">
<span class="glyphicon glyphicon-filter"></span>&nbsp;&nbsp;&nbsp;Filter
<i style="float: right" class="glyphicon glyphicon-circle-arrow-down"></i>
</h4>
</div>
</a>
</div>
<div id="filter_panel_body" class="row panel-body panel-collapse collapse">${filterlist}</div>
</div>
</div>
<div class="panel-group row" id="list_panel" style="margin-top: 15px;">
<div class="panel panel-default panel-info">
<div class="panel-heading" style="padding: 0" >
<div style="width: 100%; height: 100%; padding: 10px;">
<h4 class="panel-title">
<span class="glyphicon glyphicon-search"></span>&nbsp;
<input type="text" id="list_text_search" placeholder="Suche..."/>
<button id="btn_text_search" type="button" class="btn btn-sm btn-primary">anfragen</button>
</h4>
</div>
</div>
<div id="list_panel_body" class="row panel-body panel-collapse">
<div id="list_frame" class="row">
${votelist}
</div>
</div>
</div>
</div>

View File

@ -1,21 +1,34 @@
<div id="vote_main" class="row">
<div class="col-md-2">
<label class="label label-primary" style="padding: 5px">
<span class="glyphicon glyphicon-info-sign"></span>
${statusmarker}
</label>
</div>
<div class="col-md-7">
${title}
</div>
<div class="col-md-1">
<img src="${frontend_logos}icon_urn_${vote_class}.png">
</div>
<div class="col-md-2">
<a href="#!start(poll);poll.${ID}" class="btn btn-primary btn-small" poll_ID="${ID}"><span class="glyphicon glyphicon-eye-open"></span>&nbsp;&nbsp;Abstimmen</a>
<div id="vote_main" class="row" style="margin: 0; margin-top: 25px; background: white; padding: 10px; ">
<div class="row" style="margin: 0;">
<div class="col-md-1">
<img src="${frontend_logos}icon_urn_${vote_class}.png">
</div>
<div class="col-md-8">
${title}
</div>
<div class="col-md-1">
<label class="label label-primary" style="padding: 5px">
<span class="glyphicon glyphicon-info-sign"></span>
${statusmarker}
</label>
<br>
<font size="1">${votecount}&nbsp;Stimme/n</font>
</div>
<div class="col-md-2">
<a href="#!start(poll);poll.${ID}" class="btn btn-primary btn-small" poll_ID="${ID}"><span class="glyphicon glyphicon-eye-open"></span>&nbsp;&nbsp;Abstimmen</a>
</div>
</div>
<br>
<div class="row" style="border-top: 1px solid #ccc">
<div class="col-md-8" style="padding: 5px;">
${tags}
</div>
</div>
</div>
<hr>

View File

@ -4,14 +4,23 @@ class user_main_votelist extends SYSTEM\PAGE\Page {
$vars = votes::get_user_count();
return $vars['count'];
}
public static function get_list_tags(){
$result = '';
$vars = \SQL\UVOTE_DATA_USER_TAGS::QA(array());
foreach($vars as $tag){
$result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/filter.tpl'), $tag);
}
return $result;
}
public static function js(){
return array(\SYSTEM\WEBPATH(new \PPAGE(),'user_main_votelist/js/user_main_votelist.js'));}
public function html(){
$vars = array();
$vars['votelist'] = lists::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'] = votes::get_user_temp_votes();
$vars['filterlist'] = $this->get_list_tags();
$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,13 @@
<?php
namespace SQL;
class UVOTE_DATA_COMMUNITY_TO_PARTIES_OVERALL extends \SYSTEM\DB\QQ {
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 uvote_votes_per_party.choice GROUP by party;'
;}}

View File

@ -0,0 +1,8 @@
<?php
namespace SQL;
class UVOTE_DATA_TEXT_SEARCH extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function mysql(){return
'SELECT * FROM uvote_votes WHERE `title` LIKE ?;'
;}}

View File

@ -0,0 +1,8 @@
<?php
namespace SQL;
class UVOTE_DATA_USER_TAGS extends \SYSTEM\DB\QQ {
public static function get_class(){return \get_class();}
public static function mysql(){return
'SELECT DISTINCT(tag) as tag FROM uvote_votes_tag;'
;}}

View File

@ -0,0 +1,8 @@
<?php
namespace SQL;
class UVOTE_DATA_USER_TAGS_OF_VOTE extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function mysql(){return
'SELECT tag FROM uvote_votes_tag LEFT JOIN uvote_votes ON uvote_votes_tag.poll_ID = uvote_votes.ID WHERE uvote_votes.ID = ? AND uvote_votes.group = 1;'
;}}

View File

@ -0,0 +1,8 @@
<?php
namespace SQL;
class UVOTE_GENERATE_VOTELIST_FILTERED extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function mysql(){return
'SELECT * FROM `uvote_votes` LEFT JOIN uvote_votes_tag ON uvote_votes.ID = uvote_votes_tag.poll_ID WHERE uvote_votes.group = ? AND uvote_votes_tag.tag = ? ORDER BY (time_end-time_start) ASC;'
;}}