Merge
This commit is contained in:
commit
b8b964169a
6 changed files with 111 additions and 19 deletions
|
|
@ -1574,7 +1574,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
|
|||
|
||||
// Role
|
||||
if (!empty($arrayfields['sc.role']['checked'])) {
|
||||
print '<td>';
|
||||
print '<td class="tdoverflowmax150">';
|
||||
print $formcompany->showRoles("roles", $contactstatic, 'view');
|
||||
print '</td>';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ function tree_showpad(&$fulltree, $key, $silent = 0)
|
|||
* TODO Replace with jstree plugin instead of treeview plugin.
|
||||
*
|
||||
* @param array $tab Array of all elements
|
||||
* @param array $pere Array with parent ids ('rowid'=>,'mainmenu'=>,'leftmenu'=>,'fk_mainmenu=>,'fk_leftmenu=>)
|
||||
* @param array $pere Array with parent ids ('rowid'=>,'mainmenu'=>,'leftmenu'=>,'fk_mainmenu'=>,'fk_leftmenu'=>)
|
||||
* @param int $rang Level of element
|
||||
* @param string $iddivjstree Id to use for parent ul element
|
||||
* @param int $donoresetalreadyloaded Do not reset global array $donoresetalreadyloaded used to avoid to go down on an already processed record
|
||||
|
|
@ -148,13 +148,14 @@ function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoreset
|
|||
return; // Protect against infinite loop. Max 50 depth
|
||||
}
|
||||
|
||||
//ballayage du tableau
|
||||
$sizeoftab = count($tab);
|
||||
// Loop on each element of tree
|
||||
$ulprinted = 0;
|
||||
for ($x = 0; $x < $sizeoftab; $x++) {
|
||||
foreach ($tab as $tmpkey => $tmpval) {
|
||||
$x = $tmpkey;
|
||||
|
||||
//var_dump($tab[$x]);exit;
|
||||
// If an element has $pere for parent
|
||||
if ($tab[$x]['fk_menu'] != -1 && $tab[$x]['fk_menu'] == $pere['rowid']) {
|
||||
if ($tab[$x]['fk_menu'] != -1 && ((int) $tab[$x]['fk_menu']) == $pere['rowid']) {
|
||||
//print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n";
|
||||
if (empty($ulprinted) && !empty($pere['rowid'])) {
|
||||
if (!empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) {
|
||||
|
|
@ -184,7 +185,7 @@ function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoreset
|
|||
// And now we search all its sons of lower level
|
||||
tree_recur($tab, $tab[$x], $rang + 1, 'iddivjstree', 0, $showfk);
|
||||
print '</li>';
|
||||
} elseif (!empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) {
|
||||
} elseif (!empty($tab[$x]['rowid']) && ((int) $tab[$x]['fk_menu']) == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) {
|
||||
//print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n";
|
||||
if (empty($ulprinted) && !empty($pere['rowid'])) {
|
||||
if (!empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) {
|
||||
|
|
|
|||
|
|
@ -1916,6 +1916,9 @@ while ($i < $imaxinloop) {
|
|||
$totalarray['nbfield']++;
|
||||
$totalarray['pos'][$totalarray['nbfield']] = 'totalam';
|
||||
}
|
||||
if (empty($totalarray['val']['totalam'])) {
|
||||
$totalarray['val']['totalam'] = 0; // avoid PHP Warning: Undefined array key "totalam" on line 1891
|
||||
}
|
||||
$totalarray['val']['totalam'] += $totalpay;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ ShowAllPerms=Show all permission rows
|
|||
HideAllPerms=Hide all permission rows
|
||||
UserPublicPageDesc=You can enable a virtual card for this user. An url with the user profile and a barcode will be available to allow anybody with a smartphone to scan it and add your contact to its address book.
|
||||
EnablePublicVirtualCard=Enable the user's virtual business card
|
||||
ExcludedByFilter=Non qualified by filters but shown to see its hierarchy
|
||||
UserEnabledDisabled=User status changed: %s
|
||||
AlternativeEmailForOAuth2=Alternative Email for OAuth2 login
|
||||
ErrorUpdateCanceledDueToDuplicatedUniqueValue=Error, The update was canceled because one of the pieces of data, that should be unique, already exists
|
||||
|
|
|
|||
|
|
@ -3810,7 +3810,7 @@ class User extends CommonObject
|
|||
}
|
||||
|
||||
dol_syslog(get_class($this)."::get_full_tree dol_sort_array", LOG_DEBUG);
|
||||
$this->users = dol_sort_array($this->users, 'fullname', 'asc', true, false);
|
||||
$this->users = dol_sort_array($this->users, 'fullname', 'asc', true, false, 1);
|
||||
|
||||
//var_dump($this->users);
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTI
|
|||
|
||||
|
||||
$search_status = GETPOST('search_status', 'intcomma');
|
||||
if ($search_status == '' || $search_status == '0') {
|
||||
if ($search_status == '') {
|
||||
$search_status = '1';
|
||||
}
|
||||
|
||||
|
|
@ -60,6 +60,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter',
|
|||
$search_status = "";
|
||||
}
|
||||
|
||||
$search_employee = -1;
|
||||
if ($contextpage == 'employeelist') {
|
||||
$search_employee = 1;
|
||||
}
|
||||
|
|
@ -104,10 +105,24 @@ $arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css
|
|||
|
||||
llxHeader('', $title, $help_url, '', 0, 0, $arrayofjs, $arrayofcss, '', 'bodyforlist');
|
||||
|
||||
|
||||
$filters = [];
|
||||
if (($search_status != '' && $search_status >= 0)) {
|
||||
$filters[] = "statut = ".((int) $search_status);
|
||||
}
|
||||
if (($search_employee != '' && $search_employee >= 0)) {
|
||||
$filters[] = "employee = ".((int) $search_employee);
|
||||
}
|
||||
$sqlfilter= '';
|
||||
if (!empty($filters)) {
|
||||
$sqlfilter = join(' AND ', $filters);
|
||||
}
|
||||
// Load hierarchy of users
|
||||
$user_arbo = $userstatic->get_full_tree(0, ($search_status != '' && $search_status >= 0) ? "statut = ".$search_status : '');
|
||||
|
||||
$user_arbo_all = $userstatic->get_full_tree(0, '');
|
||||
if ($sqlfilter) {
|
||||
$user_arbo = $userstatic->get_full_tree(0, $sqlfilter);
|
||||
} else {
|
||||
$user_arbo = $user_arbo_all;
|
||||
}
|
||||
|
||||
// Count total nb of records
|
||||
$nbtotalofrecords = count($user_arbo);
|
||||
|
|
@ -121,7 +136,8 @@ if (!is_array($user_arbo) && $user_arbo < 0) {
|
|||
//var_dump($fulltree);
|
||||
// Define data (format for treeview)
|
||||
$data = array();
|
||||
$data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>'');
|
||||
$data[0] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>'');
|
||||
|
||||
foreach ($fulltree as $key => $val) {
|
||||
$userstatic->id = $val['id'];
|
||||
$userstatic->ref = (string) $val['id'];
|
||||
|
|
@ -159,15 +175,86 @@ if (!is_array($user_arbo) && $user_arbo < 0) {
|
|||
|
||||
$entry = '<table class="nobordernopadding centpercent"><tr class="trtree"><td class="'.($val['statut'] ? 'usertdenabled' : 'usertddisabled').'">'.$li.'</td><td align="right" class="'.($val['statut'] ? 'usertdenabled' : 'usertddisabled').'">'.$userstatic->getLibStatut(2).'</td></tr></table>';
|
||||
|
||||
$data[] = array(
|
||||
$data[$val['rowid']] = array(
|
||||
'rowid'=>$val['rowid'],
|
||||
'fk_menu'=>$val['fk_user'],
|
||||
'fk_menu'=>$val['fk_user'], // TODO Replace fk_menu with fk_parent
|
||||
'statut'=>$val['statut'],
|
||||
'entry'=>$entry
|
||||
);
|
||||
}
|
||||
|
||||
//var_dump($data);
|
||||
// Loop on $data to link user linked to a parent that was excluded by the filter
|
||||
foreach ($data as $key => $tmpdata) {
|
||||
$idparent = $tmpdata['fk_menu'];
|
||||
// Loop to check if parent exists
|
||||
if ($idparent > 0) {
|
||||
$parentfound = array_key_exists($idparent, $data) ? 1 : 0;
|
||||
|
||||
$i = 0;
|
||||
while (!$parentfound && $i < 50) {
|
||||
// Parent was not found but we need it to show the child, so we reintroduce the parent
|
||||
if (!empty($user_arbo_all[$idparent])) {
|
||||
$val = $user_arbo_all[$idparent];
|
||||
$userstatic->id = $val['id'];
|
||||
$userstatic->ref = $val['id'];
|
||||
$userstatic->login = $val['login'];
|
||||
$userstatic->firstname = $val['firstname'];
|
||||
$userstatic->lastname = $val['lastname'];
|
||||
$userstatic->statut = $val['statut'];
|
||||
$userstatic->email = $val['email'];
|
||||
$userstatic->gender = $val['gender'];
|
||||
$userstatic->socid = $val['fk_soc'];
|
||||
$userstatic->admin = $val['admin'];
|
||||
$userstatic->entity = $val['entity'];
|
||||
$userstatic->photo = $val['photo'];
|
||||
|
||||
$li = '<span class="opacitymedium">';
|
||||
$li .= $userstatic->getNomUrl(-1, '', 0, 1);
|
||||
if (isModEnabled('multicompany') && $userstatic->admin && !$userstatic->entity) {
|
||||
$li .= img_picto($langs->trans("SuperAdministrator"), 'redstar');
|
||||
} elseif ($userstatic->admin) {
|
||||
$li .= img_picto($langs->trans("Administrator"), 'star');
|
||||
}
|
||||
$li .= ' <span class="opacitymedium">('.$val['login'].($entitystring ? ' - '.$entitystring : '').')</span>';
|
||||
$li .= ' - <span class="opacitymedium">'.$langs->trans("ExcludedByFilter").'</span>';
|
||||
$li .= '</span>';
|
||||
|
||||
$entry = '<table class="nobordernopadding centpercent"><tr class="trtree"><td class="'.($val['statut'] ? 'usertdenabled' : 'usertddisabled').'">'.$li.'</td><td align="right" class="'.($val['statut'] ? 'usertdenabled' : 'usertddisabled').'">'.$userstatic->getLibStatut(2).'</td></tr></table>';
|
||||
|
||||
$data[$idparent] = array(
|
||||
'rowid' => $idparent,
|
||||
'fk_menu' => $user_arbo_all[$idparent]['fk_user'],
|
||||
'statut' => $user_arbo_all[$idparent]['statut'],
|
||||
'entry' => $entry
|
||||
);
|
||||
$idparent = $user_arbo_all[$idparent]['fk_user'];
|
||||
if ($idparent > 0) {
|
||||
$parentfound = array_key_exists($idparent, $data) ? 1 : 0;
|
||||
} else {
|
||||
$parentfound = 1;
|
||||
}
|
||||
//var_dump($data[$idparent]);
|
||||
} else {
|
||||
// We should not be here. If a record has a parent id, parent id should be into $user_arbo_all
|
||||
$data[$key]['fk_menu'] = -2;
|
||||
if (empty($data[-2])) {
|
||||
$li = '<span class="opacitymedium">'.$langs->trans("ParentIDDoesNotExistAnymore").'</span>';
|
||||
$entry = '<table class="nobordernopadding centpercent"><tr class="trtree"><td class="usertddisabled">'.$li.'</td><td align="right" class="usertddisabled"></td></tr></table>';
|
||||
$data[-2] = array(
|
||||
'rowid'=>'-2',
|
||||
'fk_menu'=>null,
|
||||
'statut'=>'1',
|
||||
'entry'=>$entry
|
||||
);
|
||||
}
|
||||
$parentfound = 1;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
//var_dump($data);exit;
|
||||
|
||||
$param = "&search_status=".urlencode($search_status);
|
||||
$param = "&contextpage=".urlencode($contextpage);
|
||||
|
|
@ -211,8 +298,8 @@ if (!is_array($user_arbo) && $user_arbo < 0) {
|
|||
print '<td class="liste_titre"> </td>';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
// Status
|
||||
print '<td class="liste_titre right">';
|
||||
print $form->selectarray('search_status', array('-1'=>'', '1'=>$langs->trans('Enabled')), $search_status, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp');
|
||||
print '<td class="liste_titre right parentonrightofpage">';
|
||||
print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('Disabled'), '1'=>$langs->trans('Enabled')), $search_status, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp onrightofpage width100');
|
||||
print '</td>';
|
||||
// Action column
|
||||
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
||||
|
|
@ -230,7 +317,7 @@ if (!is_array($user_arbo) && $user_arbo < 0) {
|
|||
}
|
||||
print_liste_field_titre("HierarchicView");
|
||||
print_liste_field_titre('<div id="iddivjstreecontrol"><a href="#">'.img_picto('', 'folder', 'class="paddingright"').'<span class="hideonsmartphone">'.$langs->trans("UndoExpandAll").'</span></a> | <a href="#">'.img_picto('', 'folder-open', 'class="paddingright"').'<span class="hideonsmartphone">'.$langs->trans("ExpandAll").'</span></a></div>', $_SERVER['PHP_SELF'], "", '', "", 'align="center"');
|
||||
print_liste_field_titre("Status", $_SERVER['PHP_SELF'], "", '', "", '', '', '', 'right ');
|
||||
print_liste_field_titre("Status", $_SERVER['PHP_SELF'], "", '', "", '', '', '', 'right onrightofpage');
|
||||
// Action column
|
||||
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
||||
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', '', '', 'maxwidthsearch ');
|
||||
|
|
|
|||
Loading…
Reference in a new issue