7784e23d4443f48ba1a6fe5e7755395672f53ab7
[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['withdrawl'] && $_REQUEST['confirm'] && $_REQUEST['id']) {
22 $stmt = $db->getStatement("close decision");
23 $status = -2;
24 $stmt->bindParam(":status",$status);
25 $stmt->bindParam(":decision",$_REQUEST['id']);
26 $stmt->execute();
27 }
28 if ($_REQUEST['motion']) {
29 $stmt = $db->getStatement("list decision");
30 $stmt->execute(array($_REQUEST['motion']));
31 } else {
32 $stmt = $db->getStatement("list decisions");
33 $stmt->execute(array($page));
34 }
35 $items = 0;
36 $id = -1;
37 while ($row = $stmt->fetch()) {
38 $items++;
39 $id = $row['id'];
40 ?><tr>
41 <td class="<?php switch($row['status']) { case 0: echo "pending"; break; case 1: echo "approved"; break; case -1: echo "declined"; break; case -2: echo "withdrawn"; break; }?>">
42 <?php
43 switch($row['status']) {
44 case 0: echo "Pending<br/><i>".$row['due']." UTC</i>"; break;
45 case 1: echo "Approved<br/><i>".$row['modified']." UTC</i>"; break;
46 case -1: echo "Declined<br/><i>".$row['modified']." UTC</i>"; break;
47 case -2: echo "Withdrawn<br/><i>".$row['modified']." UTC</i>"; break;
48 }
49 ?>
50 </td>
51 <td>
52 <i><a href="motions.php?id=<?php echo $row['tag'].'">'.$row['tag']; ?></a></i><br/>
53 <b><?php echo htmlentities($row['title']); ?></b><br/>
54 <pre><?php echo htmlspecialchars($row['content']); ?></pre>
55 <br/>
56 <i>Due: <?php echo($row['due']); ?> UTC</i><br/>
57 <i>Proposed: <?php echo($row['proposer']); ?> (<?php echo($row['proposed']); ?> UTC)</i><br/>
58 <i>Required Votes: <?php echo($row['quorum']); ?></i><br/>
59 <i>Majority: <?php echo($row['majority']); ?>%</i><br/>
60 <i>Aye|Naye|Abstain: <?php echo($row['ayes']); ?>|<?php echo($row['nayes']); ?>|<?php echo($row['abstains']); ?></i><br/>
61 <?php
62 if ($row['status'] ==0 || $_REQUEST['showvotes']) {
63 $state = array('Naye','Abstain','Aye');
64 $vstmt = $db->getStatement("list votes");
65 $vstmt->execute(array($row['id']));
66 echo "<i>Votes:</i><br/>";
67 while ($vrow = $vstmt->fetch()) {
68 echo "<i>".$vrow['name']." ".$state[$vrow['vote']+1]."</i><br/>";
69 }
70 } else {
71 echo '<i><a href="motions.php?motion='.$row['tag'].'&showvotes=1">Show Votes</a></i><br/>';
72 }
73 ?>
74 </td>
75 <td class="actions">
76 <?php
77 if ($row['status'] == 0) {
78 ?>
79 <ul>
80 <li><a href="vote.php?motion=<?php echo($row['id']); ?>&amp;vote=1">Aye</a></li>
81 <li><a href="vote.php?motion=<?php echo($row['id']); ?>&amp;vote=0">Abstain</a></li>
82 <li><a href="vote.php?motion=<?php echo($row['id']); ?>&amp;vote=-1">Naye</a></li>
83 <li><a href="proxy.php?motion=<?php echo($row['id']); ?>">Proxy Vote</a></li>
84 <li><a href="motion.php?motion=<?php echo($row['id']); ?>">Modify</a></li>
85 <li><a href="motions.php?motion=<?php echo($row['tag']); ?>&amp;withdrawl=1">Withdrawl</a></li>
86 </ul>
87 <?php
88 } else {
89 ?>
90 &nbsp;
91 <?php
92 }
93 ?>
94 </td>
95 </tr><?php
96 }
97 ?>
98 <tr>
99 <td colspan="2" class="navigation">
100 <?php if ($page>1) { ?><a href="?page=<?php echo($page-1); ?>">&lt;</a><?php } else { ?>&nbsp;<?php } ?>
101 &nbsp;
102 <?php if ($items>9) { ?><a href="?page=<?php echo($page+1); ?>">&gt;</a><?php } else { ?>&nbsp;<?php } ?>
103 </td>
104 <td class="actions">
105 <ul>
106 <li><a href="motion.php">New Motion</a></li>
107 </ul>
108 </td>
109 </tr>
110 <?php
111 if ($_REQUEST['withdrawl']) {
112 ?>
113 <tr>
114 <td colspan="3">
115 <?php
116 if ($_REQUEST['confirm'] && $_REQUEST['id']) {
117 ?>
118 <a href="motions.php">Motion Withdrawn</a>
119 <?php
120 } else {
121 ?>
122 <form action="?withdrawl=1&amp;confirm=1&amp;id=<?php echo $id;?>" method="post">
123 <input type="submit" value="Withdrawl">
124 </form>
125 <?php
126 }
127 ?>
128 </td>
129 </tr>
130 <?php
131 }
132 ?>
133 </table>
134 </body>
135 </html>