% 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' => $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'},
)
%>
% }
<%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);';
%init>