Custom Module not showing activities correctly in list view

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jcortes0309
    Member
    • Mar 2016
    • 68

    Custom Module not showing activities correctly in list view

    I created a new custom Module and I'm trying to figure out how to show the Overdue and Today's activities in the list view. I reviewed the Task.php file in the SelectManagers folder and pretty much copied it for my module; however for some reason it's showing the Today activities as Overdue. Is there anything I need to change in the code below? I also check my time zone to make sure it's not set up incorrectly. I have also attached pictures showing my issue.


    PHP Code:
    protected function boolFilterActual(&$result)
        {
            $this->filterActual($result);
        }
    
        protected function boolFilterCompleted(&$result)
        {
            $this->filterCompleted($result);
        }
    
        protected function filterActual(&$result)
        {
            $result['whereClause'][] = array(
                'status!=' => ['Completed', 'Canceled', 'Archived']
            );
        }
    
        protected function filterCompleted(&$result)
        {
            $result['whereClause'][] = array(
                'status=' => 'Completed'
            );
        }
        
        protected function filterArchived(&$result)
        {
            $result['whereClause'][] = array(
                'status=' => 'Archived'
            );
        }
        
        protected function filterOverdue(&$result)
        {
            $result['whereClause'][] = [
                $this->convertDateTimeWhere(array(
                    'type' => 'past',
                    'field' => 'dateEnd',
                    'timeZone' => $this->getUserTimeZone()
                )),
                [
                    array(
                        'status!=' => ['Completed', 'Canceled', 'Archived']
                    )
                ]
            ];
        }
        
        protected function filterTodays(&$result)
        {
            $result['whereClause'][] = $this->convertDateTimeWhere(array(
                'type' => 'today',
                'field' => 'dateEnd',
                'timeZone' => $this->getUserTimeZone()
            ));
        }
        
        protected function convertDateTimeWhere($item)
        {
            $result = parent::convertDateTimeWhere($item);
    
            if (empty($result)) {
                return null;
            }
            $field = $item['field'];
    
            if ($field != 'dateStart' && $field != 'dateEnd') {
                return $result;
            }
    
            $fieldDate = $field . 'Date';
    
            $dateItem = array(
                'field' => $fieldDate,
                'type' => $item['type']
            );
            if (!empty($item['value'])) {
                $dateItem['value'] = $item['value'];
            }
    
            $result = array(
                'OR' => array(
                    'AND' => [
                        $result,
                        $fieldDate . '=' => null
                    ],
                    $this->getWherePart($dateItem)
                )
            );
    
            return $result;
        } 
    

  • jcortes0309
    Member
    • Mar 2016
    • 68

    #2
    Well this code started working today. Not sure why as I didn't make any changes, but glad that is working properly.

    Comment

    Working...