--- /tmp/dsg/dolibarr/htdocs/hrm/github_19.0.3_index.php +++ /tmp/dsg/dolibarr/htdocs/hrm/client_index.php @@ -6,2 +6 @@ - * Copyright (C) 2019 Nicolas ZABOURI - * Copyright (C) 2021 Frédéric France + * Copyright (C) 2019 Nicolas ZABOURI @@ -24,3 +23,3 @@ - * \file htdocs/hrm/index.php - * \ingroup hrm - * \brief Home page for HRM area. + * \file htdocs/hrm/index.php + * \ingroup hrm + * \brief Home page for HRM area. @@ -29,2 +27,0 @@ - -// Load Dolibarr environment @@ -34,0 +32,2 @@ +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; @@ -37,19 +36,4 @@ -require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; -require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; - -if (isModEnabled('deplacement')) { - require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; -} -if (isModEnabled('expensereport')) { - require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; -} -if (isModEnabled('recruitment')) { - require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php'; - require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php'; -} -if (isModEnabled('holiday')) { - require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; -} - - -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +if ($conf->deplacement->enabled) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; +if ($conf->expensereport->enabled) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; + @@ -57 +40,0 @@ - @@ -61,3 +44,2 @@ -$langs->loadLangs(array('users', 'holiday', 'trips', 'boxes')); - -// Get Parameters +$langs->loadLangs(array('users', 'holidays', 'trips', 'boxes')); + @@ -67,9 +49,9 @@ -if ($user->socid > 0) { - accessforbidden(); -} - -if (!getDolGlobalString('MAIN_INFO_SOCIETE_NOM') || !getDolGlobalString('MAIN_INFO_SOCIETE_COUNTRY')) { - $setupcompanynotcomplete = 1; -} - -$max = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT'); +if ($user->socid > 0) accessforbidden(); + +if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete = 1; + +$holiday = new Holiday($db); +$holidaystatic = new Holiday($db); + +$max = 3; + @@ -83,3 +65,3 @@ -if (isModEnabled('holiday') && !empty($setupcompanynotcomplete)) { - $holidaystatic = new Holiday($db); - $result = $holidaystatic->updateBalance(); +if (!empty($conf->holiday->enabled) && !empty($setupcompanynotcomplete)) +{ + $result = $holiday->updateBalance(); @@ -93,2 +74,0 @@ -$listofsearchfields = array(); - @@ -98,8 +78,7 @@ -$title = $langs->trans('HRMArea'); - -llxHeader('', $title, ''); - -print load_fiche_titre($langs->trans("HRMArea"), '', 'hrm'); - - -if (!empty($setupcompanynotcomplete)) { +llxHeader('', $langs->trans('HRMArea')); + +print load_fiche_titre($langs->trans("HRMArea"), '', 'user'); + + +if (!empty($setupcompanynotcomplete)) +{ @@ -108 +87 @@ - print '
'; + print '
'; @@ -117,4 +96,67 @@ -if (getDolGlobalString('MAIN_SEARCH_FORM_ON_HOME_AREAS')) { // This is useless due to the global search combo - if (isModEnabled('holiday') && $user->hasRight('holiday', 'read')) { - $langs->load("holiday"); - $listofsearchfields['search_holiday'] = array('text'=>'TitreRequestCP'); +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +{ + if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) + { + $langs->load("holiday"); + $listofsearchfields['search_holiday'] = array('text'=>'TitreRequestCP'); + } + if (!empty($conf->deplacement->enabled) && $user->rights->deplacement->lire) + { + $langs->load("trips"); + $listofsearchfields['search_deplacement'] = array('text'=>'ExpenseReport'); + } + if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) + { + $langs->load("trips"); + $listofsearchfields['search_expensereport'] = array('text'=>'ExpenseReport'); + } + if (count($listofsearchfields)) + { + print '
'; + print ''; + print '
'; + print ''; + $i = 0; + foreach ($listofsearchfields as $key => $value) + { + if ($i == 0) print ''; + print ''; + print ''; + if ($i == 0) print ''; + print ''; + $i++; + } + print '
'.$langs->trans("Search").'
'; + print '
'; + print '
'; + print '
'; + } +} + + +if (!empty($conf->holiday->enabled)) +{ + if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) + { + $user_id = $user->id; + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans("Holidays").'
'; + + $out = ''; + $typeleaves = $holiday->getTypes(1, 1); + foreach ($typeleaves as $key => $val) + { + $nb_type = $holiday->getCPforUser($user->id, $val['rowid']); + $nb_holiday += $nb_type; + $out .= ' - '.$val['label'].': '.($nb_type ?price2num($nb_type) : 0).'
'; + } + print $langs->trans('SoldeCPUser', round($nb_holiday, 5)).'
'; + print $out; + + print '

'; @@ -122,61 +164,2 @@ - if (isModEnabled('deplacement') && $user->hasRight('deplacement', 'lire')) { - $langs->load("trips"); - $listofsearchfields['search_deplacement'] = array('text'=>'ExpenseReport'); - } - if (isModEnabled('expensereport') && $user->hasRight('expensereport', 'lire')) { - $langs->load("trips"); - $listofsearchfields['search_expensereport'] = array('text'=>'ExpenseReport'); - } - if (count($listofsearchfields)) { - print '
'; - print ''; - print '
'; - print ''; - $i = 0; - foreach ($listofsearchfields as $key => $value) { - if ($i == 0) { - print ''; - } - print ''; - print ''; - if ($i == 0) { - print ''; - } - print ''; - $i++; - } - print '
'.$langs->trans("Search").'
'; - print '
'; - print '
'; - print '
'; - } -} - - -if (isModEnabled('holiday')) { - if (!getDolGlobalString('HOLIDAY_HIDE_BALANCE')) { - $holidaystatic = new Holiday($db); - $user_id = $user->id; - - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans("Holidays").'
'; - - $out = ''; - $nb_holiday = 0; - $typeleaves = $holidaystatic->getTypes(1, 1); - foreach ($typeleaves as $key => $val) { - $nb_type = $holidaystatic->getCPforUser($user->id, $val['rowid']); - $nb_holiday += $nb_type; - $out .= ' - '.($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']).': '.($nb_type ? price2num($nb_type) : 0).'
'; - } - $balancetoshow = $langs->trans('SoldeCPUser', '{s1}'); - print '
'.str_replace('{s1}', img_picto('', 'holiday', 'class="paddingleft pictofixedwidth"').''.round($nb_holiday, 5).'', $balancetoshow).'
'; - print ''.$out.''; - - print '

'; - } elseif (!is_numeric($conf->global->HOLIDAY_HIDE_BALANCE)) { + elseif (!is_numeric($conf->global->HOLIDAY_HIDE_BALANCE)) + { @@ -188,10 +171,93 @@ -print '
'; - - - -// Latest modified leave requests -if (isModEnabled('holiday') && $user->hasRight('holiday', 'read')) { - $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.photo, u.statut as user_status,"; - $sql .= " x.rowid, x.ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status"; - $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE u.rowid = x.fk_user"; +print '
'; + + + +// Latest leave requests +if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) +{ + $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.photo, u.statut, x.rowid, x.rowid as ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE u.rowid = x.fk_user"; + $sql .= " AND x.entity = ".$conf->entity; + if (empty($user->rights->holiday->read_all)) $sql .= ' AND x.fk_user IN ('.join(',', $childids).')'; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + //if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid; + $sql .= $db->order("x.tms", "DESC"); + $sql .= $db->plimit($max, 0); + + $result = $db->query($sql); + if ($result) + { + $var = false; + $num = $db->num_rows($result); + + $holidaystatic = new Holiday($db); + $userstatic = new User($db); + + $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon")); + $typeleaves = $holidaystatic->getTypes(1, -1); + + $i = 0; + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($num) + { + while ($i < $num && $i < $max) + { + $obj = $db->fetch_object($result); + + $holidaystatic->id = $obj->rowid; + $holidaystatic->ref = $obj->ref; + + $userstatic->id = $obj->uid; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->login = $obj->login; + $userstatic->photo = $obj->photo; + $userstatic->email = $obj->email; + $userstatic->statut = $obj->statut; + + print ''; + print ''; + print ''; + print ''; + + $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning'; + $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon'; + + print ''; + print ''; + print ''; + + $i++; + } + } + else + { + print ''; + } + print '
'.$langs->trans("BoxTitleLastLeaveRequests", min($max, $num)).''.$langs->trans("from").''.$langs->trans("to").''.$langs->trans("DateModificationShort").' 
'.$holidaystatic->getNomUrl(1).''.$userstatic->getNomUrl(-1, 'leave').''.$typeleaves[$obj->fk_type]['label'].''.dol_print_date($db->jdate($obj->date_start), 'day').' '.$langs->trans($listhalfday[$starthalfday]); + print ''.dol_print_date($db->jdate($obj->date_end), 'day').' '.$langs->trans($listhalfday[$endhalfday]); + print ''.dol_print_date($db->jdate($obj->dm), 'day').''.$holidaystatic->LibStatut($obj->status, 3).'
'.$langs->trans("None").'
'; + print '
'; + print '
'; + } + else dol_print_error($db); +} + + +// Latest expense report +if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) +{ + $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.statut, u.photo, x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u"; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE u.rowid = x.fk_user_author"; @@ -199,5 +265,3 @@ - if (!$user->hasRight('holiday', 'readall')) { - $sql .= ' AND x.fk_user IN ('.$db->sanitize(join(',', $childids)).')'; - } - //if (empty($user->rights->societe->client->voir) && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - //if (!empty($socid)) $sql.= " AND x.fk_soc = ".((int) $socid); + if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $sql .= ' AND x.fk_user_author IN ('.join(',', $childids).')'; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + //if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid; @@ -208,86 +272,2 @@ - if ($result) { - $var = false; - $num = $db->num_rows($result); - - $holidaystatic = new Holiday($db); - $userstatic = new User($db); - - $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon")); - $typeleaves = $holidaystatic->getTypes(1, -1); - - $i = 0; - - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($num) { - while ($i < $num && $i < $max) { - $obj = $db->fetch_object($result); - - $holidaystatic->id = $obj->rowid; - $holidaystatic->ref = $obj->ref; - $holidaystatic->statut = $obj->status; - $holidaystatic->date_debut = $db->jdate($obj->date_start); - - $userstatic->id = $obj->uid; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - $userstatic->login = $obj->login; - $userstatic->photo = $obj->photo; - $userstatic->email = $obj->email; - $userstatic->statut = $obj->user_status; - $userstatic->status = $obj->user_status; - - print ''; - print ''; - print ''; - - $leavecode = empty($typeleaves[$obj->fk_type]) ? 'Undefined' : $typeleaves[$obj->fk_type]['code']; - print ''; - - $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning'; - $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon'; - - print ''; - print ''; - print ''; - - $i++; - } - } else { - print ''; - } - print '
'.$langs->trans("BoxTitleLastLeaveRequests", min($max, $num)).''.$langs->trans("from").''.$langs->trans("to").''.$langs->trans("FullList").'
'.$holidaystatic->getNomUrl(1).''.$userstatic->getNomUrl(-1, 'leave').''.dol_escape_htmltag($langs->trans($leavecode)).''.dol_print_date($db->jdate($obj->date_start), 'day').' '.$langs->trans($listhalfday[$starthalfday]).''; - print ''.dol_print_date($db->jdate($obj->date_end), 'day').' '.$langs->trans($listhalfday[$endhalfday]).''; - print ''.dol_print_date($db->jdate($obj->dm), 'day').''.$holidaystatic->LibStatut($obj->status, 3, $holidaystatic->date_debut).'
'.$langs->trans("None").'
'; - print '
'; - print '
'; - } else { - dol_print_error($db); - } -} - - -// Latest modified expense report -if (isModEnabled('expensereport') && $user->hasRight('expensereport', 'read')) { - $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.statut as user_status, u.photo,"; - $sql .= " x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status"; - $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u"; - //if (empty($user->rights->societe->client->voir) && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE u.rowid = x.fk_user_author"; - $sql .= " AND x.entity = ".$conf->entity; - if (!$user->hasRight('expensereport', 'readall') && !$user->hasRight('expensereport', 'lire_tous')) { - $sql .= ' AND x.fk_user_author IN ('.$db->sanitize(join(',', $childids)).')'; - } - //if (empty($user->rights->societe->client->voir) && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - //if (!empty($socid)) $sql.= " AND x.fk_soc = ".((int) $socid); - $sql .= $db->order("x.tms", "DESC"); - $sql .= $db->plimit($max, 0); - - $result = $db->query($sql); - if ($result) { + if ($result) + { @@ -303 +283,2 @@ - print ''.$langs->trans("FullList").''; + print ''.$langs->trans("DateModificationShort").''; + print ' '; @@ -305 +286,2 @@ - if ($num) { + if ($num) + { @@ -310 +292,2 @@ - while ($i < $num && $i < $max) { + while ($i < $num && $i < $max) + { @@ -315,2 +297,0 @@ - $expensereportstatic->statut = $obj->status; - $expensereportstatic->status = $obj->status; @@ -321 +302 @@ - $userstatic->email = $obj->email; + $userstatic->email = $obj->email; @@ -323 +304 @@ - $userstatic->statut = $obj->user_status; + $userstatic->statut = $obj->statut; @@ -327 +308 @@ - print ''.$expensereportstatic->getNomUrl(1).''; + print ''.$expensereportstatic->getNomUrl(1).''; @@ -329 +310 @@ - print ''.price($obj->total_ttc).''; + print ''.price($obj->total_ttc).''; @@ -331 +312 @@ - print ''.$expensereportstatic->LibStatut($obj->status, 3).''; + print ''.$expensereportstatic->LibStatut($obj->status, 3).''; @@ -336,2 +317,4 @@ - } else { - print ''.$langs->trans("None").''; + } + else + { + print ''.$langs->trans("None").''; @@ -341,3 +323,0 @@ - print '
'; - } else { - dol_print_error($db); @@ -345,77 +325,5 @@ -} - - -// Last modified job position -if (isModEnabled('recruitment') && $user->hasRight('recruitment', 'recruitmentjobposition', 'read')) { - $staticrecruitmentcandidature = new RecruitmentCandidature($db); - $staticrecruitmentjobposition = new RecruitmentJobPosition($db); - $sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status,"; - $sql.= " rp.rowid as jobid, rp.ref as jobref, rp.label"; - $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as rp ON rc.fk_recruitmentjobposition = rp.rowid"; - if (isModEnabled('societe') && !$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } - $sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentcandidature->element).")"; - if (isModEnabled('societe') && !$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND rp.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } - if ($socid) { - $sql .= " AND rp.fk_soc = $socid"; - } - $sql .= $db->order("rc.tms", "DESC"); - $sql .= $db->plimit($max, 0); - - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($num) { - while ($i < $num) { - $objp = $db->fetch_object($resql); - $staticrecruitmentcandidature->id = $objp->rowid; - $staticrecruitmentcandidature->ref = $objp->ref; - $staticrecruitmentcandidature->email = $objp->email; - $staticrecruitmentcandidature->status = $objp->status; - $staticrecruitmentcandidature->date_creation = $objp->date_creation; - $staticrecruitmentcandidature->firstname = $objp->firstname; - $staticrecruitmentcandidature->lastname = $objp->lastname; - - $staticrecruitmentjobposition->id = $objp->jobid; - $staticrecruitmentjobposition->ref = $objp->jobref; - $staticrecruitmentjobposition->label = $objp->label; - - print ''; - print ''; - print ''; - print ''; - print ''; - print '"; - print ''; - $i++; - } - - $db->free($resql); - } else { - print ''; - } - print "
'; - print $langs->trans("BoxTitleLatestModifiedCandidatures", min($max, $num)); - print ''.$langs->trans("FullList").'
'.$staticrecruitmentcandidature->getNomUrl(1, '').''.$staticrecruitmentcandidature->getFullName($langs).''.$staticrecruitmentjobposition->getNomUrl(1).''.dol_print_date($db->jdate($objp->tms), 'day').''; - print $staticrecruitmentcandidature->getLibStatut(3); - print "
'.$langs->trans("None").'
"; - print "
"; - print "
"; - } else { - dol_print_error($db); - } -} - -print '
'; + else dol_print_error($db); +} + + +print '';