if (!empty($_POST['terms'])) { if ($_POST['terms'] == _('Acepto')) { $db->query("INSERT INTO league_terms VALUES({$current_user->user_id}, 'nivea')"); } else { header("location: /"); exit; } } $accepted_terms = $db->get_row("SELECT count(*) as t FROM league_terms WHERE user_id={$current_user->user_id} AND vendor='nivea'")->t == 1; } /* }}} */ $sites = $db->get_results("select * from subs where visible order by id asc"); $args = compact('league', 'accepted_terms', 'sites'); Haanga::Load('league/layout-header.tpl', $args); if (isset($_GET['match'])) { $match = new Match(intval($_GET['match'])); if ($match->read() && $match->league_id == $league->id) { $match->print_summary(); } } else { foreach ($league->get_pages($league->per_page) as $m) { $match = new Match($m->id); $match->read(); $match->print_summary(); } echo '<div class="pages-ad">'; do_pages_reverse($league->total, $league->per_page); echo '</div>'; } echo '</body></html>'; /* vim:set noet ci pi sts=0 sw=4 ts=4: */
$data = array('leagues' => $db->get_results("SELECT id,name FROM league"), 'teams' => $db->get_results("SELECT id,name FROM league_teams")); switch ($_GET['action']) { case 'create': create_form('match', _('Agregar un partido'), $data); break; case 'update': $league = new Match($_GET['id']); if (!$league->read()) { die(_("No se puede encontrar el PArtido")); } create_form('match', _('Editar un partido'), array_merge($data, get_object_vars($league))); break; case 'list': default: $total = $db->get_row("SELECT count(*) as total from " . Match::TABLE)->total; $per_page = 30; $pages = ceil($total / $per_page); $current = $pages; if (!empty($_GET['page']) && is_numeric($_GET['page'])) { $current = intval($_GET['page']); } $offset = ($pages - $current) * $per_page; $sql = "SELECT\n\t\tm.*,\n\t\tt1.name as local,\n\t\tt1.shortname as local_short,\n\t\tt2.name as visitante,\n\t\tt2.shortname as visitante_short,\n\t\tl.name as liga\n\tFROM \n\t\t" . Match::TABLE . " m\n\tINNER JOIN " . Team::TABLE . " t1 ON (t1.id = m.local)\n\tINNER JOIN " . Team::TABLE . " t2 ON (t2.id = m.visitor)\n\tINNER JOIN " . League::TABLE . " l ON (l.id = m.league_id)\n\tORDER BY id DESC\n\tLIMIT {$offset}, {$per_page}\n\t"; $data['cols'] = array('liga' => _('Liga'), 'local' => _('Local'), 'visitante' => _('Visitante'), 'date' => _('Fecha')); $data['rows'] = $db->get_results($sql); $data['page'] = $globals['league_base_url'] . 'matches.php'; Haanga::Load("league/abm-list.tpl", $data); do_pages_reverse($total, $per_page); } do_footer(); /* vim:set noet ci pi sts=0 sw=4 ts=4: */