From fc3f60b6af1d4c5695283cf3642de42128e4ee64 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 31 Jan 2023 00:42:23 +0100 Subject: [PATCH] Clean code related to HR --- htdocs/core/modules/modHRM.class.php | 20 ++++++------- htdocs/user/bank.php | 14 +++++---- htdocs/user/class/user.class.php | 26 +---------------- htdocs/user/list.php | 43 ++++++++++++++++++++++++++-- 4 files changed, 59 insertions(+), 44 deletions(-) diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index 78c0bde14f6..f4295f53193 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -250,9 +250,17 @@ class modHRM extends DolibarrModules $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->compare_advance->read) $r++; + // Evaluation + $this->rights[$r][0] = 4029; // Permission id (must not be already used) + $this->rights[$r][1] = 'Read all evaluations'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'evaluation'; + $this->rights[$r][5] = 'readall'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->read) + $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][1] = 'Read personal/HR 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) @@ -260,19 +268,11 @@ class modHRM extends DolibarrModules // 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][1] = 'Write personal/HR 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++; - - // Evaluation - $this->rights[$r][0] = 4033; // Permission id (must not be already used) - $this->rights[$r][1] = 'Read all evaluations'; // Permission label - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'evaluation'; - $this->rights[$r][5] = 'readall'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->read) - $r++; } /** diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 9cc825082d7..4c26ec27021 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -83,6 +83,8 @@ if (empty($account->userid)) { $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 || $user->rights->hrm->read_personal_information->read); $permissiontoaddbankaccount = (!empty($user->rights->salaries->write) || !empty($user->rights->hrm->employee->write) || !empty($user->rights->user->creer)); +$permissiontoreadhr = $user->hasRight('hrm', 'read_personal_information', 'read') || $user->hasRight('hrm', 'write_personal_information', 'write'); +$permissiontowritehr = $user->hasRight('hrm', 'write_personal_information', 'write'); // Ok if user->rights->salaries->read or user->rights->hrm->read //$result = restrictedArea($user, 'salaries|hrm', $object->id, 'user&user', $feature2); @@ -551,23 +553,23 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac } // Employee Number - if ($user->hasRight('hrm', 'read_personal_information', 'read') || $user->hasRight('hrm', 'write_personal_information', 'write')) { + if ($permissiontoreadhr) { print ''; print ''; - print $form->editfieldkey("RefEmployee", 'ref_employee', $object->ref_employee, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write); + print $form->editfieldkey("RefEmployee", 'ref_employee', $object->ref_employee, $object, $permissiontowritehr); print ''; - 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 $form->editfieldval("RefEmployee", 'ref_employee', $object->ref_employee, $object, $permissiontowritehr, 'string', $object->ref_employee); print ''; print ''; } // National registration number - if ($user->hasRight('hrm', 'read_personal_information', 'read') || $user->hasRight('hrm', 'write_personal_information', 'write')) { + if ($permissiontoreadhr) { print ''; print ''; - 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 $form->editfieldkey("NationalRegistrationNumber", 'national_registration_number', $object->national_registration_number, $object, $permissiontowritehr); print ''; - 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 $form->editfieldval("NationalRegistrationNumber", 'national_registration_number', $object->national_registration_number, $object, $permissiontowritehr, 'string', $object->national_registration_number); print ''; print ''; } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 2893378bdd9..089e082fae3 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -99,34 +99,10 @@ class User extends CommonObject public $personal_email; /** - * @var array array of socialnetworks + * @var array array of socialnetwo18dprks */ public $socialnetworks; - /** - * @var string skype account - * @deprecated - */ - public $skype; - - /** - * @var string twitter account - * @deprecated - */ - public $twitter; - - /** - * @var string facebook account - * @deprecated - */ - public $facebook; - - /** - * @var string linkedin account - * @deprecated - */ - public $linkedin; - /** * @var string job position */ diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 3cac5d06c56..30adec1dd08 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -116,6 +116,9 @@ if (!empty($conf->api->enabled)) { $fieldstosearchall['u.api_key'] = "ApiKey"; } +$permissiontoreadhr = $user->hasRight('hrm', 'read_personal_information', 'read') || $user->hasRight('hrm', 'write_personal_information', 'write'); +$permissiontowritehr = $user->hasRight('hrm', 'write_personal_information', 'write'); + // Definition of fields for list $arrayfields = array( 'u.login'=>array('label'=>"Login", 'checked'=>1, 'position'=>10), @@ -124,14 +127,16 @@ $arrayfields = array( 'u.entity'=>array('label'=>"Entity", 'checked'=>1, 'position'=>50, 'enabled'=>(isModEnabled('multicompany') && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))), 'u.gender'=>array('label'=>"Gender", 'checked'=>0, 'position'=>22), 'u.employee'=>array('label'=>"Employee", 'checked'=>($contextpage == 'employeelist' ? 1 : 0), 'position'=>25), - 'u.fk_user'=>array('label'=>"HierarchicalResponsible", 'checked'=>1, 'position'=>27), + 'u.fk_user'=>array('label'=>"HierarchicalResponsible", 'checked'=>1, 'position'=>27, 'csslist'=>'maxwidth150'), 'u.accountancy_code'=>array('label'=>"AccountancyCode", 'checked'=>0, 'position'=>30), 'u.office_phone'=>array('label'=>"PhonePro", 'checked'=>1, 'position'=>31), 'u.user_mobile'=>array('label'=>"PhoneMobile", 'checked'=>1, 'position'=>32), 'u.email'=>array('label'=>"EMail", 'checked'=>1, 'position'=>35), 'u.api_key'=>array('label'=>"ApiKey", 'checked'=>0, 'position'=>40, "enabled"=>(!empty($conf->api->enabled) && $user->admin)), 'u.fk_soc'=>array('label'=>"Company", 'checked'=>($contextpage == 'employeelist' ? 0 : 1), 'position'=>45), - 'u.salary'=>array('label'=>"Salary", 'checked'=>1, 'position'=>80, 'enabled'=>(!empty($conf->salaries->enabled) && $user->hasRight("salaries", "readall"))), + 'u.ref_employee'=>array('label'=>"RefEmployee", 'checked'=>1, 'position'=>60, 'enabled'=>(isModEnabled('hrm') && $permissiontoreadhr)), + 'u.national_registration_number'=>array('label'=>"NationalRegistrationNumber", 'checked'=>1, 'position'=>61, 'enabled'=>(isModEnabled('hrm') && $permissiontoreadhr)), + 'u.salary'=>array('label'=>"Salary", 'checked'=>1, 'position'=>80, 'enabled'=>(isModEnabled('salaries') && $user->hasRight("salaries", "readall"))), 'u.datelastlogin'=>array('label'=>"LastConnexion", 'checked'=>1, 'position'=>100), 'u.datepreviouslogin'=>array('label'=>"PreviousConnexion", 'checked'=>0, 'position'=>110), 'u.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), @@ -357,7 +362,7 @@ $morehtmlright = ""; // Build and execute select // -------------------------------------------------------------------- $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.admin, u.fk_soc, u.login, u.office_phone, u.user_mobile, u.email, u.api_key, u.accountancy_code, u.gender, u.employee, u.photo,"; -$sql .= " u.salary, u.datelastlogin, u.datepreviouslogin,"; +$sql .= " u.ref_employee, u.national_registration_number, u.salary, u.datelastlogin, u.datepreviouslogin,"; $sql .= " u.ldap_sid, u.statut as status, u.entity,"; $sql .= " u.tms as date_update, u.datec as date_creation,"; $sql .= " u2.rowid as id2, u2.login as login2, u2.firstname as firstname2, u2.lastname as lastname2, u2.admin as admin2, u2.fk_soc as fk_soc2, u2.office_phone as ofice_phone2, u2.user_mobile as user_mobile2, u2.email as email2, u2.gender as gender2, u2.photo as photo2, u2.entity as entity2, u2.statut as status2,"; @@ -772,6 +777,12 @@ if (!empty($arrayfields['u.fk_soc']['checked'])) { if (!empty($arrayfields['u.entity']['checked'])) { print ''; } +if (!empty($arrayfields['u.ref_employee']['checked'])) { + print ''; +} +if (!empty($arrayfields['u.national_registration_number']['checked'])) { + print ''; +} if (!empty($arrayfields['u.salary']['checked'])) { print ''; } @@ -874,6 +885,14 @@ if (!empty($arrayfields['u.entity']['checked'])) { print_liste_field_titre("Entity", $_SERVER['PHP_SELF'], "u.entity", $param, "", "", $sortfield, $sortorder); $totalarray['nbfield']++; } +if (!empty($arrayfields['u.ref_employee']['checked'])) { + print_liste_field_titre("RefEmployee", $_SERVER['PHP_SELF'], "u.ref_employee", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['u.national_registration_number']['checked'])) { + print_liste_field_titre("NationalRegistrationNumber", $_SERVER['PHP_SELF'], "u.national_registration_number", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; +} if (!empty($arrayfields['u.salary']['checked'])) { print_liste_field_titre("Salary", $_SERVER['PHP_SELF'], "u.salary", $param, "", "", $sortfield, $sortorder, 'right '); $totalarray['nbfield']++; @@ -1160,6 +1179,24 @@ while ($i < $imaxinloop) { } } + // Ref employee + if (!empty($arrayfields['u.ref_employee']['checked'])) { + print ''; + print dol_escape_htmltag($obj->ref_employee); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // National number + if (!empty($arrayfields['u.national_registration_number']['checked'])) { + print ''; + print dol_escape_htmltag($obj->national_registration_number); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } // Salary if (!empty($arrayfields['u.salary']['checked'])) { print '';