From 4cacb3fa439b56fc7c9a742b69ec3f6ffd660433 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 4 Feb 2010 20:39:56 +0000 Subject: discounts, RT#6679 --- httemplate/elements/tr-select-discount.html | 154 +++++++++++++++++++++++++++- 1 file changed, 150 insertions(+), 4 deletions(-) (limited to 'httemplate/elements/tr-select-discount.html') diff --git a/httemplate/elements/tr-select-discount.html b/httemplate/elements/tr-select-discount.html index 4ff8d1357..df221da96 100644 --- a/httemplate/elements/tr-select-discount.html +++ b/httemplate/elements/tr-select-discount.html @@ -1,20 +1,156 @@ -% if ( scalar(@{ $opt{'discount'} }) == 0 ) { +% if ( scalar(@{ $opt{'discount'} }) == 0 +% && ! $curuser->access_right('Custom discount customer package') ) { - + % } else { <% $opt{'label'} || 'Discount' %> - + > <% include( '/elements/select-discount.html', 'curr_value' => $discountnum, + 'onchange' => $name.'_changed', %opt, ) %> +% # a weird kind of false laziness w/edit/discount.html + + + + + <% include( '/elements/tr-select.html', + 'label' => 'Discount Type', + 'field' => $name. '__type', + 'id' => $name. '__type', + 'options' => \@_type_options, + #XXX 'curr_value' => + 'onchange' => '_type_changed', + 'colspan' => $opt{'colspan'}, + ) + %> + + <% include( '/elements/tr-input-money.html', + 'label' => 'Discount Amount', + 'field' => $name. '_amount', + 'id' => $name. '_amount', + 'default' => '0.00', + #XXX 'curr_value' => + 'colspan' => $opt{'colspan'}, + ) + %> + + <% include( '/elements/tr-input-percentage.html', + 'label' => 'Discount Percentage', + 'field' => $name. '_percent', + 'id' => $name. '_percent', + 'default' => '0', + #XXX 'curr_value' => + 'colspan' => $opt{'colspan'}, + ) + %> + + <% include( '/elements/tr-input-text.html', + 'label' => 'Discount # of Months', + 'field' => $name. '_months', + 'id' => $name. '_months', + 'size' => 2, + 'postfix' => qq((blank for non-expiring discount)), + #XXX 'curr_value' => + 'colspan' => $opt{'colspan'}, + ) + %> + + + % } <%init> @@ -23,5 +159,15 @@ my $discountnum = $opt{'curr_value'} || $opt{'value'}; $opt{'discount'} ||= [ qsearch( 'discount', { disabled=>'' } ) ]; - +my $curuser = $FS::CurrentUser::CurrentUser; + +my $name = $opt{'element_name'} || $opt{'field'} || 'discountnum'; + +my $select = 'Select discount type'; +my @_type_options = ( 'Amount', 'Percentage' ); +unshift @_type_options, $select; + +my $colspan = $opt{'colspan'} ? 'COLSPAN="'.$opt{'colspan'}.'"' : ''; + + -- cgit v1.2.1