/**
  * Lists all Players models.
  * @return mixed
  */
 public function actionIndex()
 {
     $teamId = Teams::find()->select('id')->where(['name' => Yii::$app->params['main-team']])->one()->id;
     $dataProvider['vr'] = new ActiveDataProvider(['query' => Players::find()->where(['teams_id' => $teamId, 'role' => 'вр']), 'pagination' => false]);
     $dataProvider['zsh'] = new ActiveDataProvider(['query' => Players::find()->where(['teams_id' => $teamId, 'role' => 'зщ']), 'pagination' => false]);
     $dataProvider['pzsh'] = new ActiveDataProvider(['query' => Players::find()->where(['teams_id' => $teamId, 'role' => 'пз']), 'pagination' => false]);
     $dataProvider['np'] = new ActiveDataProvider(['query' => Players::find()->where(['teams_id' => $teamId, 'role' => 'нп']), 'pagination' => false]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
示例#2
0
 /**
  * Displays a single Games model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $this->layout = 'main-full';
     $model = $this->findModel($id);
     $gameData['home'] = GamesPlayers::find()->where(['game_id' => $model->id, 'team_id' => $model->home_id])->all();
     $gameData['guest'] = GamesPlayers::find()->where(['game_id' => $model->id, 'team_id' => $model->guest_id])->all();
     $gameData['mainTeam'] = Teams::find()->select('id')->where(['name' => Yii::$app->params['main-team']])->one();
     $gameData['nextGame'] = Games::find()->select('id')->where(['home_id' => $gameData['mainTeam']->id])->orWhere(['guest_id' => $gameData['mainTeam']->id])->andWhere(['>', 'date', $model->date])->one();
     $gameData['prevGame'] = Games::find()->select('id')->where(['home_id' => $gameData['mainTeam']->id])->orWhere(['guest_id' => $gameData['mainTeam']->id])->andWhere(['<', 'date', $model->date])->orderBy('date DESC')->one();
     $dataProvider['gamePlayersHome'] = new ActiveDataProvider(['query' => GamesPlayers::find()->where(['game_id' => $model->id, 'team_id' => $model->home_id])]);
     $dataProvider['gamePlayersGuest'] = new ActiveDataProvider(['query' => GamesPlayers::find()->where(['game_id' => $model->id, 'team_id' => $model->guest_id])]);
     return $this->render('view', ['model' => $model, 'gameData' => $gameData, 'dataProvider' => $dataProvider]);
 }
示例#3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Teams::find()->orderBy('id DESC');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'year', $this->year])->andFilterWhere(['like', 'web_site', $this->web_site])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'stadium', $this->stadium]);
     return $dataProvider;
 }
 /**
  * Lists all ClubQuestionsSearch models.
  * @return mixed
  */
 public function actionIndex()
 {
     $model = new ClubQuestions();
     $data['mainTeam'] = Teams::find()->where(['name' => Yii::$app->params['main-team']])->with('players')->with('coachingStaff')->one();
     if ($model->load(Yii::$app->request->post())) {
         //            var_dump($model);die;
         $ip = $_SERVER['REMOTE_ADDR'];
         if (isset($ip)) {
             $model->ip = $ip;
         } else {
             $model->ip = 'NULL';
         }
         //            $query = BlackList::find()->where(['email'=>$model->email])->orWhere(['ip'=>$model->ip]);
         //            if (!Yii::$app->user->isGuest) {
         //                $query->orWhere(['user_id'=>$model->ip]);
         //            }
         //            $blacklistedCheck = $query->one();
         //            if (is_null($blacklistedCheck)) {
         $model->date = time();
         $model->status = 'on';
         if (Yii::$app->user->isGuest) {
             $model->user_id = 0;
         } else {
             $model->user_id = Yii::$app->user->identity->id;
             $userDetails = User::findOne($model->user_id);
             $model->name = $userDetails['username'];
             $model->email = $userDetails['email'];
         }
         if ($model->save()) {
             //                    $model = new ClubQuestions();
             return Alert::widget(['options' => ['class' => 'alert-success'], 'body' => '<b>Успешно!</b> Ваша запись опубликованна.']);
         } else {
             var_dump($model->errors);
             exit;
         }
         //            } else {
         //                return Alert::widget([
         //                    'options' => [
         //                        'class' => 'alert-danger'
         //                    ],
         //                    'body' => '<b>Ошибка!</b> Вы в чёрном списке.'
         //                ]);
         //            }
     }
     $dataProvider = new ActiveDataProvider(['query' => ClubQuestions::find()->where(['status' => 'on'])->orderBy('date DESC'), 'pagination' => ['pageSize' => 20]]);
     return $this->render('index', ['dataProvider' => $dataProvider, 'model' => $model, 'data' => $data]);
 }
 public function searchFrontend($params)
 {
     $model = Teams::find()->where(['name' => Yii::$app->params['main-team']])->with('seasonDetails')->one();
     $season_id = $model->lastSeasonDetails->season_id;
     $query = SeasonDetails::find()->select('*, `goals_scored`-`goals_against` as `rm`')->where(['season_id' => $season_id])->orderBy('spectacles DESC, wins DESC, draws DESC, lesions, rm DESC, goals_scored DESC, goals_against');
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => false, 'sort' => false]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'season_id' => $this->season_id, 'team_id' => $this->team_id, 'games' => $this->games, 'wins' => $this->wins, 'draws' => $this->draws, 'lesions' => $this->lesions, 'spectacles' => $this->spectacles, 'goals_against' => $this->goals_against, 'goals_scored' => $this->goals_scored]);
     return $dataProvider;
 }
 /**
  * Updates an existing Players model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     //        var_dump($model); die;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         if (!empty($_FILES['UploadForm']['tmp_name']['file'])) {
             $model->removeImages();
             $model->attachImage($_FILES['UploadForm']['tmp_name']['file']);
             if ($model->errors) {
                 var_dump($model->errors);
                 die;
             }
         }
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'teams' => Teams::find()->all()]);
     }
 }
示例#7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTeam()
 {
     return $this->hasOne(Teams::className(), ['id' => 'team_id']);
 }
示例#8
0
 /**
  * Displays homepage.
  *
  * @return mixed
  */
 public function actionIndex()
 {
     $data['questions'] = Questions::find()->where(['status' => 'on'])->orderBy('id DESC')->one();
     $data['answerPoll'] = AnswersPoll::find()->where(['quest_id' => $data['questions']->id, 'ip' => $_SERVER['REMOTE_ADDR']])->one();
     if (!empty($_POST)) {
         $model = new AnswersPoll();
         $dataPost = Yii::$app->request->post();
         $model->quest_id = $dataPost['question_id'];
         $model->answer_id = $dataPost['answer_id'];
         $model->ip = $_SERVER['REMOTE_ADDR'];
         $check = AnswersPoll::find()->where(['quest_id' => $model->quest_id, 'ip' => $model->ip])->one();
         $model->date = time();
         $alertMessage = '';
         if ($model->save() && is_null($check)) {
             $modelAnswer = Answers::findOne($dataPost['answer_id']);
             $modelAnswer->how_many = $modelAnswer->how_many + 1;
             $modelAnswer->save();
             $data['answerPoll'] = AnswersPoll::find()->where(['quest_id' => $data['questions']->id, 'ip' => $_SERVER['REMOTE_ADDR']])->one();
         } else {
             $alertMessage = Alert::widget(['options' => ['class' => 'alert-danger'], 'body' => '<b>Ошибка!</b> Ответ не был записан.']);
         }
         return $this->render('_poll', ['answersData' => $data['questions']->answers, 'questions' => $data['questions'], 'answerPoll' => $data['answerPoll'], 'alertMessage' => $alertMessage]);
     }
     $dataProvider['news'] = new ActiveDataProvider(['query' => News::find()->where(['status_id' => 'on'])->orderBy('date_create DESC, id DESC')->limit(10), 'pagination' => ['pageSize' => 11]]);
     $data['mainTeam'] = Teams::find()->where(['name' => Yii::$app->params['main-team']])->one();
     //        $CId = [2];
     $CId = [3];
     $allCoaches = CoachingStaff::find()->where(['teams_id' => $data['mainTeam']->id])->andWhere(['in', 'id', $CId])->all();
     $PlId = [28, 4, 20, 17];
     $allPlayers = Players::find()->where(['teams_id' => $data['mainTeam']->id])->andWhere(['in', 'id', $PlId])->all();
     $data['allPlayers'] = [];
     foreach ($allPlayers as $item) {
         //            $allPlayers[$item->id] = $item;
         if ($item->id == 28) {
             $data['allPlayers'][1] = $item;
         }
         if ($item->id == 4) {
             $data['allPlayers'][2] = $item;
         }
         if ($item->id == 20) {
             $data['allPlayers'][3] = $item;
         }
         if ($item->id == 17) {
             $data['allPlayers'][4] = $item;
         }
     }
     foreach ($allCoaches as $item) {
         $data['allCoaches'][0] = $item;
     }
     ksort($data['allPlayers']);
     //        ksort($data['allCoaches']);
     //        $data['allPlayers'] = ksort($data['allPlayers']);
     //        var_dump($data['allPlayers']);
     //        var_dump(krsort($data['allPlayers']));
     //        $data['allPlayers'][0] = $allPlayers[2];
     //        var_dump($allPlayers);
     //        die;
     //        $data['allPlayers'][1] = $allPlayers[28];
     //        $data['allPlayers'][2] = $allPlayers[4];
     //        $data['allPlayers'][3] = $allPlayers[20];
     //        $data['allPlayers'][4] = $allPlayers[17];
     //        CaseMaster::find()->where(["DATE_FORMAT( FROM_UNIXTIME( i_date ),'%d-%m-%Y' )"=>date('d-m-Y')])->all();
     //        DATE_FORMAT("2008-11-19",'%d.%m.%Y');
     //        $sorted_articles=[];
     //        foreach($articles as $article){
     //            $dt=date('d.m.Y',$article->sort_date);
     //            $sorted_articles[$dt][]=$article;
     //        }
     //        $data['allPlayers'] = [];
     //        foreach($data['allPlayers'] as $item) {
     //            var_dump(date('d.m.Y', $item->date));
     ////            var_dump($item['date_new']);
     ////            $item['new_date'] = $item->date;
     ////            $item->date = date('d.m', $item->date);
     ////            $dt = date('d.m', $item->date);
     //            $data['allPlayers'][] = $item;
     //        }
     //        var_dump($data['allPlayers']);
     $data['seasonDetails'] = $data['mainTeam']->lastSeasonDetails;
     $data['season'] = $data['seasonDetails']->season;
     $dataProvider['standings'] = new ActiveDataProvider(['query' => SeasonDetails::find()->where(['season_id' => $data['season']->id])->orderBy('spectacles DESC')->limit(20), 'pagination' => false]);
     $data['gameLast'] = Games::find()->where(['home_id' => $data['mainTeam']->id])->orWhere(['guest_id' => $data['mainTeam']->id])->orderBy('date')->one();
     $data['gameFirst'] = Games::find()->where(['home_id' => $data['mainTeam']->id])->orWhere(['guest_id' => $data['mainTeam']->id])->orderBy('date DESC')->one();
     $data['gamesLast'] = Games::find()->where(['home_id' => $data['mainTeam']->id])->orWhere(['guest_id' => $data['mainTeam']->id])->andWhere(['<', 'date', time()])->orderBy('date DESC')->limit(3)->all();
     $data['gamesFirst'] = Games::find()->where(['home_id' => $data['mainTeam']->id])->orWhere(['guest_id' => $data['mainTeam']->id])->andWhere(['>', 'date', time()])->orderBy('date')->limit(3)->all();
     $model = new AnswersPoll();
     return $this->render('index', ['dataProvider' => $dataProvider, 'data' => $data, 'model' => $model]);
 }
示例#9
0
 public function getAllTeams()
 {
     return Teams::find()->all();
 }
示例#10
0
 /**
  * Finds the Teams model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Teams the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Teams::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#11
0
 public function getAllTeam()
 {
     return ArrayHelper::map(Teams::find()->select(['id', 'name'])->asArray()->all(), 'id', 'name');
 }
示例#12
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGuest()
 {
     return $this->hasOne(Teams::className(), ['id' => 'guest_id']);
 }
示例#13
0
<?php

use yii\helpers\Html;
use common\models\Teams;
/* @var $this yii\web\View */
/* @var $model common\models\Players */
$this->title = 'Создание игрока';
$this->params['breadcrumbs'][] = ['label' => 'Игроки', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="players-create">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <?php 
echo $this->render('_form', ['model' => $model, 'teams' => Teams::find()->all()]);
?>

</div>