X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Felements%2Ftr-select-discount.html;h=ee862519f7705b7505c8b988c51d0e3723fe8b77;hb=430b2c784d2ee9ea5be00b821d2dbd27279ef132;hp=4ff8d135731b886767884474280c8d96afa2d5e0;hpb=2d5f9e43a60773a9b079e96c330cb9e0e089800a;p=freeside.git
diff --git a/httemplate/elements/tr-select-discount.html b/httemplate/elements/tr-select-discount.html
index 4ff8d1357..ee862519f 100644
--- a/httemplate/elements/tr-select-discount.html
+++ b/httemplate/elements/tr-select-discount.html
@@ -1,27 +1,212 @@
-% if ( scalar(@{ $opt{'discount'} }) == 0 ) {
+% if ( scalar(@{ $opt{'discount'} }) == 0
+% && ! $curuser->access_right('Custom discount customer package') ) {
-
+
% } else {
- <% $opt{'label'} || 'Discount' %> |
-
+ | <% $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=>'' } ) ];
-%init>
+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>