diff --git a/uvote/api/api_uvote.php b/uvote/api/api_uvote.php
index 2bf568c..c2768ad 100644
--- a/uvote/api/api_uvote.php
+++ b/uvote/api/api_uvote.php
@@ -28,6 +28,16 @@ class api_uvote extends \SYSTEM\API\api_system {
public static function call_graph_bt_to_user_overall_by_time($timespan = 84600){
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){
+ 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){
+ 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){
+ 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){
+ 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){
+ return graphs::graph_party_to_user_overall_by_time($party, $timespan);}
//comments
public static function call_vote_action_comment($poll_ID, $c_choice, $c_txt, $c_src) {
diff --git a/uvote/api/votes/graphs.php b/uvote/api/votes/graphs.php
index a64bb21..c819397 100644
--- a/uvote/api/votes/graphs.php
+++ b/uvote/api/votes/graphs.php
@@ -24,4 +24,14 @@ class graphs {
return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result;
}
+ 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));
+ while ($row = $res->next()){
+ $result[] = array( 0 => $row['day'],
+ 'class_match' => $row['class_match'] / ($row['class_match']+$row['class_mismatch']+1));
+ }
+ return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result;
+ }
+
}
diff --git a/uvote/api/votes/votes.php b/uvote/api/votes/votes.php
index 0e29d89..783b5ef 100644
--- a/uvote/api/votes/votes.php
+++ b/uvote/api/votes/votes.php
@@ -11,6 +11,10 @@ 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));
}
@@ -25,7 +29,84 @@ 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
';
+ }
+ $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
diff --git a/uvote/page/default_page/default_page.php b/uvote/page/default_page/default_page.php
index 112fd12..4ee7ac6 100644
--- a/uvote/page/default_page/default_page.php
+++ b/uvote/page/default_page/default_page.php
@@ -39,12 +39,18 @@ class default_page extends SYSTEM\PAGE\Page {
public function exchange_loginform(){
return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/tpl/loggedinformtop.tpl'),array());}
+
+ public function get_menu(){
+ return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/tpl/menu.tpl'),array());}
+ public function exchange_menu(){
+ return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/tpl/menu_loggedout.tpl'),array());}
public function html($_escaped_fragment_ = NULL){
$vars = array();
if(!$_escaped_fragment_){
$vars['js'] = $this->js();}
$vars['css'] = $this->css();
+ $vars['menu'] = \SYSTEM\SECURITY\Security::isLoggedIn() ? $this->get_menu() : $this->exchange_menu();
$vars['registerform'] = \SYSTEM\SECURITY\Security::isLoggedIn() ? $this->getloggedinform() : $this->exchange_registerform();
$vars['loginform'] = \SYSTEM\SECURITY\Security::isLoggedIn() ? $this->exchange_loginform() : $this->getloginform() ;
$vars['frontend_logos'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).'api.php?call=files&cat=frontend_logos&id=';
diff --git a/uvote/page/default_page/js/loadtexts.js b/uvote/page/default_page/js/loadtexts.js
index 883dee7..19f566b 100644
--- a/uvote/page/default_page/js/loadtexts.js
+++ b/uvote/page/default_page/js/loadtexts.js
@@ -2,7 +2,15 @@ $(document).ready(function() {
new SYSTEM('./api.php',1,'start');
register_login();
register_logout();
+ navstate();
});
+function navstate(){
+ $(".nav a").on("click", function(){
+ $(".nav").find(".active").removeClass("active");
+ $(this).parent().addClass("active");
+});
+}
+
function register_login(){
$("#form_login input").not("[type=submit]").jqBootstrapValidation({
@@ -268,8 +276,38 @@ function load_visualisation_urvote(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);
});
-}
\ No newline at end of file
+}
+
+function load_visualisation_user_to_party_overall(id, party, timespan){
+ $('img#loader').show();
+ $.getJSON('./api.php?call=graph_party_to_user_overall_by_time&party=' + party,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('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)];}}));});
+
+
+ var options = {title: 'Übereinstimmung mit ' + party, aggregationTarget: 'category', selectionMode: 'multiple', curveType: 'function', /*focusTarget: 'category',*/ chartArea:{}, vAxis:{logScale: false}, interpolateNulls: false, width: "800", height: "250"};
+ new google.visualization.LineChart(document.getElementById(id)).draw(data, options);
+ });
+}
+
diff --git a/uvote/page/default_page/tpl/menu.tpl b/uvote/page/default_page/tpl/menu.tpl
new file mode 100644
index 0000000..0ee882c
--- /dev/null
+++ b/uvote/page/default_page/tpl/menu.tpl
@@ -0,0 +1,15 @@
+
diff --git a/uvote/page/default_page/tpl/menu_loggedout.tpl b/uvote/page/default_page/tpl/menu_loggedout.tpl
new file mode 100644
index 0000000..f9acf00
--- /dev/null
+++ b/uvote/page/default_page/tpl/menu_loggedout.tpl
@@ -0,0 +1,8 @@
+
\ No newline at end of file
diff --git a/uvote/page/default_page/tpl/page.tpl b/uvote/page/default_page/tpl/page.tpl
index b0f0678..4ca474f 100644
--- a/uvote/page/default_page/tpl/page.tpl
+++ b/uvote/page/default_page/tpl/page.tpl
@@ -10,49 +10,34 @@
${js}
-
-
-
-
-
-
-
- ${impressum_header}
- ${impressum_1}
- ${impressum_2}
- ${impressum_3}
- ${impressum_4}
- ${impressum_5}
+
-
-
+
+
-
-
-
-
-
-