Skip to content

Commit

Permalink
feat(services-list): created global search; backported from develop
Browse files Browse the repository at this point in the history
  • Loading branch information
atm-irvine committed Jan 15, 2025
1 parent 7ac84bd commit db19e97
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog_Koesio.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## Backported from 17.0 :
- Backport develop PR #32662 : New hooks in services_list and added global search
- Backport develop PR #32129 : New field rule for lines dates
- Backport 17.0 PR #32247 : added error message in cron
- Backport develop : fix abs fatal error
Expand Down
36 changes: 36 additions & 0 deletions htdocs/contrat/services_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,21 @@

$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');

/** BACKPORT PR 32662 */
$sall = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');

$fieldstosearchall = [
'p.label' => 'Product',
's.nom' => 'ThirdParty',
];
$parameters = ['fieldstosearchall' => $fieldstosearchall];
$reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action);
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
$fieldstosearchall = array_merge($fieldstosearchall, $hookmanager->resArray);
/** END BACKPORT PR 32662 */

// Security check
$contratid = GETPOST('id', 'int');
if (!empty($user->socid)) {
Expand Down Expand Up @@ -252,6 +267,13 @@
if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cd.rowid = ef.fk_object)";
}
/** BACKPORT PR 32662 */
// Add table from hooks
$parameters = [];
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
/** END BACKPORT PR 32662 */

$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
if ($search_product_category > 0) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product';
Expand Down Expand Up @@ -346,6 +368,13 @@
if (!empty($filter_opcloture) && $filter_opcloture == ' BETWEEN ') {
$sql .= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture_start)."' AND '".$db->idate($filter_datecloture_end)."'";
}

/** BACKPORT PR 32662 */
if ($sall) {
$sql .= natural_search(array_keys($fieldstosearchall), $sall);
}
/** END BACKPORT PR 32662 */

// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
$sql .= $db->order($sortfield, $sortorder);
Expand Down Expand Up @@ -392,6 +421,13 @@
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.$limit;
}

/** BACKPORT PR 32662 */
if ($sall != '') {
$param .= '&sall='.urlencode($sall);
}
/** END BACKPORT PR 32662 */

if ($search_contract) {
$param .= '&amp;search_contract='.urlencode($search_contract);
}
Expand Down

0 comments on commit db19e97

Please sign in to comment.