From 5e7d172a58cccd501d08a17294256c8a96b5ff58 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 6 Feb 2018 19:16:15 +0100 Subject: [PATCH] Fix look and feel v7 on ref popup --- htdocs/user/class/usergroup.class.php | 76 +++++++++++++++++++++++++++ htdocs/user/group/index.php | 14 +++-- htdocs/user/home.php | 44 +++++++++------- 3 files changed, 111 insertions(+), 23 deletions(-) diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 6032489b9c7..1c9ede28d94 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -40,6 +40,8 @@ class UserGroup extends CommonObject public $picto='group'; public $entity; // Entity of group + + public $name; // Name of group /** * @deprecated * @see name @@ -48,6 +50,7 @@ class UserGroup extends CommonObject public $globalgroup; // Global group public $datec; // Creation date of group public $datem; // Modification date of group + public $note; // Description public $members=array(); // Array of users public $nb_rights; // Number of rights granted to the user @@ -786,6 +789,79 @@ class UserGroup extends CommonObject return ''; } + /** + * Return a link to the user card (with optionaly the picto) + * Use this->id,this->lastname, this->firstname + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo, -3=Only photo very small) + * @param string $option On what the link point to ('nolink', ) + * @param integer $notooltip 1=Disable tooltip on picto and name + * @param string $mode ''=Show firstname and lastname, 'firstname'=Show only firstname, 'login'=Show login + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1) + { + global $langs, $conf, $db, $hookmanager; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; + + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpicto) $withpicto=0; + + $result=''; $label=''; + $link=''; $linkstart=''; $linkend=''; + + $label.= '
'; + $label.= '' . $langs->trans("Group") . '
'; + $label.= '' . $langs->trans('Name') . ': ' . $this->name; + $label.= '
' . $langs->trans("Description").': '.$this->note; + $label.='
'; + + $url = DOL_URL_ROOT.'/user/group/card.php?id='.$this->id; + + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } + + $linkclose=""; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $langs->load("users"); + $label=$langs->trans("ShowGroup"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.= ' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + } + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('groupdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $linkclose = $hookmanager->resPrint; + + $linkstart = ''; + $linkend=''; + + $result = $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->name; + $result .= $linkend; + + return $result; + } + /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * diff --git a/htdocs/user/group/index.php b/htdocs/user/group/index.php index 0a7b32062e2..0fcd2af98f2 100644 --- a/htdocs/user/group/index.php +++ b/htdocs/user/group/index.php @@ -25,6 +25,7 @@ */ require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { @@ -98,7 +99,7 @@ if (empty($reshook)) llxHeader(); -$sql = "SELECT g.rowid, g.nom as name, g.entity, g.datec, COUNT(DISTINCT ugu.fk_user) as nb"; +$sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec, COUNT(DISTINCT ugu.fk_user) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid"; if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity))) @@ -114,7 +115,7 @@ if (! empty($search_group)) $sql .= " AND (g.nom LIKE '%".$db->escape($search_group)."%' OR g.note LIKE '%".$db->escape($search_group)."%')"; } if ($sall) $sql.= " AND (g.nom LIKE '%".$db->escape($sall)."%' OR g.note LIKE '%".$db->escape($sall)."%')"; -$sql.= " GROUP BY g.rowid, g.nom, g.entity, g.datec"; +$sql.= " GROUP BY g.rowid, g.nom, g.note, g.entity, g.datec"; $sql.= $db->order($sortfield,$sortorder); $resql = $db->query($sql); @@ -174,14 +175,19 @@ if ($resql) print_liste_field_titre("DateCreationShort",$_SERVER["PHP_SELF"],"g.datec",$param,"",'align="right"',$sortfield,$sortorder); print "\n"; - $var=True; + $grouptemp = new UserGroup($db); + while ($i < $num) { $obj = $db->fetch_object($resql); + $grouptemp->id = $obj->id; + $grouptemp->name = $obj->name; + $grouptemp->note = $obj->note; print ''; - print ''.img_object($langs->trans("ShowGroup"),"group").' '.$obj->name.''; + print ''; + print $grouptemp->getNomUrl(1); if (! $obj->entity) { print img_picto($langs->trans("GlobalGroup"),'redstar'); diff --git a/htdocs/user/home.php b/htdocs/user/home.php index 7c464ce2e45..620954553fb 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -22,6 +22,7 @@ */ require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; if (! $user->rights->user->user->lire && ! $user->admin) { @@ -118,26 +119,30 @@ if ($resql) $num = $db->num_rows($resql); print ''; print ''; - $var = true; $i = 0; while ($i < $num && $i < $max) { $obj = $db->fetch_object($resql); - + + $fuserstatic->id = $obj->rowid; + $fuserstatic->statut = $obj->statut; + $fuserstatic->lastname = $obj->lastname; + $fuserstatic->firstname = $obj->firstname; + $fuserstatic->login = $obj->login; + $fuserstatic->photo = $obj->photo; + $fuserstatic->admin = $obj->admin; + $fuserstatic->email = $obj->email; + $fuserstatic->skype = $obj->skype; + $fuserstatic->societe_id = $obj->fk_soc; + + $companystatic->id=$obj->fk_soc; + $companystatic->name=$obj->name; + $companystatic->code_client = $obj->code_client; + $companystatic->canvas=$obj->canvas; print ''; print '
'.$langs->trans("LastUsersCreated",min($num,$max)).'
'; - $fuserstatic->id = $obj->rowid; - $fuserstatic->statut = $obj->statut; - $fuserstatic->lastname = $obj->lastname; - $fuserstatic->firstname = $obj->firstname; - $fuserstatic->login = $obj->login; - $fuserstatic->photo = $obj->photo; - $fuserstatic->admin = $obj->admin; - $fuserstatic->email = $obj->email; - $fuserstatic->skype = $obj->skype; - $fuserstatic->societe_id = $obj->fk_soc; print $fuserstatic->getNomUrl(-1); if (! empty($conf->multicompany->enabled) && $obj->admin && ! $obj->entity) { @@ -152,10 +157,6 @@ if ($resql) print ""; if ($obj->fk_soc) { - $companystatic->id=$obj->fk_soc; - $companystatic->name=$obj->name; - $companystatic->code_client = $obj->code_client; - $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1); } else @@ -231,16 +232,21 @@ if ($canreadperms) $num = $db->num_rows($resql); print ''; print ''; - $var = true; $i = 0; + $grouptemp = new UserGroup($db); + while ($i < $num && (! $max || $i < $max)) { $obj = $db->fetch_object($resql); - + + $grouptemp->id = $obj->id; + $grouptemp->name = $obj->name; + $grouptemp->note = $obj->note; print ''; - print '
'.$langs->trans("LastGroupsCreated",($num ? $num : $max)).'
'.img_object($langs->trans("ShowGroup"),"group").' '.$obj->name.''; + print ''; + print $grouptemp->getNomUrl(1); if (! $obj->entity) { print img_picto($langs->trans("GlobalGroup"),'redstar');