/** * Lists all Note models. * @return mixed */ public function actionIndex() { $searchModel = new NoteSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider->getSort()->defaultOrder = ['updated_at' => SORT_DESC, 'created_at' => SORT_DESC]; return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }
public function actionNotes() { if (Yii::$app->user->can('viewAdminPanelNotes')) { $noteSearch = new NoteSearch(); $noteSearch->setScenario('admin'); $noteProvider = $noteSearch->search(Yii::$app->request->queryParams); return $this->render('notes', ['noteSearch' => $noteSearch, 'noteProvider' => $noteProvider]); } else { throw new ForbiddenHttpException(); } }
public function actionIndex($viewType = null) { if ($viewType) { Yii::$app->response->cookies->add(new Cookie(['name' => 'viewType', 'value' => $viewType])); } else { if ($cookie = Yii::$app->request->cookies->get('viewType')) { $viewType = $cookie->value; } else { $viewType = 'panel'; Yii::$app->response->cookies->add(new Cookie(['name' => 'viewType', 'value' => $viewType])); } } $noteSearch = new NoteSearch(); $noteSearch->setScenario('all'); $noteProvider = $noteSearch->search(Yii::$app->request->queryParams, ['visibility' => Note::VIS_PUBLIC_LISTED]); return $this->render('/notes', ['cur' => 'all', 'viewType' => $viewType, 'notes' => $noteProvider->getModels(), 'pagination' => $noteProvider->pagination, 'sort' => $noteProvider->sort, 'noteSearch' => $noteSearch]); }
public function actionHome($viewType = null) { if ($viewType) { Yii::$app->response->cookies->add(new Cookie(['name' => 'viewType', 'value' => $viewType])); } else { if ($cookie = Yii::$app->request->cookies->get('viewType')) { $viewType = $cookie->value; } else { $viewType = 'panel'; Yii::$app->response->cookies->add(new Cookie(['name' => 'viewType', 'value' => $viewType])); } } $query = Note::find(); $noteSearch = new NoteSearch(); $noteSearch->setScenario('own'); $noteProvider = $noteSearch->search(Yii::$app->request->queryParams, ['user_id' => Yii::$app->user->identity->id]); $curDate = getdate(); $beginOfCurDay = \DateTime::createFromFormat('Y-n-j H:i:s', $curDate['year'] . '-' . $curDate['mon'] . '-' . $curDate['mday'] . ' 00:00:00')->getTimestamp(); $beginOfCurMonth = \DateTime::createFromFormat('Y-n-j H:i:s', $curDate['year'] . '-' . $curDate['mon'] . '-1 00:00:00')->getTimestamp(); return $this->render('/notes', ['cur' => 'own', 'viewType' => $viewType, 'notes' => $noteProvider->getModels(), 'pagination' => $noteProvider->pagination, 'sort' => $noteProvider->sort, 'noteSearch' => $noteSearch, 'notesCountDay' => $query->where(['>=', 'created_at', $beginOfCurDay])->andWhere(['user_id' => Yii::$app->user->identity->id])->count(), 'notesCountMonth' => $query->where(['>=', 'created_at', $beginOfCurMonth])->andWhere(['user_id' => Yii::$app->user->identity->id])->count()]); }