Code Monkey home page Code Monkey logo

coop.symbiotic.timetrack's Introduction

Timetrack

General idea: you have activities and can track time with activities. However, you may have some activities are done over various moments in a day/week/month, and you want to track your time in a more granular way.

This extension adds a new entities for "tasks" and "punches", which have a begin date/time, duration and comment. The punches are linked to tasks of a case.

Punches can then be invoiced to the client (making it easy to know which work has been invoiced or not). The extension can generate invoices in OpenDocument (odt) format using the tinybutstrong (opentbs) library (see "Invoicing").

Timetrack also includes reports, custom searches and new APIs to manipulate the punches and make it easy to punch using 3rd-party systems, such as Mattermost.

Here are a few screenshots:

To download the latest version of this module:
https://lab.civicrm.org/extensions/timetrack

Requirements

  • CiviCRM 5.7+
  • PHP 7.2+

Timetrack does not (yet) work with the CiviCase v5 extension.

Installation

Install as any other regular CiviCRM extension:

1- Download this extension and unpack it in your 'extensions' directory. You may need to create it if it does not already exist, and configure the correct path in CiviCRM -> Administer -> System -> Directories.

2- Enable the extension from CiviCRM -> Administer -> System -> Extensions.

History

Timetrack is a partial rewrite of "kproject"[1], a time management tool written by Koumbit.org. It was written as a Drupal 6 module, and was an awesome time tracker, which included an IRC bot and a few planning features suitable for small-medium organisations.

However, it was mostly used only by Koumbit, and they did not upgrade it to Drupal 7. Since kproject implemented many CRM-ish features that are present in CiviCRM, causing some duplication of information (list of clients, contact information), this extension attempts to implement in CiviCRM some of the features of kproject.

The "client" in kproject becomes a CiviCRM Contact, and the kproject contract becomes a CiviCRM Case. In reality, Timetrack does not use many CiviCase features, but it provides a good way to have multiple contracts for an organisation.

You can also create different case types depending on your type of contracts (ex: consultation, support), and you can create standart timelines for them.

The "task", "punch" and "order" in kproject are mostly kept as is. Orders also have an "order_line" in order to keep more granular tracking in invoices.

[1] https://www.drupal.org/project/kproject

Punching using Mattermost

Mattermost is an open source, self-hosted alternative. The following instructions should also work for Slack.

You can connect your Mattermost instance with your Timetrack instance by setting up a "Slash Command" in Mattermost. You may need to be an admin to do this.

  • Go to Menu > Integrations > Slash Commands
  • Fill in the instructions.
    • Command Trigger Word: (example) punch, so that we can punch time using /punch [...] on the chat
    • Request URL: https://example.org/civicrm/timetrack/mattermost
    • Request Method: POST
    • Response Username: (example) "timetrack" (name of the bot)
    • Autocomplete Hint: [14:30+90m] [project/task] [comment]

For more information, see:
https://docs.mattermost.com/help/messaging/executing-commands.html

Examples

Punch in a project, then later punch out:

/punch myproject/mytask This is my comment
/punch

Punch in at a specific time, then later punch out:

/punch 9:30 myproject/mytask This is my comment
/punch

Punch in at a specific time, and with a specified duration (no need to punch out):

/punch 9:30+1h myproject/mytask This is my comment

Invoicing

Invoices can be quite an art and need to look good, Timetrack takes an ordinary OpenDocument file (odt) as a template in order to generate invoices.

The OpenDocument file can have the following tokens that will be filled-in by Timetrack. Since we are using the tinybutstrong library, the tokens have the following syntax:

  • [var.ClientId] ("contact ID" of the case contact)
  • [var.ClientName] ("display name" of the case contact)
  • [var.ClientAddress1] (primary address of the case contact)
  • [var.ClientAddress2] (corresponds to "additional address 1" in CiviCRM)
  • [var.ClientAddress3] (corresponds to "additional address 1" in CiviCRM)
  • [var.ClientCity]
  • [var.ClientStateProvince]
  • [var.ClientPostalCode]
  • [var.LedgerId] (ledger ID associated to an invoice)
  • [var.InvoiceId] (auto-generated internal ID for invoices)
  • [var.InvoiceDate]
  • [var.CaseId]

The following tokens should be used in a row:

  • [t.title;block=table:table-row]
  • [t.qty]
  • [t.unit]
  • [t.cost]
  • [t.amount]

The invoice subtotal can be found in [var.SubTotal].

Warning: LibreOffice/OpenOffice might wrap your text in a "span", depending on how you entered the text. Type the tokens all at once. If you have to delete a typo, restart from the beginning. Otherwise, the template engine might not be able to recognize the token, such as: "[t.title]". If in doubt, unzip the .odt file and inspect it with a text editor.

Finally, to define the location of your invoice template, you must define the setting manually using the API:

$ drush cvapi Setting.create TimetrackInvoiceTemplateDefault='/path/to/invoice-template.odt';

The generator will respect the "preferred language" of the contact if you have a template for that language. It must be defined using, for example:

$ drush cvapi Setting.create TimetrackInvoiceTemplateFR='/path/to/invoice-template-fr.odt';

where "FR" is extracted from the contact's preferred language (ex: "fr_CA" becomes "FR").

You can also use the API explorer (example.org/civicrm/api/explorer), instead of drush.

(yes, this is a bit weird, it was a quick hack and needs a UI)

Timetrack APIs

TODO: needs documentation. See the 'api/v3' directory of this extension.

Status & Todo

Tasks and punches:

  • [wishlist] Punching in a 'new' task should change it to 'open'.
  • [wishlist] Quick punch form, not linked to a specific case.

Invoices:

  • [rc] Rename the "hours_billed" in the DB to just "qty".
  • [wishlist] Have a per-task default cost (hourly fee)? Currently we support a per-project fee.
  • [wishlist] Have a way to list the punches specific to a task? (popup?)
  • [wishlist] Add a "public note" field, for a text to add on the invoice sent to the client?
  • [wishlist] Add a "private note" field, for internal notes? (not shown on the final invoice)

Misc:

  • [rc] Implement "case merge" hook.
  • [rc] Convert all unix timestamp fields to mysql datetime (ex: task begin/end, punch begin ✔).
  • [important] Config UI for the invoice template file (currently the path of the template is hardcoded).
  • [wishlist] Invoicing has some redundancy with CiviAccounts. Would be neat to integrate all that together.

General assumptions that might need fixing:

  • Assuming that cases have only 1 client contact, ex: api/v3/Timetrackinvoice.php get.
  • The system mostly works in hours. All durations displayed are usually in hours (as opposed to days).

Support

Please post bug reports in the issue tracker of this project on CiviCRM's Gitlab:
https://lab.civicrm.org/extensions/timetrack/issues

For general questions and support, please post on the CiviCRM Stack Exchange:
http://civicrm.stackexchange.com

This extension was written thanks to the financial support of organisations using it, as well as the very helpful and collaborative CiviCRM community.

While we do our best to provide volunteer support for this extension, please consider financially contributing to support or development of this extension if you can.

Support via Coop SymbioTIC:
https://www.symbiotic.coop/en

Coop Symbiotic is a worker-owned co-operative based in Canada. We have a strong experience working with non-profits and CiviCRM. We provide affordable, fast, turn-key hosting with regular upgrades and proactive monitoring, as well as custom development and training.

License

Distributed under the terms of the GNU Affero General public license (AGPL). See LICENSE.txt for details.

(C) 2014-2020 Mathieu Lutfy [email protected] (C) 2016-2020 Mathieu Lutfy [email protected] (C) 2016-2020 Coop SymbioTIC [email protected]

Includes code based on "kproject"
https://drupal.org/project/kproject

(C) 2008-2011 Yann Rocq
(C) 2008-2011 Samuel Vanhove

Bundles the "tinybutstrong" library and the "openbts" plugin, distributed under the terms of the GNU Lesser General public license (LGPL).
http://www.tinybutstrong.com/
http://www.tinybutstrong.com/support.php#licence

Bundles the "dhtmlxscheduler" library, distributed under the terms of the GNU General Public License v2. (c) Dinamenta UAB
http://dhtmlx.com/docs/products/dhtmlxScheduler/
https://github.com/DHTMLX/scheduler/
https://github.com/DHTMLX/scheduler/blob/master/license.txt

coop.symbiotic.timetrack's People

Contributors

mlutfy avatar totten avatar colemanw avatar samuelsov avatar dependabot[bot] avatar urlisse avatar

Stargazers

Usha Matisson avatar  avatar

Watchers

 avatar  avatar  avatar  avatar James Cloos avatar  avatar  avatar

Forkers

colemanw totten

coop.symbiotic.timetrack's Issues

Cannnot de-punch when there are two open punches

A bit of a weird use-case, but it can happen due to a bug: when there are two open punches (duration = -1), it's not possible to unpunch using the API, because the punchout 'getsingle' call will trigger an exception ("Expected one Timetrackpunch but found 2").

Better integration with case activities

Users doing case tracking often have to log an activity for an interaction with a client, as well as to log their time in the time tracker.

  • In the new punch UI #3, have an option "[x] create an activity"?
  • In the case activity form, have an option to track time? (the "duration" field is not used by timetrack, and would probably not be relevant, but something to keep in mind)
  • Should "tasks" be (optionally) linked to Activity Types?
    • would make it easier to "[x] create new activity"
    • and also while in the Case Activity form, so that the user doesn't need to select the task type.

Improve the UI for punching

  • Have a permanently displayed widget (in the menu or at the bottom of the screen) to punch in a project.
  • Menu item for the report of recent punches
  • Menu item for the timeline

Accept+document dates as (optional) part of time expression

Background: The docs currently point to a notation like this for punching on Mattermost:

!pi -s 17:00+30m wmf/dev This is my description

Use-Case: I find it handy to track time in a text-file. It's useful for offline work (either due to wonky-Internet or travel or tuning-out from the firehose). It also makes it a bit easier to fill-in details (like project id and issues) asynchronously, to copy-edit notes, and to split out things that were multitasked.

The problem is that it might take a day or so to copy it back in. And after midnight... it gets hard to copy info in.

Aside: The offline log is also a little insidious... once I had a backlog that's hard to transfer, then I started feeling some incentive to keep everything together... which meant continuing to use the text file even if I had online access... so I currently have a... long backlog. That's got me feeling a little motivated. (For me, writing a small parser is probably about as easy as doing data-entry for 50 records...) Tried to find the parser for Mattermost comments... but couldn't. The README suggests that a hubot script lives elsewhere. If you can point me at it, then I might be able to write a patch and/or give a better suggestion.

Possible Notations

## Idea 1
!pi [-d YYYY-MM-DD] [-s HH:MM+DDU] [category] [description]
!pi -d 2019-02-01 -s 17:00+30m wmf/dev This is my description

## Idea 2
!pi [-s [YYYY-MM-DD:]HH:MM+DDU] [category] [description]
!pi -s 2019-02-01:17:00+30m wmf/dev This is my description

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.