From 0bcce7171ba2140f7bd99a2723561a4298732087 Mon Sep 17 00:00:00 2001 From: atm-irvine <165771178+atm-irvine@users.noreply.github.com> Date: Wed, 24 Apr 2024 21:18:36 +0200 Subject: [PATCH 1/8] FIX : Row size of role contact in thirdparty (#29456) --- htdocs/core/lib/company.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index b949c2df58b..52c46720474 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1467,7 +1467,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl // Role if (!empty($arrayfields['sc.role']['checked'])) { - print ''; + print ''; print $formcompany->showRoles("roles", $contactstatic, 'view'); print ''; } From 9ed8f0708207d7a1b946ecc1414f069def1fdb82 Mon Sep 17 00:00:00 2001 From: Can Arslan <138895927+mc2rcanarslan@users.noreply.github.com> Date: Wed, 24 Apr 2024 13:20:27 -0600 Subject: [PATCH 2/8] FIX: missing comma in query (#29435) Co-authored-by: Laurent Destailleur From f46ec55e0b86702384defc73b5527c2b3966d394 Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Wed, 24 Apr 2024 22:39:22 +0200 Subject: [PATCH 3/8] fix: when option SOCIETE_ADDRESSES_MANAGEMENT is set then PHP message: PHP Fatal error: Uncaught Error: Call to undefined function show_addresses() in htdocs/societe/card.php:3325 (#29461) --- htdocs/societe/card.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 4a09785b7f6..de2c210f795 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -3319,11 +3319,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $result = show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); } - - // Addresses list - if (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) { - $result = show_addresses($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); - } } } From 80ee6c813c0b3418bdd4a4ef06ab372077220abb Mon Sep 17 00:00:00 2001 From: PsyCrow <93346975+PsyCrow-code@users.noreply.github.com> Date: Fri, 26 Apr 2024 15:50:54 -0600 Subject: [PATCH 4/8] FIX PHP Warning: Undefined array key "totalam" on line 1891 (#29487) FIX PHP Warning: Undefined array key "totalam" on line 1891 --- htdocs/fourn/facture/list.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index d3d60c970f8..ebb7c98bb92 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -1885,6 +1885,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; } From 00e61f875a7dfc0434b7f9bb2c839023720bd6de Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Sat, 27 Apr 2024 00:57:32 +0200 Subject: [PATCH 5/8] FIX: Hierarchy Employee view do not filter on employee = 1 (#29496) * FIX: Hierarchy Employee list do not filters on employee = 1 * Update hierarchy.php --------- Co-authored-by: Laurent Destailleur --- htdocs/user/hierarchy.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index 671e3bf3c7e..4b0772ee246 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -104,9 +104,19 @@ $arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css llxHeader('', $title, $help_url, '', 0, 0, $arrayofjs, $arrayofcss, '', 'bodyforlist'); - +$filters = []; +if (($search_statut != '' && $search_statut >= 0)) { + $filters[] = "statut = ".((int) $search_statut); +} +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_statut != '' && $search_statut >= 0) ? "statut = ".$search_statut : ''); +$user_arbo = $userstatic->get_full_tree(0, $sqlfilter); // Count total nb of records From 3a887ab2fa77636171998393182ace95db9efeab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Apr 2024 03:12:17 +0200 Subject: [PATCH 6/8] FIX #29496 - filtering a record should not hide its child not filtered --- htdocs/core/lib/treeview.lib.php | 13 ++--- htdocs/langs/en_US/users.lang | 1 + htdocs/user/class/user.class.php | 2 +- htdocs/user/hierarchy.php | 89 +++++++++++++++++++++++++++++--- 4 files changed, 92 insertions(+), 13 deletions(-) diff --git a/htdocs/core/lib/treeview.lib.php b/htdocs/core/lib/treeview.lib.php index 78703c669c5..13d325702ba 100644 --- a/htdocs/core/lib/treeview.lib.php +++ b/htdocs/core/lib/treeview.lib.php @@ -103,7 +103,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 aleady processed record @@ -142,13 +142,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']."
\n"; if (empty($ulprinted) && !empty($pere['rowid'])) { if (!empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) { @@ -175,7 +176,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 ''; - } 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']."
\n"; if (empty($ulprinted) && !empty($pere['rowid'])) { if (!empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) { diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index 8da39ed1cd8..922b2c794ad 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -132,3 +132,4 @@ 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 public virtual user card +ExcludedByFilter=Non qualified by filters but shown to see its hierarchy \ No newline at end of file diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 65a3ca15fae..c7feb5d408e 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -3577,7 +3577,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); diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index 4b0772ee246..2cb4773edc8 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -60,6 +60,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', $search_statut = ""; } +$search_employee = -1; if ($contextpage == 'employeelist') { $search_employee = 1; } @@ -116,8 +117,12 @@ if (!empty($filters)) { $sqlfilter = join(' AND ', $filters); } // Load hierarchy of users -$user_arbo = $userstatic->get_full_tree(0, $sqlfilter); - +$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); @@ -131,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 = $val['id']; @@ -169,15 +175,86 @@ if (!is_array($user_arbo) && $user_arbo < 0) { $entry = '
'.$li.''.$userstatic->getLibStatut(2).'
'; - $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 = ''; + $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 .= ' ('.$val['login'].($entitystring ? ' - '.$entitystring : '').')'; + $li .= ' - '.$langs->trans("ExcludedByFilter").''; + $li .= ''; + + $entry = '
'.$li.''.$userstatic->getLibStatut(2).'
'; + + $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 = ''.$langs->trans("ParentIDDoesNotExistAnymore").''; + $entry = '
'.$li.'
'; + $data[-2] = array( + 'rowid'=>'-2', + 'fk_menu'=>null, + 'statut'=>'1', + 'entry'=>$entry + ); + } + $parentfound = 1; + } + + $i++; + } + } + } + //var_dump($data);exit; $param = "&search_statut=".urlencode($search_statut); $param = "&contextpage=".urlencode($contextpage); From d854870bb251a1c740f0882a9b3c334270dda253 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Apr 2024 03:24:20 +0200 Subject: [PATCH 7/8] Fix CSS --- htdocs/user/hierarchy.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index 52d11123b0c..60f1d2f9b49 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -298,8 +298,8 @@ if (!is_array($user_arbo) && $user_arbo < 0) { print ' '; print ' '; // Status - print ''; - print $form->selectarray('search_statut', array('-1'=>'', '1'=>$langs->trans('Enabled')), $search_statut, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp'); + print ''; + print $form->selectarray('search_statut', array('-1'=>'', '1'=>$langs->trans('Enabled')), $search_statut, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp onrightofpage width100'); print ''; // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { @@ -317,7 +317,7 @@ if (!is_array($user_arbo) && $user_arbo < 0) { } print_liste_field_titre("HierarchicView"); print_liste_field_titre('', $_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 '); From 2f1dcbc2add75d0527fe0e57846d6880a30f5c98 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Apr 2024 03:27:25 +0200 Subject: [PATCH 8/8] Fix filter on status in hierarchy page --- htdocs/user/hierarchy.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index 60f1d2f9b49..31cc151b664 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -51,13 +51,13 @@ $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -$search_statut = GETPOST('search_statut', 'int'); -if ($search_statut == '' || $search_statut == '0') { - $search_statut = '1'; +$search_status = GETPOST('search_statut', 'int') ? GETPOST('search_statut', 'int') : GETPOST('search_status', 'int'); +if ($search_status === '') { + $search_status = '1'; } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers - $search_statut = ""; + $search_status = ""; } $search_employee = -1; @@ -106,8 +106,8 @@ $arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css llxHeader('', $title, $help_url, '', 0, 0, $arrayofjs, $arrayofcss, '', 'bodyforlist'); $filters = []; -if (($search_statut != '' && $search_statut >= 0)) { - $filters[] = "statut = ".((int) $search_statut); +if (($search_status != '' && $search_status >= 0)) { + $filters[] = "statut = ".((int) $search_status); } if (($search_employee != '' && $search_employee >= 0)) { $filters[] = "employee = ".((int) $search_employee); @@ -256,7 +256,7 @@ if (!is_array($user_arbo) && $user_arbo < 0) { } //var_dump($data);exit; - $param = "&search_statut=".urlencode($search_statut); + $param = "&search_status=".urlencode($search_status); $param = "&contextpage=".urlencode($contextpage); $newcardbutton = ''; @@ -299,7 +299,7 @@ if (!is_array($user_arbo) && $user_arbo < 0) { print ' '; // Status print ''; - print $form->selectarray('search_statut', array('-1'=>'', '1'=>$langs->trans('Enabled')), $search_statut, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp onrightofpage width100'); + 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 ''; // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {