##// END OF EJS Templates
issue subjects modified on gantt pdf export...
Jean-Philippe Lang -
r55:9b2bd72e1f65
parent child
Show More
@@ -1,168 +1,168
1 1 <%
2 2 pdf=IfpdfHelper::IFPDF.new
3 3 pdf.AliasNbPages
4 4 pdf.footer_date = format_date(Date.today)
5 5 pdf.AddPage("L")
6 6 pdf.SetFont('Arial','B',12)
7 7 pdf.SetX(15)
8 8 pdf.Cell(70, 20, @project.name)
9 9 pdf.Ln
10 10 pdf.SetFont('Arial','B',9)
11 11
12 12 subject_width = 70
13 13 header_heigth = 5
14 14
15 15 headers_heigth = header_heigth
16 16 show_weeks = false
17 17 show_days = false
18 18
19 19 if @months < 7
20 20 show_weeks = true
21 21 headers_heigth = 2*header_heigth
22 22 if @months < 3
23 23 show_days = true
24 24 headers_heigth = 3*header_heigth
25 25 end
26 26 end
27 27
28 28 g_width = 210
29 29 zoom = (g_width) / (@date_to - @date_from + 1)
30 30 g_height = 120
31 31 t_height = g_height + headers_heigth
32 32
33 33 y_start = pdf.GetY
34 34
35 35
36 36 #
37 37 # Months headers
38 38 #
39 39 month_f = @date_from
40 40 left = subject_width
41 41 height = header_heigth
42 42 @months.times do
43 43 width = ((month_f >> 1) - month_f) * zoom
44 44 pdf.SetY(y_start)
45 45 pdf.SetX(left)
46 46 pdf.Cell(width, height, "#{month_f.year}-#{month_f.month}", "LTR", 0, "C")
47 47 left = left + width
48 48 month_f = month_f >> 1
49 49 end
50 50
51 51 #
52 52 # Weeks headers
53 53 #
54 54 if show_weeks
55 55 left = subject_width
56 56 height = header_heigth
57 57 if @date_from.cwday == 1
58 58 # @date_from is monday
59 59 week_f = @date_from
60 60 else
61 61 # find next monday after @date_from
62 62 week_f = @date_from + (7 - @date_from.cwday + 1)
63 63 width = (7 - @date_from.cwday + 1) * zoom-1
64 64 pdf.SetY(y_start + header_heigth)
65 65 pdf.SetX(left)
66 66 pdf.Cell(width + 1, height, "", "LTR")
67 67 left = left + width+1
68 68 end
69 69 while week_f < @date_to
70 70 width = (week_f + 6 <= @date_to) ? 7 * zoom : (@date_to - week_f + 1) * zoom
71 71 pdf.SetY(y_start + header_heigth)
72 72 pdf.SetX(left)
73 73 pdf.Cell(width, height, week_f.cweek.to_s, "LTR", 0, "C")
74 74 left = left + width
75 75 week_f = week_f+7
76 76 end
77 77 end
78 78
79 79 #
80 80 # Days headers
81 81 #
82 82 if show_days
83 83 left = subject_width
84 84 height = header_heigth
85 85 wday = @date_from.cwday
86 86 pdf.SetFont('Arial','B',7)
87 87 (@date_to - @date_from + 1).to_i.times do
88 88 width = zoom
89 89 pdf.SetY(y_start + 2 * header_heigth)
90 90 pdf.SetX(left)
91 91 pdf.Cell(width, height, day_name(wday)[0,1], "LTR", 0, "C")
92 92 left = left + width
93 93 wday = wday + 1
94 94 wday = 1 if wday > 7
95 95 end
96 96 end
97 97
98 98 pdf.SetY(y_start)
99 99 pdf.SetX(15)
100 100 pdf.Cell(subject_width+g_width-15, headers_heigth, "", 1)
101 101
102 102
103 103 #
104 104 # Tasks
105 105 #
106 106 top = headers_heigth + y_start
107 107 pdf.SetFont('Arial','B',7)
108 108 @issues.each do |i|
109 109 pdf.SetY(top)
110 110 pdf.SetX(15)
111 pdf.Cell(subject_width-15, 5, i.id.to_s + " " + 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 113 pdf.SetY(top)
114 114 pdf.SetX(subject_width)
115 115 pdf.Cell(g_width, 5, "", "LR")
116 116
117 117 i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
118 118 i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
119 119
120 120 i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
121 121 i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
122 122 i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )
123 123
124 124 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
125 125
126 126 i_left = ((i_start_date - @date_from)*zoom)
127 127 i_width = ((i_end_date - i_start_date + 1)*zoom)
128 128 d_width = ((i_done_date - i_start_date)*zoom)
129 129 l_width = ((i_late_date - i_start_date+1)*zoom) if i_late_date
130 130 l_width ||= 0
131 131
132 132 pdf.SetY(top+1.5)
133 133 pdf.SetX(subject_width + i_left)
134 134 pdf.SetFillColor(200,200,200)
135 135 pdf.Cell(i_width, 2, "", 0, 0, "", 1)
136 136
137 137 if l_width > 0
138 138 pdf.SetY(top+1.5)
139 139 pdf.SetX(subject_width + i_left)
140 140 pdf.SetFillColor(255,100,100)
141 141 pdf.Cell(l_width, 2, "", 0, 0, "", 1)
142 142 end
143 143 if d_width > 0
144 144 pdf.SetY(top+1.5)
145 145 pdf.SetX(subject_width + i_left)
146 146 pdf.SetFillColor(100,100,255)
147 147 pdf.Cell(d_width, 2, "", 0, 0, "", 1)
148 148 end
149 149
150 150 pdf.SetY(top+1.5)
151 151 pdf.SetX(subject_width + i_left + i_width)
152 152 pdf.Cell(30, 2, "#{i.status.name} #{i.done_ratio}%")
153 153
154 154 top = top + 5
155 155 pdf.SetDrawColor(200, 200, 200)
156 156 pdf.Line(15, top, subject_width+g_width, top)
157 157 if pdf.GetY() > 180
158 158 pdf.AddPage("L")
159 159 top = 20
160 160 pdf.Line(15, top, subject_width+g_width, top)
161 161 end
162 162 pdf.SetDrawColor(0, 0, 0)
163 163 end
164 164
165 165 pdf.Line(15, top, subject_width+g_width, top)
166 166
167 167 %>
168 168 <%= pdf.Output %> No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now