X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fsearch%2Felements%2Fsearch.html;h=60548e28edffb2bfbc6287c4f66e0e01625e48ea;hp=7b1a515dfa21df9fd77f41155a0593ca8ecc5b84;hb=fc263806f5e475559a0c4cfdb70a5f1cefe0ffa3;hpb=9f8e50c683598d9797e8babf4a21db4f6a65a1d8 diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index 7b1a515df..60548e28e 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -2,30 +2,22 @@ Example: - include( 'elements/search.html', + <& elements/search.html, + + ### + # required + ### - # basic options, required 'title' => 'Page title', - + 'name_singular' => 'item', #singular name for the records returned #OR# # (preferred, will be pluralized automatically) 'name' => 'items', #plural name for the records returned # (deprecated, will be singularlized # simplisticly) - - # some HTML callbacks... - 'menubar' => '', #menubar arrayref - 'html_init' => '', #after the header/menubar and before the pager - 'html_form' => '', #after the pager, right before the results - # (only shown if there are results) - # (use this for any form-opening tag rather than - # html_init, to avoid a nested form) - 'html_foot' => '', #at the bottom - 'html_posttotal' => '', #at the bottom - # (these three can be strings or coderefs) - - - #literal SQL query string (deprecated?) or qsearch hashref, required + + #literal SQL query string (corner cases only) or qsearch hashref or arrayref + #of qsearch hashrefs for a union of qsearches 'query' => { 'table' => 'tablename', #everything else is optional... @@ -38,533 +30,195 @@ Example: 'addl_from' => '', #'LEFT JOIN othertable USING ( key )', 'extra_sql' => '', #'AND otherstuff', #'WHERE onlystuff', 'order_by' => 'ORDER BY something', - + }, # "select * from tablename"; - #required unless 'query' is an SQL query string (shouldn't be...) + #required (now even if 'query' is an SQL query string) 'count_query' => 'SELECT COUNT(*) FROM tablename', - - 'count_addl' => [], #additional count fields listref of sprintf strings - # [ $money_char.'%.2f total paid', ], - + + ### + # recommended / common + ### + #listref of column labels,
- - + 'redirect' => sub { my( $record, $cgi ) = @_; + [ popurl(2).'view/item.html', 'primary_key' ]; + }, - | + #redirect if there's no items + # scalar URL or a coderef that returns a URL + 'redirect_empty' => sub { my( $cgi ) = @_; + popurl(2).'view/item.html'; + }, -% unless ( $opt{'disable_download'} || $type eq 'html-print' ) { + ### + # optional + ### -
+ # some HTML callbacks...
+ 'menubar' => '', #menubar arrayref
+ 'html_init' => '', #after the header/menubar and before the pager
+ 'html_form' => '', #after the pager, right before the results
+ # (only shown if there are results)
+ # (use this for any form-opening tag rather than
+ # html_init, to avoid a nested form)
+ 'html_foot' => '', #at the bottom
+ 'html_posttotal' => '', #at the bottom
+ # (these three can be strings or coderefs)
- Download full results + 'count_addl' => [], #additional count fields listref of sprintf strings or coderefs + # [ $money_char.'%.2f total paid', ], -% $cgi->param('_type', "$xlsname.xls" ); - as Excel spreadsheet + #second (smaller) header line, currently only for HTML + 'header2 => [ '#', + 'Item', + { 'label' => 'Another Item', -% $cgi->param('_type', 'csv'); - as CSV file + }, + ], -% $cgi->param('_type', 'html-print'); - as printable copy + #listref of column footers + 'footer' => [], - |
-% $cgi->param('_type', "html" );
-% }
+ #disabling things
+ 'disable_download' => '', # set true to hide the CSV/Excel download links
+ 'disable_total' => '', # set true to hide the total"
+ 'disable_maxselect' => '', # set true to disable record/page selection
+ 'disable_nonefound' => '', # set true to disable the "No matching Xs found"
+ # message
+ 'nohtmlheader' => '', # set true to remove the header and menu bar
+
+ #handling "disabled" fields in the records
+ 'disableable' => 1, # set set to 1 (or column position for "disabled"
+ # status col) to enable if this table has a "disabled"
+ # field, to hide disabled records & have
+ # "show disabled/hide disabled" links
+ #(can't be used with a literal query)
+ 'disabled_statuspos' => 3, #optional position (starting from 0) to insert
+ #a Status column when showing disabled records
+ #(query needs to be a qsearch hashref and
+ # header & fields need to be defined)
- |||||
+ # Agent Virtualization parameters:
+ # In this context, only available if your selected table has agentnum.
+ # You must also include agentnum as a SELECT column in your SQL query,
+ # or experience non-obvious problems
+ #
+ 'agent_virt' => 1, # set true if this search should be
+ # agent-virtualized
+ 'agent_null' => 1, # set true to view global records always
+ 'agent_null_right' => 'Access Right', # optional right to view global
+ # records
+ 'agent_null_right_link' => 'Access Right' # optional right to link to
+ # global records; defaults to
+ # same as agent_null_right
+ 'agent_pos' => 3, # optional position (starting from 0) to
+ # insert an Agent column (query needs to be a
+ # qsearch hashref and header & fields need to
+ # be defined)
+
+ # sort, link & display properties for fields
+
+ 'sort_fields' => [], #optional list of field names or SQL expressions for sorts
+
+ 'order_by_sql' => { #to keep complex SQL expressions out of cgi order_by value,
+ 'fieldname' => 'sql snippet', # maps fields/sort_fields values to sql snippets
+ }
-% my $pager = '';
-% unless ( $type eq 'html_print' ) {
+ #listref - each item is the empty string,
+ # or a listref of link and method name to append,
+ # or a listref of link and coderef to run and append
+ # or a coderef that returns such a listref
+ 'links' => [],
- <% $pager = include( '/elements/pager.html',
- 'offset' => $offset,
- 'num_rows' => scalar(@$rows),
- 'total' => $total,
- 'maxrecords' => $maxrecords,
- )
- %>
+ #listref - each item is the empty string,
+ # or a string onClick handler for the corresponding link
+ # or a coderef that returns string onClick handler
+ 'link_onclicks' => [],
- <% defined($opt{'html_form'})
- ? ( ref($opt{'html_form'})
- ? &{$opt{'html_form'}}()
- : $opt{'html_form'}
- )
- : ''
- %>
+ #one letter for each column, left/right/center/none
+ # or pass a listref with full values: [ 'left', 'right', 'center', '' ]
+ 'align' => 'lrc.',
-% }
+ #listrefs of ( scalars or coderefs )
+ # currently only HTML, maybe eventually Excel too
+ 'color' => [],
+ 'size' => [],
+ 'style' => [], # or , etc.
+ 'cell_style' => [], #STYLE= attribute of TR, very HTML-specific...
- <% include('/elements/table-grid.html') %>
+ # Excel-specific listref of ( hashrefs or coderefs )
+ # each hashref: http://search.cpan.org/dist/Spreadsheet-WriteExcel/lib/Spreadsheet/WriteExcel.pm#Format_methods_and_Format_properties
+ 'xls_format' => => [],
- <% $header %> |
-% }
-
|