protected function findModel($id) { if (($model = Order::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Order::find()->where(['status' => [Order::DONE, Order::PROCESSED, Order::NOT_MODERATED]]); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]], 'pagination' => ['pageSize' => 20]]); $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, 'user_id' => $this->user_id, 'service_id' => $this->service_id, 'date' => $this->date, 'status' => $this->status, 'kind' => $this->kind, 'members_count' => $this->members_count, 'cost' => $this->cost, 'sex' => $this->sex, 'age_min' => $this->age_min, 'age_max' => $this->age_max, 'friends_count' => $this->friends_count, 'country' => $this->country, 'city' => $this->city, 'minute_1' => $this->minute_1, 'minutes_5' => $this->minutes_5, 'hour_1' => $this->hour_1, 'hours_4' => $this->hours_4, 'day_1' => $this->day_1, 'sum' => $this->sum]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'tag_list', $this->tag_list])->andFilterWhere(['like', 'city_text', $this->city_text]); return $dataProvider; }
/* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Orders'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="order-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'status', 'format' => 'text', 'filter' => \backend\modules\task\models\db\Order::getStatuses(), 'value' => function ($model) { return \common\models\db\Promotion::getStatuses()[$model->status]; }], ['attribute' => 'url', 'format' => 'raw', 'value' => function ($model) { return '<a href="' . $model->url . '" target=_blank>' . $model->url . '</a>'; }], ['class' => \yii\grid\DataColumn::className(), 'header' => 'Действия', 'format' => 'html', 'value' => function ($model, $index, $widget) { $apply = Html::a("<span class='glyphicon glyphicon-plus'></span>", Yii::$app->urlManager->createUrl(['autopromotion/order/apply', 'id' => $model->id]), ['class' => 'btn btn-default', 'title' => 'Принять']); $rejected = Html::a("<span class='glyphicon glyphicon-minus'></span>", Yii::$app->urlManager->createUrl(['autopromotion/ajax/rejected', 'id' => $model->id]), ['class' => 'btn btn-default view-rejected-modal', 'title' => 'Отклонить']); $buttons = ''; if ($model->status == \common\models\db\Promotion::NOT_MODERATED) { $buttons = $apply . $rejected; } return $buttons; }]]]); ?> <div id="modal-window-rejected" class="well modal-window-rejected"> <div class="content">
</h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Синхронизировать все статусы', ['synchronize'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'service_id', 'format' => 'text', 'value' => function ($model) { return $model->service->name; }], ['attribute' => 'status', 'format' => 'text', 'filter' => \backend\modules\task\models\db\Order::getStatuses(), 'value' => function ($model) { return \backend\modules\task\models\db\Order::getStatuses()[$model->status]; }], 'title', ['attribute' => 'url', 'format' => 'raw', 'value' => function ($model) { return '<a href="' . $model->url . '" target=_blank>' . $model->url . '</a>'; }], 'sum', ['class' => \yii\grid\DataColumn::className(), 'header' => 'Действия', 'format' => 'html', 'value' => function ($model, $index, $widget) { $apply = Html::a("<span class='glyphicon glyphicon-plus'></span>", Yii::$app->urlManager->createUrl(['task/order/apply', 'id' => $model->id]), ['class' => 'btn btn-default', 'title' => 'Принять']); $rejected = Html::a("<span class='glyphicon glyphicon-minus'></span>", Yii::$app->urlManager->createUrl(['task/ajax/rejected', 'id' => $model->id]), ['class' => 'btn btn-default view-rejected-modal', 'title' => 'Отклонить']); $doneAndHide = Html::a("<span class='glyphicon glyphicon-remove'></span>", Yii::$app->urlManager->createUrl(['task/order/cancel', 'id' => $model->id, 'type' => \backend\modules\task\models\db\Order::DONE_AND_HIDE]), ['class' => 'btn btn-default', 'title' => 'Удалить']); $stopped = Html::a("<span class='glyphicon glyphicon-remove'></span>", Yii::$app->urlManager->createUrl(['task/order/cancel', 'id' => $model->id, 'type' => \backend\modules\task\models\db\Order::STOPPED]), ['class' => 'btn btn-default', 'title' => 'Остановить и вернуть все деньги.']); $buttons = ''; if ($model->status == \backend\modules\task\models\db\Order::NOT_MODERATED) { $buttons = $apply . $rejected; } if ($model->status == \backend\modules\task\models\db\Order::DONE) { $buttons = $doneAndHide; } if ($model->status == \backend\modules\task\models\db\Order::PROCESSED) {