From 21766764cc3eafbb7975fd51ddae929089d6ecb8 Mon Sep 17 00:00:00 2001 From: Naeltard Date: Wed, 21 Oct 2015 01:41:14 +0200 Subject: [PATCH] =?UTF-8?q?working=20state=20included=20antr=C3=A4ge=20inc?= =?UTF-8?q?luded=20js=20api=20for=20poll?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uvote/api/api_uvote.php | 5 +- uvote/api/votes/votes.php | 48 +++++++- uvote/page/autoload.inc | 3 +- uvote/page/default_page/js/loadtexts.js | 17 --- uvote/page/page_uvote.php | 7 +- .../tpl/tab_basic/tab_basic_user.tpl | 2 +- .../page/user_main_poll/js/user_main_poll.js | 13 +- .../user_main_poll/tpl/buttons/sub_button.tpl | 8 ++ uvote/page/user_main_poll/tpl/full_vote.tpl | 44 +++++-- .../page/user_main_poll/tpl/vote_buttons.tpl | 8 +- uvote/page/user_main_poll/user_main_poll.php | 13 +- .../js/user_main_poll_sub.js | 28 +++++ .../page/user_main_poll_sub/tpl/bars_user.tpl | 6 + uvote/page/user_main_poll_sub/tpl/comment.tpl | 17 +++ .../page/user_main_poll_sub/tpl/full_vote.tpl | 96 +++++++++++++++ .../tpl/icons_table_parties.tpl | 1 + .../page/user_main_poll_sub/tpl/table_bt.tpl | 7 ++ .../tpl/table_bt_choice.tpl | 3 + .../user_main_poll_sub/tpl/table_parties.tpl | 12 ++ uvote/page/user_main_poll_sub/tpl/vote_bt.tpl | 11 ++ .../user_main_poll_sub/tpl/vote_buttons.tpl | 24 ++++ .../tpl/vote_buttons_fresh.tpl | 18 +++ .../user_main_poll_sub/tpl/voteweight.tpl | 4 + .../user_main_poll_sub/user_main_poll_sub.php | 111 ++++++++++++++++++ uvote/page/user_main_votelist/tpl/vote.tpl | 17 +-- uvote/sql/qq/UVOTE_DATA_POLL_INITIATIVE.php | 8 ++ uvote/sql/qq/UVOTE_POLL_EXPIRED.php | 2 +- 27 files changed, 477 insertions(+), 56 deletions(-) create mode 100644 uvote/page/user_main_poll/tpl/buttons/sub_button.tpl create mode 100644 uvote/page/user_main_poll_sub/js/user_main_poll_sub.js create mode 100644 uvote/page/user_main_poll_sub/tpl/bars_user.tpl create mode 100644 uvote/page/user_main_poll_sub/tpl/comment.tpl create mode 100644 uvote/page/user_main_poll_sub/tpl/full_vote.tpl create mode 100644 uvote/page/user_main_poll_sub/tpl/icons_table_parties.tpl create mode 100644 uvote/page/user_main_poll_sub/tpl/table_bt.tpl create mode 100644 uvote/page/user_main_poll_sub/tpl/table_bt_choice.tpl create mode 100644 uvote/page/user_main_poll_sub/tpl/table_parties.tpl create mode 100644 uvote/page/user_main_poll_sub/tpl/vote_bt.tpl create mode 100644 uvote/page/user_main_poll_sub/tpl/vote_buttons.tpl create mode 100644 uvote/page/user_main_poll_sub/tpl/vote_buttons_fresh.tpl create mode 100644 uvote/page/user_main_poll_sub/tpl/voteweight.tpl create mode 100644 uvote/page/user_main_poll_sub/user_main_poll_sub.php create mode 100644 uvote/sql/qq/UVOTE_DATA_POLL_INITIATIVE.php diff --git a/uvote/api/api_uvote.php b/uvote/api/api_uvote.php index fdc6e93..abf29ff 100644 --- a/uvote/api/api_uvote.php +++ b/uvote/api/api_uvote.php @@ -4,7 +4,8 @@ class api_uvote extends \SYSTEM\API\api_system { //votes public static function call_vote_action_vote($poll_ID, $vote) { return votes::write_vote($poll_ID, $vote);} - + public static function call_vote_action_vote_sub($poll_ID, $vote) { + return votes::write_vote_sub($poll_ID, $vote);} public static function call_vote_action_data($location, $birthyear, $gender, $children) { return votes::write_data($location, $birthyear, $gender, $children);} @@ -58,8 +59,8 @@ class api_uvote extends \SYSTEM\API\api_system { if($set == 'bilance_choice'){ return stats_bilance_choice::basic_bilance_choice($cat); } + } } -} \ No newline at end of file diff --git a/uvote/api/votes/votes.php b/uvote/api/votes/votes.php index c401f5b..9b728b8 100644 --- a/uvote/api/votes/votes.php +++ b/uvote/api/votes/votes.php @@ -22,12 +22,21 @@ class votes { return NULL;} $con = new \SYSTEM\DB\Connection(); $res = $con->prepare( 'selVoteByGrp', - 'SELECT * FROM `uvote_data` WHERE `user_ID` = ? AND poll_ID = ?;', + 'SELECT * FROM `uvote_data` WHERE `user_ID` = ? AND poll_ID = ? AND uvote_data.group = 1;', + array(\SYSTEM\SECURITY\Security::getUser()->id,$poll_ID)); + $result = $res->next(); + return $result['choice']; + } + public static function getUserPollDataSub($poll_ID){ + if (!\SYSTEM\SECURITY\Security::isLoggedIn()){ + return NULL;} + $con = new \SYSTEM\DB\Connection(); + $res = $con->prepare( 'selVoteByGrp', + 'SELECT * FROM `uvote_data` WHERE `user_ID` = ? AND poll_ID = ? AND uvote_data.group = 2;', array(\SYSTEM\SECURITY\Security::getUser()->id,$poll_ID)); $result = $res->next(); return $result['choice']; } - public static function get_barsperusers($poll_ID,$return_as_json = true){ $con = new \SYSTEM\DB\Connection(); @@ -133,13 +142,31 @@ class votes { public static function get_voteinfo($poll_ID){ $con = new \SYSTEM\DB\Connection(); $res = $con->prepare( 'selVoteByID', - 'SELECT * FROM `uvote_votes` WHERE `ID` = ?;', + 'SELECT * FROM `uvote_votes` WHERE `ID` = ? AND uvote_votes.group = 1;', + array($poll_ID)); + $res = $res->next(); +// $res['title'] = utf8_encode($res['title']); + return $res; + } + public static function get_sublinks($poll_ID){ + $result = ''; + $res = \SQL\UVOTE_DATA_POLL_INITIATIVE::QA(array($poll_ID)); + foreach ($res as $row){ + + $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_poll/tpl/buttons/sub_button.tpl'), $row); + } +// $res['title'] = utf8_encode($res['title']); + return $result; + } + public static function get_voteinfo_sub($poll_ID){ + $con = new \SYSTEM\DB\Connection(); + $res = $con->prepare( 'selVoteByIDSub', + 'SELECT * FROM `uvote_votes` WHERE `ID` = ? AND uvote_votes.group = 2;', array($poll_ID)); $res = $res->next(); // $res['title'] = utf8_encode($res['title']); return $res; } - public static function get_party_choice($poll_ID, $party){ $res = \SQL\UVOTE_DATA_PARTY_CHOICE_PER_POLL::Q1(array($poll_ID, $party)); @@ -153,7 +180,18 @@ class votes { array($poll_ID)); $res = $con->prepare( 'insertVote', 'REPLACE uvote_data - VALUES (?, ?, ?, 0, NOW());', + VALUES (?, ?, ?, 1, NOW());', + array($poll_ID, \SYSTEM\SECURITY\Security::getUser()->id, $vote)); + return JsonResult::ok(); + } + public static function write_vote_sub($poll_ID, $vote){ + $con = new \SYSTEM\DB\Connection(); + $res = $con->prepare( 'selVote', + 'SELECT * FROM `uvote_votes` WHERE `ID` = ?;', + array($poll_ID)); + $res = $con->prepare( 'insertVote', + 'REPLACE uvote_data + VALUES (?, ?, ?, 2, NOW());', array($poll_ID, \SYSTEM\SECURITY\Security::getUser()->id, $vote)); return JsonResult::ok(); } diff --git a/uvote/page/autoload.inc b/uvote/page/autoload.inc index 84231a5..c61a71e 100644 --- a/uvote/page/autoload.inc +++ b/uvote/page/autoload.inc @@ -9,4 +9,5 @@ SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_start',''); SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_votelist',''); SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_analysis',''); SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_options',''); -SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_poll',''); \ No newline at end of file +SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_poll',''); +SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_poll_sub',''); \ No newline at end of file diff --git a/uvote/page/default_page/js/loadtexts.js b/uvote/page/default_page/js/loadtexts.js index 666e045..e33c78f 100644 --- a/uvote/page/default_page/js/loadtexts.js +++ b/uvote/page/default_page/js/loadtexts.js @@ -69,23 +69,6 @@ function get_barsperparty (poll_ID) { }); } -function vote_click (poll_ID, vote) { - $.getJSON('./api.php?call=vote&action=vote&poll_ID=' + poll_ID + '&vote=' + vote, function(data) { - var items = []; - if(data.status == true){ - alert("success"); - $('#user_main').load('./?action=open_bulletin&poll_ID=' + poll_ID, function(){ - open_vote(poll_ID); - }); - } else { - alert(data.result.message); - } - }); -} - - - - function submit_commentrate (c_ID, val) { alert('success'); $.getJSON('./api.php?call=vote&action=commentrate&c_ID=' + c_ID + '&val=' + val, function(data) { diff --git a/uvote/page/page_uvote.php b/uvote/page/page_uvote.php index 02cc4d5..5c9d805 100644 --- a/uvote/page/page_uvote.php +++ b/uvote/page/page_uvote.php @@ -24,7 +24,12 @@ class page_uvote extends \SYSTEM\API\api_default { //return (new user_main_poll($poll_ID))->html();} if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ return (new default_register ())->html();} - return (new user_main_poll($poll_ID))->html();} + return (new user_main_poll($poll_ID))->html();} + public static function page_user_main_poll_sub($poll_ID) { + //return (new user_main_poll($poll_ID))->html();} + if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ + return (new default_register ())->html();} + return (new user_main_poll_sub($poll_ID))->html();} public static function page_user_main_votelist(){ if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ diff --git a/uvote/page/user_main_analysis/tpl/tab_basic/tab_basic_user.tpl b/uvote/page/user_main_analysis/tpl/tab_basic/tab_basic_user.tpl index ce56151..e0258c8 100644 --- a/uvote/page/user_main_analysis/tpl/tab_basic/tab_basic_user.tpl +++ b/uvote/page/user_main_analysis/tpl/tab_basic/tab_basic_user.tpl @@ -20,7 +20,7 @@

${analysis_help_basic_votes}

- ${analysis_math_basic votes} + ${analysis_math_basic_votes} diff --git a/uvote/page/user_main_poll/js/user_main_poll.js b/uvote/page/user_main_poll/js/user_main_poll.js index 86ff653..f466f63 100644 --- a/uvote/page/user_main_poll/js/user_main_poll.js +++ b/uvote/page/user_main_poll/js/user_main_poll.js @@ -11,5 +11,16 @@ function init_user_main_poll(){ $('#user_main').resize(function(){ $('#pollframe').height($('#user_main').height()); }); - + +} +function vote_click (poll_ID, vote) { + $.getJSON('./api.php?call=vote&action=vote&poll_ID=' + poll_ID + '&vote=' + vote, function(data) { + var items = []; + if(data.status == true){ + alert("success"); + system.reload(); + } else { + alert(data.result.message); + } + }); } \ No newline at end of file diff --git a/uvote/page/user_main_poll/tpl/buttons/sub_button.tpl b/uvote/page/user_main_poll/tpl/buttons/sub_button.tpl new file mode 100644 index 0000000..4b10ee9 --- /dev/null +++ b/uvote/page/user_main_poll/tpl/buttons/sub_button.tpl @@ -0,0 +1,8 @@ +
+ ${title}
+ + + +
\ No newline at end of file diff --git a/uvote/page/user_main_poll/tpl/full_vote.tpl b/uvote/page/user_main_poll/tpl/full_vote.tpl index d08f220..8565c4a 100644 --- a/uvote/page/user_main_poll/tpl/full_vote.tpl +++ b/uvote/page/user_main_poll/tpl/full_vote.tpl @@ -1,5 +1,5 @@ - -
+
+
@@ -9,16 +9,37 @@
-
-

${title}

- ${openvote_help_text} - ${title} abstimmen. -
- ${voice_weight} +
+
+

${title}

+ ${openvote_help_text} + ${title} abstimmen. + +
+
+
+
+ +
+
+
+
+ ${sub_buttons} +
+
+ +
+
+
+
@@ -28,7 +49,7 @@   Statistik
-
+
@@ -65,6 +86,8 @@
+ +
@@ -76,6 +99,7 @@
${vote_buttons} + ${voice_weight}
@@ -90,5 +114,5 @@
- +
diff --git a/uvote/page/user_main_poll/tpl/vote_buttons.tpl b/uvote/page/user_main_poll/tpl/vote_buttons.tpl index 8c9b4dd..fa5772d 100644 --- a/uvote/page/user_main_poll/tpl/vote_buttons.tpl +++ b/uvote/page/user_main_poll/tpl/vote_buttons.tpl @@ -1,16 +1,16 @@
Ändere deine Stimme hier ab
- - -
diff --git a/uvote/page/user_main_poll/user_main_poll.php b/uvote/page/user_main_poll/user_main_poll.php index d89580e..892aabe 100644 --- a/uvote/page/user_main_poll/user_main_poll.php +++ b/uvote/page/user_main_poll/user_main_poll.php @@ -73,10 +73,10 @@ class user_main_poll extends SYSTEM\PAGE\Page { } $classes = array('','',''); switch($user_poll){ - case 1: $classes = array('poll_ID'=>$this->poll_ID, 'yes'=>'btn-success disabled','no'=>'btn-danger','ent'=>'btn-info','choice'=>'pro'); break; - case 2: $classes = array('poll_ID'=>$this->poll_ID, 'yes'=>'btn-success','no'=>'btn-danger disabled','ent'=>'btn-info','choice'=>'con'); break; - case 3: $classes = array('poll_ID'=>$this->poll_ID, 'yes'=>'btn-success','no'=>'btn-danger','ent'=>'btn-info disabled','choice'=>'ent'); break; - default: array('','',''); + case 1: $classes = array('poll_ID'=>$this->poll_ID, 'yes'=>'disabled','no'=>'','ent'=>'','choice'=>'_pro'); break; + case 2: $classes = array('poll_ID'=>$this->poll_ID, 'yes'=>'','no'=>'disabled','ent'=>'','choice'=>'_con'); break; + case 3: $classes = array('poll_ID'=>$this->poll_ID, 'yes'=>'','no'=>'','ent'=>'disabled','choice'=>'_ent'); break; + default: $classes = array('poll_ID'=>$this->poll_ID, 'yes'=>'','no'=>'','ent'=>'','choice'=>''); } return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_poll/tpl/vote_buttons.tpl'), $classes); @@ -93,10 +93,11 @@ class user_main_poll extends SYSTEM\PAGE\Page { return array(\SYSTEM\WEBPATH(new \PPAGE(),'user_main_poll/js/user_main_poll.js'));} public function html(){ - $poll_expired = \SQL\UVOTE_POLL_EXPIRED::Q1(array($this->poll_ID)); + $poll_expired = \SQL\UVOTE_POLL_EXPIRED::Q1(array($this->poll_ID, 1)); $user_vote = votes::getUserPollData($this->poll_ID); $vars = array(); - $vars = array_merge($vars,votes::get_voteinfo($this->poll_ID)); + $vars = array_merge($vars, votes::get_voteinfo($this->poll_ID)); + $vars['sub_buttons'] = votes::get_sublinks($this->poll_ID); $vars['choice_party'] = $this->choice_party(); $vars['bars_user'] = $this->bars_user(); $vars['bars_bt'] = $this->bars_bt(); diff --git a/uvote/page/user_main_poll_sub/js/user_main_poll_sub.js b/uvote/page/user_main_poll_sub/js/user_main_poll_sub.js new file mode 100644 index 0000000..68d92f7 --- /dev/null +++ b/uvote/page/user_main_poll_sub/js/user_main_poll_sub.js @@ -0,0 +1,28 @@ +function init_user_main_poll_sub(){ + $('#btnvote_yes').click(function () { + vote_click($(this).attr('poll_ID'),1); + }); + $('#btnvote_no').click(function () { + vote_click($(this).attr('poll_ID'),2); + }); + $('#btnvote_off').click(function () { + vote_click($(this).attr('poll_ID'),3); + }); + $('#user_main').resize(function(){ + $('#pollframe').height($('#user_main').height()); + }); + +} +function vote_click (poll_ID, vote) { + $.getJSON('./api.php?call=vote&action=vote_sub&poll_ID=' + poll_ID + '&vote=' + vote, function(data) { + var items = []; + if(data.status == true){ + alert("success"); + $('#user_main').load('./?action=open_bulletin&poll_ID=' + poll_ID, function(){ + open_vote(poll_ID); + }); + } else { + alert(data.result.message); + } + }); +} \ No newline at end of file diff --git a/uvote/page/user_main_poll_sub/tpl/bars_user.tpl b/uvote/page/user_main_poll_sub/tpl/bars_user.tpl new file mode 100644 index 0000000..0839b29 --- /dev/null +++ b/uvote/page/user_main_poll_sub/tpl/bars_user.tpl @@ -0,0 +1,6 @@ +

uvote community

+
+
${vote_yes_perc}%
+
${vote_no_perc}%
+
${vote_ent_perc}%
+
diff --git a/uvote/page/user_main_poll_sub/tpl/comment.tpl b/uvote/page/user_main_poll_sub/tpl/comment.tpl new file mode 100644 index 0000000..e0450f9 --- /dev/null +++ b/uvote/page/user_main_poll_sub/tpl/comment.tpl @@ -0,0 +1,17 @@ +
+
${timestamp}
+ +
+
${c_txt}
+
+
+ ${count_up} + + ${count_down} + +
Quelle:${c_src}
+
+ +
+ +
\ No newline at end of file diff --git a/uvote/page/user_main_poll_sub/tpl/full_vote.tpl b/uvote/page/user_main_poll_sub/tpl/full_vote.tpl new file mode 100644 index 0000000..3c01c6e --- /dev/null +++ b/uvote/page/user_main_poll_sub/tpl/full_vote.tpl @@ -0,0 +1,96 @@ +
+
+
+
+
+
+

+   Info +

+
+
+
+

${title}

+ ${openvote_help_text} + ${title} abstimmen. +
+ ${voice_weight} +
+
+
+
+
+
+
+
+
+

+   Statistik +

+
+
+
+
+
+
+

+ Endergebnis +

+
+
+ ${bars_user}
+ ${bars_bt} +
+
+
+
+
+
+
+ +
+ ${choice_party} +
+
+
+
+
+
+
+
+
+ +
+ + +
+
+
+
+

+   Abstimmen +

+
+
+
+ ${vote_buttons} +
+
+
+
+
+ +
+ Quelle: ${iframe_link} +
+
+ +
+ +
+
+ diff --git a/uvote/page/user_main_poll_sub/tpl/icons_table_parties.tpl b/uvote/page/user_main_poll_sub/tpl/icons_table_parties.tpl new file mode 100644 index 0000000..fa6b9e8 --- /dev/null +++ b/uvote/page/user_main_poll_sub/tpl/icons_table_parties.tpl @@ -0,0 +1 @@ +
${urvote_party_table_desc}
diff --git a/uvote/page/user_main_poll_sub/tpl/table_bt.tpl b/uvote/page/user_main_poll_sub/tpl/table_bt.tpl new file mode 100644 index 0000000..f6b7b01 --- /dev/null +++ b/uvote/page/user_main_poll_sub/tpl/table_bt.tpl @@ -0,0 +1,7 @@ +${choice_show} +Stimmverteilung Bundestag +
+
${bt_pro}%
+
${bt_con}%
+

${bt_ent}%

+
diff --git a/uvote/page/user_main_poll_sub/tpl/table_bt_choice.tpl b/uvote/page/user_main_poll_sub/tpl/table_bt_choice.tpl new file mode 100644 index 0000000..02671bf --- /dev/null +++ b/uvote/page/user_main_poll_sub/tpl/table_bt_choice.tpl @@ -0,0 +1,3 @@ + +Der Bundestag hat "${choice_full}" abgestimmt.

+${disclaimer} \ No newline at end of file diff --git a/uvote/page/user_main_poll_sub/tpl/table_parties.tpl b/uvote/page/user_main_poll_sub/tpl/table_parties.tpl new file mode 100644 index 0000000..1fc807c --- /dev/null +++ b/uvote/page/user_main_poll_sub/tpl/table_parties.tpl @@ -0,0 +1,12 @@ + +
+
+
${party_yes}%
+
+
+
${party_no}%
+
+
+
${party_ent}%
+
+
diff --git a/uvote/page/user_main_poll_sub/tpl/vote_bt.tpl b/uvote/page/user_main_poll_sub/tpl/vote_bt.tpl new file mode 100644 index 0000000..a5f5edc --- /dev/null +++ b/uvote/page/user_main_poll_sub/tpl/vote_bt.tpl @@ -0,0 +1,11 @@ +
+
+
+
+
${party_yes}%
+
${party_no}%
+
${party_ent}%
+
+
+
+
\ No newline at end of file diff --git a/uvote/page/user_main_poll_sub/tpl/vote_buttons.tpl b/uvote/page/user_main_poll_sub/tpl/vote_buttons.tpl new file mode 100644 index 0000000..8c9b4dd --- /dev/null +++ b/uvote/page/user_main_poll_sub/tpl/vote_buttons.tpl @@ -0,0 +1,24 @@ +
+
+
Ändere deine Stimme hier ab
+ + + +
+
+
Abgestimmt mit:
+ + +
+
diff --git a/uvote/page/user_main_poll_sub/tpl/vote_buttons_fresh.tpl b/uvote/page/user_main_poll_sub/tpl/vote_buttons_fresh.tpl new file mode 100644 index 0000000..75e0c54 --- /dev/null +++ b/uvote/page/user_main_poll_sub/tpl/vote_buttons_fresh.tpl @@ -0,0 +1,18 @@ +
+
+
Stimme hier ab
+ + + +
+
+
Noch nich Abgestimmt...
+ +
+
\ No newline at end of file diff --git a/uvote/page/user_main_poll_sub/tpl/voteweight.tpl b/uvote/page/user_main_poll_sub/tpl/voteweight.tpl new file mode 100644 index 0000000..fc5d06f --- /dev/null +++ b/uvote/page/user_main_poll_sub/tpl/voteweight.tpl @@ -0,0 +1,4 @@ +
+ Dein aktuelles Stimmgewicht bei dieser Abstimmung: + ${voteweight}% +
\ No newline at end of file diff --git a/uvote/page/user_main_poll_sub/user_main_poll_sub.php b/uvote/page/user_main_poll_sub/user_main_poll_sub.php new file mode 100644 index 0000000..fdff3af --- /dev/null +++ b/uvote/page/user_main_poll_sub/user_main_poll_sub.php @@ -0,0 +1,111 @@ +poll_ID = $poll_ID; + } + + private function choice_party (){ + $result = ''; + $party_votes = \SQL\UVOTE_DATA_PARTY_PER_POLL::QA(array($this->poll_ID)); + foreach($party_votes as $pv){ + $vote = array( 'party' => $pv['party'], + 'choice' => switchers::get_party_per_poll($pv['choice']), + 'choice_class' => switchers::tablerow_class($pv['choice']), + 'party_yes' => $pv['votes_pro'] > 0 ? round($pv['votes_pro']/$pv['total']*100,0) : ($pv['choice'] == 1 ? '100' : '0'), + 'party_no' => $pv['votes_contra'] > 0 ? round($pv['votes_contra']/$pv['total']*100,0) : ($pv['choice'] == 2 ? '100' : '0'), + 'party_off' => $pv['total'] > 0 ? round(($pv['total'] - $pv['nr_attending'])/$pv['total']*100,0) : '0', + 'party_ent' => $pv['nr_attending'] > 0 ? round(($pv['nr_attending'] - $pv['votes_pro'] - $pv['votes_contra'])/$pv['nr_attending']*100,0) : $pv['nr_attending']); + if($vote['party_yes'] == '0' && $vote['party_no'] == '0' && $vote['party_ent'] == '0'){ + $vote['party_ent'] = 100;} + $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_poll/tpl/vote_bt.tpl'),$vote); + } + return $result; + } + private function bars_user(){ + $bars = votes::get_barsperusers($this->poll_ID,false); + $bars['vote_yes_perc'] = round($bars['yes_perc']*100,0); + $bars['vote_no_perc'] = round($bars['no_perc']*100,0); + $bars['vote_ent_perc'] = round($bars['ent_perc']*100,0); + $bars['title'] = 'Gemessen auf uVote'; + return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_poll/tpl/bars_user.tpl'),$bars); + } + + + + private function bars_bt(){ + $vars = votes::get_bar_bt_per_poll($this->poll_ID); + $info = votes::get_voteinfo($this->poll_ID); + if (!$vars['bt_total']){ + + $var['disclaimer'] = 'Keine differenzierten Ergebnisse für den Bundestag verfügbar'; + $var['choice'] = switchers::tablerow_class($info['bt_choice']); + $var['choice_full'] = switchers::tablerow_class($info['bt_choice']); + if ($var['choice_full'] == ''){ + $var['choice_full'] = 'noch nicht'; + } + return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_poll/tpl/table_bt_choice.tpl'), $var); + } + + $vars['disclaimer'] = ''; + $vars['choice'] = switchers::tablerow_class($info['bt_choice']); + $vars['choice_full'] = switchers::tablerow_class($info['bt_choice']); + if ($vars['choice_full'] == 'open'){ + $vars['choice_full'] = 'noch nicht'; + } + $vars['choice_show'] = SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_poll/tpl/table_bt_choice.tpl'), $vars); + $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(),'user_main_poll/tpl/table_bt.tpl'), $vars); + } + + private function voice_weight(){ + $vars = votes::get_count_user_votes_per_poll($this->poll_ID); + $vars['voteweight'] = $vars['count'] ? round(1/$vars['count']*100) : 'no votes'; + return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_poll/tpl/voteweight.tpl'), $vars); + } + + private function vote_buttons($poll_expired,$user_poll){ + + if(!$user_poll){ + return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_poll/tpl/vote_buttons_fresh.tpl', array('poll_ID'=>$this->poll_ID))); + } + $classes = array('','',''); + switch($user_poll){ + case 1: $classes = array('poll_ID'=>$this->poll_ID, 'yes'=>'disabled','no'=>'','ent'=>'','choice'=>'_pro'); break; + case 2: $classes = array('poll_ID'=>$this->poll_ID, 'yes'=>'','no'=>'disabled','ent'=>'','choice'=>'_con'); break; + case 3: $classes = array('poll_ID'=>$this->poll_ID, 'yes'=>'','no'=>'','ent'=>'disabled','choice'=>'_ent'); break; + default: $classes = array('poll_ID'=>$this->poll_ID, 'yes'=>'','no'=>'','ent'=>'','choice'=>''); + } + + return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_poll/tpl/vote_buttons.tpl'), $classes); + + } + private function get_voteinfo(){ + $var = votes::get_voteinfo($this->poll_ID); + return $var['iframe_link']; + } + public static function js(){ + return array(\SYSTEM\WEBPATH(new \PPAGE(),'user_main_poll_sub/js/user_main_poll_sub.js'));} + + public function html(){ + $poll_expired = \SQL\UVOTE_POLL_EXPIRED::Q1(array($this->poll_ID, 2)); + $user_vote = votes::getUserPollDataSub($this->poll_ID); + $vars = array(); + $vars = array_merge($vars,votes::get_voteinfo_sub($this->poll_ID)); + $vars['choice_party'] = $this->choice_party(); + $vars['bars_user'] = $this->bars_user(); + $vars['bars_bt'] = $this->bars_bt(); + $vars['voice_weight'] = $this->voice_weight(); + $vars['vote_buttons'] = $this->vote_buttons($poll_expired, $user_vote); + $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=files&cat=frontend_logos&id='; + $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('uvote_register')); + $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('uvote')); + //$vars['vote'] = $this->get_voteinfo(); //votes::getVoteOfGroup($poll_ID); + $result = SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_poll_sub/tpl/full_vote.tpl'), $vars); + return $result; + } + +} \ No newline at end of file diff --git a/uvote/page/user_main_votelist/tpl/vote.tpl b/uvote/page/user_main_votelist/tpl/vote.tpl index 7bc3b85..e1185aa 100644 --- a/uvote/page/user_main_votelist/tpl/vote.tpl +++ b/uvote/page/user_main_votelist/tpl/vote.tpl @@ -1,17 +1,20 @@
+ +
+ +
+
+ ${title} +
-
- ${title} -
-
- - ${statusmarker} -

diff --git a/uvote/sql/qq/UVOTE_DATA_POLL_INITIATIVE.php b/uvote/sql/qq/UVOTE_DATA_POLL_INITIATIVE.php new file mode 100644 index 0000000..17c01c9 --- /dev/null +++ b/uvote/sql/qq/UVOTE_DATA_POLL_INITIATIVE.php @@ -0,0 +1,8 @@ +