function Users_view($users, $order_by, $arrived_count, $active_count, $force_active_count, $freeloads_count, $tshirts_count, $voucher_count) { foreach ($users as &$user) { $user['Nick'] = User_Nick_render($user); $user['Gekommen'] = glyph_bool($user['Gekommen']); $user['Aktiv'] = glyph_bool($user['Aktiv']); $user['force_active'] = glyph_bool($user['force_active']); $user['lastLogIn'] = date(_('m/d/Y h:i a'), $user['lastLogIn']); $user['actions'] = table_buttons(array(button_glyph(page_link_to('admin_user') . '&id=' . $user['UID'], 'edit', 'btn-xs'))); } $users[] = array('Nick' => '<strong>' . _('Sum') . '</strong>', 'Gekommen' => $arrived_count, 'Aktiv' => $active_count, 'force_active' => $force_active_count, 'Tshirt' => $tshirts_count, 'actions' => '<strong>' . count($users) . '</strong>'); return page_with_title(_('All users'), array(msg(), buttons(array(button(page_link_to('register'), glyph('plus') . _('New user')))), table(array('Nick' => Users_table_header_link('Nick', _('Nick'), $order_by), 'Vorname' => Users_table_header_link('Vorname', _('First Name'), $order_by), 'Name' => Users_table_header_link('Name', _('Name'), $order_by), 'gender' => Users_table_header_link('gender', _('Gender'), $order_by), 'Handy' => Users_table_header_link('Mobile', _('Mobile'), $order_by), 'Telefon' => Users_table_header_link('Phone', _('Phone'), $order_by), 'Gekommen' => Users_table_header_link('Gekommen', _('Available'), $order_by), 'Aktiv' => Users_table_header_link('Aktiv', _('Active'), $order_by), 'force_active' => Users_table_header_link('force_active', _('Forced'), $order_by), 'kommentar' => Users_table_header_link('kommentar', _('Additional Info'), $order_by), 'lastLogIn' => Users_table_header_link('lastLogIn', _('Last login'), $order_by), 'actions' => ''), $users))); }
function Users_view($users, $order_by, $arrived_count, $active_count, $force_active_count, $freeloads_count, $tshirts_count, $voucher_count) { global $user; foreach ($users as &$user_item) { $user_item['Nick'] = User_Nick_render($user_item); $user_item['Gekommen'] = glyph_bool($user_item['Gekommen']); $user_item['got_voucher'] = $user_item['got_voucher']; $user_item['kiffel'] = glyph_bool($user_item['kiffel']); $user_item['Aktiv'] = glyph_bool($user_item['Aktiv']); $user_item['force_active'] = glyph_bool($user_item['force_active']); $user_item['Tshirt'] = glyph_bool($user_item['Tshirt']); $user_item['lastLogIn'] = date(_('m/d/Y h:i a'), $user_item['lastLogIn']); $user_item['actions'] = table_buttons(array(button_glyph(page_link_to('admin_user') . '&id=' . $user_item['UID'], 'edit', 'btn-xs'))); } $users[] = array('Nick' => '<strong>' . _('Sum') . '</strong>', 'Gekommen' => $arrived_count, 'got_voucher' => $voucher_count, 'Aktiv' => $active_count, 'force_active' => $force_active_count, 'freeloads' => $freeloads_count, 'Tshirt' => $tshirts_count, 'actions' => '<strong>' . count($users) . '</strong>'); return page_with_title(_('All users'), array(msg(), buttons(array(button(page_link_to('register'), glyph('plus') . _('New user')), button(page_link_to('admin_export_users') . "&type=csv&key=" . $user['api_key'], _('Export CSV')), button(page_link_to('admin_export_users') . "&type=mail&key=" . $user['api_key'], _('Export Mail')))), table(array('Nick' => Users_table_header_link('Nick', _('Nick'), $order_by), 'Vorname' => Users_table_header_link('Vorname', _('Prename'), $order_by), 'Name' => Users_table_header_link('Name', _('Name'), $order_by), 'Handy' => Users_table_header_link('Handy', _('Handy'), $order_by), 'Gekommen' => Users_table_header_link('Gekommen', _('Arrived'), $order_by), 'kiffel' => Users_table_header_link('kiffel', _('KIFfel'), $order_by), 'got_voucher' => Users_table_header_link('got_voucher', _('Voucher'), $order_by), 'freeloads' => _('Freeloads'), 'Aktiv' => Users_table_header_link('Aktiv', _('Active'), $order_by), 'force_active' => Users_table_header_link('force_active', _('Forced'), $order_by), 'Tshirt' => Users_table_header_link('Tshirt', _('T-Shirt'), $order_by), 'Size' => Users_table_header_link('Size', _('Size'), $order_by), 'lastLogIn' => Users_table_header_link('lastLogIn', _('Last login'), $order_by), 'actions' => ''), $users))); }
/** * Render angeltype membership state * * @param UserAngelType $user_angeltype * UserAngelType and AngelType * @return string */ function AngelType_render_membership($user_angeltype) { $membership = ""; if ($user_angeltype['user_angeltype_id'] != null) { if ($user_angeltype['restricted']) { if ($user_angeltype['confirm_user_id'] == null) { $membership = glyph('lock') . _("Unconfirmed"); } elseif ($user_angeltype['coordinator']) { $membership = glyph_bool(true) . _("Coordinator"); } else { $membership = glyph_bool(true) . _("Member"); } } elseif ($user_angeltype['coordinator']) { $membership = glyph_bool(true) . _("Coordinator"); } else { $membership = glyph_bool(true) . _("Member"); } } else { $membership = glyph_bool(false); } return $membership; }
function admin_active() { global $tshirt_sizes, $shift_sum_formula; $msg = ""; $search = ""; $forced_count = sql_num_query("SELECT * FROM `User` WHERE `force_active`=1"); $count = $forced_count; $limit = ""; $set_active = ""; if (isset($_REQUEST['search'])) { $search = strip_request_item('search'); } if (isset($_REQUEST['set_active'])) { $ok = true; if (isset($_REQUEST['count']) && preg_match("/^[0-9]+\$/", $_REQUEST['count'])) { $count = strip_request_item('count'); if ($count < $forced_count) { error(sprintf(_("At least %s angels are forced to be active. The number has to be greater."), $forced_count)); redirect(page_link_to('admin_active')); } } else { $ok = false; $msg .= error(_("Please enter a number of angels to be marked as active."), true); } if ($ok) { $limit = " LIMIT " . $count; } if (isset($_REQUEST['ack'])) { sql_query("UPDATE `User` SET `Aktiv` = 0 WHERE `Tshirt` = 0"); $users = sql_select("\n SELECT `User`.*, COUNT(`ShiftEntry`.`id`) as `shift_count`, {$shift_sum_formula} as `shift_length` \n FROM `User` \n LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` \n LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID` \n WHERE `User`.`Gekommen` = 1 AND `User`.`force_active`=0 \n GROUP BY `User`.`UID` \n ORDER BY `force_active` DESC, `shift_length` DESC" . $limit); $user_nicks = array(); foreach ($users as $usr) { sql_query("UPDATE `User` SET `Aktiv` = 1 WHERE `UID`='" . sql_escape($usr['UID']) . "'"); $user_nicks[] = User_Nick_render($usr); } sql_query("UPDATE `User` SET `Aktiv`=1 WHERE `force_active`=TRUE"); engelsystem_log("These angels are active now: " . join(", ", $user_nicks)); $limit = ""; $msg = success(_("Marked angels."), true); } else { $set_active = '<a href="' . page_link_to('admin_active') . '&serach=' . $search . '">« ' . _("back") . '</a> | <a href="' . page_link_to('admin_active') . '&search=' . $search . '&count=' . $count . '&set_active&ack">' . _("apply") . '</a>'; } } if (isset($_REQUEST['active']) && preg_match("/^[0-9]+\$/", $_REQUEST['active'])) { $id = $_REQUEST['active']; $user_source = User($id); if ($user_source != null) { sql_query("UPDATE `User` SET `Aktiv`=1 WHERE `UID`='" . sql_escape($id) . "' LIMIT 1"); engelsystem_log("User " . User_Nick_render($user_source) . " is active now."); $msg = success(_("Angel has been marked as active."), true); } else { $msg = error(_("Angel not found."), true); } } elseif (isset($_REQUEST['not_active']) && preg_match("/^[0-9]+\$/", $_REQUEST['not_active'])) { $id = $_REQUEST['not_active']; $user_source = User($id); if ($user_source != null) { sql_query("UPDATE `User` SET `Aktiv`=0 WHERE `UID`='" . sql_escape($id) . "' LIMIT 1"); engelsystem_log("User " . User_Nick_render($user_source) . " is NOT active now."); $msg = success(_("Angel has been marked as not active."), true); } else { $msg = error(_("Angel not found."), true); } } elseif (isset($_REQUEST['tshirt']) && preg_match("/^[0-9]+\$/", $_REQUEST['tshirt'])) { $id = $_REQUEST['tshirt']; $user_source = User($id); if ($user_source != null) { sql_query("UPDATE `User` SET `Tshirt`=1 WHERE `UID`='" . sql_escape($id) . "' LIMIT 1"); engelsystem_log("User " . User_Nick_render($user_source) . " has tshirt now."); $msg = success(_("Angel has got a t-shirt."), true); } else { $msg = error("Angel not found.", true); } } elseif (isset($_REQUEST['not_tshirt']) && preg_match("/^[0-9]+\$/", $_REQUEST['not_tshirt'])) { $id = $_REQUEST['not_tshirt']; $user_source = User($id); if ($user_source != null) { sql_query("UPDATE `User` SET `Tshirt`=0 WHERE `UID`='" . sql_escape($id) . "' LIMIT 1"); engelsystem_log("User " . User_Nick_render($user_source) . " has NO tshirt."); $msg = success(_("Angel has got no t-shirt."), true); } else { $msg = error(_("Angel not found."), true); } } $users = sql_select("\n SELECT `User`.*, COUNT(`ShiftEntry`.`id`) as `shift_count`, {$shift_sum_formula} as `shift_length` \n FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` \n LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID` \n WHERE `User`.`Gekommen` = 1 \n GROUP BY `User`.`UID` \n ORDER BY `force_active` DESC, `shift_length` DESC" . $limit); $matched_users = array(); if ($search == "") { $tokens = array(); } else { $tokens = explode(" ", $search); } 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; } } $usr['nick'] = User_Nick_render($usr); $usr['shirt_size'] = $tshirt_sizes[$usr['Size']]; $usr['work_time'] = round($usr['shift_length'] / 60) . ' min (' . round($usr['shift_length'] / 3600) . ' h)'; $usr['active'] = glyph_bool($usr['Aktiv'] == 1); $usr['force_active'] = glyph_bool($usr['force_active'] == 1); $usr['tshirt'] = glyph_bool($usr['Tshirt'] == 1); $actions = array(); if ($usr['Aktiv'] == 0) { $actions[] = '<a href="' . page_link_to('admin_active') . '&active=' . $usr['UID'] . '&search=' . $search . '">' . _("set active") . '</a>'; } if ($usr['Aktiv'] == 1 && $usr['Tshirt'] == 0) { $actions[] = '<a href="' . page_link_to('admin_active') . '&not_active=' . $usr['UID'] . '&search=' . $search . '">' . _("remove active") . '</a>'; $actions[] = '<a href="' . page_link_to('admin_active') . '&tshirt=' . $usr['UID'] . '&search=' . $search . '">' . _("got t-shirt") . '</a>'; } if ($usr['Tshirt'] == 1) { $actions[] = '<a href="' . page_link_to('admin_active') . '&not_tshirt=' . $usr['UID'] . '&search=' . $search . '">' . _("remove t-shirt") . '</a>'; } $usr['actions'] = join(' ', $actions); $matched_users[] = $usr; } $shirt_statistics = sql_select("\n SELECT `Size`, count(`Size`) AS `count`\n FROM `User`\n WHERE `Tshirt`=1\n GROUP BY `Size`\n ORDER BY `count` DESC"); $shirt_statistics[] = array('Size' => '<b>' . _("Sum") . '</b>', 'count' => '<b>' . sql_select_single_cell("SELECT count(*) FROM `User` WHERE `Tshirt`=1") . '</b>'); return page_with_title(admin_active_title(), array(form(array(form_text('search', _("Search angel:"), $search), form_submit('submit', _("Search")))), $set_active == "" ? form(array(form_text('count', _("How much angels should be active?"), $count), form_submit('set_active', _("Preview")))) : $set_active, msg(), table(array('nick' => _("Nickname"), 'shirt_size' => _("Size"), 'shift_count' => _("Shifts"), 'work_time' => _("Length"), 'active' => _("Active?"), 'force_active' => _("Forced"), 'tshirt' => _("T-shirt?"), 'actions' => ""), $matched_users), '<h2>' . _("Given shirts") . '</h2>', table(array('Size' => _("Size"), 'count' => _("Count")), $shirt_statistics))); }
function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angeltypes, $admin_angeltypes, $coordinator, $user_driver_license, $user) { $buttons = [button(page_link_to('angeltypes'), _("Angeltypes"), 'back')]; if ($angeltype['requires_driver_license']) { $buttons[] = button(user_driver_license_edit_link($user), glyph("road") . _("my driving license")); } if ($user_angeltype == null) { $buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add'); } else { if ($angeltype['requires_driver_license'] && $user_driver_license == null) { error(_("This angeltype requires a driver license. Please enter your driver license information!")); } if ($angeltype['restricted'] && $user_angeltype['confirm_user_id'] == null) { error(sprintf(_("You are unconfirmed for this angeltype. Please go to the introduction for %s to get confirmed."), $angeltype['name'])); } $buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'], _("leave"), 'cancel'); } if ($admin_angeltypes || $coordinator) { $buttons[] = button(page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'], _("edit"), 'edit'); } if ($admin_angeltypes) { $buttons[] = button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], _("delete"), 'delete'); } $page = array(msg(), buttons($buttons)); $page[] = '<h3>' . _("Description") . '</h3>'; $parsedown = new Parsedown(); if ($angeltype['description'] != "") { $page[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>'; } $coordinators = array(); $members_confirmed = array(); $members_unconfirmed = array(); foreach ($members as $member) { $member['Nick'] = User_Nick_render($member); if ($angeltype['requires_driver_license']) { $member['wants_to_drive'] = glyph_bool($member['user_id']); $member['has_car'] = glyph_bool($member['has_car']); $member['has_license_car'] = glyph_bool($member['has_license_car']); $member['has_license_3_5t_transporter'] = glyph_bool($member['has_license_3_5t_transporter']); $member['has_license_7_5t_truck'] = glyph_bool($member['has_license_7_5t_truck']); $member['has_license_12_5t_truck'] = glyph_bool($member['has_license_12_5t_truck']); $member['has_license_forklift'] = glyph_bool($member['has_license_forklift']); } if ($angeltype['restricted'] && $member['confirm_user_id'] == null) { $member['actions'] = table_buttons([button(page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $member['user_angeltype_id'], _("confirm"), 'btn-xs'), button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'], _("deny"), 'btn-xs')]); $members_unconfirmed[] = $member; } elseif ($member['coordinator']) { if ($admin_angeltypes) { $member['actions'] = table_buttons([button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&coordinator=0', _("Remove coordinator rights"), 'btn-xs')]); } else { $member['actions'] = ''; } $coordinators[] = $member; } else { if ($admin_user_angeltypes) { $member['actions'] = table_buttons([$admin_angeltypes ? button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&coordinator=1', _("Add coordinator rights"), 'btn-xs') : '', button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'], _("remove"), 'btn-xs')]); } $members_confirmed[] = $member; } } $table_headers = ['Nick' => _("Nick"), 'DECT' => _("DECT"), 'actions' => '']; if ($angeltype['requires_driver_license'] && ($coordinator || $admin_angeltypes)) { $table_headers = ['Nick' => _("Nick"), 'DECT' => _("DECT"), 'wants_to_drive' => _("Driver"), 'has_car' => _("Has car"), 'has_license_car' => _("Car"), 'has_license_3_5t_transporter' => _("3,5t Transporter"), 'has_license_7_5t_truck' => _("7,5t Truck"), 'has_license_12_5t_truck' => _("12,5t Truck"), 'has_license_forklift' => _("Forklift"), 'actions' => '']; } if (count($coordinators) > 0) { $page[] = '<h3>' . _("Coordinators") . '</h3>'; $page[] = table($table_headers, $coordinators); } if (count($members_confirmed) > 0) { $members_confirmed[] = ['Nick' => _('Sum'), 'DECT' => count($members_confirmed), 'actions' => '']; } if (count($members_unconfirmed) > 0) { $members_unconfirmed[] = ['Nick' => _('Sum'), 'DECT' => count($members_unconfirmed), 'actions' => '']; } $page[] = '<h3>' . _("Members") . '</h3>'; if ($admin_user_angeltypes) { $page[] = buttons([button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("Add"), 'add')]); } $page[] = table($table_headers, $members_confirmed); if ($admin_user_angeltypes && $angeltype['restricted'] && count($members_unconfirmed) > 0) { $page[] = '<h3>' . _("Unconfirmed") . '</h3>'; $page[] = buttons([button(page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'], _("confirm all"), 'ok'), button(page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'], _("deny all"), 'cancel')]); $page[] = table($table_headers, $members_unconfirmed); } return page_with_title(sprintf(_("Team %s"), $angeltype['name']), $page); }