* @copyright PrestaShop
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @version 1.3
*
*/
include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php');
include_once(PS_ADMIN_DIR.'/tabs/AdminAttributes.php');
class AdminAttributesGroups extends AdminTab
{
/** @var object AdminAttributes() instance */
private $adminAttributes;
public function __construct()
{
$this->adminAttributes = new AdminAttributes();
$this->table = 'attribute_group';
$this->className = 'AttributeGroup';
$this->lang = true;
$this->edit = true;
$this->delete = true;
$this->fieldsDisplay = array(
'name' => array('title' => $this->l('Name'), 'width' => 140),
'attribute' => array('title' => $this->l('Attributes'), 'width' => 240, 'orderby' => false, 'search' => false));
parent::__construct();
}
public function display()
{
global $currentIndex;
if ((isset($_POST['submitAddattribute']) AND sizeof($this->adminAttributes->_errors))
OR isset($_GET['updateattribute']) OR isset($_GET['addattribute']))
{
$this->adminAttributes->displayForm($this->token);
echo '
'.$this->l('Back to list').'
';
}
else
parent::display();
}
public function postProcess()
{
global $cookie, $currentIndex;
$this->adminAttributes->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id);
$this->adminAttributes->postProcess($this->token);
if(Tools::getValue('submitDel'.$this->table))
{
if ($this->tabAccess['delete'] === '1')
{
if (isset($_POST[$this->table.'Box']))
{
$object = new $this->className();
if ($object->deleteSelection($_POST[$this->table.'Box']))
Tools::redirectAdmin($currentIndex.'&conf=2'.'&token='.$this->token);
$this->_errors[] = Tools::displayError('an error occurred while deleting selection');
}
else
$this->_errors[] = Tools::displayError('you must select at least one element to delete');
}
else
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
}
else
parent::postProcess();
}
public function displayErrors()
{
$this->adminAttributes->displayErrors();
parent::displayErrors();
}
/* Report to AdminTab::displayList() for more details */
public function displayList()
{
global $currentIndex, $cookie;
echo '
'.$this->l('Add attributes group').'
'.$this->l('Add attribute').'
'.$this->l('Click on the group name to view its attributes. Click again to hide them.').'
';
if ($this->_list === false)
Tools::displayError('no elements found');
$this->displayListHeader();
echo '';
if (!sizeof($this->_list))
echo '