/** * Lists all MatchEvent models. * @return mixed */ public function actionIndex() { $searchModel = new MatchEventSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $matchEventTable = $searchModel::tableName(); $matchEventTypeTable = MatchEventType::tableName(); $matchEvents = MatchEventType::find()->innerJoin($matchEventTable, "{$matchEventTable}.match_event_type_id = {$matchEventTypeTable}.id")->all(); $eventFilter = ArrayHelper::map($matchEvents, 'id', 'name'); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'eventFilter' => $eventFilter]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = MatchEventType::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * Updates statistics of an existing Match model. * @param integer $id * @return mixed */ public function actionEvents($id) { $model = $this->findModel($id); $matchEventModel = new MatchEvent(); $matchEventModel->match_id = $model->id; $matchEventModelSearch = new MatchEventSearch(); $params = ['MatchEventSearch' => ['match_id' => $model->id]]; $matchEventDataProvider = $matchEventModelSearch->search($params); // $totalCount = $matchEventDataProvider->getTotalCount(); // $matchEventDataProvider->pagination = ['defaultPageSize' => 60]; $matchEventDataProvider->setSort(['defaultOrder' => ['minute' => SORT_DESC, 'additional_minute' => SORT_DESC]]); $matchEvents = MatchEventType::find()->all(); $eventFilter = ArrayHelper::map($matchEvents, 'id', 'name'); $searchModel = new CompositionSearch(); // homeCompositionDataProvider $params = ['CompositionSearch' => ['match_id' => $model->id, 'command_id' => $model->command_home_id]]; $homeCompositionDataProvider = $searchModel->search($params); $homeCompositionDataProvider->setSort(['defaultOrder' => ['is_basis' => SORT_DESC, 'number' => SORT_ASC]]); // guestCompositionDataProvider $params = ['CompositionSearch' => ['match_id' => $model->id, 'command_id' => $model->command_guest_id]]; $guestCompositionDataProvider = $searchModel->search($params); $guestCompositionDataProvider->setSort(['defaultOrder' => ['is_basis' => SORT_DESC, 'number' => SORT_ASC]]); if ($matchEventModel->load(Yii::$app->request->post()) && $matchEventModel->validate()) { $matchEventModel->save(false); $this->redirect(['match/events', 'id' => $model->id]); } return $this->render('match_events', compact('model', 'matchEventModel', 'matchEventModelSearch', 'matchEventDataProvider', 'eventFilter', 'homeCompositionDataProvider', 'guestCompositionDataProvider')); }
use common\models\Composition; /* @var $this yii\web\View */ /* @var $model common\models\MatchEvent */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="match-event-form"> <?php $form = ActiveForm::begin(); ?> <div class="row"> <div class="col-sm-6"> <?php echo $form->field($model, 'match_event_type_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(MatchEventType::find()->all(), 'id', 'name'), 'language' => 'ru', 'options' => ['placeholder' => 'Выберите тип события...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> <div class="col-sm-3"> <?php echo $form->field($model, 'minute')->textInput(); ?> </div> <div class="col-sm-3"> <?php echo $form->field($model, 'additional_minute')->textInput(); ?> </div> </div> <div class="row">
<div class="info"> <div class="minute"><?php echo $event->getTime(); ?> </div> </div> <div class="text"> <?php echo $event->notes; ?> </div> <div class="clearfix"></div> </div> <?php } else { $eventValue = MatchEventType::find()->where(['id' => $event->match_event_type_id])->all(); $eventIcon = $eventValue[0]->getAsset(); $eventIconUrl = $eventIcon->getFileUrl(); ?> <div class="message message-with-icon"> <div class="info"> <?php if ($eventIconUrl) { ?> <img src="<?php echo $eventIconUrl; ?> " class="icon"> <?php } ?>