1 <& elements/search.html,
2 'html_init' => $html_init,
3 'title' => emt('Package Search Results'),
6 'count_query' => $count_query,
7 'html_init_data' => $search_string,
8 'header' => [ emt('#'),
29 FS::UI::Web::cust_header(
30 $cgi->param('cust_fields')
39 sub { ucfirst(shift->status); },
42 sub { sprintf( $money_char.'%.2f',
43 shift->part_pkg->option('setup_fee'),
47 sprintf( $money_char.'%.2f',
51 sub { FS::part_pkg::freq_pretty(shift); },
53 ( map { time_or_blank($_) }
54 qw( setup last_bill bill adjourn susp dundate expire contract_end change_date cancel ) ),
56 sub { my $self = shift;
58 foreach my $action ( qw ( cancel susp ) ) {
59 my $reason = $self->last_reason($action);
60 $return = $reason->reason if $reason;
66 \&FS::UI::Web::cust_fields,
69 my $type = $cgi->param('_type') || '';
70 if ($type =~ /xls|csv/) {
71 my $cust_svc = $cust_pkg->primary_cust_svc;
73 return join ": ",($cust_svc->label)[0,1];
80 [ $process_svc_labels->( $cust_pkg ) ]
89 sub { shift->statuscolor; },
106 FS::UI::Web::cust_colors(),
109 'style' => [ '', '', '', '', 'b', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
110 FS::UI::Web::cust_styles() ],
111 'size' => [ '', '', '', '', '-1' ],
112 'align' => 'rrlccccrrlrrrrrrrrrrl'. FS::UI::Web::cust_aligns(). 'r',
131 '', # link to changed-from package?
135 ( map { $_ ne 'Cust. Status' ? $clink : '' }
136 FS::UI::Web::cust_header(
137 $cgi->param('cust_fields')
145 my $curuser = $FS::CurrentUser::CurrentUser;
148 unless $curuser->access_right('List packages');
150 my $conf = new FS::Conf;
151 my $money_char = $conf->config('money_char') || '$';
153 my %search_hash = ();
156 #some false laziness w/misc/bulk_change_pkg.cgi
158 $search_hash{'query'} = $cgi->keywords;
161 for (qw( agentnum cust_status cust_main_salesnum salesnum custnum magic status
162 reasonnum custom cust_fields pkgbatch zip
163 477part 477rownum date
166 $search_hash{$_} = $cgi->param($_) if length($cgi->param($_));
167 $search_string .= '&'.$_.'='.$cgi->param($_) if length($cgi->param($_));
171 for my $param (qw( pkgpart classnum refnum towernum )) {
172 $search_hash{$param} = [ $cgi->param($param) ]
173 if grep { $_ eq $param } $cgi->param;
174 $search_string .= '&'.$param.'='.$cgi->param($param) if grep { $_ eq $param } $cgi->param;
177 #scalars that need to be passed if empty
178 for my $param (qw( censustract censustract2 )) {
179 $search_hash{$param} = $cgi->param($param) || ''
180 if grep { $_ eq $param } $cgi->param;
181 $search_string .= '&'.$param.'='.$cgi->param($param) if grep { $_ eq $param } $cgi->param;
184 #location flags (checkboxes)
185 my @loc = grep /^\w+$/, $cgi->param('loc');
186 $search_hash{"location_$_"} = 1 foreach @loc;
187 $search_string .= '&location_'.$_.'=1' foreach @loc;
189 my $report_option = $cgi->param('report_option');
190 $search_hash{report_option} = $report_option if $report_option;
191 $search_string .= '&report_option='.$report_option if $report_option;
193 for my $param (grep /^report_option_any/, $cgi->param) {
194 $search_hash{$param} = $cgi->param($param);
201 #false laziness w/report_cust_pkg.html
204 'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, 'contract_end'=>1, 'dundate'=>1, },
205 'active' => { 'susp'=>1, 'cancel'=>1 },
206 'suspended' => { 'cancel' =>1, 'dundate'=>1, },
211 foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end change_date cancel active )) {
213 $search_hash{$field.'_null'} = scalar( $cgi->param($field.'_null') );
214 $search_string .= '&'.$field.'_null='.scalar( $cgi->param($field.'_null') );
216 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field);
218 next if $beginning == 0 && $ending == 4294967295
219 or $disable{$cgi->param('status')}->{$field};
221 $search_hash{$field} = [ $beginning, $ending ];
222 $search_string .= '&'.$field.'_begin='.$beginning.'&'.$field.'_end='.$ending;
226 my $sql_query = FS::cust_pkg->search(\%search_hash);
227 my $count_query = delete($sql_query->{'count_query'});
229 my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/
235 my $frag = 'cust_pkg'. $self->pkgnum; #hack for IE ignoring real #fragment
236 [ "${p}view/cust_main.cgi?custnum=".$self->custnum.
237 "$show;fragment=$frag#cust_pkg",
243 my $cust_pkg = shift;
244 $cust_pkg->cust_main_custnum
245 ? [ "${p}view/cust_main.cgi?", 'custnum' ]
253 my $value = $record->get($column); #mmm closures
254 $value ? time2str('%b %d %Y', $value ) : '';
258 my $html_init = sub {
261 my $curuser = $FS::CurrentUser::CurrentUser;
263 if ( $curuser->access_right('Bulk change customer packages') ) {
264 $text .= include('/elements/init_overlib.html').
265 include( '/elements/popup_link.html',
266 'label' => emt('Change these packages'),
267 'action' => "${p}misc/bulk_change_pkg.cgi?$query",
268 'actionlabel' => emt('Change Packages'),
273 $text .= include( '/elements/popup_link.html',
274 'label' => emt('Suspend these packages'),
275 'action' => "${p}misc/bulk_suspend_pkg.cgi?$query",
276 'actionlabel' => emt('Suspend Packages'),
279 ). '<BR>' if $search_hash{status} eq 'active';
281 $text .= include( '/elements/popup_link.html',
282 'label' => emt('Unsuspend these packages'),
283 'action' => "${p}misc/bulk_unsuspend_pkg.cgi?$query",
284 'actionlabel' => emt('Unsuspend Packages'),
287 ). '<BR>' if $search_hash{status} eq 'suspended';
289 if ( $curuser->access_right('Edit customer package dates') ) {
290 $text .= include( '/elements/popup_link.html',
291 'label' => emt('Increment next bill date'),
292 'action' => "${p}misc/bulk_pkg_increment_bill.cgi?$query",
293 'actionlabel' => emt('Increment Bill Date'),
298 $text .= include( '/elements/email-link.html',
299 'search_hash' => \%search_hash,
300 'table' => 'cust_pkg',
306 my $large_pkg_size = $conf->config('cust_pkg-large_pkg_size');
308 my $process_svc_labels = sub {
309 my $cust_pkg = shift;
311 foreach my $part_svc ( $cust_pkg->part_svc) {
312 # some false laziness with view/cust_main/packages/services.html
314 my $num_cust_svc = $cust_pkg->num_cust_svc( $part_svc->svcpart );
316 if ( $large_pkg_size > 0 and $large_pkg_size <= $num_cust_svc ) {
317 my $href = $p.'search/cust_pkg_svc.html?svcpart='.$part_svc->svcpart.
318 ';pkgnum='.$cust_pkg->pkgnum;
320 { 'data' => $part_svc->svc . ':',
323 { 'data' => mt('(view all [_1])', $num_cust_svc),
329 { 'data' => include('/elements/search-cust_svc.html',
330 'svcpart' => $part_svc->svcpart,
331 'pkgnum' => $cust_pkg->pkgnum,
337 foreach ( map { [ $_->label ] } @{ $part_svc->cust_pkg_svc } ) {
339 { 'data' => $_->[0]. ':',
345 'link' => $p. 'view/cust_svc.cgi?' . $_->[3],