[*] BO #PSFV-94 : Added AdminEmployeesController
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9536 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -1,273 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 7210 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class AdminEmployees extends AdminTab
|
||||
{
|
||||
/** @var array profiles list */
|
||||
private $profilesArray = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->context = Context::getContext();
|
||||
$this->table = 'employee';
|
||||
$this->className = 'Employee';
|
||||
$this->lang = false;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
$this->_select = 'pl.`name` AS profile';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'profile` p ON a.`id_profile` = p.`id_profile`
|
||||
LEFT JOIN `'._DB_PREFIX_.'profile_lang` pl ON (pl.`id_profile` = p.`id_profile` AND pl.`id_lang` = '.(int)$this->context->language->id.')';
|
||||
|
||||
$profiles = Profile::getProfiles($this->context->language->id);
|
||||
if (!$profiles)
|
||||
$this->_errors[] = Tools::displayError('No profile');
|
||||
else
|
||||
foreach ($profiles as $profile)
|
||||
$this->profilesArray[$profile['name']] = $profile['name'];
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_employee' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'lastname' => array('title' => $this->l('Last name'), 'width' => 130),
|
||||
'firstname' => array('title' => $this->l('First name'), 'width' => 130),
|
||||
'email' => array('title' => $this->l('E-mail address'), 'width' => 180),
|
||||
'profile' => array('title' => $this->l('Profile'), 'width' => 90, 'type' => 'select', 'select' => $this->profilesArray, 'filter_key' => 'pl!name'),
|
||||
'active' => array('title' => $this->l('Can log in'), 'align' => 'center', 'active' => 'status', 'type' => 'bool'),
|
||||
);
|
||||
|
||||
$this->optionsList = array(
|
||||
'general' => array(
|
||||
'title' => $this->l('Employees options'),
|
||||
'fields' => array(
|
||||
'PS_PASSWD_TIME_BACK' => array('title' => $this->l('Password regenerate:'), 'desc' => $this->l('Security minimum time to wait to regenerate a new password'), 'cast' => 'intval', 'size' => 5, 'type' => 'text', 'suffix' => ' '.$this->l('minutes'), 'visibility' => Shop::CONTEXT_ALL),
|
||||
'PS_BO_ALLOW_EMPLOYEE_FORM_LANG' => array('title' => $this->l('Memorize form language:'), 'desc' => $this->l('Allow employees to save their own default form language'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'value', 'list' => array(
|
||||
'0' => array('value' => 0, 'name' => $this->l('No')),
|
||||
'1' => array('value' => 1, 'name' => $this->l('Yes'))
|
||||
), 'visibility' => Shop::CONTEXT_ALL)
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function _childValidation()
|
||||
{
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
return false;
|
||||
$email = $this->getFieldValue($obj, 'email');
|
||||
if (!Validate::isEmail($email))
|
||||
$this->_errors[] = Tools::displayError('Invalid e-mail');
|
||||
else if (Employee::employeeExists($email) && !Tools::getValue('id_employee'))
|
||||
$this->_errors[] = Tools::displayError('An account already exists for this e-mail address:').' '.$email;
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
parent::displayForm();
|
||||
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
return;
|
||||
$profiles = Profile::getProfiles($this->context->language->id);
|
||||
|
||||
echo '<script type="text/javascript" src="'._PS_JS_DIR_.'/jquery/jquery-colorpicker.js"></script>
|
||||
<script type="text/javascript">
|
||||
var employeePage = true;
|
||||
</script>
|
||||
|
||||
|
||||
<form action="'.self::$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.((int)$this->tabAccess['view'] ? '' : '&updateemployee&id_employee='.(int)$obj->id).'" method="post" enctype="multipart/form-data" autocomplete="off">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
'.((int)$this->tabAccess['view'] ? '' : '<input type="hidden" name="back" value="'.self::$currentIndex.'&token='.$this->token.'&updateemployee&id_employee='.(int)$obj->id.'" />').'
|
||||
<fieldset class="width3"><legend><img src="../img/admin/nav-user.gif" />'.$this->l('Employees').'</legend>
|
||||
<label>'.$this->l('Last name:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="lastname" value="'.htmlentities($this->getFieldValue($obj, 'lastname'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
</div>
|
||||
<label>'.$this->l('First name:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="firstname" value="'.htmlentities($this->getFieldValue($obj, 'firstname'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
</div>
|
||||
<label>'.$this->l('Password:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="password" size="33" name="passwd" value="" /> <sup>*</sup>
|
||||
<p>'.($obj->id ? $this->l('Leave blank if you do not want to change your password') : $this->l('Min. 8 characters; use only letters, numbers or').' -_').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('E-mail address:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="email" value="'.htmlentities($this->getFieldValue($obj, 'email'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
</div><div class="clear"> </div>
|
||||
<label>'.$this->l('Back office color:').' </label>
|
||||
<div class="margin-form">';
|
||||
// Note : width= fix Firefox 4 display bug related to colorpicker librarie
|
||||
echo '<input type="color" width="50px" data-hex="true" class="color mColorPickerInput" name="bo_color" value="'.htmlentities($this->getFieldValue($obj, 'bo_color'), ENT_COMPAT, 'UTF-8').'" />
|
||||
<p>'.$this->l('Back office background will be displayed in this color. HTML colors only (e.g.,').' "lightblue", "#CC6600")</p>
|
||||
</div><div class="clear"> </div>
|
||||
<label>'.$this->l('Language:').' </label>
|
||||
<div class="margin-form">
|
||||
<select name="id_lang">';
|
||||
foreach (Language::getLanguages() as $lang)
|
||||
echo ' <option value="'.(int)$lang['id_lang'].'" '.($this->getFieldValue($obj, 'id_lang') == $lang['id_lang'] ? 'selected="selected"' : '').'>'.Tools::htmlentitiesUTF8($lang['name']).'</option>';
|
||||
echo ' </select> <sup>*</sup>
|
||||
</div><div class="clear"> </div>
|
||||
<label>'.$this->l('Theme:').' </label>
|
||||
<div class="margin-form">
|
||||
<select name="bo_theme">';
|
||||
$path = dirname(__FILE__).'/../themes/';
|
||||
foreach (scandir($path) as $theme)
|
||||
if ($theme[0] != '.' && file_exists($path.$theme.'/admin.css'))
|
||||
echo ' <option value="'.Tools::htmlentitiesUTF8($theme).'" '.($this->getFieldValue($obj, 'bo_theme') == $theme ? 'selected="selected"' : '').'>'.Tools::htmlentitiesUTF8($theme).'</option>';
|
||||
echo ' </select> <sup>*</sup>
|
||||
</div>';
|
||||
if ((int)$this->tabAccess['edit'])
|
||||
{
|
||||
echo '<div class="clear"> </div>
|
||||
<label>'.$this->l('UI mode:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="bo_uimode" id="uimode_on" value="hover" '.($this->getFieldValue($obj, 'bo_uimode') == 'hover' ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="uimode_on">'.$this->l('Hover on tabs').'</label>
|
||||
<input type="radio" name="bo_uimode" id="uimode_off" value="click" '.($this->getFieldValue($obj, 'bo_uimode') == 'click' ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="uimode_off">'.$this->l('Click on tabs').'</label>
|
||||
</div><div class="clear"> </div>
|
||||
<label>'.$this->l('Show screencast:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="bo_show_screencast" id="bo_show_screencast_on" value="1" '.($this->getFieldValue($obj, 'bo_show_screencast') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="bo_show_screencast" id="bo_show_screencast_off" value="0" '.(!$this->getFieldValue($obj, 'bo_show_screencast') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('Show the welcome video on the dashbord of the back office').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Status:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="active" id="active_on" value="1" '.($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="active" id="active_off" value="0" '.(!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('Allow or disallow this employee to log into this Back Office').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Profile:').' </label>
|
||||
<div class="margin-form">
|
||||
<select name="id_profile">
|
||||
<option value="">'.$this->l('-- Choose --').'</option>';
|
||||
foreach ($profiles as $profile)
|
||||
echo '<option value="'.$profile['id_profile'].'"'.($profile['id_profile'] === $this->getFieldValue($obj, 'id_profile') ? ' selected="selected"' : '').'>'.$profile['name'].'</option>';
|
||||
echo '</select> <sup>*</sup>
|
||||
</div>';
|
||||
if (Shop::isFeatureActive())
|
||||
{
|
||||
echo '
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$(\'select[name=id_profile]\').change(function(){
|
||||
ifSuperAdmin($(this));
|
||||
});
|
||||
|
||||
ifSuperAdmin($(\'select[name=id_profile]\'));
|
||||
});
|
||||
|
||||
function ifSuperAdmin(el)
|
||||
{
|
||||
var val = $(el).val();
|
||||
if(val == '._PS_ADMIN_PROFILE_.')
|
||||
{
|
||||
$(\'.assoShop input[type=checkbox]\').attr(\'disabled\', \'disabled\');
|
||||
$(\'.assoShop input[type=checkbox]\').attr(\'checked\', \'checked\');
|
||||
}
|
||||
else
|
||||
$(\'.assoShop input[type=checkbox]\').attr(\'disabled\', \'\');
|
||||
}
|
||||
</script>
|
||||
';
|
||||
echo '<label>'.$this->l('Shop association:').'</label><div class="margin-form">';
|
||||
$this->displayAssoShop();
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
echo '<div class="clear"> </div>
|
||||
<center>
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</center><div class="clear"> </div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
$this->context = Context::getContext();
|
||||
if (Tools::isSubmit('deleteemployee') || Tools::isSubmit('status') || Tools::isSubmit('statusemployee'))
|
||||
{
|
||||
/* PrestaShop demo mode */
|
||||
if (_PS_MODE_DEMO_ && $id_employee = Tools::getValue('id_employee') && (int)$id_employee == _PS_DEMO_MAIN_BO_ACCOUNT_)
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('This functionnality has been disabled.');
|
||||
return;
|
||||
}
|
||||
/* PrestaShop demo mode*/
|
||||
|
||||
if ($this->context->employee->id == Tools::getValue('id_employee'))
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('You cannot disable or delete your own account.');
|
||||
return false;
|
||||
}
|
||||
|
||||
$employee = new Employee(Tools::getValue('id_employee'));
|
||||
if ($employee->isLastAdmin())
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('You cannot disable or delete the last administrator account.');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (Tools::isSubmit('submitAddemployee'))
|
||||
{
|
||||
$employee = new Employee((int)Tools::getValue('id_employee'));
|
||||
if (!(int)$this->tabAccess['edit'])
|
||||
$_POST['id_profile'] = $_GET['id_profile'] = $employee->id_profile;
|
||||
|
||||
if ($employee->isLastAdmin())
|
||||
{
|
||||
if (Tools::getValue('id_profile') != (int)_PS_ADMIN_PROFILE_)
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('You should have at least one employee in the administrator group.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Tools::getvalue('active') == 0)
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('You cannot disable or delete the last administrator account.');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$assos = self::getAssoShop($this->table);
|
||||
|
||||
if (count($assos[0]) == 0 && $this->table = 'employee')
|
||||
if (Shop::isFeatureActive() && _PS_ADMIN_PROFILE_ != $_POST['id_profile'])
|
||||
$this->_errors[] = Tools::displayError('The employee must be associated with at least one shop');
|
||||
}
|
||||
return parent::postProcess();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,321 @@
|
||||
{*
|
||||
* 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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 8971 $
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
{if $firstCall}
|
||||
<script type="text/javascript">
|
||||
var vat_number = {$vat_number};
|
||||
var module_dir = '{$module_dir}';
|
||||
var id_language = {$defaultFormLanguage};
|
||||
var languages = new Array();
|
||||
var employeePage = true;
|
||||
|
||||
$(document).ready(function() {ldelim}
|
||||
{foreach $languages as $k => $language}
|
||||
languages[{$k}] = {ldelim}
|
||||
id_lang: {$language.id_lang},
|
||||
iso_code: '{$language.iso_code}',
|
||||
name: '{$language.name}'
|
||||
{rdelim};
|
||||
{/foreach}
|
||||
displayFlags(languages, id_language, {$allowEmployeeFormLang});
|
||||
|
||||
{if isset($fields_value.id_state)}
|
||||
if ($('#id_country') && $('#id_state'))
|
||||
{ldelim}
|
||||
ajaxStates({$fields_value.id_state});
|
||||
$('#id_country').change(function() {ldelim}
|
||||
ajaxStates();
|
||||
{rdelim});
|
||||
{rdelim}
|
||||
{/if}
|
||||
{rdelim});
|
||||
</script>
|
||||
<script type="text/javascript" src="../js/form.js"></script>
|
||||
{/if}
|
||||
{if isset($fields.title)}<h2>{$fields.title}</h2>{/if}
|
||||
<form action="{$current}&{$submit_action}=1&token={$token}" method="post" enctype="multipart/form-data">
|
||||
{if $form_id}
|
||||
<input type="hidden" name="id_{$table}" value="{$form_id}" />
|
||||
{/if}
|
||||
<fieldset>
|
||||
{foreach $fields as $key => $field}
|
||||
{if $key == 'legend'}
|
||||
<legend>
|
||||
{if isset($field.image)}<img src="{$field.image}" alt="{$field.title}" />{/if}
|
||||
{$field.title}
|
||||
</legend>
|
||||
{elseif $key == 'input'}
|
||||
{foreach $field as $input}
|
||||
{if $input.name == 'id_state'}
|
||||
<div id="contains_states" {if $contains_states}style="display:none;"{/if}>
|
||||
{/if}
|
||||
{if isset($input.label)}
|
||||
<label>{$input.label} </label>
|
||||
{/if}
|
||||
{if $input.type == 'hidden'}
|
||||
<input type="hidden" name="{$input.name}" value="{$fields_value[$input.name]}" />
|
||||
{else}
|
||||
<div class="margin-form">
|
||||
{if $input.type == 'text'}
|
||||
{if isset($input.lang) && isset($input.attributeLang)}
|
||||
{foreach $languages as $language}
|
||||
<div id="{$input.name}_{$language.id_lang}" style="display:{if $language.id_lang == $defaultFormLanguage}block{else}none{/if}; float: left;">
|
||||
<input type="text"
|
||||
name="{$input.name}_{$language.id_lang}"
|
||||
value="{$fields_value[$input.name][$language.id_lang]}"
|
||||
{if isset($input.size)}size="{$input.size}"{/if}
|
||||
{if isset($input.maxlength)}maxlength="{$input.maxlength}"{/if}
|
||||
{if isset($input.class)}class="{$input.class}"{/if}
|
||||
{if isset($input.readonly) && $input.readonly}readonly="readonly"{/if}
|
||||
{if isset($input.disabled) && $input.disabled}disabled="disabled"{/if} />
|
||||
{if isset($input.hint)}<span class="hint" name="help_box">{$input.hint}<span class="hint-pointer"> </span></span>{/if}
|
||||
</div>
|
||||
{/foreach}
|
||||
{if count($languages) > 1}
|
||||
<div class="displayed_flag">
|
||||
<img src="../img/l/{$defaultFormLanguage}.jpg"
|
||||
class="pointer"
|
||||
id="language_current_{$input.name}"
|
||||
onclick="toggleLanguageFlags(this);" />
|
||||
</div>
|
||||
<div id="languages_{$input.name}" class="language_flags">
|
||||
{l s='Choose language:'}<br /><br />
|
||||
{foreach $languages as $language}
|
||||
<img src="../img/l/{$language.id_lang}.jpg"
|
||||
class="pointer"
|
||||
alt="{$language.name}"
|
||||
title="{$language.name}"
|
||||
onclick="changeLanguage('{$input.name}', '{$input.attributeLang}', {$language.id_lang}, '{$language.iso_code}');" />
|
||||
{/foreach}
|
||||
</div>
|
||||
{/if}
|
||||
{else}
|
||||
<input type="text"
|
||||
name="{$input.name}"
|
||||
id="{$input.name}"
|
||||
value="{$fields_value[$input.name]}"
|
||||
{if isset($input.size)}size="{$input.size}"{/if}
|
||||
{if isset($input.maxlength)}maxlength="{$input.maxlength}"{/if}
|
||||
{if isset($input.class)}class="{$input.class}"{/if}
|
||||
{if isset($input.readonly) && $input.readonly}readonly="readonly"{/if}
|
||||
{if isset($input.disabled) && $input.disabled}disabled="disabled"{/if} />
|
||||
{if isset($input.hint)}<span class="hint" name="help_box">{$input.hint}<span class="hint-pointer"> </span></span>{/if}
|
||||
{/if}
|
||||
{elseif $input.type == 'select'}
|
||||
<select name="{$input.name}" id="{$input.name}" {if isset($input.multiple)}multiple="multiple" {/if}{if isset($input.onchange)}onchange="{$input.onchange}"{/if}>
|
||||
{if isset($input.options.default)}
|
||||
<option value="{$input.options.default.value}">{$input.options.default.label}</option>
|
||||
{/if}
|
||||
{if isset($input.options.optiongroup)}
|
||||
{foreach $input.options.optiongroup.query AS $optiongroup}
|
||||
<optgroup label="{$optiongroup[$input.options.optiongroup.label]}">
|
||||
{foreach $optiongroup[$input.options.options.query] as $option}
|
||||
<option value="{$option[$input.options.options.id]}"
|
||||
{if isset($input.multiple)}
|
||||
{foreach $fields_value[$input.name] as $field_value}
|
||||
{if $field_value == $option[$input.options.options.id]}selected="selected"{/if}
|
||||
{/foreach}
|
||||
{else}
|
||||
{if $fields_value[$input.name] == $option[$input.options.options.id]}selected="selected"{/if}
|
||||
{/if}
|
||||
>{$option[$input.options.options.name]|escape:'htmlall':'UTF-8'}</option>
|
||||
{/foreach}
|
||||
</optgroup>
|
||||
{/foreach}
|
||||
{else}
|
||||
{foreach $input.options.query AS $option}
|
||||
{if $input.name == 'bo_theme'}
|
||||
<option value="{$option}"
|
||||
{if isset($input.multiple)}
|
||||
{foreach $fields_value[$input.name] as $field_value}
|
||||
{$field_value}
|
||||
{if $field_value == $option}selected="selected"{/if}
|
||||
{/foreach}
|
||||
{else}
|
||||
{if $fields_value[$input.name] == $option}selected="selected"{/if}
|
||||
{/if}
|
||||
>{$option|escape:'htmlall':'UTF-8'}</option>
|
||||
{else}
|
||||
<option value="{$option[$input.options.id]}"
|
||||
{if isset($input.multiple)}
|
||||
{foreach $fields_value[$input.name] as $field_value}
|
||||
{$field_value}
|
||||
{if $field_value == $option[$input.options.id]}selected="selected"{/if}
|
||||
{/foreach}
|
||||
{else}
|
||||
{if $fields_value[$input.name] == $option[$input.options.id]}selected="selected"{/if}
|
||||
{/if}
|
||||
>{$option[$input.options.name]|escape:'htmlall':'UTF-8'}</option>
|
||||
{/if}
|
||||
{/foreach}
|
||||
{/if}
|
||||
</select>
|
||||
{if isset($input.hint)}<span class="hint" name="help_box">{$input.hint}<span class="hint-pointer"> </span></span>{/if}
|
||||
{elseif $input.type == 'radio'}
|
||||
{foreach $input.values as $value}
|
||||
<input type="radio"
|
||||
name="{$input.name}"
|
||||
id="{$value.id}"
|
||||
value="{$value.value|escape:'htmlall':'UTF-8'}"
|
||||
{if $fields_value[$input.name] == $value.value}checked="checked"{/if} />
|
||||
<label {if isset($input.class)}class="{$input.class}"{/if} for="{$value.id}">
|
||||
{if isset($input.is_bool) && $input.is_bool == true}
|
||||
{if $value.value == 1}
|
||||
<img src="../img/admin/enabled.gif" alt="{$value.label}" title="{$value.label}" />
|
||||
{else}
|
||||
<img src="../img/admin/disabled.gif" alt="{$value.label}" title="{$value.label}" />
|
||||
{/if}
|
||||
{else}
|
||||
{$value.label}
|
||||
{/if}
|
||||
</label>
|
||||
{if isset($input.br) && $input.br}<br />{/if}
|
||||
{/foreach}
|
||||
{elseif $input.type == 'textarea'}
|
||||
{if isset($input.lang) && isset($input.attributeLang)}
|
||||
{foreach $languages as $language}
|
||||
<div id="{$input.name}_{$language.id_lang}" style="display:{if $language.id_lang == $defaultFormLanguage}block{else}none{/if}; float: left;">
|
||||
<textarea cols="{$input.cols}" rows="{$input.rows}" name="{$input.name}_{$language.id_lang}">{$fields_value[$input.name][$language.id_lang]}</textarea>
|
||||
</div>
|
||||
{/foreach}
|
||||
{if count($languages) > 1}
|
||||
<div class="displayed_flag">
|
||||
<img src="../img/l/{$defaultFormLanguage}.jpg"
|
||||
class="pointer"
|
||||
id="language_current_{$input.name}"
|
||||
onclick="toggleLanguageFlags(this);" />
|
||||
</div>
|
||||
<div id="languages_{$input.name}" class="language_flags">
|
||||
{l s='Choose language:'}<br /><br />
|
||||
{foreach $languages as $language}
|
||||
<img src="../img/l/{$language.id_lang}.jpg"
|
||||
class="pointer"
|
||||
alt="{$language.name}"
|
||||
title="{$language.name}"
|
||||
onclick="changeLanguage('{$input.name}', '{$input.attributeLang}', {$language.id_lang}, '{$language.iso_code}');" />
|
||||
{/foreach}
|
||||
</div>
|
||||
{/if}
|
||||
{else}
|
||||
<textarea name="{$input.name}" id="{$input.name}" cols="{$input.cols}" rows="{$input.rows}">{$fields_value[$input.name]}</textarea>
|
||||
{/if}
|
||||
{elseif $input.type == 'checkbox'}
|
||||
{foreach $input.values.query as $value}
|
||||
{assign var=id_checkbox value=$input.name|cat:'_'|cat:$value[$input.values.id]}
|
||||
<input type="checkbox" name="{$id_checkbox}" id="{$id_checkbox}" {if $fields_value[$id_checkbox]}checked="checked"{/if} />
|
||||
<label for="{$id_checkbox}" class="t"><strong>{$value[$input.values.name]}</strong></label><br />
|
||||
{/foreach}
|
||||
{elseif $input.type == 'file'}
|
||||
<input type="file" name="{$input.name}" />
|
||||
<img src="{$fields_value[$input.name]}" />
|
||||
{elseif $input.type == 'password'}
|
||||
<input type="password"
|
||||
name="{$input.name}"
|
||||
size="{$input.size}"
|
||||
value="" />
|
||||
{elseif $input.type == 'group'}
|
||||
{assign var=groups value=$input.values}
|
||||
{include file='form_group.tpl'}
|
||||
{elseif $input.type == 'shop' OR $input.type == 'group_shop'}
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('select[name=id_profile]').change(function(){
|
||||
ifSuperAdmin($(this));
|
||||
});
|
||||
|
||||
ifSuperAdmin($('select[name=id_profile]'));
|
||||
});
|
||||
|
||||
function ifSuperAdmin(el)
|
||||
{
|
||||
var val = $(el).val();
|
||||
if(val == {$_PS_ADMIN_PROFILE_})
|
||||
{
|
||||
$('.assoShop input[type=checkbox]').attr('disabled', 'disabled');
|
||||
$('.assoShop input[type=checkbox]').attr('checked', 'checked');
|
||||
}
|
||||
else
|
||||
$('.assoShop input[type=checkbox]').attr('disabled', '');
|
||||
}
|
||||
</script>
|
||||
{include file='form_shop.tpl'}
|
||||
{elseif $input.type == 'asso_shop' && isset($asso_shop) && $asso_shop}
|
||||
<label>{l s='Shop association:'}</label>
|
||||
<div class="margin-form">
|
||||
{$asso_shop}
|
||||
</div>
|
||||
{elseif $input.type == 'color'}
|
||||
<script type="text/javascript" src="../js/jquery/jquery-colorpicker.js"></script>
|
||||
<input type="color"
|
||||
size="{$input.size}"
|
||||
data-hex="true"
|
||||
class="{$input.class}"
|
||||
name="{$input.name}"
|
||||
value="{$fields_value[$input.name]}" />
|
||||
{/if}
|
||||
{if isset($input.required) && $input.required} <sup>*</sup>{/if}
|
||||
{if isset($input.p)}
|
||||
<p class="clear">
|
||||
{if is_array($input.p)}
|
||||
{foreach $input.p as $p}
|
||||
{if is_array($p)}
|
||||
<span id="{$p.id}">{$p.text}</span><br />
|
||||
{else}
|
||||
{$p}<br />
|
||||
{/if}
|
||||
{/foreach}
|
||||
{else}
|
||||
{$input.p}
|
||||
{/if}
|
||||
</p>
|
||||
{/if}
|
||||
{if isset($languages)}<div class="clear"></div>{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{if $input.name == 'id_state'}
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
{elseif $key == 'submit'}
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="{$field.title}" name="{$submit_action}" {if isset($field.class)}class="{$field.class}"{/if} />
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
{if $required_fields}
|
||||
<div class="small"><sup>*</sup> {l s ='Required field'}</div>
|
||||
{/if}
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<br /><br />
|
||||
{if $firstCall && !$no_back}
|
||||
{if $back}
|
||||
<a href="{$back}"><img src="../img/admin/arrow2.gif" />{l s='Back'}</a>
|
||||
{else}
|
||||
<a href="{$current}&token={$token}"><img src="../img/admin/arrow2.gif" />{l s='Back to list'}</a>
|
||||
{/if}
|
||||
<br />
|
||||
{/if}
|
||||
@@ -217,6 +217,11 @@
|
||||
{elseif $input.type == 'file'}
|
||||
<input type="file" name="{$input.name}" />
|
||||
<img src="{$fields_value[$input.name]}" />
|
||||
{elseif $input.type == 'password'}
|
||||
<input type="password"
|
||||
name="{$input.name}"
|
||||
size="{$input.size}"
|
||||
value="" />
|
||||
{elseif $input.type == 'group'}
|
||||
{assign var=groups value=$input.values}
|
||||
{include file='form_group.tpl'}
|
||||
|
||||
@@ -1790,6 +1790,34 @@ class AdminControllerCore extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with selected shops and type (group or boutique shop)
|
||||
*
|
||||
* @param string $table
|
||||
* @param int $id_object
|
||||
*/
|
||||
protected static function getAssoShop($table, $id_object = false)
|
||||
{
|
||||
$shopAsso = Shop::getAssoTables();
|
||||
$groupShopAsso = GroupShop::getAssoTables();
|
||||
if (isset($shopAsso[$table]) && $shopAsso[$table]['type'] == 'shop')
|
||||
$type = 'shop';
|
||||
else if (isset($groupShopAsso[$table]) && $groupShopAsso[$table]['type'] == 'group_shop')
|
||||
$type = 'group_shop';
|
||||
else
|
||||
return;
|
||||
|
||||
$assos = array();
|
||||
foreach ($_POST as $k => $row)
|
||||
{
|
||||
if (!preg_match('/^checkBox'.Tools::toCamelCase($type, true).'Asso_'.$table.'_([0-9]+)?_([0-9]+)$/Ui', $k, $res))
|
||||
continue;
|
||||
$id_asso_object = (!empty($res[1]) ? $res[1] : $id_object);
|
||||
$assos[] = array('id_object' => (int)$id_asso_object, 'id_'.$type => (int)$res[2]);
|
||||
}
|
||||
return array($assos, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the associations of shops
|
||||
*
|
||||
|
||||
@@ -0,0 +1,366 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @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 AdminEmployeesControllerCore extends AdminController
|
||||
{
|
||||
/** @var array profiles list */
|
||||
private $profiles_array = array();
|
||||
|
||||
/** @var array themes list*/
|
||||
private $themes = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'employee';
|
||||
$this->className = 'Employee';
|
||||
$this->lang = false;
|
||||
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('delete');
|
||||
|
||||
$this->requiredDatabase = true;
|
||||
|
||||
$this->context = Context::getContext();
|
||||
|
||||
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
|
||||
|
||||
$profiles = Profile::getProfiles($this->context->language->id);
|
||||
if (!$profiles)
|
||||
$this->_errors[] = Tools::displayError('No profile');
|
||||
else
|
||||
foreach ($profiles as $profile)
|
||||
$this->profiles_array[$profile['name']] = $profile['name'];
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_employee' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'lastname' => array('title' => $this->l('Last name'), 'width' => 130),
|
||||
'firstname' => array('title' => $this->l('First name'), 'width' => 130),
|
||||
'email' => array('title' => $this->l('E-mail address'), 'width' => 180),
|
||||
'profile' => array('title' => $this->l('Profile'), 'width' => 90, 'type' => 'select', 'select' => $this->profiles_array, 'filter_key' => 'pl!name'),
|
||||
'active' => array('title' => $this->l('Can log in'), 'align' => 'center', 'active' => 'status', 'type' => 'bool'),
|
||||
);
|
||||
|
||||
$this->options = array(
|
||||
'general' => array(
|
||||
'title' => $this->l('Employees options'),
|
||||
'fields' => array(
|
||||
'PS_PASSWD_TIME_BACK' => array(
|
||||
'title' => $this->l('Password regenerate:'),
|
||||
'desc' => $this->l('Security minimum time to wait to regenerate a new password'),
|
||||
'cast' => 'intval',
|
||||
'size' => 5,
|
||||
'type' => 'text',
|
||||
'suffix' => ' '.$this->l('minutes'),
|
||||
'visibility' => Shop::CONTEXT_ALL
|
||||
),
|
||||
'PS_BO_ALLOW_EMPLOYEE_FORM_LANG' => array(
|
||||
'title' => $this->l('Memorize form language:'),
|
||||
'desc' => $this->l('Allow employees to save their own default form language'),
|
||||
'cast' => 'intval',
|
||||
'type' => 'select',
|
||||
'identifier' => 'value',
|
||||
'list' => array(
|
||||
'0' => array('value' => 0, 'name' => $this->l('No')),
|
||||
'1' => array('value' => 1, 'name' => $this->l('Yes')
|
||||
)
|
||||
), 'visibility' => Shop::CONTEXT_ALL)
|
||||
),
|
||||
'submit' => array()
|
||||
)
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function initList()
|
||||
{
|
||||
$this->_select = 'pl.`name` AS profile';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'profile` p ON a.`id_profile` = p.`id_profile`
|
||||
LEFT JOIN `'._DB_PREFIX_.'profile_lang` pl ON (pl.`id_profile` = p.`id_profile` AND pl.`id_lang` = '.(int)$this->context->language->id.')';
|
||||
|
||||
parent::initList();
|
||||
}
|
||||
|
||||
public function initForm()
|
||||
{
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
return;
|
||||
|
||||
$path = _PS_ADMIN_DIR_.'/themes/';
|
||||
foreach (scandir($path) as $theme)
|
||||
if (file_exists($path.$theme.'/admin.css'))
|
||||
$this->themes[] = $theme;
|
||||
|
||||
$this->fields_form = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Employees'),
|
||||
'image' => '../img/admin/nav-user.gif'
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Last name:'),
|
||||
'name' => 'lastname',
|
||||
'size' => 33,
|
||||
'required' => true
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('First name:'),
|
||||
'name' => 'firstname',
|
||||
'size' => 33,
|
||||
'required' => true
|
||||
),
|
||||
array(
|
||||
'type' => 'password',
|
||||
'label' => $this->l('Password:'),
|
||||
'name' => 'passwd',
|
||||
'required' => true,
|
||||
'size' => 33,
|
||||
'p' => ($obj->id ?
|
||||
$this->l('Leave blank if you do not want to change your password') :
|
||||
$this->l('Min. 8 characters; use only letters, numbers or').' -_')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('E-mail address:'),
|
||||
'name' => 'email',
|
||||
'size' => 33,
|
||||
'required' => true
|
||||
),
|
||||
array(
|
||||
'type' => 'color',
|
||||
'label' => $this->l('Back office color:'),
|
||||
'name' => 'bo_color',
|
||||
'class' => 'color mColorPickerInput',
|
||||
'size' => 20,
|
||||
'p' => $this->l('Back office background will be displayed in this color. HTML colors only (e.g.,').' "lightblue", "#CC6600")'
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Language:'),
|
||||
'name' => 'id_lang',
|
||||
'required' => true,
|
||||
'options' => array(
|
||||
'query' => Language::getLanguages(),
|
||||
'id' => 'id_lang',
|
||||
'name' => 'name'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Theme:'),
|
||||
'name' => 'bo_theme',
|
||||
'options' => array('query' => $this->themes),
|
||||
'p' => $this->l('Out-of-range behavior when none is defined (e.g., when a customer\'s cart weight is greater than the highest range limit)')
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((int)$this->tabAccess['edit'])
|
||||
{
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('UI mode:'),
|
||||
'name' => 'bo_uimode',
|
||||
'required' => false,
|
||||
'class' => 't',
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'uimode_on',
|
||||
'value' => 'hover',
|
||||
'label' => $this->l('Hover on tabs')
|
||||
),
|
||||
array(
|
||||
'id' => 'uimode_off',
|
||||
'value' => 'click',
|
||||
'label' => $this->l('Click on tabs')
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Show screencast:'),
|
||||
'name' => 'bo_show_screencast',
|
||||
'required' => false,
|
||||
'class' => 't',
|
||||
'is_bool' => true,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'bo_show_screencast_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'bo_show_screencast_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
'p' => $this->l('Show the welcome video on the dashbord of the back office')
|
||||
);
|
||||
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Status:'),
|
||||
'name' => 'active',
|
||||
'required' => false,
|
||||
'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')
|
||||
)
|
||||
),
|
||||
'p' => $this->l('Allow or disallow this employee to log into this Back Office')
|
||||
);
|
||||
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Profile:'),
|
||||
'name' => 'id_profile',
|
||||
'required' => true,
|
||||
'options' => array(
|
||||
'query' => Profile::getProfiles($this->context->language->id),
|
||||
'id' => 'id_profile',
|
||||
'name' => 'name',
|
||||
'default' => array(
|
||||
'value' => '',
|
||||
'label' => $this->l('-- Choose --')
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if (Shop::isFeatureActive())
|
||||
{
|
||||
$this->context->smarty->assign('_PS_ADMIN_PROFILE_', (int)_PS_ADMIN_PROFILE_);
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'shop',
|
||||
'label' => $this->l('Shop association:'),
|
||||
'name' => 'checkBoxShopAsso',
|
||||
'values' => Shop::getTree()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->fields_form['submit'] = array(
|
||||
'title' => $this->l(' Save '),
|
||||
'class' => 'button'
|
||||
);
|
||||
|
||||
$this->fields_value['passwd'] = false;
|
||||
|
||||
//Added values of object Shop
|
||||
if ($obj->id)
|
||||
{
|
||||
$assos = array();
|
||||
$sql = 'SELECT `id_shop`, `'.pSQL($this->identifier).'`
|
||||
FROM `'._DB_PREFIX_.pSQL($this->table).'_shop`
|
||||
WHERE `'.pSQL($this->identifier).'` = '.(int)$obj->id;
|
||||
foreach (Db::getInstance()->executeS($sql) as $row)
|
||||
$this->fields_value['shop'][$row['id_shop']][] = $row[$this->identifier];
|
||||
}
|
||||
|
||||
parent::initForm();
|
||||
}
|
||||
|
||||
protected function _childValidation()
|
||||
{
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
return false;
|
||||
$email = $this->getFieldValue($obj, 'email');
|
||||
if (!Validate::isEmail($email))
|
||||
$this->_errors[] = Tools::displayError('Invalid e-mail');
|
||||
else if (Employee::employeeExists($email) && !Tools::getValue('id_employee'))
|
||||
$this->_errors[] = Tools::displayError('An account already exists for this e-mail address:').' '.$email;
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (Tools::isSubmit('deleteemployee') || Tools::isSubmit('status') || Tools::isSubmit('statusemployee'))
|
||||
{
|
||||
/* PrestaShop demo mode */
|
||||
if (_PS_MODE_DEMO_ && $id_employee = Tools::getValue('id_employee') && (int)$id_employee == _PS_DEMO_MAIN_BO_ACCOUNT_)
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('This functionnality has been disabled.');
|
||||
return;
|
||||
}
|
||||
/* PrestaShop demo mode*/
|
||||
|
||||
if ($this->context->employee->id == Tools::getValue('id_employee'))
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('You cannot disable or delete your own account.');
|
||||
return false;
|
||||
}
|
||||
|
||||
$employee = new Employee(Tools::getValue('id_employee'));
|
||||
if ($employee->isLastAdmin())
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('You cannot disable or delete the last administrator account.');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (Tools::isSubmit('submitAddemployee'))
|
||||
{
|
||||
$employee = new Employee((int)Tools::getValue('id_employee'));
|
||||
if (!(int)$this->tabAccess['edit'])
|
||||
$_POST['id_profile'] = $_GET['id_profile'] = $employee->id_profile;
|
||||
|
||||
if ($employee->isLastAdmin())
|
||||
{
|
||||
if (Tools::getValue('id_profile') != (int)_PS_ADMIN_PROFILE_)
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('You should have at least one employee in the administrator group.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Tools::getvalue('active') == 0)
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('You cannot disable or delete the last administrator account.');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$assos = self::getAssoShop($this->table);
|
||||
|
||||
if (count($assos[0]) == 0 && $this->table = 'employee')
|
||||
if (Shop::isFeatureActive() && _PS_ADMIN_PROFILE_ != $_POST['id_profile'])
|
||||
$this->_errors[] = Tools::displayError('The employee must be associated with at least one shop');
|
||||
}
|
||||
return parent::postProcess();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user