diff --git a/include/ajax/ajax_add_concerned_card.php b/include/ajax/ajax_add_concerned_card.php index 6b0d61d15..1f9f97286 100644 --- a/include/ajax/ajax_add_concerned_card.php +++ b/include/ajax/ajax_add_concerned_card.php @@ -72,6 +72,12 @@ $r.=HtmlInput::submit('fs', _('Recherche'), "", "smallbutton"); $r.=''; $r.=dossier::hidden().HtmlInput::hidden('op2', 'add_concerned_card'); $r.=HtmlInput::request_to_hidden(array('ag_id')); +$inactive=$http->get("inactive_card","string",0); +if ($inactive=="undefined" || $inactive == "") $inactive=0; +$is=new InputSwitch("inactive_card",$inactive); +$is->value=$inactive; +$r.=_("Toutes les fiches").$is->input(); + $r.=''; @@ -79,6 +85,7 @@ $query=$http->get("query", "string",""); $sql_array['query']=$query; $sql_array['typecard']='all'; $sql_array['search_in']=$select->selected; +$sql_array['inactive_card']=$inactive; $fiche=new Card_Multiple($cn); /* Build the SQL and show result */ diff --git a/include/class/card_multiple.class.php b/include/class/card_multiple.class.php index e03a185a0..b4094851b 100644 --- a/include/class/card_multiple.class.php +++ b/include/class/card_multiple.class.php @@ -31,41 +31,68 @@ class Card_Multiple $this->sql="select f_id,quick_code,vw_name,accounting,vw_first_name,vw_description from vw_fiche_attr "; } - + /** + * + * @param type $sql_array + * @return type + */ function build_sql($sql_array) { $cn=Dossier::connect(); + $filter=""; + if ( $sql_array["inactive_card"]==0) { + $filter=" and ".$this->filter_enable_card(); + } $query=sql_string($sql_array['query']); if ( $sql_array['search_in'] == "-1") { $string_sql=$this->sql." where - vw_name ilike '%$query%' - or quick_code ilike '%$query%' + (vw_name ilike '%$query%' + or quick_code ilike '%$query%') + ".$filter." order by vw_name limit ".MAX_CARD_SEARCH; } else { $string_sql=sprintf($this->sql." where f_id in (select f_id from fiche_detail where - ad_id = '%s' and ad_value ilike '%%%s%%') " - , sql_string($sql_array["search_in"]),$query); + ad_id = '%s' and ad_value ilike '%%%s%%') and %s" + , sql_string($sql_array["search_in"]),$query,$filter); } return $string_sql; } - + /** + * + * @param type $sql_array + * @return type + */ function count_sql($sql_array) { $cn=Dossier::connect(); $query=sql_string($sql_array['query']); + $filter=""; + if ( $sql_array["inactive_card"]==0) { + $filter="and ".$this->filter_enable_card(); + } $string_sql="select count(*) from vw_fiche_attr where - vw_name ilike '%$query%' - or quick_code ilike '%$query%'"; + ( vw_name ilike '%$query%' + or quick_code ilike '%$query%') + ".$filter; - return $cn->get_value($string_sql); ; + return $cn->get_value($string_sql); + } + /** + * + * @return string + */ + private function filter_enable_card() + { + $filter_enable_card=" f_id in (select f_id from fiche_detail where ad_value = '1' and ad_id=54) "; + return $filter_enable_card; } /** *