Пример #1
0
 /**
  * Show all books.
  */
 public function actionList()
 {
     $criteria = new CDbCriteria();
     $criteria->with = 'author';
     $searchForm = new SearchForm();
     if (isset($_POST['SearchForm'])) {
         $searchForm->setAttributes($_POST['SearchForm']);
         $criteria = $searchForm->apllyFilter($criteria);
     }
     $pages = new CPagination(Books::model()->count());
     $pages->applyLimit($criteria);
     $sort = new CSort('Books');
     $sort->attributes = array('name', 'date', 'date_update', 'author' => array('asc' => 'author.lastname, author.firstname', 'desc' => 'author.lastname DESC, author.firstname DESC', 'label' => 'Автор'));
     $sort->defaultOrder = 'name';
     $sort->applyOrder($criteria);
     $books = Books::model()->findAll($criteria);
     $formWidget = $this->createWidget('FormWindow');
     $formWidget->afterClose = '$("#ui-datepicker-div").remove();$("#content").load("#");';
     $formWidget->run();
     $this->renderAjax('list', array('pages' => $pages, 'models' => $books, 'sort' => $sort, 'searchForm' => $searchForm));
 }