Ejemplo n.º 1
0
 /**
  * Get active/applied filters to make easier to cancel them.
  */
 public function getActiveFilters()
 {
     $request = Yii::app()->request;
     // Render links to cancel applied filters like prices, manufacturers, attributes.
     $menuItems = array();
     $manufacturers = array_filter(explode(',', $request->getQuery('manufacturer')));
     $manufacturers = ShopManufacturer::model()->findAllByPk($manufacturers);
     if ($request->getQuery('min_price')) {
         array_push($menuItems, array('linkOptions' => array('class' => 'remove'), 'label' => Yii::t('ShopModule.core', 'от {minPrice} {c}', array('{minPrice}' => (int) $this->getCurrentMinPrice(), '{c}' => Yii::app()->currency->active->symbol)), 'url' => $request->removeUrlParam('/shop/category/view', 'min_price')));
     }
     if ($request->getQuery('max_price')) {
         array_push($menuItems, array('label' => Yii::t('ShopModule.core', 'до {maxPrice} {c}', array('{maxPrice}' => (int) $this->getCurrentMaxPrice(), '{c}' => Yii::app()->currency->active->symbol)), 'linkOptions' => array('class' => 'remove'), 'url' => $request->removeUrlParam('/shop/category/view', 'max_price')));
     }
     if (!empty($manufacturers)) {
         foreach ($manufacturers as $manufacturer) {
             array_push($menuItems, array('label' => $manufacturer->name, 'linkOptions' => array('class' => 'remove'), 'url' => $request->removeUrlParam('/shop/category/view', 'manufacturer', $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('label' => $option->value, 'linkOptions' => array('class' => 'remove'), 'url' => $request->removeUrlParam('/shop/category/view', $attribute->name, $option->id)));
                     }
                 }
             }
         }
     }
     return $menuItems;
 }
Ejemplo 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();
 }
Ejemplo n.º 3
0
 /**
  * Display products by manufacturer
  *
  * @param $seo_alias
  * @throws CHttpException
  */
 public function actionIndex($seo_alias)
 {
     $this->model = ShopManufacturer::model()->findByAttributes(array('seo_alias' => $seo_alias));
     if (!$this->model) {
         throw new CHttpException(404, Yii::t('ShopModule.admin', 'NO_FOUND_BRAND'));
     }
     $this->pageTitle = $this->model->seo_title ? $this->model->seo_title : $this->model->name;
     $this->pageKeywords = $this->model->seo_keywords;
     $this->pageDescription = $this->model->seo_description;
     $query = new ShopProduct(null);
     $query->attachBehaviors($query->behaviors());
     $query->active();
     $query->applyManufacturers($this->model->id);
     $provider = new ActiveDataProvider($query, array('id' => false, 'pagination' => array('pageSize' => $this->allowedPageLimit[0])));
     $this->render('index', array('provider' => $provider));
 }
Ejemplo n.º 4
0
 /**
  * Update manufacturer
  * @param bool $new
  * @throws CHttpException
  */
 public function actionUpdate($new = false)
 {
     if ($new === true) {
         $model = new ShopManufacturer();
     } else {
         $model = ShopManufacturer::model()->findByPk($_GET['id']);
     }
     $this->topButtons = false;
     if (!$model) {
         throw new CHttpException(404, Yii::t('ShopModule.admin', 'NO_FOUND_BRAND'));
     }
     $oldImage = $model->image;
     $this->pageName = $model->isNewRecord ? $model::t('PAGE_NAME', 0) : $model::t('PAGE_NAME', 1);
     $this->breadcrumbs = array(Yii::t('ShopModule.default', 'MODULE_NAME') => array('/admin/shop'), Yii::t('ShopModule.admin', 'BRANDS') => $this->createUrl('index'), $this->pageName);
     if (isset($_POST['ShopManufacturer'])) {
         $model->attributes = $_POST['ShopManufacturer'];
         if ($model->validate()) {
             $model->uploadFile('image', 'webroot.uploads.manufacturer', $oldImage);
             $model->save();
         }
     }
     $this->render('update', array('model' => $model));
 }
Ejemplo n.º 5
0
 public function getForm()
 {
     Yii::import('zii.widgets.jui.CJuiDatePicker');
     Yii::app()->controller->widget('ext.tinymce.TinymceWidget');
     return array('showErrorSummary' => true, 'attributes' => array('enctype' => 'multipart/form-data', 'class' => 'form-horizontal', 'id' => __CLASS__), 'elements' => array('content' => array('type' => 'form', 'title' => $this->t('TAB_GENERAL'), 'elements' => array('name' => array('type' => 'text', 'id' => 'title', 'visible' => Yii::app()->settings->get('shop', 'auto_gen_url') ? false : true), 'seo_alias' => array('type' => 'text', 'id' => 'alias', 'visible' => Yii::app()->settings->get('shop', 'auto_gen_url') || Yii::app()->settings->get('core', 'translate_object_url') ? false : true), 'sku' => array('type' => 'text', 'afterField' => '<span class="fieldIcon icon-barcode "></span>'), 'price' => array('type' => $this->use_configurations ? 'hidden' : 'text', 'afterField' => '<span class="fieldIcon icon-coin"></span>'), 'price_purchase' => array('type' => 'text', 'afterField' => '<span class="fieldIcon icon-coin"></span>'), 'pcs' => array('type' => 'text', 'visible' => Yii::app()->settings->get('shop', 'wholesale') ? true : false), 'label' => array('type' => 'dropdownlist', 'items' => self::getProductLabels(), 'empty' => Yii::t('core', 'EMPTY_DROPDOWNLIST', 1)), 'currency_id' => array('type' => 'dropdownlist', 'items' => Html::listData(ShopCurrency::model()->findAll(array('condition' => '`t`.`default`=:int', 'params' => array(':int' => 0))), 'id', 'name'), 'empty' => '&mdash; Не привязывать &mdash;', 'visible' => Yii::app()->controller->module->accept_currency), 'main_category_id' => array('type' => 'dropdownlist', 'items' => ShopCategory::flatTree(), 'empty' => '---'), 'switch' => array('type' => 'dropdownlist', 'items' => array(1 => Yii::t('app', 'YES'), 0 => Yii::t('app', 'NO')), 'hint' => $this->t('HINT_SWITCH')), 'date_create' => array('type' => 'CJuiDatePicker', 'options' => array('dateFormat' => 'yy-mm-dd ' . date('H:i:s')), 'afterField' => '<span class="fieldIcon icon-calendar-2"></span>'), 'manufacturer_id' => array('type' => 'dropdownlist', 'items' => Html::listData(ShopManufacturer::model()->findAll(), 'id', 'name'), 'empty' => $this->t('EMPTY_MANUFACTURER')), 'supplier_id' => array('type' => 'dropdownlist', 'items' => Html::listData(ShopSuppliers::model()->findAll(), 'id', 'name'), 'empty' => $this->t('EMPTY_SUPPLIERS'), 'visible' => Yii::app()->controller->module->supplier), 'short_description' => array('type' => 'textarea', 'class' => 'editor', 'hint' => Yii::app()->settings->get('shop', 'auto_fill_short_desc') ? Yii::t('ShopModule.admin', 'MODE_ENABLE', array('{mode}' => Yii::t('ShopModule.SettingsShopForm', 'AUTO_FILL_SHORT_DESC'))) : null), 'full_description' => array('type' => 'textarea', 'class' => 'editor'))), 'warehouse' => array('type' => 'form', 'title' => $this->t('TAB_WAREHOUSE'), 'elements' => array('quantity' => array('type' => 'text'), 'discount' => array('type' => 'text', 'hint' => $this->t('HINT_DISCOUNT')), 'auto_decrease_quantity' => array('type' => 'dropdownlist', 'items' => array(0 => Yii::t('app', 'NO'), 1 => Yii::t('app', 'YES')), 'hint' => $this->t('HINT_AUTO_DECREASE_QUANTITY')), 'availability' => array('type' => 'dropdownlist', 'items' => $this->getAvailabilityList()))), 'seo' => array('type' => 'form', 'title' => $this->t('TAB_SEO'), 'elements' => array('seo_title' => array('type' => 'text'), 'seo_keywords' => array('type' => 'textarea'), 'seo_description' => array('type' => 'textarea')))), 'buttons' => array('submit' => array('type' => 'submit', 'class' => 'btn btn-success', 'label' => $this->isNewRecord ? Yii::t('app', 'CREATE', 0) : Yii::t('app', 'SAVE'))));
 }
Ejemplo n.º 6
0
 /**
  * Create/update product
  * @param bool $new
  * @throws CHttpException
  */
 public function actionUpdate($new = false)
 {
     $this->topButtons = false;
     $config = Yii::app()->settings->get('shop');
     if ($new === true) {
         $model = new ShopProduct();
     } else {
         $model = ShopProduct::model()->language(Yii::app()->language->active)->findByPk($_GET['id']);
     }
     if (!$model) {
         throw new CHttpException(404, Yii::t('ShopModule.admin', 'NO_FOUND_PRODUCT'));
     }
     $oldImage = $model->image;
     if (!$model->isNewRecord) {
         $this->topButtons = array(array('label' => Yii::t('ShopModule.admin', 'VIEW_PRODUCT'), 'url' => $model->getAbsoluteUrl(), 'htmlOptions' => array('class' => 'btn btn-info', 'target' => '_blank')));
     }
     // Apply use_configurations, configurable_attributes, type_id
     if (isset($_GET['ShopProduct'])) {
         $model->attributes = $_GET['ShopProduct'];
     }
     $title = $model->isNewRecord ? Yii::t('ShopModule.admin', 'CREATE_PRODUCT') : Yii::t('ShopModule.admin', 'UPDATE_PRODUCT');
     if ($model->type) {
         $title .= ' "' . Html::encode($model->type->name) . '"';
     }
     $this->pageName = $title;
     $this->breadcrumbs = array(Yii::t('ShopModule.default', 'MODULE_NAME') => array('/admin/shop'), Yii::t('ShopModule.admin', 'PRODUCTS') => $this->createUrl('index'), $this->pageName);
     // On create new product first display "Choose type" form first.
     if ($model->isNewRecord && isset($_GET['ShopProduct']['type_id'])) {
         if (ShopProductType::model()->countByAttributes(array('id' => $model->type_id)) === '0') {
             throw new CHttpException(404, Yii::t('ShopModule.admin', 'ERR_PRODUCT_TYPE'));
         }
     }
     // Set main category id to have categories drop-down selected value
     if ($model->mainCategory) {
         $model->main_category_id = $model->mainCategory->id;
     }
     // Or set selected category from type pre-set.
     if ($model->type && !Yii::app()->request->isPostRequest && $model->isNewRecord) {
         $model->main_category_id = $model->type->main_category;
     }
     // Set configurable attributes on new record
     if ($model->isNewRecord) {
         if ($model->use_configurations && isset($_GET['ShopProduct']['configurable_attributes'])) {
             $model->configurable_attributes = $_GET['ShopProduct']['configurable_attributes'];
         }
     }
     $form = new TabForm($model->getForm(), $model);
     //  $form->positionTabs = 'vertical';
     // Set additional tabs
     $form->additionalTabs[$model->t('TAB_CAT')] = array('content' => $this->renderPartial('_tree', array('model' => $model), true));
     $form->additionalTabs[$model->t('TAB_IMG')] = array('content' => $this->renderPartial('_images', array('model' => $model, 'uploadModel' => $uploadModel), true));
     $form->additionalTabs[$model->t('TAB_ATTR')] = array('content' => $this->renderPartial('_attributes', array('model' => $model), true));
     $form->additionalTabs[$model->t('TAB_REL')] = array('content' => $this->renderPartial('_relatedProducts', array('exclude' => $model->id, 'product' => $model), true));
     //if (Yii::app()->getModule('shop')->variations)
     $form->additionalTabs[Yii::t('ShopModule.admin', 'UPDATE_PRODUCT_TAB_VARIANTS')] = array('content' => $this->renderPartial('_variations', array('model' => $model), true));
     // if($this->isInstallModule('comments')){
     //      $form->additionalTabs['icon-comment'] = array(
     //         'content' => $this->renderPartial('_comments', array('model' => $model), true)
     //         );
     // }
     /*    $form->additionalTabs = array(
           'icon-folder-open' => array(
           'content' => $this->renderPartial('_tree', array('model' => $model), true)
           ),
           'icon-copy-3' => array(
           'content' => $this->renderPartial('_relatedProducts', array('exclude' => $model->id, 'product' => $model), true)
           ),
           'icon-images' => array(
           'content' => $this->renderPartial('_images', array('model' => $model, 'uploadModel' => $uploadModel), true)
           ),
           'icon-paragraph-justify' => array(
           'content' => $this->renderPartial('_attributes', array('model' => $model), true),
           'visible'=>false
           ),
           Yii::t('ShopModule.admin', 'Варианты') => array(
           'content' => $this->renderPartial('_variations', array('model' => $model), true)
           ),
           'icon-comment' => array(
           'content' => $this->renderPartial('_comments', array('model' => $model), true)
           ),
           ); */
     if ($model->use_configurations) {
         $form->additionalTabs[Yii::t('ShopModule.admin', 'UPDATE_PRODUCT_TAB_CONF')] = array('content' => $this->renderPartial('_configurations', array('product' => $model), true));
     }
     if (isset($_GET['ShopProduct']['main_category_id'])) {
         $model->main_category_id = $_GET['ShopProduct']['main_category_id'];
     }
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = $_POST['ShopProduct'];
         // Handle related products
         $model->setRelatedProducts(Yii::app()->getRequest()->getPost('RelatedProductId', array()));
         if ($config['auto_gen_url']) {
             $model->name = ShopCategory::model()->findByPk($model->main_category_id)->name . ' ' . ShopManufacturer::model()->findByPk($model->manufacturer_id)->name . ' ' . $model->sku;
             $model->seo_alias = CMS::translit($model->name);
             // die($model->name.$model->seo_alias);
         }
         /* if($model->currency_id){
            $currency = ShopCurrency::model()->findByPk($model->currency_id);
            $convertPrice = $model->price*$currency->rate/$currency->rate_old;
            $model->price=$convertPrice;
            } */
         if ($model->validate() && $this->validateAttributes($model)) {
             $model->uploadFile('image', 'webroot.uploads.product', $oldImage);
             $model->save();
             // Process categories
             $mainCategoryId = 1;
             if (isset($_POST['ShopProduct']['main_category_id'])) {
                 $mainCategoryId = $_POST['ShopProduct']['main_category_id'];
             }
             $model->setCategories(Yii::app()->request->getPost('categories', array()), $mainCategoryId);
             // Process attributes
             $this->processAttributes($model);
             // Process variants
             $this->processVariants($model);
             // Process configurations
             $this->processConfigurations($model);
             // Handle images
             $this->handleUploadedImages($model);
             // Set main image
             $this->updateMainImage($model);
             // Update image titles
             $this->updateImageTitles();
             $model->save(false, false);
             $this->redirect(array('index'));
         } else {
             $this->setFlashMessage(Yii::t('ShopModule.admin', 'ERR_PRODUCT_TYPE'));
         }
     }
     $this->render('update', array('model' => $model, 'form' => $form));
 }
Ejemplo n.º 7
0
 public function getForm()
 {
     Yii::import('zii.widgets.jui.CJuiDatePicker');
     return array('showErrorSummary' => true, 'attributes' => array('class' => 'form-horizontal', 'id' => __CLASS__), 'elements' => array('content' => array('type' => 'form', 'title' => Yii::t('DiscountsModule.admin', 'Общая информация'), 'elements' => array('name' => array('type' => 'text'), 'switch' => array('type' => 'checkbox'), 'sum' => array('type' => 'text', 'hint' => $this->t('HINT_SUM')), 'start_date' => array('type' => 'CJuiDatePicker', 'htmlOptions' => array('class' => 'form-control'), 'options' => array('dateFormat' => 'yy-mm-dd ' . date('H:i:s'))), 'end_date' => array('type' => 'CJuiDatePicker', 'htmlOptions' => array('class' => 'form-control'), 'options' => array('dateFormat' => 'yy-mm-dd ' . date('H:i:s'))), 'manufacturers' => array('type' => 'dropdownlist', 'items' => Html::listData(ShopManufacturer::model()->orderByName()->findAll(), 'id', 'name'), 'multiple' => 'multiple', 'data-placeholder' => $this->t('HINT_MANUFACTURERS')), 'userRoles' => array('type' => 'dropdownlist', 'items' => DiscountHelper::getGroup(), 'multiple' => 'multiple')))), 'buttons' => array('submit' => array('type' => 'submit', 'class' => 'btn btn-success', 'label' => $this->isNewRecord ? Yii::t('app', 'CREATE', 0) : Yii::t('app', 'SAVE'))));
 }
Ejemplo n.º 8
0
<?php

if ($this->isAjax) {
    $this->renderPartial('mod.admin.views.layouts._content-top');
    echo Html::openTag('div', array('class' => 'wrapper'));
}
?>
<div class="widget">
    <div class="whead">
        <h6><?php 
echo $this->pageName;
?>
</h6>
        <a class="buttonH bBlue" title="" href="/admin/shop/notify/deliverySend"><?php 
echo Yii::t('CartModule.admin', 'Отправить');
?>
</a>
        <div class="clear"></div>
    </div>

    <?php 
$this->widget('ext.fancybox.Fancybox', array('target' => 'td.image a'));
$this->widget('ext.adminList.GridView', array('dataProvider' => $dataProvider, 'selectableRows' => false, 'autoColumns' => false, 'enableHeader' => false, 'columns' => array(array('class' => 'SGridIdColumn', 'type' => 'html', 'htmlOptions' => array('class' => 'image'), 'value' => '(!empty($data->mainImage))?Html::link(Html::image($data->mainImage->getUrl("50x50"),""),$data->mainImage->getUrl("500x500")):"no image"'), array('name' => 'name', 'type' => 'raw', 'value' => 'Html::link(Html::encode($data->name), array("/shop/admin/products/update", "id"=>$data->id))'), 'price', array('name' => 'manufacturer_id', 'type' => 'raw', 'value' => '$data->manufacturer ? Html::encode($data->manufacturer->name) : ""', 'filter' => Html::listData(ShopManufacturer::model()->orderByName()->findAll(), 'id', 'name')), array('name' => 'supplier_id', 'type' => 'raw', 'value' => '$data->supplier_id ? Html::encode($data->supplier->name) : ""', 'filter' => Html::listData(ShopSuppliers::model()->findAll(), 'id', 'name')), array('type' => 'raw', 'header' => 'Категория/и', 'htmlOptions' => array('style' => 'width:100px'), 'value' => '$data->getCategories()', 'filter' => false))));
?>
    <div class="clear"></div>
</div>
<?php 
if ($this->isAjax) {
    echo Html::closeTag('div');
}
Ejemplo n.º 9
0
 public function run()
 {
     $data = ShopManufacturer::model()->onlyImage()->findAll();
     $this->render($this->skin, array('result' => $data));
 }
Ejemplo n.º 10
0
 /**
  * Find or create manufacturer
  * @param $name
  * @return integer
  */
 public function getManufacturerIdByName($name)
 {
     if (isset($this->manufacturerCache[$name])) {
         return $this->manufacturerCache[$name];
     }
     $cr = new CDbCriteria();
     $cr->with = array('man_translate');
     $cr->compare('man_translate.name', $name);
     $model = ShopManufacturer::model()->find($cr);
     if (!$model) {
         $model = new ShopManufacturer();
         $model->name = $name;
         $model->seo_alias = CMS::translit($name);
         if ($model->validate()) {
             $model->save(false, false);
         }
     }
     $this->manufacturerCache[$name] = $model->id;
     return $model->id;
 }