Mercurial > hg > fapweb
comparison results.inc.php @ 94:6edd7d623eab
Start adding votekey modes code.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 18 Oct 2013 20:28:58 +0300 |
parents | b75f99a8973c |
children | eecac02579c4 |
comparison
equal
deleted
inserted
replaced
93:f36ebd03afd6 | 94:6edd7d623eab |
---|---|
30 if (!$showResults) | 30 if (!$showResults) |
31 { | 31 { |
32 echo "<p>Sorry, no results available! Nothing to see here, move along.</p>"; | 32 echo "<p>Sorry, no results available! Nothing to see here, move along.</p>"; |
33 } | 33 } |
34 else | 34 else |
35 if (($res = stExecSQL("SELECT * FROM compos WHERE visible<>0 ORDER BY name DESC")) !== FALSE) | |
35 { | 36 { |
36 if (($res = stExecSQL("SELECT * FROM compos WHERE visible<>0 ORDER BY name DESC")) !== FALSE) | 37 if ($useASCII) echo "<pre>\n"; |
38 foreach ($res as $compo) | |
37 { | 39 { |
38 if ($useASCII) echo "<pre>\n"; | 40 $sqlConds = $sqlJoins = ""; |
39 foreach ($res as $compo) | 41 switch (stGetSetting("voteKeyMode")) |
40 { | 42 { |
41 $sql = | 43 case VOTE_FREELY: |
42 "SELECT entries.*,SUM(votes.value) AS votesum ". | 44 break; |
43 "FROM entries ". | 45 |
44 "LEFT JOIN votes ON entries.id=votes.entry_id ". | 46 case VOTE_ACTIVATE: |
45 "LEFT JOIN attendees ON attendees.id=votes.voter_id ". | 47 $sqlConds = "AND votekeys.active<>0 "; |
46 "WHERE entries.compo_id=".$compo["id"]." AND attendees.active<>0 ". | 48 break; |
47 "GROUP BY votes.entry_id ". | 49 |
48 "ORDER BY votesum DESC"; | 50 case VOTE_ASSIGN: |
51 $sqlJoins = "LEFT JOIN attendees ON votekeys.voter_id=attendees.id "; | |
52 break; | |
53 } | |
49 | 54 |
50 if (($fres = stExecSQL($sql)) !== FALSE) | 55 $sql = |
56 "SELECT entries.*,SUM(votes.value) AS votesum ". | |
57 "FROM entries ". | |
58 "LEFT JOIN votes ON entries.id=votes.entry_id ". | |
59 "LEFT JOIN votekeys ON votekeys.id=votes.voter_id ". | |
60 $sqlJoins. | |
61 "WHERE entries.compo_id=".$compo["id"]." ". | |
62 $sqlConds. | |
63 "GROUP BY votes.entry_id ". | |
64 "ORDER BY votesum DESC"; | |
65 | |
66 if (($fres = stExecSQL($sql)) !== FALSE) | |
67 { | |
68 if ($useASCII) | |
51 { | 69 { |
52 if ($useASCII) | 70 echo "<b> ".$compo["name"]." </b>\n"; |
71 echo str_repeat("=", strlen($compo["name"]) + 2)."-- - .\n\n"; | |
72 | |
73 $index = 0; | |
74 $prev = FALSE; | |
75 foreach ($fres as $entry) | |
53 { | 76 { |
54 echo "<b> ".$compo["name"]." </b>\n"; | 77 if ($entry["votesum"] != $prev || $index == 0) |
55 echo str_repeat("=", strlen($compo["name"]) + 2)."-- - .\n\n"; | 78 { |
79 $index++; | |
80 printf("%3d.", $index); | |
81 } | |
82 else | |
83 echo " "; | |
84 $prev = $entry["votesum"]; | |
56 | 85 |
57 $index = 0; | 86 printf(" %s by %s (%d pts)\n", |
58 $prev = FALSE; | 87 chentities(stChop($entry["name"], 30)), |
59 foreach ($fres as $entry) | 88 chentities(stChop($showAuthors ? $entry["author"] : "-", 30)), |
60 { | 89 $entry["votesum"]); |
61 if ($entry["votesum"] != $prev) | |
62 { | |
63 $index++; | |
64 printf("%3d.", $index); | |
65 } | |
66 else | |
67 echo " "; | |
68 $prev = $entry["votesum"]; | |
69 | 90 |
70 printf(" %s by %s (%d pts)\n", | 91 } |
71 chentities(stChop($entry["name"], 30)), | 92 echo "\n\n"; |
72 chentities(stChop($showAuthors ? $entry["author"] : "-", 30)), | 93 } |
73 $entry["votesum"]); | 94 else |
95 { | |
96 echo "<h2>".$compo["name"]."</h2>\n". | |
97 "<table class=\"attendees\" style=\"width: 80%;\">\n". | |
98 " <tr>\n". | |
99 " <th style=\"width: 1%;\">#</th>\n". | |
100 " <th style=\"width: 3%;\">Points</th>\n". | |
101 " <th>Name</th>\n". | |
102 " <th>Author</th>\n". | |
103 " </tr>\n"; | |
74 | 104 |
75 } | 105 $index = 0; |
76 echo "\n\n"; | 106 foreach ($fres as $entry) |
107 { | |
108 if ($entry["votesum"] != $prev) | |
109 $index++; | |
110 $prev = $entry["votesum"]; | |
111 echo | |
112 "<tr>". | |
113 "<td>#".$index."</td>". | |
114 "<td>".$entry["votesum"]."</td>". | |
115 "<td>".chentities($entry["name"])."</td>". | |
116 "<td>".($showAuthors ? chentities($entry["author"]) : "-")."</td>". | |
117 "</tr>\n"; | |
77 } | 118 } |
78 else | |
79 { | |
80 echo "<h2>".$compo["name"]."</h2>\n". | |
81 "<table class=\"attendees\" style=\"width: 80%;\">\n". | |
82 " <tr>\n". | |
83 " <th style=\"width: 1%;\">#</th>\n". | |
84 " <th style=\"width: 3%;\">Points</th>\n". | |
85 " <th>Name</th>\n". | |
86 " <th>Author</th>\n". | |
87 " </tr>\n"; | |
88 | 119 |
89 $index = 0; | 120 echo "</table>\n"; |
90 foreach ($fres as $entry) | |
91 { | |
92 if ($entry["votesum"] != $prev) | |
93 $index++; | |
94 $prev = $entry["votesum"]; | |
95 echo | |
96 "<tr>". | |
97 "<td>#".$index."</td>". | |
98 "<td>".$entry["votesum"]."</td>". | |
99 "<td>".chentities($entry["name"])."</td>". | |
100 "<td>".($showAuthors ? chentities($entry["author"]) : "-")."</td>". | |
101 "</tr>\n"; | |
102 } | |
103 | |
104 echo "</table>\n"; | |
105 } | |
106 } | 121 } |
107 } | 122 } |
108 if ($useASCII) echo "</pre>\n"; | |
109 } | 123 } |
124 if ($useASCII) echo "</pre>\n"; | |
110 } | 125 } |
111 ?> | 126 ?> |