From 996f9c1eec5f98521daab13193c0b087d9b140f9 Mon Sep 17 00:00:00 2001 From: Nestor <npegane@hotmail.com> Date: Fri, 13 Oct 2017 10:15:14 +0200 Subject: [PATCH] FIX #6089 Quick and advanced search empty spaces handled --- .../indexing_searching/search_adv_result.php | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/apps/maarch_entreprise/indexing_searching/search_adv_result.php b/apps/maarch_entreprise/indexing_searching/search_adv_result.php index 53a75168424..a5bf7bdfebf 100755 --- a/apps/maarch_entreprise/indexing_searching/search_adv_result.php +++ b/apps/maarch_entreprise/indexing_searching/search_adv_result.php @@ -139,7 +139,8 @@ if (count($_REQUEST['meta']) > 0) { } elseif ($tab_id_fields[$j] == 'multifield' && !empty($_REQUEST['multifield'])) { // MULTIFIELD : subject, title, doc_custom_t1, process notes - $json_txt .= "'multifield' : ['".addslashes(trim($_REQUEST['multifield']))."'],"; + $multifield = trim($_REQUEST['multifield']); + $json_txt .= "'multifield' : ['".addslashes($multifield)."'],"; $where_request .= "(lower(translate(subject,'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖØÙÚÛÜÃÞßà áâãäåæçèéêëìÃîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) like lower(:multifield) " ."or (lower(translate(alt_identifier,'/','')) like lower(:multifield) OR lower(alt_identifier) like lower(:multifield)) " ."or lower(title) LIKE lower(:multifield) " @@ -152,7 +153,7 @@ if (count($_REQUEST['meta']) > 0) { $arrayPDO = array_merge($arrayPDO, array(":multifield2" => $_REQUEST['multifield'])); } - $multifield = \Core\Models\TextFormatModel::normalize(['string' => $_REQUEST['multifield']]); + $multifield = \Core\Models\TextFormatModel::normalize(['string' => $multifield]); $arrayPDO = array_merge($arrayPDO, array(":multifield" => "%".$multifield."%")); $where_request .=" and "; @@ -323,11 +324,12 @@ if (count($_REQUEST['meta']) > 0) { elseif ($tab_id_fields[$j] == 'subject' && !empty($_REQUEST['subject'])) { //var_dump($_REQUEST['subject']);exit(); - $_REQUEST['subject'] = $func->normalize($_REQUEST['subject']); - $json_txt .= " 'subject' : ['".addslashes(trim($_REQUEST['subject']))."'],"; + $subject = trim($_REQUEST['subject']); + $subject = $func->normalize($subject); + $json_txt .= " 'subject' : ['".addslashes($subject)."'],"; $where_request .= " (lower(translate(subject,'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖØÙÚÛÜÃÞßà áâãäåæçèéêëìÃîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) like lower(:subject) " ."or (res_id in (SELECT res_id_master FROM res_view_attachments WHERE coll_id = 'letterbox_coll' AND lower(translate(title,'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖØÙÚÛÜÃÞßà áâãäåæçèéêëìÃîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) like lower(:subject) ))) and "; - $arrayPDO = array_merge($arrayPDO, array(":subject" => "%".$_REQUEST['subject']."%")); + $arrayPDO = array_merge($arrayPDO, array(":subject" => "%".$subject."%")); } elseif ($tab_id_fields[$j] == 'fulltext' && !empty($_REQUEST['fulltext']) ) { @@ -464,12 +466,12 @@ if (count($_REQUEST['meta']) > 0) { //WELCOME PAGE elseif ($tab_id_fields[$j] == 'welcome' && (!empty($_REQUEST['welcome']))) { - $welcome = $_REQUEST['welcome']; - $json_txt .= "'multifield' : ['".addslashes(trim($welcome))."'],"; + $welcome = trim($_REQUEST['welcome']); + $json_txt .= "'multifield' : ['".addslashes($welcome)."'],"; if (is_numeric($_REQUEST['welcome'])) { $where_request_welcome .= "(res_id = :resIdWelcome) or "; - $arrayPDO = array_merge($arrayPDO, array(":resIdWelcome" => $_REQUEST['welcome'])); + $arrayPDO = array_merge($arrayPDO, array(":resIdWelcome" => $welcome)); } $where_request_welcome .= "( lower(translate(subject,'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖØÙÚÛÜÃÞßà áâãäåæçèéêëìÃîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) like lower(:multifieldWelcome) " ."or lower(identifier) LIKE lower(:multifieldWelcome) " @@ -479,9 +481,8 @@ if (count($_REQUEST['meta']) > 0) { ."or res_id in (select res_id_master from res_view_attachments where (lower(translate(identifier,'/','')) like lower(:multifieldWelcome) OR lower(identifier) like lower(:multifieldWelcome)) AND status NOT IN ('DEL','OBS','TMP')) " ."or contact_id in (select contact_id from view_contacts where society ilike :multifieldWelcome or contact_firstname ilike :multifieldWelcome or contact_lastname ilike :multifieldWelcome) or (exp_user_id in (select user_id from users where firstname ilike :multifieldWelcome or lastname ilike :multifieldWelcome )))"; - $multifieldWelcome = \Core\Models\TextFormatModel::normalize(['string' => $_REQUEST['welcome']]); + $multifieldWelcome = \Core\Models\TextFormatModel::normalize(['string' => $welcome]); $arrayPDO = array_merge($arrayPDO, array(":multifieldWelcome" => "%".$multifieldWelcome."%")); - $welcome = $_REQUEST['welcome']; set_include_path('apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR . 'tools' -- GitLab