Skip to content

Commit

Permalink
Merge pull request #559 from ATM-Consulting/NEW/132/TK2501-3509/GLOBA…
Browse files Browse the repository at this point in the history
…L_SEARCH

feat(services-list): created global search; backported from develop
  • Loading branch information
atm-lena authored Jan 16, 2025
2 parents ce31270 + f0f2263 commit 594b9f2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 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 17.0 PR #32654 : Search thirdparty in services list
- Backport develop PR #32129 : New field rule for lines dates
- Backport 17.0 PR #32247 : added error message in cron
Expand Down
40 changes: 38 additions & 2 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 */
$search_all = GETPOST('search_all', '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 @@ -348,6 +370,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 ($search_all) {
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
}
/** 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 @@ -394,6 +423,13 @@
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.$limit;
}

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

if ($search_contract) {
$param .= '&amp;search_contract='.urlencode($search_contract);
}
Expand Down Expand Up @@ -477,11 +513,11 @@

print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contract', 0, '', '', $limit);

if (!empty($sall)) {
if (!empty($search_all)) {
foreach ($fieldstosearchall as $key => $val) {
$fieldstosearchall[$key] = $langs->trans($val);
}
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
}

$morefilter = '';
Expand Down

0 comments on commit 594b9f2

Please sign in to comment.