This is an old revision of the document!
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.
|2021-01-08||2.1.2|| * Add overview missing dictionary entries
* Fix Activity class format
* Fix dependency with legacysearchbase
|2020-11-04||2.1.1||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|
Use the Standard installation process for this extension.
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 AS 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,description,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.description, 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 AND a.obj_class = t.finalclass; ALTER TABLE activity DROP person_id, DROP start_date, DROP start_time, DROP duration, DROP end_time, DROP ticket_id, DROP description; UPDATE priv_changeop SET objclass = "TimeSpent" WHERE objclass = "Activity"; DELETE FROM activity WHERE obj_id = 0;
'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, 'delete_max_event_age' => 30, 'manager_report_silo' => 'SELECT Person', 'weekly_report_time_spent_attribute' => '', 'weekly_report_time_spent_default' => '30hrs', 'report_charts_definition' => array( array('group_by_attribute' => 'contact_id', 'label' => 'TimeTracking:ReportActivityPerUser'), array('group_by_attribute' => 'org_id', 'label' => 'TimeTracking:ReportActivityPerCustomer') ) ),
|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|
|clone_events||Since 2.1.3 allow user to clone time spent via ctrl+click||false|
|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 checking if a stop watch has to be stopped||1 hour|
|stopwatch_max_time||max duration in hours 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|
|default_report_query||Since 2.1.3 Time spent scope for self report (available placeholder: contact_id, start||SELECT TimeSpent WHERE contact_id = :contact_id AND start_date >= :start_date AND end_date < :end_date|
|manager_report_query||Since 2.1.3 Time spent scope for self report (available placeholder: contact_id, start||SELECT TimeSpent WHERE start_date >= :start_date AND end_date < :end_date|
|manager_report_silo||The silo describing what Contacts Time Tracking Managers will be able to see||SELECT Person|
|weekly_report_time_spent_attribute||Attribute describing the expected time shown in Time Tracking Manager Overview||empty|
|weekly_report_time_spent_default||Describe the default value in case `weekly_report_time_spent_default` is empty (can be a dictionary entry)||'30hrs'|
|report_charts_definition||Define the charts displayed at the bottom of Time Tracking report page||array( array('group_by_attribute' ⇒ 'contact_id', 'label' ⇒ 'TimeTracking:ReportActivityPerUser'), array('group_by_attribute' ⇒ 'org_id', 'label' ⇒ 'TimeTracking:ReportActivityPerCustomer'))|
Time tracking modes
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.
A user can track her/his time in multiple way:
Two new profiles are defined with this extension:
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
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.
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.
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.
Each calendar has multiple views: month, week, day ,list.
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.
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)
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.
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.
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'
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
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.
The class TimeSpent is defined in XML, so it can be edited to add additional attributes if required.