diff --git a/admin-dev/themes/default/template/header.tpl b/admin-dev/themes/default/template/header.tpl index c7e4faea4..ff32ec514 100644 --- a/admin-dev/themes/default/template/header.tpl +++ b/admin-dev/themes/default/template/header.tpl @@ -334,6 +334,7 @@
diff --git a/classes/Employee.php b/classes/Employee.php index b09e4449c..3ee83a2dd 100644 --- a/classes/Employee.php +++ b/classes/Employee.php @@ -126,6 +126,8 @@ class EmployeeCore extends ObjectModel if ($this->id) $this->associated_shops = $this->getAssociatedShops(); + + $this->image_dir = _PS_EMPLOYEE_IMG_DIR_; } /** @@ -347,4 +349,11 @@ class EmployeeCore extends ObjectModel { return $this->id_profile == _PS_ADMIN_PROFILE_; } + + public function getImage() + { + if (!isset($this->id) || empty($this->id) || !file_exists($this->image_dir.$this->id.'.jpg')) + return _PS_IMG_DIR_.'prestashop-avatar.png'; + return $this->image_dir.$this->id.'.jpg'; + } } diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 796638e29..96a52cf09 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -1529,6 +1529,7 @@ class AdminControllerCore extends Controller 'tabs' => $tabs, 'is_multishop' => $is_multishop, 'multishop_context' => $this->multishop_context, + 'employee_avatar' => ImageManager::thumbnail($this->context->employee->getImage(), 'employee'.'_'.(int)$this->context->employee->id.'.'.$this->imageType, 150, $this->imageType, true, true) )); } $this->context->smarty->assign(array( diff --git a/config/defines.inc.php b/config/defines.inc.php index 9a19f3641..13e590314 100755 --- a/config/defines.inc.php +++ b/config/defines.inc.php @@ -55,44 +55,48 @@ if (!defined('PHP_VERSION_ID')) /* Directories */ define('_PS_ROOT_DIR_', realpath($currentDir.'/..')); -define('_PS_CLASS_DIR_', _PS_ROOT_DIR_.'/classes/'); -define('_PS_CONTROLLER_DIR_', _PS_ROOT_DIR_.'/controllers/'); -define('_PS_FRONT_CONTROLLER_DIR_', _PS_ROOT_DIR_.'/controllers/front/'); -define('_PS_ADMIN_CONTROLLER_DIR_', _PS_ROOT_DIR_.'/controllers/admin/'); -define('_PS_OVERRIDE_DIR_', _PS_ROOT_DIR_.'/override/'); -define('_PS_TRANSLATIONS_DIR_', _PS_ROOT_DIR_.'/translations/'); -define('_PS_DOWNLOAD_DIR_', _PS_ROOT_DIR_.'/download/'); -define('_PS_MAIL_DIR_', _PS_ROOT_DIR_.'/mails/'); -define('_PS_PDF_DIR_', _PS_ROOT_DIR_.'/pdf/'); define('_PS_ALL_THEMES_DIR_', _PS_ROOT_DIR_.'/themes/'); -define('_PS_IMG_DIR_', _PS_ROOT_DIR_.'/img/'); -if (!defined('_PS_MODULE_DIR_')) - define('_PS_MODULE_DIR_', _PS_ROOT_DIR_.'/modules/'); -define('_PS_CAT_IMG_DIR_', _PS_IMG_DIR_.'c/'); -define('_PS_STORE_IMG_DIR_', _PS_IMG_DIR_.'st/'); -define('_PS_PROD_IMG_DIR_', _PS_IMG_DIR_.'p/'); -define('_PS_SCENE_IMG_DIR_', _PS_IMG_DIR_.'scenes/'); -define('_PS_SCENE_THUMB_IMG_DIR_', _PS_IMG_DIR_.'scenes/thumbs/'); -define('_PS_MANU_IMG_DIR_', _PS_IMG_DIR_.'m/'); -define('_PS_SHIP_IMG_DIR_', _PS_IMG_DIR_.'s/'); -define('_PS_ORDER_STATE_IMG_DIR_', _PS_IMG_DIR_.'os/'); -define('_PS_LANG_IMG_DIR_', _PS_IMG_DIR_.'l/'); -define('_PS_SUPP_IMG_DIR_', _PS_IMG_DIR_.'su/'); -define('_PS_COL_IMG_DIR_', _PS_IMG_DIR_.'co/'); -define('_PS_TMP_IMG_DIR_', _PS_IMG_DIR_.'tmp/'); -define('_PS_UPLOAD_DIR_', _PS_ROOT_DIR_.'/upload/'); -define('_PS_TOOL_DIR_', _PS_ROOT_DIR_.'/tools/'); -define('_PS_GEOIP_DIR_', _PS_TOOL_DIR_.'geoip/'); -define('_PS_SWIFT_DIR_', _PS_TOOL_DIR_.'swift/'); -define('_PS_GENDERS_DIR_', _PS_IMG_DIR_.'genders/'); -define('_PS_FPDF_PATH_', _PS_TOOL_DIR_.'fpdf/'); // @deprecated will be removed in 1.6 -define('_PS_TCPDF_PATH_', _PS_TOOL_DIR_.'tcpdf/'); -define('_PS_TAASC_PATH_', _PS_TOOL_DIR_.'taasc/'); -define('_PS_PEAR_XML_PARSER_PATH_', _PS_TOOL_DIR_.'pear_xml_parser/'); -define('_PS_CACHE_DIR_', _PS_ROOT_DIR_.'/cache/'); /* BO THEMES */ if (defined('_PS_ADMIN_DIR_')) define('_PS_BO_ALL_THEMES_DIR_', _PS_ADMIN_DIR_.'/themes/'); +define('_PS_CACHE_DIR_', _PS_ROOT_DIR_.'/cache/'); +define('_PS_CLASS_DIR_', _PS_ROOT_DIR_.'/classes/'); +define('_PS_DOWNLOAD_DIR_', _PS_ROOT_DIR_.'/download/'); +define('_PS_MAIL_DIR_', _PS_ROOT_DIR_.'/mails/'); +if (!defined('_PS_MODULE_DIR_')) + define('_PS_MODULE_DIR_', _PS_ROOT_DIR_.'/modules/'); +define('_PS_OVERRIDE_DIR_', _PS_ROOT_DIR_.'/override/'); +define('_PS_PDF_DIR_', _PS_ROOT_DIR_.'/pdf/'); +define('_PS_TRANSLATIONS_DIR_', _PS_ROOT_DIR_.'/translations/'); +define('_PS_UPLOAD_DIR_', _PS_ROOT_DIR_.'/upload/'); + +define('_PS_CONTROLLER_DIR_', _PS_ROOT_DIR_.'/controllers/'); +define('_PS_ADMIN_CONTROLLER_DIR_', _PS_ROOT_DIR_.'/controllers/admin/'); +define('_PS_FRONT_CONTROLLER_DIR_', _PS_ROOT_DIR_.'/controllers/front/'); + +define('_PS_TOOL_DIR_', _PS_ROOT_DIR_.'/tools/'); +define('_PS_FPDF_PATH_', _PS_TOOL_DIR_.'fpdf/'); // @deprecated will be removed in 1.6 +define('_PS_GEOIP_DIR_', _PS_TOOL_DIR_.'geoip/'); +define('_PS_PEAR_XML_PARSER_PATH_', _PS_TOOL_DIR_.'pear_xml_parser/'); +define('_PS_SWIFT_DIR_', _PS_TOOL_DIR_.'swift/'); +define('_PS_TAASC_PATH_', _PS_TOOL_DIR_.'taasc/'); +define('_PS_TCPDF_PATH_', _PS_TOOL_DIR_.'tcpdf/'); + +define('_PS_IMG_DIR_', _PS_ROOT_DIR_.'/img/'); +define('_PS_CAT_IMG_DIR_', _PS_IMG_DIR_.'c/'); +define('_PS_COL_IMG_DIR_', _PS_IMG_DIR_.'co/'); +define('_PS_EMPLOYEE_IMG_DIR_', _PS_IMG_DIR_.'e/'); +define('_PS_GENDERS_DIR_', _PS_IMG_DIR_.'genders/'); +define('_PS_LANG_IMG_DIR_', _PS_IMG_DIR_.'l/'); +define('_PS_MANU_IMG_DIR_', _PS_IMG_DIR_.'m/'); +define('_PS_ORDER_STATE_IMG_DIR_', _PS_IMG_DIR_.'os/'); +define('_PS_PROD_IMG_DIR_', _PS_IMG_DIR_.'p/'); +define('_PS_SCENE_IMG_DIR_', _PS_IMG_DIR_.'scenes/'); +define('_PS_SCENE_THUMB_IMG_DIR_', _PS_IMG_DIR_.'scenes/thumbs/'); +define('_PS_SHIP_IMG_DIR_', _PS_IMG_DIR_.'s/'); +define('_PS_STORE_IMG_DIR_', _PS_IMG_DIR_.'st/'); +define('_PS_SUPP_IMG_DIR_', _PS_IMG_DIR_.'su/'); +define('_PS_TMP_IMG_DIR_', _PS_IMG_DIR_.'tmp/'); /* settings php */ define('_PS_TRANS_PATTERN_', '(.*[^\\\\])'); diff --git a/controllers/admin/AdminEmployeesController.php b/controllers/admin/AdminEmployeesController.php index 229fdde20..466894d7a 100644 --- a/controllers/admin/AdminEmployeesController.php +++ b/controllers/admin/AdminEmployeesController.php @@ -47,6 +47,11 @@ class AdminEmployeesControllerCore extends AdminController $this->addRowAction('edit'); $this->addRowAction('delete'); + $this->fieldImageSettings = array( + 'name' => 'image', + 'dir' => 'e' + ); + $this->context = Context::getContext(); $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); @@ -185,19 +190,28 @@ class AdminEmployeesControllerCore extends AdminController 'input' => array( array( 'type' => 'text', - 'label' => $this->l('First Name:'), + 'label' => $this->l('First Name'), 'name' => 'firstname', 'required' => true ), array( 'type' => 'text', - 'label' => $this->l('Last Name:'), + 'label' => $this->l('Last Name'), 'name' => 'lastname', 'required' => true ), + array( + 'type' => 'file', + 'label' => $this->l('Picture'), + 'name' => 'image', + 'image' => ImageManager::thumbnail($obj->getImage(), $this->table.'_'.(int)$obj->id.'.'.$this->imageType, 150, $this->imageType, true, true), + 'col' => 6, + 'value' => true, + 'display_image' => true, + ), array( 'type' => 'password', - 'label' => $this->l('Password:'), + 'label' => $this->l('Password'), 'name' => 'passwd', 'required' => true, 'hint' => ($obj->id ? @@ -206,7 +220,7 @@ class AdminEmployeesControllerCore extends AdminController ), array( 'type' => 'text', - 'label' => $this->l('Email address:'), + 'label' => $this->l('Email address'), 'name' => 'email', 'required' => true ),