Permalink
Browse files

Factor Workload out of Taskjuggler

  • Loading branch information...
1 parent 0e87649 commit 37e2b02132727d1acca1585201bc0c7d191710a6 @chris2fr committed Sep 12, 2009
View
@@ -1,6 +1,6 @@
= Taskjuggler
-Redmine Task Juggler
+Redmine Taskjuggler
This is Redmine and Task Juggler integration.
@@ -10,8 +10,9 @@ The next step is to integrate directly with Task Juggler 3 in Ruby.
== Features
-* Workload management
-* Task-juggler export and partial import
+* Taskjuggler export
+* Taskjuggler import
+* Taskjuggler additionnal
== Getting the plugin
@@ -54,176 +54,6 @@ def index
@users = User.find(:all)
end
- def timetable_update
- @flag = "non"
- act_id = Enumeration.find(:first,:conditions => {:opt => "ACTI"} ).id
- params[:time_entry].each do |issue_id, hours|
- @spent_hours = get_spent_hours(issue_id,params[:user_id].to_i(),params[:date])
- #unless @spent_hours == hours.to_f()
- if (@spent_hours == 0.0 and hours != "0") # Ajouter TimeEntry
- @te = TimeEntry.create()
- @te.hours = hours.to_i()
- @te.activity_id = act_id
- issue = Issue.find(:first,:conditions => {:id => issue_id})
- @te.project_id = issue.project_id
- @te.issue_id = issue_id.to_i()
- @te.user_id = params[:user_id]
- @te.spent_on = params[:date]
- @te.save()
- elsif @spent_hours != 0 and hours == "0"# and hours == "0" # Supprimer
- TimeEntry.delete(TimeEntry.find(:first, :conditions => {:user_id => params[:user_id].to_i(),:issue_id => issue_id, :spent_on => params[:date]}).id)
- @flag = "oui"
- elsif @spent_hours != hours.to_f()
- @te = TimeEntry.find(:first, :conditions => {:user_id => params[:user_id].to_i(),:issue_id => issue_id, :spent_on => params[:date]})
- @te.hours = hours
- @te.save()
- end
- #end
- end
- @date = Date::parse(params[:date])
- @conditions = 'user_id = '+params[:user_id] + ' AND spent_on > "' + (@date - 30).to_s() + '" AND spent_on < "' + (@date + 30).to_s() + '"'
- @logged_te = TimeEntry.find(:all,:conditions => [@conditions], :order => ['issue_id,spent_on'] )
- @logged_issues = {}
- @logged_days = {}
- @total_days = {}
- @projcat = {}
- @projects = Project.find(:all, :conditions => {:status => 1}, :order => ['parent_id,name'])
- @projects.each do |projet|
- @projcat[projet.id] = {}
- @projcat[projet.id]["total"] = 0.0
- issue_categories = projet.issue_categories
- projet.issue_categories.each do |cat|
- @projcat[projet.id][cat.id] = {}
- end
- end
- @logged_te.each do |te|
- unless @logged_issues.has_key?(te.issue_id)
- @logged_issues[te.issue_id] = Issue.find(:first, :conditions => {:id => te.issue_id})
- @logged_days[te.issue_id] = {}
- #(-29..29).each do |delta|
- # @logged_days[te.issue_id][(@date + delta).to_s()] = 0
- #end
- end
- if te.spent_on
- @logged_days[te.issue_id][te.spent_on.to_s()] = te.hours.to_f() / 8
- ####### @projcat[te.project_id][te.project.category_id][te.spent_on.to_s()] = te.hours.to_f() / 8
- @projcat = add_to_projcat(@projcat, te.issue.project, te.issue.category, te)
- unless @total_days.has_key?(te.spent_on.to_s())
- @total_days[te.spent_on.to_s()] = te.hours.to_f() / 8
- else
- @total_days[te.spent_on.to_s()] += te.hours.to_f() / 8
- end
- end
- end
- end
-
- def timetable
- if params[:user_id]
- @current_user_id = params[:user_id].to_i()
- else
- @current_user_id = User.current.id.to_i()
- end
- if params[:date]
- @current_date = params[:date]
- else
- now = DateTime::now()
- date = Date::civil(now.year,now.month,now.mday)
- @current_date = date.to_s()
- end
- @users = User.find(:all,:order => ['firstname'])
- projects = Project.find(:all, :conditions => {:status => 1}, :order => ['parent_id,name'])
- @project_list = {}
- @category_list = {}
- @status_list = {}
- @tracker_list = {}
- trackers = Tracker.find(:all)
- trackers.each do |tracker|
- @tracker_list[tracker.id] = tracker
- end
- statuses = IssueStatus.find(:all)
- statuses.each do |status|
- @status_list[status.id] = status
- end
- projects.each do |project|
- @project_list[project.id] = project
- cats = IssueCategory.find(:all,:conditions => {:project_id => project.id},:order => ['name'])
- cats.each do |cat|
- @category_list[cat.id] = cat
- end
- end
- #projet
- @hours_total = 0
- @time_entries_hours = {}
- # Time-logged issues
- @logged_issues = {}
- time_entries = TimeEntry.find(:all,:conditions => {:user_id => @current_user_id, :spent_on => @current_date})
- if time_entries
- seen_te = {}
- time_entries.each do |time_entry|
- if time_entry.hours > 8
- time_entry.hours = 8
- time_entry.save()
- end
- # Fuse all multiple te for a same date
- if seen_te.has_key?(time_entry.issue_id)
- seen_te[time_entry.issue_id].hours += time_entry.hours
- if time_entry.comments
- seen_te[time_entry.issue_id].comments += " + " + time_entry.comments
- end
- @hours_total += time_entry.hours
- seen_te[time_entry.issue_id].save()
- TimeEntry.delete(time_entry.id)
- @logged_issues[time_entry.issue_id] = get_spent_hours(time_entry.issue_id, @current_user_id,@current_date)
- else
- seen_te[time_entry.issue_id] = time_entry
- @logged_issues[time_entry.issue_id] = Issue.find(:first,:conditions => {:id => time_entry.issue_id})
- @time_entries_hours[time_entry.issue_id] = get_spent_hours(time_entry.issue_id, @current_user_id,@current_date)
- @hours_total += time_entry.hours
- end
- end
- end
- # Assigned issues
- @assigned_issues = {}
- issues = Issue.find(:all, :conditions => ["assigned_to_id = " + @current_user_id.to_s()], :order => ["project_id, category_id, id"] )
- issues.each do |issue|
- unless (@logged_issues and @logged_issues[issue.id])
- #@time_entries_hours[issue.id] = get_spent_hours(issue.id, params[:user_id],params[:date])
- @assigned_issues[issue.id] = issue
- end
- end
- # Watched issues
- watched = Watcher.find(:all, :conditions => {:user_id => @current_user_id, :watchable_type => "issue"})
- @watched_issues = {}
- watched.each do |watched_issue|
- unless (@logged_issues and @logged_issues[watched_issue.watchable_id]) or (@assigned_issues and @assigned_issues[watched_issue.watchable_id])
- @watched_issues[watched_issue.watchable_id] = Issue.find(:first, :conditions => {:id => watched_issue.watchable_id})
- end
- end
- @user = User.find(:first, :conditions => ["id = " + @current_user_id.to_s()])
- #@time_entries = TimeEntry
- end
-
- def add_to_projcat (projcat, proj, cat, te)
- unless projcat.has_key?(proj.id)
- projcat[proj.id] = {}
- projcat[proj.id]["total"] = 0.0
- end
- #unless projcat[proj.id].has_key?("total")
- # projcat[proj.id]["total"] = 0.0
- #end
- unless cat
- cat_id = "other"
- end
- unless projcat[proj.id].has_key?(cat_id)
- projcat[proj.id][cat_id] = {}
- projcat[proj.id][cat_id]["total"] = 0.0
- end
- projcat[proj.id][cat_id][te.spent_on.to_s()] = te.hours.to_f() / 8.0
- projcat[proj.id][cat_id]["total"] += te.hours.to_f() / 8.0
- #projcat[proj.id]["total"] += te.hours.to_f() / 8.0
- return projcat
- end
-
def initial_export
### Initialize necessary variables
if params[:project_identifier]
@@ -1,60 +0,0 @@
-<table border="1">
-<tr>
-<td>&nbsp;&nbsp;<B><%= User.current.login %></B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
-
-
-<%
-
-
-((date_debut)..(date_fin)).each do |idate|
- if idate.wday != 0 and idate.wday != 6
- %>
- <td><%= idate.to_s()[8,2]%>/<%= idate.to_s()[5,2]%></td>
-<%
- end
-end
-%>
-</TR>
-<%
-@projects.each do |projet|
- if @projcat.has_key?(projet.id) and @projcat[projet.id].has_key?("total")
- %>
-<TR>
-<td colspan="<%= (date_fin) - (date_debut) %>"><H3><%= projet.name %></H3></td>
-</TR>
-<%
- projet.issue_categories.each do |cat|
-%>
-<TR>
-<td><H4><%= cat.name %></H4></td>
-<%
- ((date_debut)..(date_fin)).each do |idate|
- if idate.wday != 0 and idate.wday != 6
- idate = (idate).to_s()
- if @projcat[projet.id][cat.id].has_key?(idate)
- hours = @projcat[projet.name][cat.id][idate]
- else
- hours = 0
- end
- %><TD <%
- %>style="background-color:rgb(255, 255, <%= 255 - (255 * hours).to_i() %>)"<%
- %>
- ><%= hours %></TD>
- <%
- end
- end
- %>
- <TD><%= @projcat[projet.id][cat.id]["total"]%></TD>
- <%
- end
-%>
-</TR>
-
-<%
-end
-%>
-<%
-end
-%>
-</TR>
-</TABLE>
@@ -1,58 +0,0 @@
-<table border="1">
-<tr>
-<td>&nbsp;&nbsp;<B><%= User.current.login %></B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
-<%
-((date_debut)..(date_fin)).each do |idate|
- if idate.wday != 0 and idate.wday != 6
- %>
- <td><%= idate.to_s()[8,2]%>/<%= idate.to_s()[5,2]%></td>
-<%
- end
-end
-%>
-</TR>
-<%
-@logged_issues.each do |id,li|
- %>
-<TR>
-<td>#<a href="/issues/show/<%= li.id %>"><%= li.id %></a> <b><%= li.subject %></b></td>
-<%
- ((date_debut)..(date_fin)).each do |idate|
- if idate.wday != 0 and idate.wday != 6
- idate = (idate).to_s()
- if @logged_days[li.id].has_key?(idate)
- hours = @logged_days[li.id][idate]
- else
- hours = 0
- end
-%>
- <TD <%
- %>style="background-color:rgb(255, 255, <%= 255 - (255 * hours).to_i() %>)"<%
- %>
-><%= hours %></TD>
-<%
- end
- end
- %></TR><%
-end
-%>
-<TR>
-<TD align="right"><B>TOTAL<B></TD>
-<%
-((date_debut)..(date_fin)).each do |idate|
- if idate.wday != 0 and idate.wday != 6
- %>
- <td><B><%
- if @total_days.has_key?(idate.to_s())
- %><%= @total_days[idate.to_s()] %><%
- else
- %>0<%
- end
-
- %></B></td>
-<%
- end
-end
-%>
-</TR>
-</TABLE>
@@ -1,43 +0,0 @@
-<SELECT NAME="time_entry[<%= issue.id%>]">
- <OPTION VALUE="0" <%
- if @time_entries_hours[issue.id] == 0
- %> SELECTED <%
- end
- %>>0</OPTION>
- <OPTION VALUE="8"<%
- if @time_entries_hours[issue.id] == 8
- %> SELECTED <%
- end
- %>>1</OPTION>
- <OPTION VALUE="4"<%
- if @time_entries_hours[issue.id] == 4
- %> SELECTED <%
- end
- %>>1/2</OPTION>
- <OPTION VALUE="2"<%
- if @time_entries_hours[issue.id] == 2
- %> SELECTED <%
- end
- %>>1/4</OPTION>
- <OPTION VALUE="1"<%
- if @time_entries_hours[issue.id] == 1
- %> SELECTED <%
- end
- %>>1/8</OPTION>
- <OPTION VALUE="6"<%
- if @time_entries_hours[issue.id] == 6
- %> SELECTED <%
- end
- %>>3/4</OPTION>
- <OPTION VALUE="3"<%
- if @time_entries_hours[issue.id] == 3
- %> SELECTED <%
- end
- %>>3/8</OPTION>
- <OPTION VALUE="5"<%
- if @time_entries_hours[issue.id] == 5
- %> SELECTED <%
- end
- %>>5/8</OPTION>
- </SELECT> [<%= @category_list[issue.category_id] %>] <b><%= @project_list[issue.project_id] %></b>
- <a href="/issues/show/<%= issue.id%>">#<%= issue.id %></a>. "<%= issue.subject %>" (<%= @status_list[issue.status_id] %>)
Oops, something went wrong.

0 comments on commit 37e2b02

Please sign in to comment.