summaryrefslogtreecommitdiffstats
path: root/template/en/default/reports/report-table.html.tmpl
blob: 9767f50301afce6dde2f0346706ad4246640c162 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
 <!-- 1.0@bugzilla.org -->
[%# The contents of this file are subject to the Mozilla Public
  # License Version 1.1 (the "License"); you may not use this file
  # except in compliance with the License. You may obtain a copy of
  # the License at http://www.mozilla.org/MPL/
  #
  # Software distributed under the License is distributed on an "AS
  # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  # implied. See the License for the specific language governing
  # rights and limitations under the License.
  #
  # The Original Code is the Bugzilla Bug Tracking System.
  #
  # The Initial Developer of the Original Code is Netscape Communications
  # Corporation. Portions created by Netscape are
  # Copyright (C) 1998 Netscape Communications Corporation. All
  # Rights Reserved.
  #
  # Contributor(s): Gervase Markham <gerv@gerv.net>
  #                 <rdean@cambianetworks.com>
  #%]

[%# INTERFACE:
  # querybase: The base query for this table, in URL form
  # query: The query for this table, in URL form
  # data: hash of hash of hash of numbers. Bug counts.
  # names: hash of hash of strings. Names of tables, rows and columns.
  # col_field: string. Name of the field being plotted as columns.
  # row_field: string. Name of the field being plotted as rows.
  # tbl_field: string. Name of the field being plotted as tables.
  #%]

[% PROCESS "global/field-descs.html.tmpl" %]

[% tbl_field_disp = field_descs.$tbl_field || tbl_field %]
[% col_field_disp = field_descs.$col_field || col_field %]
[% row_field_disp = field_descs.$row_field || row_field %]

[% title = BLOCK %]
  Report: 
  [% "$tbl_field_disp / " IF tbl_field %]
  [% "$col_field_disp / " IF col_field %]
  [% row_field_disp %]
[% END %]

[% PROCESS global/header.html.tmpl 
  style = "
    .t1     { background-color: #ffffff } /* white       */
    .t2     { background-color: #dfefff } /* light blue  */
    .t3     { background-color: #dddddd } /* grey        */
    .t4     { background-color: #c3d3ed } /* darker blue */
    .ttotal { background-color: #cfffdf } /* light green */
  "
%]

<div align="right">
  [% time2str("%Y-%m-%d %H:%M:%S", time) %]
</div>

[% tbl_names = names.tbl.keys.sort %]
[% col_names = names.col.keys.sort %]
[% row_names = names.row.keys.sort %]

[% total_name = "Total" %]

[% FOREACH tbl = tbl_names %]
  [% FOREACH row = row_names %]
    [% FOREACH col = col_names %]
      [% data.$tbl.$col.$row  = (data.$tbl.$col.$row || 0) %]
      
      [% IF tbl_field %]
        [%# Calculate values for the Total table %]
        [% data.$total_name.$col.$row = 
          (data.$total_name.$col.$row || 0) + data.$tbl.$col.$row %]
      [% END %]
    [% END %]
  [% END %]
[% END %]
  
[% IF tbl_field %]
  [% tbl_names.push(total_name) %]
[% END %]

<div align="center">

[% FOREACH tbl = tbl_names %]
  <table>
    [% IF tbl_field %]
      <tr>
        <td>
        </td>
        <td align="center">
          <h2>[% tbl FILTER html %]</h2>
        </td>
      </tr>
    [% END %]  
    <tr>
      <td>
      </td>
      <td align="center">
        <strong>[% col_field_disp FILTER html %]</strong>
      </td>
    </tr>

    <tr>
      <td valign="middle">
        <strong>[% row_field_disp FILTER html %]</strong>
      </td>
      <td>


[% classes = [ [ "t1", "t2" ] , [ "t3", "t4" ] ] %]
[% col_idx = 0 %]
[% row_idx = 0 %]
[% grand_total = 0 %]

<table border="1">
  [% IF col_field %]
    <tr>
      <td class="[% classes.$row_idx.$col_idx %]">
      </td>
      [% FOREACH col = col_names %]
        [% col_totals.$col = 0 %]
        [% NEXT IF col == "" %]
        
        [% col_idx = 1 - col_idx %]
        <td class="[% classes.$row_idx.$col_idx %]">
          [% col FILTER html %]
        </td>
      [% END %]
      <td class="ttotal">
        Total
      </td>
    </tr>
  [% END %]
  
  [% FOREACH row = row_names %]
    [% row_total = 0 %]
    
    [% row_idx = 1 - row_idx %]
    <tr>
      <td class="[% classes.$row_idx.$col_idx %]" align="right">
        [% row FILTER html %]
      </td>
      [% FOREACH col = col_names %]
        [% row_total = row_total + data.$tbl.$col.$row %]
        [% NEXT IF col == "" %]
        [% col_totals.$col = col_totals.$col + data.$tbl.$col.$row %]
        
        [% col_idx = 1 - col_idx %]
        <td class="[% classes.$row_idx.$col_idx %]" align="center">
          [% IF data.$tbl.$col.$row AND data.$tbl.$col.$row > 0 %]
            <a href="buglist.cgi?[% querybase FILTER html %]&amp;
              [% tbl_field FILTER url_quote %]=[% tbl FILTER url_quote %]&amp;
              [% row_field FILTER url_quote %]=[% row FILTER url_quote %]&amp;
              [% col_field FILTER url_quote %]=[% col FILTER url_quote %]">
              [% data.$tbl.$col.$row %]</a>
          [% ELSE %]
            .
          [% END %]
        </td>
      [% END %] 
      <td class="ttotal" align="right">
        <a href="buglist.cgi?[% querybase FILTER html %]&amp;
          [% tbl_field FILTER url_quote %]=[% tbl FILTER url_quote %]&amp;
          [% row_field FILTER url_quote %]=[% row FILTER url_quote %]">
        [% row_total %]</a>
        [% grand_total = grand_total + row_total %]
      </td>
    </tr>
  [% END %]
  
  <tr>
    [% row_idx = 1 - row_idx %]
    <td class="ttotal">
      Total
    </td>
    [% FOREACH col = col_names %]
      [% NEXT IF col == "" %]
      
      <td class="ttotal" align="center">
        <a href="buglist.cgi?[% querybase FILTER html %]&amp;
          [% tbl_field FILTER url_quote %]=[% tbl FILTER url_quote %]&amp;
          [% col_field FILTER url_quote %]=[% col FILTER url_quote %]">
        [% col_totals.$col %]</a>
      <strong>
      </td> 
    [% END %]
    <td class="ttotal" align="right">
      <strong>
        <a href="buglist.cgi?[% querybase FILTER html %]">[% grand_total %]</a>
      </strong>
    </td>
  </tr>
</table>
      
      
      </td>
    </tr>
  </table>
    
  <br>

[% END %]
  
  <a href="query.cgi?[% query FILTER html %]&amp;format=report-table">Edit this report</a>
</div>

<br>

[% PROCESS global/footer.html.tmpl %]