model() public static method

public static model ( null | string $className = __CLASS__ )
$className null | string
 public function actionDelete($ids)
 {
     $ids = explode(',', $ids);
     if (count($ids) > 0) {
         foreach ($ids as $id) {
             $attributeGroup = AttributeGroup::model()->findByPk($id);
             $attributeGroup->delete();
         }
     }
     $this->redirect(array('index'));
 }
 public function actionSort()
 {
     if (isset($_POST['items']) && is_array($_POST['items'])) {
         $i = 0;
         foreach ($_POST['items'] as $item) {
             $project = AttributeGroup::model()->findByPk($item);
             $project->sort_order = $i;
             $project->save();
             $i++;
         }
     }
 }
Esempio n. 3
0
 public function save()
 {
     $attributeGroup = AttributeGroup::model()->findByPk($this->id);
     if (is_null($attributeGroup)) {
         // is insert
         $attributeGroup = new AttributeGroup();
         $attributeGroup->sort_order = $this->sortOrder;
         $attributeGroup->save();
         $attributeDescription = new AttributeGroupDescription();
         $attributeDescription->attribute_group_id = $attributeGroup->attribute_group_id;
         $attributeDescription->language_id = 1;
         // TODO: read locale
         $attributeDescription->name = $this->name;
         $attributeDescription->save();
     } else {
         $attributeGroup->sort_order = $this->sortOrder;
         $attributeGroup->save();
         $attributeGroup->description->name = $this->name;
         $attributeGroup->description->save();
     }
 }
Esempio n. 4
0
        <?php 
echo $form->textFieldGroup($model, 'name');
?>
    </div>
</div>


<div class="row">
    <?php 
$tree = [];
$selectedAttributes = [];
$model->refresh();
foreach ($model->typeAttributes as $attribute) {
    $selectedAttributes[] = $attribute->id;
}
foreach ((array) AttributeGroup::model()->findAll() as $group) {
    $items = [];
    $groupHasNotSelectedAttribute = false;
    $groupItems = (array) $group->groupAttributes;
    foreach ($groupItems as $item) {
        $selected = in_array($item->id, $selectedAttributes);
        if (!$selected) {
            $groupHasNotSelectedAttribute = true;
        }
        $items[] = ['text' => CHtml::tag('div', ['class' => 'checkbox'], CHtml::label(CHtml::checkBox('attributes[]', $selected, ['value' => $item->id]) . $item->title, null))];
    }
    $tree[] = ['text' => CHtml::tag('div', ['class' => 'checkbox'], CHtml::label(CHtml::checkBox('', count($groupItems) && !$groupHasNotSelectedAttribute, ['class' => 'group-checkbox']) . $group->name, null)), 'children' => $items];
}
foreach ((array) Attribute::model()->findAllByAttributes(['group_id' => null]) as $attribute) {
    $tree[] = ['text' => CHtml::tag('div', ['class' => 'checkbox'], CHtml::label(CHtml::checkBox('attributes[]', in_array($attribute->id, $selectedAttributes), ['value' => $attribute->id]) . $attribute->title, null))];
}
Esempio n. 5
0
File: _form.php Progetto: yupe/yupe
</div>

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

<div class='row'>
    <div class="col-sm-4">
        <?php 
echo $form->dropDownListGroup($model, 'type', ['widgetOptions' => ['data' => $model->getTypesList(), 'htmlOptions' => ['empty' => '---', 'id' => 'attribute-type']]]);
?>
    </div>

    <div class="col-sm-4">
        <?php 
echo $form->dropDownListGroup($model, 'group_id', ['widgetOptions' => ['data' => AttributeGroup::model()->getFormattedList(), 'htmlOptions' => ['empty' => '---']]]);
?>
    </div>
</div>


<div class='row'>
    <div class="col-sm-4">
        <?php 
echo $form->textFieldGroup($model, 'title');
?>
    </div>
    <div class="col-sm-4">
        <?php 
echo $form->slugFieldGroup($model, 'name', ['sourceAttribute' => 'title']);
?>
Esempio n. 6
0
                                        $.fn.yiiGridView.update('attribute-group-grid');
                                    }
                                    else {
                                        console.log(data.data);
                                    }
                                }
                            });
                        }
                    });
                });

                function changeGroupFilter() {
                    if (!$('#attribute-group-grid').find('a.editable-open')[0]) {
                        $("#Attribute_group_id").val($.fn.yiiGridView.getSelection('attribute-group-grid')).trigger("change");
                    }
                }
            </script>
        </fieldset>
        <?php 
$attributeGroup = new AttributeGroup('search');
$attributeGroup->unsetAttributes();
$this->widget('yupe\\widgets\\CustomGridView', ['id' => 'attribute-group-grid', 'type' => 'condensed', 'dataProvider' => $attributeGroup->search(), 'template' => "{items}\n{multiaction}", 'hideHeader' => true, 'selectableRows' => 1, 'sortableRows' => true, 'sortableAjaxSave' => true, 'sortableAttribute' => 'position', 'sortableAction' => '/store/attributeBackend/sortable', 'actionsButtons' => ['clear' => CHtml::link(Yii::t("StoreModule.store", "Without a group"), '#', ['id' => 'clear-attribute-group-filter', 'class' => 'btn btn-sm btn-default']), 'add' => CHtml::link(Yii::t('YupeModule.yupe', 'Add'), '#', ['id' => 'add-attribute-group', 'class' => 'btn btn-sm btn-success pull-right'])], 'afterAjaxUpdate' => 'js:function(id, data){ changeGroupFilter(); }', 'columns' => [['name' => 'name', 'class' => 'bootstrap.widgets.TbEditableColumn', 'headerHtmlOptions' => ['style' => 'width:500px'], 'editable' => ['type' => 'text', 'url' => ['/store/attributeBackend/inlineEditGroup'], 'title' => Yii::t('StoreModule.store', 'Enter {field}', ['{field}' => mb_strtolower($attributeGroup->getAttributeLabel('name'))]), 'params' => [Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken], 'placement' => 'right']]]]);
?>
    </div>
    <div class="col-sm-8">
        <?php 
$this->widget('yupe\\widgets\\CustomGridView', ['id' => 'attribute-grid', 'type' => 'condensed', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => [['name' => 'group_id', 'value' => '$data->getGroupTitle()', 'filter' => CHtml::activeDropDownList($model, 'group_id', AttributeGroup::model()->getFormattedList(), ['empty' => '', 'class' => 'form-control'])], ['name' => 'name', 'type' => 'raw', 'value' => 'CHtml::link($data->name, array("/store/attributeBackend/update", "id" => $data->id))'], ['name' => 'title', 'type' => 'raw', 'value' => 'CHtml::link($data->title, array("/store/attributeBackend/update", "id" => $data->id))'], ['name' => 'type', 'type' => 'text', 'value' => '$data->getTypeTitle($data->type)', 'filter' => $model->getTypesList()], ['class' => 'yupe\\widgets\\CustomButtonColumn']]]);
?>
    </div>
</div>
Esempio n. 7
0
File: index.php Progetto: yupe/yupe
        </fieldset>
        <?php 
$this->widget('yupe\\widgets\\CustomGridView', ['id' => 'attributes-groups-grid', 'type' => 'condensed', 'dataProvider' => $attributeGroup->search(), 'template' => "{items}\n{multiaction}\n{pager}", 'hideHeader' => true, 'selectableRows' => 1, 'sortableRows' => true, 'sortableAjaxSave' => true, 'sortableAttribute' => 'position', 'sortableAction' => '/store/attributeBackend/sortable', 'actionsButtons' => ['add' => CHtml::link(Yii::t('YupeModule.yupe', 'Add'), '#', ['id' => 'add-attribute-group', 'class' => 'btn btn-sm btn-success pull-right'])], 'columns' => [['name' => 'name', 'class' => 'bootstrap.widgets.TbEditableColumn', 'headerHtmlOptions' => ['style' => 'width:500px'], 'editable' => ['type' => 'text', 'url' => ['/store/attributeBackend/inlineEditGroup'], 'title' => Yii::t('StoreModule.store', 'Enter {field}', ['{field}' => mb_strtolower($attributeGroup->getAttributeLabel('name'))]), 'params' => [Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken], 'placement' => 'right']]]]);
?>
    </div>
    <div class="col-sm-9">
        <?php 
$this->widget('yupe\\widgets\\CustomGridView', ['id' => 'attributes-grid', 'sortableRows' => true, 'sortableAjaxSave' => true, 'sortableAttribute' => 'sort', 'sortableAction' => '/store/attributeBackend/sortattr', 'type' => 'condensed', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => [['name' => 'title', 'type' => 'raw', 'value' => function ($data) {
    return CHtml::link($data->title, array("/store/attributeBackend/update", "id" => $data->id));
}], ['name' => 'name', 'type' => 'raw', 'value' => function ($data) {
    return CHtml::link($data->name, array("/store/attributeBackend/update", "id" => $data->id));
}], ['name' => 'type', 'type' => 'text', 'value' => function ($data) {
    return $data->getTypeTitle($data->type);
}, 'filter' => $model->getTypesList()], ['name' => 'group_id', 'value' => function ($data) {
    return $data->getGroupTitle();
}, 'filter' => CHtml::activeDropDownList($model, 'group_id', AttributeGroup::model()->getFormattedList(), ['empty' => '', 'class' => 'form-control'])], ['class' => 'yupe\\widgets\\EditableStatusColumn', 'name' => 'required', 'url' => $this->createUrl('/store/attributeBackend/inlineattr'), 'source' => $model->getYesNoList(), 'options' => [['class' => 'label-default'], ['class' => 'label-success']]], ['class' => 'yupe\\widgets\\EditableStatusColumn', 'name' => 'is_filter', 'url' => $this->createUrl('/store/attributeBackend/inlineattr'), 'source' => $model->getYesNoList(), 'options' => [['class' => 'label-default'], ['class' => 'label-success']]], ['class' => 'yupe\\widgets\\CustomButtonColumn', 'template' => '{update}{delete}']]]);
?>
    </div>
</div>

<script type="text/javascript">
    $(document).ready(function () {
        var $container = $('body');
        $container.on('click', '#add-attribute-group', function (e) {
            e.preventDefault();
            var name = prompt('<?php 
echo Yii::t("StoreModule.store", "Title");
?>
');
            if (name) {
                var data = {name: name};
Esempio n. 8
0
</legend>

        </fieldset>
        <?php 
$this->widget('yupe\\widgets\\CustomGridView', ['id' => 'attributes-groups-grid', 'type' => 'condensed', 'dataProvider' => $attributeGroup->search(), 'template' => "{items}\n{multiaction}\n{pager}", 'hideHeader' => true, 'selectableRows' => 1, 'sortableRows' => true, 'sortableAjaxSave' => true, 'sortableAttribute' => 'position', 'sortableAction' => '/store/attributeBackend/sortable', 'actionsButtons' => ['add' => CHtml::link(Yii::t('YupeModule.yupe', 'Add'), '#', ['id' => 'add-attribute-group', 'class' => 'btn btn-sm btn-success pull-right'])], 'columns' => [['name' => 'name', 'class' => 'bootstrap.widgets.TbEditableColumn', 'headerHtmlOptions' => ['style' => 'width:500px'], 'editable' => ['type' => 'text', 'url' => ['/store/attributeBackend/inlineEditGroup'], 'title' => Yii::t('StoreModule.store', 'Enter {field}', ['{field}' => mb_strtolower($attributeGroup->getAttributeLabel('name'))]), 'params' => [Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken], 'placement' => 'right']]]]);
?>
    </div>
    <div class="col-sm-9">
        <?php 
$this->widget('yupe\\widgets\\CustomGridView', ['id' => 'attributes-grid', 'sortableRows' => true, 'sortableAjaxSave' => true, 'sortableAttribute' => 'sort', 'sortableAction' => '/store/attributeBackend/sortattr', 'type' => 'condensed', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => [['name' => 'title', 'type' => 'raw', 'value' => function ($data) {
    return CHtml::link($data->title, array("/store/attributeBackend/update", "id" => $data->id));
}], ['name' => 'name', 'type' => 'raw', 'value' => function ($data) {
    return CHtml::link($data->name, array("/store/attributeBackend/update", "id" => $data->id));
}], ['name' => 'group_id', 'value' => function ($data) {
    return $data->getGroupTitle();
}, 'filter' => CHtml::activeDropDownList($model, 'group_id', AttributeGroup::model()->getFormattedList(), ['empty' => '', 'class' => 'form-control'])], ['name' => 'type', 'type' => 'text', 'value' => function ($data) {
    return $data->getTypeTitle($data->type);
}, 'filter' => $model->getTypesList()], ['class' => 'yupe\\widgets\\CustomButtonColumn', 'template' => '{update}{delete}']]]);
?>
    </div>
</div>

<script type="text/javascript">
    $(document).ready(function () {
        var $container = $('body');
        $container.on('click', '#add-attribute-group', function (e) {
            e.preventDefault();
            var name = prompt('<?php 
echo Yii::t("StoreModule.store", "Title");
?>
');
Esempio n. 9
0
echo $form->labelEx($description, 'name');
?>
		<?php 
echo $form->textField($description, 'name', array('size' => 60, 'maxlength' => 64));
?>
		<?php 
echo $form->error($description, 'name');
?>
	</div>
	
	<div class="row">
		<?php 
echo $form->labelEx($model, 'attribute_group_id');
?>
		<?php 
echo TbHtml::activeDropDownList($model, 'attribute_group_id', TbHtml::listData(AttributeGroup::model()->findAll(), 'id', function ($data) {
    return $data->getName();
}));
?>
		<?php 
echo $form->error($model, 'attribute_group_id');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'sort_order');
?>
		<?php 
echo $form->textField($model, 'sort_order');
?>