querys and vis for uvote tab

This commit is contained in:
Ulf Gebhardt 2014-02-16 22:50:36 +01:00
parent 5a8c846c84
commit f2fe3108a6
6 changed files with 38 additions and 10 deletions

View File

@ -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){

View File

@ -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;'
);}}

View File

@ -1 +1,7 @@
${votes_all}
<table>
<tr>
<th>Choice</th>
<th>Vote Count</th>
</tr>
${votes_all}
</table>

View File

@ -1,12 +1,31 @@
<?php
class user_main_uVote extends SYSTEM\PAGE\Page {
private function votes_all(){
return print_r(votes::get_all_votes(),true);}
$votes = votes::get_all_votes();
$result = '';
foreach($votes as $vote){
switch($vote['choice']){
case 1:
$vote['choice'] = 'PRO';
break;
case 2:
$vote['choice'] = 'CONTRA';
break;
case 3:
$vote['choice'] = 'ENTH';
break;
}
//$vote['count'];
//$vote['choice'];
$result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_uVote/votecountchoice.tpl'),$vote);
}
return $result;
}
public function html(){
$vars = array();
$vars['votes_all'] = $this->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);
}
}

View File

@ -0,0 +1,4 @@
<tr>
<td>${choice}</td>
<td>${count}</td>
</tr>

View File

@ -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);
}