/**
  * Deletes an existing Activity model.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $this->findModel($id)->delete();
     $activities = Activity::find()->where(['belong_to' => $this->data_post['belong_to']])->orderBy('id DESC')->limit(5)->offset(0)->all();
     $this->data_post = array_merge($this->data_post, ['activities' => $activities]);
     return ['errors' => '', 'data' => $this->renderPartial('@widget/views/activities/_list', $this->data_post)];
 }
 public function actionList()
 {
     $query = Activity::find();
     $pagination = new Pagination(['defaultPageSize' => 10, 'totalCount' => $query->count()]);
     $models = $query->orderby("id DESC")->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render("list", ['models' => $models, 'pagination' => $pagination]);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $act = Models\Activity::find($id);
     //活动列表
     $activities = Models\Activity::select('id', 'title')->get();
     return view('home.activity.show', compact('act', 'activities'));
 }
 public function run()
 {
     $disViewMore = false;
     $activities = Activity::find()->where(['belong_to' => $this->belong_to])->orderBy('id DESC')->limit(5)->offset(0)->all();
     $allActivities = Activity::find()->where(['belong_to' => $this->belong_to])->orderBy('id DESC')->all();
     if (count($allActivities) <= 5) {
         $disViewMore = true;
     }
     return $this->render('activities/index', ['activities' => $activities, 'belong_to' => $this->belong_to, 'disViewMore' => $disViewMore]);
 }
 public function search($params)
 {
     $query = Activity::find()->where(['user_id' => Yii::$app->user->getId()]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 30], 'sort' => ['defaultOrder' => ['start' => SORT_DESC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'date' => $this->calories, 'val' => $this->peak_heartrate]);
     return $dataProvider;
 }
 public function search($params)
 {
     $query = Activity::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere('like', 'description', $this->description);
     return $dataProvider;
 }
 /**
  * Lists all Activity models.
  * @return mixed
  */
 public function actionIndex($id = null)
 {
     //Check user level & existence of $id
     $user = Yii::$app->user->identity->level == 0 && $id != null ? User::findOne($id) : Yii::$app->user->identity;
     $searchModel = new ActivitySearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $parentIds = \yii\helpers\ArrayHelper::getColumn($user->findParents()->all(), 'id');
     $query = Activity::find()->where(['in', 'user_id', $parentIds])->orderBy(['id' => SORT_DESC]);
     //Activity::find()->where('user_id = :parent_id OR user_id = :id', [':parent_id' =>  $user->id, ':id'=> $user->parent->id ])->orderBy(['id' => SORT_DESC]);
     //var_dump($user); die();
     $activityProvider = new ActiveDataProvider(['query' => $user->level == 3 ? $query : $query->orWhere('user_id = :parent_id OR user_id = :id', [':parent_id' => $user->id, ':id' => $user->parent->id]), 'pagination' => ['pageSize' => 8]]);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'activityProvider' => $activityProvider, 'user' => $user]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Activity::find()->where(['user_id' => Yii::$app->user->id]);
     $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, 'user_id' => $this->user_id, 'date' => $this->date]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description]);
     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]);
     $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, 'category' => $this->category, 'level_id' => $this->level_id, 'recruit_count' => $this->recruit_count, 'sign_up_begin_time' => $this->sign_up_begin_time, 'sign_up_end_time' => $this->sign_up_end_time, 'sign_up_status' => $this->sign_up_status, 'begin_time' => $this->begin_time, 'end_time' => $this->end_time, 'status' => $this->status, 'lesson' => $this->lesson, 'score' => $this->score, 'create_time' => $this->create_time, 'update_time' => $this->update_time]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'launch', $this->launch])->andFilterWhere(['like', 'organizers', $this->organizers])->andFilterWhere(['like', 'join_teams', $this->join_teams])->andFilterWhere(['like', 'create_user', $this->create_user])->andFilterWhere(['like', 'update_user', $this->update_user]);
     return $dataProvider;
 }
 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(['created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'id', $this->id])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'program_id', $this->program_id]);
     return $dataProvider;
 }
 public function actionIndex()
 {
     $levelId = \Yii::$app->request->get('levelId') ? \Yii::$app->request->get('levelId') : 2;
     $query = Activity::find()->where(['level_id' => $levelId]);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count()]);
     $models = $query->offset($pages->offset)->limit($pages->limit)->all();
     if (!empty($models)) {
         foreach ($models as $key => $val) {
             $val->begin_time = date('Y-m-d', strtotime($val->begin_time));
             //录取人数
             $countResult = \app\models\ActivityUsers::find()->where(['activity_id' => $val->id, 'status' => [ActivityUsers::APPROVED, ActivityUsers::DOING, ActivityUsers::END]]);
             $val->already_recruit_count = $countResult->count();
         }
     }
     return $this->render('index', ['models' => $models, 'pages' => $pages, 'levelId' => $levelId]);
 }
 public function actionIndex($id = -1)
 {
     $message = "";
     $errormsg = "";
     $model = new ActivityItemForm();
     if ($id > -1) {
         $model = ActivityItemForm::find()->where(['id' => $id])->one();
     }
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $message = "活动提交成功";
         $model->save();
     } else {
         $errormsg = $model->getErrors();
     }
     $activities = Activity::find()->select(['subject', 'id'])->asArray()->all();
     $acts = array();
     foreach ($activities as $activity) {
         $acts[$activity['id']] = $activity['subject'];
     }
     return $this->render("index", ['model' => $model, 'acts' => $acts, 'message' => $message, 'errormsg' => $errormsg]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Activity::find();
     $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 $query->asArray()->all();
     }
     $query->joinWith('venue');
     $query->joinWith('topic');
     $query->joinWith('activityType');
     $query->orFilterWhere(['like', 'Activity_name', $this->globalSearch])->orFilterWhere(['like', 'startDatetime', $this->globalSearch])->orFilterWhere(['like', 'endDatetime', $this->globalSearch])->orFilterWhere(['like', 'Venue.name', $this->globalSearch])->orFilterWhere(['like', 'Topic.name', $this->globalSearch])->orFilterWhere(['like', 'ActivityType.ActivityType_name', $this->globalSearch]);
     $raw = $query->asArray()->all();
     $returnArr = [];
     foreach ($raw as $row) {
         $detail = substr($row['description'], 0, 200) . '...';
         $arrayRow = ['type' => 'activity', 'id' => $row['id'], 'title' => $row['Activity_name'], 'detail' => $detail];
         array_push($returnArr, $arrayRow);
     }
     return $returnArr;
 }
 /**
  * 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->joinWith('venue');
     $query->joinWith('topic');
     $query->joinWith('activityType');
     //$query->andFilterWhere([
     //'id' => $this ->id,
     //'Venue_id' => $this -> Venue_id,
     //'ActivityType_id' => $this -> ActivityType_id
     /*$query->andFilterWhere([
                 'id' => $this->id,
                 'personInCharge' => $this->personInCharge,
                 'lastModifyTime' => $this->lastModifyTime,
                 'startDatetime' => $this->startDatetime,
                 'endDatetime' => $this->endDatetime,
                 //'Venue_id' => $this->Venue_id,
                 //'Topic_id' => $this->Topic_id,
                 //'ActivityType_id' => $this->ActivityType_id,
                 'Administrator_id' => $this->Administrator_id,
             ]);
     
             $query->andFilterWhere(['like', 'Activity_name', $this->Activity_name])
                 ->andFilterWhere(['like', 'description', $this->description])
                 ->andFilterWhere(['like', 'documentLink', $this->documentLink])
                 ->andFilterWhere(['like', 'venue.name', $this->Venue_id])
                 ->andFilterWhere(['like', 'topic.name', $this->Topic_id])
                 ->andFilterWhere(['like', 'activityType.ActivityType_name', $this->ActivityType_id]);*/
     $query->orFilterWhere(['like', 'Activity_name', $this->globalSearch])->orFilterWhere(['like', 'startDatetime', $this->globalSearch])->orFilterWhere(['like', 'endDatetime', $this->globalSearch])->orFilterWhere(['like', 'venue.name', $this->globalSearch])->orFilterWhere(['like', 'topic.name', $this->globalSearch])->orFilterWhere(['like', 'activityType.ActivityType_name', $this->globalSearch]);
     return $dataProvider;
 }
 /**
  * Display user dashboard
  * @param integer $id User ID
  */
 public function actionDashboard($id = null)
 {
     //Check user level & existence of $id
     $id = Yii::$app->user->identity->level == 0 && $id != null ? $id : Yii::$app->user->id;
     $model = User::findOne($id);
     $photos = \app\models\Photos::getItems();
     $journals = new ActiveDataProvider(['query' => Journal::find()->where('FIND_IN_SET(' . $id . ', shared_with)')->orWhere(['user_id' => $id])->orderBy(['date' => SORT_DESC])->limit(5), 'pagination' => false]);
     if ($model->level == 3) {
         //if the user is child
         $moods = new ActiveDataProvider(['query' => Mood::find()->select('mood')->where(['user_id' => $id])->orderBy(['date' => SORT_DESC, 'time' => SORT_DESC])->limit(1), 'pagination' => false]);
         $DataProvider = new ActiveDataProvider(['query' => $model->findParents(), 'pagination' => ['pageSize' => 20]]);
         return $this->render('childdashboard', ['dataProvider' => $DataProvider, 'journalProvider' => $journals, 'moodsProvider' => $moods, 'moods' => new Mood(), 'model' => $model, 'photos' => $photos]);
     } else {
         //if the user is parent
         $events = new ActiveDataProvider(['query' => \app\models\Event::find()->where('FIND_IN_SET(' . $id . ', shared_with)')->orWhere(['user_id' => $id])->orderBy(['date' => SORT_DESC])->limit(5), 'pagination' => false]);
         $wishlists = new ActiveDataProvider(['query' => \app\models\Wishlist::find()->where(['assigned_to' => $id, 'status' => 0])->orderBy('id')->limit(5), 'pagination' => false]);
         $DataProvider = new ActiveDataProvider(['query' => $model->findFamily()]);
         $activity = new ActiveDataProvider(['query' => \app\models\Activity::find()->where(['user_id' => Yii::$app->user->id])->orderBy(['id' => SORT_DESC])->limit(4), 'pagination' => false]);
         return $this->render('dashboard', ['dataProvider' => $DataProvider, 'activity' => $activity, 'events' => $events, 'journals' => $journals, 'photos' => $photos, 'wishlists' => $wishlists]);
     }
 }
Exemple #16
0
 public function getActivitiesByPicUserId($id)
 {
     return Activity::find()->where(['personInCharge' => $id])->asArray()->all();
 }
 /**
  * @return newsfeed generations array- DTR
  */
 public function getNews()
 {
     $user = Yii::$app->user->id;
     $notification = Notification::find()->where(['shared_id' => $user])->orderBy(['date' => SORT_DESC])->all();
     foreach ($notification as $news) {
         if ($news->type == 'event') {
             return Event::find()->where(['id' => $news->type_id]);
         } elseif ($news->type == 'activity') {
             return Activity::find()->where(['id' => $news->type_id]);
         } elseif ($news->type == 'journal') {
             return Journal::find()->where(['id' => $news->type_id]);
         } elseif ($news->type == 'wishlist') {
             return Wishlist::find()->where(['id' => $news->type_id]);
         } else {
             return Photos::find()->where(['id' => $news->type_id]);
         }
     }
 }
 /**
  * Finds the Activity model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Activity the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if ($model = Activity::find()->where(['id' => $id])->all()[0]) {
         //if ($model = Activity::find($id)->one()) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $act = Models\Activity::find($id);
     if ($act->delete()) {
         if (\DB::table('activity_associate')->where('activity_id', '=', $id)->delete()) {
             return redirect(action('Admin\\ActivityController@index'))->withErrors('删除成功');
         } else {
             return redirect(action('Admin\\ActivityController@index'))->withErrors('删除失败');
         }
     }
     return redirect(action('Admin\\ActivityController@index'));
 }
Exemple #20
0
<?php

use app\models\Activity;
?>
<ul class="timeline-list media-list">
    <?php 
$disViewMore = false;
$allActivities = Activity::find()->where(['belong_to' => $belong_to])->all();
// set value of $disViewMore
if (count($allActivities) > count($activities)) {
    $disViewMore = false;
} else {
    $disViewMore = true;
}
$i = 1;
if (!empty($activities)) {
    foreach ($activities as $key => $activity) {
        $i++;
        ?>
   
                <li class="<?php 
        echo $i % 2 == 0 ? 'active' : '';
        ?>
 media clearfix">
                    <div class="timeline-icon"><i class="fa fa-info"></i></div>
                    <div class="timeline-time">
                        <?php 
        if ($activity->reminder) {
            ?>
                            <i class="fa fa-bell"></i>
                        <?php 
 public function getActivityListByLevelId($levelId)
 {
     $query = Activity::find()->where(['level_id' => $levelId]);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count()]);
     $models = $query->offset($pages->offset)->limit($pages->limit)->all();
     if (!empty($models)) {
         foreach ($models as $key => $val) {
             $val->begin_time = date('Y-m-d', strtotime($val->begin_time));
             //录取人数
             $countResult = ActivityUsers::find()->where(['activity_id' => $val->id, 'status' => [ActivityUsers::APPROVED, ActivityUsers::DOING, ActivityUsers::END]]);
             $val->already_recruit_count = $countResult->count();
         }
     }
     return $models;
 }