Multiple contact Search on selected attribute
This commit is contained in:
parent
5f61996d4a
commit
7aadc12a6d
4 changed files with 28 additions and 15 deletions
|
|
@ -183,6 +183,7 @@ function action_concerned_search_card(obj)
|
|||
var dossier = 0;
|
||||
var inp="";
|
||||
var ag_id=0;
|
||||
var search_in=-1;
|
||||
|
||||
if (obj.dossier) {
|
||||
dossier = obj.dossier; /* From the button */
|
||||
|
|
@ -204,6 +205,9 @@ function action_concerned_search_card(obj)
|
|||
if (obj.elements['ag_id']) {
|
||||
ag_id = obj.elements['ag_id'].value;
|
||||
}
|
||||
if (obj.elements['search_in']) {
|
||||
search_in = obj.elements['search_in'].value;
|
||||
}
|
||||
}
|
||||
if (dossier == 0) {
|
||||
throw "obj.dossier not found";
|
||||
|
|
@ -218,7 +222,8 @@ function action_concerned_search_card(obj)
|
|||
'ctl' : 'unused',
|
||||
'ag_id' : ag_id,
|
||||
'op':'card',
|
||||
'accvis':0
|
||||
'accvis':0,
|
||||
'search_in':search_in
|
||||
});
|
||||
|
||||
waiting_box();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php,
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
|
|
@ -65,7 +65,7 @@ $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 order by 2 ",1);
|
||||
$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");
|
||||
|
|
@ -78,6 +78,7 @@ $r.='</form>';
|
|||
$query=$http->get("query", "string","");
|
||||
$sql_array['query']=$query;
|
||||
$sql_array['typecard']='all';
|
||||
$sql_array['search_in']=$select->selected;
|
||||
|
||||
$fiche=new Card_Multiple($cn);
|
||||
/* Build the SQL and show result */
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class Card_Attribut_MTable extends Manage_Table_SQL
|
|||
function __construct(\Data_SQL $p_table)
|
||||
{
|
||||
parent::__construct($p_table);
|
||||
$this->set_property_visible("ad_id", FALSE);
|
||||
$this->set_property_visible("ad_id", TRUE);
|
||||
$this->set_property_updatable("ad_id", FALSE);
|
||||
$this->set_col_label("ad_text", _("Nom"));
|
||||
$this->set_col_label("ad_type", _("Type"));
|
||||
|
|
|
|||
|
|
@ -25,25 +25,31 @@
|
|||
*/
|
||||
class Card_Multiple
|
||||
{
|
||||
|
||||
private $sql ; //!< SQL with the right column name
|
||||
function __construct()
|
||||
{
|
||||
|
||||
$this->sql="select f_id,quick_code,vw_name,accounting,vw_first_name,vw_description
|
||||
from vw_fiche_attr ";
|
||||
}
|
||||
|
||||
function build_sql($sql_array)
|
||||
{
|
||||
$cn=Dossier::connect();
|
||||
$query=sql_string($sql_array['query']);
|
||||
|
||||
$string_sql="select *
|
||||
from vw_fiche_attr
|
||||
where
|
||||
vw_name ilike '%$query%'
|
||||
or quick_code ilike '%$query%'
|
||||
order by vw_name
|
||||
limit
|
||||
".MAX_CARD_SEARCH;
|
||||
if ( $sql_array['search_in'] == "-1")
|
||||
{
|
||||
$string_sql=$this->sql."
|
||||
where
|
||||
vw_name ilike '%$query%'
|
||||
or quick_code ilike '%$query%'
|
||||
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);
|
||||
}
|
||||
return $string_sql;
|
||||
}
|
||||
|
||||
|
|
@ -83,6 +89,7 @@ class Card_Multiple
|
|||
if ( ! $g_user->can_read_action($ag_id)) {
|
||||
throw new Exception (_("CMCDO01"."Security"));
|
||||
}
|
||||
// First select the option
|
||||
$sql="select
|
||||
cor.cor_id,
|
||||
cor.cor_label,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue