Merge pull request #3964 from aspangaro/develop-hrm3
HRM : Work in progress
This commit is contained in:
commit
552ecbcd95
@ -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] = 'card';
|
||||
$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
|
||||
*
|
||||
|
||||
@ -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__);
|
||||
|
||||
@ -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))
|
||||
{
|
||||
|
||||
@ -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"
|
||||
@ -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',
|
||||
@ -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 ++;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -226,13 +226,12 @@ $formother = new FormOther($db);
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
$head = user_prepare_head($fuser);
|
||||
|
||||
$title = $langs->trans("User");
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/user/index.php">'.$langs->trans("BackToList").'</a>';
|
||||
$head = user_prepare_head($fuser);
|
||||
|
||||
dol_fiche_head($head, 'paidholidays', $title, 0, 'user');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/user/index.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($fuser,'id',$linkback,$user->rights->user->user->lire || $user->admin);
|
||||
|
||||
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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 '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
|
||||
dol_fiche_head($head, 'parameters', $langs->trans("HRM"), 0, "user");
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="3">' . $langs->trans('Journaux') . '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
foreach ( $list as $key ) {
|
||||
$var = ! $var;
|
||||
|
||||
print '<tr ' . $bc[$var] . ' class="value">';
|
||||
|
||||
// Param
|
||||
$label = $langs->trans($key);
|
||||
print '<td width="50%"><label for="' . $key . '">' . $label . '</label></td>';
|
||||
|
||||
// Value
|
||||
print '<td>';
|
||||
print '<input type="text" size="20" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print "</table>\n";
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
@ -1,241 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \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 = '<u>' . $langs->trans("Employee") . '</u>';
|
||||
$label.= '<div width="100%">';
|
||||
$label.= '<b>' . $langs->trans('Name') . ':</b> ' . $this->getFullName($langs,'','');
|
||||
$label.= '<br><b>' . $langs->trans("EMail").':</b> '.$this->email;
|
||||
$label.='</div>';
|
||||
if (! empty($this->photo))
|
||||
{
|
||||
$label.= '<div class="photointooltip">';
|
||||
$label.= Form::showphoto('userphoto', $this, 80, 0, 0, 'photowithmargin photologintooltip', 'small', 0, 1);
|
||||
$label.= '</div><div style="clear: both;"></div>';
|
||||
}
|
||||
|
||||
$link.= '<a href="'.DOL_URL_ROOT.'/hrm/employee/card.php?id='.$this->id.'"';
|
||||
if (empty($notooltip))
|
||||
{
|
||||
if (! empty($conf->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='</a>';
|
||||
|
||||
//if ($withpictoimg == -1) $result.='<div class="nowrap">';
|
||||
$result.=$link;
|
||||
if ($withpictoimg)
|
||||
{
|
||||
$paddafterimage='';
|
||||
if (abs($withpictoimg) == 1) $paddafterimage='style="padding-right: 3px;"';
|
||||
if ($withpictoimg > 0) $picto='<div class="inline-block valignmiddle'.($morecss?' userimg'.$morecss:'').'">'.img_object('', 'user', $paddafterimage.' '.($notooltip?'':'class="classfortooltip"')).'</div>';
|
||||
else $picto='<div class="inline-block valignmiddle'.($morecss?' userimg'.$morecss:'').'"'.($paddafterimage?' '.$paddafterimage:'').'>'.Form::showphoto('userphoto', $this, 0, 0, 0, 'loginphoto', 'mini', 0, 1).'</div>';
|
||||
$result.=$picto;
|
||||
}
|
||||
if (abs($withpictoimg) != 2)
|
||||
{
|
||||
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result.='<div class="inline-block valignmiddle'.($morecss?' usertext'.$morecss:'').'">';
|
||||
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.='</div>';
|
||||
}
|
||||
$result.=$linkend;
|
||||
//if ($withpictoimg == -1) $result.='</div>';
|
||||
$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');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,222 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \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='<form action="'.DOL_URL_ROOT.'/hrm/employee/hierarchy.php'.(($search_statut != '' && $search_statut >= 0) ? '?search_statut='.$search_statut : '').'" method="POST"><input type="submit" class="button" style="width:120px" name="viewcal" value="'.dol_escape_htmltag($langs->trans("HierarchicView")).'"></form>';
|
||||
|
||||
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 '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
|
||||
$param="search_user=".$search_user."&sall=".$sall;
|
||||
$param.="&search_statut=".$search_statut;
|
||||
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
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 "</tr>\n";
|
||||
|
||||
// Search bar
|
||||
if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode)) $colspan++;
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td><input type="text" name="search_login" size="6" value="'.$search_login.'"></td>';
|
||||
print '<td><input type="text" name="search_lastname" size="6" value="'.$search_lastname.'"></td>';
|
||||
print '<td><input type="text" name="search_firstname" size="6" value="'.$search_firstname.'"></td>';
|
||||
print '<td> </td>';
|
||||
|
||||
// Status
|
||||
print '<td align="right">';
|
||||
print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut);
|
||||
print '</td>';
|
||||
|
||||
print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
|
||||
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\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 "<tr ".$bc[$var].">";
|
||||
print '<td>';
|
||||
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 '</td>';
|
||||
print '<td>'.ucfirst($obj->lastname).'</td>';
|
||||
print '<td>'.ucfirst($obj->firstname).'</td>';
|
||||
|
||||
// Resp
|
||||
print '<td class="nowrap" align="center">';
|
||||
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 '</td>';
|
||||
|
||||
// Statut
|
||||
print '<td align="center">'.$employeestatic->getLibStatut(5).'</td>';
|
||||
print '<td> </td>';
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
print "</table>";
|
||||
print "</form>\n";
|
||||
$db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
@ -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,7 +9,12 @@ 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
|
||||
Employee=Employee
|
||||
NewEmployee=New employee
|
||||
EmployeeCard=Employee card
|
||||
|
||||
@ -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 = '<a href="'.DOL_URL_ROOT.'/hrm/employee/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$title = $langs->trans("User");
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/user/index.php">'.$langs->trans("BackToList").'</a>';
|
||||
}
|
||||
|
||||
$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 = '<a href="'.DOL_URL_ROOT.'/user/index.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
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 '<div class="fichecenter">';
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user