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