* @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() { global $cookie; $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)$cookie->id_lang.')'; $this->_group = 'GROUP BY 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->optionTitle = $this->l('Shops options'); $this->_fieldsOptions = 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)) { $shop = new Shop((int)$newShop->id); $shop->copyShopData((int)Tools::getValue('importFromShop'), $importData); } } public function postProcess() { if (Tools::isSubmit('delete'.$this->table) OR ((Tools::isSubmit('status') OR Tools::isSubmit('status'.$this->table)) && $this->loadObject()->active)) { if (Shop::getTotalShops() == 1) { $this->_errors[] = Tools::displayError('You cannot delete or disable the last shop.'); return false; } } return parent::postProcess(); } public function displayForm($isMainTab = true) { global $currentIndex, $cookie; parent::displayForm($isMainTab); if (!($obj = $this->loadObject(true))) return; if (Shop::getTotalShops() > 1 AND $obj->id) $disabled = 'disabled="disabled"'; else $disabled = ''; echo '
'; } }