Time Tracking

name:
Time Tracking
description:
Track your time spent on objects
version:
2.1.1
release:
2020-11-04
code:
itop-time-tracking
state:
stable
diffusion:
Client Store, iTop Hub

This extension provides a way to track the time spent by the end-users in association with objects in iTop (like Tickets). The user input is done via a Google-like calendar via (provided by FullCalendar JS), either directly as an extra tab on the target object, or via a special page (and its menu “Track my time”).

The module also provides two menus pointing to reports: “My time tracking report”, and “Time tracking report”. The first menu provides a report of the activities of the current user only, while the second takes into account the activities of all users.

The implementation provided by this extension limits the time tracking to User Requests and Incidents tickets.

Features

  • Customized scopes for each time tracking feature
  • Interactive time tracking via a calendar or a stopwatch
  • Configure your calendar settings, activity colors etc..
  • Activity customization per user
  • Daily / weekly / monthly reports with multiple filtering criteria
  • Cumulated bar chart grouped by User or Customer

Revision history

Date Version Description
2020-11-04 1.0.5 Fix installation issue
2020-08-03 2.1.0 * Fix data not being filtered by search on report page
* Add an overview for Time tracker manager in report page
* Add silo for managers in config
* Add configuration for report chart in config
* Align chart color with time tracking colors
2019-09-18 2.0.0 Release 2 with a complete redesign and features set
2018-08-02 1.0.2 Compatibility with iTop 2.5
2014-08-29 1.0.0 First version

Limitations

Requirements

Installation

Use the Standard installation process for this extension.

If you were using the previous version 1.0 of this extension you have to follow the migration procedure describe below

The migration procedure consists in executing the SQL request below in order to migrate the former data structure to the new one. You have to execute those queries before tracking time

CREATE TABLE activity_legacy (
id INT(11) AUTO_INCREMENT PRIMARY KEY,
person_id  INT(11),
start_date DATE,
start_time VARCHAR(255),
duration VARCHAR(255),
end_time VARCHAR(255),
ticket_id  INT(11),
description TEXT
);
 
 
INSERT INTO activity_legacy (id,person_id,start_date,start_time,duration,end_time,ticket_id,description)
  SELECT id,person_id,start_date,start_time,duration,end_time,ticket_id,description FROM activity;
 
INSERT INTO activity (obj_id,obj_class,background_color,text_color,label)
  SELECT DISTINCT a.ticket_id, t.finalclass,'#0000ff','#ffffff',t.ref FROM activity_legacy AS a JOIN ticket AS t ON a.ticket_id=t.id;
 
INSERT INTO timespent (id,user_id,start_date,end_date,duration,org_id,title,contact_id,activity_id)
  SELECT ts.id,u.id,concat(ts.start_date," ",ts.start_time),concat(ts.start_date," ",ts.end_time), TIMESTAMPDIFF(SECOND,concat(ts.start_date," ",ts.start_time),concat(ts.start_date," ",ts.end_time)),t.org_id,t.ref,ts.person_id,a.id FROM activity_legacy AS ts LEFT JOIN priv_user AS u ON ts.person_id = u.contactid JOIN ticket AS t ON ts.ticket_id=t.id JOIN activity AS a ON a.obj_id=ts.ticket_id;
 
 
ALTER TABLE activity DROP person_id ;
ALTER TABLE activity DROP start_date ;
ALTER TABLE activity DROP start_time ;
ALTER TABLE activity DROP duration ;
ALTER TABLE activity DROP end_time ;
ALTER TABLE activity DROP ticket_id ;
ALTER TABLE activity DROP description ;

Configuration

'itop-time-tracking' => array(
        'allowed_classes' => array (
                'UserRequest' => array(
                        'calendar-tab' => 'SELECT UserRequest WHERE status != "closed"',
                        'calendar-page' => 'SELECT UserRequest WHERE status != "new"',
                        'stopwatch' => 'SELECT UserRequest',
                        'report-tab' => 'SELECT UserRequest WHERE status != "closed"',
                ),
                'Incident' => array(
                        'stopwatch' => 'SELECT Incident'
                )
           ),
        'colors' => array(
                'default_stopwatch' =>  array('text'=> '#ffffff', 'background'=> '#a6a6a6'),
                'default_calendar' =>  array('text'=> '#ffffff', 'background'=> '#FFCC80'),
                'classes' => array(
                        'UserRequest' => array('text'=> '#ffffff', 'background'=> 'shadeof:blue'),
                        'Incident' => array('text'=> '#ffffff', 'background'=> 'shadeof:green')
                )
        ),
        'default_event_duration' => '00:30:00',
        'day_start_time' => '04:00:00',
        'day_end_time' => '21:00:00',
        'excluded_days' => array('Saturday','Sunday'),
        'first_day' => 1,
        'business_hours'=> array(
                'days_of_week' => array('1', '2', '3', '4', '5'),
                'start' => '04:00:00',
                'end' => '21:00:00',
        ),
        'minimum_event_duration_display' => '00:30:00',
        'stopwatch_clean_periodicity' => 12,
        'stopwatch_max_time' => 12,
),
Parameter Meaning Sample value
allowed_classes array of type of class for which time tracking is allowed. For each class you can define a array of time tracking mode you allow.
colors array defining the default colors globaly and by type of object. The array default_stopwatch defines the default color for a stopwatch. The array default_calendar defines the default color for time tracked in a calendar view. The you can define an array for each type fo object (classes) to define a default color for this one
default_event_duration duration of an activity by default 30 minutes
day_start_time start time in the calendar view 6:00
day_end_time end time in the calendar view 22:00
excluded_days days that are excluded from the calendar view saturday, sunday
first_day first day in the calendar view 0 is Sunday, 1 is Monday 1:Monday
business_hours array describing the business hours Monday to Friday 8:00 - 18:00
minimum_event_duration_display minimum duration displayed in a calendar view even if the time spent is lower 30 minutes
stopwatch_clean_periodicity periodicity to stop check if a stop watch has to be stopper 1 hour
stopwatch_max_time max duration rin hour of a stopwatch if it is not stop manualy by a user 4 hours
delete_max_event_age duration in days after which a user cannot modify or create a time spent 30 days

Time tracking modes

  • calendar tab : the user is allowed to set time tracking in a tab directly on the corresponding objects
  • calendar page : the user can track time in “My time tracking” page for the corresponding objects
  • stopwatch : the user cans track time using a stopwatch for the corresponding objects
  • report-tab : a reporting tab is displayed for the corresponding objects

Colors

Either use an hexadecimal color, or use a shadeof:color where color is one of the following value and will pick randomly for each object a corresponding color.

blue
bluegrey
cyan
green
grey
lime
orange
purple
red
rainbow

Usage

A user can track her/his time in multiple way:

  • From the “Time Tracking” tab on the details of an object present in a “calendar-tab” scope
  • From the “Track my time” menu if objects are present in a “calendar-page” scope
  • From the stopwatch on the right of the screen on the details of an object present in a “stopwatch” scope

Two new profiles are defined with this extension:

  • Time Tracker
  • Time Tracking Manager
A user can track his time only if he has one of those 2 profils.

A user having the Time Tracker profil can only track time for himself and see only his time tracked

A user having the Time tracking Manager profil can track time for other and will have access to the time tracked by anybody

From the details of a ticket

An extra tab “Time Tracking” appears once the extension is installed. Inside the tab a calendar shows the activities associated with the ticket. The activities of the current user are shown in color, whereas the activities of all other users (on this object) and stopwatches appear in ```default_calendar``` and ```default_stopwatch``` color (see configuration). Clicking on an item in the calendar displays a popup to edit this event. To create a new activity, simply click and drag in the calendar. You also change the start date & time or the duration of an Activity by clicking it in the calendar.

Time Tracking tab

From the "Track my time" menu

The same kind of editing is possible from the “Track my time” menu. You need to select an activity in the combobox, from there you set your favorite activities and customize its color.

  • The top search bare use auto-complete mecanism
  • To set your favorite activity, you just have to click on the “heart” icon.
  • To customize the color, you have to click on the “pencil” icon.
  • The drop down list display first your favorite activities, then other activities grouped by type (User Request, Customer Contract …)

Select activity (classic mode)

You can pick a “classic mode” with the combobox always visible or a “modal mode” which prompts a modal each time to click and drag on the calendar.

Select activity (modal mode)

Each calendar has multiple views: month, week, day ,list.

Week view Month view List view
Week view Month view List view

From the stopwatch

A simple icon appears on the right of eligible object. The icon will be black if the stopwatch is not running or green if it's tracking time at the moment.

Right icon

Clicking on this icon will display the stopwatch widget with buttons to start/stop/reset the stopwatch and the recent tracking history of the object with few information : Contacts whom tracked time on this object, the time spent and its date, the origin of this tracked time (stopwatch or calendar)

Opened widget

If you start a stopwatch and go on another object, you'll be prompted by the widget that you are visiting an object while you track time on another object.

Opened widget

Reporting

The extension provides some basic reporting capabilities via two menus: “Time tracking report” and “My time tracking report” and a “Time spent” tab on each object present in ```report-tab``` scopes (see configuration).

Those menus are available, only if the user has one of the time tracking profils. The “Time tracking report” menu is available only for the time tracking managers.

The result is a list of “TimeSpent” objects, which can be exported if needed.

Both menus show the same information, the only difference is that the latter is limited to displaying the activities of the current user only.

Time Tracking Report

The report can be a daily / weekly or monthly report (use the “prev.” and “next” buttons at the top left to navigate to the desired date), and the results can be filtered by additional criteria.

Moreover, at the bottom of the page, several bars charts display the total activity, per day, grouped on one given dimension (User, Customers…)

The TimeSpent data can be retrieved by an OQL query and exported using the standard iTop export capability

Here are some query example to extract time spent information:

Time spent by the current user (My Time Spent)

SELECT TimeSpent WHERE user_id=:current_user_id

Time spent by Claude Monet

SELECT TimeSpent AS ts JOIN Person AS p ON ts.contact_id=p.id WHERE p.friendlyname='Claude Monet'

Time spent for a given organization

SELECT TimeSpent AS ts JOIN Organization AS o ON ts.org_id=o.id WHERE o.name='Demo'

Notification Trigger

This extension brings a new Trigger: Trigger (when a time tracking stopwatch times out) This one is triggered when a time spent stopwatch reach the threshold “stopwatch_max_time”

The class configured for this trigger is TimeSpentBackground ($this) and can be used as a placeholder in the related filter and Actions

You can use this trigger to inform a user that a TimeSpent stopwatch had been stopped automatically after a given delay

Question and Answer

Q: What happen if I suppress a ticket for which I tracked time?
A:
The TimeSpent related to this ticket is not suppressed, just the id of the Ticket is reset to 0.

Customization

The class TimeSpent is defined in XML, so it can be edited to add additional attributes if required.

extensions/itop-time-tracking.txt · Last modified: 2020/11/04 13:00 (external edit)
Back to top
Contact us