X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Felements%2Fselect-table.html;h=d86b7ee43433dc2699612d58aa7b6de03ccb433b;hp=36eb4e2119f5d6e1dac480804bd66c6fe65eae4e;hb=833cfe5c9938d33c3e6b97ed610c25a7afa6eb04;hpb=9608be1f5c73517fc348f1ab458892b34ed7facb diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html index 36eb4e211..d86b7ee43 100644 --- a/httemplate/elements/select-table.html +++ b/httemplate/elements/select-table.html @@ -1,63 +1,233 @@ -<% - - ##required - # 'table' => 'table_name', - # 'name_col' => 'name_column', - # - ##strongly recommended (you want your forms to be "sticky" on errors, right?) - # 'value' => 'current_value', - # - ##opt - # 'empty_label' => '', #better specify it though, the default might change - # 'hashref' => {}, - # 'extra_sql' => '', - # 'records' => \@records, #instead of hashref - # 'pre_options' => [ 'value' => 'option' ], #before normal options - # 'element_name' => '', #HTML element name, defaults to the name of - # # the primary key column - # 'element_etc' => '', #additional attributes (i.e. "DISABLED") for the - # #> +<%doc> + +Example: + + include( '/elements/select-table.html', + + ## + # required + ## + 'table' => 'table_name', + 'name_col' => 'name_column', #or method if you pass an order_by + + #strongly recommended (you want your forms to be "sticky" on errors, right?) + 'curr_value' => 'current_value', + #'value' => #deprecated form of 'curr_value', + + ## + # optional + ## + + #search params + 'hashref' => {}, + 'addl_from' => '', + 'extra_sql' => '', + 'agent_virt' => 0, #set true and make sure the result is JOINed to + #something with agentnum (usually cust_main) + 'agent_null' => 0, #set true to always show un-agented entries + 'agent_null_right' => '', #right to see un-agented entries + #or + 'records' => \@records, #instead of search params + 'presorted' => 0, #set true to disable sorting the records on name_col + + #instead of the primary key... only for special cases + 'value_col' => 'columnname', + + #basic params controlling the resulting + 'element_name' => '', #HTML element name, defaults to the name of + # the primary key column + 'field' => '', #synonym for element_name + 'element_etc' => '', #additional attributes (i.e. "DISABLED") for the + # + NAME = "<% $opt{'element_name'} || $opt{'field'} || $key %>" + ID = "<% $opt{'id'} || $key %>" + <% $onchange %> + <% $size %> + <% $opt{'element_etc'} %> +> + +% while ( @pre_options ) { +% my $pre_opt = shift(@pre_options); +% my $pre_label = shift(@pre_options); +% my $selected = $opt{'all_selected'} +% || ( ref($value) && $value->{$pre_opt} ) +% || ( $value eq $pre_opt ); + +% } + +% unless ( $opt{'multiple'} || $opt{'disable_empty'} ) { + +% } + +% foreach my $record ( +% # we have the order_by parameter for this +% #sort { $a->$name_col() cmp $b->$name_col() +% # || $a->$key() <=> $b->$key() +% # } +% @records +% ) +% { +% my $recvalue = $record->$key(); +% my $selected; +% if ( $opt{'all_selected'} ) { +% $selected = 1; +% } elsif ( $opt{'compare_sub'} && !ref($value) ) { +% $selected = &{ $opt{'compare_sub'} }( $value, $recvalue ); +% } else { +% $selected = ( ref($value) && $value->{$recvalue} ) +% || ( $value && $value eq $recvalue ); #not == because of value_col +% } + +% } + +% while ( @post_options ) { +% my $post_opt = shift(@post_options); +% my $post_label = shift(@post_options); +% my $selected = ( ref($value) && $value->{$post_opt} ) +% || ( $value eq $post_opt ); + +% } - <% while ( @pre_options ) { %> -