2011-12-17 16:25:54 +01:00
|
|
|
<?php
|
2016-09-29 10:53:17 +02:00
|
|
|
|
2017-01-02 03:57:23 +01:00
|
|
|
function admin_free_title()
|
|
|
|
{
|
|
|
|
return _("Free angels");
|
2013-11-25 21:04:58 +01:00
|
|
|
}
|
|
|
|
|
2017-01-02 03:57:23 +01:00
|
|
|
function admin_free()
|
|
|
|
{
|
|
|
|
global $privileges;
|
2014-08-22 22:34:13 +02:00
|
|
|
|
2017-01-02 03:57:23 +01:00
|
|
|
$search = "";
|
|
|
|
if (isset($_REQUEST['search'])) {
|
|
|
|
$search = strip_request_item('search');
|
|
|
|
}
|
2014-08-22 22:34:13 +02:00
|
|
|
|
2017-01-02 03:57:23 +01:00
|
|
|
$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 .= ") ";
|
2016-09-29 10:53:17 +02:00
|
|
|
}
|
2014-08-22 22:34:13 +02:00
|
|
|
|
2017-01-02 03:57:23 +01:00
|
|
|
$angel_types_source = sql_select("SELECT `id`, `name` FROM `AngelTypes` ORDER BY `name`");
|
|
|
|
$angel_types = [
|
|
|
|
'' => 'alle Typen'
|
2016-09-29 10:53:17 +02:00
|
|
|
];
|
2017-01-02 03:57:23 +01:00
|
|
|
foreach ($angel_types_source as $angel_type) {
|
|
|
|
$angel_types[$angel_type['id']] = $angel_type['name'];
|
|
|
|
}
|
2014-08-22 22:34:13 +02:00
|
|
|
|
2017-01-02 03:57:23 +01:00
|
|
|
$users = sql_select("
|
2014-12-17 17:22:35 +01:00
|
|
|
SELECT `User`.*
|
|
|
|
FROM `User`
|
|
|
|
${angeltypesearch}
|
|
|
|
LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID`
|
2014-12-28 13:44:56 +01:00
|
|
|
LEFT JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID` AND `Shifts`.`start` < '" . sql_escape(time()) . "' AND `Shifts`.`end` > '" . sql_escape(time()) . "')
|
2014-12-17 17:22:35 +01:00
|
|
|
WHERE `User`.`Gekommen` = 1 AND `Shifts`.`SID` IS NULL
|
|
|
|
GROUP BY `User`.`UID`
|
|
|
|
ORDER BY `Nick`");
|
2014-08-22 22:34:13 +02:00
|
|
|
|
2017-01-02 03:57:23 +01:00
|
|
|
$free_users_table = [];
|
|
|
|
if ($search == "") {
|
|
|
|
$tokens = [];
|
|
|
|
} else {
|
|
|
|
$tokens = explode(" ", $search);
|
2012-12-30 17:58:23 +01:00
|
|
|
}
|
2017-01-02 03:57:23 +01:00
|
|
|
foreach ($users as $usr) {
|
|
|
|
if (count($tokens) > 0) {
|
|
|
|
$match = false;
|
|
|
|
$index = join("", $usr);
|
|
|
|
foreach ($tokens as $t) {
|
|
|
|
if (stristr($index, trim($t))) {
|
|
|
|
$match = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (! $match) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2014-08-22 22:34:13 +02:00
|
|
|
|
2017-01-02 03:57:23 +01:00
|
|
|
$free_users_table[] = [
|
2014-08-23 19:15:10 +02:00
|
|
|
'name' => User_Nick_render($usr),
|
2014-08-24 15:49:46 +02:00
|
|
|
'shift_state' => User_shift_state_render($usr),
|
2014-08-23 19:15:10 +02:00
|
|
|
'dect' => $usr['DECT'],
|
|
|
|
'jabber' => $usr['jabber'],
|
2016-11-11 15:24:51 +01:00
|
|
|
'email' => $usr['email_by_human_allowed'] ? $usr['email'] : glyph('eye-close'),
|
2017-01-02 03:57:23 +01:00
|
|
|
'actions' => in_array('admin_user', $privileges) ? button(page_link_to('admin_user') . '&id=' . $usr['UID'], _("edit"), 'btn-xs') : ''
|
2016-09-29 10:53:17 +02:00
|
|
|
];
|
2017-01-02 03:57:23 +01:00
|
|
|
}
|
|
|
|
return page_with_title(admin_free_title(), [
|
2016-09-29 10:53:17 +02:00
|
|
|
form([
|
|
|
|
div('row', [
|
|
|
|
div('col-md-4', [
|
2017-01-02 03:57:23 +01:00
|
|
|
form_text('search', _("Search"), $search)
|
2016-09-29 10:53:17 +02:00
|
|
|
]),
|
|
|
|
div('col-md-4', [
|
2017-01-02 03:57:23 +01:00
|
|
|
form_select('angeltype', _("Angeltype"), $angel_types, $_REQUEST['angeltype'])
|
2016-09-29 10:53:17 +02:00
|
|
|
]),
|
|
|
|
div('col-md-2', [
|
2017-01-02 03:57:23 +01:00
|
|
|
form_checkbox('confirmed_only', _("Only confirmed"), isset($_REQUEST['confirmed_only']))
|
2016-09-29 10:53:17 +02:00
|
|
|
]),
|
|
|
|
div('col-md-2', [
|
2017-01-02 03:57:23 +01:00
|
|
|
form_submit('submit', _("Search"))
|
|
|
|
])
|
|
|
|
])
|
2016-09-29 10:53:17 +02:00
|
|
|
]),
|
|
|
|
table([
|
2014-08-23 19:15:10 +02:00
|
|
|
'name' => _("Nick"),
|
|
|
|
'shift_state' => '',
|
|
|
|
'dect' => _("DECT"),
|
|
|
|
'jabber' => _("Jabber"),
|
|
|
|
'email' => _("E-Mail"),
|
2017-01-02 03:57:23 +01:00
|
|
|
'actions' => ''
|
|
|
|
], $free_users_table)
|
2016-09-29 10:53:17 +02:00
|
|
|
]);
|
2011-12-17 16:25:54 +01:00
|
|
|
}
|