示例#1
0
 /**
  * Действие для управления настройками
  */
 public function action_index()
 {
     $settings = \Model_Striker::find('first');
     $seasons = \Model_Season::get_seasons_for_select();
     if (\Input::method() == 'POST') {
         $settings->show = \Input::post('show', 0);
         $settings->season_id = \Input::post('season_id');
         $settings->save();
         \Session::set_flash('success', 'Настройки обновлены.');
         \Response::redirect_back('admin/competitions/strikers');
     }
     \View::set_global('seasons', $seasons);
     \View::set_global('settings', $settings);
     $this->template->content = \View::forge('competitions/strikers/index', array('settings' => $settings));
 }
示例#2
0
 /**
  * Действие для создания матча
  */
 public function action_create()
 {
     if (\Input::method() == 'POST') {
         $val = \Model_Match::validate('create');
         if ($val->run()) {
             $match = \Model_Match::forge(array('team_1_id' => \Input::post('team_1_id'), 'team_2_id' => \Input::post('team_2_id'), 'status_id' => 1, 'season_id' => \Input::post('season_id'), 'date' => \Input::post('date') ? strtotime(\Input::post('date')) : NULL, 'name' => \Input::post('name'), 'vk_comments_count' => 0));
             if ($match and $match->save()) {
                 \Session::set_flash('success', 'Матч создано.');
                 \Response::redirect('admin/competitions/matches/edit/' . $match->id);
             } else {
                 \Session::set_flash('error', 'Could not save match.');
             }
         } else {
             \Session::set_flash('error', $val->error());
         }
     }
     // Сезоны для select
     \View::set_global('seasons', \Model_Season::get_seasons_for_select());
     $this->template->content = \View::forge('competitions/matches/create');
 }
示例#3
0
 public function action_get_teams_by_season()
 {
     $data['teams'] = array();
     $data['teams'][] = array('id' => '', 'val' => '');
     $season = \Model_Season::find('first', array('related' => 'teams', 'where' => array(array('id', '=', \Input::get('season_id')))));
     foreach ($season->teams as $value) {
         $data['teams'][] = array('id' => $value->id, 'val' => $value->value);
     }
     return \View::forge('competitions/seasons/get_teams_by_season', $data);
 }
示例#4
0
 /**
  * Действие для отображения списка сезонов
  */
 public function action_index()
 {
     $data['seasons'] = \Model_Season::find('all', array('order_by' => array('id' => 'desc')));
     $this->template->page_title = 'Команда :: Календарь матчей';
     $this->template->content = \View::forge('calendar/index', $data, FALSE);
 }
示例#5
0
 /**
  * Действие для отображения бомбардиров
  */
 public function action_strikers()
 {
     // Извлекаем настройки из БД
     $data['settings'] = \Model_Striker::find('first');
     if ($data['settings']->show == 1) {
         // Считаем голы игроков
         $data['season'] = \Model_Season::find($data['settings']->season_id);
         \Config::load('my_config');
         $team_id = \Config::get('main_team_id');
         $sql = "SELECT COUNT(`m_e`.`player`) AS `goals`, `m_e`.`player` AS `player`\n                FROM `matches_events` AS `m_e`                 \n                LEFT JOIN `matches` AS `m` ON (`m_e`.`match_id` = `m`.`id`) \n                WHERE `m_e`.`event_id` = 1  \n                      AND `m`.`status_id` = 2 \n                      AND `m_e`.`team_id` = {$team_id}\n                      AND (`m`.`team_1_id` = {$team_id} OR `m`.`team_2_id` = {$team_id})\n                      AND `m`.`season_id` = {$data['settings']->season_id}    \n                GROUP BY `m_e`.`player`\n                ORDER BY `goals` DESC\n                LIMIT 5";
         $data['goals'] = \DB::query($sql)->execute();
     }
     return \View::forge('widgets/strikers', $data, FALSE)->render();
 }