Exemplo n.º 1
0
    public function getForm()
    {
        Yii::import('ext.TagInput');
        $tab = new TabForm(array('attributes' => array('enctype' => 'multipart/form-data', 'class' => 'form-horizontal', 'id' => __CLASS__), 'showErrorSummary' => true, 'elements' => array('main' => array('type' => 'form', 'title' => $this->t('TAB_GENERAL'), 'elements' => array('per_page' => array('type' => 'text', 'hint' => $this->t('HINT_PER_PAGE')), 'auto_fill_short_desc' => array('type' => 'checkbox'), 'wholesale' => array('type' => 'checkbox'), 'filter_enable_price' => array('type' => 'checkbox'), 'filter_enable_brand' => array('type' => 'checkbox'), 'filter_enable_attr' => array('type' => 'checkbox'), 'auto_gen_url' => array('type' => 'checkbox', 'hint' => $this->t('HINT_AUTO_GEN_URL')), 'create_btn_action' => array('type' => 'dropdownlist', 'items' => Html::listData(ShopProductType::model()->findAll(), 'id', 'name'), 'empty' => '&mdash; Не привязывать &mdash;', 'hint' => $this->t('HINT_CREATE_BTN_ACTION')))), 'seo' => array('type' => 'form', 'title' => $this->t('TAB_SEO'), 'elements' => array('auto_gen_meta' => array('type' => 'checkbox'), 'auto_gen_tpl_title' => array('type' => 'textarea', 'hint' => $this->t('META_TPL', array('{currency}' => Yii::app()->currency->active->symbol))), 'auto_gen_tpl_keywords' => array('type' => 'textarea', 'hint' => $this->t('META_TPL', array('{currency}' => Yii::app()->currency->active->symbol))), 'auto_gen_tpl_description' => array('type' => 'textarea', 'hint' => $this->t('META_TPL', array('{currency}' => Yii::app()->currency->active->symbol))))), 'catseo' => array('type' => 'form', 'title' => $this->t('TAB_CAT_SEO'), 'elements' => array('auto_gen_cat_meta' => array('type' => 'checkbox'), 'auto_gen_cat_tpl_title' => array('type' => 'textarea', 'hint' => $this->t('META_CAT_TPL', array('{currency}' => Yii::app()->currency->active->symbol))), 'auto_gen_cat_tpl_keywords' => array('type' => 'textarea', 'hint' => $this->t('META_CAT_TPL', array('{currency}' => Yii::app()->currency->active->symbol))), 'auto_gen_cat_tpl_description' => array('type' => 'textarea', 'hint' => $this->t('META_CAT_TPL', array('{currency}' => Yii::app()->currency->active->symbol))))), 'watermark' => array('type' => 'form', 'title' => $this->t('TAB_WM'), 'elements' => array('watermark_active' => array('type' => 'checkbox'), 'watermark_image' => array('type' => 'file'), '<div class="formRow">
				<div class="grid5"><label></label></div>
				<div class="grid7">' . $this->renderWatermarkImageTag() . '</div>
                                    <div class="clear"></div>
				</div>', 'watermark_corner' => array('type' => 'dropdownlist', 'items' => $this->getWatermarkCorner()), 'watermark_offsetX' => array('type' => 'text'), 'watermark_offsetY' => array('type' => 'text'))), 'images' => array('type' => 'form', 'title' => $this->t('TAB_IMG'), 'elements' => array('img_preview_size_list' => array('type' => 'text', 'class' => 'maskWidthHeight', 'afterField' => '<span class="fieldIcon icon-image"></span>'), 'img_view_size' => array('type' => 'text', 'class' => 'maskWidthHeight', 'afterField' => '<span class="fieldIcon icon-image"></span>'), 'img_view_thumbs_size' => array('type' => 'text', 'afterField' => '<span class="fieldIcon icon-image"></span>'), 'maxFileSize' => array('type' => 'text', 'hint' => Yii::t('ShopModule.admin', 'Укажите размер в байтах.')), 'maximum_image_size' => array('type' => 'text', 'hint' => Yii::t('ShopModule.admin', 'Изображения превышающие этот размер, будут изменены.')))), 'formatprice' => array('type' => 'form', 'title' => $this->t('TAB_FORMATPRICE'), 'elements' => array('fp_penny' => array('type' => 'dropdownlist', 'items' => array(0 => Yii::t('app', 'NO'), 2 => Yii::t('app', 'YES'))), 'fp_separator_thousandth' => array('type' => 'dropdownlist', 'items' => self::fpSeparator()), 'fp_separator_hundredth' => array('type' => 'dropdownlist', 'items' => self::fpSeparator())))), 'buttons' => array('submit' => array('type' => 'submit', 'class' => 'btn btn-success', 'label' => Yii::t('app', 'SAVE')))), $this);
        return $tab;
    }
Exemplo n.º 2
0
 public function afterUninstall()
 {
     Yii::app()->settings->clear('shop');
     Yii::app()->unintallComponent('currency');
     $db = Yii::app()->db;
     $tablesArray = array(ShopTypeAttribute::model()->tableName(), ShopAttribute::model()->tableName(), ShopAttributeOption::model()->tableName(), ShopAttributeOptionTranslate::model()->tableName(), ShopAttributeTranslate::model()->tableName(), ShopCategory::model()->tableName(), ShopCategoryTranslate::model()->tableName(), ShopCurrency::model()->tableName(), ShopManufacturer::model()->tableName(), ShopManufacturerTranslate::model()->tableName(), ShopProduct::model()->tableName(), ShopProductCategoryRef::model()->tableName(), ShopProductImage::model()->tableName(), ShopProductTranslate::model()->tableName(), ShopProductType::model()->tableName(), ShopProductVariant::model()->tableName(), ShopRelatedProduct::model()->tableName(), ShopSuppliers::model()->tableName(), $db->tablePrefix . 'shop_product_attribute_eav', $db->tablePrefix . 'shop_product_configurable_attributes', $db->tablePrefix . 'shop_product_configurations');
     foreach ($tablesArray as $table) {
         $db->createCommand()->dropTable($table);
     }
     CFileHelper::removeDirectory(Yii::getPathOfAlias('webroot.uploads.product'), array('traverseSymlinks' => true));
     CFileHelper::removeDirectory(Yii::getPathOfAlias('webroot.uploads.categories'), array('traverseSymlinks' => true));
     CFileHelper::removeDirectory(Yii::getPathOfAlias('webroot.uploads.manufacturer'), array('traverseSymlinks' => true));
     return parent::afterUninstall();
 }
Exemplo n.º 3
0
 /**
  * Delete type
  * @param array $id
  */
 public function actionDelete($id = array())
 {
     if (Yii::app()->request->isPostRequest) {
         $model = ShopProductType::model()->findAllByPk($_REQUEST['id']);
         if (!empty($model)) {
             foreach ($model as $m) {
                 if ($m->productsCount > 0) {
                     throw new CHttpException(404, Yii::t('ShopModule.admin', 'ERR_DEL_TYPE_PRODUCT'));
                 } else {
                     $m->delete();
                 }
             }
         }
         if (!Yii::app()->request->isAjaxRequest) {
             $this->redirect('index');
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Load attributes relative to type and available for product configurations.
  * Used on creating new product.
  */
 public function actionLoadConfigurableOptions()
 {
     // For configurations that  are available only dropdown and radio lists.
     $cr = new CDbCriteria();
     $cr->addInCondition('type', array(ShopAttribute::TYPE_DROPDOWN, ShopAttribute::TYPE_RADIO_LIST));
     $type = ShopProductType::model()->with(array('shopAttributes'))->findByPk($_GET['type_id'], $cr);
     $data = array();
     foreach ($type->shopAttributes as $attr) {
         $data[] = array('id' => $attr->id, 'title' => $attr->title);
     }
     echo json_encode($data);
 }
Exemplo n.º 5
0
    echo Html::form('', 'get', array('class' => 'form-horizontal'));
    if ($attributeError) {
        echo '<div class="errorSummary"><p>' . Yii::t('ShopModule', 'Необходимо исправить следующие ошибки:') . '</p>
					<ul>
						<li>' . Yii::t('ShopModule.admin', 'Выберите атрибуты для конфигурации продуктов.') . '</li>
					</ul>
			</div>';
    }
    ?>
    <div class="form-group">
        <div class="col-sm-4"><?php 
    echo Html::activeLabel($model, 'type_id');
    ?>
</div>
        <div class="col-sm-8"><?php 
    echo Html::activeDropDownList($model, 'type_id', CHtml::listData(ShopProductType::model()->orderByName()->findAll(), 'id', 'name'), array('class' => 'form-control'));
    ?>
</div>
    </div>
    <div class="form-group">
        <div class="col-sm-4"><?php 
    echo Html::activeLabel($model, 'use_configurations');
    ?>
</div>
        <div class="col-sm-8"><?php 
    echo Html::activeDropDownList($model, 'use_configurations', array(0 => Yii::t('app', 'NO'), 1 => Yii::t('app', 'YES')), array('class' => 'form-control'));
    ?>
</div>
    </div>
    <div id="availableAttributes"></div>
    <div class="form-group text-center">
Exemplo n.º 6
0
 /**
  * Get product type by name. If type not exists - create new one.
  * @param $name
  * @return int
  */
 public function getTypeIdByName($name)
 {
     if (isset($this->productTypeCache[$name])) {
         return $this->productTypeCache[$name];
     }
     $model = ShopProductType::model()->findByAttributes(array('name' => $name));
     if (!$model) {
         $model = new ShopProductType();
         $model->name = $name;
         $model->save();
     }
     $this->productTypeCache[$name] = $model->id;
     return $model->id;
 }