From f602e1fba79fca9a1d707a27275af99bca1caf1b Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 12 Nov 2015 05:48:56 +0100 Subject: [PATCH 01/12] HRM : Add an email address in admin to prevent HRM external service (public accountant for exemple) --- htdocs/hrm/admin/admin_establishment.php | 1 - htdocs/hrm/admin/admin_hrm.php | 60 ++++++++++++++++++++++-- htdocs/langs/en_US/hrm.lang | 4 +- 3 files changed, 60 insertions(+), 5 deletions(-) diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index 26e11dd6b94..002b6e35565 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -22,7 +22,6 @@ */ require('../../main.inc.php'); require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php'; $langs->load("admin"); diff --git a/htdocs/hrm/admin/admin_hrm.php b/htdocs/hrm/admin/admin_hrm.php index 7dba4392740..7f9ed583b98 100644 --- a/htdocs/hrm/admin/admin_hrm.php +++ b/htdocs/hrm/admin/admin_hrm.php @@ -25,22 +25,43 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; $langs->load("admin"); -$langs->load('hrm'); +$langs->load("hrm"); if (! $user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); +// Other parameters HRM_* +$list = array ( + 'HRM_EMAIL_EXTERNAL_SERVICE' // To prevent your public accountant for example +); + /* * Actions */ +if ($action == 'update') { + $error = 0; + + foreach ($list as $constname) { + $constvalue = GETPOST($constname, 'alpha'); + + if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error ++; + } + } + + if (! $error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} /* * View */ -$page_name = "Parameters"; -llxHeader('', $langs->trans($page_name)); +llxHeader('', $langs->trans('Parameters')); $form = new Form($db); @@ -52,7 +73,40 @@ print load_fiche_titre($langs->trans("HRMSetup"), $linkback); // Configuration header $head = hrm_admin_prepare_head(); + +print '
'; +print ''; +print ''; + dol_fiche_head($head, 'parameters', $langs->trans("HRM"), 0, "user"); +print ''; +print ''; +print ''; +print "\n"; + +foreach ( $list as $key ) { + $var = ! $var; + + print ''; + + // Param + $label = $langs->trans($key); + print ''; + + // Value + print ''; +} + +print "
' . $langs->trans('Journaux') . '
'; + print ''; + print '
\n"; + +dol_fiche_end(); + +print '
'; + +print '
'; + llxFooter(); $db->close(); diff --git a/htdocs/langs/en_US/hrm.lang b/htdocs/langs/en_US/hrm.lang index b2e9387d62f..4fe6c8e761a 100644 --- a/htdocs/langs/en_US/hrm.lang +++ b/htdocs/langs/en_US/hrm.lang @@ -1,6 +1,7 @@ # Dolibarr language file - en_US - hrm CHARSET=UTF-8 - +# Admin +HRM_EMAIL_EXTERNAL_SERVICE=Email to prevent HRM external service Establishments=Establishments Establishment=Establishment NewEstablishment=New establishment @@ -8,6 +9,7 @@ DeleteEstablishment=Delete establishment ConfirmDeleteEstablishment=Are-you sure to delete this establishment ? OpenEtablishment=Open establishment CloseEtablishment=Close establishment +# Module ListOfEmployees=List of employees Employees=Employees Employee=Employee From 20872498ba79d7d0a24961cd63d34fc20932d223 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 12 Nov 2015 06:58:26 +0100 Subject: [PATCH 02/12] HRM: Add a tab for holiday module in employee card --- htdocs/core/modules/modHoliday.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 8daba0040d7..26d01c34371 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -113,6 +113,7 @@ class modHoliday extends DolibarrModules // 'contact' to add a tab in contact view // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) $this->tabs = array('user:+paidholidays:CPTitreMenu:holiday:$user->rights->holiday->read:/holiday/list.php?mainmenu=holiday&id=__ID__'); + $this->tabs = array('employee:+paidholidays:CPTitreMenu:holiday:$user->rights->holiday->read:/holiday/list.php?mainmenu=holiday&id=__ID__'); // Boxes $this->boxes = array(); // List of boxes From 7693b407e8306b8093ccc8211b7427dfbee5832c Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 12 Nov 2015 06:59:40 +0100 Subject: [PATCH 03/12] HRM: Begin to work on employee card --- htdocs/core/lib/hrm.lib.php | 2 +- htdocs/hrm/employee/card.php | 1677 ++++++++++++++++++++++++++++++++++ htdocs/langs/en_US/hrm.lang | 1 + 3 files changed, 1679 insertions(+), 1 deletion(-) create mode 100644 htdocs/hrm/employee/card.php diff --git a/htdocs/core/lib/hrm.lib.php b/htdocs/core/lib/hrm.lib.php index f7f3ed11bd8..dd3f17ef995 100644 --- a/htdocs/core/lib/hrm.lib.php +++ b/htdocs/core/lib/hrm.lib.php @@ -36,7 +36,7 @@ function employee_prepare_head($object) { $head [$h] [0] = DOL_URL_ROOT.'/hrm/employee/card.php?id=' . $object->id; $head [$h] [1] = $langs->trans("Card"); - $head [$h] [2] = 'card'; + $head [$h] [2] = 'employee'; $h ++; complete_head_from_modules($conf, $langs, $object, $head, $h, 'employee'); diff --git a/htdocs/hrm/employee/card.php b/htdocs/hrm/employee/card.php new file mode 100644 index 00000000000..aa7bd92ec8b --- /dev/null +++ b/htdocs/hrm/employee/card.php @@ -0,0 +1,1677 @@ + + * Copyright (C) 2002-2003 Jean-Louis Bergamo + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2015 Regis Houssin + * Copyright (C) 2005 Lionel Cousteix + * Copyright (C) 2011 Herve Prot + * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Ari Elbaz (elarifr) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/hrm/employee/card.php + * \ingroup HRM + * \brief Tab of employee card + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +if (! empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; +if (! empty($conf->multicompany->enabled)) dol_include_once('/multicompany/class/actions_multicompany.class.php'); + +$id = GETPOST('id','int'); +$action = GETPOST('action','alpha'); +$confirm = GETPOST('confirm','alpha'); +$subaction = GETPOST('subaction','alpha'); +$group = GETPOST("group","int",3); + +// Define value to know what current user can do on users +$canadduser=(! empty($user->admin) || $user->rights->user->user->creer); +$canreaduser=(! empty($user->admin) || $user->rights->user->user->lire); +$canedituser=(! empty($user->admin) || $user->rights->user->user->creer); +$candisableuser=(! empty($user->admin) || $user->rights->user->user->supprimer); +$canreadgroup=$canreaduser; +$caneditgroup=$canedituser; +if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) +{ + $canreadgroup=(! empty($user->admin) || $user->rights->user->group_advance->read); + $caneditgroup=(! empty($user->admin) || $user->rights->user->group_advance->write); +} +// Define value to know what current user can do on properties of edited user +if ($id) +{ + // $user est le user qui edite, $id est l'id de l'utilisateur edite + $caneditfield=((($user->id == $id) && $user->rights->user->self->creer) + || (($user->id != $id) && $user->rights->user->user->creer)); + $caneditpassword=((($user->id == $id) && $user->rights->user->self->password) + || (($user->id != $id) && $user->rights->user->user->password)); +} + +// Security check +$socid=0; +if ($user->societe_id > 0) $socid = $user->societe_id; +$feature2='user'; +if ($user->id == $id) { $feature2=''; $canreaduser=1; } // A user can always read its own card +if (!$canreaduser) { + $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); +} +if ($user->id <> $id && ! $canreaduser) accessforbidden(); + +$langs->load("users"); +$langs->load("companies"); +$langs->load("ldap"); +$langs->load("admin"); +$langs->load("hrm"); + +$object = new User($db); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); + +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('usercard','globalcard')); + + + +/** + * Actions + */ + +$parameters=array('id'=>$socid); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { + + if ($action == 'confirm_disable' && $confirm == "yes" && $candisableuser) { + if ($id <> $user->id) { + $object->fetch($id); + $object->setstatus(0); + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); + exit; + } + } + if ($action == 'confirm_enable' && $confirm == "yes" && $candisableuser) { + $error = 0; + + if ($id <> $user->id) { + $object->fetch($id); + + if (!empty($conf->file->main_limit_users)) { + $nb = $object->getNbOfUsers("active"); + if ($nb >= $conf->file->main_limit_users) { + $error ++; + setEventMessage($langs->trans("YourQuotaOfUsersIsReached"), 'errors'); + } + } + + if (!$error) { + $object->setstatus(1); + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); + exit; + } + } + } + + if ($action == 'confirm_delete' && $confirm == "yes" && $candisableuser) { + if ($id <> $user->id) { + $object = new User($db); + $object->id = $id; + $result = $object->delete(); + if ($result < 0) { + $langs->load("errors"); + setEventMessage($langs->trans("ErrorUserCannotBeDelete"), 'errors'); + } else { + header("Location: index.php"); + exit; + } + } + } + + // Action Add user + if ($action == 'add' && $canadduser) { + $error = 0; + + if (!$_POST["lastname"]) { + $error ++; + setEventMessage($langs->trans("NameNotDefined"), 'errors'); + $action = "create"; // Go back to create page + } + if (!$_POST["login"]) { + $error ++; + setEventMessage($langs->trans("LoginNotDefined"), 'errors'); + $action = "create"; // Go back to create page + } + + if (!empty($conf->file->main_limit_users)) { // If option to limit users is set + $nb = $object->getNbOfUsers("active"); + if ($nb >= $conf->file->main_limit_users) { + $error ++; + setEventMessage($langs->trans("YourQuotaOfUsersIsReached"), 'errors'); + $action = "create"; // Go back to create page + } + } + + if (!$error) { + $object->lastname = GETPOST("lastname", 'alpha'); + $object->firstname = GETPOST("firstname", 'alpha'); + $object->login = GETPOST("login", 'alpha'); + $object->api_key = GETPOST("api_key", 'alpha'); + $object->gender = GETPOST("gender", 'alpha'); + $object->admin = GETPOST("admin", 'alpha'); + $object->office_phone = GETPOST("office_phone", 'alpha'); + $object->office_fax = GETPOST("office_fax", 'alpha'); + $object->user_mobile = GETPOST("user_mobile"); + $object->skype = GETPOST("skype"); + $object->email = GETPOST("email", 'alpha'); + $object->job = GETPOST("job", 'alpha'); + $object->signature = GETPOST("signature"); + $object->accountancy_code = GETPOST("accountancy_code"); + $object->note = GETPOST("note"); + $object->ldap_sid = GETPOST("ldap_sid"); + $object->fk_user = GETPOST("fk_user") > 0 ? GETPOST("fk_user") : 0; + $object->employee = GETPOST('employee'); + + $object->thm = GETPOST("thm") != '' ? GETPOST("thm") : ''; + $object->tjm = GETPOST("tjm") != '' ? GETPOST("tjm") : ''; + $object->salary = GETPOST("salary") != '' ? GETPOST("salary") : ''; + $object->salaryextra = GETPOST("salaryextra") != '' ? GETPOST("salaryextra") : ''; + $object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : ''; + + $object->color = GETPOST("color") != '' ? GETPOST("color") : ''; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) { + $error ++; + } + + // Set entity property + $entity = GETPOST('entity', 'int'); + if (!empty($conf->multicompany->enabled)) { + if (!empty($_POST["superadmin"])) { + $object->entity = 0; + } else { + if ($conf->multicompany->transverse_mode) { + $object->entity = 1; // all users are forced into master entity + } else { + $object->entity = ($entity == '' ? 1 : $entity); + } + } + } else { + $object->entity = ($entity == '' ? 1 : $entity); + /*if ($user->admin && $user->entity == 0 && GETPOST("admin",'alpha')) + { + }*/ + } + + $db->begin(); + + $id = $object->create($user); + if ($id > 0) { + if (isset($_POST['password']) && trim($_POST['password'])) { + $object->setPassword($user, trim($_POST['password'])); + } + + $db->commit(); + + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); + exit; + } else { + $langs->load("errors"); + $db->rollback(); + if (is_array($object->errors) && count($object->errors)) { + setEventMessage($object->errors, 'errors'); + } else { + setEventMessage($object->error, 'errors'); + } + $action = "create"; // Go back to create page + } + } + } + + // Action add usergroup + if (($action == 'addgroup' || $action == 'removegroup') && $caneditfield) + { + if ($group) + { + $editgroup = new UserGroup($db); + $editgroup->fetch($group); + $editgroup->oldcopy=clone $editgroup; + + $object->fetch($id); + if ($action == 'addgroup') { + $object->SetInGroup($group, ($conf->multicompany->transverse_mode ? GETPOST("entity") : $editgroup->entity)); + } + if ($action == 'removegroup') { + $object->RemoveFromGroup($group, ($conf->multicompany->transverse_mode ? GETPOST("entity") : $editgroup->entity)); + } + + if ($result > 0) { + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); + exit; + } else { + setEventMessage($object->error, 'errors'); + } + } + } + + if ($action == 'update' && !$_POST["cancel"]) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + if ($caneditfield) // Case we can edit all field + { + $error = 0; + + if (!$_POST["lastname"]) { + setEventMessage($langs->trans("NameNotDefined"), 'errors'); + $action = "edit"; // Go back to create page + $error ++; + } + if (!$_POST["login"]) { + setEventMessage($langs->trans("LoginNotDefined"), 'errors'); + $action = "edit"; // Go back to create page + $error ++; + } + + if (!$error) { + $object->fetch($id); + + $object->oldcopy = clone $object; + + if (!$error) { + $db->begin(); + + $object->oldcopy = dol_clone($object); + + $object->lastname = GETPOST("lastname", 'alpha'); + $object->firstname = GETPOST("firstname", 'alpha'); + $object->login = GETPOST("login", 'alpha'); + $object->gender = GETPOST("gender", 'alpha'); + $object->pass = GETPOST("password"); + $object->api_key = (GETPOST("api_key", 'alpha')) ? GETPOST("api_key", 'alpha') : $object->api_key; + $object->admin = empty($user->admin) ? 0 : GETPOST("admin"); // A user can only be set admin by an admin + $object->office_phone = GETPOST("office_phone", 'alpha'); + $object->office_fax = GETPOST("office_fax", 'alpha'); + $object->user_mobile = GETPOST("user_mobile"); + $object->skype = GETPOST("skype"); + $object->email = GETPOST("email", 'alpha'); + $object->job = GETPOST("job", 'alpha'); + $object->signature = GETPOST("signature"); + $object->accountancy_code = GETPOST("accountancy_code"); + $object->openid = GETPOST("openid"); + $object->fk_user = GETPOST("fk_user") > 0 ? GETPOST("fk_user") : 0; + $object->employee = GETPOST('employee'); + + $object->thm = GETPOST("thm") != '' ? GETPOST("thm") : ''; + $object->tjm = GETPOST("tjm") != '' ? GETPOST("tjm") : ''; + $object->salary = GETPOST("salary") != '' ? GETPOST("salary") : ''; + $object->salaryextra = GETPOST("salaryextra") != '' ? GETPOST("salaryextra") : ''; + $object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : ''; + + if (! empty($conf->multicompany->enabled)) + { + if (! empty($_POST["superadmin"])) + { + $object->entity = 0; + } + else if ($conf->multicompany->transverse_mode) + { + $object->entity = 1; // all users in master entity + } + else + { + $object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); + } + } + else + { + $object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); + } + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) { + $error ++; + } + + if (!empty($conf->multicompany->enabled)) { + if (!empty($_POST["superadmin"])) { + $object->entity = 0; + } else { + if ($conf->multicompany->transverse_mode) { + $object->entity = 1; // all users in master entity + } else { + $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); + } + } + } else { + $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); + } + + if (GETPOST('deletephoto')) { + $object->photo = ''; + } + if (!empty($_FILES['photo']['name'])) { + $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); + } + + if (!$error) { + $ret = $object->update($user); + if ($ret < 0) { + $error ++; + if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("errors"); + setEventMessage($langs->trans("ErrorLoginAlreadyExists", $object->login), 'errors'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + if (!$error && isset($_POST['contactid'])) { + $contactid = GETPOST('contactid'); + + if ($contactid > 0) { + $contact = new Contact($db); + $contact->fetch($contactid); + + $sql = "UPDATE ".MAIN_DB_PREFIX."user"; + $sql .= " SET fk_socpeople=".$db->escape($contactid); + if ($contact->socid) { + $sql .= ", fk_soc=".$db->escape($contact->socid); + } + $sql .= " WHERE rowid=".$object->id; + } else { + $sql = "UPDATE ".MAIN_DB_PREFIX."user"; + $sql .= " SET fk_socpeople=NULL, fk_soc=NULL"; + $sql .= " WHERE rowid=".$object->id; + } + dol_syslog("fiche::update", LOG_DEBUG); + $resql = $db->query($sql); + if (!$resql) { + $error ++; + setEventMessage($db->lasterror(), 'errors'); + } + } + + if (!$error && !count($object->errors)) { + if (GETPOST('deletephoto') && $object->photo) { + $fileimg = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/'.$object->photo; + $dirthumbs = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/thumbs'; + dol_delete_file($fileimg); + dol_delete_dir_recursive($dirthumbs); + } + + if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) { + $dir = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user'); + + dol_mkdir($dir); + + if (@is_dir($dir)) { + $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); + $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']); + + if (!$result > 0) { + setEventMessage($langs->trans("ErrorFailedToSaveFile"), 'errors'); + } else { + // Create small thumbs for company (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); + + // Create mini thumbs for company (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); + } + } else { + $error ++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFailedToCreateDir", $dir), $mesgs, 'errors'); + } + } + } + + if (!$error && !count($object->errors)) { + setEventMessage($langs->trans("UserModified")); + $db->commit(); + + $login = $_SESSION["dol_login"]; + if ($login && $login == $object->oldcopy->login && $object->oldcopy->login != $object->login) // Current user has changed its login + { + $error++; + $langs->load("errors"); + setEventMessages($langs->transnoentitiesnoconv("ErrorFailedToCreateDir", $dir), $mesgs, 'errors'); + } + } else { + $db->rollback(); + } + } + } else { + if ($caneditpassword) // Case we can edit only password + { + $object->fetch($id); + + $object->oldcopy = dol_clone($object); + + $ret = $object->setPassword($user, $_POST["password"]); + if ($ret < 0) { + setEventMessage($object->error, 'errors'); + } + } + } + } + + $object->oldcopy = clone $object; + + $ret=$object->setPassword($user,$_POST["password"]); + if ($ret < 0) + { + setEventMessage($object->error, 'errors'); + } + } + + // Change password with a new generated one + if ((($action == 'confirm_password' && $confirm == 'yes') + || ($action == 'confirm_passwordsend' && $confirm == 'yes')) && $caneditpassword + ) { + $object->fetch($id); + + $newpassword = $object->setPassword($user, ''); + if ($newpassword < 0) { + // Echec + setEventMessage($langs->trans("ErrorFailedToSetNewPassword"), 'errors'); + } else { + // Succes + if ($action == 'confirm_passwordsend' && $confirm == 'yes') { + if ($object->send_password($user, $newpassword) > 0) { + setEventMessage($langs->trans("PasswordChangedAndSentTo", $object->email)); + } else { + setEventMessage($object->error, 'errors'); + } + } else { + setEventMessage($langs->trans("PasswordChangedTo", $newpassword), 'errors'); + } + } + } + + // Action initialisation donnees depuis record LDAP + if ($action == 'adduserldap') { + $selecteduser = $_POST['users']; + + $required_fields = array( + $conf->global->LDAP_KEY_USERS, + $conf->global->LDAP_FIELD_NAME, + $conf->global->LDAP_FIELD_FIRSTNAME, + $conf->global->LDAP_FIELD_LOGIN, + $conf->global->LDAP_FIELD_LOGIN_SAMBA, + $conf->global->LDAP_FIELD_PASSWORD, + $conf->global->LDAP_FIELD_PASSWORD_CRYPTED, + $conf->global->LDAP_FIELD_PHONE, + $conf->global->LDAP_FIELD_FAX, + $conf->global->LDAP_FIELD_MOBILE, + $conf->global->LDAP_FIELD_SKYPE, + $conf->global->LDAP_FIELD_MAIL, + $conf->global->LDAP_FIELD_TITLE, + $conf->global->LDAP_FIELD_DESCRIPTION, + $conf->global->LDAP_FIELD_SID + ); + + $ldap = new Ldap(); + $result = $ldap->connect_bind(); + if ($result >= 0) { + // Remove from required_fields all entries not configured in LDAP (empty) and duplicated + $required_fields = array_unique(array_values(array_filter($required_fields, "dol_validElement"))); + + $ldapusers = $ldap->getRecords($selecteduser, $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields); + //print_r($ldapusers); + + if (is_array($ldapusers)) { + foreach ($ldapusers as $key => $attribute) { + $ldap_lastname = $attribute[$conf->global->LDAP_FIELD_NAME]; + $ldap_firstname = $attribute[$conf->global->LDAP_FIELD_FIRSTNAME]; + $ldap_login = $attribute[$conf->global->LDAP_FIELD_LOGIN]; + $ldap_loginsmb = $attribute[$conf->global->LDAP_FIELD_LOGIN_SAMBA]; + $ldap_pass = $attribute[$conf->global->LDAP_FIELD_PASSWORD]; + $ldap_pass_crypted = $attribute[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED]; + $ldap_phone = $attribute[$conf->global->LDAP_FIELD_PHONE]; + $ldap_fax = $attribute[$conf->global->LDAP_FIELD_FAX]; + $ldap_mobile = $attribute[$conf->global->LDAP_FIELD_MOBILE]; + $ldap_skype = $attribute[$conf->global->LDAP_FIELD_SKYPE]; + $ldap_mail = $attribute[$conf->global->LDAP_FIELD_MAIL]; + $ldap_sid = $attribute[$conf->global->LDAP_FIELD_SID]; + } + } + } else { + setEventMessage($ldap->error, 'errors'); + } + } +} + + +/* + * View + */ + +$form = new Form($db); +$formother=new FormOther($db); + +llxHeader('',$langs->trans("EmployeeCard")); + +if (($action == 'create') || ($action == 'adduserldap')) +{ + /* ************************************************************************** */ + /* */ + /* Affichage fiche en mode creation */ + /* */ + /* ************************************************************************** */ + + print load_fiche_titre($langs->trans("NewUser")); + + print $langs->trans("CreateInternalUserDesc")."
\n"; + print "
"; + + + if (! empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')) + { + /* + * Affiche formulaire d'ajout d'un compte depuis LDAP + * si on est en synchro LDAP vers Dolibarr + */ + + $ldap = new Ldap(); + $result = $ldap->connect_bind(); + if ($result >= 0) + { + $required_fields=array( + $conf->global->LDAP_KEY_USERS, + $conf->global->LDAP_FIELD_FULLNAME, + $conf->global->LDAP_FIELD_NAME, + $conf->global->LDAP_FIELD_FIRSTNAME, + $conf->global->LDAP_FIELD_LOGIN, + $conf->global->LDAP_FIELD_LOGIN_SAMBA, + $conf->global->LDAP_FIELD_PASSWORD, + $conf->global->LDAP_FIELD_PASSWORD_CRYPTED, + $conf->global->LDAP_FIELD_PHONE, + $conf->global->LDAP_FIELD_FAX, + $conf->global->LDAP_FIELD_MOBILE, + $conf->global->LDAP_FIELD_SKYPE, + $conf->global->LDAP_FIELD_MAIL, + $conf->global->LDAP_FIELD_TITLE, + $conf->global->LDAP_FIELD_DESCRIPTION, + $conf->global->LDAP_FIELD_SID + ); + + // Remove from required_fields all entries not configured in LDAP (empty) and duplicated + $required_fields=array_unique(array_values(array_filter($required_fields, "dol_validElement"))); + + // Get from LDAP database an array of results + $ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1); + + if (is_array($ldapusers)) + { + $liste=array(); + foreach ($ldapusers as $key => $ldapuser) + { + // Define the label string for this user + $label=''; + foreach ($required_fields as $value) + { + if ($value) + { + $label.=$value."=".$ldapuser[$value]." "; + } + } + $liste[$key] = $label; + } + + } + else + { + setEventMessage($ldap->error, 'errors'); + } + } + else + { + setEventMessage($ldap->error, 'errors'); + } + + // If user list is full, we show drop-down list + print "\n\n\n"; + + print '
'; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("LDAPUsers"); + print ''; + print ''; + if (is_array($liste) && count($liste)) + { + print $form->selectarray('users', $liste, '', 1); + } + print ''; + print ''; + print '
'; + print '
'; + + print "\n\n\n"; + print '
'; + } + + + print '
'; + print ''; + print ''; + if (! empty($ldap_sid)) print ''; + print ''; + + dol_fiche_head('', '', '', 0, ''); + + print dol_set_focus('#lastname'); + + print ''; + + print ''; + + // Lastname + print ''; + print ''; + + // Firstname + print ''; + print ''; + + // Gender + print ''; + print ''; + + // Tel + print ''; + print ''; + + // Tel portable + print ''; + print ''; + + // Fax + print ''; + print ''; + + // Skype + if (! empty($conf->skype->enabled)) + { + print ''; + print ''; + } + + // EMail + print 'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").''; + print ''; + + // Signature + print ''; + print ''; + + // Multicompany + if (! empty($conf->multicompany->enabled)) + { + if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity && is_object($mc)) + { + print "".''; + print "\n"; + } + else + { + print ''; + } + } + + // Hierarchy + print ''; + print ''; + print "\n"; + + // Accountancy code + if ($conf->salaries->enabled) + { + print ''; + print ''; + } + + // Note + print '\n"; + + // Other attributes + $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $object->showOptionals($extrafields,'edit'); + } + + print "
'.$langs->trans("Lastname").''; + if (! empty($ldap_lastname)) + { + print ''; + print $ldap_lastname; + } + else + { + print ''; + } + print '
'.$langs->trans("Firstname").''; + if (! empty($ldap_firstname)) + { + print ''; + print $ldap_firstname; + } + else + { + print ''; + } + print '
'.$langs->trans("Gender").''; + $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('gender', $arraygender, GETPOST('gender'), 1); + print '
'.$langs->trans("PhonePro").''; + if (! empty($ldap_phone)) + { + print ''; + print $ldap_phone; + } + else + { + print ''; + } + print '
'.$langs->trans("PhoneMobile").''; + if (! empty($ldap_mobile)) + { + print ''; + print $ldap_mobile; + } + else + { + print ''; + } + print '
'.$langs->trans("Fax").''; + if (! empty($ldap_fax)) + { + print ''; + print $ldap_fax; + } + else + { + print ''; + } + print '
'.$langs->trans("Skype").''; + if (! empty($ldap_skype)) + { + print ''; + print $ldap_skype; + } + else + { + print ''; + } + print '
'; + if (! empty($ldap_mail)) + { + print ''; + print $ldap_mail; + } + else + { + print ''; + } + print '
'.$langs->trans("Signature").''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('signature',GETPOST('signature'),'',138,'dolibarr_mailings','In',true,true,empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1,ROWS_4,90); + print $doleditor->Create(1); + print '
'.$langs->trans("Entity").'".$mc->select_entities($conf->entity); + print "
'.$langs->trans("HierarchicalResponsible").''; + print $form->select_dolusers($object->fk_user,'fk_user',1,array($object->id),0,'',0,$conf->entity); + print '
'.$langs->trans("AccountancyCode").''; + print ''; + print '
'; + print $langs->trans("Note"); + print ''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('note','','',180,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_4,90); + $doleditor->Create(); + print "
\n"; + + dol_fiche_end(); + + print '
'; + print ''; + //print '     '; + //print ''; + print '
'; + + print "
"; +} +else +{ + /* ************************************************************************** */ + /* */ + /* View and edition */ + /* */ + /* ************************************************************************** */ + + if ($id > 0) + { + $object->fetch($id); + if ($res < 0) { dol_print_error($db,$object->error); exit; } + $res=$object->fetch_optionals($object->id,$extralabels); + + // Show tabs + $head = employee_prepare_head($object); + $title = $langs->trans("Employee"); + + /* + * View mode + */ + if ($action != 'edit') + { + dol_fiche_head($head, 'employee', $title, 0, 'user'); + + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); + + + print '
'; + print '
'; + + print '
'; + print ''; + + // Position/Job + print ''; + print ''; + print ''."\n"; + + // Gender + print ''; + print ''; + + // Skype + if (! empty($conf->skype->enabled)) + { + print ''; + print ''; + print "\n"; + } + + // Signature + print '\n"; + + // Hierarchy + print ''; + print ''; + print "\n"; + + // Accountancy code + if ($conf->salaries->enabled) + { + print ''; + print ''; + } + + print '
'.$langs->trans("PostOrFunction").''.$object->job.'
'.$langs->trans("Gender").''; + if ($object->gender) print $langs->trans("Gender".$object->gender); + print '
'.$langs->trans("Skype").''.dol_print_skype($object->skype,0,0,1).'
'.$langs->trans('Signature').''; + print dol_htmlentitiesbr($object->signature); + print "
'.$langs->trans("HierarchicalResponsible").''; + if (empty($object->fk_user)) print $langs->trans("None"); + else { + $huser=new User($db); + $huser->fetch($object->fk_user); + print $huser->getNomUrl(1); + } + print '
'.$langs->trans("AccountancyCode").''.$object->accountancy_code.'
'; + + print '
'; + print '
'; + + print '
'; + print ''; + + // Other attributes + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $object->showOptionals($extrafields); + } + + print "
\n"; + print '
'; + + print '
'; + print '
'; + + + dol_fiche_end(); + + + /* + * Buttons actions + */ + + print '
'; + + if ($caneditfield && (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + { + if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) + { + print ''; + } + else + { + print ''; + } + } + elseif ($caneditpassword && ! $object->ldap_sid && + (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + { + print ''; + } + + // Si on a un gestionnaire de generation de mot de passe actif + if ($conf->global->USER_PASSWORD_GENERATED != 'none') + { + if ($object->statut == 0) + { + print ''; + } + elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + { + print ''; + } + + if ($object->statut == 0) + { + print ''; + } + else if (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + { + if ($object->email) print ''; + else print ''; + } + } + + // Activer + if ($user->id <> $id && $candisableuser && $object->statut == 0 && + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + { + print ''; + } + // Desactiver + if ($user->id <> $id && $candisableuser && $object->statut == 1 && + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + { + print ''; + } + // Delete + if ($user->id <> $id && $candisableuser && + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + { + if ($user->admin || ! $object->admin) // If user edited is admin, delete is possible on for an admin + { + print ''; + } + else + { + print ''; + } + } + + print "
\n"; + print "
\n"; + + + /* + * Groups assigned to user + */ + print ''; + print ''; + print ''; + if(! empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + { + print ''; + } + print "\n"; + + if (! empty($groupslist)) + { + $var=true; + + foreach($groupslist as $group) + { + $var=!$var; + + print ""; + print ''; + if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + { + print '\n"; + } + } + else + { + print ''; + } + + print "
'.$langs->trans("Groups").''.$langs->trans("Entity").' 
'; + if ($caneditgroup) + { + print ''.img_object($langs->trans("ShowGroup"),"group").' '.$group->name.''; + } + else + { + print img_object($langs->trans("ShowGroup"),"group").' '.$group->name; + } + print ''; + if (! empty($group->usergroup_entity)) + { + $nb=0; + foreach($group->usergroup_entity as $group_entity) + { + $mc->getInfo($group_entity); + print ($nb > 0 ? ', ' : '').$mc->label; + print ''; + print img_delete($langs->trans("RemoveFromGroup")); + print ''; + $nb++; + } + } + } + print ''; + if ($caneditgroup && empty($conf->multicompany->transverse_mode)) + { + print ''; + print img_delete($langs->trans("RemoveFromGroup")); + print ''; + } + else + { + print " "; + } + print "
'.$langs->trans("None").'
"; + print "
"; + } + + /* + * Fiche en mode edition + */ + if ($action == 'edit' && ($canedituser || $caneditfield || $caneditpassword || ($user->id == $object->id))) + { + print '
'; + print ''; + print ''; + print ''; + + dol_fiche_head($head, 'user', $title, 0, 'user'); + + $rowspan=17; + if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) $rowspan++; + if (! empty($conf->societe->enabled)) $rowspan++; + if (! empty($conf->adherent->enabled)) $rowspan++; + if (! empty($conf->skype->enabled)) $rowspan++; + if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) $rowspan = $rowspan+3; + if (! empty($conf->agenda->enabled)) $rowspan++; + + print ''; + + // Ref/ID + if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) + { + print ''; + print ''; + print ''; + } + + // Lastname + print ""; + print ''; + print ''; + + // Photo + print ''; + + print ''; + + // Firstname + print "".''; + print ''; + + // Employee + print ''; + print ''; + + // Position/Job + print ''; + print ''; + + // Gender + print ''; + print ''; + + // Login + print "".''; + print ''; + print ''; + + // Pass + print ''; + print '\n"; + + // API key + if(! empty($conf->api->enabled) && $user->admin) { + print ''; + print ''; + } + + // Administrator + print ''; + if ($object->societe_id > 0) + { + $langs->load("admin"); + print ''; + } + else + { + print ''; + } + + // Type + print ''; + print ''; + + // Tel pro + print "".''; + print ''; + + // Tel mobile + print "".''; + print ''; + + // Fax + print "".''; + print ''; + + // Skype + if (! empty($conf->skype->enabled)) + { + print ''; + print ''; + } + + // EMail + print "".'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").''; + print ''; + + // Signature + print "".''; + print ''; + + // OpenID url + if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) + { + print "".''; + print ''; + } + + // Hierarchy + print ''; + print ''; + print "\n"; + + if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) + { + $langs->load("salaries"); + + // THM + print ''; + print ''; + print "\n"; + + // TJM + print ''; + print ''; + print "\n"; + + // Salary + print ''; + print ''; + print "\n"; + } + + // Weeklyhours + print ''; + print ''; + print "\n"; + + // Accountancy code + if ($conf->salaries->enabled) + { + print ""; + print ''; + print ''; + print ""; + } + + // User color + if (! empty($conf->agenda->enabled)) + { + print ''; + print ''; + } + + // Status + print ''; + print ''; + + // Company / Contact + if (! empty($conf->societe->enabled)) + { + print ''; + print ''; + print "\n"; + } + + // Module Adherent + if (! empty($conf->adherent->enabled)) + { + $langs->load("members"); + print ''; + print ''; + print "\n"; + } + + // Multicompany + // TODO check if user not linked with the current entity before change entity (thirdparty, invoice, etc.) !! + if (! empty($conf->multicompany->enabled) && is_object($mc)) + { + if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + { + print "".''; + print "\n"; + } + else + { + print ''; + } + } + + // Other attributes + $parameters=array('colspan' => ' colspan="2"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $object->showOptionals($extrafields,'edit'); + } + + print '
'.$langs->trans("Ref").''; + print $object->id; + print '
'.$langs->trans("Lastname").''; + if ($caneditfield && !$object->ldap_sid) + { + print ''; + } + else + { + print ''; + print $object->lastname; + } + print ''; + print $form->showphoto('userphoto',$object,100,0,$caneditfield); + print '
'.$langs->trans("Firstname").''; + if ($caneditfield && !$object->ldap_sid) + { + print ''; + } + else + { + print ''; + print $object->firstname; + } + print '
'.fieldLabel('Employee','employee',0).''; + print $form->selectyesno("employee",$object->employee,1); + print '
'.$langs->trans("PostOrFunction").''; + if ($caneditfield) + { + print ''; + } + else + { + print ''; + print $object->job; + } + print '
'.$langs->trans("Gender").''; + $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('gender', $arraygender, GETPOST('gender')?GETPOST('gender'):$object->gender, 1); + print '
'.$langs->trans("Login").''; + if ($user->admin && !$object->ldap_sid) + { + print ''; + } + else + { + print ''; + print $object->login; + } + print '
'.$langs->trans("Password").''; + if ($object->ldap_sid) + { + $text=$langs->trans("DomainPassword"); + } + else if ($caneditpassword) + { + $text=''; + if ($dolibarr_main_authentication && $dolibarr_main_authentication == 'http') + { + $text=$form->textwithpicto($text,$langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless",$dolibarr_main_authentication),1,'warning'); + } + } + else + { + $text=preg_replace('/./i','*',$object->pass); + } + print $text; + print "
'.$langs->trans("ApiKey").''; + print ''; + if (! empty($conf->use_javascript_ajax)) + print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"'); + print '
'.$langs->trans("Administrator").''; + print ''.yn($object->admin); + print ' ('.$langs->trans("ExternalUser").')'; + print '
'; + $nbAdmin = $user->getNbOfUsers('active','',1); + $nbSuperAdmin = $user->getNbOfUsers('active','superadmin',1); + //var_dump($nbAdmin); + //var_dump($nbSuperAdmin); + if ($user->admin // Need to be admin to allow downgrade of an admin + && ($user->id != $object->id) // Don't downgrade ourself + && ( + (empty($conf->multicompany->enabled) && $nbAdmin > 1) + || (! empty($conf->multicompany->enabled) && ($object->entity > 0 || $nbSuperAdmin > 1)) // Don't downgrade a superadmin if alone + ) + ) + { + print $form->selectyesno('admin',$object->admin,1); + + if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode)) + { + if ($conf->use_javascript_ajax) + { + print ''; + } + + $checked=(($object->admin && ! $object->entity) ? ' checked' : ''); + print ' '.$langs->trans("SuperAdministrator"); + } + } + else + { + $yn = yn($object->admin); + print ''; + print ''; + if (! empty($conf->multicompany->enabled) && empty($object->entity)) print $form->textwithpicto($yn,$langs->trans("DontDowngradeSuperAdmin"),1,'warning'); + else print $yn; + } + print '
'.$langs->trans("Type").''; + if ($user->id == $object->id || ! $user->admin) + { + $type=$langs->trans("Internal"); + if ($object->societe_id) $type=$langs->trans("External"); + print $form->textwithpicto($type,$langs->trans("InternalExternalDesc")); + if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; + } + else + { + $type=0; + if ($object->contact_id) $type=$object->contact_id; + print $form->selectcontacts(0,$type,'contactid',2,'','',1,'',false,1); + if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; + } + print '
'.$langs->trans("PhonePro").''; + if ($caneditfield && empty($object->ldap_sid)) + { + print ''; + } + else + { + print ''; + print $object->office_phone; + } + print '
'.$langs->trans("PhoneMobile").''; + if ($caneditfield && empty($object->ldap_sid)) + { + print ''; + } + else + { + print ''; + print $object->user_mobile; + } + print '
'.$langs->trans("Fax").''; + if ($caneditfield && empty($object->ldap_sid)) + { + print ''; + } + else + { + print ''; + print $object->office_fax; + } + print '
'.$langs->trans("Skype").''; + if ($caneditfield && empty($object->ldap_sid)) + { + print ''; + } + else + { + print ''; + print $object->skype; + } + print '
'; + if ($caneditfield && empty($object->ldap_sid)) + { + print ''; + } + else + { + print ''; + print $object->email; + } + print '
'.$langs->trans("Signature").''; + if ($caneditfield) + { + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('signature',$object->signature,'',138,'dolibarr_mailings','In',false,true,empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1,ROWS_4,72); + print $doleditor->Create(1); + } + else + { + print dol_htmlentitiesbr($object->signature); + } + print '
'.$langs->trans("OpenIDURL").''; + if ($caneditfield) + { + print ''; + } + else + { + print ''; + print $object->openid; + } + print '
'.$langs->trans("HierarchicalResponsible").''; + if ($caneditfield) + { + print $form->select_dolusers($object->fk_user,'fk_user',1,array($object->id),0,'',0,$object->entity); + } + else + { + print ''; + $huser=new User($db); + $huser->fetch($object->fk_user); + print $huser->getNomUrl(1); + } + print '
'; + $text=$langs->trans("THM"); + print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm'); + print ''; + print ''; + print '
'; + $text=$langs->trans("TJM"); + print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classthm'); + print ''; + print ''; + print '
'.$langs->trans("Salary").''; + print ''; + print '
'.$langs->trans("WeeklyHours").''; + print ''; + print '
'.$langs->trans("AccountancyCode").''; + if ($caneditfield) + { + print ''; + } + else + { + print ''; + print $object->accountancy_code; + } + print '
'.$langs->trans("ColorUser").''; + print $formother->selectColor(GETPOST('color')?GETPOST('color'):$object->color, 'color', null, 1, '', 'hideifnotset'); + print '
'.$langs->trans("Status").''; + print $object->getLibStatut(4); + print '
'.$langs->trans("LinkToCompanyContact").''; + if ($object->societe_id > 0) + { + $societe = new Societe($db); + $societe->fetch($object->societe_id); + print $societe->getNomUrl(1,''); + if ($object->contact_id) + { + $contact = new Contact($db); + $contact->fetch($object->contact_id); + print ' / '.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).''; + } + } + else + { + print $langs->trans("ThisUserIsNot"); + } + print ' ('.$langs->trans("UseTypeFieldToChange").')'; + print '
'.$langs->trans("LinkedToDolibarrMember").''; + if ($object->fk_member) + { + $adh=new Adherent($db); + $adh->fetch($object->fk_member); + $adh->ref=$adh->login; // Force to show login instead of id + print $adh->getNomUrl(1); + } + else + { + print $langs->trans("UserNotLinkedToMember"); + } + print '
'.$langs->trans("Entity").'".$mc->select_entities($object->entity, 'entity', '', 0, 1); // last parameter 1 means, show also a choice 0=>'all entities' + print "
'; + + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print '
'; + } + + if (! empty($conf->ldap->enabled) && ! empty($object->ldap_sid)) $ldap->close; + } +} + +if (! empty($conf->api->enabled) && ! empty($conf->use_javascript_ajax)) +{ + print "\n".''; +} + +llxFooter(); +$db->close(); diff --git a/htdocs/langs/en_US/hrm.lang b/htdocs/langs/en_US/hrm.lang index 4fe6c8e761a..733630ffcf4 100644 --- a/htdocs/langs/en_US/hrm.lang +++ b/htdocs/langs/en_US/hrm.lang @@ -14,3 +14,4 @@ ListOfEmployees=List of employees Employees=Employees Employee=Employee NewEmployee=New employee +EmployeeCard=Employee card From 154f88a58cd7d6af0ecea920cbf145022fedd378 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 12 Nov 2015 07:24:52 +0100 Subject: [PATCH 04/12] HRM: Copy info from user --- htdocs/hrm/employee/info.php | 94 ++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 htdocs/hrm/employee/info.php diff --git a/htdocs/hrm/employee/info.php b/htdocs/hrm/employee/info.php new file mode 100644 index 00000000000..dac6d34c7fa --- /dev/null +++ b/htdocs/hrm/employee/info.php @@ -0,0 +1,94 @@ + + * Copyright (C) 2005-2015 Regis Houssin + * Copyright (C) 2015 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/user/info.php + * \ingroup core + * \brief Page des informations d'un utilisateur + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + +$langs->load("users"); + +// Security check +$id = GETPOST('id','int'); +$object = new User($db); +if ($id > 0 || ! empty($ref)) +{ + $result = $object->fetch($id, $ref); +} + +// Security check +$socid=0; +if ($user->societe_id > 0) $socid = $user->societe_id; +$feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); +if ($user->id == $id) // A user can always read its own card +{ + $feature2=''; +} +$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); + +// If user is not user that read and no permission to read other users, we stop +if (($object->id != $user->id) && (! $user->rights->user->user->lire)) + accessforbidden(); + + + +/* + * View + */ + +$form = new Form($db); + +llxHeader('',$langs->trans("EmployeeCard")); + +$head = employee_prepare_head($object); + +$title = $langs->trans("Employee"); +dol_fiche_head($head, 'info', $title, 0, 'user'); + + +$linkback = ''.$langs->trans("BackToList").''; + +dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin); + + +$object->info($id); // This overwrite ->ref with login instead of id + + +print '
'; + +print '
'; + +print '
'; + +dol_print_object_info($object); + +print '
'; + + +dol_fiche_end(); + + +llxFooter(); +$db->close(); From bedba7ffb70f654d4eb2e2939cb0b890c47cc386 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 12 Nov 2015 07:26:51 +0100 Subject: [PATCH 05/12] HRM: add a mode 'employee' for development to show tab --- htdocs/core/modules/modHoliday.class.php | 2 +- htdocs/holiday/list.php | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 26d01c34371..9ca28f0c040 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -113,7 +113,7 @@ class modHoliday extends DolibarrModules // 'contact' to add a tab in contact view // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) $this->tabs = array('user:+paidholidays:CPTitreMenu:holiday:$user->rights->holiday->read:/holiday/list.php?mainmenu=holiday&id=__ID__'); - $this->tabs = array('employee:+paidholidays:CPTitreMenu:holiday:$user->rights->holiday->read:/holiday/list.php?mainmenu=holiday&id=__ID__'); + $this->tabs = array('employee:+paidholidays:CPTitreMenu:holiday:$user->rights->holiday->read:/holiday/list.php?mainmenu=holiday&mode=employee&id=__ID__'); // Boxes $this->boxes = array(); // List of boxes diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 09d7d165d1f..eeb44703048 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php'; $langs->load('users'); $langs->load('holidays'); @@ -39,6 +40,7 @@ $langs->load('holidays'); // Protection if external user if ($user->societe_id > 0) accessforbidden(); +$mode = GETPOST("mode",'alpha'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); @@ -226,13 +228,22 @@ $formother = new FormOther($db); if ($id > 0) { - $head = user_prepare_head($fuser); + if ($mode == 'employee') // For HRM module development + { + $head = employee_prepare_head($fuser); + $title = $langs->trans("Employee"); + $linkback = ''.$langs->trans("BackToList").''; + } + else + { + $head = user_prepare_head($fuser); + $title = $langs->trans("User"); + $linkback = ''.$langs->trans("BackToList").''; + } - $title = $langs->trans("User"); + dol_fiche_head($head, 'paidholidays', $title, 0, 'user'); - $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($fuser,'id',$linkback,$user->rights->user->user->lire || $user->admin); From 30c4f1c896c569ebec064b00adbe8b85a7bd89be Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 12 Nov 2015 07:40:46 +0100 Subject: [PATCH 06/12] HRM : language --- htdocs/core/modules/modHRM.class.php | 4 ++-- htdocs/langs/en_US/hrm.lang | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index 1e82db5dfc4..0ce7061617b 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -91,8 +91,8 @@ class modHRM extends DolibarrModules MAIN_DB_PREFIX."c_hrm_function" ), 'tablib'=>array( - "DepartmentDict", - "FunctionDict" + "DictionaryDepartment", + "DictionaryFunction" ), 'tabsql'=>array( 'SELECT rowid, pos, code, label, active FROM '.MAIN_DB_PREFIX.'c_hrm_department', diff --git a/htdocs/langs/en_US/hrm.lang b/htdocs/langs/en_US/hrm.lang index 733630ffcf4..1ea8d970a3f 100644 --- a/htdocs/langs/en_US/hrm.lang +++ b/htdocs/langs/en_US/hrm.lang @@ -9,6 +9,9 @@ DeleteEstablishment=Delete establishment ConfirmDeleteEstablishment=Are-you sure to delete this establishment ? OpenEtablishment=Open establishment CloseEtablishment=Close establishment +# Dictionary +DictionaryDepartment=HRM - Department list +DictionaryFunction=HRM - Function list # Module ListOfEmployees=List of employees Employees=Employees From b7b25c9682cdedd4189a6cd650e201332d29b3e8 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 17 Nov 2015 21:04:11 +0100 Subject: [PATCH 07/12] Remove some code --- htdocs/core/lib/hrm.lib.php | 29 - htdocs/hrm/employee/card.php | 1677 ---------------------------------- 2 files changed, 1706 deletions(-) delete mode 100644 htdocs/hrm/employee/card.php diff --git a/htdocs/core/lib/hrm.lib.php b/htdocs/core/lib/hrm.lib.php index dd3f17ef995..5f7eabc7500 100644 --- a/htdocs/core/lib/hrm.lib.php +++ b/htdocs/core/lib/hrm.lib.php @@ -22,35 +22,6 @@ */ $langs->load('hrm'); -/** - * Return head table for employee tabs screen - * - * @param object $object contact - * @return array head table of tabs - */ -function employee_prepare_head($object) { - global $langs, $conf, $user; - - $h = 0; - $head = array (); - - $head [$h] [0] = DOL_URL_ROOT.'/hrm/employee/card.php?id=' . $object->id; - $head [$h] [1] = $langs->trans("Card"); - $head [$h] [2] = 'employee'; - $h ++; - - complete_head_from_modules($conf, $langs, $object, $head, $h, 'employee'); - - $head [$h] [0] = DOL_URL_ROOT.'/hrm/employee/info.php?id=' . $object->id; - $head [$h] [1] = $langs->trans("Info"); - $head [$h] [2] = 'info'; - $h ++; - - complete_head_from_modules($conf, $langs, $object, $head, $h, 'employee', 'remove'); - - return $head; -} - /** * Return head table for establishment tabs screen * diff --git a/htdocs/hrm/employee/card.php b/htdocs/hrm/employee/card.php deleted file mode 100644 index aa7bd92ec8b..00000000000 --- a/htdocs/hrm/employee/card.php +++ /dev/null @@ -1,1677 +0,0 @@ - - * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2015 Regis Houssin - * Copyright (C) 2005 Lionel Cousteix - * Copyright (C) 2011 Herve Prot - * Copyright (C) 2012 Juanjo Menent - * Copyright (C) 2013 Florian Henry - * Copyright (C) 2013-2015 Alexandre Spangaro - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2015 Ari Elbaz (elarifr) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/hrm/employee/card.php - * \ingroup HRM - * \brief Tab of employee card - */ - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; -require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; -require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -if (! empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; -if (! empty($conf->multicompany->enabled)) dol_include_once('/multicompany/class/actions_multicompany.class.php'); - -$id = GETPOST('id','int'); -$action = GETPOST('action','alpha'); -$confirm = GETPOST('confirm','alpha'); -$subaction = GETPOST('subaction','alpha'); -$group = GETPOST("group","int",3); - -// Define value to know what current user can do on users -$canadduser=(! empty($user->admin) || $user->rights->user->user->creer); -$canreaduser=(! empty($user->admin) || $user->rights->user->user->lire); -$canedituser=(! empty($user->admin) || $user->rights->user->user->creer); -$candisableuser=(! empty($user->admin) || $user->rights->user->user->supprimer); -$canreadgroup=$canreaduser; -$caneditgroup=$canedituser; -if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) -{ - $canreadgroup=(! empty($user->admin) || $user->rights->user->group_advance->read); - $caneditgroup=(! empty($user->admin) || $user->rights->user->group_advance->write); -} -// Define value to know what current user can do on properties of edited user -if ($id) -{ - // $user est le user qui edite, $id est l'id de l'utilisateur edite - $caneditfield=((($user->id == $id) && $user->rights->user->self->creer) - || (($user->id != $id) && $user->rights->user->user->creer)); - $caneditpassword=((($user->id == $id) && $user->rights->user->self->password) - || (($user->id != $id) && $user->rights->user->user->password)); -} - -// Security check -$socid=0; -if ($user->societe_id > 0) $socid = $user->societe_id; -$feature2='user'; -if ($user->id == $id) { $feature2=''; $canreaduser=1; } // A user can always read its own card -if (!$canreaduser) { - $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); -} -if ($user->id <> $id && ! $canreaduser) accessforbidden(); - -$langs->load("users"); -$langs->load("companies"); -$langs->load("ldap"); -$langs->load("admin"); -$langs->load("hrm"); - -$object = new User($db); -$extrafields = new ExtraFields($db); - -// fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); - -// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array -$hookmanager->initHooks(array('usercard','globalcard')); - - - -/** - * Actions - */ - -$parameters=array('id'=>$socid); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - -if (empty($reshook)) { - - if ($action == 'confirm_disable' && $confirm == "yes" && $candisableuser) { - if ($id <> $user->id) { - $object->fetch($id); - $object->setstatus(0); - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); - exit; - } - } - if ($action == 'confirm_enable' && $confirm == "yes" && $candisableuser) { - $error = 0; - - if ($id <> $user->id) { - $object->fetch($id); - - if (!empty($conf->file->main_limit_users)) { - $nb = $object->getNbOfUsers("active"); - if ($nb >= $conf->file->main_limit_users) { - $error ++; - setEventMessage($langs->trans("YourQuotaOfUsersIsReached"), 'errors'); - } - } - - if (!$error) { - $object->setstatus(1); - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); - exit; - } - } - } - - if ($action == 'confirm_delete' && $confirm == "yes" && $candisableuser) { - if ($id <> $user->id) { - $object = new User($db); - $object->id = $id; - $result = $object->delete(); - if ($result < 0) { - $langs->load("errors"); - setEventMessage($langs->trans("ErrorUserCannotBeDelete"), 'errors'); - } else { - header("Location: index.php"); - exit; - } - } - } - - // Action Add user - if ($action == 'add' && $canadduser) { - $error = 0; - - if (!$_POST["lastname"]) { - $error ++; - setEventMessage($langs->trans("NameNotDefined"), 'errors'); - $action = "create"; // Go back to create page - } - if (!$_POST["login"]) { - $error ++; - setEventMessage($langs->trans("LoginNotDefined"), 'errors'); - $action = "create"; // Go back to create page - } - - if (!empty($conf->file->main_limit_users)) { // If option to limit users is set - $nb = $object->getNbOfUsers("active"); - if ($nb >= $conf->file->main_limit_users) { - $error ++; - setEventMessage($langs->trans("YourQuotaOfUsersIsReached"), 'errors'); - $action = "create"; // Go back to create page - } - } - - if (!$error) { - $object->lastname = GETPOST("lastname", 'alpha'); - $object->firstname = GETPOST("firstname", 'alpha'); - $object->login = GETPOST("login", 'alpha'); - $object->api_key = GETPOST("api_key", 'alpha'); - $object->gender = GETPOST("gender", 'alpha'); - $object->admin = GETPOST("admin", 'alpha'); - $object->office_phone = GETPOST("office_phone", 'alpha'); - $object->office_fax = GETPOST("office_fax", 'alpha'); - $object->user_mobile = GETPOST("user_mobile"); - $object->skype = GETPOST("skype"); - $object->email = GETPOST("email", 'alpha'); - $object->job = GETPOST("job", 'alpha'); - $object->signature = GETPOST("signature"); - $object->accountancy_code = GETPOST("accountancy_code"); - $object->note = GETPOST("note"); - $object->ldap_sid = GETPOST("ldap_sid"); - $object->fk_user = GETPOST("fk_user") > 0 ? GETPOST("fk_user") : 0; - $object->employee = GETPOST('employee'); - - $object->thm = GETPOST("thm") != '' ? GETPOST("thm") : ''; - $object->tjm = GETPOST("tjm") != '' ? GETPOST("tjm") : ''; - $object->salary = GETPOST("salary") != '' ? GETPOST("salary") : ''; - $object->salaryextra = GETPOST("salaryextra") != '' ? GETPOST("salaryextra") : ''; - $object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : ''; - - $object->color = GETPOST("color") != '' ? GETPOST("color") : ''; - - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - if ($ret < 0) { - $error ++; - } - - // Set entity property - $entity = GETPOST('entity', 'int'); - if (!empty($conf->multicompany->enabled)) { - if (!empty($_POST["superadmin"])) { - $object->entity = 0; - } else { - if ($conf->multicompany->transverse_mode) { - $object->entity = 1; // all users are forced into master entity - } else { - $object->entity = ($entity == '' ? 1 : $entity); - } - } - } else { - $object->entity = ($entity == '' ? 1 : $entity); - /*if ($user->admin && $user->entity == 0 && GETPOST("admin",'alpha')) - { - }*/ - } - - $db->begin(); - - $id = $object->create($user); - if ($id > 0) { - if (isset($_POST['password']) && trim($_POST['password'])) { - $object->setPassword($user, trim($_POST['password'])); - } - - $db->commit(); - - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); - exit; - } else { - $langs->load("errors"); - $db->rollback(); - if (is_array($object->errors) && count($object->errors)) { - setEventMessage($object->errors, 'errors'); - } else { - setEventMessage($object->error, 'errors'); - } - $action = "create"; // Go back to create page - } - } - } - - // Action add usergroup - if (($action == 'addgroup' || $action == 'removegroup') && $caneditfield) - { - if ($group) - { - $editgroup = new UserGroup($db); - $editgroup->fetch($group); - $editgroup->oldcopy=clone $editgroup; - - $object->fetch($id); - if ($action == 'addgroup') { - $object->SetInGroup($group, ($conf->multicompany->transverse_mode ? GETPOST("entity") : $editgroup->entity)); - } - if ($action == 'removegroup') { - $object->RemoveFromGroup($group, ($conf->multicompany->transverse_mode ? GETPOST("entity") : $editgroup->entity)); - } - - if ($result > 0) { - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); - exit; - } else { - setEventMessage($object->error, 'errors'); - } - } - } - - if ($action == 'update' && !$_POST["cancel"]) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - if ($caneditfield) // Case we can edit all field - { - $error = 0; - - if (!$_POST["lastname"]) { - setEventMessage($langs->trans("NameNotDefined"), 'errors'); - $action = "edit"; // Go back to create page - $error ++; - } - if (!$_POST["login"]) { - setEventMessage($langs->trans("LoginNotDefined"), 'errors'); - $action = "edit"; // Go back to create page - $error ++; - } - - if (!$error) { - $object->fetch($id); - - $object->oldcopy = clone $object; - - if (!$error) { - $db->begin(); - - $object->oldcopy = dol_clone($object); - - $object->lastname = GETPOST("lastname", 'alpha'); - $object->firstname = GETPOST("firstname", 'alpha'); - $object->login = GETPOST("login", 'alpha'); - $object->gender = GETPOST("gender", 'alpha'); - $object->pass = GETPOST("password"); - $object->api_key = (GETPOST("api_key", 'alpha')) ? GETPOST("api_key", 'alpha') : $object->api_key; - $object->admin = empty($user->admin) ? 0 : GETPOST("admin"); // A user can only be set admin by an admin - $object->office_phone = GETPOST("office_phone", 'alpha'); - $object->office_fax = GETPOST("office_fax", 'alpha'); - $object->user_mobile = GETPOST("user_mobile"); - $object->skype = GETPOST("skype"); - $object->email = GETPOST("email", 'alpha'); - $object->job = GETPOST("job", 'alpha'); - $object->signature = GETPOST("signature"); - $object->accountancy_code = GETPOST("accountancy_code"); - $object->openid = GETPOST("openid"); - $object->fk_user = GETPOST("fk_user") > 0 ? GETPOST("fk_user") : 0; - $object->employee = GETPOST('employee'); - - $object->thm = GETPOST("thm") != '' ? GETPOST("thm") : ''; - $object->tjm = GETPOST("tjm") != '' ? GETPOST("tjm") : ''; - $object->salary = GETPOST("salary") != '' ? GETPOST("salary") : ''; - $object->salaryextra = GETPOST("salaryextra") != '' ? GETPOST("salaryextra") : ''; - $object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : ''; - - if (! empty($conf->multicompany->enabled)) - { - if (! empty($_POST["superadmin"])) - { - $object->entity = 0; - } - else if ($conf->multicompany->transverse_mode) - { - $object->entity = 1; // all users in master entity - } - else - { - $object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); - } - } - else - { - $object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); - } - - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - if ($ret < 0) { - $error ++; - } - - if (!empty($conf->multicompany->enabled)) { - if (!empty($_POST["superadmin"])) { - $object->entity = 0; - } else { - if ($conf->multicompany->transverse_mode) { - $object->entity = 1; // all users in master entity - } else { - $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); - } - } - } else { - $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); - } - - if (GETPOST('deletephoto')) { - $object->photo = ''; - } - if (!empty($_FILES['photo']['name'])) { - $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); - } - - if (!$error) { - $ret = $object->update($user); - if ($ret < 0) { - $error ++; - if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - setEventMessage($langs->trans("ErrorLoginAlreadyExists", $object->login), 'errors'); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } - - if (!$error && isset($_POST['contactid'])) { - $contactid = GETPOST('contactid'); - - if ($contactid > 0) { - $contact = new Contact($db); - $contact->fetch($contactid); - - $sql = "UPDATE ".MAIN_DB_PREFIX."user"; - $sql .= " SET fk_socpeople=".$db->escape($contactid); - if ($contact->socid) { - $sql .= ", fk_soc=".$db->escape($contact->socid); - } - $sql .= " WHERE rowid=".$object->id; - } else { - $sql = "UPDATE ".MAIN_DB_PREFIX."user"; - $sql .= " SET fk_socpeople=NULL, fk_soc=NULL"; - $sql .= " WHERE rowid=".$object->id; - } - dol_syslog("fiche::update", LOG_DEBUG); - $resql = $db->query($sql); - if (!$resql) { - $error ++; - setEventMessage($db->lasterror(), 'errors'); - } - } - - if (!$error && !count($object->errors)) { - if (GETPOST('deletephoto') && $object->photo) { - $fileimg = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/'.$object->photo; - $dirthumbs = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/thumbs'; - dol_delete_file($fileimg); - dol_delete_dir_recursive($dirthumbs); - } - - if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) { - $dir = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user'); - - dol_mkdir($dir); - - if (@is_dir($dir)) { - $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); - $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']); - - if (!$result > 0) { - setEventMessage($langs->trans("ErrorFailedToSaveFile"), 'errors'); - } else { - // Create small thumbs for company (Ratio is near 16/9) - // Used on logon for example - $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); - - // Create mini thumbs for company (Ratio is near 16/9) - // Used on menu or for setup page for example - $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); - } - } else { - $error ++; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFailedToCreateDir", $dir), $mesgs, 'errors'); - } - } - } - - if (!$error && !count($object->errors)) { - setEventMessage($langs->trans("UserModified")); - $db->commit(); - - $login = $_SESSION["dol_login"]; - if ($login && $login == $object->oldcopy->login && $object->oldcopy->login != $object->login) // Current user has changed its login - { - $error++; - $langs->load("errors"); - setEventMessages($langs->transnoentitiesnoconv("ErrorFailedToCreateDir", $dir), $mesgs, 'errors'); - } - } else { - $db->rollback(); - } - } - } else { - if ($caneditpassword) // Case we can edit only password - { - $object->fetch($id); - - $object->oldcopy = dol_clone($object); - - $ret = $object->setPassword($user, $_POST["password"]); - if ($ret < 0) { - setEventMessage($object->error, 'errors'); - } - } - } - } - - $object->oldcopy = clone $object; - - $ret=$object->setPassword($user,$_POST["password"]); - if ($ret < 0) - { - setEventMessage($object->error, 'errors'); - } - } - - // Change password with a new generated one - if ((($action == 'confirm_password' && $confirm == 'yes') - || ($action == 'confirm_passwordsend' && $confirm == 'yes')) && $caneditpassword - ) { - $object->fetch($id); - - $newpassword = $object->setPassword($user, ''); - if ($newpassword < 0) { - // Echec - setEventMessage($langs->trans("ErrorFailedToSetNewPassword"), 'errors'); - } else { - // Succes - if ($action == 'confirm_passwordsend' && $confirm == 'yes') { - if ($object->send_password($user, $newpassword) > 0) { - setEventMessage($langs->trans("PasswordChangedAndSentTo", $object->email)); - } else { - setEventMessage($object->error, 'errors'); - } - } else { - setEventMessage($langs->trans("PasswordChangedTo", $newpassword), 'errors'); - } - } - } - - // Action initialisation donnees depuis record LDAP - if ($action == 'adduserldap') { - $selecteduser = $_POST['users']; - - $required_fields = array( - $conf->global->LDAP_KEY_USERS, - $conf->global->LDAP_FIELD_NAME, - $conf->global->LDAP_FIELD_FIRSTNAME, - $conf->global->LDAP_FIELD_LOGIN, - $conf->global->LDAP_FIELD_LOGIN_SAMBA, - $conf->global->LDAP_FIELD_PASSWORD, - $conf->global->LDAP_FIELD_PASSWORD_CRYPTED, - $conf->global->LDAP_FIELD_PHONE, - $conf->global->LDAP_FIELD_FAX, - $conf->global->LDAP_FIELD_MOBILE, - $conf->global->LDAP_FIELD_SKYPE, - $conf->global->LDAP_FIELD_MAIL, - $conf->global->LDAP_FIELD_TITLE, - $conf->global->LDAP_FIELD_DESCRIPTION, - $conf->global->LDAP_FIELD_SID - ); - - $ldap = new Ldap(); - $result = $ldap->connect_bind(); - if ($result >= 0) { - // Remove from required_fields all entries not configured in LDAP (empty) and duplicated - $required_fields = array_unique(array_values(array_filter($required_fields, "dol_validElement"))); - - $ldapusers = $ldap->getRecords($selecteduser, $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields); - //print_r($ldapusers); - - if (is_array($ldapusers)) { - foreach ($ldapusers as $key => $attribute) { - $ldap_lastname = $attribute[$conf->global->LDAP_FIELD_NAME]; - $ldap_firstname = $attribute[$conf->global->LDAP_FIELD_FIRSTNAME]; - $ldap_login = $attribute[$conf->global->LDAP_FIELD_LOGIN]; - $ldap_loginsmb = $attribute[$conf->global->LDAP_FIELD_LOGIN_SAMBA]; - $ldap_pass = $attribute[$conf->global->LDAP_FIELD_PASSWORD]; - $ldap_pass_crypted = $attribute[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED]; - $ldap_phone = $attribute[$conf->global->LDAP_FIELD_PHONE]; - $ldap_fax = $attribute[$conf->global->LDAP_FIELD_FAX]; - $ldap_mobile = $attribute[$conf->global->LDAP_FIELD_MOBILE]; - $ldap_skype = $attribute[$conf->global->LDAP_FIELD_SKYPE]; - $ldap_mail = $attribute[$conf->global->LDAP_FIELD_MAIL]; - $ldap_sid = $attribute[$conf->global->LDAP_FIELD_SID]; - } - } - } else { - setEventMessage($ldap->error, 'errors'); - } - } -} - - -/* - * View - */ - -$form = new Form($db); -$formother=new FormOther($db); - -llxHeader('',$langs->trans("EmployeeCard")); - -if (($action == 'create') || ($action == 'adduserldap')) -{ - /* ************************************************************************** */ - /* */ - /* Affichage fiche en mode creation */ - /* */ - /* ************************************************************************** */ - - print load_fiche_titre($langs->trans("NewUser")); - - print $langs->trans("CreateInternalUserDesc")."
\n"; - print "
"; - - - if (! empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')) - { - /* - * Affiche formulaire d'ajout d'un compte depuis LDAP - * si on est en synchro LDAP vers Dolibarr - */ - - $ldap = new Ldap(); - $result = $ldap->connect_bind(); - if ($result >= 0) - { - $required_fields=array( - $conf->global->LDAP_KEY_USERS, - $conf->global->LDAP_FIELD_FULLNAME, - $conf->global->LDAP_FIELD_NAME, - $conf->global->LDAP_FIELD_FIRSTNAME, - $conf->global->LDAP_FIELD_LOGIN, - $conf->global->LDAP_FIELD_LOGIN_SAMBA, - $conf->global->LDAP_FIELD_PASSWORD, - $conf->global->LDAP_FIELD_PASSWORD_CRYPTED, - $conf->global->LDAP_FIELD_PHONE, - $conf->global->LDAP_FIELD_FAX, - $conf->global->LDAP_FIELD_MOBILE, - $conf->global->LDAP_FIELD_SKYPE, - $conf->global->LDAP_FIELD_MAIL, - $conf->global->LDAP_FIELD_TITLE, - $conf->global->LDAP_FIELD_DESCRIPTION, - $conf->global->LDAP_FIELD_SID - ); - - // Remove from required_fields all entries not configured in LDAP (empty) and duplicated - $required_fields=array_unique(array_values(array_filter($required_fields, "dol_validElement"))); - - // Get from LDAP database an array of results - $ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1); - - if (is_array($ldapusers)) - { - $liste=array(); - foreach ($ldapusers as $key => $ldapuser) - { - // Define the label string for this user - $label=''; - foreach ($required_fields as $value) - { - if ($value) - { - $label.=$value."=".$ldapuser[$value]." "; - } - } - $liste[$key] = $label; - } - - } - else - { - setEventMessage($ldap->error, 'errors'); - } - } - else - { - setEventMessage($ldap->error, 'errors'); - } - - // If user list is full, we show drop-down list - print "\n\n\n"; - - print '
'; - print ''; - print ''; - print ''; - print '
'; - print $langs->trans("LDAPUsers"); - print ''; - print ''; - if (is_array($liste) && count($liste)) - { - print $form->selectarray('users', $liste, '', 1); - } - print ''; - print ''; - print '
'; - print '
'; - - print "\n\n\n"; - print '
'; - } - - - print '
'; - print ''; - print ''; - if (! empty($ldap_sid)) print ''; - print ''; - - dol_fiche_head('', '', '', 0, ''); - - print dol_set_focus('#lastname'); - - print ''; - - print ''; - - // Lastname - print ''; - print ''; - - // Firstname - print ''; - print ''; - - // Gender - print ''; - print ''; - - // Tel - print ''; - print ''; - - // Tel portable - print ''; - print ''; - - // Fax - print ''; - print ''; - - // Skype - if (! empty($conf->skype->enabled)) - { - print ''; - print ''; - } - - // EMail - print 'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").''; - print ''; - - // Signature - print ''; - print ''; - - // Multicompany - if (! empty($conf->multicompany->enabled)) - { - if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity && is_object($mc)) - { - print "".''; - print "\n"; - } - else - { - print ''; - } - } - - // Hierarchy - print ''; - print ''; - print "\n"; - - // Accountancy code - if ($conf->salaries->enabled) - { - print ''; - print ''; - } - - // Note - print '\n"; - - // Other attributes - $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields,'edit'); - } - - print "
'.$langs->trans("Lastname").''; - if (! empty($ldap_lastname)) - { - print ''; - print $ldap_lastname; - } - else - { - print ''; - } - print '
'.$langs->trans("Firstname").''; - if (! empty($ldap_firstname)) - { - print ''; - print $ldap_firstname; - } - else - { - print ''; - } - print '
'.$langs->trans("Gender").''; - $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); - print $form->selectarray('gender', $arraygender, GETPOST('gender'), 1); - print '
'.$langs->trans("PhonePro").''; - if (! empty($ldap_phone)) - { - print ''; - print $ldap_phone; - } - else - { - print ''; - } - print '
'.$langs->trans("PhoneMobile").''; - if (! empty($ldap_mobile)) - { - print ''; - print $ldap_mobile; - } - else - { - print ''; - } - print '
'.$langs->trans("Fax").''; - if (! empty($ldap_fax)) - { - print ''; - print $ldap_fax; - } - else - { - print ''; - } - print '
'.$langs->trans("Skype").''; - if (! empty($ldap_skype)) - { - print ''; - print $ldap_skype; - } - else - { - print ''; - } - print '
'; - if (! empty($ldap_mail)) - { - print ''; - print $ldap_mail; - } - else - { - print ''; - } - print '
'.$langs->trans("Signature").''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('signature',GETPOST('signature'),'',138,'dolibarr_mailings','In',true,true,empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1,ROWS_4,90); - print $doleditor->Create(1); - print '
'.$langs->trans("Entity").'".$mc->select_entities($conf->entity); - print "
'.$langs->trans("HierarchicalResponsible").''; - print $form->select_dolusers($object->fk_user,'fk_user',1,array($object->id),0,'',0,$conf->entity); - print '
'.$langs->trans("AccountancyCode").''; - print ''; - print '
'; - print $langs->trans("Note"); - print ''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note','','',180,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_4,90); - $doleditor->Create(); - print "
\n"; - - dol_fiche_end(); - - print '
'; - print ''; - //print '     '; - //print ''; - print '
'; - - print "
"; -} -else -{ - /* ************************************************************************** */ - /* */ - /* View and edition */ - /* */ - /* ************************************************************************** */ - - if ($id > 0) - { - $object->fetch($id); - if ($res < 0) { dol_print_error($db,$object->error); exit; } - $res=$object->fetch_optionals($object->id,$extralabels); - - // Show tabs - $head = employee_prepare_head($object); - $title = $langs->trans("Employee"); - - /* - * View mode - */ - if ($action != 'edit') - { - dol_fiche_head($head, 'employee', $title, 0, 'user'); - - $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); - - - print '
'; - print '
'; - - print '
'; - print ''; - - // Position/Job - print ''; - print ''; - print ''."\n"; - - // Gender - print ''; - print ''; - - // Skype - if (! empty($conf->skype->enabled)) - { - print ''; - print ''; - print "\n"; - } - - // Signature - print '\n"; - - // Hierarchy - print ''; - print ''; - print "\n"; - - // Accountancy code - if ($conf->salaries->enabled) - { - print ''; - print ''; - } - - print '
'.$langs->trans("PostOrFunction").''.$object->job.'
'.$langs->trans("Gender").''; - if ($object->gender) print $langs->trans("Gender".$object->gender); - print '
'.$langs->trans("Skype").''.dol_print_skype($object->skype,0,0,1).'
'.$langs->trans('Signature').''; - print dol_htmlentitiesbr($object->signature); - print "
'.$langs->trans("HierarchicalResponsible").''; - if (empty($object->fk_user)) print $langs->trans("None"); - else { - $huser=new User($db); - $huser->fetch($object->fk_user); - print $huser->getNomUrl(1); - } - print '
'.$langs->trans("AccountancyCode").''.$object->accountancy_code.'
'; - - print '
'; - print '
'; - - print '
'; - print ''; - - // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields); - } - - print "
\n"; - print '
'; - - print '
'; - print '
'; - - - dol_fiche_end(); - - - /* - * Buttons actions - */ - - print '
'; - - if ($caneditfield && (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) - { - if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) - { - print ''; - } - else - { - print ''; - } - } - elseif ($caneditpassword && ! $object->ldap_sid && - (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) - { - print ''; - } - - // Si on a un gestionnaire de generation de mot de passe actif - if ($conf->global->USER_PASSWORD_GENERATED != 'none') - { - if ($object->statut == 0) - { - print ''; - } - elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) - { - print ''; - } - - if ($object->statut == 0) - { - print ''; - } - else if (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) - { - if ($object->email) print ''; - else print ''; - } - } - - // Activer - if ($user->id <> $id && $candisableuser && $object->statut == 0 && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) - { - print ''; - } - // Desactiver - if ($user->id <> $id && $candisableuser && $object->statut == 1 && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) - { - print ''; - } - // Delete - if ($user->id <> $id && $candisableuser && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) - { - if ($user->admin || ! $object->admin) // If user edited is admin, delete is possible on for an admin - { - print ''; - } - else - { - print ''; - } - } - - print "
\n"; - print "
\n"; - - - /* - * Groups assigned to user - */ - print ''; - print ''; - print ''; - if(! empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) - { - print ''; - } - print "\n"; - - if (! empty($groupslist)) - { - $var=true; - - foreach($groupslist as $group) - { - $var=!$var; - - print ""; - print ''; - if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) - { - print '\n"; - } - } - else - { - print ''; - } - - print "
'.$langs->trans("Groups").''.$langs->trans("Entity").' 
'; - if ($caneditgroup) - { - print ''.img_object($langs->trans("ShowGroup"),"group").' '.$group->name.''; - } - else - { - print img_object($langs->trans("ShowGroup"),"group").' '.$group->name; - } - print ''; - if (! empty($group->usergroup_entity)) - { - $nb=0; - foreach($group->usergroup_entity as $group_entity) - { - $mc->getInfo($group_entity); - print ($nb > 0 ? ', ' : '').$mc->label; - print ''; - print img_delete($langs->trans("RemoveFromGroup")); - print ''; - $nb++; - } - } - } - print ''; - if ($caneditgroup && empty($conf->multicompany->transverse_mode)) - { - print ''; - print img_delete($langs->trans("RemoveFromGroup")); - print ''; - } - else - { - print " "; - } - print "
'.$langs->trans("None").'
"; - print "
"; - } - - /* - * Fiche en mode edition - */ - if ($action == 'edit' && ($canedituser || $caneditfield || $caneditpassword || ($user->id == $object->id))) - { - print '
'; - print ''; - print ''; - print ''; - - dol_fiche_head($head, 'user', $title, 0, 'user'); - - $rowspan=17; - if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) $rowspan++; - if (! empty($conf->societe->enabled)) $rowspan++; - if (! empty($conf->adherent->enabled)) $rowspan++; - if (! empty($conf->skype->enabled)) $rowspan++; - if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) $rowspan = $rowspan+3; - if (! empty($conf->agenda->enabled)) $rowspan++; - - print ''; - - // Ref/ID - if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) - { - print ''; - print ''; - print ''; - } - - // Lastname - print ""; - print ''; - print ''; - - // Photo - print ''; - - print ''; - - // Firstname - print "".''; - print ''; - - // Employee - print ''; - print ''; - - // Position/Job - print ''; - print ''; - - // Gender - print ''; - print ''; - - // Login - print "".''; - print ''; - print ''; - - // Pass - print ''; - print '\n"; - - // API key - if(! empty($conf->api->enabled) && $user->admin) { - print ''; - print ''; - } - - // Administrator - print ''; - if ($object->societe_id > 0) - { - $langs->load("admin"); - print ''; - } - else - { - print ''; - } - - // Type - print ''; - print ''; - - // Tel pro - print "".''; - print ''; - - // Tel mobile - print "".''; - print ''; - - // Fax - print "".''; - print ''; - - // Skype - if (! empty($conf->skype->enabled)) - { - print ''; - print ''; - } - - // EMail - print "".'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").''; - print ''; - - // Signature - print "".''; - print ''; - - // OpenID url - if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) - { - print "".''; - print ''; - } - - // Hierarchy - print ''; - print ''; - print "\n"; - - if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) - { - $langs->load("salaries"); - - // THM - print ''; - print ''; - print "\n"; - - // TJM - print ''; - print ''; - print "\n"; - - // Salary - print ''; - print ''; - print "\n"; - } - - // Weeklyhours - print ''; - print ''; - print "\n"; - - // Accountancy code - if ($conf->salaries->enabled) - { - print ""; - print ''; - print ''; - print ""; - } - - // User color - if (! empty($conf->agenda->enabled)) - { - print ''; - print ''; - } - - // Status - print ''; - print ''; - - // Company / Contact - if (! empty($conf->societe->enabled)) - { - print ''; - print ''; - print "\n"; - } - - // Module Adherent - if (! empty($conf->adherent->enabled)) - { - $langs->load("members"); - print ''; - print ''; - print "\n"; - } - - // Multicompany - // TODO check if user not linked with the current entity before change entity (thirdparty, invoice, etc.) !! - if (! empty($conf->multicompany->enabled) && is_object($mc)) - { - if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) - { - print "".''; - print "\n"; - } - else - { - print ''; - } - } - - // Other attributes - $parameters=array('colspan' => ' colspan="2"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields,'edit'); - } - - print '
'.$langs->trans("Ref").''; - print $object->id; - print '
'.$langs->trans("Lastname").''; - if ($caneditfield && !$object->ldap_sid) - { - print ''; - } - else - { - print ''; - print $object->lastname; - } - print ''; - print $form->showphoto('userphoto',$object,100,0,$caneditfield); - print '
'.$langs->trans("Firstname").''; - if ($caneditfield && !$object->ldap_sid) - { - print ''; - } - else - { - print ''; - print $object->firstname; - } - print '
'.fieldLabel('Employee','employee',0).''; - print $form->selectyesno("employee",$object->employee,1); - print '
'.$langs->trans("PostOrFunction").''; - if ($caneditfield) - { - print ''; - } - else - { - print ''; - print $object->job; - } - print '
'.$langs->trans("Gender").''; - $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); - print $form->selectarray('gender', $arraygender, GETPOST('gender')?GETPOST('gender'):$object->gender, 1); - print '
'.$langs->trans("Login").''; - if ($user->admin && !$object->ldap_sid) - { - print ''; - } - else - { - print ''; - print $object->login; - } - print '
'.$langs->trans("Password").''; - if ($object->ldap_sid) - { - $text=$langs->trans("DomainPassword"); - } - else if ($caneditpassword) - { - $text=''; - if ($dolibarr_main_authentication && $dolibarr_main_authentication == 'http') - { - $text=$form->textwithpicto($text,$langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless",$dolibarr_main_authentication),1,'warning'); - } - } - else - { - $text=preg_replace('/./i','*',$object->pass); - } - print $text; - print "
'.$langs->trans("ApiKey").''; - print ''; - if (! empty($conf->use_javascript_ajax)) - print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"'); - print '
'.$langs->trans("Administrator").''; - print ''.yn($object->admin); - print ' ('.$langs->trans("ExternalUser").')'; - print '
'; - $nbAdmin = $user->getNbOfUsers('active','',1); - $nbSuperAdmin = $user->getNbOfUsers('active','superadmin',1); - //var_dump($nbAdmin); - //var_dump($nbSuperAdmin); - if ($user->admin // Need to be admin to allow downgrade of an admin - && ($user->id != $object->id) // Don't downgrade ourself - && ( - (empty($conf->multicompany->enabled) && $nbAdmin > 1) - || (! empty($conf->multicompany->enabled) && ($object->entity > 0 || $nbSuperAdmin > 1)) // Don't downgrade a superadmin if alone - ) - ) - { - print $form->selectyesno('admin',$object->admin,1); - - if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode)) - { - if ($conf->use_javascript_ajax) - { - print ''; - } - - $checked=(($object->admin && ! $object->entity) ? ' checked' : ''); - print ' '.$langs->trans("SuperAdministrator"); - } - } - else - { - $yn = yn($object->admin); - print ''; - print ''; - if (! empty($conf->multicompany->enabled) && empty($object->entity)) print $form->textwithpicto($yn,$langs->trans("DontDowngradeSuperAdmin"),1,'warning'); - else print $yn; - } - print '
'.$langs->trans("Type").''; - if ($user->id == $object->id || ! $user->admin) - { - $type=$langs->trans("Internal"); - if ($object->societe_id) $type=$langs->trans("External"); - print $form->textwithpicto($type,$langs->trans("InternalExternalDesc")); - if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; - } - else - { - $type=0; - if ($object->contact_id) $type=$object->contact_id; - print $form->selectcontacts(0,$type,'contactid',2,'','',1,'',false,1); - if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; - } - print '
'.$langs->trans("PhonePro").''; - if ($caneditfield && empty($object->ldap_sid)) - { - print ''; - } - else - { - print ''; - print $object->office_phone; - } - print '
'.$langs->trans("PhoneMobile").''; - if ($caneditfield && empty($object->ldap_sid)) - { - print ''; - } - else - { - print ''; - print $object->user_mobile; - } - print '
'.$langs->trans("Fax").''; - if ($caneditfield && empty($object->ldap_sid)) - { - print ''; - } - else - { - print ''; - print $object->office_fax; - } - print '
'.$langs->trans("Skype").''; - if ($caneditfield && empty($object->ldap_sid)) - { - print ''; - } - else - { - print ''; - print $object->skype; - } - print '
'; - if ($caneditfield && empty($object->ldap_sid)) - { - print ''; - } - else - { - print ''; - print $object->email; - } - print '
'.$langs->trans("Signature").''; - if ($caneditfield) - { - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('signature',$object->signature,'',138,'dolibarr_mailings','In',false,true,empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1,ROWS_4,72); - print $doleditor->Create(1); - } - else - { - print dol_htmlentitiesbr($object->signature); - } - print '
'.$langs->trans("OpenIDURL").''; - if ($caneditfield) - { - print ''; - } - else - { - print ''; - print $object->openid; - } - print '
'.$langs->trans("HierarchicalResponsible").''; - if ($caneditfield) - { - print $form->select_dolusers($object->fk_user,'fk_user',1,array($object->id),0,'',0,$object->entity); - } - else - { - print ''; - $huser=new User($db); - $huser->fetch($object->fk_user); - print $huser->getNomUrl(1); - } - print '
'; - $text=$langs->trans("THM"); - print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm'); - print ''; - print ''; - print '
'; - $text=$langs->trans("TJM"); - print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classthm'); - print ''; - print ''; - print '
'.$langs->trans("Salary").''; - print ''; - print '
'.$langs->trans("WeeklyHours").''; - print ''; - print '
'.$langs->trans("AccountancyCode").''; - if ($caneditfield) - { - print ''; - } - else - { - print ''; - print $object->accountancy_code; - } - print '
'.$langs->trans("ColorUser").''; - print $formother->selectColor(GETPOST('color')?GETPOST('color'):$object->color, 'color', null, 1, '', 'hideifnotset'); - print '
'.$langs->trans("Status").''; - print $object->getLibStatut(4); - print '
'.$langs->trans("LinkToCompanyContact").''; - if ($object->societe_id > 0) - { - $societe = new Societe($db); - $societe->fetch($object->societe_id); - print $societe->getNomUrl(1,''); - if ($object->contact_id) - { - $contact = new Contact($db); - $contact->fetch($object->contact_id); - print ' / '.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).''; - } - } - else - { - print $langs->trans("ThisUserIsNot"); - } - print ' ('.$langs->trans("UseTypeFieldToChange").')'; - print '
'.$langs->trans("LinkedToDolibarrMember").''; - if ($object->fk_member) - { - $adh=new Adherent($db); - $adh->fetch($object->fk_member); - $adh->ref=$adh->login; // Force to show login instead of id - print $adh->getNomUrl(1); - } - else - { - print $langs->trans("UserNotLinkedToMember"); - } - print '
'.$langs->trans("Entity").'".$mc->select_entities($object->entity, 'entity', '', 0, 1); // last parameter 1 means, show also a choice 0=>'all entities' - print "
'; - - dol_fiche_end(); - - print '
'; - print ''; - print '     '; - print ''; - print '
'; - - print '
'; - } - - if (! empty($conf->ldap->enabled) && ! empty($object->ldap_sid)) $ldap->close; - } -} - -if (! empty($conf->api->enabled) && ! empty($conf->use_javascript_ajax)) -{ - print "\n".''; -} - -llxFooter(); -$db->close(); From c7df6c15a2db69a54e5c6b387180c980f1623e8f Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 17 Nov 2015 21:22:45 +0100 Subject: [PATCH 08/12] Different display if employee mode --- htdocs/holiday/list.php | 4 +--- htdocs/hrm/class/employee.class.php | 2 +- htdocs/user/card.php | 17 +++++++++++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index eeb44703048..40f2e5581ca 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -32,7 +32,6 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php'; $langs->load('users'); $langs->load('holidays'); @@ -230,17 +229,16 @@ if ($id > 0) { if ($mode == 'employee') // For HRM module development { - $head = employee_prepare_head($fuser); $title = $langs->trans("Employee"); $linkback = ''.$langs->trans("BackToList").''; } else { - $head = user_prepare_head($fuser); $title = $langs->trans("User"); $linkback = ''.$langs->trans("BackToList").''; } + $head = user_prepare_head($fuser); dol_fiche_head($head, 'paidholidays', $title, 0, 'user'); diff --git a/htdocs/hrm/class/employee.class.php b/htdocs/hrm/class/employee.class.php index 1a1350b3b63..42f940811a9 100644 --- a/htdocs/hrm/class/employee.class.php +++ b/htdocs/hrm/class/employee.class.php @@ -145,7 +145,7 @@ class Employee extends CommonObject $label.= '
'; } - $link.= 'global->MAIN_OPTIMIZEFORTEXTBROWSER)) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index ffd2f878adf..957344ccbf9 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -45,6 +45,7 @@ if (! empty($conf->multicompany->enabled)) dol_include_once('/multicompany/class $id = GETPOST('id','int'); $action = GETPOST('action','alpha'); +$mode = GETPOST('mode','alpha'); $confirm = GETPOST('confirm','alpha'); $subaction = GETPOST('subaction','alpha'); $group = GETPOST("group","int",3); @@ -1108,8 +1109,18 @@ else } // Show tabs + if ($mode == 'employee') // For HRM module development + { + $title = $langs->trans("Employee"); + $linkback = ''.$langs->trans("BackToList").''; + } + else + { + $title = $langs->trans("User"); + $linkback = ''.$langs->trans("BackToList").''; + } + $head = user_prepare_head($object); - $title = $langs->trans("User"); /* * Confirmation reinitialisation mot de passe @@ -1158,9 +1169,7 @@ else { dol_fiche_head($head, 'user', $title, 0, 'user'); - $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); + dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); print '
'; From 1f9960d1bb833f94cdd4a5bf1cb78ed0a04424b4 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 17 Nov 2015 21:25:07 +0100 Subject: [PATCH 09/12] Remove info on employee card --- htdocs/hrm/employee/info.php | 94 ------------------------------------ 1 file changed, 94 deletions(-) delete mode 100644 htdocs/hrm/employee/info.php diff --git a/htdocs/hrm/employee/info.php b/htdocs/hrm/employee/info.php deleted file mode 100644 index dac6d34c7fa..00000000000 --- a/htdocs/hrm/employee/info.php +++ /dev/null @@ -1,94 +0,0 @@ - - * Copyright (C) 2005-2015 Regis Houssin - * Copyright (C) 2015 Alexandre Spangaro - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/user/info.php - * \ingroup core - * \brief Page des informations d'un utilisateur - */ - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - -$langs->load("users"); - -// Security check -$id = GETPOST('id','int'); -$object = new User($db); -if ($id > 0 || ! empty($ref)) -{ - $result = $object->fetch($id, $ref); -} - -// Security check -$socid=0; -if ($user->societe_id > 0) $socid = $user->societe_id; -$feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); -if ($user->id == $id) // A user can always read its own card -{ - $feature2=''; -} -$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); - -// If user is not user that read and no permission to read other users, we stop -if (($object->id != $user->id) && (! $user->rights->user->user->lire)) - accessforbidden(); - - - -/* - * View - */ - -$form = new Form($db); - -llxHeader('',$langs->trans("EmployeeCard")); - -$head = employee_prepare_head($object); - -$title = $langs->trans("Employee"); -dol_fiche_head($head, 'info', $title, 0, 'user'); - - -$linkback = ''.$langs->trans("BackToList").''; - -dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin); - - -$object->info($id); // This overwrite ->ref with login instead of id - - -print '
'; - -print '
'; - -print '
'; - -dol_print_object_info($object); - -print '
'; - - -dol_fiche_end(); - - -llxFooter(); -$db->close(); From 258ac45519f7f9e6a87a5ad648d183e9ef184d13 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 17 Nov 2015 22:14:39 +0100 Subject: [PATCH 10/12] Remove obsolete code --- htdocs/core/modules/modHoliday.class.php | 1 - htdocs/holiday/list.php | 14 ++------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index d3907ed1dbf..73b316ec164 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -114,7 +114,6 @@ class modHoliday extends DolibarrModules // 'contact' to add a tab in contact view // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) $this->tabs = array('user:+paidholidays:CPTitreMenu:holiday:$user->rights->holiday->read:/holiday/list.php?mainmenu=holiday&id=__ID__'); - $this->tabs = array('employee:+paidholidays:CPTitreMenu:holiday:$user->rights->holiday->read:/holiday/list.php?mainmenu=holiday&mode=employee&id=__ID__'); // Boxes $this->boxes = array(); // List of boxes diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 40f2e5581ca..2f008e5ccd1 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -39,7 +39,6 @@ $langs->load('holidays'); // Protection if external user if ($user->societe_id > 0) accessforbidden(); -$mode = GETPOST("mode",'alpha'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); @@ -227,17 +226,8 @@ $formother = new FormOther($db); if ($id > 0) { - if ($mode == 'employee') // For HRM module development - { - $title = $langs->trans("Employee"); - $linkback = ''.$langs->trans("BackToList").''; - } - else - { - $title = $langs->trans("User"); - $linkback = ''.$langs->trans("BackToList").''; - } - + $title = $langs->trans("User"); + $linkback = ''.$langs->trans("BackToList").''; $head = user_prepare_head($fuser); dol_fiche_head($head, 'paidholidays', $title, 0, 'user'); From 96d97657fdf63ff6c0a673a90fc4129d315729ae Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 17 Nov 2015 22:17:18 +0100 Subject: [PATCH 11/12] Remove obsolete code --- htdocs/hrm/class/employee.class.php | 241 ---------------------------- htdocs/hrm/employee/index.html | 0 htdocs/hrm/employee/list.php | 222 ------------------------- 3 files changed, 463 deletions(-) delete mode 100644 htdocs/hrm/class/employee.class.php delete mode 100644 htdocs/hrm/employee/index.html delete mode 100644 htdocs/hrm/employee/list.php diff --git a/htdocs/hrm/class/employee.class.php b/htdocs/hrm/class/employee.class.php deleted file mode 100644 index 42f940811a9..00000000000 --- a/htdocs/hrm/class/employee.class.php +++ /dev/null @@ -1,241 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/hrm/class/employee.class.php - * \ingroup HRM - * \brief File of class to manage employees - */ - -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; - -/** - * Class to manage establishments - */ -class Employee extends CommonObject -{ - public $element='employee'; - public $table_element='user'; - public $table_element_line = ''; - public $fk_element = 'fk_user'; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - - var $rowid; - - var $name; - var $address; - var $zip; - var $town; - var $status; // 0=open, 1=closed - var $entity; - - var $statuts=array(); - var $statuts_short=array(); - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - - $this->statuts_short = array(0 => 'Opened', 1 => 'Closed'); - $this->statuts = array(0 => 'Opened', 1 => 'Closed'); - - return 1; - } - - /** - * Load an object from database - * - * @param int $id Id of record to load - * @return int <0 if KO, >0 if OK - */ - function fetch($id='') - { - global $conf, $user; - - $sql = "SELECT e.rowid, e.firstname, e.lastname, e.gender, e.email, e.statut, e.entity, e.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as e"; - $sql.= " WHERE rowid = ".$id; - - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $obj = $this->db->fetch_object($result); - if ($obj) - { - $this->id = $obj->rowid; - $this->lastname = $obj->lastname; - $this->firstname = $obj->firstname; - $this->gender = $obj->gender; - $this->address = $obj->address; - $this->zip = $obj->zip; - $this->town = $obj->town; - $this->statut = $obj->statut; - $this->photo = $obj->photo; - - $this->db->free($result); - } - else - { - $this->error="EMPLOYEENOTFOUND"; - dol_syslog(get_class($this)."::fetch user not found", LOG_DEBUG); - - $this->db->free($result); - return 0; - } - } - else - { - $this->error=$this->db->lasterror(); - return -1; - } - } - - /** - * Return a link to the employee card (with optionaly the picto) - * Use this->id,this->lastname, this->firstname - * - * @param int $withpictoimg Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo) - * @param string $option On what the link point to - * @param integer $notooltip 1=Disable tooltip on picto and name - * @param int $maxlen Max length of visible employee name - * @param int $hidethirdpartylogo Hide logo of thirdparty - * @param string $mode ''=Show firstname and lastname, 'firstname'=Show only firstname, 'login'=Show login - * @param string $morecss Add more css on link - * @return string String with URL - */ - function getNomUrl($withpictoimg=0, $option='', $notooltip=0, $maxlen=24, $hidethirdpartylogo=0, $mode='',$morecss='') - { - global $langs, $conf; - - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0; - - $result = ''; - $companylink = ''; - $link = ''; - - $label = '' . $langs->trans("Employee") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Name') . ': ' . $this->getFullName($langs,'',''); - $label.= '
' . $langs->trans("EMail").': '.$this->email; - $label.='
'; - if (! empty($this->photo)) - { - $label.= '
'; - $label.= Form::showphoto('userphoto', $this, 80, 0, 0, 'photowithmargin photologintooltip', 'small', 0, 1); - $label.= '
'; - } - - $link.= 'global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $langs->load("users"); - $label=$langs->trans("ShowUser"); - $link.=' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $link.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $link.= ' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; - } - $link.= '>'; - $linkend=''; - - //if ($withpictoimg == -1) $result.='
'; - $result.=$link; - if ($withpictoimg) - { - $paddafterimage=''; - if (abs($withpictoimg) == 1) $paddafterimage='style="padding-right: 3px;"'; - if ($withpictoimg > 0) $picto='
'.img_object('', 'user', $paddafterimage.' '.($notooltip?'':'class="classfortooltip"')).'
'; - else $picto='
'.Form::showphoto('userphoto', $this, 0, 0, 0, 'loginphoto', 'mini', 0, 1).'
'; - $result.=$picto; - } - if (abs($withpictoimg) != 2) - { - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result.='
'; - if ($mode == 'login') $result.=dol_trunc($this->login, $maxlen); - else $result.=$this->getFullName($langs,'',($mode == 'firstname' ? 2 : -1),$maxlen); - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result.='
'; - } - $result.=$linkend; - //if ($withpictoimg == -1) $result.='
'; - $result.=$companylink; - return $result; - } - - /** - * Return status label of an employee - * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto - * @return string Label of status - */ - function getLibStatut($mode=0) - { - return $this->LibStatut($this->statut,$mode); - } - - /** - * Return label of given status - * - * @param int $statut Id statut - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto - * @return string Label of status - */ - function LibStatut($statut,$mode=0) - { - global $langs; - $langs->load('users'); - - if ($mode == 0) - { - $prefix=''; - if ($statut == 1) return $langs->trans('Enabled'); - if ($statut == 0) return $langs->trans('Disabled'); - } - if ($mode == 1) - { - if ($statut == 1) return $langs->trans('Enabled'); - if ($statut == 0) return $langs->trans('Disabled'); - } - if ($mode == 2) - { - if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); - } - if ($mode == 3) - { - if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4'); - if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5'); - } - if ($mode == 4) - { - if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); - } - if ($mode == 5) - { - if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); - if ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); - } - } -} diff --git a/htdocs/hrm/employee/index.html b/htdocs/hrm/employee/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/hrm/employee/list.php b/htdocs/hrm/employee/list.php deleted file mode 100644 index 86e1f3d10d5..00000000000 --- a/htdocs/hrm/employee/list.php +++ /dev/null @@ -1,222 +0,0 @@ - - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015 Alexandre Spangaro - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/hrm/employee/list.php - * \ingroup core - * \brief Page of users - */ - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/hrm/class/employee.class.php'; - -if (! $user->rights->hrm->employee->read) - accessforbidden(); - -$langs->load("users"); -$langs->load("companies"); -$langs->load("hrm"); - -// Security check (for external users) -$socid=0; -if ($user->societe_id > 0) - $socid = $user->societe_id; - -$sall=GETPOST('sall','alpha'); -$search_user=GETPOST('search_user','alpha'); -$search_login=GETPOST('search_login','alpha'); -$search_lastname=GETPOST('search_lastname','alpha'); -$search_firstname=GETPOST('search_firstname','alpha'); -$search_statut=GETPOST('search_statut','alpha'); -$search_thirdparty=GETPOST('search_thirdparty','alpha'); -$optioncss = GETPOST('optioncss','alpha'); - -if ($search_statut == '') $search_statut='1'; - -$sortfield = GETPOST('sortfield','alpha'); -$sortorder = GETPOST('sortorder','alpha'); -$page = GETPOST('page','int'); -if ($page == -1) { $page = 0; } -$offset = $conf->liste_limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; -$limit = $conf->liste_limit; -if (! $sortfield) $sortfield="u.login"; -if (! $sortorder) $sortorder="ASC"; - -$employeestatic = new Employee($db); -$companystatic = new Societe($db); -$form = new Form($db); - -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) -{ - $search_user=""; - $search_login=""; - $search_lastname=""; - $search_firstname=""; - $search_statut=""; - $search_thirdparty=""; -} - - -/* - * View - */ - -llxHeader('',$langs->trans("ListOfEmployees")); - -$buttonviewhierarchy='
'; - -print load_fiche_titre($langs->trans("ListOfEmployees"), $buttonviewhierarchy); - -$sql = "SELECT u.rowid, u.lastname, u.firstname, u.email, u.gender,"; -$sql.= " u.datec,"; -$sql.= " u.tms as datem,"; -$sql.= " u.ldap_sid, u.statut, u.entity,"; -$sql.= " u2.login as login2, u2.firstname as firstname2, u2.lastname as lastname2,"; -$sql.= " s.nom as name, s.canvas"; -$sql.= " FROM ".MAIN_DB_PREFIX."user as u"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u2 ON u.fk_user = u2.rowid"; -$sql.= " WHERE u.employee >= '1'"; -$sql.= " AND u.entity IN (".getEntity('user',1).")"; - -if ($socid > 0) $sql.= " AND u.fk_soc = ".$socid; -if ($search_user != '') $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user); -if ($search_thirdparty != '') $sql.=natural_search(array('s.nom'), $search_thirdparty); -if ($search_login != '') $sql.= natural_search("u.login", $search_login); -if ($search_lastname != '') $sql.= natural_search("u.lastname", $search_lastname); -if ($search_firstname != '') $sql.= natural_search("u.firstname", $search_firstname); -if ($search_statut != '' && $search_statut >= 0) $sql.= " AND (u.statut=".$search_statut.")"; -if ($sall) $sql.= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email', 'u.note'), $sall); -$sql.=$db->order($sortfield,$sortorder); - -$result = $db->query($sql); -if ($result) -{ - $num = $db->num_rows($result); - $i = 0; - - print '
'."\n"; - if ($optioncss != '') print ''; - - $param="search_user=".$search_user."&sall=".$sall; - $param.="&search_statut=".$search_statut; - if ($optioncss != '') $param.='&optioncss='.$optioncss; - - print ''; - print ''; - print_liste_field_titre($langs->trans("Login"),$_SERVER['PHP_SELF'],"u.login",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("LastName"),$_SERVER['PHP_SELF'],"u.lastname",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("FirstName"),$_SERVER['PHP_SELF'],"u.firstname",$param,"","",$sortfield,$sortorder); - if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode)) - { - print_liste_field_titre($langs->trans("Entity"),$_SERVER['PHP_SELF'],"u.entity",$param,"","",$sortfield,$sortorder); - } - print_liste_field_titre($langs->trans("HierarchicalResponsible"),$_SERVER['PHP_SELF'],"u2.login",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),$_SERVER['PHP_SELF'],"u.statut",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); - print "\n"; - - // Search bar - if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode)) $colspan++; - print ''; - print ''; - print ''; - print ''; - print ''; - - // Status - print ''; - - print ''; - - print "\n"; - - $employee2=new Employee($db); - - $var=True; - while ($i < $num) - { - $obj = $db->fetch_object($result); - $var=!$var; - - $employeestatic->id=$obj->rowid; - $employeestatic->ref=$obj->label; - $employeestatic->login=$obj->login; - $employeestatic->statut=$obj->statut; - $employeestatic->email=$obj->email; - $employeestatic->gender=$obj->gender; - $employeestatic->societe_id=$obj->fk_soc; - $employeestatic->firstname=$obj->firstname; - $employeestatic->lastname=$obj->lastname; - - $li=$employeestatic->getNomUrl(1,'',0,0,24,1); - - print ""; - print ''; - print ''; - print ''; - - // Resp - print ''; - - // Statut - print ''; - print ''; - print "\n"; - $i++; - } - print "
 '; - print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut); - print ''; - print ''; - print '
'; - print $li; - if (! empty($conf->multicompany->enabled) && $obj->admin && ! $obj->entity) - { - print img_picto($langs->trans("SuperAdministrator"),'redstar'); - } - else if ($obj->admin) - { - print img_picto($langs->trans("Administrator"),'star'); - } - print ''.ucfirst($obj->lastname).''.ucfirst($obj->firstname).''; - if ($obj->login2) - { - $employee2->login=$obj->login2; - //$employee2->lastname=$obj->lastname2; - //$employee2->firstname=$obj->firstname2; - $employee2->lastname=$employee2->login; - $employee2->firstname=''; - print $employee2->getNomUrl(1); - } - print ''.$employeestatic->getLibStatut(5).' 
"; - print "
\n"; - $db->free($result); -} -else -{ - dol_print_error($db); -} - -llxFooter(); - -$db->close(); From ad457b416d87e214dda2bee937994ecf3150a6a7 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 17 Nov 2015 22:51:34 +0100 Subject: [PATCH 12/12] Use menu & add mode 'employee' in user/index.php --- htdocs/core/menus/init_menu_auguria.sql | 6 ++- htdocs/core/menus/standard/eldy.lib.php | 16 +++++-- htdocs/core/modules/modHRM.class.php | 63 +------------------------ htdocs/user/index.php | 4 ++ 4 files changed, 23 insertions(+), 66 deletions(-) diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index a75be746ad1..84b9928e432 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -17,7 +17,7 @@ insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, left insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('projet', '$conf->projet->enabled', 7__+MAX_llx_menu__, __HANDLER__, 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&leftmenu=', 'Projects', -1, 'projects', '$user->rights->projet->lire', '', 2, 70, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('mailing|export|import|opensurvey', '$conf->mailing->enabled || $conf->export->enabled || $conf->import->enabled || $conf->opensurvey->enabled', 8__+MAX_llx_menu__, __HANDLER__, 'top', 'tools', '', 0, '/core/tools.php?mainmenu=tools&leftmenu=', 'Tools', -1, 'other', '$user->rights->mailing->lire || $user->rights->export->lire || $user->rights->import->run || $user->rights->opensurvey->read', '', 2, 90, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('adherent', '$conf->adherent->enabled', 13__+MAX_llx_menu__, __HANDLER__, 'top', 'members', '', 0, '/adherents/index.php?mainmenu=members&leftmenu=', 'Members', -1, 'members', '$user->rights->adherent->lire', '', 2, 110, __ENTITY__); -insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('hrm', '$conf->holiday->enabled || $conf->deplacement->enabled || $conf->expensereport->enabled', 15__+MAX_llx_menu__, __HANDLER__, 'top', 'hrm', '', 0, '/compta/hrm.php?mainmenu=hrm&leftmenu=', 'HRM', -1, 'holiday', '$user->rights->holiday->write || $user->rights->deplacement->lire || $user->rights->expensereport->lire', '', 0, 80, __ENTITY__); +insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('hrm', '$conf->hrm->enabled || $conf->holiday->enabled || $conf->deplacement->enabled || $conf->expensereport->enabled', 15__+MAX_llx_menu__, __HANDLER__, 'top', 'hrm', '', 0, '/compta/hrm.php?mainmenu=hrm&leftmenu=', 'HRM', -1, 'holiday', '$user->rights->hrm->employee->read || $user->rights->holiday->write || $user->rights->deplacement->lire || $user->rights->expensereport->lire', '', 0, 80, __ENTITY__); -- Home - Setup insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$user->admin', __HANDLER__, 'left', 100__+MAX_llx_menu__, 'home', 'setup', 1__+MAX_llx_menu__, '/admin/index.php?leftmenu=setup', 'Setup', 0, 'admin', '', '', 2, 0, __ENTITY__); @@ -299,6 +299,10 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left -- Members - Category member insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->adherent->enabled && $conf->categorie->enabled', __HANDLER__, 'left', 5200__+MAX_llx_menu__, 'members', 'cat', 13__+MAX_llx_menu__, '/categories/index.php?leftmenu=cat&type=3', 'MembersCategoriesShort', 0, 'categories', '$user->rights->categorie->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->adherent->enabled && $conf->categorie->enabled', __HANDLER__, 'left', 5201__+MAX_llx_menu__, 'members', '', 5200__+MAX_llx_menu__, '/categories/card.php?action=create&type=3', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); +-- HRM - Employee +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4600__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/user/index.php?&leftmenu=hrm&mode=employee', 'Employees', 0, 'hrm', '$user->rights->hrm->employee->read', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4601__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/card.php?&action=create', 'NewEmployee', 1, 'hrm', '$user->rights->hrm->employee->write', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4602__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/index.php?$leftmenu=hrm&mode=employee', 'List', 1, 'hrm', '$user->rights->hrm->employee->read', '', 0, 2, __ENTITY__); -- HRM - Holiday insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5000__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/holiday/list.php?&leftmenu=hrm', 'CPTitreMenu', 0, 'holiday', '$user->rights->holiday->write', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5001__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/card.php?&action=request', 'MenuAddCP', 1, 'holiday', '$user->rights->holiday->write', '', 0, 1, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index d26e8e44078..83a8f63fee6 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -196,9 +196,9 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0) } // HRM - $tmpentry=array('enabled'=>(! empty($conf->holiday->enabled) || ! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled)), - 'perms'=>(! empty($user->rights->holiday->write) || ! empty($user->rights->deplacement->lire) || ! empty($user->rights->expensereport->lire)), - 'module'=>'holiday|deplacement|expensereport'); + $tmpentry=array('enabled'=>(! empty($conf->hrm->enabled) || ! empty($conf->holiday->enabled) || ! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled)), + 'perms'=>(! empty($user->rights->hrm->employee->read) || ! empty($user->rights->holiday->write) || ! empty($user->rights->deplacement->lire) || ! empty($user->rights->expensereport->lire)), + 'module'=>'hrm|holiday|deplacement|expensereport'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { @@ -1229,6 +1229,16 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu */ if ($mainmenu == 'hrm') { + // HRM module + if (! empty($conf->hrm->enabled)) + { + $langs->load("hrm"); + + $newmenu->add("/user/index.php?&leftmenu=hrm&mode=employee", $langs->trans("Employees"), 0, $user->rights->hrm->employee->read, '', $mainmenu, 'hrm'); + $newmenu->add("/user/card.php?&action=create", $langs->trans("NewEmployee"), 1,$user->rights->hrm->employee->write); + $newmenu->add("/user/index.php?&leftmenu=hrm&mode=employee", $langs->trans("List"), 1,$user->rights->hrm->employee->read); + } + // Leave/Holiday/Vacation module if (! empty($conf->holiday->enabled)) { diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index 0ce7061617b..1dcf2b28177 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -77,7 +77,7 @@ class modHRM extends DolibarrModules ); // Minimum version of PHP required by module $this->need_dolibarr_version = array ( 3, - 7 + 8 ); // Minimum version of Dolibarr required by module $this->langfiles = array ( "hrm" @@ -166,67 +166,6 @@ class modHRM extends DolibarrModules // Main menu entries $this->menus = array (); // List of menus to add $r = 0; - - $this->menu[$r] = array ( - 'fk_menu' => 'fk_mainmenu=hrm', - 'type' => 'left', - 'titre' => 'Employees', - 'leftmenu' => 'employee', - 'mainmenu' => 'hrm', - 'url' => '/hrm/employee/index.php', - 'langs' => 'hrm', - 'position' => 100, - 'enabled' => '$user->rights->hrm->employee->read', - 'perms' => '$user->rights->hrm->employee->read', - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array( - 'fk_menu' => 'fk_mainmenu=hrm,fk_leftmenu=employee', - 'type' => 'left', - 'titre' => 'NewEmployee', - 'mainmenu' => 'hrm', - 'url' => '/hrm/employee/card.php?action=create', - 'langs' => 'hrm', - 'position' => 101, - 'enabled' => '$user->rights->hrm->employee->write', - 'perms' => '$user->rights->hrm->employee->write', - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array( - 'fk_menu' => 'fk_mainmenu=hrm,fk_leftmenu=employee', - 'type' => 'left', - 'titre' => 'List', - 'mainmenu' => 'hrm', - 'url' => '/hrm/employee/list.php', - 'langs' => 'hrm', - 'position' => 102, - 'enabled' => '$user->rights->hrm->employee->read', - 'perms' => '$user->rights->hrm->employee->read', - 'target' => '', - 'user' => 0 - ); - $r ++; - - $this->menu[$r] = array( - 'fk_menu' => 'fk_mainmenu=hrm,fk_leftmenu=employee', - 'type' => 'left', - 'titre' => 'Statistics', - 'mainmenu' => 'hrm', - 'url' => '/hrm/employee/stats.php', - 'langs' => 'hrm', - 'position' => 103, - 'enabled' => '$user->rights->hrm->employee->read', - 'perms' => '$user->rights->hrm->employee->read', - 'target' => '', - 'user' => 0 - ); - $r ++; } /** diff --git a/htdocs/user/index.php b/htdocs/user/index.php index e19b7c8ab6a..5961d03246e 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -40,6 +40,9 @@ $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; +// Load mode employee +$mode = GETPOST("mode", 'alpha'); + // Load variable for pagination $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); @@ -188,6 +191,7 @@ else { $sql.= " WHERE u.entity IN (".getEntity('user',1).")"; } +if ($mode = "employee") $sql.= " AND u.employee = 1"; if ($socid > 0) $sql.= " AND u.fk_soc = ".$socid; //if ($search_user != '') $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user); if ($search_supervisor > 0) $sql.= " AND u.fk_user = ".$search_supervisor;