Results 1 to 1 of 1

Thread: Adding new query rules for dates?

  1. #1
    bhartin is offline Junior Member
    Join Date
    Jul 2008
    Posts
    2

    Default Adding new query rules for dates?

    I'm currently working on a migration from MSCRM into SugarCRM Pro, and ran into an issue creating a report. I want to be able to query a date field to return only results older than 3 days from the current date.

    (a) Is there an easy method to do this?

    (b) If I write a new query function, how should I go about it in a portable (upgrade-proof) manner?

    For (b), I did track down the file include/generic/SugarWidgets/SugarWidgetFielddate.php (and *datetime.php), which contains the actual functions used for date fields, such as function queryFilterTP_last_7_days. I'd have to modify a few other files to add it to the drop down, but I also need to find how these are called and associated with the dropdown. I also need to know how to do this 'correctly' as a customization.

    Thanks for any direction anyone can provide!

    Edit:
    This looks like editing (SugarPro 5.2.0a):

    modules/Reports/templates/templates_modules_def_js.php - Add this around line 406:
    Code:
    qualifiers[qualifiers.length] = {name:'tp_before_3_days_ago',value:'<?php echo $mod_strings['LBL_BEFORE_3_DAYS_AGO]; ?>'};
    modules/Reports/language/en_us.lang.php - Add this around line 271:
    Code:
        'LBL_BEFORE_3_DAYS_AGO'=>'Before 3 Days Ago',
    include/generic/SugarWidgets/SugarWidgetFielddatetime.php - Add around line 405:
    Code:
            function queryFilterBefore(& $layout_def) { // Taken from queryFilterBefore and queryFilterYesterday
                    global $timedate;
    
                   $begin_timestamp = time() - (3*86400); 
                   $begin = gmdate($GLOBALS['timedate']->get_db_date_time_format(), $begin_timestamp);
                   $begin = $timedate->handle_offset($begin, $timedate->get_db_date_time_format(), true,                $this->assigned_user);
    
              return $this->_get_column_select($layout_def)."<'".$this->reporter->db->quote($begin)."'\n";
    }
    Same file, add around line 839:
    Code:
    'TP_before_3_days_ago'  => $home_mode_strings['LBL_BEFORE_3_DAYS_AGO'],
    (All of the above is untested, just what I've documented and hacked together so far. The problem is I don't want to actually edit any of the above core files, but rather put them in a more portable place.)
    Last edited by bhartin; 2009-03-05 at 08:22 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Crm rules read about it
    By zerocost in forum General Discussion
    Replies: 5
    Last Post: 2011-12-06, 10:49 AM
  2. How to set up due dates based on business dates
    By sugar7478 in forum Developer Help
    Replies: 0
    Last Post: 2009-02-27, 02:27 PM
  3. Replies: 2
    Last Post: 2009-02-05, 10:35 PM
  4. Replies: 0
    Last Post: 2009-01-22, 05:58 PM
  5. Rules and Rights
    By MRO in forum Help
    Replies: 2
    Last Post: 2004-08-30, 11:56 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
  •