Exemplo n.º 1
0
 public function actionRubric($id = null, $new = null)
 {
     $rubric = Rubrics::model()->findByPk($id);
     // страница
     $page = Yii::app()->request->getParam('page');
     if (!$page && !is_numeric($page)) {
         $page = 1;
     }
     // кол-во товароа на странице
     $per_page = 10;
     $select = '*';
     $where = 'status=1';
     $params = array();
     if ($new) {
         $where .= ' and new=1';
     } else {
         $where .= ' and rubric_id IN (' . $rubric->getChildsId() . ')';
     }
     /* бренды */
     $brands = Brands::model()->findAll(array('condition' => 'status=1', 'order' => 'name'));
     $filterBrand = Yii::app()->request->getParam('b');
     if ($filterBrand > 0) {
         $where .= ' and brand_id=:brandId';
         $params[':brandId'] = $filterBrand;
         $filterBrand = Brands::model()->findByPk($filterBrand)->name;
     }
     $catalog = Catalog::model()->findAll(array('select' => $select, 'condition' => $where, 'params' => $params, 'order' => $sort, 'limit' => $per_page, 'offset' => ($page - 1) * $per_page));
     $cnt = Catalog::model()->count(array('condition' => $where, 'params' => $params));
     $pages = ceil($cnt / $per_page);
     $data = array('rubric' => $rubric, 'data' => $catalog, 'brands' => $brands, 'filterBrand' => $filterBrand, 'pages' => $pages, 'page' => $page, 'page_link' => '?' . Yii::app()->request->getQueryString(), 'pp' => $per_page);
     $this->render('/catalog/rubric', $data);
 }
Exemplo n.º 2
0
 public function actionSingle($id)
 {
     $brand = Brands::model()->findByPk($id);
     $sales = Sales::model()->findAll(array('condition' => 'status=1 and brand_id=:brandId and ((start=finish and start<=:now) OR :now between start and finish)', 'params' => array(':brandId' => $brand->id, ':now' => date('Y-m-d H:i:s'))));
     $data = array('brand' => $brand, 'sales' => $sales, 'title' => $brand->name);
     $this->render('single', $data);
 }
Exemplo n.º 3
0
 public function getBrandsArray()
 {
     $brands = Brands::model()->findAll(array('order' => 'name'));
     $array = array(0 => '-выберите-');
     foreach ($brands as $k => $v) {
         $array[$v->id] = $v->name;
     }
     return $array;
 }
Exemplo n.º 4
0
?>
				
				</div>
			</div>
			<br class="clear" />
		</div>
		
		<div class="row">
			<div class="label">
				<?php 
echo $form->labelEx($model, 'brand_id');
?>
			</div>
			<div class="field">
				<?php 
echo $form->dropDownList($model, 'brand_id', Brands::model()->getBrandsArray());
?>
				<?php 
echo $form->error($model, 'brand_id');
?>
			</div>
		</div>	

		<div class="row">
			<div class="col3">
				<div class="label">
					<?php 
echo $form->labelEx($model, 'sale');
?>
				</div>
				<div class="field">
Exemplo n.º 5
0
					<?php 
echo $form->error($model, 'logo_bg');
?>
				</div>
			</div>	
			<div class="clear"></div>
		</div>
		<div class="row">
			<div class="label">
				<?php 
echo $form->labelEx($model, 'categories_id');
?>
			</div>
			<div class="field checkbox_list">
				<?php 
echo CHtml::checkBoxList('Categories[]', explode(',', $model->categories_id), Brands::model()->getCategoriesArray(), array('separator' => ' ', 'template' => '<span class="item">{input} {label}</span>'));
?>
				<?php 
echo $form->error($model, 'categories_id');
?>
			</div>		
		</div>	
		<div class="row">
			<div class="label">
				<?php 
echo $form->labelEx($model, 'text');
?>
			</div>
			<div class="field">
				<?php 
$this->widget('application.extensions.tinymce.ETinyMce', array('name' => get_class($model) . '[text]', 'value' => $model->getAttribute('text'), 'height' => '300px'));
Exemplo n.º 6
0
    /**
     * Get active/applied filters to make easier to cancel them.
     */
    public function getActiveFilters($rootcat='goods')
    {
        // Render links to cancel applied filters like prices, manufacturers, attributes.
        $menuItems = array();
                
                
                   $url = explode(';', Yii::app()->request->getQuery('url'));
                   
                   $criteria=new CDbCriteria;
                    $criteria->addInCondition('t.url', $url);
                    $criteria->order = 't.name';
                    $categ = Categories::model()->findAll($criteria);
                
                
        
                
        $manufacturers = array_filter(explode(';', Yii::app()->request->getQuery('brand')));
        $manufacturers = Brands::model()->findAllByPk($manufacturers);
        $accounts = array_filter(explode(';', Yii::app()->request->getQuery('account')));
        $accounts = User::model()->findAllByPk($accounts);
        $shops = array_filter(explode(';', Yii::app()->request->getQuery('shop')));
        $shops = Shops::model()->findAllByPk($shops);    

                if(!empty($categ))
        {
                    
            
                        
                    foreach($categ as $category)
            {
                        
                               if($category->url != 'goods' && $category->url != 'services' && $category->url != 'all'){
                               array_push($menuItems, array(
                                        'mode'=>'category',
                                        'label'=> $category->name,
                                        'url'  => Yii::app()->request->removeUrlParamCat($rootcat, $category->url),
                                        'titlecat'=>$category->url


                                   
                ));
                                }
            }
        }
                if(!empty($manufacturers))
        {
                    
            foreach($manufacturers as $manufacturer)
            {
                array_push($menuItems, array(
                                        'mode'=>'brand',
                    'label'=> $manufacturer->title,
                    'url'  => Yii::app()->request->removeUrlParam('/store/catalog/view', 'brand', $manufacturer->id)
                ));
            }
        }
        
        // Process eav attributes
        $activeAttributes = $this->getOwner()->activeAttributes;
        if(!empty($activeAttributes))
        {
            foreach($activeAttributes as $attributeName=>$value)
            {
                if(isset($this->getOwner()->eavAttributes[$attributeName]))
                {
                    $attribute = $this->getOwner()->eavAttributes[$attributeName];
                                        
                    foreach($attribute->options as $option)
                    {
                                            
                        if(isset($activeAttributes[$attribute->name]) && in_array($option->id, $activeAttributes[$attribute->name]))
                        {
                            array_push($menuItems, array(
                                                                'mode'=>'attributes',
                                                                'submode'=>$attribute->name,
                                'label'=> $option->value,
                                'url'  => Yii::app()->request->removeUrlParam('/store/catalog/view', $attribute->name, $option->id)
                            ));
                        }
                    }
                }
            }
        }
                if(Yii::app()->request->getQuery('min_price'))
        {
            array_push($menuItems, array(
                                'mode'=>'minprice',
                'label'=> Yii::t('StoreModule.core', 'от {minPrice} {c}', array('{minPrice}'=>(int)$this->getCurrentMinPrice(), '{c}'=>Yii::app()->currency->active->symbol)),
                'url'  => Yii::app()->request->removeUrlParam('/store/catalog/view', 'min_price')
            ));
        }

        if(Yii::app()->request->getQuery('max_price'))
        {
            array_push($menuItems, array(
                                'mode'=>'maxprice',
                'label'=> Yii::t('StoreModule.core', 'до {maxPrice} {c}', array('{maxPrice}'=>(int)$this->getCurrentMaxPrice(), '{c}'=>Yii::app()->currency->active->symbol)),
                'url'  => Yii::app()->request->removeUrlParam('/store/catalog/view', 'max_price')
            ));
        }

        if(!empty($accounts))
        {
                    
            foreach($accounts as $account)
            {
                array_push($menuItems, array(
                    'mode'=>'account',
                    'label'=> $account->username,
                    'url'  => Yii::app()->request->removeUrlParam('/store/catalog/view', 'account', $account->id)
                ));
            }
        } 
                if(!empty($shops)) {
                    
            foreach($shops as $shop)
            {
                array_push($menuItems, array(
                    'mode'=>'shop',
                    'label'=> $shop->title,
                    'url'  => Yii::app()->request->removeUrlParam('/store/catalog/view', 'shop', $shop->id)
                ));
            }
        }
                
        return $menuItems;
    }
Exemplo n.º 7
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 Brands the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Brands::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemplo n.º 8
0
 public function actionSearch()
 {
     // страница
     $page = Yii::app()->request->getParam('page');
     if (!$page && !is_numeric($page)) {
         $page = 1;
     }
     $per_page = 10;
     // ключевое слово
     $select = '*';
     $where = '1';
     $string = Yii::app()->request->getParam('string');
     $string = strip_tags($string);
     if (isset($_GET['string'])) {
         if ($string) {
             $select .= ', MATCH(name) AGAINST (:string) as description';
             $where .= " and (MATCH(name) AGAINST(:string) > 5 OR name like '%" . $string . "%' OR art like '%" . $string . "%')";
             $params[':string'] = $string;
             $rubric = new Rubrics();
             $rubric->parent_id = -1;
             $rubric->name = $string;
         } else {
             Yii::app()->user->setFlash('no_search_string', 'Задана пустая строка. Введите поисковую фразу.');
         }
     }
     /* бренды */
     $brands = Brands::model()->findAll(array('condition' => 'status=1', 'order' => 'name'));
     $filterBrand = Yii::app()->request->getParam('b');
     if ($filterBrand > 0) {
         $where .= ' and brand_id=:brandId';
         $params[':brandId'] = $filterBrand;
         $filterBrand = Brands::model()->findByPk($filterBrand)->name;
     }
     if (!$rubric) {
         $rubric = new Rubrics();
         $rubric->parent_id = 1;
         $rubric->name = $filterBrand;
     }
     /* производитель аксессуаров */
     $accessories = Accessories::model()->findAll(array('condition' => 'status=1', 'order' => 'name'));
     $filterAccessories = Yii::app()->request->getParam('a');
     if ($filterAccessories > 0) {
         $where .= ' and accessories_id=:accessoriesId';
         $params[':accessoriesId'] = $filterAccessories;
         $filterAccessories = Accessories::model()->findByPk($filterAccessories)->name;
     }
     if (!$rubric) {
         $rubric = new Rubrics();
         $rubric->parent_id = 1;
         $rubric->name = $filterAccessories;
     }
     $catalog = Catalog::model()->findAll(array('select' => $select, 'condition' => $where, 'params' => $params, 'order' => $sort, 'limit' => $per_page, 'offset' => ($page - 1) * $per_page));
     $cnt = Catalog::model()->count(array('condition' => $where, 'params' => $params));
     $pages = ceil($cnt / $per_page);
     $data = array('rubric' => $rubric, 'data' => $catalog, 'brands' => $brands, 'accessories' => $accessories, 'pages' => $pages, 'page' => $page, 'page_link' => '?' . Yii::app()->request->getQueryString(), 'pp' => $per_page);
     $this->render('/catalog/rubric', $data);
 }
Exemplo n.º 9
0
	<span><?php 
echo $rubric->name;
?>
</span>
	<?php 
echo CHtml::link('Свойства', '#', array('class' => 'btn right cancel', 'onclick' => '$("#rubric_propeties").toggle();return false;'));
?>
		
	<?php 
echo CHtml::link('Вводный текст', '#', array('class' => 'btn right cancel', 'onclick' => '$("#rubric_text").toggle();return false;'));
?>
	<?php 
echo CHtml::link('Создать', $rubric->getLink() . 'add', array('class' => 'btn right'));
?>
</div>

<div id="rubric_text" class="none">
	<?php 
echo $this->renderPartial('/text/_form', array('rubric' => $rubric, 'text' => $text));
?>
</div>

<div id="rubric_propeties" class="none">
	<?php 
echo $this->renderPartial('/rubrics/_propeties', array('rubric' => $rubric));
?>
</div>

<?php 
$this->widget('zii.widgets.grid.CGridView', array('template' => '{summary} {pager} {items} {pager}', 'id' => 'data-grid', 'dataProvider' => $model->search(), 'pager' => array('class' => 'CLinkPager', 'firstPageLabel' => 'Первая', 'prevPageLabel' => 'Предыдущая', 'nextPageLabel' => 'Следующая', 'lastPageLabel' => 'В конец', 'header' => '<b>Страницы: </b>'), 'summaryText' => 'Показано {start} - {end} позиций. Всего найдено <b>{count}</b> записей', 'filter' => $model, 'columns' => array('id', array('name' => 'finish', 'type' => 'html', 'header' => 'Сроки', 'value' => '$data->start."<br /><br />".$data->finish'), 'name', 'announce', array('name' => 'brand_id', 'type' => 'html', 'value' => '"<img src=\'/userdata/brands/brands_".$data->brand->id."/thumb_s/".$data->brand->logo."\' />"', 'htmlOptions' => array('align' => 'center'), 'filter' => Brands::model()->getBrandsArray()), array('class' => 'EImageColumn', 'name' => 'image', 'parent_id' => 'id', 'pathPrefix' => '/userdata/sales/sales_', 'pathThumb' => '/thumb_s/', 'link' => true, 'htmlOptions' => array('align' => 'center', 'width' => 100)), array('name' => 'status', 'filter' => $this->defaultStatus, 'value' => 'Yii::app()->controller->getRuStatus($data->status)'), array('class' => 'CButtonColumn', 'updateButtonLabel' => 'Изменить', 'updateButtonUrl' => '"update/".$data->primaryKey."/?".Yii::app()->request->queryString', 'deleteButtonLabel' => 'Удалить', 'deleteButtonUrl' => '"delete/".$data->primaryKey."/?".Yii::app()->request->queryString'))));
Exemplo n.º 10
0
 public function actionDelete($id)
 {
     $brand = Brands::model()->findByPk($bid);
     $model = Addresses::model()->findByPk($id)->delete();
     if (!Yii::app()->request->isAjaxRequest) {
         $this->redirect('/admin/brands/' . $bid . '/addresses/');
     }
 }