fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [9207] property: filter on custom fields


From: Sigurd Nes
Subject: [Fmsystem-commits] [9207] property: filter on custom fields
Date: Mon, 23 Apr 2012 11:36:03 +0000

Revision: 9207
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9207
Author:   sigurdne
Date:     2012-04-23 11:36:03 +0000 (Mon, 23 Apr 2012)
Log Message:
-----------
property: filter on custom fields

Modified Paths:
--------------
    trunk/property/inc/class.soentity.inc.php
    trunk/property/inc/class.sos_agreement.inc.php

Modified: trunk/property/inc/class.soentity.inc.php
===================================================================
--- trunk/property/inc/class.soentity.inc.php   2012-04-23 06:21:38 UTC (rev 
9206)
+++ trunk/property/inc/class.soentity.inc.php   2012-04-23 11:36:03 UTC (rev 
9207)
@@ -55,6 +55,7 @@
                        $this->bocommon         = 
CreateObject('property.bocommon');
                        $this->custom           = 
createObject('property.custom_fields');
                        $this->db           = & $GLOBALS['phpgw']->db;
+                       $this->db2          = clone($this->db);
                        $this->join                     = & $this->db->join;
                        $this->left_join        = & $this->db->left_join;
                        $this->like                     = & $this->db->like;
@@ -1257,23 +1258,42 @@
                                                        case 'CH':
                                                                
if(!$criteria_id)
                                                                {
+                                                                       // from 
filter
                                                                        
$_querymethod[]= "$entity_table." . $this->db->f('column_name') . " 
{$this->like} '%,{$query},%'";
                                                                        
$__querymethod = array(); // remove block
+
+                                                                       // from 
text-search
+                                                                       
$_filter_choise = "WHERE (phpgw_cust_choice.location_id =" . 
(int)$this->db->f('location_id')
+                                                                               
." AND phpgw_cust_choice.attrib_id =" . (int)$this->db->f('id')
+                                                                               
." AND phpgw_cust_choice.value {$this->like} '%{$query}%')";
+
+                                                                       
$this->db2->query("SELECT phpgw_cust_choice.id FROM phpgw_cust_choice 
{$_filter_choise}",__LINE__,__FILE__);
+                                                                       while 
($this->db2->next_record())
+                                                                       {
+                                                                               
$_querymethod[]= "$entity_table." . $this->db->f('column_name') . " 
{$this->like} '%,". $this->db2->f('id') . ",%'";
+                                                                       }
                                                                }
                                                                break;
                                                        case 'R':
                                                        case 'LB':
                                                                
if(!$criteria_id)
                                                                {
-                                                                       
if(!$_joinmethod_datatype_custom)//only join once
+                                                                       
$_filter_choise = "WHERE (phpgw_cust_choice.location_id =" . 
(int)$this->db->f('location_id')
+                                                                               
." AND phpgw_cust_choice.attrib_id =" . (int)$this->db->f('id')
+                                                                               
." AND phpgw_cust_choice.value {$this->like} '%{$query}%')";
+
+                                                                       
$this->db2->query("SELECT phpgw_cust_choice.id FROM phpgw_cust_choice 
{$_filter_choise}",__LINE__,__FILE__);
+                                                                       
$__filter_choise = array();
+                                                                       while 
($this->db2->next_record())
                                                                        {
-                                                                               
$_joinmethod_datatype_custom[] = "{$this->join} phpgw_cust_choice ON 
phpgw_cust_choice.location_id =" . (int)$this->db->f('location_id');
+                                                                               
$__filter_choise[] = $this->db2->f('id');
                                                                        }
+
+                                                                       
if($__filter_choise)
+                                                                       {
+                                                                               
$_querymethod[]= "$entity_table." . $this->db->f('column_name') . ' IN (' . 
implode(',', $__filter_choise) . ')';
+                                                                       }
        
-                                                                       
$_querymethod[]= "(phpgw_cust_choice.location_id =" . 
(int)$this->db->f('location_id')
-                                                                               
." AND phpgw_cust_choice.attrib_id =" . (int)$this->db->f('id')
-                                                                               
." AND phpgw_cust_choice.value {$this->like} '%{$query}%')";
-       
                                                                        
$__querymethod = array(); // remove block
                                                                }
                                                                break;

Modified: trunk/property/inc/class.sos_agreement.inc.php
===================================================================
--- trunk/property/inc/class.sos_agreement.inc.php      2012-04-23 06:21:38 UTC 
(rev 9206)
+++ trunk/property/inc/class.sos_agreement.inc.php      2012-04-23 11:36:03 UTC 
(rev 9207)
@@ -409,23 +409,42 @@
                                                        case 'CH':
                                                                
if(!$criteria_id)
                                                                {
+                                                                       // from 
filter
                                                                        
$_querymethod[]= "$entity_table." . $this->db->f('column_name') . " 
{$this->like} '%,{$query},%'";
                                                                        
$__querymethod = array(); // remove block
+
+                                                                       // from 
text-search
+                                                                       
$_filter_choise = "WHERE (phpgw_cust_choice.location_id =" . 
(int)$this->db->f('location_id')
+                                                                               
." AND phpgw_cust_choice.attrib_id =" . (int)$this->db->f('id')
+                                                                               
." AND phpgw_cust_choice.value {$this->like} '%{$query}%')";
+
+                                                                       
$this->db2->query("SELECT phpgw_cust_choice.id FROM phpgw_cust_choice 
{$_filter_choise}",__LINE__,__FILE__);
+                                                                       while 
($this->db2->next_record())
+                                                                       {
+                                                                               
$_querymethod[]= "$entity_table." . $this->db->f('column_name') . " 
{$this->like} '%,". $this->db2->f('id') . ",%'";
+                                                                       }
                                                                }
                                                                break;
                                                        case 'R':
                                                        case 'LB':
                                                                
if(!$criteria_id)
                                                                {
-                                                                       
if(!$_joinmethod_datatype_custom)//only join once
+                                                                       
$_filter_choise = "WHERE (phpgw_cust_choice.location_id =" . 
(int)$this->db->f('location_id')
+                                                                               
." AND phpgw_cust_choice.attrib_id =" . (int)$this->db->f('id')
+                                                                               
." AND phpgw_cust_choice.value {$this->like} '%{$query}%')";
+
+                                                                       
$this->db2->query("SELECT phpgw_cust_choice.id FROM phpgw_cust_choice 
{$_filter_choise}",__LINE__,__FILE__);
+                                                                       
$__filter_choise = array();
+                                                                       while 
($this->db2->next_record())
                                                                        {
-                                                                               
$_joinmethod_datatype_custom[] = "{$this->join} phpgw_cust_choice ON 
phpgw_cust_choice.location_id =" . (int)$this->db->f('location_id');
+                                                                               
$__filter_choise[] = $this->db2->f('id');
                                                                        }
+
+                                                                       
if($__filter_choise)
+                                                                       {
+                                                                               
$_querymethod[]= "$entity_table." . $this->db->f('column_name') . ' IN (' . 
implode(',', $__filter_choise) . ')';
+                                                                       }
        
-                                                                       
$_querymethod[]= "(phpgw_cust_choice.location_id =" . 
(int)$this->db->f('location_id')
-                                                                               
." AND phpgw_cust_choice.attrib_id =" . (int)$this->db->f('id')
-                                                                               
." AND phpgw_cust_choice.value {$this->like} '%{$query}%')";
-       
                                                                        
$__querymethod = array(); // remove block
                                                                }
                                                                break;




reply via email to

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