2 % $cgi->param('error', $error);
3 <% $cgi->redirect(popurl(2). 'bulk_pkg_increment_bill.cgi?'. $cgi->query_string ) %>
5 <& /elements/header-popup.html, 'Packages Adjusted' &>
6 <SCRIPT TYPE="text/javascript">
13 local $FS::UID::AutoCommit = 0;
18 unless $FS::CurrentUser::CurrentUser->access_right('Bulk change customer packages')
19 and $FS::CurrentUser::CurrentUser->access_right('Edit customer package dates');
21 my $days = $cgi->param('days') or die "missing parameter: days";
22 $days > 0 or $error = "Number of days must be > 0";
26 $search_hash{'query'} = $cgi->param('query');
29 for (qw( agentnum cust_status cust_main_salesnum salesnum custnum magic status
30 custom cust_fields pkgbatch zip
31 477part 477rownum date
34 $search_hash{$_} = $cgi->param($_) if length($cgi->param($_));
38 for my $param (qw( pkgpart classnum refnum towernum )) {
39 $search_hash{$param} = [ $cgi->param($param) ]
40 if grep { $_ eq $param } $cgi->param;
43 #scalars that need to be passed if empty
44 for my $param (qw( censustract censustract2 )) {
45 $search_hash{$param} = $cgi->param($param) || ''
46 if grep { $_ eq $param } $cgi->param;
49 #location flags (checkboxes)
50 my @loc = grep /^\w+$/, $cgi->param('loc');
51 $search_hash{"location_$_"} = 1 foreach @loc;
53 my $report_option = $cgi->param('report_option');
54 $search_hash{report_option} = $report_option if $report_option;
56 for my $param (grep /^report_option_any/, $cgi->param) {
57 $search_hash{$param} = $cgi->param($param);
64 #false laziness w/report_cust_pkg.html and bulk_change_pkg.cgi
67 'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, },
68 'active' => { 'susp'=>1, 'cancel'=>1 },
69 'suspended' => { 'cancel' => 1 },
74 foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end change_date cancel active )) {
76 $search_hash{$field.'_null'} = scalar( $cgi->param($field.'_null') );
78 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field);
80 next if $beginning == 0 && $ending == 4294967295
81 or $disable{$cgi->param('status')}->{$field};
83 $search_hash{$field} = [ $beginning, $ending ];
88 foreach my $cust_pkg (qsearch(FS::cust_pkg->search(\%search_hash))) {
89 next if ! $cust_pkg->bill;
90 my $new_cust_pkg = FS::cust_pkg->new({ $cust_pkg->hash });
91 $new_cust_pkg->bill($new_cust_pkg->bill + $days*86400);
92 $error = $new_cust_pkg->replace($cust_pkg);
95 $cgi->param("error",substr($error, 0, 512));