Results 1 to 6 of 6

Thread: Search by date range

  1. #1
    jkuchta is offline Junior Member
    Join Date
    Jul 2009
    Posts
    4

    Default Search by date range

    Is it possible to search by a date range for the leads module? As far as I can tell it appears the only way to search is based on a specific date.

  2. #2
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Search by date range

    To change by a date range you need to:
    1. Create a new class which extends the default Lead class;
    2. Create a custom controller for Leads and implement the method action_listview;
    3. Inside this method you need to override the attribute $this->bean as an instance of the new class;
    4. Implement into new Lead class the method create_new_list_query to override the array $ret_array according to your needs. This method is defined into data/SugarBean.php
    5. Create an extended vardefs for Leads to add two non-db date fields;
    6. Add these two new fields into searchdefs.php
    7. Modify the create_new_list_query into new Lead class to consider the sql query based on the two fields;

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  3. #3
    christianknoll's Avatar
    christianknoll is offline Sugar Community Member
    Join Date
    Nov 2008
    Location
    Vienna
    Posts
    939

    Default Re: Search by date range

    Alternatively you can use the lucene integration I posted on Sugarforge http://www.sugarforge.org/projects/kinamulucene/ and search for leads (include object_name:Lead in the search and then the resp date field ... the link to the lucene search syntax will tell you how to search for date ranges.

    In addition you can also add any other query you might want in that ...

    ... christian.

    PS: you will only need to make sure that the respective date field get's indexed by the search engine.

    Quote Originally Posted by andopes View Post
    To change by a date range you need to:
    1. Create a new class which extends the default Lead class;
    2. Create a custom controller for Leads and implement the method action_listview;
    3. Inside this method you need to override the attribute $this->bean as an instance of the new class;
    4. Implement into new Lead class the method create_new_list_query to override the array $ret_array according to your needs. This method is defined into data/SugarBean.php
    5. Create an extended vardefs for Leads to add two non-db date fields;
    6. Add these two new fields into searchdefs.php
    7. Modify the create_new_list_query into new Lead class to consider the sql query based on the two fields;

    Cheers

  4. #4
    jkuchta is offline Junior Member
    Join Date
    Jul 2009
    Posts
    4

    Default Re: Search by date range

    Sounds good, thanks for the replies.

  5. #5
    work77 is offline Senior Member
    Join Date
    Aug 2010
    Posts
    84

    Default Re: Search by date range

    I've run into a snag using Andopes's Date Range solution above. Any suggestions?

    http://www.sugarcrm.com/forums/showthread.php?p=237511

  6. #6
    Cedric K is offline Senior Member
    Join Date
    Sep 2010
    Posts
    155

    Default Re: Search by date range

    Quote Originally Posted by work77 View Post
    I've run into a snag using Andopes's Date Range solution above. Any suggestions?

    http://www.sugarcrm.com/forums/showthread.php?p=237511
    Hi,

    I think there is a mistake in the regex. The pattern does not match the WHERE clause for all the situations, according to the order the fields are organized. I could make this customization working by using the following regex. It's working for me in all the situations :

    PHP Code:
     $ret_array['where'] = preg_replace('/\(\s?leads\.create_start_date[^)]+\)/''1'$ret_array['where']);
    $ret_array['where'] = preg_replace('/\(\s?leads\.create_end_date[^)]+\)/''1'$ret_array['where']); 
    Hope this could help help someone in the future.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Exporting Sugar DB within a date range?
    By SKAAA in forum General Discussion
    Replies: 2
    Last Post: 2009-09-01, 02:20 PM
  2. date range
    By mpatwi in forum General Discussion
    Replies: 6
    Last Post: 2009-06-10, 04:29 PM
  3. Date range fields under the advanced search panel
    By mathewp in forum Sugar Developer Website
    Replies: 7
    Last Post: 2009-03-09, 06:35 PM
  4. Date Range for Dashboard
    By LuvDodo in forum General Discussion
    Replies: 4
    Last Post: 2006-03-22, 06:18 PM

Tags for this Thread

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
  •