diff options
author | Mark Wells <mark@freeside.biz> | 2015-06-27 15:51:29 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2015-06-27 19:33:52 -0700 |
commit | 062f38f2f5d0da64c6fd0702d4df2e805473a1f5 (patch) | |
tree | ace3971025894ea6c0251f8a9ecd637c6cfe400e /httemplate/search/elements/grouped-search.html | |
parent | 68546df9b125f73764eda31f1dcb4e2c0555f859 (diff) |
reports with row grouping for payment/refund search, #25944
Diffstat (limited to 'httemplate/search/elements/grouped-search.html')
-rw-r--r-- | httemplate/search/elements/grouped-search.html | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/httemplate/search/elements/grouped-search.html b/httemplate/search/elements/grouped-search.html new file mode 100644 index 000000000..56fc88d38 --- /dev/null +++ b/httemplate/search/elements/grouped-search.html @@ -0,0 +1,49 @@ +<%doc> + +<& elements/grouped-search/html, + + # required + 'title' => 'Page title', + + 'name_singular' => 'item', + + 'query' => { + 'table' => 'tablename', + 'hashref' => { 'field' => 'value', ... }, # optional + 'select' => '*', + 'addl_from' => '', + 'extra_sql' => '', + #'order_by' is not allowed + }, + 'group_column' => 'classnum', # must be a single field + # 'group_table' => 'mytable', # optional; defaults to the one in the query + 'group_label' => 'classname', + 'subtotal' => { amount => 'sum(amount)', ... } + # The subtotal row will be generated as an FS::* object of the same type + # as all the detail rows. + # The only fields present will be the grouping column and any subtotals + # defined in 'subtotal'. Key is a field name (in the FS::* object), + # value is an SQL aggregate expression. + + # How to display that object: arrayref of literal strings or coderefs + # (the subtotal object will be passed). These will be placed in table + # cells, and can contain HTML. + 'subtotal_row' => + [ 'Total' + sub { sprintf('%.2f', $_[0]->amount) }, + ], + + 'order_by' => '_date', # SQL ordering expression for the detail rows + + 'header' => [ ... ], # per search.html + 'fields' => [ ... ], + +&> +</%doc> +<%init> +my $type = 'html'; +if ($cgi->param('type') =~ /^(html|html-print|xls)$/) { + $type = $1; +} +</%init> +<& "grouped-search/$type", @_ &> |