add empty SQL structure. Add links to single entities
[cacert-boardvoting.git] / motions.php
1 <?php
2 require_once("database.php");
3 $db = new DB();
4 $db->closeVotes();
5 $page = is_numeric($_REQUEST['page'])?$_REQUEST['page']:1;
6 ?>
7 <html>
8 <head>
9 <title>CAcert Board Decisions</title>
10 <meta http-equiv="Content-Type" content="text/html; charset='UTF-8'" />
11 <link rel="stylesheet" type="text/css" href="styles.css" />
12 </head>
13 <body>
14 <table class="list">
15 <tr>
16 <th>Status</th>
17 <th>Motion</th>
18 <th>Actions</th>
19 </tr>
20 <?php
21 if ($_REQUEST['id']) {
22 $stmt = $db->getStatement("list decision");
23 $stmt->execute(array($_REQUEST['id']));
24 } else {
25 $stmt = $db->getStatement("list decisions");
26 $stmt->execute(array($page));
27 }
28 $items = 0;
29 while ($row = $stmt->fetch()) {
30 $items++;
31 ?><tr>
32 <td class="<?php switch($row['status']) { case 0: echo "pending"; break; case 1: echo "approved"; break; case -1: echo "declined"; break; }?>">
33 <?php
34 switch($row['status']) {
35 case 0: echo "Pending<br/><i>".$row['due']." UTC</i>"; break;
36 case 1: echo "Approved<br/><i>".$row['modified']." UTC</i>"; break;
37 case -1: echo "Declined<br/><i>".$row['modified']." UTC</i>"; break;
38 }
39 ?>
40 </td>
41 <td>
42 <i><a href="motions.php?id=<?php echo $row['tag'].'">'.$row['tag']; ?></a></i><br/>
43 <b><?php echo $row['title']; ?></b><br/>
44 <pre><?php echo $row['content']; ?></pre>
45 <br/>
46 <i>Due: <?php echo($row['due']); ?> UTC</i><br/>
47 <i>Proposed: <?php echo($row['proposer']); ?> (<?php echo($row['proposed']); ?> UTC)</i><br/>
48 <i>Required Votes: <?php echo($row['quorum']); ?></i><br/>
49 <i>Majority: <?php echo($row['majority']); ?>%</i><br/>
50 <i>Aye|Naye|Abstain: <?php echo($row['ayes']); ?>|<?php echo($row['nayes']); ?>|<?php echo($row['abstains']); ?></i><br/>
51 <?php
52 if ($row['status'] ==0 || $_REQUEST['showvotes']) {
53 $state = array('Naye','Abstain','Aye');
54 $vstmt = $db->getStatement("list votes");
55 $vstmt->execute(array($row['id']));
56 echo "<i>Votes:</i><br/>";
57 while ($vrow = $vstmt->fetch()) {
58 echo "<i>".$vrow['name']." ".$state[$vrow['vote']+1]."</i><br/>";
59 }
60 } else {
61 echo '<i><a href="motions.php?id='.$row['tag'].'&showvotes=1">Show Votes</a></i><br/>';
62 }
63 ?>
64 </td>
65 <td class="actions">
66 <?php
67 if ($row['status'] == 0) {
68 ?>
69 <ul>
70 <li><a href="vote.php?motion=<?php echo($row['id']); ?>&amp;vote=1">Aye</a></li>
71 <li><a href="vote.php?motion=<?php echo($row['id']); ?>&amp;vote=0">Abstain</a></li>
72 <li><a href="vote.php?motion=<?php echo($row['id']); ?>&amp;vote=-1">Naye</a></li>
73 <li><a href="proxy.php?motion=<?php echo($row['id']); ?>">Proxy Vote</a></li>
74 <li><a href="motion.php?motion=<?php echo($row['id']); ?>">Modify</a></li>
75 </ul>
76 <?php
77 } else {
78 ?>
79 &nbsp;
80 <?php
81 }
82 ?>
83 </td>
84 </tr><?php
85 }
86 ?>
87 <tr>
88 <td colspan="2" class="navigation">
89 <?php if ($page>1) { ?><a href="?page=<?php echo($page-1); ?>">&lt;</a><?php } else { ?>&nbsp;<?php } ?>
90 &nbsp;
91 <?php if ($items>9) { ?><a href="?page=<?php echo($page+1); ?>">&gt;</a><?php } else { ?>&nbsp;<?php } ?>
92 </td>
93 <td class="actions">
94 <ul>
95 <li><a href="motion.php">New Motion</a></li>
96 </ul>
97 </td>
98 </tr>
99 </table>
100 </body>
101 </html>