2 <% $cgi->redirect(popurl(2)."bulk_suspend_pkg.cgi?".$cgi->query_string ) %>
4 <% include('/elements/popup-topreload.html', "Packages Suspended") %>
8 unless $FS::CurrentUser::CurrentUser->access_right('Bulk change customer packages');
16 $search_hash{'query'} = $cgi->param('query');
19 for (qw( agentnum cust_status cust_main_salesnum salesnum custnum magic status
20 custom cust_fields pkgbatch zip reasonnum
21 477part 477rownum date
24 $search_hash{$_} = $cgi->param($_) if length($cgi->param($_));
28 for my $param (qw( pkgpart classnum refnum towernum )) {
29 $search_hash{$param} = [ $cgi->param($param) ]
30 if grep { $_ eq $param } $cgi->param;
33 #scalars that need to be passed if empty
34 for my $param (qw( censustract censustract2 )) {
35 $search_hash{$param} = $cgi->param($param) || ''
36 if grep { $_ eq $param } $cgi->param;
39 #location flags (checkboxes)
40 my @loc = grep /^\w+$/, $cgi->param('loc');
41 $search_hash{"location_$_"} = 1 foreach @loc;
43 my $report_option = $cgi->param('report_option');
44 $search_hash{report_option} = $report_option if $report_option;
46 for my $param (grep /^report_option_any/, $cgi->param) {
47 $search_hash{$param} = $cgi->param($param);
54 #false laziness w/report_cust_pkg.html and bulk_pkg_increment_bill.cgi
57 'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, },
58 'active' => { 'susp'=>1, 'cancel'=>1 },
59 'suspended' => { 'cancel' => 1 },
64 foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end change_date cancel active )) {
66 $search_hash{$field.'_null'} = scalar( $cgi->param($field.'_null') );
68 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field);
70 next if $beginning == 0 && $ending == 4294967295
71 or $disable{$cgi->param('status')}->{$field};
73 $search_hash{$field} = [ $beginning, $ending ];
77 my $sql_query = FS::cust_pkg->search(\%search_hash);
78 $sql_query->{'select'} = 'cust_pkg.pkgnum';
81 $cgi->param('suspend_reasonnum') =~ /^(\d+)$/ or die "Illegal Reason";
82 my $suspend_reasonnum = $1;
84 my $suspend_date = time;
85 parse_datetime($cgi->param('suspend_date')) =~ /^(\d+)$/ or die "Illegal date";
88 my $suspend_resume_date = '';
89 (parse_datetime($cgi->param('suspend_resume_date')) =~ /^(\d+)$/ or die "Illegal resume date") if $cgi->param('suspend_resume_date');
90 $suspend_resume_date = $1;
92 foreach my $pkgnum (map { $_->pkgnum } qsearch($sql_query)) {
93 my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
95 $error = $cust_pkg->suspend('reason' => $suspend_reasonnum,
96 'date' => $suspend_date,
97 'resume_date' => $suspend_resume_date,
103 $cgi->param("error", substr($error, 0, 512)); # arbitrary length believed
104 # suited for all supported