Duration of Tasks doesn't appear correct in Calendar

Hi, I have the following problem with the tasks in the calendar:
when I add a task it is displayed into the calendar but if, for exemple, I set Date start= 07/11/2019 09:00 and Date end=07/11/2019 14:00 in the calendar the task isn’t until the 14:00 but before it.
I attach an exemple

The yellows one are from meeting module, the purple one is from task module and, as marked in red, it is not correct.
What should I do to fix this? I found this post but it failed to help me

My version of SuiteCRM is 7.11.7

Hi,
I don’t think so you are referring to the correct task in the calendar as there should be 5 HOURS interval between the TIME although they are in any Time Zone. as from 9am to 2PM we have 5 hours of difference. Yet in calendar red highlight task has only “2.5” hours interval.
Can you please also share the screenshot of the task as well?

The exemple before the sreenshot is not the same task in the screenshot.
The task’s screenshot is start at 10:00am and should be end at 12:30pm but in the calendar it ends at 12:00pm (it starts sorrectly)

I am not pretty much clear. If you show it to me via Skype i can help.

sohaib.majeed44

The problem is that the task in the screenhot has a duration of 2:30 hour but in the calendar is cover only 2 hour and not the entire duration of the task.

Please try reproducing this in the live demo

demo.suiteondemand.com (user:will, pass: will)

and if it’s broken there, please open an issue on GitHub for this, unless there is one there already. Thanks

https://github.com/salesagility/SuiteCRM/issues/

The demo’s behavior is not the same of mine:
in the demo the task’s block starts at the time in the “Due Date” field and it ends after 2 hours from the time in the “Due Date” field (demo’s task starts at 11/11/2019 08:00 and ends 11/11/2049 16:00 but in the calendar the relative block starts 11/11/2019 16:00 and ends at 11/11/2019 18:00)

in my application the task’s block starts correctly but it ends after 2 hours from the time in the “Start Date” field (my task starts 7/11/2019 10:00 and ends 7/11/2019 16:30 but in the calendar the relative block starts 7/11/2019 10:00 but ends at 7/11/2019 12:00)

I can’t figure it out… :huh:

Did you try playing with different timezones in the user’s profile? I am guessing that this could be the origin of the bug…

No the timezones of my server and my user profile are the same:
the timezone of the server is

the timezone of my user profile is

After deep investigation, i found that, the task module dont have duration hrs and mins field, so i calculated the duration hrs and mins.

SuiteCRM\modules\Calendar\CalendarActivity.php

/**
     * CalendarActivity constructor.
     * @param $args
     */
    public function __construct($args)        {
        // if we've passed in an array, then this is a free/busy slot
        // and does not have a sugarbean associated to it
        global $timedate;

        if (is_array($args)) {
            $this->start_time = clone $args[0];
            $this->end_time = clone $args[1];
            $this->sugar_bean = null;
            $timedate->tzGMT($this->start_time);
            $timedate->tzGMT($this->end_time);

            return;
        }

        // else do regular constructor..

        $sugar_bean = $args;
        $this->sugar_bean = $sugar_bean;


        if ($sugar_bean->object_name === 'Task') {
            if (!empty($this->sugar_bean->date_start)) {
                $this->start_time = $timedate->fromUser($this->sugar_bean->date_start);
            } else {
                $this->start_time = $timedate->fromUser($this->sugar_bean->date_due);
            }
            if (empty($this->start_time)) {
                return;
            }
            $this->end_time = $timedate->fromUser($this->sugar_bean->date_due);
            
            //VJ - Script to fix task module duration issue - starts
            $start_time = strtotime($this->start_time);  
            $end_time = strtotime($this->end_time);
            $hours = floor(($end_time - $start_time) / (60*60));
            $mins = floor((($end_time - $start_time) - ($hours * (60*60))) / (60));
            $this->sugar_bean->duration_hours = $hours;
            $this->sugar_bean->duration_minutes = $mins;
            //VJ - Script to fix task module duration issue - ends

        } else {
            $this->start_time = $timedate->fromUser($this->sugar_bean->date_start);
            if (empty($this->start_time)) {
                return;
            }
            $hours = $this->sugar_bean->duration_hours;
            if (empty($hours)) {
                $hours = 0;
            }
            $mins = $this->sugar_bean->duration_minutes;
            if (empty($mins)) {
                $mins = 0;
            }
            $this->end_time = $this->start_time->get("+$hours hours $mins minutes");
        }
        // Convert it back to database time so we can properly manage it for getting the proper start and end dates
        $timedate->tzGMT($this->start_time);
        $timedate->tzGMT($this->end_time);
    }

Hope, it will resolve the issue.

Hi all,

Is this fix included in the most recent version of SuiteCRM? I’m guessing not because I still see the same issue as described above so that leads to my second question: Is there any plan to fix this issue in a future release?

Thanks,
Tim.

In order for this to be considered, there needs to be an Issue open for it on GitHub, and then a Pull Request with the fix.

As you probably know, the Product Team is overwhelmed with hundreds of these. So it’s really important that the Community does its part - in this case, providing the Issue and the fix in the proper places.

Thanks!

Hi,

Is this upgrade proof?

As it is, no.

But it probably could be made iupgrade-safe by doing the method override from custom dir.