function display_content()
 {
     $team = $this->get_item();
     $db = new KKL_DB();
     $seasons = $db->getSeasons();
     $season_options = array("" => __('please_select', 'kkl-ligatool'));
     foreach ($seasons as $season) {
         $season_options[$season->id] = $season->name;
     }
     $clubs = $db->getClubs();
     $club_options = array("" => __('please_select', 'kkl-ligatool'));
     foreach ($clubs as $club) {
         $club_options[$club->id] = $club->name;
     }
     $locations = $db->getLocations();
     $location_options = array("" => __('please_select', 'kkl-ligatool'));
     foreach ($locations as $location) {
         $location_options[$location->id] = $location->title;
     }
     $leaguewinner_checked = $team->properties && array_key_exists('current_league_winner', $team->properties);
     if ($this->errors && $_POST['current_league_winner']) {
         $leaguewinner_checked = true;
     }
     $cupwinner_checked = $team->properties && array_key_exists('current_cup_winner', $team->properties);
     if ($this->errors && $_POST['current_cup_winner']) {
         $cupwinner_checked = true;
     }
     echo $this->form_table(array(array('type' => 'hidden', 'name' => 'id', 'value' => $team->id), array('title' => __('name', 'kkl-ligatool'), 'type' => 'text', 'name' => 'name', 'value' => $this->errors ? $_POST['name'] : $team->name, 'extra' => $this->errors['name'] ? array('style' => "border-color: red;") : array()), array('title' => __('url_code', 'kkl-ligatool'), 'type' => 'text', 'name' => 'short_name', 'value' => $this->errors ? $_POST['short_name'] : $team->short_name, 'extra' => $this->errors['short_name'] ? array('style' => "border-color: red;") : array()), array('title' => __('season', 'kkl-ligatool'), 'type' => 'select', 'name' => 'season', 'choices' => $season_options, 'selected' => $this->errors ? $_POST['season'] : $team->season_id, 'extra' => $this->errors['season'] ? array('style' => "border-color: red;") : array()), array('title' => __('club', 'kkl-ligatool'), 'type' => 'select', 'name' => 'club', 'choices' => $club_options, 'selected' => $this->errors ? $_POST['club'] : $team->club_id, 'extra' => $this->errors['club'] ? array('style' => "border-color: red;") : array()), array('title' => __('location', 'kkl-ligatool'), 'type' => 'select', 'name' => 'location', 'choices' => $location_options, 'selected' => $this->errors ? $_POST['location'] : $team->properties['location']), array('title' => __('current_league_winner', 'kkl-ligatool'), 'type' => 'checkbox', 'name' => 'current_league_winner', 'checked' => $leaguewinner_checked), array('title' => __('current_cup_winner', 'kkl-ligatool'), 'type' => 'checkbox', 'name' => 'current_cup_winner', 'checked' => $cupwinner_checked)));
 }
 function display_content()
 {
     $db = new KKL_DB();
     $db_locations = $db->getLocations();
     $locations = array();
     $locations[0] = __('unknown location', 'kkl-ligatool');
     foreach ($db_locations as $location) {
         $locations[$location->id] = $location->title;
     }
     $match = $this->get_item();
     $current_game_day = $this->get_game_day();
     $db_game_days = $this->get_game_days();
     $game_days = array();
     foreach ($db_game_days as $game_day) {
         $game_days[$game_day->id] = $game_day->number;
     }
     $db_teams = $db->getTeamsForSeason($current_game_day->season_id);
     $teams = array();
     foreach ($db_teams as $team) {
         $teams[$team->id] = $team->name;
     }
     $db_games = $db->getMatchesByGameDay($current_game_day->id);
     $games = array();
     $games[0] = __('back to overview', 'kkl-ligatool');
     $games[1] = __('create new game', 'kkl-ligatool');
     foreach ($db_games as $game) {
         $home = $db->getTeam($game->home_team);
         $away = $db->getTeam($game->away_team);
         $games[$game->id] = $home->name . " - " . $away->name;
     }
     $final_checked = $match->status == 3;
     if ($this->errors && $_POST['final_score']) {
         $final_checked = true;
     }
     $fixture = $this->cleanDate($match->fixture);
     echo $this->form_table(array(array('type' => 'hidden', 'name' => 'id', 'value' => $match->id), array('title' => __('game_day', 'kkl-ligatool'), 'type' => 'select', 'name' => 'game_day', 'value' => $game_days, 'selected' => $this->errors ? $_POST['game_day'] : $current_game_day->id), array('title' => __('fixture', 'kkl-ligatool'), 'type' => 'text', 'name' => 'fixture', 'value' => $fixture, 'extra' => array('class' => "pickfixture")), array('title' => __('team_home', 'kkl-ligatool'), 'type' => 'select', 'name' => 'team_home', 'value' => $teams, 'selected' => $this->errors ? $_POST['team_home'] : $match->home_team), array('title' => __('team_away', 'kkl-ligatool'), 'type' => 'select', 'name' => 'team_away', 'value' => $teams, 'selected' => $this->errors ? $_POST['team_away'] : $match->away_team), array('title' => __('location', 'kkl-ligatool'), 'type' => 'select', 'name' => 'location', 'value' => $locations), array('title' => __('goals_home', 'kkl-ligatool'), 'type' => 'select', 'name' => 'goals_home', 'value' => $this->get_goals_array(), 'selected' => $this->errors ? $_POST['goals_home'] : $match->goals_home), array('title' => __('goals_away', 'kkl-ligatool'), 'type' => 'select', 'name' => 'goals_away', 'value' => $this->get_goals_array(), 'selected' => $this->errors ? $_POST['goals_away'] : $match->goals_away), array('title' => __('score_home', 'kkl-ligatool'), 'type' => 'select', 'name' => 'score_home', 'value' => $this->get_score_array(), 'selected' => $this->errors ? $_POST['score_home'] : $match->score_home), array('title' => __('score_away', 'kkl-ligatool'), 'type' => 'select', 'name' => 'score_away', 'value' => $this->get_score_array(), 'selected' => $this->errors ? $_POST['score_away'] : $match->score_away), array('title' => __('final_score', 'kkl-ligatool'), 'type' => 'checkbox', 'name' => 'final_score', 'checked' => $final_checked), array('title' => __('description', 'kkl-ligatool'), 'type' => 'textarea', 'name' => 'description', 'value' => $this->errors ? $_POST['description'] : $match->notes, 'extra' => array('rows' => 7, 'cols' => 100)), array('title' => __('next_game', 'kkl-ligatool'), 'type' => 'select', 'name' => 'next_game', 'value' => $games, 'selected' => $this->errors ? $_POST['next_game'] : null)));
 }