summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2013-08-05 09:59:24 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2013-08-22 17:48:18 +0200
commit481ff2335c42ae1be0263eb5529981ad4b73dda0 (patch)
treed29483085464283de9417fa8b5264c1e621b368f
parentd41e40d9d6598d13ac35c7301316e4dba481be4a (diff)
downloadaurweb-481ff2335c42ae1be0263eb5529981ad4b73dda0.tar.xz
tu_details.php: Avoid inline computations
Compute the total number of votes and the participation at the beginning of the template instead of doing it inside the template itself. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
-rw-r--r--web/template/tu_details.php21
1 files changed, 15 insertions, 6 deletions
diff --git a/web/template/tu_details.php b/web/template/tu_details.php
index 4f291f0..61abab7 100644
--- a/web/template/tu_details.php
+++ b/web/template/tu_details.php
@@ -1,3 +1,12 @@
+<?php
+$yes = $row["Yes"];
+$no = $row["No"];
+$abstain = $row["Abstain"];
+$active_tus = $row["ActiveTUs"];
+
+$total = $yes + $no + $abstain;
+$participation = $total / $active_tus;
+?>
<div class="box">
<h2><?= __("Proposal Details") ?></h2>
@@ -37,10 +46,10 @@
<th><?= __('Participation') ?></th>
</tr>
<tr>
- <td><?= $row['Yes'] ?></td>
- <td><?= $row['No'] ?></td>
- <td><?= $row['Abstain'] ?></td>
- <td><?= ($row['Yes'] + $row['No'] + $row['Abstain']) ?></td>
+ <td><?= $yes ?></td>
+ <td><?= $no ?></td>
+ <td><?= $abstain ?></td>
+ <td><?= $total ?></td>
<td>
<?php if ($hasvoted == 0): ?>
<span style="color: red; font-weight: bold"><?= __("No") ?></span>
@@ -48,8 +57,8 @@
<span style="color: green; font-weight: bold"><?= __("Yes") ?></span>
<?php endif; ?>
</td>
- <?php if ($row['ActiveTUs'] > 0): ?>
- <td><?= number_format(($row['Yes'] + $row['No'] + $row['Abstain']) / $row['ActiveTUs'] * 100, 2) ?>%</td>
+ <?php if ($active_tus > 0): ?>
+ <td><?= number_format($participation * 100, 2) ?>%</td>
<?php else: ?>
<td><?= __("unknown") ?></td>
<?php endif; ?>