model() public static method

Returns the static model of the specified AR class.
public static model ( string $className = __CLASS__ ) : StoreCategory
$className string
return StoreCategory the static model class
 public function run($args)
 {
     mb_internal_encoding("UTF-8");
     mb_regex_encoding("UTF-8");
     Yii::app()->setImport(['application.modules.store.models.*']);
     $models = StoreCategory::model()->findAll();
     foreach ($models as $model) {
         $res = preg_replace('/\\s\\s+/', ' ', $model->name_ru);
         if ($res !== FALSE) {
             if (mb_strlen($res) !== mb_strlen($model->name_ru)) {
                 $model->name_ru = $res;
                 $model->update(['name_ru']);
                 print_r($model->id . ' ');
             }
         }
     }
     Yii::import('application.components.spreadsheetReader.SpreadsheetReader');
     $reader = new SpreadsheetReader(Yii::getPathOfAlias('application.components.spreadsheetReader.translates') . '/' . 'site_store_category.ods');
     foreach ($reader as $row) {
         if ($row[0] != 'id') {
             $res = Yii::app()->db->createCommand('
                 UPDATE `site_store_category` SET `name_en`= :row2, `name_zh_cn`= :row3, `name_zh_tw`= :row4 WHERE  `name_ru`= :row1;
             ')->execute([':row1' => $row[1], ':row2' => $row[2], ':row3' => $row[3], ':row4' => $row[4]]);
             print_r($res . ' ' . $row[2] . ' ');
         }
     }
 }
 /**
  * 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 = StoreCategory::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #3
0
 public function catename($data, $row)
 {
     $cate = StoreCategory::model()->findByAttributes(array('ca_id' => $data->c_id));
     if ($cate != NULL) {
         return ucfirst($cate->ca_name);
     } else {
         return '-';
     }
 }
Example #4
0
 /**
  * @param $path
  * @throws CHttpException
  */
 public function actionView($path)
 {
     $category = StoreCategory::model()->published()->findByPath($path);
     if (null === $category) {
         throw new CHttpException(404);
     }
     $data = Yii::app()->getRequest()->getQueryString() ? $this->productRepository->getByFilter($this->attributeFilter->getMainAttributesForSearchFromQuery(Yii::app()->getRequest(), [AttributeFilter::MAIN_SEARCH_PARAM_CATEGORY => [$category->id]]), $this->attributeFilter->getTypeAttributesForSearchFromQuery(Yii::app()->getRequest())) : $this->productRepository->getListForCategory($category);
     $this->render('view', ['dataProvider' => $data, 'category' => $category]);
 }
Example #5
0
 public function actionSearch()
 {
     if (Yii::app()->getRequest()->getQuery('SearchForm')) {
         $form = new SearchForm();
         $form->setAttributes(Yii::app()->getRequest()->getQuery('SearchForm'));
         if ($form->validate()) {
             $category = $form->category ? StoreCategory::model()->findByPk($form->category) : null;
             $this->render('search', ['category' => $category, 'searchForm' => $form, 'dataProvider' => $this->productRepository->search($form->q, $form->category)]);
         }
     }
 }
 public function run()
 {
     $data = StoreCategory::model()->getMenuList(10);
     echo CHtml::openTag('div', ['id' => $this->id]);
     echo CHtml::openTag('ul');
     $this->createHtmlTree($data);
     echo CHtml::closeTag('ul');
     echo CHtml::closeTag('div');
     $options = CJavaScript::encode($this->options);
     Yii::app()->clientScript->registerScript('JsTreeScript', "\n\t\t\t\$('#{$this->id}').jstree({$options});\n\t\t");
 }
 public function run($args)
 {
     Yii::app()->setImport(['application.modules.store.models.*']);
     $db = \Yii::app()->db;
     $dump_category = $db->createCommand()->select('t1.id')->from('site_store_category t1')->leftJoin('site_store_category t2', 't1.id = t2.parent_id')->where('t2.id IS NULL')->queryColumn();
     foreach ($dump_category as $category_id) {
         $category = StoreCategory::model()->findByPk($category_id);
         $category->updateFilterData();
     }
     echo 'End';
 }
 public function actionSearch()
 {
     if (!Yii::app()->getRequest()->getQuery('SearchForm')) {
         throw new CHttpException(404);
     }
     $form = new SearchForm();
     $form->setAttributes(Yii::app()->getRequest()->getQuery('SearchForm'));
     if ($form->validate()) {
         $category = $form->category ? StoreCategory::model()->findByPk($form->category) : null;
         $this->render('search', ['category' => $category, 'searchForm' => $form, 'dataProvider' => $this->productRepository->getByFilter($this->attributeFilter->getMainAttributesForSearchFromQuery(Yii::app()->getRequest(), [AttributeFilter::MAIN_SEARCH_PARAM_NAME => $form->q]), $this->attributeFilter->getEavAttributesForSearchFromQuery(Yii::app()->getRequest()))]);
     }
 }
Example #9
0
 private function getCategoriesElement()
 {
     $models = StoreCategory::model()->findAll();
     $res = '';
     $res .= CHtml::openTag('categories');
     /* @var $models StoreCategory[] */
     foreach ($models as $model) {
         $res .= CHtml::tag('category', ['id' => $model->id, 'parentId' => $model->parent_id], $model->name);
     }
     $res .= CHtml::closeTag('categories');
     return $res;
 }
Example #10
0
 public function testLanguageLoad()
 {
     Yii::app()->languageManager->setActive('en');
     $model = StoreCategory::model()->findByPk(1);
     $name = 'root_' . time();
     $model->name = $name;
     $model->saveNode();
     $this->assertTrue($model instanceof StoreCategory);
     $this->assertEquals($model->name, $name);
     Yii::app()->languageManager->setActive('ru');
     $model = StoreCategory::model()->findByPk(1);
     $this->assertEquals($model->name, 'root');
 }
 public function up()
 {
     mb_internal_encoding("UTF-8");
     mb_regex_encoding("UTF-8");
     Yii::app()->setImport(['application.modules.store.models.*']);
     $models = StoreCategory::model()->findAll();
     foreach ($models as $model) {
         //$res = mb_ereg_replace('/\s\s+/', ' ', $model->name_ru);
         $res = preg_replace('/\\s\\s+/', ' ', $model->name_ru);
         if ($res !== FALSE) {
             $model->name_ru = $res;
             $model->update(['name_ru']);
         }
     }
 }
Example #12
0
 /**
  * @param $id
  * @throws CHttpException
  */
 public function actionDelete($id)
 {
     if (Yii::app()->request->isPostRequest) {
         $model = StoreCategory::model()->findByPk($id);
         //Delete if not root node
         if ($model && $model->id != 1) {
             foreach ($model->descendants()->findAll() as $subCategory) {
                 $subCategory->deleteNode();
             }
             $model->deleteNode();
         }
         if (!Yii::app()->request->isAjaxRequest) {
             $this->redirect('create');
         }
     }
 }
 public function actionUpdate($id)
 {
     $breadcrumb = [];
     if (isset($_POST['StoreCategory'])) {
         \StoreCategory::model()->updateByPk($_POST['StoreCategory']['id'], ['name_ru' => $_POST['StoreCategory']['name_ru']]);
         $this->redirect(array('index'));
     }
     $model = \StoreCategory::model()->findByPk($id);
     $StoreCategory = \StoreCategory::model()->findByPk($id);
     $breadcrumb[] = ['url' => $StoreCategory->id, 'name' => $StoreCategory->name];
     while ($StoreCategory->parent_id != null) {
         $StoreCategory = \StoreCategory::model()->findByPk($StoreCategory->parent_id);
         $breadcrumb[] = ['url' => $StoreCategory->id, 'name' => $StoreCategory->name];
     }
     $this->render('update', ['model' => $model, 'breadcrumb' => $breadcrumb]);
     // $this->redirect('index');
 }
 /**
  * @param array $mainSearchAttributes
  * @param array $typeSearchAttributes
  * @return CActiveDataProvider
  */
 public function getByFilter(array $mainSearchAttributes, array $typeSearchAttributes)
 {
     $criteria = new CDbCriteria();
     $criteria->select = 't.*';
     $criteria->params = [];
     $criteria->addCondition('t.status = :status');
     $criteria->params['status'] = Product::STATUS_ACTIVE;
     $criteria->distinct = true;
     //поиск по категории, производителю и цене
     foreach ($this->attributeFilter->getMainSearchParams() as $param => $field) {
         if (empty($mainSearchAttributes[$param])) {
             continue;
         }
         if ($param === 'category') {
             $categories = [];
             foreach ($mainSearchAttributes[$param] as $categoryId) {
                 $categories[] = $categoryId;
                 $categories = CMap::mergeArray($categories, StoreCategory::model()->getChildsArray($categoryId));
             }
             $criteria->with = ['categoryRelation' => ['together' => true]];
             $criteria->addInCondition('categoryRelation.category_id', array_unique($categories));
             $criteria->addInCondition('t.category_id', array_unique($categories), 'OR');
             $criteria->group = 't.id';
             continue;
         }
         if (isset($mainSearchAttributes[$param]['from'], $mainSearchAttributes[$param]['to'])) {
             $criteria->addBetweenCondition("t." . $field, $mainSearchAttributes[$param]['from'], $mainSearchAttributes[$param]['to']);
         } elseif (isset($mainSearchAttributes[$param]['from']) && !isset($mainSearchAttributes[$param]['to'])) {
             $criteria->addCondition("t.{$field} >= :attr_{$field}");
             $criteria->params[":attr_{$field}"] = $mainSearchAttributes[$param]['from'];
         } elseif (isset($mainSearchAttributes[$param]['to']) && !isset($mainSearchAttributes[$param]['from'])) {
             $criteria->addCondition("t.{$field} <= :attr_{$field}");
             $criteria->params[":attr_{$field}"] = $mainSearchAttributes[$param]['to'];
         } else {
             $criteria->addInCondition("t." . $field, $mainSearchAttributes[$param]);
         }
     }
     //поиск по названию и артикулу
     if (!empty($mainSearchAttributes[AttributeFilter::MAIN_SEARCH_PARAM_NAME])) {
         $criteria->addSearchCondition('name', $mainSearchAttributes[AttributeFilter::MAIN_SEARCH_PARAM_NAME], true);
         $criteria->addSearchCondition('sku', $mainSearchAttributes[AttributeFilter::MAIN_SEARCH_PARAM_NAME], true, 'OR');
     }
     $criteria->mergeWith($this->buildCriteriaForTypeAttributes($typeSearchAttributes));
     return new CActiveDataProvider('Product', ['criteria' => $criteria, 'pagination' => ['pageSize' => (int) Yii::app()->getModule('store')->itemsPerPage, 'pageVar' => 'page'], 'sort' => ['sortVar' => 'sort', 'defaultOrder' => 't.position']]);
 }
 public function actionView($id)
 {
     $model = Export::model()->findByPk($id);
     if (false === $model) {
         throw new CHttpException(404);
     }
     $criteria = new CDbCriteria();
     $criteria->compare('t.status', Product::STATUS_ACTIVE);
     if (!empty($model->categories)) {
         $criteria->addInCondition('t.category_id', (array) $model->categories);
     }
     if (!empty($model->brands)) {
         $criteria->addInCondition('t.producer_id', (array) $model->brands);
     }
     $dataProvider = new CActiveDataProvider('Product', ['criteria' => $criteria]);
     $offers = new CDataProviderIterator($dataProvider, 100);
     ContentType::setHeader(ContentType::TYPE_XML);
     $this->renderPartial('view', ['model' => $model, 'currencies' => Yii::app()->getModule('store')->getCurrencyList(), 'categories' => StoreCategory::model()->published()->findAll(), 'offers' => $offers]);
 }
Example #16
0
 /**
  * Generate store category tree
  *
  * @param string $order
  *
  * @return array
  */
 private static function generateTree($order = 'sort')
 {
     $tree = [];
     $data = StoreCategory::model()->findAll(['order' => $order]);
     foreach ($data as $item) {
         $tree[$item->id] = ['id' => $item->id, 'parent_id' => $item->parent_id, 'name' => $item->name, 'status' => $item->status];
     }
     foreach ($tree as $key => &$value) {
         if (isset($tree[$value['parent_id']])) {
             $tree[$value['parent_id']]['items'][$key] =& $value;
         }
         unset($value);
     }
     $tree = array_filter($tree, function ($value) {
         return $value['parent_id'] == 0;
     });
     Yii::app()->getCache()->set(self::CACHE_CATEGORY_TREE, $tree, 0, new TagsCache(self::CACHE_CATEGORY_TAG));
     return $tree;
 }
Example #17
0
 /**
  * @static
  * @param $type
  * @param $externalId
  * @param bool $loadModel
  */
 public static function getObject($type, $externalId, $loadModel = true)
 {
     $query = Yii::app()->db->createCommand()->select("*")->from('accounting1c')->where('object_type=:type AND external_id=:externalId', array(':type' => $type, ':externalId' => $externalId))->limit(1)->queryRow();
     if ($query === false) {
         return false;
     }
     if ($loadModel === true && $query['object_id']) {
         switch ($type) {
             case self::OBJECT_TYPE_CATEGORY:
                 return StoreCategory::model()->findByPk($query['object_id']);
                 break;
             case self::OBJECT_TYPE_ATTRIBUTE:
                 return StoreAttribute::model()->findByPk($query['object_id']);
                 break;
             case self::OBJECT_TYPE_PRODUCT:
                 return StoreProduct::model()->findByPk($query['object_id']);
                 break;
         }
     }
     return $query['object_id'];
 }
Example #18
0
 public function SetCategoryId($category_id)
 {
     \Yii::import('application.modules.store.models.*');
     \Yii::import('application.modules.cabinet.*');
     //->category_id
     if (empty($category_id)) {
         $category_id = 1;
     }
     $mas = [];
     //$mas[]=$category_id;
     $model = \StoreCategory::model()->findByPk($category_id);
     $mas[] = $model->id;
     while ($model->parent_id != NULL) {
         $mas[] = $model->parent_id;
         $model = \StoreCategory::model()->findByPk($model->parent_id);
         // break;
     }
     switch (count($mas)) {
         case 5:
             $this->category_id_1 = $mas[3];
             $this->category_id_2 = $mas[2];
             $this->category_id_3 = $mas[1];
             $this->category_id_4 = $mas[0];
             break;
         case 4:
             $this->category_id_1 = $mas[2];
             $this->category_id_2 = $mas[1];
             $this->category_id_3 = $mas[0];
             $this->category_id_4 = null;
             break;
         case 3:
             $this->category_id_1 = $mas[1];
             $this->category_id_2 = $mas[0];
             break;
         case 2:
             $this->category_id_1 = $mas[0];
             break;
     }
     return $mas;
 }
Example #19
0
 public function actionStoreCategory()
 {
     // определимся из какой формы был запрос
     $term_ext = \Yii::app()->getRequest()->getParam('term_ext');
     if (isset($term_ext)) {
         $type = explode('/', $term_ext);
         $type = reset($type);
         $type = $type === 'product' ? 'tovary' : 'uslugi';
     } else {
         $type = 'tovary';
     }
     $sql = 'SELECT c1.* FROM {{store_category}} c1 LEFT JOIN {{store_category}} c2 ON c1.id=c2.parent_id WHERE c2.id IS NULL AND c1.name_' . \Yii::app()->language . ' LIKE :name AND c1.type=:type';
     $command = \Yii::app()->db->createCommand($sql);
     $command->bindValue(':name', '%' . $_REQUEST['term'] . '%');
     $command->bindValue(':type', $type);
     $rows = $command->queryAll();
     $cats = [];
     foreach ($rows as $row) {
         $category = \StoreCategory::model()->findByPk($row['id']);
         $cats[] = ['hidden_value' => $row['id'], 'value' => $category->getParentStoreCategories(), 'label' => $category->getParentStoreCategories()];
     }
     echo json_encode($cats);
 }
Example #20
0
 public function getDescendantsId()
 {
     $category = StoreCategory::model()->findByPk($this->id);
     $descendants = $category->descendants()->findAll();
     foreach ($descendants as $descendant) {
         $ids[] = $descendant->id;
     }
     $cid = $ids ? implode(',', $ids) : NULL;
     return $cid;
 }
 protected function getChildrenCategories($category)
 {
     foreach ($category->children as $cat) {
         $this->categories[] = $cat->id;
         $childCat = StoreCategory::model()->findByPk($cat->id);
         if (!empty($childCat->children)) {
             $this->getChildrenCategories($childCat);
         }
     }
     return $this->categories;
 }
Example #22
0
	<?php 
$this->beginWidget('zii.widgets.jui.CJuiButton', array('buttonType' => 'buttonset', 'name' => 'tree-set', 'htmlOptions' => array('style' => 'padding-top:2px;')));
$this->widget('zii.widgets.jui.CJuiButton', array('name' => 'button1', 'buttonType' => 'button', 'caption' => Yii::t('StoreModule.admin', 'Развернуть все'), 'onclick' => 'js:function(){
				 $("#StoreCategoryTreeFilter").jstree("open_all");
			}', 'options' => array('text' => false, 'icons' => array('primary' => 'ui-icon-triangle-1-s'))));
$this->widget('zii.widgets.jui.CJuiButton', array('name' => 'button12', 'buttonType' => 'button', 'caption' => Yii::t('StoreModule.admin', 'Свернуть все'), 'onclick' => 'js:function(){
				 $("#StoreCategoryTreeFilter").jstree("close_all");
				 $("#StoreCategoryTreeFilter").jstree("open_node", "#StoreCategoryTreeFilterNode_1", false, true);
			}', 'options' => array('text' => false, 'icons' => array('primary' => 'ui-icon-triangle-1-n'))));
$this->endWidget();
?>

</div>

<div style="clear: both;"></div>

<?php 
// Create jstree to filter products
$this->widget('ext.jstree.SJsTree', array('id' => 'StoreCategoryTreeFilter', 'data' => StoreCategoryNode::fromArray(StoreCategory::model()->findAllByPk(1), array('displayCount' => true)), 'options' => array('core' => array('initially_open' => 'StoreCategoryTreeFilterNode_1'), 'plugins' => array('themes', 'html_data', 'ui', 'crrm', 'search'), 'cookies' => array('save_selected' => false))));
// Category id to select in sidebar.
$activeCategoryId = Yii::app()->request->getQuery('category', 0);
if (is_array($activeCategoryId)) {
    $activeCategoryId = 0;
}
Yii::app()->getClientScript()->registerScript('insertAllCategory', '
$("#StoreCategoryTreeFilter").bind("loaded.jstree", function (event, data) {
	$(this).jstree("create",-1,false,{attr:{id:"StoreCategoryTreeFilterNode_0"}, data:{title:"' . Yii::t('StoreModule.admin', 'Все категории') . '"}},false,true);
	$(this).jstree("select_node","#StoreCategoryTreeFilterNode_' . $activeCategoryId . '");
});
');
Yii::app()->getClientScript()->registerCss("StoreCategoryTreeStyles", "\n\t#StoreCategoryTree { width:90% }\n\t#StoreCategoryTreeFilter {width: 255px}\n");
Example #23
0
 /**
  * Get category id by path. If category not exits it will new one.
  * @param $path string Main/Music/Rock
  * @return integer category id
  */
 protected function getCategoryByPath($path)
 {
     if (isset($this->categoriesPathCache[$path])) {
         return $this->categoriesPathCache[$path];
     }
     if ($this->rootCategory === null) {
         $this->rootCategory = StoreCategory::model()->findByPk(1);
     }
     $result = preg_split($this->subCategoryPattern, $path, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
     $result = array_map('stripcslashes', $result);
     $parent = $this->rootCategory;
     $level = 2;
     // Level 1 is only root
     foreach ($result as $name) {
         $cr = new CDbCriteria();
         $cr->with = array('cat_translate');
         $cr->compare('cat_translate.name', $name);
         $model = StoreCategory::model()->find($cr);
         if (!$model) {
             $model = new StoreCategory();
             $model->name = $name;
             $model->appendTo($parent);
         }
         $parent = $model;
         $level++;
     }
     // Cache category id
     $this->categoriesPathCache[$path] = $model->id;
     if (isset($model)) {
         return $model->id;
     }
     return 1;
     // root category
 }
 public function actionSearch()
 {
     if (!Yii::app()->getRequest()->getQuery('SearchForm')) {
         throw new CHttpException(404);
     }
     $form = new SearchForm();
     $form->setAttributes(Yii::app()->getRequest()->getQuery('SearchForm'));
     if ($form->validate()) {
         $category = $form->category ? StoreCategory::model()->findByPk($form->category) : null;
         $countries['list'] = [];
         $countries['checked'] = [];
         $price['minValue'] = [];
         $price['maxValue'] = [];
         //$countries['list'] = $this->productRepository->getCountriesFilter($form->q);
         if (Yii::app()->request->getQuery('strana')) {
             foreach (Yii::app()->request->getQuery('strana') as $item) {
                 $countries['checked'] += [$item => $item];
             }
         }
         $price = $this->productRepository->getPricesFilter($form->q);
         if (Yii::app()->request->getQuery('minPrice')) {
             $price['minValue'] = Yii::app()->request->getQuery('minPrice');
         }
         if (Yii::app()->request->getQuery('maxPrice')) {
             $price['maxValue'] = Yii::app()->request->getQuery('maxPrice');
         }
         $this->render('search', ['category' => $category, 'searchForm' => $form, 'price' => $price, 'countries' => $countries, 'dataProvider' => $this->productRepository->getByFilter($this->attributeFilter->getMainAttributesForSearchFromQuery(Yii::app()->getRequest(), [AttributeFilter::MAIN_SEARCH_PARAM_NAME => $form->q]), $this->attributeFilter->getEavAttributesForSearchFromQuery(Yii::app()->getRequest()))]);
     } else {
         if ($form->category) {
             $category = StoreCategory::model()->findByPk($form->category);
             $this->redirect('/store/' . $category->type);
         }
     }
 }
 /**
  * @param $slug
  *
  * @return array|mixed|null
  */
 public function getByAlias($slug)
 {
     return StoreCategory::model()->published()->find('slug = :slug', [':slug' => $slug]);
 }
<?php

$this->widget('ext.jstree.SJsTree', array('id' => 'CategoryAssignTreeDialog', 'data' => StoreCategoryNode::fromArray(StoreCategory::model()->findAllByPk(1))));
?>

<script type="text/javascript">
	$("#CategoryAssignTreeDialog").jstree(<?php 
echo CJavaScript::encode(array('core' => array('initially_open' => 'CategoryAssignTreeDialogNode_1'), 'plugins' => array('themes', 'html_data', 'ui', 'crrm', 'search', 'checkbox', 'cookies'), 'checkbox' => array('two_state' => true), 'cookies' => array('save_selected' => true)));
?>
);
</script>
Example #27
0
}
?>
			</div>

			<div id="cart">
				<?php 
$this->renderFile(Yii::getPathOfAlias('orders.views.cart._small_cart') . '.php');
?>
			</div>
		</div>
	</div>

	<div class="mainm">
		<?php 
Yii::import('application.modules.store.models.StoreCategory');
$items = StoreCategory::model()->findByPk(1)->asCMenuArray();
if (isset($items['items'])) {
    $this->widget('application.extensions.mbmenu.MbMenu', array('cssFile' => Yii::app()->theme->baseUrl . '/assets/css/menu.css', 'htmlOptions' => array('class' => 'dropdown', 'id' => 'nav'), 'items' => $items['items']));
}
?>
	</div>
</div>

<div id="content">
	<?php 
if ($messages = Yii::app()->user->getFlash('messages')) {
    ?>
		<div class="flash_messages">
			<button class="close">×</button>
			<?php 
    if (is_array($messages)) {
Example #28
0
 /**
  * @return StoreCategory
  */
 public function getRootCategory()
 {
     if ($this->_rootCategory) {
         return $this->_rootCategory;
     }
     $this->_rootCategory = StoreCategory::model()->findByPk(1);
     return $this->_rootCategory;
 }
Example #29
0
?>
    <span class="required">*</span>
    <?php 
echo Yii::t('StoreModule.store', 'are required');
?>
</div>

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


<div class='row'>
    <div class="col-sm-3">
        <?php 
echo $form->dropDownListGroup($model, 'parent_id', ['widgetOptions' => ['data' => StoreCategory::model()->getFormattedList(), 'htmlOptions' => ['empty' => Yii::t('StoreModule.store', '--no--'), 'encode' => false]]]);
?>
    </div>
    <div class="col-sm-4">
        <?php 
echo $form->dropDownListGroup($model, 'status', ['widgetOptions' => ['data' => $model->getStatusList()]]);
?>
    </div>
</div>
<div class='row'>
    <div class="col-sm-7">
        <?php 
echo $form->textFieldGroup($model, 'name');
?>
    </div>
</div>
Example #30
0
        <h3><?php 
echo Yii::t('StoreModule.store', 'Link products');
?>
</h3>
        <?php 
$this->widget('yupe\\widgets\\CustomGridView', ['id' => 'product-grid', 'type' => 'condensed', 'dataProvider' => $searchModel->searchNotFor(isset($product->id) ? $product->id : null), 'filter' => $searchModel, 'actionsButtons' => false, 'bulkActions' => [false], 'ajaxUrl' => ['/store/linkBackend/index'], 'columns' => [['type' => 'raw', 'value' => function ($data) {
    return CHtml::link(CHtml::image($data->getImageUrl(40, 40), "", ["class" => "img-thumbnail"]), ["/store/productBackend/update", "id" => $data->id]);
}], ['name' => 'name', 'type' => 'raw', 'value' => function ($data) {
    return CHtml::link($data->name, ["/store/productBackend/update", "id" => $data->id]);
}], ['class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'sku', 'editable' => ['emptytext' => '---', 'url' => $this->createUrl('/store/productBackend/inline'), 'mode' => 'inline', 'params' => [Yii::app()->getRequest()->csrfTokenName => Yii::app()->getRequest()->csrfToken]], 'filter' => CHtml::activeTextField($searchModel, 'sku', ['class' => 'form-control'])], ['name' => 'category_id', 'value' => function ($data) {
    $categoryList = '<span class="label label-primary">' . (isset($data->mainCategory) ? $data->mainCategory->name : '---') . '</span>';
    foreach ($data->categories as $category) {
        $categoryList .= '<br>' . $category->name;
    }
    return $categoryList;
}, 'type' => 'raw', 'filter' => CHtml::activeDropDownList($searchModel, 'category', StoreCategory::model()->getFormattedList(), ['encode' => false, 'empty' => '', 'class' => 'form-control']), 'htmlOptions' => ['width' => '220px']], ['class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'price', 'value' => function ($data) {
    return (double) $data->price;
}, 'editable' => ['url' => $this->createUrl('/store/productBackend/inline'), 'mode' => 'inline', 'params' => [Yii::app()->getRequest()->csrfTokenName => Yii::app()->getRequest()->csrfToken]], 'filter' => CHtml::activeTextField($searchModel, 'price', ['class' => 'form-control'])], ['value' => function ($data) use($linkTypes) {
    $links = [];
    foreach ($linkTypes as $id => $name) {
        $links[] = ['label' => $name, 'linkOptions' => ['class' => 'link-product-button', 'data-type-id' => $id, 'data-linked-product-id' => $data->id], 'url' => '#'];
    }
    return $this->widget('booster.widgets.TbButtonGroup', ['buttons' => [['label' => Yii::t('StoreModule.store', 'Add in'), 'items' => $links]]], true);
}, 'type' => 'raw']]]);
?>
    </div>
</div>

<?php 
$productId = isset($product) ? $product->id : null;
$linkUrl = Yii::app()->createUrl('/store/linkBackend/link');