diff --git a/ChangeLog b/ChangeLog index 9432bdea4d7..18e2b1cdc72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ English Dolibarr ChangeLog -------------------------------------------------------------- + ***** ChangeLog for 17.0.0 compared to 16.0.0 ***** For users: @@ -25,9 +26,10 @@ WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * The signature of method getNomUrl() of class ProductFournisseur has been modified to match the signature of method Product * Trigger ORDER_SUPPLIER_DISPATCH is removed, use ORDER_SUPPLIER_RECEIVE and/or LINEORDER_SUPPLIER_DISPATCH instead. -* All functions fetch_all() are deprecated for naming consitency, use fetchAll() instead -* Code standardization: $user->rights->propale is now $user->rights->propal everywhere. +* All functions fetch_all() have been set to deprecated for naming consitency, use fetchAll() instead. +* Code standardization: '$user->rights->propale' is now '$user->rights->propal' everywhere. * Deprecated method set_billed() on shipment and reception class has been removed. Use setBilled() instead. +* Tables llx_prelevement_facture and llx_prelevement_facture_demande have been renamed into llx_prelevement and llx_prelevement_demande. ***** ChangeLog for 16.0.1 compared to 16.0.0 ***** diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 4b3a5cdb82c..394a650d7ee 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -370,7 +370,11 @@ if (!empty($searchCategoryContactList)) { if (intval($searchCategoryContact) == -2) { $searchCategoryContactSqlList[] = "NOT EXISTS (SELECT ck.fk_categorie FROM ".MAIN_DB_PREFIX."categorie_member as ck WHERE d.rowid = ck.fk_member)"; } elseif (intval($searchCategoryContact) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryContact); + if ($searchCategoryContactOperator == 0) { + $searchCategoryContactSqlList[] = " EXISTS (SELECT ck.fk_categorie FROM ".MAIN_DB_PREFIX."categorie_member as ck WHERE d.rowid = ck.fk_member AND ck.fk_categorie = ".((int) $searchCategoryContact).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryContact); + } } } if ($listofcategoryid) { diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 1f4fc60397e..54cd0f2b58c 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -222,7 +222,11 @@ if (!empty($searchCategoryBankList)) { if (intval($searchCategoryBank) == -2) { $searchCategoryBankSqlList[] = "NOT EXISTS (SELECT ck.fk_account FROM ".MAIN_DB_PREFIX."categorie_account as ck WHERE b.rowid = ck.fk_account)"; } elseif (intval($searchCategoryBank) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryBank); + if ($searchCategoryBankOperator == 0) { + $searchCategoryBankSqlList[] = " EXISTS (SELECT ck.fk_account FROM ".MAIN_DB_PREFIX."categorie_account as ck WHERE b.rowid = ck.fk_account AND ck.fk_categorie = ".((int) $searchCategoryBank).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryBank); + } } } if ($listofcategoryid) { diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 11fdb6ac982..fb7616e8ab3 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -813,7 +813,11 @@ if (!empty($searchCategoryProductList)) { if (intval($searchCategoryProduct) == -2) { $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product)"; } elseif (intval($searchCategoryProduct) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); + if ($searchCategoryProductOperator == 0) { + $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); + } } } if ($listofcategoryid) { @@ -839,7 +843,11 @@ if (!empty($searchCategoryCustomerList)) { if (intval($searchCategoryCustomer) == -2) { $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc)"; } elseif (intval($searchCategoryCustomer) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer); + if ($searchCategoryCustomerOperator == 0) { + $searchCategoryCustomerSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategoryCustomer).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer); + } } } if ($listofcategoryid) { diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index e8396a4299c..ae5deba98f1 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -438,7 +438,11 @@ if (!empty($searchCategoryContactList)) { if (intval($searchCategoryContact) == -2) { $searchCategoryContactSqlList[] = "NOT EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX."categorie_contact as ck WHERE s.rowid = ck.fk_socpeople)"; } elseif (intval($searchCategoryContact) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryContact); + if ($searchCategoryContactOperator == 0) { + $searchCategoryContactSqlList[] = " EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX."categorie_contact as ck WHERE s.rowid = ck.fk_socpeople AND ck.fk_categorie = ".((int) $searchCategoryContact).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryContact); + } } } if ($listofcategoryid) { @@ -464,7 +468,11 @@ if (!empty($searchCategoryCustomerList)) { if (intval($searchCategoryCustomer) == -2) { $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc)"; } elseif (intval($searchCategoryCustomer) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer); + if ($searchCategoryCustomerOperator == 0) { + $searchCategoryCustomerSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategoryCustomer).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer); + } } } if ($listofcategoryid) { @@ -490,7 +498,11 @@ if (!empty($searchCategorySupplierList)) { if (intval($searchCategorySupplier) == -2) { $searchCategorySupplierSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)"; } elseif (intval($searchCategorySupplier) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier); + if ($searchCategorySupplierOperator == 0) { + $searchCategorySupplierSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategorySupplier).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier); + } } } if ($listofcategoryid) { diff --git a/htdocs/core/class/html.formcategory.class.php b/htdocs/core/class/html.formcategory.class.php index c0e07b6bb7a..bd2315645db 100644 --- a/htdocs/core/class/html.formcategory.class.php +++ b/htdocs/core/class/html.formcategory.class.php @@ -32,11 +32,13 @@ class FormCategory extends Form /** * Return a HTML filter box for a list filter view * - * @param string $type The categorie type (e.g Categorie::TYPE_WAREHOUSE) - * @param Array $preSelected A list with the elements that should pre-selected - * @return string A HTML filter box (Note: selected results can get with GETPOST("search_category_".$type."_list")) + * @param string $type The categorie type (e.g Categorie::TYPE_WAREHOUSE) + * @param array $preSelected A list with the elements that should pre-selected + * @param string $morecss More CSS + * @param int $searchCategoryProductOperator 0 or 1 to enable the checkbox to search with a or (0=not preseleted, 1=preselected) + * @return string A HTML filter box (Note: selected results can get with GETPOST("search_category_".$type."_list")) */ - public function getFilterBox($type, array $preSelected) + public function getFilterBox($type, array $preSelected, $morecss = "minwidth300 widthcentpercentminusx", $searchCategoryProductOperator = -1) { global $langs; @@ -45,6 +47,7 @@ class FormCategory extends Form } $htmlName = "search_category_".$type."_list"; + $htmlName2 = "search_category_".$type."_operator"; $categoryArray = $this->select_all_categories($type, "", "", 64, 0, 1); $categoryArray[-2] = "- ".$langs->trans('NotCategorized')." -"; @@ -55,7 +58,10 @@ class FormCategory extends Form $filter .= '
'; $filter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); //$filter .= $langs->trans('Categories').": "; - $filter .= Form::multiselectarray($htmlName, $categoryArray, $preSelected, 0, 0, "minwidth300 widthcentpercentminusx", 0, 0, '', '', $tmptitle); + $filter .= Form::multiselectarray($htmlName, $categoryArray, $preSelected, 0, 0, $morecss, 0, 0, '', '', $tmptitle); + if ($searchCategoryProductOperator >= 0) { + $filter .= ' '; + } $filter .= "
"; return $filter; diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 103b370dcb0..7e14474bc96 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -429,8 +429,7 @@ class FormOther if (!is_numeric($showempty)) { $textforempty = $showempty; } - $moreforfilter .= ''."\n"; - //$moreforfilter .= ''; // Should use -1 to say nothing + $moreforfilter .= ''."\n"; } if (is_array($tab_categs)) { @@ -439,6 +438,7 @@ class FormOther if ($categ['id'] == $selected) { $moreforfilter .= ' selected'; } + $moreforfilter .= ' data-html="'.dol_escape_htmltag(img_picto('', 'category', 'class="pictofixedwidth" style="color: #'.$categ['color'].'"').dol_trunc($categ['fulllabel'], 50, 'middle')).'"'; $moreforfilter .= '>'.dol_trunc($categ['fulllabel'], 50, 'middle').''; } } diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 10c50ca99ee..d6945d26fd5 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -473,9 +473,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left -- HRM - Employee -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4600__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee', 'Employees', 0, 'hrm', '$user->rights->user->user->lire', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4600__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&contextpage=employeelist', 'Employees', 0, 'hrm', '$user->rights->user->user->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4601__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/card.php?mainmenu=hrm&action=create&employee=1', 'NewEmployee', 1, 'hrm', '$user->rights->user->user->creer', '', 0, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4602__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee&contextpage=employeelist', 'List', 1, 'hrm', '$user->rights->user->user->lire', '', 0, 2, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4602__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&contextpage=employeelist', 'List', 1, 'hrm', '$user->rights->user->user->lire', '', 0, 2, __ENTITY__); -- HRM - Holiday insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5000__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/holiday/list.php?mainmenu=hrm&leftmenu=hrm', 'CPTitreMenu', 0, 'holiday', '$user->rights->holiday->read', '', 0, 1, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 4a6636942c4..22613a331b7 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -2251,9 +2251,9 @@ function get_left_menu_hrm($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = if (isModEnabled('hrm')) { $langs->load("hrm"); - $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee", $langs->trans("Employees"), 0, $user->hasRight('user', 'user', 'read'), '', $mainmenu, 'hrm', 0, '', '', '', img_picto('', 'user', 'class="paddingright pictofixedwidth"')); + $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&contextpage=employeelist", $langs->trans("Employees"), 0, $user->hasRight('user', 'user', 'read'), '', $mainmenu, 'hrm', 0, '', '', '', img_picto('', 'user', 'class="paddingright pictofixedwidth"')); $newmenu->add("/user/card.php?mainmenu=hrm&leftmenu=hrm&action=create&employee=1", $langs->trans("NewEmployee"), 1, $user->hasRight('user', 'user', 'write')); - $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee&contextpage=employeelist", $langs->trans("List"), 1, $user->hasRight('user', 'user', 'read')); + $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&contextpage=employeelist", $langs->trans("List"), 1, $user->hasRight('user', 'user', 'read')); $newmenu->add("/hrm/skill_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("SkillsManagement"), 0, $user->hasRight('hrm', 'all', 'read'), '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'shapes', 'class="paddingright pictofixedwidth"')); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index ddc4036e91b..709204793e9 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -594,7 +594,11 @@ if (!empty($searchCategorySupplierList)) { if (intval($searchCategorySupplier) == -2) { $searchCategorySupplierSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)"; } elseif (intval($searchCategorySupplier) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier); + if ($searchCategorySupplierOperator == 0) { + $searchCategorySupplierSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategorySupplier).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier); + } } } if ($listofcategoryid) { @@ -612,7 +616,7 @@ if (!empty($searchCategorySupplierList)) { } // Search for tag/category ($searchCategoryProductList is an array of ID) $searchCategoryProductList = $search_product_category ? array($search_product_category) : array(); -$searchCategorySupplierOperator = 0; +$searchCategoryProductOperator = 0; if (!empty($searchCategoryProductList)) { $searchCategoryProductSqlList = array(); $listofcategoryid = ''; @@ -620,7 +624,11 @@ if (!empty($searchCategoryProductList)) { if (intval($searchCategoryProduct) == -2) { $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product)"; } elseif (intval($searchCategoryProduct) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); + if ($searchCategoryProductOperator == 0) { + $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); + } } } if ($listofcategoryid) { diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index 217c7c71468..c8df2018ae7 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -293,7 +293,11 @@ if (!empty($searchCategoryKnowledgemanagementList)) { if (intval($searchCategoryKnowledgemanagement) == -2) { $searchCategoryKnowledgemanagementSqlList[] = "NOT EXISTS (SELECT ck.fk_knowledgemanagement FROM ".MAIN_DB_PREFIX."categorie_knowledgemanagement as ck WHERE t.rowid = ck.fk_knowledgemanagement)"; } elseif (intval($searchCategoryKnowledgemanagement) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryKnowledgemanagement); + if ($searchCategoryKnowledgemanagementOperator == 0) { + $searchCategoryKnowledgemanagementSqlList[] = " EXISTS (SELECT ck.fk_knowledgemanagement FROM ".MAIN_DB_PREFIX."categorie_knowledgemanagement as ck WHERE t.rowid = ck.fk_knowledgemanagement AND ck.fk_categorie = ".((int) $searchCategoryKnowledgemanagement).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryKnowledgemanagement); + } } } if ($listofcategoryid) { diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index d9ed8a37c5e..18104118068 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -270,49 +270,32 @@ foreach ($search as $key => $val) { if ($search_all) { $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } -// Search for tag/category -$searchCategoryProductSqlList = array(); -if ($searchCategoryProductOperator == 1) { - $existsCategoryProductList = array(); +// Search for tag/category ($searchCategoryProductList is an array of ID) +if (!empty($searchCategoryProductList)) { + $searchCategoryProductSqlList = array(); + $listofcategoryid = ''; foreach ($searchCategoryProductList as $searchCategoryProduct) { if (intval($searchCategoryProduct) == -2) { - $sqlCategoryProductNotExists = " NOT EXISTS ("; - $sqlCategoryProductNotExists .= " SELECT cp.fk_product"; - $sqlCategoryProductNotExists .= " FROM ".$db->prefix()."categorie_product AS cp"; - $sqlCategoryProductNotExists .= " WHERE cp.fk_product = t.fk_product"; - $sqlCategoryProductNotExists .= " )"; - $searchCategoryProductSqlList[] = $sqlCategoryProductNotExists; + $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product)"; } elseif (intval($searchCategoryProduct) > 0) { - $existsCategoryProductList[] = $db->escape($searchCategoryProduct); + if ($searchCategoryProductOperator == 0) { + $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); + } } } - if (!empty($existsCategoryProductList)) { - $sqlCategoryProductExists = " EXISTS ("; - $sqlCategoryProductExists .= " SELECT cp.fk_product"; - $sqlCategoryProductExists .= " FROM ".$db->prefix()."categorie_product AS cp"; - $sqlCategoryProductExists .= " WHERE cp.fk_product = t.fk_product"; - $sqlCategoryProductExists .= " AND cp.fk_categorie IN (".$db->sanitize(implode(',', $existsCategoryProductList)).")"; - $sqlCategoryProductExists .= " )"; - $searchCategoryProductSqlList[] = $sqlCategoryProductExists; + if ($listofcategoryid) { + $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; } - if (!empty($searchCategoryProductSqlList)) { - $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")"; - } -} else { - foreach ($searchCategoryProductList as $searchCategoryProduct) { - if (intval($searchCategoryProduct) == -2) { - $sqlCategoryProductNotExists = " NOT EXISTS ("; - $sqlCategoryProductNotExists .= " SELECT cp.fk_product"; - $sqlCategoryProductNotExists .= " FROM ".$db->prefix()."categorie_product AS cp"; - $sqlCategoryProductNotExists .= " WHERE cp.fk_product = t.fk_product"; - $sqlCategoryProductNotExists .= " )"; - $searchCategoryProductSqlList[] = $sqlCategoryProductNotExists; - } elseif (intval($searchCategoryProduct) > 0) { - $searchCategoryProductSqlList[] = "t.fk_product IN (SELECT fk_product FROM ".$db->prefix()."categorie_product WHERE fk_categorie = ".((int) $searchCategoryProduct).")"; + if ($searchCategoryProductOperator == 1) { + if (!empty($searchCategoryProductSqlList)) { + $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")"; + } + } else { + if (!empty($searchCategoryProductSqlList)) { + $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")"; } - } - if (!empty($searchCategoryProductSqlList)) { - $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")"; } } // Add where from extra fields diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 26f6a3a410c..55c5dc396b2 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -45,6 +45,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; if (isModEnabled('categorie')) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php'; } // Load translation files required by the page @@ -72,7 +73,7 @@ $search_type = GETPOST("search_type", 'int'); $search_vatrate = GETPOST("search_vatrate", 'alpha'); $searchCategoryProductOperator = 0; if (GETPOSTISSET('formfilteraction')) { - $searchCategoryProductOperator = GETPOST('search_category_product_operator', 'int'); + $searchCategoryProductOperator = GETPOSTINT('search_category_product_operator'); } elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) { $searchCategoryProductOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT; } @@ -508,7 +509,11 @@ if (!empty($searchCategoryProductList)) { if (intval($searchCategoryProduct) == -2) { $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product)"; } elseif (intval($searchCategoryProduct) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); + if ($searchCategoryProductOperator == 0) { + $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck WHERE p.rowid = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); + } } } if ($listofcategoryid) { @@ -554,7 +559,6 @@ if ($search_accountancy_code_buy_intra) { if ($search_accountancy_code_buy_export) { $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy_export', $search_accountancy_code_buy_export); } - // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -820,13 +824,8 @@ if ($resql) { // Filter on categories $moreforfilter = ''; if (isModEnabled('categorie') && $user->rights->categorie->lire) { - $moreforfilter .= '
'; - $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"'); - $categoriesProductArr = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', '', 64, 0, 1); - $categoriesProductArr[-2] = '- '.$langs->trans('NotCategorized').' -'; - $moreforfilter .= Form::multiselectarray('search_category_product_list', $categoriesProductArr, $searchCategoryProductList, 0, 0, 'minwidth300'); - $moreforfilter .= ' '; - $moreforfilter .= '
'; + $formcategory = new FormCategory($db); + $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PRODUCT, $searchCategoryProductList, 'minwidth300', $searchCategoryProductOperator ? $searchCategoryProductOperator : 0); } //Show/hide child products. Hidden by default diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index af2bb49b05e..b0c33e61484 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -270,7 +270,11 @@ if (!empty($searchCategoryWarehouseList)) { if (intval($searchCategoryWarehouse) == -2) { $searchCategoryWarehouseSqlList[] = "NOT EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE p.rowid = ck.fk_warehouse)"; } elseif (intval($searchCategoryWarehouse) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryWarehouse); + if ($searchCategoryWarehouseOperator == 0) { + $searchCategoryWarehouseSqlList[] = " EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE p.rowid = ck.fk_warehouse AND ck.fk_categorie = ".((int) $searchCategoryWarehouse).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryWarehouse); + } } } if ($listofcategoryid) { diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 696888a75dd..9ef64174325 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -570,7 +570,11 @@ if (!empty($searchCategoryProjectList)) { if (intval($searchCategoryProject) == -2) { $searchCategoryProjectSqlList[] = "NOT EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project)"; } elseif (intval($searchCategoryProject) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject); + if ($searchCategoryProjectOperator == 0) { + $searchCategoryProjectSqlList[] = " EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project AND ck.fk_categorie = ".((int) $searchCategoryProject).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject); + } } } if ($listofcategoryid) { diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 76261480ffe..fdec5c6a958 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -444,7 +444,11 @@ if (!empty($searchCategoryProjectList)) { if (intval($searchCategoryProject) == -2) { $searchCategoryProjectSqlList[] = "NOT EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project)"; } elseif (intval($searchCategoryProject) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject); + if ($searchCategoryProjectOperator == 0) { + $searchCategoryProjectSqlList[] = " EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project AND ck.fk_categorie = ".((int) $searchCategoryProject).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject); + } } } if ($listofcategoryid) { diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index f32317163ad..c0f50a5e7b0 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -536,7 +536,11 @@ if (!empty($searchCategoryCustomerList)) { if (intval($searchCategoryCustomer) == -2) { $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc)"; } elseif (intval($searchCategoryCustomer) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer); + if ($searchCategoryCustomerOperator == 0) { + $searchCategoryCustomerSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategoryCustomer).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer); + } } } if ($listofcategoryid) { @@ -562,7 +566,11 @@ if (!empty($searchCategorySupplierList)) { if (intval($searchCategorySupplier) == -2) { $searchCategorySupplierSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)"; } elseif (intval($searchCategorySupplier) > 0) { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier); + if ($searchCategorySupplierOperator == 0) { + $searchCategorySupplierSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategorySupplier).")"; + } else { + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier); + } } } if ($listofcategoryid) { diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index c48eda2312e..44ab46193d9 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -4,7 +4,7 @@ * Copyright (C) 2006-2015 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2019-2021 Frédéric France + * Copyright (C) 2019-2021 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; // Load translation files required by page -$langs->loadLangs(array('users', 'companies')); +$langs->loadLangs(array('users', 'companies', 'hrm', 'salaries')); // Security check (for external users) $socid = 0; @@ -40,16 +40,15 @@ if ($user->socid > 0) { } $optioncss = GETPOST('optioncss', 'alpha'); -$contextpage = GETPOST('optioncss', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'userlist'; // To manage different context of search +$mode = GETPOST("mode", 'alpha'); + $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -// Load mode employee -$mode = GETPOST("mode", 'alpha'); $search_statut = GETPOST('search_statut', 'int'); - if ($search_statut == '' || $search_statut == '0') { $search_statut = '1'; } @@ -58,18 +57,30 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', $search_statut = ""; } +if ($contextpage == 'employeelist') { + $search_employee = 1; +} + $userstatic = new User($db); // Define value to know what current user can do on users $canadduser = (!empty($user->admin) || $user->hasRight("user", "user", "write")); -if (!$user->hasRight("user", "user", "read") && !$user->admin) { - accessforbidden(); +// Permission to list +if ($contextpage == 'employeelist' && $search_employee == 1) { + if (!$user->hasRight("salaries", "read")) { + accessforbidden(); + } +} else { + if (!$user->hasRight("user", "user", "read") && empty($user->admin)) { + accessforbidden(); + } } $childids = $user->getAllChildIds(1); + /* * View */ @@ -77,7 +88,11 @@ $childids = $user->getAllChildIds(1); $form = new Form($db); $help_url = 'EN:Module_Users|FR:Module_Utilisateurs|ES:Módulo_Usuarios|DE:Modul_Benutzer'; -$title = $langs->trans("Users"); +if ($contextpage == 'employeelist' && $search_employee == 1) { + $title = $langs->trans("Employees"); +} else { + $title = $langs->trans("Users"); +} $arrayofjs = array( '/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js', @@ -152,6 +167,7 @@ if (!is_array($user_arbo) && $user_arbo < 0) { //var_dump($data); $param = "&search_statut=".urlencode($search_statut); + $param = "&contextpage=".urlencode($contextpage); $newcardbutton = ''; $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars paddingleft imgforviewmode', DOL_URL_ROOT.'/user/list.php?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 05d2f88c035..dacf572d175 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -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 ''; print ''; print ''; -$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); }