1 <& elements/search.html,
2 'html_init' => $html_init,
3 'title' => emt('Package Search Results'),
6 'count_query' => $count_query,
7 'header' => [ emt('#'),
28 FS::UI::Web::cust_header(
29 $cgi->param('cust_fields')
38 sub { ucfirst(shift->status); },
41 sub { sprintf( $money_char.'%.2f',
42 shift->part_pkg->option('setup_fee'),
46 sprintf( $money_char.'%.2f',
47 $c->part_pkg->base_recur($c)
50 sub { FS::part_pkg::freq_pretty(shift); },
52 ( map { time_or_blank($_) }
53 qw( setup last_bill bill adjourn susp dundate expire contract_end change_date cancel ) ),
55 sub { my $self = shift;
57 foreach my $action ( qw ( cancel susp ) ) {
58 my $reason = $self->last_reason($action);
59 $return = $reason->reason if $reason;
65 \&FS::UI::Web::cust_fields,
68 my $type = $cgi->param('_type') || '';
69 if ($type =~ /xls|csv/) {
70 my $cust_svc = $cust_pkg->primary_cust_svc;
72 return join ": ",($cust_svc->label)[0,1];
79 [ $process_svc_labels->( $cust_pkg ) ]
88 sub { shift->statuscolor; },
105 FS::UI::Web::cust_colors(),
108 'style' => [ '', '', '', '', 'b', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
109 FS::UI::Web::cust_styles() ],
110 'size' => [ '', '', '', '', '-1' ],
111 'align' => 'rrlccccrrlrrrrrrrrrrl'. FS::UI::Web::cust_aligns(). 'r',
130 '', # link to changed-from package?
134 ( map { $_ ne 'Cust. Status' ? $clink : '' }
135 FS::UI::Web::cust_header(
136 $cgi->param('cust_fields')
144 my $curuser = $FS::CurrentUser::CurrentUser;
147 unless $curuser->access_right('List packages');
149 my $conf = new FS::Conf;
150 my $money_char = $conf->config('money_char') || '$';
152 my %search_hash = ();
154 #some false laziness w/misc/bulk_change_pkg.cgi
156 $search_hash{'query'} = $cgi->keywords;
159 for (qw( agentnum cust_status cust_main_salesnum salesnum custnum magic status
160 custom cust_fields pkgbatch zip
161 477part 477rownum date
164 $search_hash{$_} = $cgi->param($_) if length($cgi->param($_));
168 for my $param (qw( pkgpart classnum refnum towernum )) {
169 $search_hash{$param} = [ $cgi->param($param) ]
170 if grep { $_ eq $param } $cgi->param;
173 #scalars that need to be passed if empty
174 for my $param (qw( censustract censustract2 )) {
175 $search_hash{$param} = $cgi->param($param) || ''
176 if grep { $_ eq $param } $cgi->param;
179 #location flags (checkboxes)
180 my @loc = grep /^\w+$/, $cgi->param('loc');
181 $search_hash{"location_$_"} = 1 foreach @loc;
183 my $report_option = $cgi->param('report_option');
184 $search_hash{report_option} = $report_option if $report_option;
186 for my $param (grep /^report_option_any/, $cgi->param) {
187 $search_hash{$param} = $cgi->param($param);
194 #false laziness w/report_cust_pkg.html
197 'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, 'contract_end'=>1, 'dundate'=>1, },
198 'active' => { 'susp'=>1, 'cancel'=>1 },
199 'suspended' => { 'cancel' =>1, 'dundate'=>1, },
204 foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end change_date cancel active )) {
206 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field);
208 next if $beginning == 0 && $ending == 4294967295
209 or $disable{$cgi->param('status')}->{$field};
211 $search_hash{$field} = [ $beginning, $ending ];
215 my $sql_query = FS::cust_pkg->search(\%search_hash);
216 my $count_query = delete($sql_query->{'count_query'});
218 my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/
224 my $frag = 'cust_pkg'. $self->pkgnum; #hack for IE ignoring real #fragment
225 [ "${p}view/cust_main.cgi?custnum=".$self->custnum.
226 "$show;fragment=$frag#cust_pkg",
232 my $cust_pkg = shift;
233 $cust_pkg->cust_main_custnum
234 ? [ "${p}view/cust_main.cgi?", 'custnum' ]
242 my $value = $record->get($column); #mmm closures
243 $value ? time2str('%b %d %Y', $value ) : '';
247 my $html_init = sub {
250 my $curuser = $FS::CurrentUser::CurrentUser;
252 if ( $curuser->access_right('Bulk change customer packages') ) {
253 $text .= include('/elements/init_overlib.html').
254 include( '/elements/popup_link.html',
255 'label' => emt('Change these packages'),
256 'action' => "${p}misc/bulk_change_pkg.cgi?$query",
257 'actionlabel' => emt('Change Packages'),
262 if ( $curuser->access_right('Edit customer package dates') ) {
263 $text .= include( '/elements/popup_link.html',
264 'label' => emt('Increment next bill date'),
265 'action' => "${p}misc/bulk_pkg_increment_bill.cgi?$query",
266 'actionlabel' => emt('Increment Bill Date'),
271 $text .= include( '/elements/email-link.html',
272 'search_hash' => \%search_hash,
273 'table' => 'cust_pkg',
279 my $large_pkg_size = $conf->config('cust_pkg-large_pkg_size');
281 my $process_svc_labels = sub {
282 my $cust_pkg = shift;
284 foreach my $part_svc ( $cust_pkg->part_svc) {
285 # some false laziness with view/cust_main/packages/services.html
287 my $num_cust_svc = $cust_pkg->num_cust_svc( $part_svc->svcpart );
289 if ( $large_pkg_size > 0 and $large_pkg_size <= $num_cust_svc ) {
290 my $href = $p.'search/cust_pkg_svc.html?svcpart='.$part_svc->svcpart.
291 ';pkgnum='.$cust_pkg->pkgnum;
293 { 'data' => $part_svc->svc . ':',
296 { 'data' => mt('(view all [_1])', $num_cust_svc),
302 { 'data' => include('/elements/search-cust_svc.html',
303 'svcpart' => $part_svc->svcpart,
304 'pkgnum' => $cust_pkg->pkgnum,
310 foreach ( map { [ $_->label ] } @{ $part_svc->cust_pkg_svc } ) {
312 { 'data' => $_->[0]. ':',
318 'link' => $p. 'view/cust_svc.cgi?' . $_->[3],