1 <& elements/search.html,
2 'html_init' => $html_init,
3 'title' => emt('Package Search Results'),
6 'count_query' => $count_query,
7 'header' => [ emt('#'),
25 FS::UI::Web::cust_header(
26 $cgi->param('cust_fields')
35 sub { ucfirst(shift->status); },
36 sub { sprintf( $money_char.'%.2f',
37 shift->part_pkg->option('setup_fee'),
41 sprintf( $money_char.'%.2f',
42 $c->part_pkg->base_recur($c)
45 sub { FS::part_pkg::freq_pretty(shift); },
47 ( map { time_or_blank($_) }
48 qw( setup last_bill bill adjourn susp dundate expire contract_end cancel ) ),
50 sub { my $self = shift;
52 foreach my $action ( qw ( cancel susp ) ) {
53 my $reason = $self->last_reason($action);
54 $return = $reason->reason if $reason;
60 \&FS::UI::Web::cust_fields,
63 my $type = $cgi->param('_type') || '';
64 if ($type =~ /xls|csv/) {
65 my $cust_svc = $cust_pkg->primary_cust_svc;
67 return join ": ",($cust_svc->label)[0,1];
74 [ $process_svc_labels->( $cust_pkg ) ]
83 sub { shift->statuscolor; },
97 FS::UI::Web::cust_colors(),
100 'style' => [ '', '', '', '', 'b', '', '', '', '', '', '', '', '', '', '', '', '', '',
101 FS::UI::Web::cust_styles() ],
102 'size' => [ '', '', '', '', '-1' ],
103 'align' => 'rrlccrrlrrrrrrrrrl'. FS::UI::Web::cust_aligns(). 'r',
123 ( map { $_ ne 'Cust. Status' ? $clink : '' }
124 FS::UI::Web::cust_header(
125 $cgi->param('cust_fields')
133 my $curuser = $FS::CurrentUser::CurrentUser;
136 unless $curuser->access_right('List packages');
138 my $conf = new FS::Conf;
139 my $money_char = $conf->config('money_char') || '$';
141 my %search_hash = ();
143 #some false laziness w/misc/bulk_change_pkg.cgi
145 $search_hash{'query'} = $cgi->keywords;
148 for (qw( agentnum custnum magic status classnum custom cust_fields pkgbatch )) {
149 $search_hash{$_} = $cgi->param($_) if $cgi->param($_);
152 $search_hash{'pkgpart'} = [ $cgi->param('pkgpart') ];
154 for my $param ( qw(censustract) ) {
155 $search_hash{$param} = $cgi->param($param) || ''
156 if ( grep { /$param/ } $cgi->param );
159 my @report_option = $cgi->param('report_option')
160 if $cgi->param('report_option');
161 $search_hash{report_option} = join(',', @report_option) if @report_option;
167 #false laziness w/report_cust_pkg.html
170 'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, 'contract_end'=>1, 'dundate'=>1, },
171 'active' => { 'susp'=>1, 'cancel'=>1 },
172 'suspended' => { 'cancel' =>1, 'dundate'=>1, },
177 foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end cancel active )) {
179 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field);
181 next if $beginning == 0 && $ending == 4294967295
182 or $disable{$cgi->param('status')}->{$field};
184 $search_hash{$field} = [ $beginning, $ending ];
188 my $sql_query = FS::cust_pkg->search(\%search_hash);
189 my $count_query = delete($sql_query->{'count_query'});
191 my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/
197 my $frag = 'cust_pkg'. $self->pkgnum; #hack for IE ignoring real #fragment
198 [ "${p}view/cust_main.cgi?custnum=".$self->custnum.
199 "$show;fragment=$frag#cust_pkg",
205 my $cust_pkg = shift;
206 $cust_pkg->cust_main_custnum
207 ? [ "${p}view/cust_main.cgi?", 'custnum' ]
215 my $value = $record->get($column); #mmm closures
216 $value ? time2str('%b %d %Y', $value ) : '';
220 my $html_init = sub {
223 my $curuser = $FS::CurrentUser::CurrentUser;
225 if ( $curuser->access_right('Bulk change customer packages') ) {
226 $text .= include('/elements/init_overlib.html').
227 include( '/elements/popup_link.html',
228 'label' => emt('Change these packages'),
229 'action' => "${p}misc/bulk_change_pkg.cgi?$query",
230 'actionlabel' => emt('Change Packages'),
235 if ( $curuser->access_right('Edit customer package dates') ) {
236 $text .= include( '/elements/popup_link.html',
237 'label' => emt('Increment next bill date'),
238 'action' => "${p}misc/bulk_pkg_increment_bill.cgi?$query",
239 'actionlabel' => emt('Increment Bill Date'),
244 $text .= include( '/elements/email-link.html',
245 'search_hash' => \%search_hash,
246 'table' => 'cust_pkg',
252 my $large_pkg_size = $conf->config('cust_pkg-large_pkg_size');
254 my $process_svc_labels = sub {
255 my $cust_pkg = shift;
257 foreach my $part_svc ( $cust_pkg->part_svc) {
258 # some false laziness with view/cust_main/packages/services.html
260 my $num_cust_svc = $cust_pkg->num_cust_svc( $part_svc->svcpart );
262 if ( $large_pkg_size > 0 and $large_pkg_size <= $num_cust_svc ) {
263 my $href = $p.'search/cust_pkg_svc.html?svcpart='.$part_svc->svcpart.
264 ';pkgnum='.$cust_pkg->pkgnum;
266 { 'data' => $part_svc->svc . ':',
269 { 'data' => mt('(view all [_1])', $num_cust_svc),
275 { 'data' => include('/elements/search-cust_svc.html',
276 'svcpart' => $part_svc->svcpart,
277 'pkgnum' => $cust_pkg->pkgnum,
283 foreach ( map { [ $_->label ] } @{ $part_svc->cust_pkg_svc } ) {
285 { 'data' => $_->[0]. ':',
286 'align'=> 'right', },
289 'link' => $p. 'view/' .
290 $_->[2]. '.cgi?'. $_->[3], },