fix top subtotals on refund reports
[freeside.git] / httemplate / search / elements / grouped-search.html
1 <%doc>
2
3 <& elements/grouped-search/html,
4
5    # required
6   'title'         => 'Page title',
7   
8   'name_singular' => 'item',
9
10   'query' => {
11                 'table'     => 'tablename',
12                 'hashref'   => { 'field' => 'value', ... }, # optional
13                 'select'    => '*',
14                 'addl_from' => '',
15                 'extra_sql' => '',
16                 #'order_by' is not allowed
17              },
18   'group_column' => 'classnum', # must be a single field
19   # 'group_table' => 'mytable', # optional; defaults to the one in the query
20   'group_label'  => 'classname',
21   'subtotal' => { amount => 'sum(amount)', ... }
22     # The subtotal row will be generated as an FS::* object of the same type
23     # as all the detail rows.
24     # The only fields present will be the grouping column and any subtotals 
25     # defined in 'subtotal'. Key is a field name (in the FS::* object), 
26     # value is an SQL aggregate expression.
27
28     # How to display that object: arrayref of literal strings or coderefs
29     # (the subtotal object will be passed). These will be placed in table
30     # cells, and can contain HTML.
31   'subtotal_row' =>
32     [ 'Total'
33       sub { sprintf('%.2f', $_[0]->amount) },
34     ],
35
36   'order_by' => '_date', # SQL ordering expression for the detail rows
37
38   'header' => [ ... ], # per search.html
39   'fields' => [ ... ],
40
41 &>
42 </%doc>
43 <%init>
44 my $type = 'html';
45 if ($cgi->param('type') =~ /^(html|html-print|xls|deposit_slip)$/) {
46   $type = $1;
47 }
48 </%init>
49 <& "grouped-search/$type", @_ &>