コード例 #1
0
 public function loadModel($id)
 {
     if (($model = Author::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
コード例 #2
0
    /**
     * Displays a particular model.
     * @param integer $id the ID of the model to be displayed
     */
    public function actionView($id, $aBookId = null, $dBookId = null)
    {
        $authorsNames = [];
        $authors = Author::model()->findAllBySql('
		SELECT a.*
		FROM db_author AS a
		INNER JOIN db_authors_books AS ab
		ON ab.author_id = a.id
		WHERE ab.book_id = ' . $id);
        foreach ($authors as $author) {
            $authorsNames[] = $author['name'];
        }
        if (!Yii::app()->user->isGuest) {
            if ($aBookId) {
                $this->addFavorite($aBookId);
                $this->redirect($id, array('model' => $this->loadModel($id), 'isFavorite' => $this->isFavorite($id), 'author' => $authorsNames));
            } elseif ($dBookId) {
                $this->deleteFavorite($dBookId);
                $this->redirect($id, array('model' => $this->loadModel($id), 'isFavorite' => $this->isFavorite($id), 'author' => $authorsNames));
            } else {
                $this->render('view', array('model' => $this->loadModel($id), 'isFavorite' => $this->isFavorite($id), 'author' => $authorsNames));
            }
        } else {
            $this->render('view', array('model' => $this->loadModel($id), 'author' => $authorsNames));
        }
    }
コード例 #3
0
ファイル: SearchAction.php プロジェクト: vchimishuk/itquotes
 public function run()
 {
     $config = new CConfiguration(Yii::app()->basePath . '/config/pager.php');
     $form = new SearchForm();
     // If referrer is not our action delete search parameters from session.
     if (strpos(Yii::app()->request->urlReferrer, '/site/search') === false) {
         Yii::app()->session->remove('siteSearch');
     } else {
         if (!empty(Yii::app()->session['SearchForm'])) {
             $siteSearch = Yii::app()->session['SearchForm'];
             $form->text = $siteSearch['text'];
             $form->authorId = $siteSearch['authorId'];
         }
     }
     if (!empty($_POST['SearchForm']) && is_array($_POST['SearchForm'])) {
         $form->attributes = $_POST['SearchForm'];
         Yii::app()->session['SearchForm'] = array('text' => $form->text, 'authorId' => $form->authorId);
     }
     $criteria = new CDbCriteria();
     $criteria->order = 'approvedTime DESC';
     $criteria->condition = 'approvedTime AND (textRu LIKE :text OR textEn LIKE :text) ' . ($form->authorId ? 'AND (authorId LIKE :authorId)' : '');
     $criteria->params = array(':text' => "%{$form->text}%") + ($form->authorId ? array(':authorId' => $form->authorId) : array());
     $pages = new CPagination(Quote::model()->count($criteria));
     $config->applyTo($pages);
     $pages->applyLimit($criteria);
     $quotes = Quote::model()->with('tags')->findAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->order = 'name';
     $authors = Author::model()->findAll($criteria);
     $this->controller->render('search', array('quotes' => $quotes, 'pages' => $pages, 'form' => $form, 'authors' => $authors));
 }
コード例 #4
0
 public function actionPublisher()
 {
     if ($_POST) {
         //айди издателя
         $idPublisher = CHtml::encode($_POST['search-publishers']);
         $criteria = new CDbCriteria();
         // критерий поиска авторов
         $criteria->compare('publishing_id', $idPublisher);
         // собираем всех авторов
         $modelAuthors = Author::model()->findAll($criteria);
         // все айди авторов
         $arr = array();
         foreach ($modelAuthors as $item) {
             $arr[] = $item->id;
         }
         if ($arr) {
             $criteria = new CDbCriteria();
             $criteria->compare('author_id', $arr);
             $pages = new CPagination(Book::model()->count($criteria));
             $pages->pageSize = Options::getOption('PostOnPage');
             $pages->applyLimit($criteria);
             $model = Book::model()->findAll($criteria);
             $books = array();
             foreach ($model as $item) {
                 $books[] = Front::getBookAll($item->id);
             }
             $this->render('index', ['model' => $books, 'pages' => $pages]);
         } else {
             $this->render('index');
         }
     }
 }
コード例 #5
0
ファイル: ListAction.php プロジェクト: vchimishuk/itquotes
 public function run()
 {
     $session = Yii::app()->session;
     $config = new CConfiguration(Yii::app()->basePath . '/config/pager.php');
     $cookies = Yii::app()->request->cookies;
     // If referrer is not our controller delete search parameters from session.
     if (strpos(Yii::app()->request->urlReferrer, '/quote/list') === false) {
         unset($session['search']);
     }
     if (!empty($_POST['search']) && is_array($_POST['search'])) {
         $search = $_POST['search'];
         $session['search'] = $search;
     } else {
         if (!empty($session['search'])) {
             $search = $session['search'];
         } else {
             $search = array('text' => '', 'authorId' => 0, 'approved' => 'all');
         }
     }
     $criteria = new CDbCriteria();
     $criteria->condition = '(textRu LIKE :text OR textEn LIKE :text) ' . ($search['authorId'] ? 'AND authorId = :authorId ' : '') . ($search['approved'] == 'approved' ? 'AND approvedTime ' : '') . ($search['approved'] == 'unApproved' ? 'AND (approvedTime IS NULL OR approvedTime = 0) ' : '');
     $criteria->params = array(':text' => "%{$search['text']}%") + ($search['authorId'] ? array(':authorId' => $search['authorId']) : array());
     $criteria->order = 'Quote.id DESC';
     $pages = new CPagination(Quote::model()->count($criteria));
     $config->applyTo($pages);
     $pages->applyLimit($criteria);
     $quotes = Quote::model()->with('tags', 'author')->findAll($criteria);
     $showSearchForm = !empty($cookies['showSearchForm']) && $cookies['showSearchForm']->value ? true : false;
     $criteria = new CDbCriteria();
     $criteria->order = 'name';
     $authors = Author::model()->findAll($criteria);
     $this->controller->render('list', array('quotes' => $quotes, 'pages' => $pages, 'authors' => $authors, 'search' => $search, 'showSearchForm' => $showSearchForm));
 }
コード例 #6
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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Author::model()->findByAttributes(array('auth_id' => $id));
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #7
0
 public function run()
 {
     $module = Yii::app()->getModule('catalog');
     $counter1 = $module->counter1;
     $counter2 = Author::model()->published()->count();
     $counter3 = $module->counter3;
     $counter4 = $module->counter4;
     $this->render($this->view, array('counter1' => $counter1, 'counter2' => $counter2, 'counter3' => $counter3, 'counter4' => $counter4));
 }
コード例 #8
0
ファイル: DeleteAction.php プロジェクト: vchimishuk/itquotes
 public function run()
 {
     $id = !empty($_GET['id']) ? $_GET['id'] : 0;
     $author = Author::model()->findByPk($id);
     if ($author === null) {
         throw new CHttpException(404, 'Author not found');
     }
     $author->delete();
     Yii::app()->user->setFlash('generalMessage', 'Author was deleted successfully.');
     $this->controller->redirect(array('list'));
 }
コード例 #9
0
ファイル: SiteController.php プロジェクト: alex-bro/yiitest
 /**
  * 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]);
 }
コード例 #10
0
ファイル: AdminToolbox.php プロジェクト: vchimishuk/itquotes
 private function getStatistics()
 {
     $staistics = array();
     if ($this->controller->id == 'quote') {
         // Quotes total count.
         $staistics['totalCount'] = Quote::model()->count();
         // Get number of unapproved quotes.
         $criteria = new CDbCriteria();
         $criteria->condition = 'NOT approvedTime';
         $staistics['unapprovedCount'] = Quote::model()->count($criteria);
     } elseif ($this->controller->id == 'tag') {
         $staistics['totalCount'] = Tag::model()->count();
         $tags = Tag::model()->with('quotesCount')->findAll();
         // Delete tags with empty quotesCount (With PHP > 5.3 e can use closure here).
         // TODO: Rewrite this code for PHP 5.3 when it will be avaliable.
         function tagsFilter($tag)
         {
             return (bool) $tag->quotesCount;
         }
         $tags = array_filter($tags, 'tagsFilter');
         // Sort tags by their weights (quotesCount).
         function tagsSort($a, $b)
         {
             if ($a->quotesCount == $b->quotesCount) {
                 return 0;
             }
             return $a->quotesCount > $b->quotesCount ? -1 : 1;
         }
         usort($tags, 'tagsSort');
         $staistics['popularTags'] = array_slice($tags, 0, 10);
     } elseif ($this->controller->id == 'author') {
         $staistics['totalCount'] = Author::model()->count();
         $authors = Author::model()->with('quotesCount')->findAll();
         // Delete authors with empty quotesCount (With PHP > 5.3 e can use closure here).
         // TODO: Rewrite this code for PHP 5.3 when it will be avaliable.
         function authorsFilter($author)
         {
             return (bool) $author->quotesCount;
         }
         $authors = array_filter($authors, 'authorsFilter');
         // Sort tags by their weights (quotesCount).
         function authorsSort($a, $b)
         {
             if ($a->quotesCount == $b->quotesCount) {
                 return 0;
             }
             return $a->quotesCount > $b->quotesCount ? -1 : 1;
         }
         usort($authors, 'authorsSort');
         $staistics['popularAuthors'] = array_slice($authors, 0, 10);
     }
     return $staistics;
 }
コード例 #11
0
ファイル: ListAction.php プロジェクト: vchimishuk/itquotes
 public function run()
 {
     $config = new CConfiguration(Yii::app()->basePath . '/config/pager.php');
     $session = Yii::app()->session;
     $cookies = Yii::app()->request->cookies;
     $criteria = new CDbCriteria();
     $criteria->order = 'name';
     $pages = new CPagination(Author::model()->count($criteria));
     $config->applyTo($pages);
     $pages->applyLimit($criteria);
     $authors = Author::model()->with('quotesCount')->findAll($criteria);
     $this->controller->render('list', array('authors' => $authors, 'pages' => $pages));
 }
コード例 #12
0
ファイル: AuthorAction.php プロジェクト: vchimishuk/itquotes
 public function run()
 {
     $config = new CConfiguration(Yii::app()->basePath . '/config/pager.php');
     $author = Author::model()->findByPk($_GET['authorId']);
     if ($author === null) {
         throw new CHttpException(404, 'Author not found');
     }
     $criteria = new CDbCriteria();
     $criteria->condition = 'authorId = :authorId';
     $criteria->params = array(':authorId' => $author->id);
     $pages = new CPagination(Quote::model()->count($criteria));
     $config->applyTo($pages);
     $pages->applyLimit($criteria);
     $quotes = Quote::model()->findAll($criteria);
     $this->controller->render('author', array('author' => $author, 'quotes' => $quotes, 'pages' => $pages));
 }
コード例 #13
0
ファイル: EditAction.php プロジェクト: vchimishuk/itquotes
 public function run()
 {
     $id = !empty($_GET['id']) ? $_GET['id'] : 0;
     $author = Author::model()->findByPk($id);
     if ($author === null) {
         throw new CHttpException(404, 'Author not found');
     }
     if (!empty($_POST['Author']) && is_array($_POST['Author'])) {
         // Form was submitted.
         $author->attributes = $_POST['Author'];
         if ($author->save()) {
             Yii::app()->user->setFlash('generalMessage', 'Author was saved successfully.');
             $this->controller->redirect(array('list'));
         }
     }
     $this->controller->render('edit', array('author' => $author));
 }
コード例 #14
0
ファイル: Front.php プロジェクト: alex-bro/yiitest
 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;
 }
コード例 #15
0
ファイル: manage.php プロジェクト: akilraj1255/rajeshwari
</td>
<td align="center"><?php 
    echo Yii::t('library', 'Due Date');
    ?>
</td>
<td align="center"><?php 
    echo Yii::t('library', 'Is returned');
    ?>
</td>
</tr>

<?php 
    if ($book != NULL) {
        foreach ($book as $book_1) {
            $bookdetails = Book::model()->findByAttributes(array('id' => $book_1->book_id));
            $author = Author::model()->findByAttributes(array('auth_id' => $bookdetails->author));
            $publication = Publication::model()->findByAttributes(array('publication_id' => $bookdetails->publisher));
            ?>
<tr>

<td align="center"><?php 
            echo $student->last_name . ' ' . $student->first_name;
            ?>
</td>
<td align="center"><?php 
            echo $bookdetails->isbn;
            ?>
</td>
<td align="center"><?php 
            echo $bookdetails->title;
            ?>
コード例 #16
0
 public function actionInitAuthor()
 {
     $model = Author::model()->find('id=:author_id', array(':author_id' => (int) $_GET['id']));
     if ($model !== null) {
         echo CJSON::encode(array('id' => $model->id, 'text' => $model->author_name));
     }
 }
コード例 #17
0
ファイル: _form.php プロジェクト: jessesiu/GigaDBV3
        <?php 
echo CHtml::activeDropDownList($model, 'dataset_id', CHtml::listData(Util::getDois(), 'id', 'identifier'));
?>
		<?php 
echo $form->error($model, 'dataset_id');
?>
				</div>
	</div>

	<div class="control-group">
		<?php 
echo $form->labelEx($model, 'author_id', array('class' => 'control-label'));
?>
				<div class="controls">
        <?php 
echo CHtml::activeDropDownList($model, 'author_id', CHtml::listData(Author::model()->findAll(array('order' => 'surname')), 'id', 'fullAuthor'));
?>
		<?php 
echo $form->error($model, 'author_id');
?>
				</div>
	</div>

        <div class="control-group">
          <?php 
echo $form->labelEx($model, 'rank', array('class' => 'control-label'));
?>
          <div class="controls">
            <?php 
echo $form->textField($model, 'rank');
?>
コード例 #18
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 Author the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Author::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #19
0
 public function actionUpdateImage($id, $item_number_flag = '0')
 {
     if ($item_number_flag == '0') {
         $model = $this->loadModel($id);
     } else {
         $model = Item::model()->find('item_number=:item_number', array(':item_number' => $id));
     }
     $price_tiers = PriceTier::model()->getListPriceTierUpdate($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (Yii::app()->user->checkAccess('item.update')) {
         if (isset($_POST['Item'])) {
             $old_price = $model->unit_price;
             $model->attributes = $_POST['Item'];
             //$qty = isset($_POST['Item']['quantity']) ? $_POST['Item']['quantity'] : 0;
             //$model->quantity = $qty;  //A buggy was not noticed every update reset item to zero EM EUY
             $publisher_name = $_POST['Item']['publisher_id'];
             $category_name = $_POST['Item']['category_id'];
             $author_name = $_POST['Item']['author_id'];
             $publisher_id = Publisher::model()->savePublisher($publisher_name);
             if ($publisher_id !== null) {
                 $model->publisher_id = $publisher_id;
             }
             $author_id = Author::model()->saveAuthor($author_name);
             if ($author_id !== null) {
                 $model->author_id = $author_id;
             }
             $category_id = Category::model()->saveCategory($category_name);
             if ($category_id !== null) {
                 $model->category_id = $category_id;
             }
             if ($model->validate()) {
                 $transaction = Yii::app()->db->beginTransaction();
                 try {
                     if ($model->save()) {
                         if (isset($_POST['Item']['count_interval'])) {
                             Item::model()->saveItemCounSchedule($model->id);
                         }
                         ItemPriceTier::model()->saveItemPriceTier($model->id, $price_tiers);
                         // Product Price (retail price) history
                         ItemPrice::model()->saveItemPrice($model->id, $model->unit_price, $old_price);
                         $this->addImages($model);
                         $transaction->commit();
                         Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, 'Item Id : <strong>' . $model->name . '</strong> have been saved successfully!');
                         $this->redirect(array('admin'));
                     }
                 } catch (Exception $e) {
                     $transaction->rollback();
                     //print_r($e);
                     Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_WARNING, 'Oop something wrong : <strong>' . $e);
                 }
             }
         }
     } else {
         //throw new CHttpException(403, 'You are not authorized to perform this action');
         $this->redirect(array('site/ErrorException', 'err_no' => 403));
     }
     $this->render('update_image', array('model' => $model, 'price_tiers' => $price_tiers));
 }
コード例 #20
0
ファイル: view.php プロジェクト: akilraj1255/rajeshwari
<td align="center"><?php 
    echo Yii::t('library', 'Book Title');
    ?>
</td>
<td align="center"><?php 
    echo Yii::t('library', 'ISBN');
    ?>
</td>
<td align="center"><?php 
    echo Yii::t('library', 'Publication');
    ?>
</td>
</tr>
    <?php 
    foreach ($book as $book_1) {
        $author = Author::model()->findByAttributes(array('auth_id' => $model->auth_id));
        $sub = Subjects::model()->findByAttributes(array('id' => $book_1->subject));
        $publication = Publication::model()->findByAttributes(array('publication_id' => $book_1->publisher));
        ?>
        <tr>

<td align="center"><?php 
        echo $sub->name;
        ?>
</td>
<td align="center"><?php 
        echo $book_1->title;
        ?>
</td>
<td align="center"><?php 
        echo $book_1->isbn;
コード例 #21
0
ファイル: index.php プロジェクト: alex-bro/yiitest
    }
} 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));
}
?>
</div>
コード例 #22
0
 public function actionAutocomplete1()
 {
     if (isset($_GET['term'])) {
         $criteria = new CDbCriteria();
         $criteria->alias = "auth_name";
         //$criteria->condition = "title   like '%" . $_GET['term'] . "%'";
         $criteria->condition = 'author_name LIKE :match';
         $criteria->params = array(':match' => $_GET['term'] . '%');
         $userArray = Author::model()->findAll($criteria);
         $hotels = Author::model()->findAll($criteria);
         $return_array = array();
         foreach ($hotels as $hotel) {
             $return_array[] = array('label' => $hotel->author_name, 'value' => $hotel->author_name, 'id' => $hotel->auth_id);
         }
         echo CJSON::encode($return_array);
     }
 }
コード例 #23
0
 public function storeAuthor(&$datasetAuthor, &$id)
 {
     if (isset($_SESSION['dataset_id'])) {
         $dataset_id = $_SESSION['dataset_id'];
         $model->dataset_id = $dataset_id;
         $model = $datasetAuthor;
         //store author into table author
         $name = $datasetAuthor->author_name;
         $rank = $datasetAuthor->rank;
         //determine if the model is valid
         if (!$datasetAuthor->validate()) {
             return false;
         }
         //$author = Author::model()->findByAttributes(array('name' => $name, 'rank' => $rank));
         $author = Author::model()->findByCompleteName($name);
         if ($author != NULL) {
             $author_id = $author->id;
         } else {
             $author = new Author();
             $author->name = $name;
             //temporary
             $author->orcid = 1;
             $author->rank = $rank;
             if (!$author->save()) {
                 return false;
             }
             $author_id = $author->id;
         }
         $model->author_id = $author_id;
         $model->rank = $rank;
         if (!$model->save()) {
             Yii::app()->user->setFlash('keyword', 'Error: Author is not stored!');
             return false;
         }
         $id = $model->id;
         return true;
     }
     return false;
 }
コード例 #24
0
ファイル: Picture_1.php プロジェクト: kuzmina-mariya/gallery
 public function getAuthorList()
 {
     return CHtml::listData(Author::model()->findAll(), 'id', 'title');
 }
コード例 #25
0
ファイル: booksearch.php プロジェクト: akilraj1255/rajeshwari
                echo Yii::t('library', 'Total Copies');
                ?>
</td>
<td align="center"><?php 
                echo Yii::t('library', 'Book Position');
                ?>
</td>
<td align="center"><?php 
                echo Yii::t('library', 'Shelf No');
                ?>
</td>
</tr>
<?php 
                foreach ($list as $list_1) {
                    $sub = Subjects::model()->findByAttributes(array('id' => $list_1->subject));
                    $author = Author::model()->findByAttributes(array('auth_id' => $list_1->author));
                    $total_copies = $list_1->copy + $list_1->copy_taken;
                    ?>
<tr>
<td align="center"><?php 
                    echo $sub->name;
                    ?>
</td>
<td align="center"><?php 
                    echo $list_1->title;
                    ?>
</td>
<td align="center"><?php 
                    echo $list_1->isbn;
                    ?>
</td>
コード例 #26
0
 public function runPKSearch($i)
 {
     $author = $this->authors[array_rand($this->authors)];
     $author = Author::model()->findByPk($author->id);
     //        $this->em->clear();
 }
コード例 #27
0
ファイル: admin.php プロジェクト: soklux/bakou-pos-apsara
                &nbsp;&nbsp;

                <?php 
echo CHtml::activeCheckBox($model, 'item_archived', array('value' => 1, 'uncheckValue' => 0, 'checked' => $model->item_archived == 'false' ? false : true, 'onclick' => "\$.fn.yiiGridView.update('item-grid',{data:{archivedItem:\$(this).is(':checked')}});"));
?>
                Show archived/deleted Item
            </div>


            <!-- Flash message layouts.partial._flash_message -->
            <?php 
$this->renderPartial('//layouts/alert/_flash');
?>

            <?php 
$pageSizeDropDown = CHtml::dropDownList('pageSize', Yii::app()->user->getState('pageSize', Common::defaultPageSize()), Common::arrayFactory('page_size'), array('class' => 'change-pagesize', 'onchange' => "\$.fn.yiiGridView.update('item-grid',{data:{pageSize:\$(this).val()}});"));
?>

            <?php 
$this->widget('yiiwheels.widgets.grid.WhGridView', array('id' => 'item-grid', 'fixedHeader' => true, 'type' => TbHtml::GRID_TYPE_HOVER, 'template' => "{items}\n{summary}\n{pager}", 'summaryText' => 'Showing {start}-{end} of {count} entries ' . $pageSizeDropDown . ' rows per page', 'htmlOptions' => array('class' => 'table-responsive panel'), 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'item_number', 'value' => '$data->status=="1" ? $data->item_number : "<s class=\\"red\\">  $data->item_number </s>" ', 'filter' => '', 'type' => 'raw'), array('name' => 'name', 'value' => '$data->status=="1" ? CHtml::link($data->name, Yii::app()->createUrl("item/updateImage",array("id"=>$data->primaryKey))) : "<s class=\\"red\\">  $data->name </s>" ', 'type' => 'raw'), array('name' => 'author_id', 'value' => '$data->author_id==null? " " : $data->author->author_name', 'filter' => CHtml::listData(Author::model()->findAll(array('order' => 'author_name')), 'id', 'author_name')), array('name' => 'location', 'filter' => ''), array('name' => 'category_id', 'value' => '$data->category_id==null? " " : $data->category->name', 'filter' => CHtml::listData(Category::model()->findAll(array('order' => 'name')), 'id', 'name')), array('name' => 'quantity', 'filter' => '', 'headerHtmlOptions' => array('class' => 'hidden-480 hidden-xs hidden-md'), 'htmlOptions' => array('class' => 'hidden-480 hidden-xs hidden-md')), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '<div class="btn-group">{detail}{cost}{price}{delete}{undeleted}</div>', 'buttons' => array('detail' => array('click' => 'updateDialogOpen', 'label' => Yii::t('app', 'Stock'), 'url' => 'Yii::app()->createUrl("Inventory/admin", array("item_id"=>$data->id))', 'options' => array('data-toggle' => 'tooltip', 'data-update-dialog-title' => Yii::t('app', 'Stock History'), 'class' => 'btn btn-xs btn-pink', 'title' => Yii::t('app', 'Stock History')), 'visible' => '$data->status=="1"'), 'cost' => array('click' => 'updateDialogOpen', 'label' => Yii::t('app', 'Cost'), 'url' => 'Yii::app()->createUrl("Item/CostHistory", array("item_id"=>$data->id))', 'options' => array('data-update-dialog-title' => Yii::t('app', 'Cost History'), 'class' => 'btn btn-xs btn-info', 'title' => Yii::t('app', 'Cost History')), 'visible' => '$data->status=="1" && ( Yii::app()->user->checkAccess("item.create") || Yii::app()->user->checkAccess("item.update") )'), 'price' => array('click' => 'updateDialogOpen', 'label' => Yii::t('app', 'Price'), 'url' => 'Yii::app()->createUrl("Item/PriceHistory", array("item_id"=>$data->id))', 'options' => array('data-update-dialog-title' => Yii::t('app', 'Price History'), 'class' => 'btn btn-xs btn-success', 'title' => Yii::t('app', 'Price History')), 'visible' => '$data->status=="1" && ( Yii::app()->user->checkAccess("item.create") || Yii::app()->user->checkAccess("item.update") )'), 'delete' => array('label' => Yii::t('app', 'Delete'), 'icon' => 'bigger-120 glyphicon-trash', 'options' => array('class' => 'btn btn-xs btn-danger'), 'visible' => '$data->status=="1" && Yii::app()->user->checkAccess("item.delete")'), 'undeleted' => array('label' => Yii::t('app', 'Undo Delete'), 'url' => 'Yii::app()->createUrl("Item/UndoDelete", array("id"=>$data->id))', 'icon' => 'bigger-120 glyphicon-refresh', 'options' => array('class' => 'btn btn-xs btn-warning btn-undodelete', 'title' => Yii::t('app', 'Undo Delete')), 'visible' => '$data->status=="0" && Yii::app()->user->checkAccess("item.delete")'))))));
?>

        <?php 
$this->endWidget();
?>

    </div>
</div>

<?php 
$this->renderPartial('//layouts/admin/_footer', array('main_div_id' => 'item_cart', 'grid_id' => 'item-grid'));
コード例 #28
0
ファイル: EditAction.php プロジェクト: vchimishuk/itquotes
 public function run()
 {
     if ($this->id == 'edit') {
         $id = !empty($_GET['id']) ? $_GET['id'] : 0;
         $quote = Quote::model()->with('tags', 'author')->findByPk($id);
         if ($quote === null) {
             throw new CHttpException(404, 'Quote not found');
         }
     } else {
         // add action
         $quote = new Quote();
     }
     if (!$quote->author) {
         $quote->author = new Author();
     }
     if (!empty($_POST['Quote']) && is_array($_POST['Quote'])) {
         $quote->attributes = $_POST['Quote'];
         /*
          * Process approved time.
          */
         $approved = !empty($_POST['Quote']['approvedTime']);
         if (!$quote->approvedTime && $approved) {
             $quote->approvedTime = time();
         } elseif (!$approved) {
             $quote->approvedTime = 0;
         }
         /*
          * Process author.
          */
         if ($_POST['Quote']['authorId']) {
             // Existing author.
             $author = Author::model()->findByPk($_POST['Quote']['authorId']);
             if ($author === null) {
                 throw new CException("Author with \"{$_POST['Quote']['authorId']}\" not found.");
             }
         } else {
             // New author.
             $authorName = $_POST['Quote']['authorCustomName'];
             // At first try to find author with the same name.
             $criteria = new CDbCriteria();
             $criteria->condition = 'name = :name';
             $criteria->params = array(':name' => $authorName);
             $author = Author::model()->find($criteria);
             if ($author === null) {
                 $author = new Author();
                 $author->name = $authorName;
                 $author->save();
             }
         }
         $quote->authorId = $author->id;
         /*
          * Process tags.
          */
         if (!empty($_POST['tags']) && is_array($_POST['tags'])) {
             $tags = $_POST['tags'];
         } else {
             $tags = array();
         }
         $tagsObj = array();
         foreach ($tags as $tag) {
             $tagsObj[] = Tag::model()->findByPk($tag);
         }
         $quote->tags = $tagsObj;
         if ($quote->save()) {
             Yii::app()->user->setFlash('generalMessage', 'Quote was saved successfully.');
             $this->controller->redirect(array('list'));
         }
     }
     $criteria = new CDbCriteria();
     $criteria->order = 'name';
     $authors = Author::model()->findAll($criteria);
     $this->controller->render('edit', array('quote' => $quote, 'authors' => $authors));
 }
コード例 #29
0
 private function setAuthorList($dataset_id, $authors)
 {
     $temp = explode(";", $authors);
     foreach ($temp as $key => $value) {
         $value = trim($value);
         if (strlen($value) > 0) {
             $author = Author::model()->find("name=?", array($value));
             if (!$author) {
                 //  Author not found
                 $author = new Author();
                 $author->name = $value;
                 $author->orcid = "orcid";
                 $author->rank = 0;
                 $author->save(true);
             }
             $dataset_author = new DatasetAuthor();
             $dataset_author->dataset_id = $dataset_id;
             $dataset_author->author_id = $author->id;
             $dataset_author->save(true);
         }
     }
 }
コード例 #30
0
 public function saveAuthor($author_name)
 {
     $author_id = null;
     $exists = Author::model()->exists('id=:author_id', array(':author_id' => (int) $author_name));
     if (!$exists) {
         $author = new Author();
         $author->author_name = $author_name;
         $author->save();
         $author_id = $author->id;
     }
     return $author_id;
 }