diff options
Diffstat (limited to 'httemplate/elements')
-rw-r--r-- | httemplate/elements/select-cust_payby.html | 23 | ||||
-rw-r--r-- | httemplate/elements/select-table.html | 6 | ||||
-rw-r--r-- | httemplate/elements/tr-select-cust_payby.html | 31 |
3 files changed, 58 insertions, 2 deletions
diff --git a/httemplate/elements/select-cust_payby.html b/httemplate/elements/select-cust_payby.html new file mode 100644 index 0000000..a726cb3 --- /dev/null +++ b/httemplate/elements/select-cust_payby.html @@ -0,0 +1,23 @@ +<% include( '/elements/select-table.html', + 'table' => 'cust_payby', + 'name_col' => 'label', + 'value' => $custpaybynum, + 'disable_empty' => 1, + 'post_options' => [ '0' => 'Enter new payment information' ], + 'hashref' => { 'custnum' => $opt{'custnum'}, + 'disabled' => '', + }, + %opt, + ) +%> +<%init> + +my %opt = @_; +my $custpaybynum = $opt{'curr_value'} || $opt{'value'}; + +if ( $opt{'cust_payby'} ) { + $opt{'records'} = delete $opt{'cust_payby'}; + $opt{'presorted'} = 1 if ! exists($opt{'presorted'}); +} + +</%init> diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html index 0b04fee..4b6ddb4 100644 --- a/httemplate/elements/select-table.html +++ b/httemplate/elements/select-table.html @@ -28,6 +28,7 @@ Example: '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', @@ -176,8 +177,9 @@ if ( $opt{'agent_virt'} ) { my @records = (); if ( $opt{'records'} ) { - @records = sort { $a->get($name_col) cmp $b->get($name_col) } - @{ $opt{'records'} }; + @records = @{ $opt{'records'} }; + @records = sort { $a->get($name_col) cmp $b->get($name_col) } @records + unless $opt{'presorted'}; } else { @records = qsearch( { 'table' => $opt{'table'}, diff --git a/httemplate/elements/tr-select-cust_payby.html b/httemplate/elements/tr-select-cust_payby.html new file mode 100644 index 0000000..e2b2e09 --- /dev/null +++ b/httemplate/elements/tr-select-cust_payby.html @@ -0,0 +1,31 @@ +% if ( scalar(@{ $opt{'cust_payby'} }) == 0 ) { + + <INPUT TYPE="hidden" NAME="<% $opt{'element_name'} || $opt{'field'} || 'custpaybynum' %>" VALUE=""> + +% } else { + + <TR> + <TH ALIGN="right"><% $opt{'label'} || 'Payment via' %></TD> + <TD> + <% include( '/elements/select-cust_payby.html', + 'curr_value' => $custpaybynum, + %opt + ) + %> + </TD> + </TR> + +% } + +<%init> + +my %opt = @_; +my $custpaybynum = $opt{'curr_value'} || $opt{'value'}; + +$opt{'cust_payby'} ||= [ qsearch( 'cust_payby', { custnum => $opt{custnum}, + disabled => '', + } + ) + ]; + +</%init> |