function m_show_roster() { global $xoopsModule, $xoopsSecurity; $db = XoopsDatabaseFactory::getDatabaseConnection(); $id = rmc_server_var($_REQUEST, 'id', 0); if ($id > 0) { MCHFunctions::page_from_item($id, 'player'); } $page = rmc_server_var($_REQUEST, 'page', 1); $page = $page <= 0 ? 1 : $page; $limit = 15; $team = rmc_server_var($_REQUEST, 'team', 0); $age = rmc_server_var($_REQUEST, 'age', 0); $direction = rmc_server_var($_REQUEST, 'direction', 1); $search = rmc_server_var($_REQUEST, 'search', ''); $filters = false; //Barra de Navegación $sql = "SELECT COUNT(*) FROM " . $db->prefix('mch_players'); if ($team > 0 || $age > 0 || $search != '') { $sql .= " WHERE "; $filters = true; } $and = false; if ($team > 0) { $sql .= " team={$team}"; $and = true; $t = new MCHTeam($team); if (!$t->isNew()) { $team_data = array('name' => $t->getVar('name')); } unset($t); } if ($age > 0) { $sql .= $and ? ' AND ' : ''; $sql .= $direction ? 'birth<=' . (time() - $age * 365 * 24 * 60 * 60) : 'birth>=' . (time() - $age * 365 * 24 * 60 * 60); $and = true; } if ($search != '') { $sql .= $and ? ' AND ' : ''; $sql .= "(name LIKE '%{$search}%' OR lastname LIKE '%{$search}%' OR surname LIKE '%{$search}%')"; } list($num) = $db->fetchRow($db->query($sql)); $tpages = ceil($num / $limit); $page = $page > $tpages ? $tpages : $page; $start = $num <= 0 ? 0 : ($page - 1) * $limit; $nav = new RMPageNav($num, $limit, $page, 5); $nav->target_url('roster.php?page={PAGE_NUM}&team=' . $team); $players = array(); $sql = str_replace('COUNT(*)', '*', $sql); $sql .= ' ORDER BY ' . ($team > 0 ? 'position,lastname,surname,name' : 'lastname,surname,name'); $result = $db->query($sql); $cache_team = array(); $timef = new RMTimeFormatter('', "%M% %d%, %Y%"); while ($row = $db->fetchArray($result)) { $player = new MCHPlayer(); $player->assignVars($row); if (isset($cache_team[$player->getVar('team')])) { $t = $cache_team[$player->getVar('team')]; } else { $cache_team[$player->getVar('team')] = new MCHTeam($player->getVar('team')); $t = $cache_team[$player->getVar('team')]; } $plage = (time() - $player->getVar('birth')) / (365 * 24 * 60 * 60); $players[] = array('id' => $player->id(), 'link' => $player->permalink(), 'name' => $player->getVar('name'), 'lastname' => $player->getVar('lastname'), 'surname' => $player->getVar('surname'), 'nameid' => $player->getVar('nameid'), 'created' => $timef->format($player->getVar('created')), 'age' => sprintf(__('%u years, %u months', 'match'), intval($plage), ($plage - intval($plage)) * 12), 'birth' => $timef->format($player->getVar('birth')), 'position' => MCHFunctions::position_name($player->getVar('position')), 'team' => array('id' => $t->id(), 'name' => $t->getVar('name'), 'link' => $t->permalink())); } // Categories $teams = MCHFunctions::all_teams(false); // Event $players = RMEvents::get()->run_event('match.list.players', $players); MCHFunctions::toolbar(); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » " . __('Players', 'match')); RMTemplate::get()->assign('xoops_pagetitle', __('Players', 'match')); RMTemplate::get()->add_style('admin.css', 'match'); RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js'); RMTemplate::get()->add_local_script('admin_match.js', 'match'); RMTemplate::get()->add_head("<script type='text/javascript'>\nvar mch_message='" . __('Do you really want to delete selected players?', 'match') . "';\n\n var mch_select_message = '" . __('You must select some player before to execute this action!', 'match') . "';</script>"); xoops_cp_header(); $match_extra_options = RMEvents::get()->run_event('match.more.options'); include RMTemplate::get()->get_template("admin/mch_roster.php", 'module', 'match'); xoops_cp_footer(); }