report.html.tmpl 6.06 KB
Newer Older
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
[%# 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>
  #%]
  
[%# INTERFACE:
  # 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.
  # tbl_names: array. List of values for the field being plotted as tables.
  # time: integer. Seconds since the epoch.
  # data: <depends on format>. Data to plot. 
  # format: string. Format of the individual reports.
  # width: integer. For image charts, height of the image.
  # height: integer. For image charts, width of the image.
31
  # imagebase: string. Base URL for chart image.
32 33 34 35 36 37 38 39
  # switchbase: string. Base URL for format switching.
  # cumulate: boolean. For bar/line charts, whether to cumulate data sets.
  #%]

[% DEFAULT width = 600
           height = 350 
%]

40 41 42 43
[% IF min_width AND width < min_width %]
  [% width = min_width %]
[% END %]

44 45 46 47 48
[%# We ignore row_field for pie charts %]
[% IF format == "pie" %]
  [% row_field = "" %]
[% END %]

49
[% PROCESS "global/field-descs.none.tmpl" %]
50 51 52 53

[% 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 %]
54
[% switchbase     = switchbase FILTER html %]
55 56 57

[% title = BLOCK %]
  Report: 
58 59 60
  [% IF tbl_field %]
    [% tbl_field_disp FILTER html %]
  [% END %]
61
  [% " / " IF tbl_field AND (col_field OR row_field) %]
62 63 64
  [% IF row_field %]
    [% row_field_disp FILTER html %]
  [% END %]
65
  [% " / " IF col_field AND row_field %]
66
  [% col_field_disp FILTER html %]
67 68
[% END %]

69 70
[% time = time FILTER time('%Y-%m-%d %H:%M:%S') FILTER html %]

71 72 73 74 75 76 77 78
[% 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 */
  "
79
  header_addl_info = time
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
%]

[% IF debug %]
  <p>[% query FILTER html %]</p>
[% END %]

<div align="center">

  [% FOREACH tbl = tbl_names %]    
    [% IF tbl == "-total-" %]
      [% tbl_disp = "Total" %]
    [% ELSE %]
      [% tbl_disp = tbl %]
    [% END %]

    [% IF format == "table" %]
      [% PROCESS "reports/report-table.html.tmpl" %]
    [% ELSE %]
      [% IF tbl %]
99
        <h2>[% tbl_disp FILTER email FILTER html %]</h2>
100 101
      [% END %]
      
102
      [% imageurl = BLOCK %]report.cgi?[% imagebase FILTER html %]&amp;format=
103
        [% format FILTER url_quote %]&amp;ctype=png&amp;action=plot&amp;
104 105 106 107 108 109 110 111 112 113
        [% IF tbl_field %]
          [% IF tbl != "-total-" %]
            [% tbl_field FILTER url_quote %]=[% tbl FILTER url_quote %]&amp;
          [% ELSE %]
            [% FOREACH tblname = tbl_names %]
              [% IF tblname != "-total-" %]
                [% tbl_field FILTER url_quote %]=[% tblname FILTER url_quote %]&amp;
              [% END %]
            [% END %]
          [% END %]
114 115 116
        [% END %]width=[% width %]&amp;height=[% height %]      
      [% END %]
      
117 118
      <img alt="Graphical report results" src="[% imageurl %]"
        width="[% width %]" height="[% height %]">
119 120 121 122 123 124 125 126 127 128 129 130
    [% END %]
    <br>
  [% END %]  

  <table>
    <tr>
      <td>
        [% formats = [ { name => "pie",   description => "Pie" },
                       { name => "bar",   description => "Bar" },
                       { name => "line",  description => "Line" },
                       { name => "table", description => "Table" } ] %]

131 132
        [% formaturl = "report.cgi?$switchbase&amp;width=$width" _ 
                       "&amp;height=$height&amp;action=wrap" %]
133
        [% FOREACH other_format = formats %]
134
          [% NEXT IF other_format.name == "pie" AND row_field AND col_field %]
135
          [% UNLESS other_format.name == format %]
136
            <a href="[% formaturl %]&amp;format=[% other_format.name %]">
137
          [% END %]
138
          [% other_format.description FILTER html %]
139 140
          [% "</a>" UNLESS other_format.name == format %] | 
        [% END %]
141
        <a href="[% formaturl %]&amp;ctype=csv&amp;format=table">CSV</a> 
142 143 144 145 146 147 148
      </td>
      
      [% IF format != "table" %]
        <td>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </td>

149 150 151
        [% sizeurl = BLOCK %]report.cgi?
          [% switchbase %]&amp;action=wrap&amp;format=
          [% format FILTER html %][% END %]
152
        <td align="center">
153
          <a href="[% sizeurl %]&amp;width=[% width %]&amp;height=
154
                   [% height + 100 %]">Taller</a><br>
155
          <a href="[% sizeurl %]&amp;width=[% width - 100 %]&amp;height=
156
                   [% height %]">Thinner</a> * 
157
          <a href="[% sizeurl %]&amp;width=[% width + 100 %]&amp;height=
158
                   [% height %]">Fatter</a>&nbsp;&nbsp;&nbsp;&nbsp;<br>
159
          <a href="[% sizeurl %]&amp;width=[% width %]&amp;height=
160 161 162
                   [% height - 100 %]">Shorter</a><br>
        </td>
      [% END %]
163
    </tr>
164 165 166 167
  </table>

  <p>
    [% IF format == "table" %]
168
      <a href="query.cgi?[% switchbase %]&amp;format=report-table">Edit 
169 170
      this report</a>
    [% ELSE %]
171 172
      <a href="query.cgi?[% switchbase %]&amp;chart_format=
        [% format %]&amp;format=report-graph&amp;cumulate=[% cumulate %]">
173 174
        Edit this report
      </a>
175 176 177 178 179 180
    [% END %]
  </p>
 
</div>

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