How to create custom date filter

I'm wondering if it's possible to create a custom date filter.  As you see in the screenshot date filters come with several options.  I would like to add a couple options such as "Last Month" or "Last xx days" as premade options.  Has anyone done this before?

Thanks,

Tom Noel

Parents
  • We have done it recently.

    Initially you need to add such options at custom/clients/base/filters/operators/operators.php.

    At last you have to extend the TimeDate class:

    Create file custom/Extension/application/Ext/Utils/somefile.php

    require_once 'custom/include/CustomTimeDate.php';

    $customTimeDate = new CustomTimeDate();

    Create file custon;include/CustomTimeDate.php

    class CustomTimeDate extends TimeDate
    {
     public function __construct(User $user = null)
     {
     parent::__construct($user);
     $this->date_expressions['last_60_days'] = ["", "-59 days"];
     $this->date_expressions['last_90_days'] = ["", "-89 days"];
     $this->date_expressions['last_120_days'] = ["", "-119 days"];
     $this->date_expressions['next_60_days'] = ["", "+59 days"];
     $this->date_expressions['next_90_days'] = ["", "+89 days"];

     self::$timedate = $this;
     }
    }

    Run QRR

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Are there any SugarCRM developers who would like to put this solution together in a module loadable package for our 10.2 Enterprise Ondemand instance? 

Reply Children
No Data