1 <& elements/search.html,
2 'html_init' => $html_init,
3 'title' => emt('Package Search Results'),
6 'count_query' => $count_query,
7 'header' => [ emt('#'),
24 FS::UI::Web::cust_header(
25 $cgi->param('cust_fields')
34 sub { ucfirst(shift->status); },
35 sub { sprintf( $money_char.'%.2f',
36 shift->part_pkg->option('setup_fee'),
40 sprintf( $money_char.'%.2f',
41 $c->part_pkg->base_recur($c)
44 sub { FS::part_pkg::freq_pretty(shift); },
46 ( map { time_or_blank($_) }
47 qw( setup last_bill bill adjourn susp expire contract_end cancel ) ),
49 sub { my $self = shift;
51 foreach my $action ( qw ( cancel susp ) ) {
52 my $reason = $self->last_reason($action);
53 $return = $reason->reason if $reason;
59 \&FS::UI::Web::cust_fields,
62 my $type = $cgi->param('_type') || '';
63 if ($type =~ /xls|csv/) {
64 my $cust_svc = $cust_pkg->primary_cust_svc;
66 return join ": ",($cust_svc->label)[0,1];
75 { 'data' => $_->[0]. ':',
80 'link' => $p. 'view/' .
81 $_->[2]. '.cgi?'. $_->[3],
94 sub { shift->statuscolor; },
107 FS::UI::Web::cust_colors(),
110 'style' => [ '', '', '', '', 'b', '', '', '', '', '', '', '', '', '', '', '', '',
111 FS::UI::Web::cust_styles() ],
112 'size' => [ '', '', '', '', '-1' ],
113 'align' => 'rrlccrrlrrrrrrrrl'. FS::UI::Web::cust_aligns(). 'r',
132 ( map { $_ ne 'Cust. Status' ? $clink : '' }
133 FS::UI::Web::cust_header(
134 $cgi->param('cust_fields')
142 my $curuser = $FS::CurrentUser::CurrentUser;
145 unless $curuser->access_right('List packages');
147 my $conf = new FS::Conf;
148 my $money_char = $conf->config('money_char') || '$';
150 my %search_hash = ();
152 #some false laziness w/misc/bulk_change_pkg.cgi
154 $search_hash{'query'} = $cgi->keywords;
157 for (qw( agentnum custnum magic status classnum custom cust_fields pkgbatch )) {
158 $search_hash{$_} = $cgi->param($_) if $cgi->param($_);
161 $search_hash{'pkgpart'} = [ $cgi->param('pkgpart') ];
163 for my $param ( qw(censustract) ) {
164 $search_hash{$param} = $cgi->param($param) || ''
165 if ( grep { /$param/ } $cgi->param );
168 my @report_option = $cgi->param('report_option')
169 if $cgi->param('report_option');
170 $search_hash{report_option} = join(',', @report_option) if @report_option;
176 #false laziness w/report_cust_pkg.html
179 'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, },
180 'active' => { 'susp'=>1, 'cancel'=>1 },
181 'suspended' => { 'cancel' => 1 },
186 foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end cancel active )) {
188 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field);
190 next if $beginning == 0 && $ending == 4294967295
191 or $disable{$cgi->param('status')}->{$field};
193 $search_hash{$field} = [ $beginning, $ending ];
197 my $sql_query = FS::cust_pkg->search(\%search_hash);
198 my $count_query = delete($sql_query->{'count_query'});
200 my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/
206 my $frag = 'cust_pkg'. $self->pkgnum; #hack for IE ignoring real #fragment
207 [ "${p}view/cust_main.cgi?custnum=".$self->custnum.
208 "$show;fragment=$frag#cust_pkg",
214 my $cust_pkg = shift;
215 $cust_pkg->cust_main_custnum
216 ? [ "${p}view/cust_main.cgi?", 'custnum' ]
224 my $value = $record->get($column); #mmm closures
225 $value ? time2str('%b %d %Y', $value ) : '';
229 my $html_init = sub {
232 my $curuser = $FS::CurrentUser::CurrentUser;
234 if ( $curuser->access_right('Bulk change customer packages') ) {
235 $text .= include('/elements/init_overlib.html').
236 include( '/elements/popup_link.html',
237 'label' => emt('Change these packages'),
238 'action' => "${p}misc/bulk_change_pkg.cgi?$query",
239 'actionlabel' => emt('Change Packages'),
244 if ( $curuser->access_right('Edit customer package dates') ) {
245 $text .= include( '/elements/popup_link.html',
246 'label' => emt('Increment next bill date'),
247 'action' => "${p}misc/bulk_pkg_increment_bill.cgi?$query",
248 'actionlabel' => emt('Increment Bill Date'),
253 $text .= include( '/elements/email-link.html',
254 'search_hash' => \%search_hash,
255 'table' => 'cust_pkg',