From: Christopher Burger Date: Thu, 9 May 2019 17:22:09 +0000 (-0400) Subject: RT# 82949 - added the ability to bulk increase package fees (setup and/or recurring... X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=9cfa3648407dc2333fb549460fed278311c5393a RT# 82949 - added the ability to bulk increase package fees (setup and/or recurring) by a percentage --- diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index cb74bed66..cda189756 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -38,6 +38,9 @@ $().ready(function() { $('.taxproduct_desc').tooltip({}); }); +$(document).ready(function(){ + $(this).scrollTop(0); +}); <%init> @@ -801,8 +804,18 @@ if ( $acl_edit_bulk ) { $html_form = qq!
!; $html_foot = include('/search/elements/checkbox-foot.html', actions => [ - { submit => 'edit report classes', }, - { label => 'change customer packages', + { label => 'edit packages', + onclick=> include('/elements/popup_link_onclick.html', + 'label' => 'edit', + 'js_action' => qq{ + '${p}edit/bulk-part_pkg.html?' + \$('input[name=pkgpart]').serialize() + }, + 'actionlabel' => 'Bulk edit packages', + 'width' => 960, + 'height' => 420, + ) + }, + { label => 'change customers packages', onclick=> include('/elements/popup_link_onclick.html', 'label' => 'change', 'js_action' => qq{ diff --git a/httemplate/edit/bulk-part_pkg.html b/httemplate/edit/bulk-part_pkg.html index 4665c9f95..3225392be 100644 --- a/httemplate/edit/bulk-part_pkg.html +++ b/httemplate/edit/bulk-part_pkg.html @@ -1,5 +1,4 @@ -<& /elements/header.html, 'Edit package report classes' &> -%# change that title if we add any other editing controls +<% include('/elements/header-popup.html', 'Bulk edit packages') %> %# this should be centralized somewhere <& /elements/error.html &> + + -
-The following packages will be changed:
-% foreach my $pkgpart (sort keys(%part_pkg)) { - -<% $part_pkg{$pkgpart}->pkg_comment |h %>
-% } -
+ + + - + - - + + + % $row++; % } -
+Select the package information to change
+ +Edit report classes
-<& /elements/table-grid.html &>\ -<& /elements/tr-justtitle.html, value => mt('Report classes') &> +
+
% if ( $initial_state{$num} == -1 ) { % # needs to be a tristate so that you can say "don't change it" <& /elements/checkbox-tristate.html, field => 'report_option_'.$num &> % } else { %# for visual consistency - ><% $report_class{$num}->name %>
<% $report_class{$num}->name %>
+ + +
+ +Edit package fees. +
+
- + + +   + + The following packages will be changed:
+% foreach my $pkgpart (sort keys(%part_pkg)) { + + <% $part_pkg{$pkgpart}->pkg_comment |h %>
+% } + + +
<& /elements/footer.html &> <%init> diff --git a/httemplate/edit/process/bulk-part_pkg.html b/httemplate/edit/process/bulk-part_pkg.html index 59c914a5d..ac542cc14 100644 --- a/httemplate/edit/process/bulk-part_pkg.html +++ b/httemplate/edit/process/bulk-part_pkg.html @@ -1,35 +1,54 @@ -% if ( $error ) { -% $cgi->param('error', $error); -<% $cgi->redirect(popurl(3).'/edit/bulk-part_pkg.html?'.$cgi->query_string) %> -% } else { -<% $cgi->redirect(popurl(3).'/browse/part_pkg.cgi') %> -% } +<& /elements/popup-topreload.html, emt($message) &> + <%init> die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Bulk edit package definitions'); my @pkgparts = $cgi->param('pkgpart') or die "no package definitions selected"; -my %delete = map { 'report_option_'.($_->num) => 1 } - qsearch('part_pkg_report_option', {}); -my %insert; - -foreach my $param (grep { /^report_option_\d+$/ } $cgi->param) { - if ( $cgi->param($param) == 1 ) { - $insert{$param} = 1; - delete $delete{$param}; - } elsif ( $cgi->param($param) == -1 ) { - # leave it alone - delete $delete{$param}; - } # else it's empty, so leave it on the delete list +my $error; + +if ($cgi->param('report_class')) { + my %delete = map { 'report_option_'.($_->num) => 1 } + qsearch('part_pkg_report_option', {}); + my %insert; + + foreach my $param (grep { /^report_option_\d+$/ } $cgi->param) { + if ( $cgi->param($param) == 1 ) { + $insert{$param} = 1; + delete $delete{$param}; + } elsif ( $cgi->param($param) == -1 ) { + # leave it alone + delete $delete{$param}; + } # else it's empty, so leave it on the delete list + } + + foreach my $pkgpart (@pkgparts) { + my $part_pkg = FS::part_pkg->by_key($pkgpart); + my %options = ( $part_pkg->options, %insert ); + delete $options{$_} foreach keys(%delete); + $error ||= $part_pkg->replace( options => \%options ); + } } +if ($cgi->param('package_fees')) { + my $setup_fee_increase = $cgi->param('setup_fee_increase'); + my $recurring_fee_increase = $cgi->param('recurring_fee_increase'); -my $error; -foreach my $pkgpart (@pkgparts) { - my $part_pkg = FS::part_pkg->by_key($pkgpart); - my %options = ( $part_pkg->options, %insert ); - delete $options{$_} foreach keys(%delete); - $error ||= $part_pkg->replace( options => \%options ); + foreach my $pkgpart (@pkgparts) { + my $part_pkg = FS::part_pkg->by_key($pkgpart); + my %options = $part_pkg->options; + if ($recurring_fee_increase) { + $options{'recur_fee'} = $options{'recur_fee'} + ($options{'recur_fee'} * ($recurring_fee_increase / 100)); + } + if ($setup_fee_increase) { + $options{'setup_fee'} = $options{'setup_fee'} + ($options{'setup_fee'} * ($setup_fee_increase / 100)); + } + $error ||= $part_pkg->replace( options => \%options ); + } } + +my $message = "Packages updated successfully"; +$message = $error."=error" if $error; + diff --git a/httemplate/elements/header-full.html b/httemplate/elements/header-full.html index c73cf0463..5a5db9620 100644 --- a/httemplate/elements/header-full.html +++ b/httemplate/elements/header-full.html @@ -207,7 +207,7 @@ Example: % my ($message, $type) = split /=/, $status_msg; % $type ||= 'status'; - +
<% $message |h %> <% $message |h %>
% } @@ -274,5 +274,6 @@ if ( scalar(@agentnums) == 1 ) { ## status->green(#eeffee), warning->yellow(#fdfd96), error->red(#f97c7c) my %status_color = ( 'status' => '#eeffee', 'warning' => '#fefbd0', 'error' => '#f97c7c', ); +my %status_image = ( 'status' => 'images/tick.png', 'warning' => 'images/tick.png', 'error' => 'images/error.png', );