Hey, I wrote yet another time tracker (no, not yatt) module called addhours as an internal project. I'd love to write an upgrade path from mine to yours, but I use a couple of different columns and a unique widget. It would be possible in Drupal 7 to collaborate if we made time entries fieldable entities.
I'd be willing to start on a port of time_tracker to Drupal 7 to get you there in my free time. But I would only want to spend the effort if there aren't any radical changes that you have planned (other than say switching to bundleable entities).
I would probably start by making the time_tracker entity and activity type stuff and breaking out code into more readable chunks (*.theme.inc, *.admin.inc, *.pages.inc).
If that sounds good, I'll sandbox fork it.
| Comment | File | Size | Author |
|---|---|---|---|
| #37 | time_tracker.zip | 465.13 KB | chertzog |
| #12 | time_tracker.zip | 389.37 KB | chertzog |
| #11 | time_tracker.patch | 300.92 KB | chertzog |
| #6 | time_tracker_d7.patch | 68.89 KB | chertzog |
Comments
Comment #1
codi commentedHey mradcliffe,
That would be awesome. The co-maintainer of this module has been out of country for the last few months and I've been swamped with other duties so the issue queue and plans for D7 have languished. I'm actually hoping to start devoting more time in the next couple of weeks so timing is perfect.
The only change that we had touched on in conversations was abstracting the time entry handling into an API of sorts, but we didn't get that far.
Let me know when you get the sandbox setup!
Comment #2
mradcliffeCool. I took a look at some code last night drinking a couple of beers.
It looks like it would be possible to create entity bundles and stuff a lot of the settings for time tracker into those bundles. Some things like "notes" could be changed into Field API fields and automatically created in an update script. Obviously things like timestamp, start, end, and duration are better suited as part of the schema for queries (too many joins to start adding Time fields). But other columns like notes, billable, billing, and even nid or cid could be changed to Entity Reference fields. In my schema for "addhours" I adopted a similar model for nid. I think that's the biggest question I have about porting to an entity model.
I haven't really looked at timer, estimate, or sheet yet.
Another idea would be to make the bundle by activity and then an activity could track by duration or interval modes depending on configuration.
Edit: didn't quite finish writing this up...
Comment #3
chertzogI would love this for D7. I used it in a couple D6 projects on OA, but have since moved in another direction. I am especially interested in the timesheet functionality. I can help with the port, upgrade, and testing. Has anything been done yet, or is it still in the planning phase?
Comment #4
mradcliffeI got really busy in the last month and my off time has been mainly DrupalCamp planning. Sorry. :(
Comment #5
chertzogNo worries. I am starting work on the initial port as we speak :)
Comment #6
chertzogSo here is a start. So far i have only worked on the time_tracker module.I havent touched timer, sheet, or estimate.
1. Tracking time on nodes seems to work pretty well.
2. Tracking time on comments is kind of hosed.
3. CSS needs updating
4. There are plenty of coding standards issues, I'm aware...
This patch is against the current master.
I will continue to work on this... but i thought i would share the progress so far, so that anyone that wanted to help, would have a head start.
Comment #7
chertzogI've got the time sheet module ported except for the case tracker stuff. One of the things I loved about time tracker was the timesheet and the case tracker integration form. That way users could add time to cases from the timesheet. But judging by this article it looks like atrium may be abandoning case tracker in its current form. Although it looks like case tracker is being ported to D7, its being done so by the community and not the maintainers #678838: Case Tracker - Port to Drupal 7.
I think we could further extract the case tracker integration, and make some general assumptions based on the way case tracker (and most other project management systems) work.
For example:
So what if we had some settings where the we could pick which entity types are considered the "projects" and "tasks." We then have a settings that picks the user/entity reference field on said "task" type that indicates who the task is assigned to.
With this information we can replicate the environment that case tracker provided to time tracker.
Thoughts?
Comment #8
mradcliffeI was hoping to abstract out some of time tracker to make use of entities. Instead of an all inclusive thing with a bunch of settings I would split out into two default bundles - one duration based and one work shift based.
Comment #9
chertzogThe way that i am planning on using this module, is with entities, and i have already turned time entres into entities. i have also fixed the views stuff, and gotten timesheet sort of up to snuff.
I will try rolling a patch later tonight.
Comment #10
drclaw commentedHey Guys,
Sorry, I wasn't following this issue for some reason so I had no idea this stuff was going on! Thanks for all your work on this project. Please roll the patch when you're ready and I'll give it a test.
Thanks!
Comment #11
chertzogNow it work like this: if the week starts on monday, and all days are displayed, the sunday that is displayed at the end of the timesheet would be the sunday after the monday that started the week, not the sunday before the week start.
Comment #12
chertzogHere is a zip file of the project. It should be easier to view and understand seeing as i re-arranged the file structure a little.
Comment #13
drclaw commentedNice one @chertzog! Thanks for the zip. Definitely easier. =P
I'll give this a test this weekend and report back!
Comment #14
drclaw commentedHi,
I got a chance to test this out yesterday. It's a great start! However, I can't seem to save time entries. Should I be able to? I'm getting a Fatal Error: "Fatal error: Function name must be a string in /home/chris/www/tt7/public/includes/form.inc on line 1443". I looked at the code but didn't have enough time to troubleshoot. Also, the time sheet doesn't work for me at all. Getting a few different php errors (although I think you mentioned you had some things hardcoded for your setup...)
So far though, based on what you've told me, it seems like it's on the right track. I think starting with just time tracker and time sheet is fine. The time estimate and the timer should be easy enough to upgrade once time tracker itself is working properly. The next steps, for me, would be to start pulling some of the fields out of time tracker and adding them as entity fields. Ultimately I think every time tracker field should be an entity field, just some of them wouldn't be configurable (duration, timestamp etc). Also, we should discuss the idea of how to handle duration vs. time interval based time tracking. @mradcliffe mentioned using different bundles. It might be a good idea, but we should discuss it a bit more.
Comment #15
chertzogYes, I had hard coded a few things in timesheet because of my immediate needs (custom field names are hard coded into some queries, so yeah there would ne no way it would work). Though you should be able to track time. I dont think i hard coded anything in time tracker. Were you tracking time on nodes or in comments? The comments thing is still broken, as i wasnt planning on using it for my project at the moment.
As for fields, I had set up a psuedo field to show on the field configuration form for the time tracking form itself. But if we want to break them into their own fields that can be done.
The different bundles thing could work. We would just have a couple different fields on the different bundles.
Comment #16
drclaw commentedI was tracking time on nodes... Hmm... I'll give it another go sometime in the near future.
Anyway, I've added you as a maintainer of time tracker so you can push changes now to the 7.x-1.x branch as you move forward. =)
Comment #17
chertzogSo I have gotten a little free time to work on this again. As @mradcliffe state in #2 we have a couple options for D7.
He proposes "activity" bundles and time configuration by bundle. As well as turning most of the other fields into Field API fields or entity references.
As for the bundles by activity, I'm not so sure. I would think that the way that an organization tracks time would either be a set way for the entire organization, or configurable by user (the organization doesn't care). I dont think that most organizations (web development for example) would track time via duration for coding and via start/stop for design. My vote on this would be a global option as it is now, with a setting to allow user configurable option(we could add the option on their account edit form).
I think the Field API fields and entity reference path is a great one! This means we could in theory track time on ANY entity, taxonomy terms, nodes, comments, users... Plus with EntityFieldQuery(not having to worry about joins/tables) we could turn almost every field into a Field API field.
Entity reference fields:
Boolean:
Date module fields:
Longtext:
Integer:
We could almost eliminate the schema. I know this may be a little overboard, but we are still in the planning phase. Thoughts?
Comment #18
drclaw commentedI agree about the bundles by activity. Let's forget that for the time being.
I'm divided on using Entity Reference fields... Sure it would be great to log time on any entity, but how do we get the time tracking form "on" that entity? Right now it's easy to know where to put the time tracker form because it's only on nodes or comments... Maybe it will just work though. In my head it seems like it's going to be a headache but I don't know for sure.
I think turning as many fields as possible into Field API fields is good. The only thing is, if we're going to turn them all into Field API fields, we may as well just make it a custom node type and bundle it as a Feature with some views and custom code... Hmm... that's not a bad idea actually... Consider what you described above. Every field is essentially an existing field type already. There's no reason you couldn't just make a time_entry content type with all those fields. Then all you need is a little custom code to handle where to put/embed the form... It's at least worth discussing. What does our time tracking entity bring to the table that makes it any different than a custom node type with some views (and maybe views calc)?
Comment #19
chertzogThe feature thing is interesting and at least worth a discussion. In my project i described above, i have already removed most of the default time tracking list tables (on nodes/comments), and just replaced them with views... Though with the rest of the time tracker project (time sheet, timer, estimate), not sure those are feature material.
I like the idea of turning it into a "custom content type" with all fields being Field API, cause then you could utilize things like field permissions, conditional fields, out of the box views support, rules, and features...
As for how to get the form "on" an entity, what about hook_entity_view. We were already using hook_node_view in D6, and in my D7 port above.
Comment #20
mradcliffeNodes are nodes and come with everything that nodes come with. It's probably more efficient to keep the columns the time tracker entry table the way they are. Adding them all as fields comes with some overhead. One of the down sides of storing as entities is that there is going to be some overhead anyway, but not as much as a node imo.
Comment #21
chertzogI agree that turning entries into node or entities is less efficient, but the drop in efficiency is coupled with a huge increase in flexibility. Turning all of the fields into Field API fields and using a couple default views, would let us eliminate a LOT of code. We wouldn't need to manage most of the views includes or handlers anymore. We could strip out all of the theme functions that create the tables of of entries to be displayed on nodes/comments. and just include a couple default views (Plus you may have heard, Views is headed for Core).
I think that we should define our own entity, and populate it with Field API fields, leveraging an entity reference field to store the ID of what we are tracking time on.
Comment #22
drclaw commentedI think @mradcliffe was specifically talking about all the overhead that comes with nodes, and I have to agree a little bit. While turning the time tracker records into entities is definitely the way to go, turning them into nodes is probably not the best idea (even though I suggested it first =P). I think we're all on board with the new entity idea anyway, so we're definitely good to go ahead on that.
I'm okay with using the entity reference field, except for one thing... Right now, you can install time tracker and be tracking time on a node with one simple checkbox on the content type configuration page. After that, the form is added to the node and you're good to go. I would like the D7 version to be as easy, if possible. I don't want it to be one of those modules that gets installed, then you have to configure 10 different things before you can start using it (views, contexts, reference fields etc.). As much as I want flexibility, I would also like some out of the box functionality. Thoughts?
Lastly, I think a few fields need to be mandatory 'core' time tracker fields (kind of like 'title' on nodes): timestamp, start,end/duration. Speaking of which.... what will we do about the start/end vs. duration debate? Different bundles? Configurable custom field type?
Comment #23
chertzogWell, for configuration currently we have the one checkbox in the content type settings form.
As for entity reference, a single instance of the field can only reference a single entity type (which i didnt know before doing a little more research before writing this(see http://drupal.org/node/1360230)). I think that we may have to re-think the use of this module. I see 2 options for generic "track time on any entity" functionality:
#2 looks to be the preferred route. This would also allow us to just have a settings page, where we list all available entities and bundle types. The user then justs selects which entity/bundle they want to track time.
Comment #24
drclaw commented#2 sounds good to me. What if a user wants to create two separate time tracker bundles that tracks time on two different entities? Can they still do that?
Comment #25
chertzogAre we having multiple "time tracker" bundles? or are we just having one time tracker entity?
I would think that all we need is a time tracker entity. This way when we store an entry, we store the teid, entity type and bundle, and entity ID. This way the settings form would allow us to list all of the available entities and bundles, and the user could select which ones they want to track time on.
We would have to figure out a way to deal with tracking time on comments, because i think core only allows comments on nodes...
Comment #26
mradcliffeOne use case for tracking time differently would be if you had hourly vs salarly workers or different types of hourly workers that you wanted different information collected on. Maybe one calculates lunch or other things differently. This could be the use case for a different module that combines time into shifts, and sometimes it's good to keep a narrower, defined use case.
My use case is just to have a standard entity - everyone tracks time the same way.
Comment #27
chertzogWhat if we allowed individual users the option of how they wanted to track time (duration vs start/stop)? Couldnt we include a setting on the users account allowing them to indicate which method they would like to use?
Because it doesnt matter which way a users wants to track time, we can still calculate total time...
Comment #28
chertzogHere is what looks like the best way forward to me:
Doing it this way would move the "Track time on nodes" and "Track time on comments" settings from each content type, to the main settings form. One place to administer all time tracker tracking methods. And would allow each user to track time however they want.
Comment #29
mradcliffeSo you think separating out the time tracking columns into field API won't have any performance implications? Benefit would be field API takes care of storage, views, etc... Trade off is performance imo.
Comment #30
chertzogI didnt say that it wouldnt have any performance implications, I agree that Field API stuff would decrease performance. But i think for flexibility it would be a benefit.
Comment #31
drclaw commentedHey guys,
@chertzog: I think your proposal for how to move forward is good. I'm not sure if giving the option to the users about how they want to track time is necessarily the way to go... or at least not by default. I feel like the time entry method shouldn't be left up to the individual doing the work. A decision like that usually comes from higher up. What about making it role based? Or maybe role based by default with the option to override on a user by user basis?
@mradcliffe Right now, I feel like the flexibilty outweighs the performance, but perhaps we should talk about cases where the performance hit would be a significant issue?
Comment #32
chertzogAs for user configurable, we could have it globally configured by default, then have a admin controlled setting that would allow user configurable tracking...
Comment #33
drclaw commentedCool. I still think having the global setting be role based wouldn't be a bad thing. =)
Comment #34
chertzogI agree. Before i start coding this up, can we get a consensus on the road ahead?
I submit #28 with global option/role based time tracking configuration.
Comment #35
drclaw commentedI consent.
Comment #36
mradcliffeSounds great.
Comment #37
chertzogAll, sorry it has taken so long. But client work, family issues, etc, etc, the list goes on. Any how, attached you will find an archive with a almost completely rewritten time_tracker module. I have also committed the code to the 7.x dev branch.
New features:
1. Activities are now fieldable entities.
2. Time entries are fieldable entities.
3. You can now track time on ANY entity/bundle.
4. Seeing as core only supports comments on nodes, tracking time on comments is limited to node bundles.
5. There is a new settings page where the admin configures what entities/bundles time tracking is enabled for.
Things left to do:
1. Let users pick the way they want to track time (duration vs interval)
2. Time Sheet / Timer / Time Estimate sub modules
3. CSS needs work
Comment #38
drclaw commentedThat's awesome, chertzog! I'll give this a try this weekend.
Nice work!
Comment #39
chertzogWell seeing as the module is almost completely ported, and the only issues left are up for discussion, i think we can close this issue, and open separate issues for anything that pops up.
Comment #40
drclaw commentedAgreed.