public function actionActivitylist() { $user = new AdminUser(); if (!$user->checkUserIsLogin()) { $this->redirect(Variable::$home_url); return; } $query = Activity::find(); $pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]); $countries = $query->orderBy('addTime DESC')->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->render(Variable::$activityList_view, ['countries' => $countries, 'pagination' => $pagination]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Activity::find(); $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, 'orderid' => $this->orderid, 'create_uid' => $this->create_uid, 'create_at' => $this->create_at, 'update_at' => $this->update_at]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'template', $this->template])->andFilterWhere(['like', 'link', $this->link])->andFilterWhere(['like', 'remark', $this->remark]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Activity::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]); $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, 'id_category' => $this->id_category, 'id_type' => $this->id_type, 'lat' => $this->lat, 'lon' => $this->lon, 'geolevel' => $this->geolevel, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'url_official', $this->url_official])->andFilterWhere(['like', 'url_info', $this->url_info])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'text', $this->text])->andFilterWhere(['like', 'emails', $this->emails])->andFilterWhere(['like', 'phones', $this->phones])->andFilterWhere(['like', 'country', $this->country])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'district', $this->district])->andFilterWhere(['like', 'street', $this->street])->andFilterWhere(['like', 'zipcode', $this->zipcode])->andFilterWhere(['like', 'access', $this->access])->andFilterWhere(['like', 'geolevel_txt', $this->geolevel_txt])->andFilterWhere(['like', 'images', $this->images])->andFilterWhere(['like', 'rank', $this->rank])->andFilterWhere(['like', 'author', $this->author]); return $dataProvider; }
public function actionLink() { /*$categories = Category::find()->all(); foreach ($categories as $category){ $names = explode(';',$category->id_classification); $array = array(); foreach ($names as $id=>$name){ $classification = CategoryClassification::find()->where(['name' => $name])->one(); if ($classification){ $array[] = $classification->id; echo 'added to array '. $name . '<br>'; } } $temp = implode(";", $array); $category->id_classification = $temp; $category->save(); }*/ $categories = Activity::find()->all(); foreach ($categories as $category) { $images = explode(';', $category->images); foreach ($images as $id => $name) { $categoryImage = ActivityImage::find()->where(['name' => $name, 'id_activity' => $category->id])->one(); if ($categoryImage) { } else { $categoryImage = new ActivityImage(); $categoryImage->id_activity = $category->id; $categoryImage->name = $name; $categoryImage->save(); } } } /*$categories = Category::find()->all(); foreach ($categories as $category){ $names = explode(';',$category->id_classification); foreach ($names as $id=>$name){ $classification = CategoryClassification::find()->where(['name' => $name])->one(); if ($classification){ //echo 'yes=' . $name . '<br>'; }else{ echo 'creating =' . $name . '<br>'; $classification = new CategoryClassification(); $classification->name = $name; $classification->save(); } } //var_dump($names); }*/ /*$types = ActivityType::find()->all(); foreach ($types as $type) { $activities = Activity::find()->where(['like', 'id_type', $type->name])->all(); foreach ($activities as $activity) { $activity->id_type = $type->id; $activity->save(); } }*/ /*$activities = Category::find()->where(['id_where' => ''])->all(); foreach ($activities as $activity) { $activity->id_where = null; $activity->save(); }*/ /*$activities = Activity::find()->where(['id_type' => ''])->all(); foreach ($activities as $activity) { $activity->id_type = null; $activity->save(); }*/ /*$where = CategoryWhere::find()->all(); foreach ($where as $place) { $categories = Category::find()->where(['like', 'id_where', $place->name])->all(); foreach ($categories as $category) { $category->id_where = $place->id; $category->save(); } } $difficulties = CategoryDifficulty::find()->all(); foreach ($difficulties as $difficulty) { $categories = Category::find()->where(['like', 'id_difficulty', $difficulty->name])->all(); foreach ($categories as $category) { $category->id_difficulty = $difficulty->id; $category->save(); } } $trainings = CategoryTraining::find()->all(); foreach ($trainings as $training) { $categories = Category::find()->where(['like', 'id_training', $training->name])->all(); foreach ($categories as $category) { $category->id_training = $training->id; $category->save(); } }*/ return $this->render('link', []); }