예제 #1
0
 public function GetGroupNames()
 {
     $criteria = new CDbCriteria();
     $criteria->distinct = true;
     $criteria->select = "name";
     $rows = AttrGroup::model()->findAll($criteria);
     $res = array();
     foreach ($rows as $row) {
         $res[] = $row->name;
     }
     return $res;
 }
예제 #2
0
<?php

$this->breadcrumbs = array('Управление характеристиками товаров');
$this->menu = array(array('label' => 'Добавить характеристики', 'url' => array('create')));
?>

<h1>Управление характеристиками товаров</h1>

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'attr-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('name', array('name' => 'category', 'type' => 'raw', 'filter' => CHtml::listData(Category::model()->findAll(), 'id', 'name'), 'value' => '$data->attrGroup->category->name'), array('name' => 'attr_group_id', 'type' => 'raw', 'value' => '$data->attrGroup->name', 'filter' => isset($_GET['Attr']['category']) ? CHtml::listData(AttrGroup::model()->findAll('category_id=' . $_GET['Attr']['category']), 'id', 'name') : CHtml::listData(AttrGroup::model()->findAll(), 'id', 'name')), array('name' => 'is_main', 'filter' => array('1' => 'Да', '0' => 'Нет'), 'value' => '$data->is_main == 1 ? "Да" : "Нет"', 'header' => 'в краткое описание'), array('name' => 'type', 'type' => 'raw', 'filter' => array('1' => 'string', '2' => 'boolean', '3' => 'integer'), 'value' => '$data->GetType()'), 'pos', array('name' => 'filter', 'filter' => array('1' => 'Да', '0' => 'Нет'), 'value' => '$data->filter == 1 ? "Да" : "Нет"', 'header' => 'в фильтр'), 'global_pos', 'template', array('class' => 'CButtonColumn'))));
예제 #3
0
    <div class="row">
        <?php 
CHtml::label('Category', 'category_id_select');
?>
    <?php 
echo CHtml::dropDownList('category_id', $model->isNewRecord ? '' : $model->attrGroup->category_id, Category::TreeArray(false), array('empty' => 'выберите категорию', 'encode' => false, 'onchange' => 'GetCategoryGroups(this.value, \'' . $this->createUrl('group/CategoryGroupsOptions') . '\')', 'id' => 'category_id_select'));
?>
    </div>

    <div class="row">
        <?php 
echo $form->labelEx($model, 'attr_group_id');
?>
    <?php 
echo $form->dropDownList($model, 'attr_group_id', $model->isNewRecord ? array() : CHtml::listData(AttrGroup::model()->findAll('category_id=' . $model->attrGroup->category_id), 'id', 'name'), array('onchange' => 'GetGroupAttributes(this.value);'));
?>
        <?php 
echo $form->error($model, 'attr_group_id');
?>
    </div>

    <div class="row">
        <?php 
echo $form->checkBox($model, 'is_main');
?>
        <?php 
echo $form->labelEx($model, 'is_main', array('class' => 'inline-label'));
?>
        <?php 
echo $form->error($model, 'is_main');
예제 #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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = AttrGroup::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
예제 #5
0
    <?php 
echo $form->dropDownList($model, 'category_id', Category::TreeArray(false), array('empty' => 'выберите категорию', 'encode' => false, 'ajax' => array('type' => 'POST', 'url' => $this->createUrl('group/CategoryGroupsList'), 'data' => 'js:{"cat_id":this.value}', 'cache' => false, 'success' => 'function(data){
                                        $("#cat-groups").html(data);
                                }')));
?>
        <?php 
echo $form->error($model, 'category_id');
?>
    </div>

    <div class="row">
        <?php 
echo $form->labelEx($model, 'name');
?>
    <?php 
$this->widget('zii.widgets.jui.CJuiAutoComplete', array('model' => $model, 'attribute' => 'name', 'name' => 'attr-group-name', 'source' => AttrGroup::GetGroupNames(), 'options' => array('minLength' => '1'), 'htmlOptions' => array('style' => 'width:400px;')));
?>
        <?php 
echo $form->error($model, 'name');
?>
    </div>

    <div class="row">
        <?php 
echo $form->labelEx($model, 'pos');
?>
        <?php 
echo $form->textField($model, 'pos', array('size' => 3, 'maxlength' => 3));
?>
        <?php 
echo $form->error($model, 'pos');