1 <% include( 'elements/search.html',
2 'html_init' => $html_init,
3 'title' => 'Package Search Results',
6 'count_query' => $count_query,
25 FS::UI::Web::cust_header(
26 $cgi->param('cust_fields')
33 sub { #my $part_pkg = $part_pkg{shift->pkgpart};
34 #$part_pkg->pkg; # ' - '. $part_pkg->comment;
35 $_[0]->pkg; # ' - '. $_[0]->comment;
38 sub { ucfirst(shift->status); },
39 sub { sprintf( $money_char.'%.2f',
40 shift->part_pkg->option('setup_fee'),
44 sprintf( $money_char.'%.2f',
45 $c->part_pkg->base_recur($c)
48 sub { #shift->part_pkg->freq_pretty;
50 #my $part_pkg = $part_pkg{shift->pkgpart};
51 #$part_pkg->freq_pretty;
53 FS::part_pkg::freq_pretty(shift);
56 #sub { time2str('%b %d %Y', shift->setup); },
57 #sub { time2str('%b %d %Y', shift->last_bill); },
58 #sub { time2str('%b %d %Y', shift->bill); },
59 #sub { time2str('%b %d %Y', shift->susp); },
60 #sub { time2str('%b %d %Y', shift->expire); },
61 #sub { time2str('%b %d %Y', shift->get('cancel')); },
62 ( map { time_or_blank($_) }
63 qw( setup last_bill bill adjourn susp expire contract_end cancel ) ),
65 sub { my $self = shift;
67 foreach my $action ( qw ( cancel susp ) ) {
68 my $reason = $self->last_reason($action);
69 $return = $reason->reason if $reason;
75 \&FS::UI::Web::cust_fields,
76 #sub { '<table border=0 cellspacing=0 cellpadding=0 STYLE="border:none">'.
77 # join('', map { '<tr><td align="right" style="border:none">'. $_->[0].
78 # ':</td><td style="border:none">'. $_->[1]. '</td></tr>' }
85 my $type = $cgi->param('_type') || '';
86 if ($type =~ /xls|csv/) {
87 my $cust_svc = $cust_pkg->primary_cust_svc;
89 return join ": ",($cust_svc->label)[0,1];
98 { 'data' => $_->[0]. ':',
103 'link' => $p. 'view/' .
104 $_->[2]. '.cgi?'. $_->[3],
117 sub { shift->statuscolor; },
129 FS::UI::Web::cust_colors(),
132 'style' => [ '', '', '', '', 'b', '', '', '', '', '', '', '', '', '', '', '',
133 FS::UI::Web::cust_styles() ],
134 'size' => [ '', '', '', '', '-1' ],
135 'align' => 'rrlccrrlrrrrrrrl'. FS::UI::Web::cust_aligns(). 'r',
153 ( map { $_ ne 'Cust. Status' ? $clink : '' }
154 FS::UI::Web::cust_header(
155 $cgi->param('cust_fields')
164 my $curuser = $FS::CurrentUser::CurrentUser;
167 unless $curuser->access_right('List packages');
169 my $conf = new FS::Conf;
170 my $money_char = $conf->config('money_char') || '$';
172 # my %part_pkg = map { $_->pkgpart => $_ } qsearch('part_pkg', {});
174 my %search_hash = ();
176 #some false laziness w/misc/bulk_change_pkg.cgi
178 $search_hash{'query'} = $cgi->keywords;
181 for (qw( agentnum custnum magic status classnum custom cust_fields pkgbatch )) {
182 $search_hash{$_} = $cgi->param($_) if $cgi->param($_);
185 $search_hash{'pkgpart'} = [ $cgi->param('pkgpart') ];
187 for my $param ( qw(censustract) ) {
188 $search_hash{$param} = $cgi->param($param) || ''
189 if ( grep { /$param/ } $cgi->param );
192 my @report_option = $cgi->param('report_option')
193 if $cgi->param('report_option');
194 $search_hash{report_option} = join(',', @report_option) if @report_option;
200 #false laziness w/report_cust_pkg.html
203 'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, },
204 'active' => { 'susp'=>1, 'cancel'=>1 },
205 'suspended' => { 'cancel' => 1 },
210 foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end cancel active )) {
212 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field);
214 next if $beginning == 0 && $ending == 4294967295
215 or $disable{$cgi->param('status')}->{$field};
217 $search_hash{$field} = [ $beginning, $ending ];
221 my $sql_query = FS::cust_pkg->search(\%search_hash);
222 my $count_query = delete($sql_query->{'count_query'});
224 my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/
230 my $frag = 'cust_pkg'. $self->pkgnum; #hack for IE ignoring real #fragment
231 [ "${p}view/cust_main.cgi?custnum=".$self->custnum.
232 "$show;fragment=$frag#cust_pkg",
238 my $cust_pkg = shift;
239 $cust_pkg->cust_main_custnum
240 ? [ "${p}view/cust_main.cgi?", 'custnum' ]
244 #if ( scalar(@cust_pkg) == 1 ) {
245 # print $cgi->redirect("${p}view/cust_main.cgi?". $cust_pkg[0]->custnum.
246 # "#cust_pkg". $cust_pkg[0]->pkgnum );
248 # my @cust_svc = qsearch( 'cust_svc', { 'pkgnum' => $pkgnum } );
249 # my $rowspan = scalar(@cust_svc) || 1;
252 # foreach my $cust_svc ( @cust_svc ) {
253 # my($label, $value, $svcdb) = $cust_svc->label;
254 # my $svcnum = $cust_svc->svcnum;
255 # my $sview = $p. "view";
256 # print $n2,qq!<TD><A HREF="$sview/$svcdb.cgi?$svcnum"><FONT SIZE=-1>$label</FONT></A></TD>!,
257 # qq!<TD><A HREF="$sview/$svcdb.cgi?$svcnum"><FONT SIZE=-1>$value</FONT></A></TD>!;
265 my $value = $record->get($column); #mmm closures
266 $value ? time2str('%b %d %Y', $value ) : '';
270 my $html_init = sub {
273 my $curuser = $FS::CurrentUser::CurrentUser;
275 if ( $curuser->access_right('Bulk change customer packages') ) {
276 $text .= include('/elements/init_overlib.html').
277 include( '/elements/popup_link.html',
278 'label' => 'Change these packages',
279 'action' => "${p}misc/bulk_change_pkg.cgi?$query",
280 'actionlabel' => 'Change Packages',
285 if ( $curuser->access_right('Edit customer package dates') ) {
286 $text .= include( '/elements/popup_link.html',
287 'label' => 'Increment next bill date',
288 'action' => "${p}misc/bulk_pkg_increment_bill.cgi?$query",
289 'actionlabel' => 'Increment Bill Date',
294 $text .= include( '/elements/email-link.html',
295 'search_hash' => \%search_hash,
296 'table' => 'cust_pkg',