Ejemplo n.º 1
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $model = array();
     $model['publishers'] = count(Publishing::model()->findAll());
     $model['authors'] = count(Author::model()->findAll());
     $model['books'] = count(Book::model()->findAll());
     $model['pictures'] = count(Picture::model()->findAll());
     // renders the view file 'protected/views/site/index.php'
     // using the default layout 'protected/views/layouts/main.php'
     $this->render('index', ['model' => $model]);
 }
Ejemplo n.º 2
0
 public static function getBookAll($id)
 {
     $book = array();
     $modelBook = Book::model()->findByPk($id);
     $book['name'] = $modelBook->name;
     $book['date'] = $modelBook->date;
     $modelAuthor = Author::model()->findByPk($modelBook->author_id);
     $book['author'] = $modelAuthor->name;
     $modelPublisher = Publishing::model()->findByPk($modelAuthor->publishing_id);
     $book['publisher'] = $modelPublisher->name;
     $modelCategory = Category::model()->findByPk($modelBook->category_id);
     $book['category'] = $modelCategory->name;
     $criteria = new CDbCriteria();
     $criteria->compare('book_id', $modelBook->id);
     $bookPicture = Picture::model()->findAll($criteria);
     $book['pictures'] = array();
     foreach ($bookPicture as $pic) {
         $book['pictures'][] = $pic->image;
     }
     return $book;
 }
Ejemplo n.º 3
0
<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'author-form', 'enableAjaxValidation' => false));
?>

	<p class="note">Поля с  <span class="required">*</span> должны быть заполнены.</p>

	<?php 
echo $form->errorSummary($model);
?>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'publishing_id');
?>
		<?php 
echo $form->dropDownList($model, 'publishing_id', Publishing::getList('Publishing'));
?>
		<?php 
echo $form->error($model, 'publishing_id');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'name');
?>
		<?php 
echo $form->textField($model, 'name', array('size' => 60, 'maxlength' => 255));
?>
		<?php 
echo $form->error($model, 'name');
Ejemplo n.º 4
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Publishing the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Publishing::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Ejemplo n.º 5
0
    foreach ($model as $item) {
        $this->renderPartial('_item', ['item' => $item]);
    }
} else {
    $this->renderPartial('_empty');
}
?>
        </div>
        <div class="col-md-4 col-lg-3" id="blue">
            <div class="row">
                <div class="col-md-12">
                    <?php 
$this->renderPartial('_caregory', ['categories' => DefaultController::getCat()]);
?>
                    <?php 
$this->renderPartial('_publishers', ['publishers' => Publishing::model()->findAll()]);
?>
                    <?php 
$this->renderPartial('_author', ['author' => Author::model()->findAll()]);
?>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="container">
    <?php 
if (isset($model)) {
    $this->widget('CLinkPager', array('pages' => $pages));
}
?>