From f2fe3108a6d40ad5be9bd57ce7e99f0119b11c12 Mon Sep 17 00:00:00 2001 From: rylon Date: Sun, 16 Feb 2014 22:50:36 +0100 Subject: [PATCH 1/2] querys and vis for uvote tab --- uVote/api/votes/votes.php | 3 ++- .../qq/UVOTE_DATA_USER_PER_PARTY_OVERALL.php | 2 +- uVote/page/user_main_uVote/uVote.tpl | 8 ++++++- .../page/user_main_uVote/user_main_uVote.php | 23 +++++++++++++++++-- .../page/user_main_uVote/votecountchoice.tpl | 4 ++++ .../user_main_urVote/user_main_urVote.php | 8 +++---- 6 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 uVote/page/user_main_uVote/votecountchoice.tpl diff --git a/uVote/api/votes/votes.php b/uVote/api/votes/votes.php index cb7e5b3..d40084f 100644 --- a/uVote/api/votes/votes.php +++ b/uVote/api/votes/votes.php @@ -70,7 +70,8 @@ class votes { return \DBD\UVOTE_DATA_BT_PER_POLL::Q1(array($poll_ID));} public static function get_user_per_party_overall($user_ID){ - return \DBD\UVOTE_DATA_USER_PER_PARTY_OVERALL::QA(array($user_ID));} + return \DBD\UVOTE_DATA_USER_PER_PARTY_OVERALL::QA(array($user_ID)); + } public static function get_voteinfo($poll_ID){ diff --git a/uVote/dbd/qq/UVOTE_DATA_USER_PER_PARTY_OVERALL.php b/uVote/dbd/qq/UVOTE_DATA_USER_PER_PARTY_OVERALL.php index c05faa2..52e499e 100644 --- a/uVote/dbd/qq/UVOTE_DATA_USER_PER_PARTY_OVERALL.php +++ b/uVote/dbd/qq/UVOTE_DATA_USER_PER_PARTY_OVERALL.php @@ -9,7 +9,7 @@ class UVOTE_DATA_USER_PER_PARTY_OVERALL extends \SYSTEM\DB\QP { //mys '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 LEFT JOIN uvote_votes_per_party +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;' );}} \ No newline at end of file diff --git a/uVote/page/user_main_uVote/uVote.tpl b/uVote/page/user_main_uVote/uVote.tpl index 4365782..cafa9b9 100644 --- a/uVote/page/user_main_uVote/uVote.tpl +++ b/uVote/page/user_main_uVote/uVote.tpl @@ -1 +1,7 @@ -${votes_all} \ No newline at end of file + + + + + + ${votes_all} +
ChoiceVote Count
\ No newline at end of file diff --git a/uVote/page/user_main_uVote/user_main_uVote.php b/uVote/page/user_main_uVote/user_main_uVote.php index ac704bb..3ec5a7a 100644 --- a/uVote/page/user_main_uVote/user_main_uVote.php +++ b/uVote/page/user_main_uVote/user_main_uVote.php @@ -1,12 +1,31 @@ votes_all(); - return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_uVote/uVote.tpl'),$vars); + return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_uVote/uVote.tpl'),$vars); } } \ No newline at end of file diff --git a/uVote/page/user_main_uVote/votecountchoice.tpl b/uVote/page/user_main_uVote/votecountchoice.tpl new file mode 100644 index 0000000..b882c15 --- /dev/null +++ b/uVote/page/user_main_uVote/votecountchoice.tpl @@ -0,0 +1,4 @@ + + ${choice} + ${count} + \ No newline at end of file diff --git a/uVote/page/user_main_urVote/user_main_urVote.php b/uVote/page/user_main_urVote/user_main_urVote.php index 987dc7b..484ee94 100644 --- a/uVote/page/user_main_urVote/user_main_urVote.php +++ b/uVote/page/user_main_urVote/user_main_urVote.php @@ -2,9 +2,8 @@ class user_main_urVote extends SYSTEM\PAGE\Page { private function user_per_party_overall(){ - $vars = votes::get_user_per_party_overall(array(\SYSTEM\SECURITY\Security::getUser()->id)); - - return print_r($vars, TRUE); + $vars = votes::get_user_per_party_overall(array(\SYSTEM\SECURITY\Security::getUser()->id)); + return print_r(array(\SYSTEM\SECURITY\Security::getUser()->id,$vars), TRUE); // if (!$vars['bt_total']){ // return 'no data yet';} @@ -16,8 +15,7 @@ class user_main_urVote extends SYSTEM\PAGE\Page { public function html(){ $vars = array(); - $vars['choices_user_ID'] = $this->user_per_party_overall(); - $vars['frontend_logos'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).'api.php?call=img&cat=frontend_logos&id='; + $vars['choices_user_ID'] = $this->user_per_party_overall(); return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_urVote/urVote.tpl'),$vars); } From 70d10293cff160631c8cc92237f78f89f98c0c98 Mon Sep 17 00:00:00 2001 From: rylon Date: Sun, 16 Feb 2014 23:01:33 +0100 Subject: [PATCH 2/2] fixed party match missmatch --- uVote/page/user_main_urVote/urVote.tpl | 9 +++++++- uVote/page/user_main_urVote/urvoteparties.tpl | 5 ++++ .../user_main_urVote/user_main_urVote.php | 23 +++++++++++-------- 3 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 uVote/page/user_main_urVote/urvoteparties.tpl diff --git a/uVote/page/user_main_urVote/urVote.tpl b/uVote/page/user_main_urVote/urVote.tpl index 75707e2..41666ac 100644 --- a/uVote/page/user_main_urVote/urVote.tpl +++ b/uVote/page/user_main_urVote/urVote.tpl @@ -1,3 +1,10 @@
-${choices_user_ID} + + + + + + + ${choices_user_ID} +
PartyMatchMissmatch
\ No newline at end of file diff --git a/uVote/page/user_main_urVote/urvoteparties.tpl b/uVote/page/user_main_urVote/urvoteparties.tpl new file mode 100644 index 0000000..4e107fa --- /dev/null +++ b/uVote/page/user_main_urVote/urvoteparties.tpl @@ -0,0 +1,5 @@ + + ${party} + ${class_MATCH} + ${class_MISSMATCH} + \ No newline at end of file diff --git a/uVote/page/user_main_urVote/user_main_urVote.php b/uVote/page/user_main_urVote/user_main_urVote.php index 484ee94..ab81183 100644 --- a/uVote/page/user_main_urVote/user_main_urVote.php +++ b/uVote/page/user_main_urVote/user_main_urVote.php @@ -2,15 +2,20 @@ class user_main_urVote extends SYSTEM\PAGE\Page { private function user_per_party_overall(){ - $vars = votes::get_user_per_party_overall(array(\SYSTEM\SECURITY\Security::getUser()->id)); - return print_r(array(\SYSTEM\SECURITY\Security::getUser()->id,$vars), TRUE); - -// if (!$vars['bt_total']){ -// return 'no data yet';} -// $vars['bt_ent'] = round(($vars['bt_attending'] - $vars['bt_pro'] - $vars['bt_con'])/$vars['bt_total']*100,0); -// $vars['bt_pro'] = round($vars['bt_pro']/$vars['bt_total']*100,0); -// $vars['bt_con'] = round($vars['bt_con']/$vars['bt_total']*100,0); - return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/table_bt.tpl'), $vars); + //$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)); + while($row = $res->next()){ + $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_urVote/urvoteparties.tpl'), $row);; + } + return $result; } public function html(){