Merge pull request #20249 from atm-steve/NEW_Employee_management_improvement

New employee management improvement #18434
This commit is contained in:
Laurent Destailleur
2022-04-05 15:12:19 +02:00
committed by GitHub
8 changed files with 130 additions and 35 deletions

View File

@@ -214,28 +214,28 @@ class modHRM extends DolibarrModules
$r++; $r++;
// Evaluation // Evaluation
$this->rights[$r][0] = 4020; // Permission id (must not be already used) $this->rights[$r][0] = 4021; // Permission id (must not be already used)
$this->rights[$r][1] = 'Read evaluations'; // Permission label $this->rights[$r][1] = 'Read evaluations'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'evaluation'; $this->rights[$r][4] = 'evaluation';
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->read) $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->read)
$r++; $r++;
$this->rights[$r][0] = 4021; // Permission id (must not be already used) $this->rights[$r][0] = 4022; // Permission id (must not be already used)
$this->rights[$r][1] = 'Create/modify your evaluation'; // Permission label $this->rights[$r][1] = 'Create/modify your evaluation'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'evaluation'; $this->rights[$r][4] = 'evaluation';
$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->write) $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->write)
$r++; $r++;
$this->rights[$r][0] = 4022; // Permission id (must not be already used) $this->rights[$r][0] = 4023; // Permission id (must not be already used)
$this->rights[$r][1] = 'Validate evaluation'; // Permission label $this->rights[$r][1] = 'Validate evaluation'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'evaluation_advance'; $this->rights[$r][4] = 'evaluation_advance';
$this->rights[$r][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->validate) $this->rights[$r][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->validate)
$r++; $r++;
$this->rights[$r][0] = 4023; // Permission id (must not be already used) $this->rights[$r][0] = 4025; // Permission id (must not be already used)
$this->rights[$r][1] = 'Delete evaluations'; // Permission label $this->rights[$r][1] = 'Delete evaluations'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'evaluation'; $this->rights[$r][4] = 'evaluation';
@@ -243,12 +243,28 @@ class modHRM extends DolibarrModules
$r++; $r++;
// Comparison // Comparison
$this->rights[$r][0] = 4030; // Permission id (must not be already used) $this->rights[$r][0] = 4028; // Permission id (must not be already used)
$this->rights[$r][1] = 'See comparison menu'; // Permission label $this->rights[$r][1] = 'See comparison menu'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'compare_advance'; $this->rights[$r][4] = 'compare_advance';
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->compare_advance->read) $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->compare_advance->read)
$r++; $r++;
// Read employee
$this->rights[$r][0] = 4031; // Permission id (must not be already used)
$this->rights[$r][1] = 'Read personal information'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'read_personal_information';
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->read_personal_information->read)
$r++;
// Write employee
$this->rights[$r][0] = 4032; // Permission id (must not be already used)
$this->rights[$r][1] = 'Write personal information'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'write_personal_information';
$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->write_personal_information->write)
$r++;
} }
/** /**

View File

@@ -283,6 +283,8 @@ ALTER TABLE llx_bank_account ADD COLUMN pti_in_ctti smallint DEFAULT 0 AFTER dom
-- Set default ticket type to OTHER if no default exists -- Set default ticket type to OTHER if no default exists
UPDATE llx_c_ticket_type SET use_default=1 WHERE code='OTHER' AND NOT EXISTS(SELECT * FROM (SELECT * FROM llx_c_ticket_type) AS t WHERE use_default=1); UPDATE llx_c_ticket_type SET use_default=1 WHERE code='OTHER' AND NOT EXISTS(SELECT * FROM (SELECT * FROM llx_c_ticket_type) AS t WHERE use_default=1);
ALTER TABLE llx_user ADD COLUMN ref_employee varchar(50) DEFAULT NULL;
ALTER TABLE llx_user ADD COLUMN national_registration_number varchar(50) DEFAULT NULL;
ALTER TABLE llx_propal ADD last_main_doc VARCHAR(255) NULL AFTER model_pdf; ALTER TABLE llx_propal ADD last_main_doc VARCHAR(255) NULL AFTER model_pdf;

View File

@@ -108,5 +108,7 @@ create table llx_user
import_key varchar(14), -- import key import_key varchar(14), -- import key
default_range integer, default_range integer,
default_c_exp_tax_cat integer, default_c_exp_tax_cat integer,
employee_number varchar(50),
national_registration_number varchar(50),
fk_warehouse integer -- default warehouse os user fk_warehouse integer -- default warehouse os user
)ENGINE=innodb; )ENGINE=innodb;

View File

@@ -972,6 +972,8 @@ Permission4021=Create/modify your evaluation
Permission4022=Validate evaluation Permission4022=Validate evaluation
Permission4023=Delete evaluation Permission4023=Delete evaluation
Permission4030=See comparison menu Permission4030=See comparison menu
Permission4031=Read personal information
Permission4032=Write personal information
Permission10001=Read website content Permission10001=Read website content
Permission10002=Create/modify website content (html and javascript content) Permission10002=Create/modify website content (html and javascript content)
Permission10003=Create/modify website content (dynamic php code). Dangerous, must be reserved to restricted developers. Permission10003=Create/modify website content (dynamic php code). Dangerous, must be reserved to restricted developers.

View File

@@ -51,6 +51,8 @@ CivilityCode=Civility code
RegisteredOffice=Registered office RegisteredOffice=Registered office
Lastname=Last name Lastname=Last name
Firstname=First name Firstname=First name
RefEmployee=Employee reference
NationalRegistrationNumber=National registration number
PostOrFunction=Job position PostOrFunction=Job position
UserTitle=Title UserTitle=Title
NatureOfThirdParty=Nature of Third party NatureOfThirdParty=Nature of Third party

View File

@@ -78,8 +78,8 @@ if (empty($account->userid)) {
// Define value to know what current user can do on users // Define value to know what current user can do on users
$canadduser = (!empty($user->admin) || $user->rights->user->user->creer); $canadduser = (!empty($user->admin) || $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write);
$canreaduser = (!empty($user->admin) || $user->rights->user->user->lire); $canreaduser = (!empty($user->admin) || $user->rights->user->user->lire || $user->rights->hrm->read_personal_information->read);
$permissiontoaddbankaccount = (!empty($user->rights->salaries->write) || !empty($user->rights->hrm->employee->write) || !empty($user->rights->user->creer)); $permissiontoaddbankaccount = (!empty($user->rights->salaries->write) || !empty($user->rights->hrm->employee->write) || !empty($user->rights->user->creer));
// Ok if user->rights->salaries->read or user->rights->hrm->read // Ok if user->rights->salaries->read or user->rights->hrm->read
@@ -230,6 +230,24 @@ if ($action == 'setpersonal_mobile' && $canadduser && !$cancel) {
} }
} }
// update ref_employee
if ($action == 'setref_employee' && $canadduser && !$cancel) {
$object->ref_employee = (string) GETPOST('ref_employee', 'alphanohtml');
$result = $object->update($user);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
// update national_registration_number
if ($action == 'setnational_registration_number' && $canadduser && !$cancel) {
$object->national_registration_number = (string) GETPOST('national_registration_number', 'alphanohtml');
$result = $object->update($user);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
// update default_c_exp_tax_cat // update default_c_exp_tax_cat
if ($action == 'setdefault_c_exp_tax_cat' && $canadduser) { if ($action == 'setdefault_c_exp_tax_cat' && $canadduser) {
@@ -263,7 +281,7 @@ llxHeader(null, $langs->trans("BankAccounts"));
$head = user_prepare_head($object); $head = user_prepare_head($object);
if ($id && $bankid && $action == 'edit' && $user->rights->user->user->creer) { if ($id && $bankid && $action == 'edit' && ($user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write)) {
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">'; print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
@@ -428,6 +446,7 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac
print "</tr>\n"; print "</tr>\n";
// Date of birth // Date of birth
if ($user->rights->hrm->read_personal_information->read || $user->rights->hrm->write_personal_information->write) {
print '<tr>'; print '<tr>';
print '<td>'; print '<td>';
print $form->editfieldkey("DateOfBirth", 'birth', $object->birth, $object, $user->rights->user->user->creer); print $form->editfieldkey("DateOfBirth", 'birth', $object->birth, $object, $user->rights->user->user->creer);
@@ -435,24 +454,29 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac
print $form->editfieldval("DateOfBirth", 'birth', $object->birth, $object, $user->rights->user->user->creer, 'day', $object->birth); print $form->editfieldval("DateOfBirth", 'birth', $object->birth, $object, $user->rights->user->user->creer, 'day', $object->birth);
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
}
// Personal email // Personal email
if ($user->rights->hrm->read_personal_information->read || $user->rights->hrm->write_personal_information->write) {
print '<tr class="nowrap">'; print '<tr class="nowrap">';
print '<td>'; print '<td>';
print $form->editfieldkey("UserPersonalEmail", 'personal_email', $object->personal_email, $object, $user->rights->user->user->creer); print $form->editfieldkey("UserPersonalEmail", 'personal_email', $object->personal_email, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write);
print '</td><td>'; print '</td><td>';
print $form->editfieldval("UserPersonalEmail", 'personal_email', $object->personal_email, $object, $user->rights->user->user->creer, 'email', '', null, null, '', 0, 'dol_print_email'); print $form->editfieldval("UserPersonalEmail", 'personal_email', $object->personal_email, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write, 'email', '', null, null, '', 0, 'dol_print_email');
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
}
// Personal phone // Personal phone
if ($user->rights->hrm->read_personal_information->read || $user->rights->hrm->write_personal_information->write) {
print '<tr class="nowrap">'; print '<tr class="nowrap">';
print '<td>'; print '<td>';
print $form->editfieldkey("UserPersonalMobile", 'personal_mobile', $object->personal_mobile, $object, $user->rights->user->user->creer); print $form->editfieldkey("UserPersonalMobile", 'personal_mobile', $object->personal_mobile, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write);
print '</td><td>'; print '</td><td>';
print $form->editfieldval("UserPersonalMobile", 'personal_mobile', $object->personal_mobile, $object, $user->rights->user->user->creer, 'string', '', null, null, '', 0, 'dol_print_phone'); print $form->editfieldval("UserPersonalMobile", 'personal_mobile', $object->personal_mobile, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write, 'string', '', null, null, '', 0, 'dol_print_phone');
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
}
if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
print '<tr class="nowrap">'; print '<tr class="nowrap">';
@@ -502,6 +526,34 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac
print '</tr>'; print '</tr>';
} }
// Accountancy code
if (!empty($conf->accounting->enabled)) {
print '<tr><td>'.$langs->trans("AccountancyCode").'</td>';
print '<td>'.$object->accountancy_code.'</td></tr>';
}
// Employee Number
if ($user->rights->hrm->read_personal_information->read || $user->rights->hrm->write_personal_information->write) {
print '<tr class="nowrap">';
print '<td>';
print $form->editfieldkey("RefEmployee", 'ref_employee', $object->ref_employee, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write);
print '</td><td>';
print $form->editfieldval("RefEmployee", 'ref_employee', $object->ref_employee, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write, 'string', $object->ref_employee);
print '</td>';
print '</tr>';
}
// National registration number
if ($user->rights->hrm->read_personal_information->read || $user->rights->hrm->write_personal_information->write) {
print '<tr class="nowrap">';
print '<td>';
print $form->editfieldkey("NationalRegistrationNumber", 'national_registration_number', $object->national_registration_number, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write);
print '</td><td>';
print $form->editfieldval("NationalRegistrationNumber", 'national_registration_number', $object->national_registration_number, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write, 'string', $object->national_registration_number);
print '</td>';
print '</tr>';
}
print '</table>'; print '</table>';
print '</div><div class="fichehalfright">'; print '</div><div class="fichehalfright">';

View File

@@ -247,6 +247,8 @@ if (empty($reshook)) {
$object->civility_code = GETPOST("civility_code", 'aZ09'); $object->civility_code = GETPOST("civility_code", 'aZ09');
$object->lastname = GETPOST("lastname", 'alphanohtml'); $object->lastname = GETPOST("lastname", 'alphanohtml');
$object->firstname = GETPOST("firstname", 'alphanohtml'); $object->firstname = GETPOST("firstname", 'alphanohtml');
$object->ref_employee = GETPOST("ref_employee", 'alphanohtml');
$object->national_registration_number = GETPOST("national_registration_number", 'alphanohtml');
$object->login = GETPOST("login", 'alphanohtml'); $object->login = GETPOST("login", 'alphanohtml');
$object->api_key = GETPOST("api_key", 'alphanohtml'); $object->api_key = GETPOST("api_key", 'alphanohtml');
$object->gender = GETPOST("gender", 'aZ09'); $object->gender = GETPOST("gender", 'aZ09');
@@ -402,6 +404,8 @@ if (empty($reshook)) {
$object->civility_code = GETPOST("civility_code", 'aZ09'); $object->civility_code = GETPOST("civility_code", 'aZ09');
$object->lastname = GETPOST("lastname", 'alphanohtml'); $object->lastname = GETPOST("lastname", 'alphanohtml');
$object->firstname = GETPOST("firstname", 'alphanohtml'); $object->firstname = GETPOST("firstname", 'alphanohtml');
$object->ref_employee = GETPOST("ref_employee", 'alphanohtml');
$object->national_registration_number = GETPOST("national_registration_number", 'alphanohtml');
$object->gender = GETPOST("gender", 'aZ09'); $object->gender = GETPOST("gender", 'aZ09');
$object->pass = GETPOST("password", 'none'); // We can keep 'none' for password fields $object->pass = GETPOST("password", 'none'); // We can keep 'none' for password fields
$object->api_key = (GETPOST("api_key", 'alphanohtml')) ? GETPOST("api_key", 'alphanohtml') : $object->api_key; $object->api_key = (GETPOST("api_key", 'alphanohtml')) ? GETPOST("api_key", 'alphanohtml') : $object->api_key;
@@ -1576,12 +1580,6 @@ if ($action == 'create' || $action == 'adduserldap') {
print '</td></tr>'; print '</td></tr>';
} }
// Accountancy code
if (!empty($conf->accounting->enabled)) {
print '<tr><td>'.$langs->trans("AccountancyCode").'</td>';
print '<td>'.$object->accountancy_code.'</td></tr>';
}
print '</table>'; print '</table>';
print '</div>'; print '</div>';

View File

@@ -339,6 +339,17 @@ class User extends CommonObject
public $dateemploymentend; // Define date of employment end by company public $dateemploymentend; // Define date of employment end by company
public $default_c_exp_tax_cat; public $default_c_exp_tax_cat;
/**
* @var string ref for employee
*/
public $ref_employee;
/**
* @var string national registration number
*/
public $national_registration_number;
public $default_range; public $default_range;
/** /**
@@ -350,6 +361,8 @@ class User extends CommonObject
'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
'lastname'=>array('type'=>'varchar(50)', 'label'=>'LastName', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1), 'lastname'=>array('type'=>'varchar(50)', 'label'=>'LastName', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1),
'firstname'=>array('type'=>'varchar(50)', 'label'=>'FirstName', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), 'firstname'=>array('type'=>'varchar(50)', 'label'=>'FirstName', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1),
'ref_employee'=>array('type'=>'varchar(50)', 'label'=>'ref_employee', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>30, 'searchall'=>1),
'national_registration_number'=>array('type'=>'varchar(50)', 'label'=>'national_registration_number', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>40, 'searchall'=>1)
); );
@@ -437,6 +450,8 @@ class User extends CommonObject
$sql .= " u.fk_warehouse,"; $sql .= " u.fk_warehouse,";
$sql .= " u.ref_ext,"; $sql .= " u.ref_ext,";
$sql .= " u.default_range, u.default_c_exp_tax_cat,"; // Expense report default mode $sql .= " u.default_range, u.default_c_exp_tax_cat,"; // Expense report default mode
$sql .= " u.national_registration_number,";
$sql .= " u.ref_employee,";
$sql .= " c.code as country_code, c.label as country,"; $sql .= " c.code as country_code, c.label as country,";
$sql .= " d.code_departement as state_code, d.nom as state"; $sql .= " d.code_departement as state_code, d.nom as state";
$sql .= " FROM ".$this->db->prefix()."user as u"; $sql .= " FROM ".$this->db->prefix()."user as u";
@@ -488,6 +503,8 @@ class User extends CommonObject
$this->civility_code = $obj->civility_code; $this->civility_code = $obj->civility_code;
$this->lastname = $obj->lastname; $this->lastname = $obj->lastname;
$this->firstname = $obj->firstname; $this->firstname = $obj->firstname;
$this->ref_employee = $obj->ref_employee;
$this->national_registration_number = $obj->national_registration_number;
$this->employee = $obj->employee; $this->employee = $obj->employee;
@@ -1755,6 +1772,8 @@ class User extends CommonObject
$this->civility_code = trim($this->civility_code); $this->civility_code = trim($this->civility_code);
$this->lastname = trim($this->lastname); $this->lastname = trim($this->lastname);
$this->firstname = trim($this->firstname); $this->firstname = trim($this->firstname);
$this->ref_employee = trim($this->ref_employee);
$this->national_registration_number = trim($this->national_registration_number);
$this->employee = $this->employee ? $this->employee : 0; $this->employee = $this->employee ? $this->employee : 0;
$this->login = trim($this->login); $this->login = trim($this->login);
$this->gender = trim($this->gender); $this->gender = trim($this->gender);
@@ -1847,6 +1866,8 @@ class User extends CommonObject
$sql .= " civility = '".$this->db->escape($this->civility_code)."'"; $sql .= " civility = '".$this->db->escape($this->civility_code)."'";
$sql .= ", lastname = '".$this->db->escape($this->lastname)."'"; $sql .= ", lastname = '".$this->db->escape($this->lastname)."'";
$sql .= ", firstname = '".$this->db->escape($this->firstname)."'"; $sql .= ", firstname = '".$this->db->escape($this->firstname)."'";
$sql .= ", ref_employee = '".$this->db->escape($this->ref_employee)."'";
$sql .= ", national_registration_number = '".$this->db->escape($this->national_registration_number)."'";
$sql .= ", employee = ".(int) $this->employee; $sql .= ", employee = ".(int) $this->employee;
$sql .= ", login = '".$this->db->escape($this->login)."'"; $sql .= ", login = '".$this->db->escape($this->login)."'";
$sql .= ", api_key = ".($this->api_key ? "'".$this->db->escape($this->api_key)."'" : "null"); $sql .= ", api_key = ".($this->api_key ? "'".$this->db->escape($this->api_key)."'" : "null");