noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 71/119: Search on active card for Contact Mul


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 71/119: Search on active card for Contact Multiple
Date: Mon, 26 Oct 2020 18:27:25 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 67ce2beee64fffa412bd874a80279f2b1c7d5b73
Author: Dany De Bontridder <danydb@noalyss.eu>
AuthorDate: Sat Oct 10 19:49:33 2020 +0200

    Search on active card for Contact Multiple
---
 include/ajax/ajax_add_concerned_card.php |  7 +++++
 include/class/card_multiple.class.php    | 45 +++++++++++++++++++++++++-------
 2 files changed, 43 insertions(+), 9 deletions(-)

diff --git a/include/ajax/ajax_add_concerned_card.php 
b/include/ajax/ajax_add_concerned_card.php
index 6b0d61d..1f9f972 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.='</span>';
 $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.='</form>';
 
 
@@ -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 e03a185..b409485 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;
     }
     /**
      * 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]