|
@@ -41,9 +41,10 @@ $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk
|
|
|
$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
|
|
|
$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
|
|
|
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
|
|
|
-$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'userlist'; // To manage different context of search
|
|
|
+$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'userlist'; // To manage different context of search
|
|
|
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
|
|
|
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
|
|
|
+$mode = GETPOST("mode", 'alpha');
|
|
|
|
|
|
// Security check (for external users)
|
|
|
$socid = 0;
|
|
@@ -51,9 +52,6 @@ if ($user->socid > 0) {
|
|
|
$socid = $user->socid;
|
|
|
}
|
|
|
|
|
|
-// Load mode employee
|
|
|
-$mode = GETPOST("mode", 'alpha');
|
|
|
-
|
|
|
// Load variable for pagination
|
|
|
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
|
|
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
|
@@ -125,7 +123,7 @@ $arrayfields = array(
|
|
|
'u.firstname'=>array('label'=>"Firstname", 'checked'=>1, 'position'=>20),
|
|
|
'u.entity'=>array('label'=>"Entity", 'checked'=>1, 'position'=>50, 'enabled'=>(isModEnabled('multicompany') && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))),
|
|
|
'u.gender'=>array('label'=>"Gender", 'checked'=>0, 'position'=>22),
|
|
|
- 'u.employee'=>array('label'=>"Employee", 'checked'=>($mode == 'employee' ? 1 : 0), 'position'=>25),
|
|
|
+ 'u.employee'=>array('label'=>"Employee", 'checked'=>($contextpage == 'employeelist' ? 1 : 0), 'position'=>25),
|
|
|
'u.fk_user'=>array('label'=>"HierarchicalResponsible", 'checked'=>1, 'position'=>27),
|
|
|
'u.accountancy_code'=>array('label'=>"AccountancyCode", 'checked'=>0, 'position'=>30),
|
|
|
'u.office_phone'=>array('label'=>"PhonePro", 'checked'=>1, 'position'=>31),
|
|
@@ -164,6 +162,17 @@ $search_thirdparty = GETPOST('search_thirdparty', 'alpha');
|
|
|
$search_warehouse = GETPOST('search_warehouse', 'alpha');
|
|
|
$search_supervisor = GETPOST('search_supervisor', 'intcomma');
|
|
|
$search_categ = GETPOST("search_categ", 'int');
|
|
|
+$searchCategoryUserOperator = 0;
|
|
|
+if (GETPOSTISSET('formfilteraction')) {
|
|
|
+ $searchCategoryUserOperator = GETPOSTINT('search_category_user_operator');
|
|
|
+} elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) {
|
|
|
+ $searchCategoryUserOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT;
|
|
|
+}
|
|
|
+$searchCategoryUserList = GETPOST('search_category_user_list', 'array');
|
|
|
+$catid = GETPOST('catid', 'int');
|
|
|
+if (!empty($catid) && empty($searchCategoryUserList)) {
|
|
|
+ $searchCategoryUserList = array($catid);
|
|
|
+}
|
|
|
$catid = GETPOST('catid', 'int');
|
|
|
if (!empty($catid) && empty($search_categ)) {
|
|
|
$search_categ = $catid;
|
|
@@ -173,7 +182,7 @@ if (!empty($catid) && empty($search_categ)) {
|
|
|
if ($search_statut == '') {
|
|
|
$search_statut = '1';
|
|
|
}
|
|
|
-if ($mode == 'employee' && !GETPOSTISSET('search_employee')) {
|
|
|
+if ($contextpage == 'employeelist' && !GETPOSTISSET('search_employee')) {
|
|
|
$search_employee = 1;
|
|
|
}
|
|
|
|
|
@@ -192,7 +201,7 @@ if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
|
|
|
$error = 0;
|
|
|
|
|
|
// Permission to list
|
|
|
-if ($mode == 'employee') {
|
|
|
+if ($contextpage == 'employeelist' && $search_employee == 1) {
|
|
|
if (!$user->hasRight("salaries", "read")) {
|
|
|
accessforbidden();
|
|
|
}
|
|
@@ -428,35 +437,39 @@ if ($sall) {
|
|
|
$sql .= natural_search(array_keys($fieldstosearchall), $sall);
|
|
|
}
|
|
|
|
|
|
-// Search for tag/category ($searchCategoryProductList is an array of ID)
|
|
|
-$searchCategoryProductList = array($search_categ);
|
|
|
-if (!empty($searchCategoryProductList)) {
|
|
|
- $searchCategoryProductSqlList = array();
|
|
|
+// Search for tag/category ($searchCategoryUserList is an array of ID)
|
|
|
+$searchCategoryUserList = array($search_categ);
|
|
|
+if (!empty($searchCategoryUserList)) {
|
|
|
+ $searchCategoryUserSqlList = array();
|
|
|
$listofcategoryid = '';
|
|
|
- foreach ($searchCategoryProductList as $searchCategoryProduct) {
|
|
|
- if (intval($searchCategoryProduct) == -2) {
|
|
|
- $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user)";
|
|
|
- } elseif (intval($searchCategoryProduct) > 0) {
|
|
|
- $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
|
|
|
+ foreach ($searchCategoryUserList as $searchCategoryUser) {
|
|
|
+ if (intval($searchCategoryUser) == -2) {
|
|
|
+ $searchCategoryUserSqlList[] = "NOT EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user)";
|
|
|
+ } elseif (intval($searchCategoryUser) > 0) {
|
|
|
+ if ($searchCategoryUserOperator == 0) {
|
|
|
+ $searchCategoryUserSqlList[] = " EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user AND ck.fk_categorie = ".((int) $searchCategoryUser).")";
|
|
|
+ } else {
|
|
|
+ $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryUser);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if ($listofcategoryid) {
|
|
|
- $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
|
|
|
+ $searchCategoryUserSqlList[] = " EXISTS (SELECT ck.fk_user FROM ".MAIN_DB_PREFIX."categorie_user as ck WHERE u.rowid = ck.fk_user AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
|
|
|
}
|
|
|
- if ($searchCategoryProductOperator == 1) {
|
|
|
- if (!empty($searchCategoryProductSqlList)) {
|
|
|
- $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
|
|
|
+ if ($searchCategoryUserOperator == 1) {
|
|
|
+ if (!empty($searchCategoryUserSqlList)) {
|
|
|
+ $sql .= " AND (".implode(' OR ', $searchCategoryUserSqlList).")";
|
|
|
}
|
|
|
} else {
|
|
|
- if (!empty($searchCategoryProductSqlList)) {
|
|
|
- $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
|
|
|
+ if (!empty($searchCategoryUserSqlList)) {
|
|
|
+ $sql .= " AND (".implode(' AND ', $searchCategoryUserSqlList).")";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if ($search_warehouse > 0) {
|
|
|
$sql .= " AND u.fk_warehouse = ".((int) $search_warehouse);
|
|
|
}
|
|
|
-if ($mode == 'employee' && !$user->hasRight("salaries", "readall")) {
|
|
|
+if ($contextpage == 'employeelist' && !$user->hasRight("salaries", "readall")) {
|
|
|
$sql .= " AND u.rowid IN (".$db->sanitize(join(',', $childids)).")";
|
|
|
}
|
|
|
// Add where from extra fields
|
|
@@ -523,7 +536,6 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $
|
|
|
|
|
|
// Output page
|
|
|
// --------------------------------------------------------------------
|
|
|
-$title = $langs->trans("ListOfUsers");
|
|
|
|
|
|
llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist');
|
|
|
|
|
@@ -626,7 +638,7 @@ print '<input type="hidden" name="page" value="'.$page.'">';
|
|
|
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
|
|
print '<input type="hidden" name="mode" value="'.$mode.'">';
|
|
|
|
|
|
-$url = DOL_URL_ROOT.'/user/card.php?action=create'.($mode == 'employee' ? '&employee=1' : '').'&leftmenu=';
|
|
|
+$url = DOL_URL_ROOT.'/user/card.php?action=create'.($contextpage == 'employeelist' ? '&search_employee=1' : '').'&leftmenu=';
|
|
|
if (!empty($socid)) {
|
|
|
$url .= '&socid='.urlencode($socid);
|
|
|
}
|