2 <% $cgi->redirect(popurl(2)."/bulk_change_pkg.cgi?".$cgi->query_string ) %>
4 <% include('/elements/header-popup.html', "Packages Changed") %>
8 unless $FS::CurrentUser::CurrentUser->access_right('Bulk change customer packages');
12 $search_hash{'query'} = $cgi->param('query');
15 for (qw( agentnum cust_status cust_main_salesnum salesnum custnum magic status
16 custom cust_fields pkgbatch zip
17 477part 477rownum date
20 $search_hash{$_} = $cgi->param($_) if length($cgi->param($_));
24 for my $param (qw( pkgpart classnum refnum towernum )) {
25 $search_hash{$param} = [ $cgi->param($param) ]
26 if grep { $_ eq $param } $cgi->param;
29 #scalars that need to be passed if empty
30 for my $param (qw( censustract censustract2 )) {
31 $search_hash{$param} = $cgi->param($param) || ''
32 if grep { $_ eq $param } $cgi->param;
35 #location flags (checkboxes)
36 my @loc = grep /^\w+$/, $cgi->param('loc');
37 $search_hash{"location_$_"} = 1 foreach @loc;
39 my $report_option = $cgi->param('report_option');
40 $search_hash{report_option} = $report_option if $report_option;
42 for my $param (grep /^report_option_any/, $cgi->param) {
43 $search_hash{$param} = $cgi->param($param);
50 #false laziness w/report_cust_pkg.html and bulk_pkg_increment_bill.cgi
53 'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, },
54 'active' => { 'susp'=>1, 'cancel'=>1 },
55 'suspended' => { 'cancel' => 1 },
60 foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end change_date cancel active )) {
62 $search_hash{$field.'_null'} = scalar( $cgi->param($field.'_null') );
64 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field);
66 next if $beginning == 0 && $ending == 4294967295
67 or $disable{$cgi->param('status')}->{$field};
69 $search_hash{$field} = [ $beginning, $ending ];
73 my $sql_query = FS::cust_pkg->search(\%search_hash);
74 $sql_query->{'select'} = 'cust_pkg.pkgnum';
76 my $error = FS::cust_pkg::bulk_change( [ $cgi->param('new_pkgpart') ],
77 [ map { $_->pkgnum } qsearch($sql_query) ],
80 $cgi->param("error", substr($error, 0, 512)); # arbitrary length believed
81 # suited for all supported