CRM Open Source Business & Social CRM Software

Results 1 to 3 of 3

Thread: How to search for opportunity amounts with <, > and = operator (SugarCRM 5.0.0i)

  1. #1
    kuske's Avatar
    kuske is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Germany
    Posts
    2,587

    Default How to search for opportunity amounts with <, > and = operator (SugarCRM 5.0.0i)

    SugarCRM searches in opportunities for amounts with a standard search-like-clause.
    So if you enter 100000 in the Advanced Search Amount field you will get a where clause
    Code:
     opportunities.amount like '100000%'
    If you want to search for 100000 exactly or for more or less than 100000 you can do this by a little patch in module /include/MVC/View/views/view-list.php.

    Here clause manipulation can be added before the line
    Code:
     
    if (count($where_clauses) > 0 )$where = '('. implode(' ) AND ( ', $where_clauses) . ')';
    E.g. you can add the following code for opportunities before the above printed line:
    Code:
     
    if ( $this->seed->module_dir == "Opportunities" ) 
    { 
    foreach($where_clauses as $dakey => $dawert) 
    {
    	 if(substr($dawert,0,27)=="opportunities.amount like '") 
    	 {
    		 $datest= substr($dawert,27,1);
    		 $daop = "%";
    		 if ($datest == ">") $daop=">";
    		 if ($datest == "<") $daop="<";
    		 if ($datest == "=") $daop="=";
     
    		 if ($daop != "%")
    		 {
    			// remove test-char
    			$dawert = str_replace($daop,"",$dawert);
    			// remove %
    			$dawert = str_replace("%","",$dawert);
    			// replace like by new operation
    			$dawert = str_replace("like",$daop,$dawert);
    			// replace original where clause
    			$where_clauses[$dakey] = $dawert;
    		 }
    	 }
    }
    }
    Now you can enter “100000” and the where clause will be
    Code:
     opportunities.amount like '100000%'
    If you enter “>100000” the where clause will be
    Code:
     opportunities.amount > '100000'
    The corresponding applies to “<1000000” and “=100000”.
    Last edited by kuske; 2008-11-27 at 02:49 PM.
    Harald Kuske
    Pre-Sales Engineer DACH
    SUGARCRM Deutschland GmbH
    Crusiusstrasse 1, Munich, Germany 80538
    Email:
    hkuske@sugarcrm.com
    Home:
    http://www.sugarcrm.com

  2. #2
    vishwasrao's Avatar
    vishwasrao is offline A Prolific Poster
    Join Date
    Sep 2008
    Location
    Pune,Maharashtra,India
    Posts
    385

    Smile Re: How to search for opportunity amounts with <, > and = operator (SugarCRM 5.0.0i)

    Hi kuske,
    can we use enhanced search instead of changing code.
    Vishwasrao Salunkhe
    vishwasrao.salunkhe@gmail.com
    Fan Of Sachin Tendulkar
    Operating System :- Windows XP
    PHP Version:- 5.3
    Apache :-2.2.11
    MYSQL :-5.1.36

  3. #3
    kuske's Avatar
    kuske is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Germany
    Posts
    2,587

    Default Re: How to search for opportunity amounts with <, > and = operator (SugarCRM 5.0.0i)

    Yes you can...
    Harald Kuske
    Pre-Sales Engineer DACH
    SUGARCRM Deutschland GmbH
    Crusiusstrasse 1, Munich, Germany 80538
    Email:
    hkuske@sugarcrm.com
    Home:
    http://www.sugarcrm.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •