public function renderForm()
 {
     $this->fields_form = array('legend' => array('title' => $this->l('Shop Group')), 'description' => $this->l('Warning: it is not recommended to enable the "share customers" and "share orders" options, because once they are activated and customers or orders are created, you will not be able to disable these options. If you need these options, try to first consider using several categories instead on several shops.'), 'input' => array(array('type' => 'text', 'label' => $this->l('Shop group name:'), 'name' => 'name', 'required' => true), array('type' => 'radio', 'label' => $this->l('Share customers:'), 'name' => 'share_customer', 'required' => true, 'class' => 't', 'is_bool' => true, 'disabled' => $this->id_object && $this->display == 'edit' && ShopGroup::hasDependency($this->id_object, 'customer') ? true : false, 'values' => array(array('id' => 'share_customer_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'share_customer_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Once the option is enabled, the shops in this group will share their customers: if a customer registers on one of this group\'s shops, the account will automatically be available on the others shops of this goup. Warning: you will not be able to disable this option once you have customers registered on at least one shop of this group.')), array('type' => 'radio', 'label' => $this->l('Share available quantities to sell:'), 'name' => 'share_stock', 'required' => true, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'share_stock_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'share_stock_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Share available quantities to sell between shops of this group. When changing this option, all products available quantities for this group will be reset to 0.')), array('type' => 'radio', 'label' => $this->l('Share orders:'), 'name' => 'share_order', 'required' => true, 'class' => 't', 'is_bool' => true, 'disabled' => $this->id_object && $this->display == 'edit' && ShopGroup::hasDependency($this->id_object, 'order') ? true : false, 'values' => array(array('id' => 'share_order_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'share_order_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Once this option is enabled (which is only possible if customers and available quantities are shared among shops), the customer\'s cart will be shared among all the shops in this group. This way, any purchase started on one of the shops in this group will be able to be finished in another shop from the same shop group. Warning: you will not be able to disable this option once you have orders on at least one shop of this group.')), array('type' => 'radio', 'label' => $this->l('Status:'), 'name' => 'active', 'required' => true, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Enable or disable group shop'))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     if (Shop::getTotalShops() > 1 && $obj->id) {
         $disabled = array('share_customer' => true, 'share_stock' => true, 'share_order' => true, 'active' => false);
     } else {
         $disabled = false;
     }
     $default_shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
     $this->tpl_form_vars = array('disabled' => $disabled, 'checked' => Tools::getValue('addshop_group') !== false ? true : false, 'defaultGroup' => $default_shop->id_shop_group);
     $this->fields_value = array('active' => true);
     return parent::renderForm();
 }
Ejemplo n.º 2
0
 public function renderForm()
 {
     $this->fields_form = array('legend' => array('title' => $this->l('Shop group'), 'icon' => 'icon-shopping-cart'), 'description' => $this->l('Warning: Enabling the "share customers" and "share orders" options is not recommended. Once activated and orders are created, you will not be able to disable these options. If you need these options, we recommend using several categories rather than several shops.'), 'input' => array(array('type' => 'text', 'label' => $this->l('Shop group name'), 'name' => 'name', 'required' => true), array('type' => 'switch', 'label' => $this->l('Share customers'), 'name' => 'share_customer', 'required' => true, 'class' => 't', 'is_bool' => true, 'disabled' => $this->id_object && $this->display == 'edit' && ShopGroup::hasDependency($this->id_object, 'customer') ? true : false, 'values' => array(array('id' => 'share_customer_on', 'value' => 1), array('id' => 'share_customer_off', 'value' => 0)), 'desc' => $this->l('Once this option is enabled, the shops in this group will share customers. If a customer registers in any one of these shops, the account will automatically be available in the others shops of this group.') . '<br/>' . $this->l('Warning: you will not be able to disable this option once you have registered customers.')), array('type' => 'switch', 'label' => $this->l('Share available quantities to sell'), 'name' => 'share_stock', 'required' => true, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'share_stock_on', 'value' => 1), array('id' => 'share_stock_off', 'value' => 0)), 'desc' => $this->l('Share available quantities between shops of this group. When changing this option, all available products quantities will be reset to 0.')), array('type' => 'switch', 'label' => $this->l('Share orders'), 'name' => 'share_order', 'required' => true, 'class' => 't', 'is_bool' => true, 'disabled' => $this->id_object && $this->display == 'edit' && ShopGroup::hasDependency($this->id_object, 'order') ? true : false, 'values' => array(array('id' => 'share_order_on', 'value' => 1), array('id' => 'share_order_off', 'value' => 0)), 'desc' => $this->l('Once this option is enabled (which is only possible if customers and available quantities are shared among shops), the customer\'s cart will be shared by all shops in this group. This way, any purchase started in one shop will be able to be completed in another shop from the same group.') . '<br/>' . $this->l('Warning: You will not be able to disable this option once you\'ve started to accept orders.')), array('type' => 'switch', 'label' => $this->l('Status'), 'name' => 'active', 'required' => true, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1), array('id' => 'active_off', 'value' => 0)), 'desc' => $this->l('Enable or disable this shop group?'))), 'submit' => array('title' => $this->l('Save')));
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     if (Shop::getTotalShops() > 1 && $obj->id) {
         $disabled = array('share_customer' => true, 'share_stock' => true, 'share_order' => true, 'active' => false);
     } else {
         $disabled = false;
     }
     $default_shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
     $this->tpl_form_vars = array('disabled' => $disabled, 'checked' => Tools::getValue('addshop_group') !== false ? true : false, 'defaultGroup' => $default_shop->id_shop_group);
     $this->fields_value = array('active' => true);
     return parent::renderForm();
 }
Ejemplo n.º 3
0
 public function renderForm()
 {
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Shop'), 'icon' => 'icon-shopping-cart'), 'input' => array(array('type' => 'text', 'label' => $this->l('Shop name'), 'desc' => array($this->l('This field does not refer to the shop name visible in the front office.'), sprintf($this->l('Follow %sthis link%s to edit the shop name used on the Front Office.'), '<a href="' . $this->context->link->getAdminLink('AdminStores') . '#store_fieldset_general">', '</a>')), 'name' => 'name', 'required' => true)));
     $display_group_list = true;
     if ($this->display == 'edit') {
         $group = new ShopGroup($obj->id_shop_group);
         if ($group->share_customer || $group->share_order || $group->share_stock) {
             $display_group_list = false;
         }
     }
     if ($display_group_list) {
         $options = array();
         foreach (ShopGroup::getShopGroups() as $group) {
             if ($this->display == 'edit' && ($group->share_customer || $group->share_order || $group->share_stock) && ShopGroup::hasDependency($group->id)) {
                 continue;
             }
             $options[] = array('id_shop_group' => $group->id, 'name' => $group->name);
         }
         if ($this->display == 'add') {
             $group_desc = $this->l('Warning: You won\'t be able to change the group of this shop if this shop belongs to a group with one of these options activated: Share Customers, Share Quantities or Share Orders.');
         } else {
             $group_desc = $this->l('You can only move your shop to a shop group with all "share" options disabled -- or to a shop group with no customers/orders.');
         }
         $this->fields_form['input'][] = array('type' => 'select', 'label' => $this->l('Shop group'), 'desc' => $group_desc, 'name' => 'id_shop_group', 'options' => array('query' => $options, 'id' => 'id_shop_group', 'name' => 'name'));
     } else {
         $this->fields_form['input'][] = array('type' => 'hidden', 'name' => 'id_shop_group', 'default' => $group->name);
         $this->fields_form['input'][] = array('type' => 'textShopGroup', 'label' => $this->l('Shop group'), 'desc' => $this->l('You can\'t edit the shop group because the current shop belongs to a group with the "share" option enabled.'), 'name' => 'id_shop_group', 'value' => $group->name);
     }
     $categories = Category::getRootCategories($this->context->language->id);
     $this->fields_form['input'][] = array('type' => 'select', 'label' => $this->l('Category root'), 'desc' => $this->l('This is the root category of the store that you\'ve created. To define a new root category for your store,') . '&nbsp;<a href="' . $this->context->link->getAdminLink('AdminCategories') . '&addcategoryroot" target="_blank">' . $this->l('Please click here') . '</a>', 'name' => 'id_category', 'options' => array('query' => $categories, 'id' => 'id_category', 'name' => 'name'));
     if (Tools::isSubmit('id_shop')) {
         $shop = new Shop((int) Tools::getValue('id_shop'));
         $id_root = $shop->id_category;
     } else {
         $id_root = $categories[0]['id_category'];
     }
     $id_shop = (int) Tools::getValue('id_shop');
     self::$currentIndex = self::$currentIndex . '&id_shop_group=' . (int) (Tools::getValue('id_shop_group') ? Tools::getValue('id_shop_group') : (isset($obj->id_shop_group) ? $obj->id_shop_group : Shop::getContextShopGroupID()));
     $shop = new Shop($id_shop);
     $selected_cat = Shop::getCategories($id_shop);
     if (empty($selected_cat)) {
         // get first category root and preselect all these children
         $root_categories = Category::getRootCategories();
         $root_category = new Category($root_categories[0]['id_category']);
         $children = $root_category->getAllChildren($this->context->language->id);
         $selected_cat[] = $root_categories[0]['id_category'];
         foreach ($children as $child) {
             $selected_cat[] = $child->id;
         }
     }
     if (Shop::getContext() == Shop::CONTEXT_SHOP && Tools::isSubmit('id_shop')) {
         $root_category = new Category($shop->id_category);
     } else {
         $root_category = new Category($id_root);
     }
     $this->fields_form['input'][] = array('type' => 'categories', 'name' => 'categoryBox', 'label' => $this->l('Associated categories'), 'tree' => array('id' => 'categories-tree', 'selected_categories' => $selected_cat, 'root_category' => $root_category->id, 'use_search' => true, 'use_checkbox' => true), 'desc' => $this->l('By selecting associated categories, you are choosing to share the categories between shops. Once associated between shops, any alteration of this category will impact every shop.'));
     /*$this->fields_form['input'][] = array(
     			'type' => 'switch',
     			'label' => $this->l('Enabled'),
     			'name' => 'active',
     			'required' => true,
     			'is_bool' => true,
     			'values' => array(
     				array(
     					'id' => 'active_on',
     					'value' => 1
     				),
     				array(
     					'id' => 'active_off',
     					'value' => 0
     				)
     			),
     			'desc' => $this->l('Enable or disable your store?')
     		);*/
     $themes = Theme::getThemes();
     if (!isset($obj->id_theme)) {
         foreach ($themes as $theme) {
             if (isset($theme->id)) {
                 $id_theme = $theme->id;
                 break;
             }
         }
     }
     $this->fields_form['input'][] = array('type' => 'theme', 'label' => $this->l('Theme'), 'name' => 'theme', 'values' => $themes);
     $this->fields_form['submit'] = array('title' => $this->l('Save'));
     if (Shop::getTotalShops() > 1 && $obj->id) {
         $disabled = array('active' => false);
     } else {
         $disabled = false;
     }
     $import_data = array('carrier' => $this->l('Carriers'), 'cms' => $this->l('CMS pages'), 'contact' => $this->l('Contact information'), 'country' => $this->l('Countries'), 'currency' => $this->l('Currencies'), 'discount' => $this->l('Discount prices'), 'employee' => $this->l('Employees'), 'image' => $this->l('Images'), 'lang' => $this->l('Languages'), 'manufacturer' => $this->l('Manufacturers'), 'module' => $this->l('Modules'), 'hook_module' => $this->l('Module hooks'), 'meta_lang' => $this->l('Meta'), 'product' => $this->l('Products'), 'product_attribute' => $this->l('Combinations'), 'scene' => $this->l('Scenes'), 'stock_available' => $this->l('Available quantities for sale'), 'store' => $this->l('Stores'), 'warehouse' => $this->l('Warehouses'), 'webservice_account' => $this->l('Webservice accounts'), 'attribute_group' => $this->l('Attribute groups'), 'feature' => $this->l('Features'), 'group' => $this->l('Customer groups'), 'tax_rules_group' => $this->l('Tax rules groups'), 'supplier' => $this->l('Suppliers'), 'referrer' => $this->l('Referrers/affiliates'), 'zone' => $this->l('Zones'), 'cart_rule' => $this->l('Cart rules'));
     // Hook for duplication of shop data
     $modules_list = Hook::getHookModuleExecList('actionShopDataDuplication');
     if (is_array($modules_list) && count($modules_list) > 0) {
         foreach ($modules_list as $m) {
             $import_data['Module' . ucfirst($m['module'])] = Module::getModuleName($m['module']);
         }
     }
     asort($import_data);
     if (!$this->object->id) {
         $this->fields_import_form = array('radio' => array('type' => 'radio', 'label' => $this->l('Import data'), 'name' => 'useImportData', 'value' => 1), 'select' => array('type' => 'select', 'name' => 'importFromShop', 'label' => $this->l('Choose the shop (source)'), 'options' => array('query' => Shop::getShops(false), 'name' => 'name')), 'allcheckbox' => array('type' => 'checkbox', 'label' => $this->l('Choose data to import'), 'values' => $import_data), 'desc' => $this->l('Use this option to associate data (products, modules, etc.) the same way for each selected shop.'));
     }
     $this->fields_value = array('id_shop_group' => Tools::getValue('id_shop_group') ? Tools::getValue('id_shop_group') : isset($obj->id_shop_group) ? $obj->id_shop_group : Shop::getContextShopGroupID(), 'id_category' => Tools::getValue('id_category') ? Tools::getValue('id_category') : isset($obj->id_category) ? $obj->id_category : (int) Configuration::get('PS_HOME_CATEGORY'), 'id_theme_checked' => isset($obj->id_theme) ? $obj->id_theme : $id_theme);
     $ids_category = array();
     $shops = Shop::getShops(false);
     foreach ($shops as $shop) {
         $ids_category[$shop['id_shop']] = $shop['id_category'];
     }
     $this->tpl_form_vars = array('disabled' => $disabled, 'checked' => Tools::getValue('addshop') !== false ? true : false, 'defaultShop' => (int) Configuration::get('PS_SHOP_DEFAULT'), 'ids_category' => $ids_category);
     if (isset($this->fields_import_form)) {
         $this->tpl_form_vars = array_merge($this->tpl_form_vars, array('form_import' => $this->fields_import_form));
     }
     return parent::renderForm();
 }