Merge pull request #9709 from bafbes/abb80031
NEW Category filter on user list
This commit is contained in:
commit
46ad7de5dd
@ -26,6 +26,9 @@
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
if (! empty($conf->categorie->enabled))
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
|
||||
if (! $user->rights->user->user->lire && ! $user->admin)
|
||||
accessforbidden();
|
||||
@ -123,6 +126,8 @@ $search_thirdparty=GETPOST('search_thirdparty','alpha');
|
||||
$search_supervisor=GETPOST('search_supervisor','intcomma');
|
||||
$search_previousconn=GETPOST('search_previousconn','alpha');
|
||||
$optioncss = GETPOST('optioncss','alpha');
|
||||
$search_categ = GETPOST("search_categ",'int');
|
||||
$catid = GETPOST('catid','int');
|
||||
|
||||
// Default search
|
||||
if ($search_statut == '') $search_statut='1';
|
||||
@ -165,6 +170,7 @@ if (empty($reshook))
|
||||
$search_date_creation="";
|
||||
$search_date_update="";
|
||||
$search_array_options=array();
|
||||
$search_categ=0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,6 +179,8 @@ if (empty($reshook))
|
||||
* View
|
||||
*/
|
||||
|
||||
$htmlother=new FormOther($db);
|
||||
|
||||
$user2=new User($db);
|
||||
|
||||
$buttonviewhierarchy='<form action="'.DOL_URL_ROOT.'/user/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>';
|
||||
@ -193,6 +201,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user_extrafields as ef on (u.rowid = ef.fk_object)";
|
||||
$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";
|
||||
if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_user as cu ON u.rowid = cu.fk_user"; // We'll need this table joined to the select in order to filter by categ
|
||||
// Add fields from hooks
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printUserListWhere',$parameters); // Note that $action and $object may have been modified by hook
|
||||
@ -216,6 +225,10 @@ if ($search_accountancy_code != '') $sql.= natural_search("u.accountancy_code",
|
||||
if ($search_email != '') $sql.= natural_search("u.email", $search_email);
|
||||
if ($search_statut != '' && $search_statut >= 0) $sql.= " AND u.statut IN (".$db->escape($search_statut).")";
|
||||
if ($sall) $sql.= natural_search(array_keys($fieldstosearchall), $sall);
|
||||
if ($catid > 0) $sql.= " AND cu.fk_categorie = ".$catid;
|
||||
if ($catid == -2) $sql.= " AND cu.fk_categorie IS NULL";
|
||||
if ($search_categ > 0) $sql.= " AND cu.fk_categorie = ".$db->escape($search_categ);
|
||||
if ($search_categ == -2) $sql.= " AND cu.fk_categorie IS NULL";
|
||||
// Add where from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
||||
// Add where from hooks
|
||||
@ -268,6 +281,7 @@ if ($search_supervisor > 0) $param.="&search_supervisor=".$search_supervisor;
|
||||
if ($search_statut != '') $param.="&search_statut=".$search_statut;
|
||||
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
||||
if ($mode != '') $param.='&mode='.$mode;
|
||||
if ($search_categ > 0) $param.="&search_categ=".urlencode($search_categ);
|
||||
// Add $param from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||
|
||||
@ -296,6 +310,15 @@ $morehtmlright = '<a class="nohover" href="'.DOL_URL_ROOT.'/user/hierarchy.php'.
|
||||
|
||||
print_barre_liste($text, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'title_generic', 0, $morehtmlright.' '.$newcardbutton, '', $limit);
|
||||
|
||||
if (! empty($catid))
|
||||
{
|
||||
print "<div id='ways'>";
|
||||
$c = new Categorie($db);
|
||||
$ways = $c->print_all_ways(' > ','user/list.php');
|
||||
print " > ".$ways[0]."<br>\n";
|
||||
print "</div><br>";
|
||||
}
|
||||
|
||||
if ($sall)
|
||||
{
|
||||
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
|
||||
@ -304,7 +327,29 @@ if ($sall)
|
||||
|
||||
$moreforfilter='';
|
||||
|
||||
// Filter on categories
|
||||
if (! empty($conf->categorie->enabled))
|
||||
{
|
||||
$moreforfilter.='<div class="divsearchfield">';
|
||||
$moreforfilter.=$langs->trans('Categories'). ': ';
|
||||
$moreforfilter.=$htmlother->select_categories(Categorie::TYPE_USER,$search_categ,'search_categ',1);
|
||||
$moreforfilter.='</div>';
|
||||
}
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) $moreforfilter.=$hookmanager->resPrint;
|
||||
else $moreforfilter=$hookmanager->resPrint;
|
||||
|
||||
if ($moreforfilter)
|
||||
{
|
||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||
print $moreforfilter;
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||
|
||||
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user