##// END OF EJS Templates
Fixed an unicode problem on gantt (first letter of the day name)...
Jean-Philippe Lang -
r498:78b5e57a4ad8
parent child
Show More
@@ -1,188 +1,188
1 <%
1 <%
2 pdf=IfpdfHelper::IFPDF.new(current_language)
2 pdf=IfpdfHelper::IFPDF.new(current_language)
3 pdf.SetTitle("#{@project.name} - #{l(:label_gantt)}")
3 pdf.SetTitle("#{@project.name} - #{l(:label_gantt)}")
4 pdf.AliasNbPages
4 pdf.AliasNbPages
5 pdf.footer_date = format_date(Date.today)
5 pdf.footer_date = format_date(Date.today)
6 pdf.AddPage("L")
6 pdf.AddPage("L")
7 pdf.SetFontStyle('B',12)
7 pdf.SetFontStyle('B',12)
8 pdf.SetX(15)
8 pdf.SetX(15)
9 pdf.Cell(70, 20, @project.name)
9 pdf.Cell(70, 20, @project.name)
10 pdf.Ln
10 pdf.Ln
11 pdf.SetFontStyle('B',9)
11 pdf.SetFontStyle('B',9)
12
12
13 subject_width = 70
13 subject_width = 70
14 header_heigth = 5
14 header_heigth = 5
15
15
16 headers_heigth = header_heigth
16 headers_heigth = header_heigth
17 show_weeks = false
17 show_weeks = false
18 show_days = false
18 show_days = false
19
19
20 if @months < 7
20 if @months < 7
21 show_weeks = true
21 show_weeks = true
22 headers_heigth = 2*header_heigth
22 headers_heigth = 2*header_heigth
23 if @months < 3
23 if @months < 3
24 show_days = true
24 show_days = true
25 headers_heigth = 3*header_heigth
25 headers_heigth = 3*header_heigth
26 end
26 end
27 end
27 end
28
28
29 g_width = 210
29 g_width = 210
30 zoom = (g_width) / (@date_to - @date_from + 1)
30 zoom = (g_width) / (@date_to - @date_from + 1)
31 g_height = 120
31 g_height = 120
32 t_height = g_height + headers_heigth
32 t_height = g_height + headers_heigth
33
33
34 y_start = pdf.GetY
34 y_start = pdf.GetY
35
35
36
36
37 #
37 #
38 # Months headers
38 # Months headers
39 #
39 #
40 month_f = @date_from
40 month_f = @date_from
41 left = subject_width
41 left = subject_width
42 height = header_heigth
42 height = header_heigth
43 @months.times do
43 @months.times do
44 width = ((month_f >> 1) - month_f) * zoom
44 width = ((month_f >> 1) - month_f) * zoom
45 pdf.SetY(y_start)
45 pdf.SetY(y_start)
46 pdf.SetX(left)
46 pdf.SetX(left)
47 pdf.Cell(width, height, "#{month_f.year}-#{month_f.month}", "LTR", 0, "C")
47 pdf.Cell(width, height, "#{month_f.year}-#{month_f.month}", "LTR", 0, "C")
48 left = left + width
48 left = left + width
49 month_f = month_f >> 1
49 month_f = month_f >> 1
50 end
50 end
51
51
52 #
52 #
53 # Weeks headers
53 # Weeks headers
54 #
54 #
55 if show_weeks
55 if show_weeks
56 left = subject_width
56 left = subject_width
57 height = header_heigth
57 height = header_heigth
58 if @date_from.cwday == 1
58 if @date_from.cwday == 1
59 # @date_from is monday
59 # @date_from is monday
60 week_f = @date_from
60 week_f = @date_from
61 else
61 else
62 # find next monday after @date_from
62 # find next monday after @date_from
63 week_f = @date_from + (7 - @date_from.cwday + 1)
63 week_f = @date_from + (7 - @date_from.cwday + 1)
64 width = (7 - @date_from.cwday + 1) * zoom-1
64 width = (7 - @date_from.cwday + 1) * zoom-1
65 pdf.SetY(y_start + header_heigth)
65 pdf.SetY(y_start + header_heigth)
66 pdf.SetX(left)
66 pdf.SetX(left)
67 pdf.Cell(width + 1, height, "", "LTR")
67 pdf.Cell(width + 1, height, "", "LTR")
68 left = left + width+1
68 left = left + width+1
69 end
69 end
70 while week_f <= @date_to
70 while week_f <= @date_to
71 width = (week_f + 6 <= @date_to) ? 7 * zoom : (@date_to - week_f + 1) * zoom
71 width = (week_f + 6 <= @date_to) ? 7 * zoom : (@date_to - week_f + 1) * zoom
72 pdf.SetY(y_start + header_heigth)
72 pdf.SetY(y_start + header_heigth)
73 pdf.SetX(left)
73 pdf.SetX(left)
74 pdf.Cell(width, height, (width >= 5 ? week_f.cweek.to_s : ""), "LTR", 0, "C")
74 pdf.Cell(width, height, (width >= 5 ? week_f.cweek.to_s : ""), "LTR", 0, "C")
75 left = left + width
75 left = left + width
76 week_f = week_f+7
76 week_f = week_f+7
77 end
77 end
78 end
78 end
79
79
80 #
80 #
81 # Days headers
81 # Days headers
82 #
82 #
83 if show_days
83 if show_days
84 left = subject_width
84 left = subject_width
85 height = header_heigth
85 height = header_heigth
86 wday = @date_from.cwday
86 wday = @date_from.cwday
87 pdf.SetFontStyle('B',7)
87 pdf.SetFontStyle('B',7)
88 (@date_to - @date_from + 1).to_i.times do
88 (@date_to - @date_from + 1).to_i.times do
89 width = zoom
89 width = zoom
90 pdf.SetY(y_start + 2 * header_heigth)
90 pdf.SetY(y_start + 2 * header_heigth)
91 pdf.SetX(left)
91 pdf.SetX(left)
92 pdf.Cell(width, height, day_name(wday)[0,1], "LTR", 0, "C")
92 pdf.Cell(width, height, day_name(wday).first, "LTR", 0, "C")
93 left = left + width
93 left = left + width
94 wday = wday + 1
94 wday = wday + 1
95 wday = 1 if wday > 7
95 wday = 1 if wday > 7
96 end
96 end
97 end
97 end
98
98
99 pdf.SetY(y_start)
99 pdf.SetY(y_start)
100 pdf.SetX(15)
100 pdf.SetX(15)
101 pdf.Cell(subject_width+g_width-15, headers_heigth, "", 1)
101 pdf.Cell(subject_width+g_width-15, headers_heigth, "", 1)
102
102
103
103
104 #
104 #
105 # Tasks
105 # Tasks
106 #
106 #
107 top = headers_heigth + y_start
107 top = headers_heigth + y_start
108 pdf.SetFontStyle('B',7)
108 pdf.SetFontStyle('B',7)
109 @events.each do |i|
109 @events.each do |i|
110 pdf.SetY(top)
110 pdf.SetY(top)
111 pdf.SetX(15)
111 pdf.SetX(15)
112
112
113 if i.is_a? Issue
113 if i.is_a? Issue
114 pdf.Cell(subject_width-15, 5, "#{i.tracker.name} #{i.id}: #{i.subject}".sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)'), "LR")
114 pdf.Cell(subject_width-15, 5, "#{i.tracker.name} #{i.id}: #{i.subject}".sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)'), "LR")
115 else
115 else
116 pdf.Cell(subject_width-15, 5, "#{l(:label_version)}: #{i.name}", "LR")
116 pdf.Cell(subject_width-15, 5, "#{l(:label_version)}: #{i.name}", "LR")
117 end
117 end
118
118
119 pdf.SetY(top)
119 pdf.SetY(top)
120 pdf.SetX(subject_width)
120 pdf.SetX(subject_width)
121 pdf.Cell(g_width, 5, "", "LR")
121 pdf.Cell(g_width, 5, "", "LR")
122
122
123 pdf.SetY(top+1.5)
123 pdf.SetY(top+1.5)
124
124
125 if i.is_a? Issue
125 if i.is_a? Issue
126 i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
126 i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
127 i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
127 i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
128
128
129 i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
129 i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
130 i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
130 i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
131 i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )
131 i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )
132
132
133 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
133 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
134
134
135 i_left = ((i_start_date - @date_from)*zoom)
135 i_left = ((i_start_date - @date_from)*zoom)
136 i_width = ((i_end_date - i_start_date + 1)*zoom)
136 i_width = ((i_end_date - i_start_date + 1)*zoom)
137 d_width = ((i_done_date - i_start_date)*zoom)
137 d_width = ((i_done_date - i_start_date)*zoom)
138 l_width = ((i_late_date - i_start_date+1)*zoom) if i_late_date
138 l_width = ((i_late_date - i_start_date+1)*zoom) if i_late_date
139 l_width ||= 0
139 l_width ||= 0
140
140
141 pdf.SetX(subject_width + i_left)
141 pdf.SetX(subject_width + i_left)
142 pdf.SetFillColor(200,200,200)
142 pdf.SetFillColor(200,200,200)
143 pdf.Cell(i_width, 2, "", 0, 0, "", 1)
143 pdf.Cell(i_width, 2, "", 0, 0, "", 1)
144
144
145 if l_width > 0
145 if l_width > 0
146 pdf.SetY(top+1.5)
146 pdf.SetY(top+1.5)
147 pdf.SetX(subject_width + i_left)
147 pdf.SetX(subject_width + i_left)
148 pdf.SetFillColor(255,100,100)
148 pdf.SetFillColor(255,100,100)
149 pdf.Cell(l_width, 2, "", 0, 0, "", 1)
149 pdf.Cell(l_width, 2, "", 0, 0, "", 1)
150 end
150 end
151 if d_width > 0
151 if d_width > 0
152 pdf.SetY(top+1.5)
152 pdf.SetY(top+1.5)
153 pdf.SetX(subject_width + i_left)
153 pdf.SetX(subject_width + i_left)
154 pdf.SetFillColor(100,100,255)
154 pdf.SetFillColor(100,100,255)
155 pdf.Cell(d_width, 2, "", 0, 0, "", 1)
155 pdf.Cell(d_width, 2, "", 0, 0, "", 1)
156 end
156 end
157
157
158 pdf.SetY(top+1.5)
158 pdf.SetY(top+1.5)
159 pdf.SetX(subject_width + i_left + i_width)
159 pdf.SetX(subject_width + i_left + i_width)
160 pdf.Cell(30, 2, "#{i.status.name} #{i.done_ratio}%")
160 pdf.Cell(30, 2, "#{i.status.name} #{i.done_ratio}%")
161 else
161 else
162 i_left = ((i.start_date - @date_from)*zoom)
162 i_left = ((i.start_date - @date_from)*zoom)
163
163
164 pdf.SetX(subject_width + i_left)
164 pdf.SetX(subject_width + i_left)
165 pdf.SetFillColor(50,200,50)
165 pdf.SetFillColor(50,200,50)
166 pdf.Cell(2, 2, "", 0, 0, "", 1)
166 pdf.Cell(2, 2, "", 0, 0, "", 1)
167
167
168 pdf.SetY(top+1.5)
168 pdf.SetY(top+1.5)
169 pdf.SetX(subject_width + i_left + 3)
169 pdf.SetX(subject_width + i_left + 3)
170 pdf.Cell(30, 2, "#{i.name}")
170 pdf.Cell(30, 2, "#{i.name}")
171 end
171 end
172
172
173
173
174 top = top + 5
174 top = top + 5
175 pdf.SetDrawColor(200, 200, 200)
175 pdf.SetDrawColor(200, 200, 200)
176 pdf.Line(15, top, subject_width+g_width, top)
176 pdf.Line(15, top, subject_width+g_width, top)
177 if pdf.GetY() > 180
177 if pdf.GetY() > 180
178 pdf.AddPage("L")
178 pdf.AddPage("L")
179 top = 20
179 top = 20
180 pdf.Line(15, top, subject_width+g_width, top)
180 pdf.Line(15, top, subject_width+g_width, top)
181 end
181 end
182 pdf.SetDrawColor(0, 0, 0)
182 pdf.SetDrawColor(0, 0, 0)
183 end
183 end
184
184
185 pdf.Line(15, top, subject_width+g_width, top)
185 pdf.Line(15, top, subject_width+g_width, top)
186
186
187 %>
187 %>
188 <%= pdf.Output %> No newline at end of file
188 <%= pdf.Output %>
@@ -1,239 +1,239
1 <div class="contextual">
1 <div class="contextual">
2 <%= l(:label_export_to) %>
2 <%= l(:label_export_to) %>
3 <%= link_to 'PDF', {:zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects], :output => 'pdf'}, :class => 'icon icon-pdf' %>
3 <%= link_to 'PDF', {:zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects], :output => 'pdf'}, :class => 'icon icon-pdf' %>
4 </div>
4 </div>
5
5
6 <h2><%= l(:label_gantt) %></h2>
6 <h2><%= l(:label_gantt) %></h2>
7
7
8 <% form_tag do %>
8 <% form_tag do %>
9 <table width="100%">
9 <table width="100%">
10 <tr>
10 <tr>
11 <td align="left">
11 <td align="left">
12 <input type="text" name="months" size="2" value="<%= @months %>" />
12 <input type="text" name="months" size="2" value="<%= @months %>" />
13 <%= l(:label_months_from) %>
13 <%= l(:label_months_from) %>
14 <%= select_month(@month_from, :prefix => "month", :discard_type => true) %>
14 <%= select_month(@month_from, :prefix => "month", :discard_type => true) %>
15 <%= select_year(@year_from, :prefix => "year", :discard_type => true) %>
15 <%= select_year(@year_from, :prefix => "year", :discard_type => true) %>
16 <%= hidden_field_tag 'zoom', @zoom %>
16 <%= hidden_field_tag 'zoom', @zoom %>
17 <%= submit_tag l(:button_submit), :class => "button-small" %>
17 <%= submit_tag l(:button_submit), :class => "button-small" %>
18 </td>
18 </td>
19 <td>
19 <td>
20 <%= toggle_link l(:label_options), "trackerselect" %>
20 <%= toggle_link l(:label_options), "trackerselect" %>
21 <div id="trackerselect" class="rightbox overlay" style="width:140px; display: none;">
21 <div id="trackerselect" class="rightbox overlay" style="width:140px; display: none;">
22 <p><strong><%=l(:label_tracker_plural)%></strong></p>
22 <p><strong><%=l(:label_tracker_plural)%></strong></p>
23 <% @trackers.each do |tracker| %>
23 <% @trackers.each do |tracker| %>
24 <%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %>
24 <%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %>
25 <%= tracker.name %><br />
25 <%= tracker.name %><br />
26 <% end %>
26 <% end %>
27 <% if @project.children.any? %>
27 <% if @project.children.any? %>
28 <p><strong><%=l(:label_subproject_plural)%></strong></p>
28 <p><strong><%=l(:label_subproject_plural)%></strong></p>
29 <%= check_box_tag "with_subprojects", 1, params[:with_subprojects] %> <%= l(:general_text_Yes) %>
29 <%= check_box_tag "with_subprojects", 1, params[:with_subprojects] %> <%= l(:general_text_Yes) %>
30 <% end %>
30 <% end %>
31 <p><center><%= submit_tag l(:button_apply), :class => 'button-small' %></center></p>
31 <p><center><%= submit_tag l(:button_apply), :class => 'button-small' %></center></p>
32 </div>
32 </div>
33 </td>
33 </td>
34 <td align="right">
34 <td align="right">
35 <%= if @zoom < 4
35 <%= if @zoom < 4
36 link_to image_tag('zoom_in.png'), {:zoom => (@zoom+1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects]}
36 link_to image_tag('zoom_in.png'), {:zoom => (@zoom+1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects]}
37 else
37 else
38 image_tag 'zoom_in_g.png'
38 image_tag 'zoom_in_g.png'
39 end %>
39 end %>
40 <%= if @zoom > 1
40 <%= if @zoom > 1
41 link_to image_tag('zoom_out.png'),{:zoom => (@zoom-1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects]}
41 link_to image_tag('zoom_out.png'),{:zoom => (@zoom-1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects]}
42 else
42 else
43 image_tag 'zoom_out_g.png'
43 image_tag 'zoom_out_g.png'
44 end %>
44 end %>
45 </td>
45 </td>
46 </tr>
46 </tr>
47 </table>
47 </table>
48 <% end %>
48 <% end %>
49
49
50 <% zoom = 1
50 <% zoom = 1
51 @zoom.times { zoom = zoom * 2 }
51 @zoom.times { zoom = zoom * 2 }
52
52
53 subject_width = 330
53 subject_width = 330
54 header_heigth = 18
54 header_heigth = 18
55
55
56 headers_height = header_heigth
56 headers_height = header_heigth
57 show_weeks = false
57 show_weeks = false
58 show_days = false
58 show_days = false
59
59
60 if @zoom >1
60 if @zoom >1
61 show_weeks = true
61 show_weeks = true
62 headers_height = 2*header_heigth
62 headers_height = 2*header_heigth
63 if @zoom > 2
63 if @zoom > 2
64 show_days = true
64 show_days = true
65 headers_height = 3*header_heigth
65 headers_height = 3*header_heigth
66 end
66 end
67 end
67 end
68
68
69 g_width = (@date_to - @date_from + 1)*zoom
69 g_width = (@date_to - @date_from + 1)*zoom
70 g_height = [(20 * @events.length + 6)+150, 206].max
70 g_height = [(20 * @events.length + 6)+150, 206].max
71 t_height = g_height + headers_height
71 t_height = g_height + headers_height
72 %>
72 %>
73
73
74 <table width="100%" style="border:0; border-collapse: collapse;">
74 <table width="100%" style="border:0; border-collapse: collapse;">
75 <tr>
75 <tr>
76 <td style="width:<%= subject_width %>px;">
76 <td style="width:<%= subject_width %>px;">
77
77
78 <div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width + 1 %>px;">
78 <div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width + 1 %>px;">
79 <div style="right:-2px;width:<%= subject_width %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"></div>
79 <div style="right:-2px;width:<%= subject_width %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"></div>
80 <div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" class="gantt_hdr"></div>
80 <div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" class="gantt_hdr"></div>
81 <%
81 <%
82 #
82 #
83 # Tasks subjects
83 # Tasks subjects
84 #
84 #
85 top = headers_height + 8
85 top = headers_height + 8
86 @events.each do |i| %>
86 @events.each do |i| %>
87 <div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;"><small>
87 <div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;"><small>
88 <% if i.is_a? Issue %>
88 <% if i.is_a? Issue %>
89 <%= link_to_issue i %><%= " (#{i.project.name})" unless @project && @project == i.project %>:
89 <%= link_to_issue i %><%= " (#{i.project.name})" unless @project && @project == i.project %>:
90 <%=h i.subject %>
90 <%=h i.subject %>
91 <% else %>
91 <% else %>
92 <strong><%= "#{l(:label_version)}: #{i.name}" %></strong>
92 <strong><%= "#{l(:label_version)}: #{i.name}" %></strong>
93 <% end %>
93 <% end %>
94 </small></div>
94 </small></div>
95 <% top = top + 20
95 <% top = top + 20
96 end %>
96 end %>
97 </div>
97 </div>
98 </td>
98 </td>
99 <td>
99 <td>
100
100
101 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;">
101 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;">
102 <div style="width:<%= g_width-1 %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr">&nbsp;</div>
102 <div style="width:<%= g_width-1 %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr">&nbsp;</div>
103 <%
103 <%
104 #
104 #
105 # Months headers
105 # Months headers
106 #
106 #
107 month_f = @date_from
107 month_f = @date_from
108 left = 0
108 left = 0
109 height = (show_weeks ? header_heigth : header_heigth + g_height)
109 height = (show_weeks ? header_heigth : header_heigth + g_height)
110 @months.times do
110 @months.times do
111 width = ((month_f >> 1) - month_f) * zoom - 1
111 width = ((month_f >> 1) - month_f) * zoom - 1
112 %>
112 %>
113 <div style="left:<%= left %>px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
113 <div style="left:<%= left %>px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
114 <%= link_to "#{month_f.year}-#{month_f.month}", { :year => month_f.year, :month => month_f.month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] }, :title => "#{month_name(month_f.month)} #{month_f.year}"%>
114 <%= link_to "#{month_f.year}-#{month_f.month}", { :year => month_f.year, :month => month_f.month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] }, :title => "#{month_name(month_f.month)} #{month_f.year}"%>
115 </div>
115 </div>
116 <%
116 <%
117 left = left + width + 1
117 left = left + width + 1
118 month_f = month_f >> 1
118 month_f = month_f >> 1
119 end %>
119 end %>
120
120
121 <%
121 <%
122 #
122 #
123 # Weeks headers
123 # Weeks headers
124 #
124 #
125 if show_weeks
125 if show_weeks
126 left = 0
126 left = 0
127 height = (show_days ? header_heigth-1 : header_heigth-1 + g_height)
127 height = (show_days ? header_heigth-1 : header_heigth-1 + g_height)
128 if @date_from.cwday == 1
128 if @date_from.cwday == 1
129 # @date_from is monday
129 # @date_from is monday
130 week_f = @date_from
130 week_f = @date_from
131 else
131 else
132 # find next monday after @date_from
132 # find next monday after @date_from
133 week_f = @date_from + (7 - @date_from.cwday + 1)
133 week_f = @date_from + (7 - @date_from.cwday + 1)
134 width = (7 - @date_from.cwday + 1) * zoom-1
134 width = (7 - @date_from.cwday + 1) * zoom-1
135 %>
135 %>
136 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">&nbsp;</div>
136 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">&nbsp;</div>
137 <%
137 <%
138 left = left + width+1
138 left = left + width+1
139 end %>
139 end %>
140 <%
140 <%
141 while week_f <= @date_to
141 while week_f <= @date_to
142 width = (week_f + 6 <= @date_to) ? 7 * zoom -1 : (@date_to - week_f + 1) * zoom-1
142 width = (week_f + 6 <= @date_to) ? 7 * zoom -1 : (@date_to - week_f + 1) * zoom-1
143 %>
143 %>
144 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
144 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
145 <small><%= week_f.cweek if width >= 16 %></small>
145 <small><%= week_f.cweek if width >= 16 %></small>
146 </div>
146 </div>
147 <%
147 <%
148 left = left + width+1
148 left = left + width+1
149 week_f = week_f+7
149 week_f = week_f+7
150 end
150 end
151 end %>
151 end %>
152
152
153 <%
153 <%
154 #
154 #
155 # Days headers
155 # Days headers
156 #
156 #
157 if show_days
157 if show_days
158 left = 0
158 left = 0
159 height = g_height + header_heigth - 1
159 height = g_height + header_heigth - 1
160 wday = @date_from.cwday
160 wday = @date_from.cwday
161 (@date_to - @date_from + 1).to_i.times do
161 (@date_to - @date_from + 1).to_i.times do
162 width = zoom - 1
162 width = zoom - 1
163 %>
163 %>
164 <div style="left:<%= left %>px;top:37px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %>" class="gantt_hdr">
164 <div style="left:<%= left %>px;top:37px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %>" class="gantt_hdr">
165 <%= day_name(wday)[0,1] %>
165 <%= day_name(wday).first %>
166 </div>
166 </div>
167 <%
167 <%
168 left = left + width+1
168 left = left + width+1
169 wday = wday + 1
169 wday = wday + 1
170 wday = 1 if wday > 7
170 wday = 1 if wday > 7
171 end
171 end
172 end %>
172 end %>
173
173
174 <%
174 <%
175 #
175 #
176 # Today red line
176 # Today red line
177 #
177 #
178 if Date.today >= @date_from and Date.today <= @date_to %>
178 if Date.today >= @date_from and Date.today <= @date_to %>
179 <div style="position: absolute;height:<%= g_height %>px;top:<%= headers_height + 1 %>px;left:<%= ((Date.today-@date_from+1)*zoom).floor()-1 %>px;width:10px;border-left: 1px dashed red;">&nbsp;</div>
179 <div style="position: absolute;height:<%= g_height %>px;top:<%= headers_height + 1 %>px;left:<%= ((Date.today-@date_from+1)*zoom).floor()-1 %>px;width:10px;border-left: 1px dashed red;">&nbsp;</div>
180 <% end %>
180 <% end %>
181
181
182 <%
182 <%
183 #
183 #
184 # Tasks
184 # Tasks
185 #
185 #
186 top = headers_height + 10
186 top = headers_height + 10
187 @events.each do |i|
187 @events.each do |i|
188 if i.is_a? Issue
188 if i.is_a? Issue
189 i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
189 i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
190 i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
190 i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
191
191
192 i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
192 i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
193 i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
193 i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
194 i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )
194 i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )
195
195
196 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
196 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
197
197
198 i_left = ((i_start_date - @date_from)*zoom).floor
198 i_left = ((i_start_date - @date_from)*zoom).floor
199 i_width = ((i_end_date - i_start_date + 1)*zoom).floor - 2 # total width of the issue (- 2 for left and right borders)
199 i_width = ((i_end_date - i_start_date + 1)*zoom).floor - 2 # total width of the issue (- 2 for left and right borders)
200 d_width = ((i_done_date - i_start_date)*zoom).floor - 2 # done width
200 d_width = ((i_done_date - i_start_date)*zoom).floor - 2 # done width
201 l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor - 2 : 0 # delay width
201 l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor - 2 : 0 # delay width
202 %>
202 %>
203 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;" class="task task_todo">&nbsp;</div>
203 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;" class="task task_todo">&nbsp;</div>
204 <% if l_width > 0 %>
204 <% if l_width > 0 %>
205 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= l_width %>px;" class="task task_late">&nbsp;</div>
205 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= l_width %>px;" class="task task_late">&nbsp;</div>
206 <% end %>
206 <% end %>
207 <% if d_width > 0 %>
207 <% if d_width > 0 %>
208 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= d_width %>px;" class="task task_done">&nbsp;</div>
208 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= d_width %>px;" class="task task_done">&nbsp;</div>
209 <% end %>
209 <% end %>
210 <div style="top:<%= top %>px;left:<%= i_left + i_width + 5 %>px;background:#fff;" class="task">
210 <div style="top:<%= top %>px;left:<%= i_left + i_width + 5 %>px;background:#fff;" class="task">
211 <%= i.status.name %>
211 <%= i.status.name %>
212 <%= (i.done_ratio).to_i %>%
212 <%= (i.done_ratio).to_i %>%
213 </div>
213 </div>
214 <% # === tooltip === %>
214 <% # === tooltip === %>
215 <div class="tooltip" style="position: absolute;top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;height:12px;">
215 <div class="tooltip" style="position: absolute;top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;height:12px;">
216 <span class="tip">
216 <span class="tip">
217 <%= render :partial => "issues/tooltip", :locals => { :issue => i }%>
217 <%= render :partial => "issues/tooltip", :locals => { :issue => i }%>
218 </span></div>
218 </span></div>
219 <% else
219 <% else
220 i_left = ((i.start_date - @date_from)*zoom).floor
220 i_left = ((i.start_date - @date_from)*zoom).floor
221 %>
221 %>
222 <div style="top:<%= top %>px;left:<%= i_left %>px;width:15px;" class="task milestone">&nbsp;</div>
222 <div style="top:<%= top %>px;left:<%= i_left %>px;width:15px;" class="task milestone">&nbsp;</div>
223 <div style="top:<%= top %>px;left:<%= i_left + 12 %>px;background:#fff;" class="task">
223 <div style="top:<%= top %>px;left:<%= i_left + 12 %>px;background:#fff;" class="task">
224 <strong><%= i.name %></strong>
224 <strong><%= i.name %></strong>
225 </div>
225 </div>
226 <% end %>
226 <% end %>
227 <% top = top + 20
227 <% top = top + 20
228 end %>
228 end %>
229 </div>
229 </div>
230 </td>
230 </td>
231 </tr>
231 </tr>
232 </table>
232 </table>
233
233
234 <table width="100%">
234 <table width="100%">
235 <tr>
235 <tr>
236 <td align="left"><%= link_to ('&#171; ' + l(:label_previous)), :year => (@date_from << @months).year, :month => (@date_from << @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %></td>
236 <td align="left"><%= link_to ('&#171; ' + l(:label_previous)), :year => (@date_from << @months).year, :month => (@date_from << @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %></td>
237 <td align="right"><%= link_to (l(:label_next) + ' &#187;'), :year => (@date_from >> @months).year, :month => (@date_from >> @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %></td>
237 <td align="right"><%= link_to (l(:label_next) + ' &#187;'), :year => (@date_from >> @months).year, :month => (@date_from >> @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %></td>
238 </tr>
238 </tr>
239 </table> No newline at end of file
239 </table>
General Comments 0
You need to be logged in to leave comments. Login now