X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_pkg_discount.html;h=79c347813d0afe9ca4b84ac73b2ea62c257542b6;hp=0bb84b8f22bf1073e07a2219052bc55c611830ad;hb=9d5f61a78f7cddeb65f6943f3e58326f47cc0c0b;hpb=8a0204b4a129a3c26dcca18ba401b2de26d22d2b diff --git a/httemplate/edit/cust_pkg_discount.html b/httemplate/edit/cust_pkg_discount.html index 0bb84b8f2..79c347813 100755 --- a/httemplate/edit/cust_pkg_discount.html +++ b/httemplate/edit/cust_pkg_discount.html @@ -1,42 +1,35 @@ -<% include('/elements/header-popup.html', "Discount Package") %> - - - -<% include('/elements/error.html') %> - -
+<& /elements/header-popup.html, "Discount Package" &> +<& /elements/error.html &> + + <% ntable('#cccccc') %> - Current package  + Package  <% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><% $part_pkg->pkg |h %> - <% $part_pkg->comment |h %> -<% include('/elements/tr-select-discount.html', - 'empty_label' => ( $pkgdiscountnum ? '' : 'Select discount' ), - 'onchange' => 'enable_discount_pkg()', - 'cgi' => $cgi, - ) -%> - +<& /elements/tr-select-pkg-discount.html, + curr_value_setup => $setup_discountnum, + curr_value_recur => $recur_discountnum, + disable_setup => $disable_setup, + disable_recur => $disable_recur, + setup_label => emt('Setup fee discount'), + recur_label => emt('Recurring fee discount'), +&> +
-> +
@@ -44,14 +37,13 @@ <%init> -#some false laziness w/misc/change_pkg.cgi - my $conf = new FS::Conf; my $curuser = $FS::CurrentUser::CurrentUser; die "access denied" - unless $curuser->access_right('Discount customer package'); + unless $curuser->access_right([ 'Discount customer package', + 'Waive setup fee']); my $pkgnum = scalar($cgi->param('pkgnum')); $pkgnum =~ /^(\d+)$/ or die "illegal pkgnum $pkgnum"; @@ -67,10 +59,30 @@ my $cust_pkg = 'extra_sql' => ' AND '. $curuser->agentnums_sql, }) or die "unknown pkgnum $pkgnum"; -#my $cust_main = $cust_pkg->cust_main -# or die "can't get cust_main record for custnum ". $cust_pkg->custnum. -# " ( pkgnum ". cust_pkg->pkgnum. ")"; - my $part_pkg = $cust_pkg->part_pkg; +my @discounts = $cust_pkg->cust_pkg_discount_active; +my ($setup_discountnum, $recur_discountnum); +foreach (@discounts) { + if ( $_->setuprecur eq 'setup') { + die "multiple setup discounts on pkg#$pkgnum" if $setup_discountnum; + $setup_discountnum = $_->discountnum; + } elsif ( $_->setuprecur eq 'recur' ) { + die "multiple setup discounts on pkg#$pkgnum" if $recur_discountnum; + $recur_discountnum = $_->discountnum; + } +} +if ( $cust_pkg->waive_setup ) { + $setup_discountnum = -2; +} + +my $disable_setup = 1; +if ( !$cust_pkg->get('setup') and $cust_pkg->base_setup > 0 ) { + $disable_setup = 0; +} +my $disable_recur = 1; +if ( $cust_pkg->base_recur > 0 ) { + $disable_recur = 0; +} +