public function actionIndex()
 {
     $searchModel = new BooksSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     Url::remember();
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Example #2
0
 /**
  * Lists all Books models.
  * @return mixed
  */
 public function actionIndex()
 {
     Yii::$app->user->returnUrl = Yii::$app->request->absoluteUrl;
     $searchModel = new BooksSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Example #3
0
 /**
  * Lists all Books models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new BooksSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $dataProvider->pagination = ['pagesize' => 10];
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
 /**
  * Lists all Books models.
  * @return mixed
  */
 public function actionIndex()
 {
     $session = Yii::$app->session;
     $session->remove('redirect_param');
     $searchModel = new BooksSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Example #5
0
 public function actionIndex()
 {
     $searchModel = new BooksSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $searchModelAuthor = new AuthorsSearch();
     //$dataProviderAuthor = $searchModelAuthor->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'searchModelAuthor' => $searchModelAuthor]);
 }
 /**
  * Lists all Books models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new BooksSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     // Сохранение ссылки для возврата
     $session = new Session();
     $session->open();
     $session['urlParam'] = Yii::$app->request->queryString;
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
 /**
  * Lists all Books models.
  * @return mixed
  */
 public function actionIndex()
 {
     if (Yii::$app->user->isGuest) {
         Yii::$app->session->setFlash('alert', ['options' => ['class' => 'alert-danger'], 'body' => Yii::t('app', 'You are not authorized for this action.')]);
         return $this->redirect(Url::toRoute('/site/login'));
     }
     $searchModel = new BooksSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Example #8
0
 /**
  * Lists all Books models.
  * @return mixed
  */
 public function actionIndex()
 {
     $params = Yii::$app->request->queryParams;
     $session = Yii::$app->session;
     if (isset($params['BooksSearch'])) {
         $session->set('BooksSearch', $params['BooksSearch']);
     } elseif ($session->has('BooksSearch')) {
         return $this->redirect(['index', 'BooksSearch' => $session->get('BooksSearch')]);
     }
     $searchModel = new BooksSearch();
     $dataProvider = $searchModel->search($params);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Example #9
0
 public function actionBooksList()
 {
     $searchModel = new BooksSearch();
     if ($searchModel->load(Yii::$app->request->post())) {
         $searchModel->validate();
         Yii::$app->session->set('searchForm', Yii::$app->request->post());
     }
     if (Yii::$app->session->has('searchForm')) {
         $searchModel->load(Yii::$app->session->get('searchForm'));
     }
     $books = new ActiveDataProvider(['query' => $searchModel->search(), 'pagination' => ['pageSize' => 20], 'sort' => ['attributes' => [BooksSearch::FIELD_ID => ['asc' => [Books::FIELD_ID => SORT_ASC], 'desc' => [Books::FIELD_ID => SORT_DESC], 'default' => ''], BooksSearch::FIELD_NAME => ['asc' => [Books::FIELD_NAME => SORT_ASC], 'desc' => [Books::FIELD_NAME => SORT_DESC], 'default' => ''], BooksSearch::FIELD_FULL_AUTHOR_NAME => ['asc' => [Authors::FIELD_FIRSTNAME => SORT_ASC, Authors::FIELD_LASTNAME => SORT_ASC], 'desc' => [Authors::FIELD_FIRSTNAME => SORT_DESC, Authors::FIELD_LASTNAME => SORT_DESC], 'default' => ''], BooksSearch::FIELD_DATE => ['asc' => [Books::FIELD_DATE => SORT_ASC], 'desc' => [Books::FIELD_DATE => SORT_DESC], 'default' => ''], BooksSearch::FIELD_DATE_CREATE => ['asc' => [Books::FIELD_DATE_CREATE => SORT_ASC], 'desc' => [Books::FIELD_DATE_CREATE => SORT_DESC], 'default' => '']]]]);
     return $this->render('books_list', ['books' => $books, 'searchModel' => $searchModel]);
 }
Example #10
0
 /**
  * Lists all Books models.
  * @return mixed
  */
 public function actionIndex()
 {
     $session = Yii::$app->session;
     $session->open();
     $searchModel = new BooksSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $searchAuthModel = new AuthorsSearch();
     $authors = $searchAuthModel->getAuthors();
     Yii::$app->session['dataProvider'] = $dataProvider;
     Yii::$app->session['searchModel'] = $searchModel;
     Yii::$app->session['authors'] = $authors;
     if (!\Yii::$app->user->isGuest) {
         return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'authors' => $authors]);
     } else {
         return $this->goHome();
     }
     // Если не авторизован, то отправить на форму авторизации
 }
Example #11
0
 /**
  * Updates an existing Books model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate()
 {
     $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : '';
     $model = $this->findModel($id);
     $searchModel = new BooksSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     if ($model->load(Yii::$app->request->post()) && $model->upload()) {
         if ($model->save()) {
             return $this->success();
         } else {
             return $this->errors();
         }
     } else {
         return $this->renderAjax('update', ['authors' => Authors::find()->all(), 'model' => $model]);
     }
 }