-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathblock.php
176 lines (150 loc) · 4.65 KB
/
block.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
<?
include("common.php");
include_once("session.php");
include("permission_functions.php");
$bid = fixString($_GET['bid']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><?echo strip_tags($site_title);?> </title>
<?
echo $common_js;
echo $common_css;
?>
<script type='text/javascript'>
$(document).ready(function() {
<?echo $common_jquery;?>
$("#search").keyup( function(){
var ou_role = $("input:radio[name=add_role]:checked").val();
var spl = ou_role.split("_");
var search = $(this).val();
if(search.length >= 3){
var term = $("#term").val();
var url = "indexed_search.php?q=" + search;
$.getJSON(url, function(data){
$("#ajax_results").html("");
$.each(data, function(index, objValue) {
$("#ajax_results").append("<a href=\"add_participant.php?bid=<?echo $bid;?>&sou=" + spl[0] + "&srole=" + spl[1] + "&sid=" + objValue.id + "\">" + objValue.first + " " + objValue.middle + " " + objValue.last + "</a><br />");
});
});
}
});
$("#add-btn").click( function(){
$("#search-add").slideToggle();
$("#search").focus();
});
$("#search").focus();
});
</script>
</head>
<body>
<div class="container">
<?
drawHeader($id);
$info = getBlockGeneral($id, $bid);
echo "<h3>".$info[0]['title']."</h3>";
echo "<h4>".$info[0]['start_time']."</h4>";
//Figure out what the user's current role on the block is
$myRole = userCurrentRoleInBlock($bid, $id);
//print_r($myRole);
//Since we'll list the participants, let's figure out the current user's abilities
$details = getBlockDetails($id, $bid);
echo "<hr />Participants";
echo "<table class=\"table table-striped table-condensed\">";
echo "<thead><tr><th>Participant</th><th>Role</th><th>Attending</th><th>Attendaing from</th><th>Details</th></tr></thead>\n";
echo "<tbody>";
foreach($details as $item){
echo "<tr>";
echo "<td>";
echo $item['firstname']." ";
echo $item['lastname'];
echo "</td><td>";
echo $item['role'];
echo "</td><td>";
echo $item['attending'];
echo "</td><td>";
echo $item['long_name'];
echo "</td><td>";
echo "<a href=\"participant_info.php?bid=$bid&uid=".$item['id']."\" class=\"btn btn-mini\">...</a>";
if(canIDoThisToThem($myRole, $item, 'remove_participant') == true){
echo " <a href=\"remove_participant.php?bid=$bid&uid=".$item['id']."\" class=\"btn btn-danger btn-mini pull-right\"><i class=\"icon-trash icon-white\"></i> Remove</a>";
}
echo "</td>";
echo "</tr>\n";
}
echo "</tbody>";
echo "</table>";
?>
<div class="row" >
<div class="span12">
<button class="btn btn-success" id="add-btn"><i class="icon-plus icon-white"></i> Add Participant</button><br /><br />
</div>
</div>
<div class="row" id="search-add" style="display:none">
<div class="span5 well">
<?
$sql = "
SELECT p.ou_code, p.role, p.value, count(a.id)
from blocks b
left join properties p on (b.bid = p.bid)
left join participants a on (b.bid = a.bid and a.ou_code = p.ou_code and a.role = p.role)
where b.bid = '$bid'
and key = 'max'
group by p.ou_code, p.role, p.value
having count(a.id) < cast(p.value as int)
";
$results = db_query($sql);
$add_ou = $myRole['ou_code'];
$add_role = 'student';
$checked = " CHECKED ";
foreach($results as $item){
echo "<span class=\"label label-info\"><input type='radio' name='add_role' value='".$item['ou_code']."_".$item['role']."' $checked /> ";
echo $item['ou_code']." / ".$item['role']."</span> ";
//clear the checked variable so we just select the first item
$checked = "";
}
?>
<br />
<br />
<form id="form">
<input type="text" name="search" id="search" class="search-query" autocomplete="off"/>
<br />
<br />
<div id='ajax_results'></div>
</form>
<div id="error" class="span4"></div>
<div class="span5" id="spinner" style="display:none;">
<img src="images/ajax-loader.gif">
</div>
<div class="span5" id="ajax">
</div>
</div>
</div>
<?
$properties = getBlockProperties($id, $bid);
echo "<hr />Block Properties";
if($properties){
echo "<table class=\"table table-striped table-condensed\" >";
echo "<thead><tr><th>Role</th><th>key</th><th>Value</th></tr></thead>\n";
echo "<tbody>";
foreach($properties as $item){
echo "<tr>";
echo "<td>";
echo $item['ou_code']." ";
echo $item['role'];
echo "</td><td>";
echo $item['key'];
echo "</td><td>";
echo $item['value'];
echo "</td>";
echo "</tr>\n";
}
echo "</tbody>";
echo "</table>";
}
?>
</div>
</body>
</html>