public function actionIndex($model = null)
 {
     if (SiteModuleSettings::model()->find('site_module_id = 4 AND `status`=0')) {
         throw new CHttpException(404, 'The page can not be found.');
     }
     $data = array();
     $filters = '';
     $data['base_url'] = Pages::getBaseUrl(4);
     if (empty($model)) {
         $model = CatalogRubrics::getRoot();
     }
     //Титл и SEO
     $this->setSEOData($model);
     $criteria = new CDbCriteria();
     $criteria->condition = "parent_id = :parent_id AND status = 1";
     $criteria->params = array(":parent_id" => $model->id);
     $criteria->order = "order_id, id";
     $count = CatalogElements::model()->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 12;
     $pages->applyLimit($criteria);
     $data['elements'] = CatalogElements::model()->findAll($criteria);
     $data['pages'] = $pages;
     $data['catalogs'] = $this->getChaildCategory($model, 1);
     $data['model'] = $model;
     $this->render('index', $data);
 }
Beispiel #2
0
<?php 
echo CHtml::activeDropDownList($model, 'filterData', $catalog, array('class' => 'span5', 'encode' => false));
?>

<?php 
$assetsDir = Yii::app()->basePath;
$labels = CatalogElements::model()->attributeLabels();
$this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'productlist-grid', 'template' => "{items}\n{pager}", 'enableHistory' => true, 'htmlOptions' => array('class' => 'content_table'), 'dataProvider' => $provider, 'filter' => $model, 'columns' => array(array('class' => 'CCheckBoxColumn', 'selectableRows' => 2, 'checkBoxHtmlOptions' => array('class' => 'selectProduct')), array('header' => 'Картинка', 'name' => "image", 'type' => 'raw', 'value' => function ($dataProvider) {
    $url_img = '/images/nophoto_100_100.jpg';
    if (file_exists(YiiBase::getPathOfAlias('webroot') . '/../uploads/filestorage/catalog/elements/admin-' . $dataProvider->id . '.' . $dataProvider->image)) {
        $url_img = '/../uploads/filestorage/catalog/elements/admin-' . $dataProvider->id . '.' . $dataProvider->image;
    }
    return '<img src="' . $url_img . '" style="width:80px" />';
}, 'filter' => ''), array('header' => 'Наименование элемента', 'name' => "serch_name_code", 'type' => 'raw', 'value' => function ($dataProvider) {
    $result = '<a class="page_url" href="/' . Pages::getBaseUrl(4) . CatalogElements::model()->getProductUrl($dataProvider) . '" style="margin-left: 20px;" target="_preview">' . $dataProvider->name . '</a></BR>';
    return $result;
}, 'filter' => CHtml::textField('CatalogElements[serch_name_code]', '', array('style' => 'width:100%', 'placeholder' => 'Введите название'))), array('header' => 'Цена', 'name' => "price", 'type' => 'raw', 'value' => function ($data) {
    return CHtml::textField('price_' . $data->id, $data->price, array("class" => "price", "data-id" => $data->id, "data-price" => $data->price));
}, 'filter' => ''), array('header' => 'Порядок', 'name' => 'order_id', 'value' => function ($data) {
    return CHtml::textField('order_' . $data->id, $data->order_id, array("class" => "order", "data-id" => $data->id, "data-order" => $data->order_id));
}, 'type' => 'raw'), array('header' => 'Статус', 'name' => "status", 'type' => 'raw', 'value' => function ($data) {
    return '
                    <a href="#" class="on-off-product" data-id="' . $data->id . '" data-status="' . $data->status . '">
                        <div style="margin-left:20px; width: 13px; height: 13px; border-radius: 3px; background:' . ($data->status == 1 ? 'green' : 'red') . '"></div>
                    </a>
                ';
}, 'filter' => ''), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update_product}  {edit_chars}  {discount}  {delete_product}', 'buttons' => array('update_product' => array('label' => '', 'options' => array('data-toggle' => 'tooltip', 'class' => 'icon-pencil', 'title' => 'Редактировать'), 'url' => 'Yii::app()->createUrl("' . Yii::app()->controller->module->id . '/' . Yii::app()->controller->id . '/updateproduct", array("id"=>$data->id))'), 'edit_chars' => array('label' => '', 'options' => array('data-toggle' => 'tooltip', 'class' => 'icon-cog', 'title' => 'Редактировать свойства'), 'url' => 'Yii::app()->createUrl("' . Yii::app()->controller->module->id . '/' . Yii::app()->controller->id . '/listchars", array("id"=>$data->id, "type_parent"=>2))'), 'discount' => array('label' => '', 'options' => array('data-toggle' => 'tooltip', 'class' => 'icon-gift', 'title' => 'Скидки на товар'), 'url' => 'Yii::app()->createUrl("' . Yii::app()->controller->module->id . '/catalogelementsdiscount/index", array("CatalogElementsDiscount[element_id]"=>$data->id))'), 'delete_product' => array('label' => '', 'options' => array('data-toggle' => 'tooltip', 'class' => 'icon-trash', 'title' => 'Удалить'), 'url' => 'Yii::app()->createUrl("' . Yii::app()->controller->module->id . '/' . Yii::app()->controller->id . '/deleteproduct", array("id"=>$data->id))')), 'htmlOptions' => array('style' => 'white-space: nowrap')))));
?>

<div id="ajax_loader" style="display: none;"><img width="40px;" style="position:absolute; margin-top:10px; margin-left:-40px;" src="/images/admin/ajaxloader.gif"></div>