Пример #1
0
function m_show_teams()
{
    global $xoopsModule, $xoopsSecurity;
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $id = rmc_server_var($_REQUEST, 'id', 0);
    if ($id > 0) {
        MCHFunctions::page_from_item($id, 'team');
    }
    $page = rmc_server_var($_REQUEST, 'page', 1);
    $page = $page <= 0 ? 1 : $page;
    $limit = 15;
    $category = rmc_server_var($_REQUEST, 'category', 0);
    //Barra de Navegación
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('mch_teams');
    if ($category > 0) {
        $sql .= " WHERE category={$category}";
    }
    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('teams.php?page={PAGE_NUM}');
    $teams = array();
    $result = $db->query("SELECT * FROM " . $db->prefix("mch_teams") . ($category > 0 ? " WHERE category={$category}" : '') . " ORDER BY `wins`,active LIMIT {$start},{$limit}");
    $cache_cat = array();
    while ($row = $db->fetchArray($result)) {
        $team = new MCHTeam();
        $team->assignVars($row);
        if (isset($cache_cat[$team->getVar('category')])) {
            $cat = $cache_cat[$team->getVar('category')];
        } else {
            $cache_cat[$team->getVar('category')] = new MCHCategory($team->getVar('category'));
            $cat = $cache_cat[$team->getVar('category')];
        }
        $date = new RMTimeFormatter(0, __('%M% %d%, %Y%', 'match'));
        $teams[] = array('id' => $team->id(), 'link' => $team->permalink(), 'name' => $team->getVar('name'), 'active' => $team->getVar('active'), 'wins' => $team->getVar('wins'), 'nameid' => $team->getVar('nameid'), 'info' => $team->getVar('info'), 'created' => $date->format($team->getVar('created')), 'category' => array('id' => $cat->id(), 'name' => $cat->getVar('name'), 'link' => $cat->permalink()));
    }
    // Categories
    $categories = array();
    MCHFunctions::categories_tree($categories);
    // Event
    $teams = RMEvents::get()->run_event('match.list.teams', $teams);
    MCHFunctions::toolbar();
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> &raquo; " . __('Teams', 'match'));
    RMTemplate::get()->assign('xoops_pagetitle', __('Teams', '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 teams?\\nAll players and coaches assigned to this team will be deleted also.\\n\\nIf you no want to lose data, then reassign players and coaches before to delete this team.', 'match') . "';\n\n        var mch_select_message = '" . __('You must select some team 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_teams.php", 'module', 'match');
    xoops_cp_footer();
}
Пример #2
0
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);
    $search = rmc_server_var($_REQUEST, 'search', '');
    $filters = false;
    //Barra de Navegación
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('mch_coaches');
    if ($team > 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 ($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('coaches.php?page={PAGE_NUM}&amp;team=' . $team);
    $coaches = array();
    $sql = str_replace('COUNT(*)', '*', $sql);
    $sql .= ' ORDER BY ' . ($team > 0 ? 'charge,lastname,surname,name' : 'lastname,surname,name');
    $result = $db->query($sql);
    $cache_team = array();
    $timef = new RMTimeFormatter('', "%M% %d%, %Y%");
    while ($row = $db->fetchArray($result)) {
        $coach = new MCHCoach();
        $coach->assignVars($row);
        if (isset($cache_team[$coach->getVar('team')])) {
            $t = $cache_team[$coach->getVar('team')];
        } else {
            $cache_team[$coach->getVar('team')] = new MCHTeam($coach->getVar('team'));
            $t = $cache_team[$coach->getVar('team')];
        }
        $coaches[] = array('id' => $coach->id(), 'link' => $coach->permalink(), 'name' => $coach->getVar('name'), 'lastname' => $coach->getVar('lastname'), 'surname' => $coach->getVar('surname'), 'nameid' => $coach->getVar('nameid'), 'created' => $timef->format($coach->getVar('created')), 'charge' => MCHFunctions::charge_name($coach->getVar('charge')), 'team' => array('id' => $t->id(), 'name' => $t->getVar('name'), 'link' => $t->permalink()));
    }
    // Categories
    $teams = MCHFunctions::all_teams(false);
    // Event
    $coaches = RMEvents::get()->run_event('match.list.coaches', $coaches);
    MCHFunctions::toolbar();
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> &raquo; " . __('Coaches', 'match'));
    RMTemplate::get()->assign('xoops_pagetitle', __('Coaches', '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 coaches?', 'match') . "';\n\n        var mch_select_message = '" . __('You must select some coach 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_coaches.php", 'module', 'match');
    xoops_cp_footer();
}