Follow Up : multiple card , search by category of card

This commit is contained in:
Dany De Bontridder 2020-10-11 17:58:24 +02:00
parent 30ff1b125c
commit 5ee686eae6
3 changed files with 34 additions and 8 deletions

View file

@ -188,6 +188,7 @@ function action_concerned_search_card(obj)
var ag_id=0;
var search_in=-1;
var inactive_card=0;
var search_cat=-1;
if (obj.dossier) {
dossier = obj.dossier; /* From the button */
@ -212,9 +213,12 @@ function action_concerned_search_card(obj)
if (obj.elements['search_in']) {
search_in = obj.elements['search_in'].value;
}
if ( obj.inactive_card) {
if ( obj.elements['inactive_card']) {
inactive_card=obj.elements['inactive_card'].value;
}
if ( obj.elements['search_cat']) {
search_cat=obj.elements['search_cat'].value;
}
}
if (dossier == 0) {
throw "obj.dossier not found";
@ -231,7 +235,8 @@ function action_concerned_search_card(obj)
'op':'card',
'accvis':0,
'search_in':search_in,
'inactive_card':inactive_card
'inactive_card':inactive_card,
'search_cat':search_cat
});
waiting_box();

View file

@ -63,21 +63,31 @@ $q->value=(isset($query))?$query:'';
$r.='<span style="margin-left:50px">';
$r.=_('Fiche contenant').Icon_Action::infobulle(19);
$r.=$q->input();
// where to search
$select=new ISelect("search_in");
$select->value=$cn->make_array("select ad_id, ad_text from attr_def where ad_search_followup = 1 order by 2 ",1);
$select->selected=$http->get("search_in","string","");
$r.=_("limité aux champs ").$select->input();
$r.=HtmlInput::submit('fs', _('Recherche'), "", "smallbutton");
$r.='</span>';
$r.=dossier::hidden().HtmlInput::hidden('op2', 'add_concerned_card');
$r.=HtmlInput::request_to_hidden(array('ag_id'));
// Search by category
$sel_Category=new ISelect("search_cat");
$sel_Category->value=$cn->make_array("select fd_id,fd_label from fiche_def order by 2",1);
$sel_Category->set_value($http->request("search_cat","string","-1"));
$r.=_("Catégorie")." ".$sel_Category->input();
// search also inactive card
$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.=_("Fiches inactives").$is->input();
$r.=HtmlInput::submit('fs', _('Recherche'), "", "smallbutton");
$r.='</form>';
@ -86,6 +96,7 @@ $sql_array['query']=$query;
$sql_array['typecard']='all';
$sql_array['search_in']=$select->selected;
$sql_array['inactive_card']=$inactive;
$sql_array['search_cat']=$sel_Category->selected;
$fiche=new Card_Multiple($cn);
/* Build the SQL and show result */

View file

@ -44,6 +44,11 @@ class Card_Multiple
if ( $sql_array["inactive_card"]==0) {
$filter=" and ".$this->filter_enable_card();
}
// By Cat of card
$sql_cat="";
if ( $sql_array['search_cat']!=-1) {
$sql_cat=' and fd_id = '.sql_string($sql_array['search_cat']);
}
$query=sql_string($sql_array['query']);
if ( $sql_array['search_in'] == "-1")
{
@ -51,14 +56,14 @@ class Card_Multiple
where
(vw_name ilike '%$query%'
or quick_code ilike '%$query%')
".$filter."
".$filter.$sql_cat."
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%%') %s"
, sql_string($sql_array["search_in"]),$query,$filter);
ad_id = '%s' and ad_value ilike '%%%s%%') %s %s"
, sql_string($sql_array["search_in"]),$query,$filter,$sql_cat);
}
return $string_sql;
}
@ -75,13 +80,18 @@ class Card_Multiple
if ( $sql_array["inactive_card"]==0) {
$filter="and ".$this->filter_enable_card();
}
// By Cat of card
$sql_cat="";
if ( $sql_array['search_cat']!=-1) {
$sql_cat=' and fd_id = '.sql_string($sql_array['search_cat']);
}
$string_sql="select count(*)
from vw_fiche_attr
where
( vw_name ilike '%$query%'
or quick_code ilike '%$query%')
".$filter;
".$filter.$sql_cat;
return $cn->get_value($string_sql);