From 86777bec6afe06ff7bb3abab5c622722af2e4d0b Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 2 Aug 2020 13:40:13 +0200 Subject: [PATCH] Bug : use ilike instead of tilde --- html/js/scripts.js | 4 ++-- include/ajax/ajax_anc_search.php | 2 +- include/ajax/ajax_auto_anc_card.php | 14 ++++++++++++-- include/class/contact.class.php | 2 +- include/class/dossier.class.php | 12 ++++++------ include/class/fiche.class.php | 4 ++-- include/class/follow_up.class.php | 4 ++-- include/class/user.class.php | 20 ++++++++++++-------- 8 files changed, 38 insertions(+), 24 deletions(-) diff --git a/html/js/scripts.js b/html/js/scripts.js index ce350f34b..959788c22 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -1224,7 +1224,7 @@ function fill_box(req) *@param dossier_id *@param od_id from table op_predef */ -function mod_predf_op(dossier_id, od_id) +function mod_predf_op(dossier_id, od_id,p_ledger) { var target = "mod_predf_op"; removeDiv(target); @@ -1234,7 +1234,7 @@ function mod_predf_op(dossier_id, od_id) add_div(div); - var qs = "gDossier=" + dossier_id + '&op=mod_predf&id=' + od_id; + var qs = "gDossier=" + dossier_id + '&op=mod_predf&id=' + od_id+'&ledger_id='+p_ledger; var action = new Ajax.Request('ajax_misc.php', { diff --git a/include/ajax/ajax_anc_search.php b/include/ajax/ajax_anc_search.php index c8364d740..85d46b58b 100644 --- a/include/ajax/ajax_anc_search.php +++ b/include/ajax/ajax_anc_search.php @@ -71,7 +71,7 @@ if ( isset($_REQUEST['go'])) $plabel=$http->request("plabel"); $sql="select po_name , po_description from poste_analytique ". "where pa_id=$1 and ". - " (po_name ~* $2 or po_description ~* $3) order by po_name"; + " (po_name ilike '%'||$2||'%' or po_description ilike '%'|| $3||'%') order by po_name"; $array=$cn->get_array($sql,array($c2,$plabel,$plabel)); if (empty($array) == true) diff --git a/include/ajax/ajax_auto_anc_card.php b/include/ajax/ajax_auto_anc_card.php index a04732662..aa4622cbc 100644 --- a/include/ajax/ajax_auto_anc_card.php +++ b/include/ajax/ajax_auto_anc_card.php @@ -13,12 +13,22 @@ $cn=Dossier::connect(); if ( isset($_REQUEST['pa_id']) ) { - $res=$cn->exec_sql("select po_name,po_description from poste_analytique where pa_id=$1 and (po_description ~* $2 or po_name ~* $3) order by po_id limit 12", + $res=$cn->exec_sql("select po_name,po_description + from poste_analytique + where + pa_id=$1 + and (po_description ilike '%'|| $2||'%' or po_name ilike '%'|| $3 ||'%') + order by po_id limit 12", array($_REQUEST['pa_id'],$_POST['anccard'],$_POST['anccard'])); } else { - $res=$cn->exec_sql("select po_name,po_description from poste_analytique where po_description ~* $1 or po_name ~* $2 order by po_id limit 12 ", + $res=$cn->exec_sql("select po_name,po_description + from poste_analytique + where + po_description ilike '%'|| $1 ||'%' + or po_name ilike '%'|| $2||'%' + order by po_id limit 12 ", array($_POST['anccard'],$_POST['anccard'])); } $nb=Database::num_row($res); diff --git a/include/class/contact.class.php b/include/class/contact.class.php index 389074c6b..4bd785c17 100644 --- a/include/class/contact.class.php +++ b/include/class/contact.class.php @@ -71,7 +71,7 @@ class contact extends Fiche $search=" and f_id in (select f_id from fiche_Detail where - ad_id=1 and ad_value ~* '$p_search') "; + ad_id=1 and ad_value ilike '%$p_search%') "; } // Get The result Array $step_contact=$this->get_by_category($offset,$search.$extra_sql.$p_sql); diff --git a/include/class/dossier.class.php b/include/class/dossier.class.php index 1f62b042b..25e04259b 100644 --- a/include/class/dossier.class.php +++ b/include/class/dossier.class.php @@ -80,8 +80,8 @@ class Dossier $l_sql="select *, 'W' as priv_priv " ."from ac_dossier " ."where " - ."dos_name ~* $2 " - ."or dos_description ~* $2 " + ."dos_name ilike '%'|| $2 ||'%'" + ."or dos_description ilike '%'|| $2 || '%' " ."ORDER BY dos_name $str_limit "; $a_row=$cn->get_array($l_sql, $p_text); return $a_row; @@ -93,7 +93,7 @@ class Dossier natural join ac_users where use_login=$1 - and ( dos_name ~* $2 or dos_description ~* $2) + and ( dos_name ilike '%'|| $2 || '%' or dos_description ilike '%'|| $2|| '%' ) order by dos_name $str_limit @@ -104,10 +104,10 @@ class Dossier } else if ($p_type=='X') { - $l_sql=' select * from ac_dossier where dos_id not in + $l_sql=" select * from ac_dossier where dos_id not in (select dos_id from jnt_use_dos where use_id=$1) - and ( dos_name ~* $2 or dos_description ~* $2) - order by dos_name '.$str_limit; + and ( dos_name ilike '%'|| $2|| '%' or dos_description ilike '%'|| $2 || '%') + order by dos_name ".$str_limit; $a_row=$cn->get_array($l_sql, array($p_login, $p_text)); return $a_row; } diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php index 565612c87..a6a8e214a 100644 --- a/include/class/fiche.class.php +++ b/include/class/fiche.class.php @@ -262,7 +262,7 @@ class Fiche { $a=sql_string($p_search); $sql="select * from vw_fiche_attr where frd_id=".$p_frd_id. - " and vw_name ~* '$p_search'"; + " and vw_name ilike '%$p_search%'"; } $Ret=$this->cn->exec_sql($sql.$p_sql); @@ -1776,7 +1776,7 @@ class Fiche $search.=" and f_id in (select distinct f_id from fiche_detail where - ad_id in (1,32,30,23,18,13) and ad_value ~* '$p_search')"; + ad_id in (1,32,30,23,18,13) and ad_value ilike '%$p_search%')"; } // Get The result Array $step_tiers=$this->get_by_category($offset,$search.$filter_amount,'name'); diff --git a/include/class/follow_up.class.php b/include/class/follow_up.class.php index 64f86c9cb..48ad1e2ea 100644 --- a/include/class/follow_up.class.php +++ b/include/class/follow_up.class.php @@ -1322,9 +1322,9 @@ class Follow_Up if (isset($_REQUEST['action_query'])) { // if a query is request build the sql stmt - $action_query="and (ag_title ~* '".sql_string($_REQUEST['action_query'])."' ". + $action_query="and (ag_title ilike '%".sql_string($_REQUEST['action_query'])."%' ". "or ag_ref ='".trim(sql_string($_REQUEST['action_query'])). - "' or ag_id in (select ag_id from action_gestion_comment where agc_comment ~* '".trim(sql_string($_REQUEST['action_query']))."')". + "' or ag_id in (select ag_id from action_gestion_comment where agc_comment ilike '%".trim(sql_string($_REQUEST['action_query']))."%')". ")"; } diff --git a/include/class/user.class.php b/include/class/user.class.php index f48f79405..23051d0f7 100644 --- a/include/class/user.class.php +++ b/include/class/user.class.php @@ -1050,20 +1050,24 @@ class User { // show only available folders // if user is not an admin - $Res = $cn->exec_sql("select distinct dos_id,dos_name,dos_description + $Res = $cn->exec_sql("select + distinct dos_id,dos_name,dos_description from ac_users - natural join jnt_use_dos - natural join ac_dossier + natural join jnt_use_dos + natural join ac_dossier where - use_login= $1 - and use_active = 1 - and ( dos_name ~* $2 or dos_description ~* $2 ) + use_login= $1 + and use_active = 1 + and ( dos_name ilike '%' || $2 || '%' or dos_description ilike '%' || $2 || '%' ) order by dos_name", array($this->login, $p_filter)); } else { - $Res = $cn->exec_sql("select distinct dos_id,dos_name,dos_description from ac_dossier - where dos_name ~* $1 or dos_description ~* $1 order by dos_name", array($p_filter)); + $Res = $cn->exec_sql("select + distinct dos_id,dos_name,dos_description from ac_dossier + where + dos_name ilike '%' || $1|| '%' or dos_description ilike '%' || $1 || '%' + order by dos_name", array($p_filter)); } require_once NOALYSS_INCLUDE.'/class/database.class.php';