diff --git a/admin-dev/tabs/AdminGroupShop.php b/admin-dev/tabs/AdminGroupShop.php deleted file mode 100755 index c882e9542..000000000 --- a/admin-dev/tabs/AdminGroupShop.php +++ /dev/null @@ -1,191 +0,0 @@ - -* @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 1.4 $ -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - - -class AdminGroupShop extends AdminTab -{ - - public function __construct() - { - $this->table = 'group_shop'; - $this->className = 'GroupShop'; - $this->edit = true; - $this->delete = false; - $this->deleted = false; - - $this->fieldsDisplay = array( - 'id_group_shop' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), - 'name' => array('title' => $this->l('County'), 'width' => 130, 'filter_key' => 'b!name'), - 'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'active'), - ); - - parent::__construct(); - } - - public function postProcess() - { - if (Tools::isSubmit('delete'.$this->table) OR Tools::isSubmit('status') OR Tools::isSubmit('status'.$this->table)) - { - $object = $this->loadObject(); - if (GroupShop::getTotalGroupShops() == 1) - $this->_errors[] = Tools::displayError('You cannot delete or disable the last groupshop.'); - else if ($object->haveShops()) - $this->_errors[] = Tools::displayError('You cannot delete or disable a groupshop which have this shops using it.'); - - if (sizeof($this->_errors)) - return false; - } - return parent::postProcess(); - } - - public function afterAdd($newGroupShop) - { - if (Tools::getValue('useImportData') && ($importData = Tools::getValue('importData')) && is_array($importData)) - $newGroupShop->copyGroupShopData(Tools::getValue('importFromShop'), $importData); - } - - public function afterUpdate($newGroupShop) - { - if (Tools::getValue('useImportData') && ($importData = Tools::getValue('importData')) && is_array($importData)) - $newGroupShop->copyGroupShopData(Tools::getValue('importFromShop'), $importData); - } - - public function displayForm($isMainTab = true) - { - parent::displayForm($isMainTab); - - if (!($obj = $this->loadObject(true))) - return; - if (Shop::getTotalShops() > 1 AND $obj->id) - $disabled = 'disabled="disabled"'; - else - $disabled = ''; - - echo << - // - -EOF; - - echo ' -
- '.($obj->id ? '' : '').' -
'.$this->l('GroupShop').'
'.$this->l('You can\'t edit GroupShop when you have more than one Shop').'

- -
- -
- -
- getFieldValue($obj, 'share_customer') ? 'checked="checked" ' : '').'/> - - getFieldValue($obj, 'share_customer') ? 'checked="checked" ' : '').'/> - -

'.$this->l('Share customers between shops of this group').'

-
- -
- getFieldValue($obj, 'share_stock') ? 'checked="checked" ' : '').'/> - - getFieldValue($obj, 'share_stock') ? 'checked="checked" ' : '').'/> - -

'.$this->l('Sare stock between shops of this group').'

-
- -
- getFieldValue($obj, 'share_order') ? 'checked="checked" ' : '').'/> - - getFieldValue($obj, 'share_order') ? 'checked="checked" ' : '').'/> - -

'.$this->l('Share orders and carts between shops of this group (you can share orders only if you share customers and stock)').'

-
- -
- getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/> - - getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/> - -

'.$this->l('Enable or disable shop').'

-
-
- -
-
* '.$this->l('Required field').'
-

'; - - $importData = array( - 'attribute_group' => $this->l('Attribute groups'), - 'attribute' => $this->l('Attributes'), - //'customer_group' => $this->l('Customer groups'), - 'feature' => $this->l('Features'), - 'group' => $this->l('Groups'), - 'manufacturer' => $this->l('Manufacturers'), - 'supplier' => $this->l('Suppliers'), - 'tax_rules_group' => $this->l('Tax rules groups'), - 'zone' => $this->l('Zones'), - ); - - $checked = (Tools::getValue('addgroup_shop') !== false) ? true : false; - $defaultGroup = Shop::getInstance(Configuration::get('PS_SHOP_DEFAULT'))->getGroupID(); - echo '
'.$this->l('Import data from another group shop').''; - echo ''; - echo '
'; - echo ' '; - echo $this->l('Duplicate data from group shop'); - echo ' '; - echo '
    '; - foreach ($importData as $table => $lang) - echo '
  • '; - echo '
'; - echo '

'.$this->l('Use this option to associate data (products, modules, etc.) the same way as the selected shop').'

'; - echo '
- -
'; - echo '
'; - echo '
'; - } - - protected function displayAddButton() - { - echo '
'.$this->l('Add new group shop').'

'; - } -} diff --git a/admin-dev/themes/template/adminGroupShop.tpl b/admin-dev/themes/template/adminGroupShop.tpl new file mode 100644 index 000000000..90919a352 --- /dev/null +++ b/admin-dev/themes/template/adminGroupShop.tpl @@ -0,0 +1,113 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 8897 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + +{if isset($tab_form)} + + + +
+ {if $tab_form['id']}{/if} +
+ {l s ='GroupShop'} +
{l s ='You can\'t edit GroupShop when you have more than one Shop'}

+ +
+ +
+ +
+ + + + +

{l s ='Share customers between shops of this group'}

+
+ +
+ + + + +

{l s ='Sare stock between shops of this group'}

+
+ +
+ + + + +

{l s ='Share orders and carts between shops of this group (you can share orders only if you share customers and stock)'}

+
+ +
+ + + + +

{l s ='Enable or disable shop'}

+
+
+ +
+
* {l s ='Required field'}
+

+ +
{l s ='Import data from another group shop'} + +
+ + {l s ='Duplicate data from group shop'} + +
    + {foreach $tab_form['importData'] as $table => $lang} +
  • + {/foreach} +
+

{l s ='Use this option to associate data (products, modules, etc.) the same way as the selected shop'}

+
+ +
+
+
+{/if} + +{$content} \ No newline at end of file diff --git a/controllers/admin/AdminGroupShopController.php b/controllers/admin/AdminGroupShopController.php new file mode 100644 index 000000000..ea0c355ac --- /dev/null +++ b/controllers/admin/AdminGroupShopController.php @@ -0,0 +1,135 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 8971 $ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +class AdminGroupShopControllerCore extends AdminController +{ + public function __construct() + { + $this->table = 'group_shop'; + $this->className = 'GroupShop'; + $this->lang = false; + $this->edit = true; + $this->delete = false; + $this->requiredDatabase = true; + + $this->context = Context::getContext(); + + if (!Tools::getValue('realedit')) + $this->deleted = false; + + $this->fieldsDisplay = array( + 'id_group_shop' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), + 'name' => array('title' => $this->l('County'), 'width' => 130, 'filter_key' => 'b!name'), + 'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'active'), + ); + + $this->template = 'adminGroupShop.tpl'; + + parent::__construct(); + } + + public function postProcess() + { + if (Tools::isSubmit('delete'.$this->table) OR Tools::isSubmit('status') OR Tools::isSubmit('status'.$this->table)) + { + $object = $this->loadObject(); + if (GroupShop::getTotalGroupShops() == 1) + $this->_errors[] = Tools::displayError('You cannot delete or disable the last groupshop.'); + else if ($object->haveShops()) + $this->_errors[] = Tools::displayError('You cannot delete or disable a groupshop which have this shops using it.'); + + if (sizeof($this->_errors)) + return false; + } + return parent::postProcess(); + } + + public function afterAdd($newGroupShop) + { + if (Tools::getValue('useImportData') && ($importData = Tools::getValue('importData')) && is_array($importData)) + $newGroupShop->copyGroupShopData(Tools::getValue('importFromShop'), $importData); + } + + public function afterUpdate($newGroupShop) + { + if (Tools::getValue('useImportData') && ($importData = Tools::getValue('importData')) && is_array($importData)) + $newGroupShop->copyGroupShopData(Tools::getValue('importFromShop'), $importData); + } + + public function displayForm($isMainTab = true) + { + parent::displayForm($isMainTab); + + if (!($obj = $this->loadObject(true))) + return; + + if (Shop::getTotalShops() > 1 AND $obj->id) + $disabled = 'disabled="disabled"'; + else + $disabled = ''; + + $importData = array( + 'attribute_group' => $this->l('Attribute groups'), + 'attribute' => $this->l('Attributes'), + //'customer_group' => $this->l('Customer groups'), + 'feature' => $this->l('Features'), + 'group' => $this->l('Groups'), + 'manufacturer' => $this->l('Manufacturers'), + 'supplier' => $this->l('Suppliers'), + 'tax_rules_group' => $this->l('Tax rules groups'), + 'zone' => $this->l('Zones'), + ); + + $this->context->smarty->assign('tab_form', array( + 'current' => self::$currentIndex, + 'table' => $this->table, + 'token' => $this->token, + 'id' => $obj->id, + 'name' => $this->getFieldValue($obj, 'name'), + 'disabled' => $disabled, + 'share_customer' => $this->getFieldValue($obj, 'share_customer') ? true : false, + 'share_stock' => $this->getFieldValue($obj, 'share_stock') ? true : false, + 'share_order' => $this->getFieldValue($obj, 'share_order') ? true : false, + 'active' => $this->getFieldValue($obj, 'active') ? true : false, + 'importData' => $importData, + 'getTree' => Shop::getTree(), + 'checked' => (Tools::getValue('addgroup_shop') !== false) ? true : false, + 'defaultGroup' => Shop::getInstance(Configuration::get('PS_SHOP_DEFAULT'))->getGroupID() + )); + } + + public function initContent() + { + if ($this->display != 'edit') + $this->display = 'list'; + + parent::initContent(); + } + +} + +