* @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 AdminShop extends AdminTab { public function __construct() { $this->context = Context::getContext(); $this->table = 'shop'; $this->className = 'Shop'; $this->edit = true; $this->delete = false; $this->deleted = false; $this->_select = 'gs.name group_shop_name, cl.name category_name'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'group_shop` gs ON (a.id_group_shop = gs.id_group_shop) LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (a.id_category = cl.id_category AND cl.id_lang='.(int)$this->context->language->id.')'; $this->_group = 'GROUP BY a.id_shop'; $this->fieldsDisplay = array( 'id_shop' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'name' => array('title' => $this->l('Shop'), 'width' => 130, 'filter_key' => 'b!name'), 'group_shop_name' => array('title' => $this->l('Group Shop'), 'width' => 70), 'category_name' => array('title' => $this->l('Category Root'), 'width' => 70), 'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'active'), ); $this->optionsList = array( 'general' => array( 'title' => $this->l('Shops options'), 'fields' => array( 'PS_SHOP_DEFAULT' => array('title' => $this->l('Default shop:'), 'desc' => $this->l('The default shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_shop', 'list' => Shop::getShops(), 'visibility' => Shop::CONTEXT_ALL) ), ), ); parent::__construct(); } public function afterAdd($newShop) { if (Tools::getValue('useImportData') && ($importData = Tools::getValue('importData')) && is_array($importData)) $newShop->copyShopData((int)Tools::getValue('importFromShop'), $importData); } public function afterUpdate($newShop) { if (Tools::getValue('useImportData') && ($importData = Tools::getValue('importData')) && is_array($importData)) $newShop->copyShopData((int)Tools::getValue('importFromShop'), $importData); } public function postProcess() { if ((Tools::isSubmit('status') || Tools::isSubmit('status'.$this->table) || (Tools::isSubmit('submitAdd'.$this->table) && Tools::getValue($this->identifier) && !Tools::getValue('active'))) && $this->loadObject() && $this->loadObject()->active) { if (Tools::getValue('id_shop') == Configuration::get('PS_SHOP_DEFAULT')) $this->_errors[] = Tools::displayError('You cannot disable the default shop.'); else if (Shop::getTotalShops() == 1) $this->_errors[] = Tools::displayError('You cannot disable the last shop.'); } if ($this->_errors) return false; return parent::postProcess(); } public function displayConf() { if ($conf = Tools::getValue('conf')) { if ($conf == 3) echo '
'.$this->l('Your store has been successfully created. To make your store accessible on front office, you must create a URL for your store by clicking on this text.').'
'; else parent::displayConf(); } } public function displayForm($isMainTab = true) { parent::displayForm($isMainTab); if (!($obj = $this->loadObject(true))) return; $disabled = ''; if (Shop::getTotalShops() > 1 && $obj->id) $disabled = 'disabled="disabled"'; echo '
'.($obj->id ? '' : '').'
'.$this->l('Shop').'
'.$this->l('You can\'t change the GroupShop when you have more than one Shop').'

'; if ($disabled) { $groupShop = new GroupShop($obj->id_group_shop); echo $groupShop->name; echo ''; } else { echo ''; } echo '
'; echo '
getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/> getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>

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

'; // Theme list echo '
'; foreach (Theme::getThemes() as $i => $theme) { $checked = ((!$obj->id && $i == 0) || $obj->id_theme == $theme['id_theme']) ? true : false; echo '
'; echo ucfirst($theme['name']).'
'; echo ''.$theme['name'].'
'; echo ''; echo '
'; } echo '
'; echo '
* '.$this->l('Required field').'


'; $importData = array( 'carrier' => $this->l('Carriers'), 'carrier_lang' => $this->l('Carriers lang'), 'category_lang' => $this->l('Category lang'), 'cms' => $this->l('CMS page'), 'contact' => $this->l('Contact'), 'country' => $this->l('Countries'), 'currency' => $this->l('Currencies'), 'discount' => $this->l('Discounts'), 'image' => $this->l('Images'), 'lang' => $this->l('Langs'), 'manufacturer' => $this->l('Manufacturers'), 'module' => $this->l('Modules'), 'hook_module' => $this->l('Modules hook'), 'hook_module_exceptions' => $this->l('Modules hook exceptions'), 'meta_lang' => $this->l('Meta'), 'module_country' => $this->l('Payment module country restrictions'), 'module_group' => $this->l('Payment module customer group restrictions'), 'module_currency' => $this->l('Payment module currency restrictions'), 'product' => $this->l('Products'), 'product_lang' => $this->l('Products lang'), 'scene' => $this->l('Scenes'), 'stock' => $this->l('Stock'), 'store' => $this->l('Stores'), ); $checked = (Tools::getValue('addshop') !== false) ? true : false; echo '
'.$this->l('Import data from another shop').''; echo ''; echo '
'; echo ' '; echo $this->l('Duplicate data from 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 shop').'

'; } }