% if ( scalar(@{ $opt{'discount'} }) == 0 % && ! $curuser->access_right('Custom discount customer package') ) { % } else { <% $opt{'label'} || ''.emt('Discount').'' %> > <% include( '/elements/select-discount.html', 'curr_value' => $discountnum, 'onchange' => $onchange, %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, 'curr_value' => scalar($cgi->param($name.'__type')), 'onchange' => $name.'__type_changed', 'colspan' => $opt{'colspan'}, ) %> <% include( '/elements/tr-input-money.html', 'label' => 'Discount Amount ', 'field' => $name. '_amount', 'id' => $name. '_amount', 'default' => '0.00', 'curr_value' => scalar($cgi->param($name.'_amount')), 'colspan' => $opt{'colspan'}, ) %> <% include( '/elements/tr-input-percentage.html', 'label' => 'Discount Percentage', 'field' => $name. '_percent', 'id' => $name. '_percent', 'default' => '0', 'curr_value' => scalar($cgi->param($name.'_percent')), 'colspan' => $opt{'colspan'}, ) %> <% include( '/elements/tr-input-text.html', 'label' => 'Discount duration (months)', 'field' => $name. '_months', 'id' => $name. '_months', 'size' => 2, 'postfix' => qq((blank for non-expiring discount)), 'curr_value' => scalar($cgi->param($name.'_months')), 'colspan' => $opt{'colspan'}, ) %> <% include( '/elements/tr-checkbox.html', 'label' => 'Apply discount to setup fee', 'field' => $name.'_setup', 'id' => $name.'_setup', 'curr_value' => scalar($cgi->param($name.'_setup')), 'value' => 'Y', 'colspan' => $opt{'colspan'}, ) %> %# <% include( '/elements/tr-checkbox.html', %# 'label' => 'Apply discount to add-on packages', %# 'field' => $name.'_linked', %# 'id' => $name.'_linked', %# 'curr_value' => scalar($cgi->param($name.'_linked')), %# 'value' => 'Y', %# 'colspan' => $opt{'colspan'}, %# ) %# %> % } <%init> my %opt = @_; my $cgi = $opt{'cgi'}; 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'}.'"' : ''; my $onchange = ( $opt{'onchange'} ? delete($opt{'onchange'}).';' : '' ). $name.'_changed(this);';