bebeboutik/override/classes/Employee.php
Marion Muszynski d8c2c369c9 reset password
2017-09-18 11:00:12 +02:00

60 lines
2.1 KiB
PHP

<?php
class Employee extends EmployeeCore {
public $date_passwd_upd;
public function getFields()
{
parent::validateFields();
$fields['id_profile'] = (int)$this->id_profile;
$fields['id_lang'] = (int)$this->id_lang;
$fields['lastname'] = pSQL($this->lastname);
$fields['firstname'] = pSQL(Tools::ucfirst($this->firstname));
$fields['email'] = pSQL($this->email);
$fields['passwd'] = pSQL($this->passwd);
$fields['last_passwd_gen'] = pSQL($this->last_passwd_gen);
$fields['date_passwd_upd'] = pSQL($this->date_passwd_upd);
if (empty($this->stats_date_from))
$this->stats_date_from = date('Y-m-d 00:00:00');
$fields['stats_date_from'] = pSQL($this->stats_date_from);
if (empty($this->stats_date_to))
$this->stats_date_to = date('Y-m-d 23:59:59');
$fields['stats_date_to'] = pSQL($this->stats_date_to);
$fields['bo_color'] = pSQL($this->bo_color);
$fields['bo_theme'] = pSQL($this->bo_theme);
$fields['bo_uimode'] = pSQL($this->bo_uimode);
$fields['bo_show_screencast'] = (int)$this->bo_show_screencast;
$fields['active'] = (int)$this->active;
return $fields;
}
public static function getEmployeesByProfile($id_profiles=array())
{
Tools::displayAsDeprecated();
return Db::getInstance()->ExecuteS('
SELECT `id_employee`, CONCAT(`firstname`, \' \', `lastname`) AS "name"
FROM `'._DB_PREFIX_.'employee`
WHERE `active` = 1 AND id_profile IN ('.implode(',',$id_profiles).')
ORDER BY `email`');
}
public function update($nullValues = false)
{
$result = parent::update($nullValues);
if(isset($_POST['passwd']) && $_POST['passwd']!==null && $result){
Db::getInstance()->ExecuteS('
UPDATE `'._DB_PREFIX_.'employee`
SET `date_passwd_upd` = "'.pSQL(date('Y-m-d H:i:s')).'"
WHERE `id_employee` = '.(int)$this->id.'
');
}
return $result;
}
}