summaryrefslogtreecommitdiff
path: root/includes/pages/admin_free.php
diff options
context:
space:
mode:
authorJan-Philipp Litza <janphilipp@litza.de>2012-12-26 18:14:23 +0100
committerJan-Philipp Litza <janphilipp@litza.de>2012-12-26 18:14:23 +0100
commitfe6fab67be17cd271eb77294f33667a81c7ea156 (patch)
tree735ebd674dccff29049fa26056eb5c695e6e50d4 /includes/pages/admin_free.php
parent3cc2896376c4ef5b8d01320259010ba4e4576a3a (diff)
filter free angels by angeltype
Diffstat (limited to 'includes/pages/admin_free.php')
-rw-r--r--includes/pages/admin_free.php20
1 files changed, 18 insertions, 2 deletions
diff --git a/includes/pages/admin_free.php b/includes/pages/admin_free.php
index d5e3bd36..d6f4b7a0 100644
--- a/includes/pages/admin_free.php
+++ b/includes/pages/admin_free.php
@@ -6,7 +6,22 @@ function admin_free() {
if (isset ($_REQUEST['search']))
$search = strip_request_item('search');
- $users = sql_select("SELECT `User`.* FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` LEFT JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID` AND `Shifts`.`start` < " . sql_escape(time()) . " AND `Shifts`.`end` > " . sql_escape(time()) . ") WHERE `User`.`Gekommen` = 1 AND `Shifts`.`SID` IS NULL GROUP BY `User`.`UID` ORDER BY `Nick`");
+ $angeltypesearch = "";
+ if (empty ($_REQUEST['angeltype']))
+ $_REQUEST['angeltype'] = '';
+ else {
+ $angeltypesearch = " INNER JOIN `UserAngelTypes` ON (`UserAngelTypes`.`angeltype_id` = '" . sql_escape($_REQUEST['angeltype']) . "' AND `UserAngelTypes`.`user_id` = `User`.`UID`";
+ if (isset ($_REQUEST['confirmed_only']))
+ $angeltypesearch .= " AND `UserAngelTypes`.`confirm_user_id`";
+ $angeltypesearch .= ") ";
+ }
+
+ $angel_types_source = sql_select("SELECT `id`, `name` FROM `AngelTypes` ORDER BY `name`");
+ $angel_types = array('' => 'alle Typen');
+ foreach ($angel_types_source as $angel_type)
+ $angel_types[$angel_type['id']] = $angel_type['name'];
+
+ $users = sql_select("SELECT `User`.* FROM `User` ${angeltypesearch} LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` LEFT JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID` AND `Shifts`.`start` < " . sql_escape(time()) . " AND `Shifts`.`end` > " . sql_escape(time()) . ") WHERE `User`.`Gekommen` = 1 AND `Shifts`.`SID` IS NULL GROUP BY `User`.`UID` ORDER BY `Nick`");
$table = "";
if ($search == "")
@@ -41,8 +56,9 @@ function admin_free() {
}
return template_render('../templates/admin_free.html', array (
'search' => $search,
+ 'angeltypes' => html_select_key('angeltype', 'angeltype', $angel_types, $_REQUEST['angeltype']),
'table' => $table,
'link' => page_link_to('admin_free')
));
}
-?> \ No newline at end of file
+?>