-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewcentered.php
executable file
·205 lines (205 loc) · 7.3 KB
/
viewcentered.php
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php
$creator = get_event_creator($event["id"]);
$schedules = get_schedules_for_event($event["id"]);
$users = get_users($event["id"]);
$creatorname = $creator["name"];
if ($creator["account"] != 0)
{
$c = get_account_info($creator["account"]);
$creatorname = $c["first_name"] . " " . $c["last_name"];
}
for($i = 0; $i < count($users); $i++)
{
if ($users[$i]["id"] == $creator["id"])
array_splice($users, $i, 1);
}
?>
<?php echo "<span style=\"color: #999\">Scheduled by " . $creatorname . "</span><br>"; ?>
<?php if ($event["description"] != "") echo $event["description"] . "<br>" ?>
<div class="tabs">
<ul class="tab-links">
<?php if ($event["account"] !== $account) { ?>
<li class="active"><a href="#select"><?php echo ($me === false ? 'Select' : 'Edit') ?> Availability</a></li>
<li><?php } else echo "<li class=\"active\">" ?>
<?php if ($event["hidden"] == 0 || $event["account"] === $account) { ?><a href="#results">Poll Results</a></li>
<li><?php } ?><a href="#discussion">Discussion (<?php echo count($comments) ?>)</a></li>
<?php if ($event["public"] == 1 || $event["account"] === $account) { ?>
<li><a href="#share">Share</a></li>
<?php } ?>
<?php if ($event["account"] === $account) { ?>
<li><a href="#edit">Edit Event</a></li>
<?php } ?>
<div style="clear:both"></div>
<hr style="position: absolute; margin: -1px; width: 100%; z-index: -1">
</ul>
<div class="tab-content">
<?php if ($event["account"] !== $account) { ?>
<div id="select-div" class="tab active">
<form action="vote?event=<?php echo $_GET["event"] ?><?php if (isset($_GET["key"])) echo "&key=" . $_GET["key"] ?>" method="POST">
<?php if ($account === false) { ?>
<strong>Name</strong><br>
<input type="text" name="name" required <?php echo ($me !== false ? 'value="' . $me["name"] . '" disabled' : '') ?>><br>
<?php } ?>
<?php echo ($me === false ? 'Select' : 'Edit') ?> your availability for the event <strong><?php echo $event["name"] ?></strong>.<br>
<table border="1">
<tr>
<th>Time</th>
<th style="background-color: SpringGreen; width: 20%">Preferred</th>
<th style="background-color: LightGreen; width: 20%">Available</th>
<th style="background-color: Salmon; width: 20%">Unavailable</th>
</tr>
<?php
$votes = array();
if ($me !== false)
{
$votes = get_votes($me["id"]);
}
foreach($schedules as $s)
{
echo "<tr>";
echo "<td>" . date("n/j/Y g:i A", strtotime($s["range_start"])) . "-" . (date("n/j/Y", strtotime($s["range_start"])) == date("n/j/Y", strtotime($s["range_end"])) ? date("g:i A", strtotime($s["range_end"])) : date("n/j/Y g:i A", strtotime($s["range_end"]))) . "</td>";
for ($i = 2; $i >= 0; $i--)
{
echo "<td><input type=\"radio\" name=\"" . $s["id"] . "\" value=\"" . $i . "\" required " . ($me !== false && $votes[$s["id"]] == $i ? "checked" : "") . "></td>";
}
echo "</tr>";
}
?>
</table>
<input type="submit" value="Submit">
</form>
</div>
<?php } ?>
<?php if ($event["hidden"] == 0 || $event["account"] === $account) { ?>
<div id="results-div" class="tab<?php if ($event["account"] === $account) echo " active" ?>">
<?php if (count($users) > 0) { ?>
<table border="1">
<tr>
<th></th>
<?php
for($i = 0; $i < count($schedules); $i++)
{
$schedules[$i]["count"] = 0;
echo "<td>" . date("n/j/Y g:i A", strtotime($schedules[$i]["range_start"])) . "-" . (date("n/j/Y", strtotime($schedules[$i]["range_start"])) == date("n/j/Y", strtotime($schedules[$i]["range_end"])) ? date("g:i A", strtotime($schedules[$i]["range_end"])) : date("n/j/Y g:i A", strtotime($schedules[$i]["range_end"]))) . "</td>";
}
?>
</tr>
<?php
foreach($users as $u)
{
$votes = get_votes($u["id"]);
echo "<tr>";
if ($u["account"] != 0)
{
$a = get_account_info($u["account"]);
echo "<td>" . $a["first_name"] . " " . $a["last_name"] . "</td>";
}
else
{
echo "<td>" . $u["name"] . "</td>";
}
for($i = 0; $i < count($schedules); $i++)
{
if ($votes[$schedules[$i]["id"]] == "2")
{
$schedules[$i]["count"]++;
echo "<td style=\"background-color: SpringGreen\">Preferred</td>";
}
else if ($votes[$schedules[$i]["id"]] == "1")
{
$schedules[$i]["count"]++;
echo "<td style=\"background-color: LightGreen\">Available</td>";
}
else if ($votes[$schedules[$i]["id"]] == "0")
{
echo "<td style=\"background-color: Salmon\">Unavailable</td>";
}
}
echo "</tr>";
}
?>
<tr>
<th>Total</th>
<?php
for($i = 0; $i < count($schedules); $i++)
{
echo "<td>" . $schedules[$i]["count"] . "</td>";
}
?>
</tr>
</table>
<?php } else echo "No responses yet!"; ?>
</div>
<?php } ?>
<div id="discussion-div" class="tab">
<form action="comment?event=<?php echo $_GET["event"] ?>" method="POST">
<?php if ($account === false) { ?>
<strong>Name</strong><br>
<input type="text" name="name" required><br>
<?php } ?>
<strong>Comment</strong><br>
<textarea name="text" cols="100" rows="5" required style="margin-bottom: 5px"></textarea><br>
<input type="submit" value="Post">
</form>
<?php
foreach($comments as $c)
{
echo "<hr>";
echo "<div id=\"comment\">";
echo "<span>" . $c["name"] . "</span> on " . date("n/j/Y g:i A", strtotime($c["timestamp"])) . "<br>";
echo $c["content"];
echo "</div>";
}
?>
<br>
</div>
<?php if ($event["public"] == 1 || $event["account"] === $account) { ?>
<div id="share-div" class="tab">
<?php if ($event["public"] == 1) { ?>
<script type="text/javascript">
function selectText(containerid) {
if (document.selection) {
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById(containerid));
range.select();
} else if (window.getSelection) {
var range = document.createRange();
range.selectNode(document.getElementById(containerid));
window.getSelection().addRange(range);
}
}
</script>
Use this link to invite others to enter their availability:<br>
<div id="selectable" onclick="selectText('selectable')"><?php echo DOMAIN . SITE_ROOT . "/view?event=" . $_GET["event"] ?></div>
<?php } else { ?>
Enter an email to invite to this poll:<br>
<form action="invite?event=<?php echo $_GET["event"] ?>" method="POST">
<input type="text" name="email" size="50" required> <input type="submit" value="Invite"><br>
</form>
<?php
$invites = get_invites($event["id"], true);
if (count($invites) > 0)
{
echo "<strong>Invites Pending</strong><br>";
foreach($invites as $i)
{
echo $i["email"] . "<br>";
}
}
?>
<?php } ?>
</div>
<?php } ?>
<div id="edit-div" class="tab">
<form action="edit?event=<?php echo $_GET["event"] ?>" method="POST">
<strong>Event Name</strong><br>
<input type="text" name="name" value="<?php echo $event["name"] ?>" required>
<br>
<strong>Event Description (Optional)</strong><br>
<textarea cols="50" rows="5" name="desc"><?php echo $event["description"] ?></textarea>
<br>
<input type="submit" value="Edit"><br>
</form>
</div>
</div>
</div>