summaryrefslogtreecommitdiff
path: root/web/template/tu_details.php
blob: 38f6c0d0b4a3d827b9c668dfaf55e46b36a535b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
$yes = $row["Yes"];
$no = $row["No"];
$abstain = $row["Abstain"];
$active_tus = $row["ActiveTUs"];
$quorum = $row["Quorum"];

$total = $yes + $no + $abstain;
if ($active_tus > 0) {
	$participation = $total / $active_tus;
} else {
	$participation = 0;
}

if ($yes > $active_tus / 2) {
	$vote_accepted = true;
} elseif ($participation > $quorum && $yes > $no) {
	$vote_accepted = true;
} else {
	$vote_accepted = false;
}
?>
<div class="box">
	<h2><?= __("Proposal Details") ?></h2>

	<?php if ($isrunning == 1): ?>
	<p style="font-weight: bold; color: red">
		<?= __("This vote is still running.") ?>
	</p>
	<?php endif; ?>

	<p>
		<?= __("User") ?>:
		<strong>
			<?php if (!empty($row['User'])): ?>
			<a href="<?= get_uri('/packages/'); ?>?K=<?= $row['User'] ?>&amp;SeB=m"><?= $row['User'] ?></a>
			<?php else: ?>
			N/A
			<?php endif; ?>
		</strong>
		<br />
		<?= __("Submitted: %s by %s", gmdate("Y-m-d H:i", $row['Submitted']), html_format_username(username_from_id($row['SubmitterID']))) ?>
		<br />
		<?= __("End") ?>:
		<strong><?= gmdate("Y-m-d H:i", $row['End']) ?></strong>
		<?php if ($isrunning == 0): ?>
		<br />
		<?= __("Result") ?>:
		<?php if ($active_tus == 0): ?>
		<span><?= __("unknown") ?></span>
		<?php elseif ($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; ?>
	</p>

	<p>
		<?= str_replace("\n", "<br />\n", htmlspecialchars($row['Agenda'])) ?>
	</p>

	<table>
		<tr>
			<?php if (!$isrunning): ?>
			<th><?= __("Yes") ?></th>
			<th><?= __("No") ?></th>
			<th><?= __("Abstain") ?></th>
			<?php endif; ?>
			<th><?= __("Total") ?></th>
			<th><?= __('Voted') ?></th>
			<th><?= __('Participation') ?></th>
		</tr>
		<tr>
			<?php if (!$isrunning): ?>
			<td><?= $yes ?></td>
			<td><?= $no ?></td>
			<td><?= $abstain ?></td>
			<?php endif; ?>
			<td><?= $total ?></td>
			<td>
				<?php if ($hasvoted == 0): ?>
				<span style="color: red; font-weight: bold"><?= __("No") ?></span>
				<?php else: ?>
				<span style="color: green; font-weight: bold"><?= __("Yes") ?></span>
				<?php endif; ?>
			</td>
			<?php if ($active_tus > 0): ?>
			<td><?= number_format($participation * 100, 2) ?>%</td>
			<?php else: ?>
			<td><?= __("unknown") ?></td>
			<?php endif; ?>
		</tr>
	</table>
</div>

<?php if (!$isrunning): ?>
<div class="box">
	<h2><?= __("Voters"); ?></h2>
	<ul>
		<?php foreach($whovoted as $voter): ?>
		<li><a href="<?= get_user_uri($voter) ?>"><?= htmlspecialchars($voter) ?></a></li>
		<?php endforeach; ?>
	</ul>
</div>
<?php endif; ?>

<div class="box">

<?php if ($canvote == 1): ?>
	<form action="<?= get_uri('/tu/'); ?>?id=<?= $row['ID'] ?>" method="post">
		<fieldset>
			<input type="submit" class="button" name="voteYes" value="<?= __("Yes") ?>" />
			<input type="submit" class="button" name="voteNo" value="<?= __("No") ?>" />
			<input type="submit" class="button" name="voteAbstain" value="<?= __("Abstain") ?>" />
			<input type="hidden" name="doVote" value="1" />
			<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
		</fieldset>
	</form>
<?php else:
	print $errorvote ?>
<?php endif; ?>
</div>