On 04.08.2013 17:43, Lukas Fleischer wrote:
> This adds an field that indicates whether the vote was accepted or
> rejected, based on the rules specified in the TU Bylaws.
> 
> Signed-off-by: Lukas Fleischer <archli...@cryptocrack.de>
> ---
>  web/template/tu_details.php | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/web/template/tu_details.php b/web/template/tu_details.php
> index 4f291f0..6ed6efd 100644
> --- a/web/template/tu_details.php
> +++ b/web/template/tu_details.php
> @@ -21,6 +21,17 @@
>               <br />
>               <?= __("End") ?>:
>               <strong><?= gmdate("Y-m-d H:i", $row['End']) ?></strong>
> +             <?php if ($isrunning == 0): ?>
> +             <br />
> +             <?= __("Result") ?>:
> +             <?php if ($row['Quorum'] == 0): ?>
> +             <span><?= __("unknown") ?></span>
> +             <?php elseif (($row['Yes'] > $row['ActiveTUs'] / 2) || 
> (($row['Yes'] + $row['No'] + $row['Abstain']) / $row['ActiveTUs'] >= 
> $row['Quorum'] && $row['Yes'] > $row['No'])): ?>

This is rather long and probably better written this way:

$yes = $row["Yes"];
$active = $row["ActiveTUs"];
$no = $row["No"];
$abstain = $row["Abstain"];
$quorum = $row["Quorum"];

$total = $yes + $no + $abstain;

$vote_accepted = false;

if ($yes > $active / 2) {
        $vote_accepted = true;
}

if ($total / $active >= $quorum && $yes > $no) {
        $vote_accepted = true;
}

if ($vote_accepted) {
        ...
}

> +             <span style="color: green; font-weight: bold"><?= 
> __("Accepted") ?></span>
> +             <?php else: ?>
> +             <span style="color: red; font-weight: bold"><?= __("Rejected") 
> ?></span>
> +             <?php endif; ?>
> +             <?php endif; ?>

Also the inner if is not indented so the endifs end up at the same
level. I don't care about indentation in the resulting HTML, ymmv.

>       </p>
>  
>       <p>
> 


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to