1 <& elements/search.html,
2 'html_init' => $html_init,
3 'title' => emt('Package Search Results'),
6 'count_query' => $count_query,
7 'header' => [ emt('#'),
27 FS::UI::Web::cust_header(
28 $cgi->param('cust_fields')
37 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 { FS::part_pkg::freq_pretty(shift); },
50 ( map { time_or_blank($_) }
51 qw( setup last_bill bill adjourn susp dundate expire contract_end change_date cancel ) ),
53 sub { my $self = shift;
55 foreach my $action ( qw ( cancel susp ) ) {
56 my $reason = $self->last_reason($action);
57 $return = $reason->reason if $reason;
63 \&FS::UI::Web::cust_fields,
66 my $type = $cgi->param('_type') || '';
67 if ($type =~ /xls|csv/) {
68 my $cust_svc = $cust_pkg->primary_cust_svc;
70 return join ": ",($cust_svc->label)[0,1];
77 [ $process_svc_labels->( $cust_pkg ) ]
86 sub { shift->statuscolor; },
102 FS::UI::Web::cust_colors(),
105 'style' => [ '', '', '', '', 'b', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
106 FS::UI::Web::cust_styles() ],
107 'size' => [ '', '', '', '', '-1' ],
108 'align' => 'rrlcccrrlrrrrrrrrrrl'. FS::UI::Web::cust_aligns(). 'r',
126 '', # link to changed-from package?
130 ( map { $_ ne 'Cust. Status' ? $clink : '' }
131 FS::UI::Web::cust_header(
132 $cgi->param('cust_fields')
140 my $curuser = $FS::CurrentUser::CurrentUser;
143 unless $curuser->access_right('List packages');
145 my $conf = new FS::Conf;
146 my $money_char = $conf->config('money_char') || '$';
148 my %search_hash = ();
150 #some false laziness w/misc/bulk_change_pkg.cgi
152 $search_hash{'query'} = $cgi->keywords;
155 for (qw( agentnum custnum magic status custom cust_fields pkgbatch )) {
156 $search_hash{$_} = $cgi->param($_) if $cgi->param($_);
160 for my $param (qw( pkgpart classnum )) {
161 $search_hash{$param} = [ $cgi->param($param) ]
162 if grep { $_ eq $param } $cgi->param;
165 #scalars that need to be passed if empty
166 for my $param (qw( censustract censustract2 )) {
167 $search_hash{$param} = $cgi->param($param) || ''
168 if grep { $_ eq $param } $cgi->param;
171 my $report_option = $cgi->param('report_option');
172 $search_hash{report_option} = $report_option if $report_option;
174 for my $param (grep /^report_option_any/, $cgi->param) {
175 $search_hash{$param} = $cgi->param($param);
182 #false laziness w/report_cust_pkg.html
185 'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, 'contract_end'=>1, 'dundate'=>1, },
186 'active' => { 'susp'=>1, 'cancel'=>1 },
187 'suspended' => { 'cancel' =>1, 'dundate'=>1, },
192 foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end change_date cancel active )) {
194 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field);
196 next if $beginning == 0 && $ending == 4294967295
197 or $disable{$cgi->param('status')}->{$field};
199 $search_hash{$field} = [ $beginning, $ending ];
203 my $sql_query = FS::cust_pkg->search(\%search_hash);
204 my $count_query = delete($sql_query->{'count_query'});
206 my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/
212 my $frag = 'cust_pkg'. $self->pkgnum; #hack for IE ignoring real #fragment
213 [ "${p}view/cust_main.cgi?custnum=".$self->custnum.
214 "$show;fragment=$frag#cust_pkg",
220 my $cust_pkg = shift;
221 $cust_pkg->cust_main_custnum
222 ? [ "${p}view/cust_main.cgi?", 'custnum' ]
230 my $value = $record->get($column); #mmm closures
231 $value ? time2str('%b %d %Y', $value ) : '';
235 my $html_init = sub {
238 my $curuser = $FS::CurrentUser::CurrentUser;
240 if ( $curuser->access_right('Bulk change customer packages') ) {
241 $text .= include('/elements/init_overlib.html').
242 include( '/elements/popup_link.html',
243 'label' => emt('Change these packages'),
244 'action' => "${p}misc/bulk_change_pkg.cgi?$query",
245 'actionlabel' => emt('Change Packages'),
250 if ( $curuser->access_right('Edit customer package dates') ) {
251 $text .= include( '/elements/popup_link.html',
252 'label' => emt('Increment next bill date'),
253 'action' => "${p}misc/bulk_pkg_increment_bill.cgi?$query",
254 'actionlabel' => emt('Increment Bill Date'),
259 $text .= include( '/elements/email-link.html',
260 'search_hash' => \%search_hash,
261 'table' => 'cust_pkg',
267 my $large_pkg_size = $conf->config('cust_pkg-large_pkg_size');
269 my $process_svc_labels = sub {
270 my $cust_pkg = shift;
272 foreach my $part_svc ( $cust_pkg->part_svc) {
273 # some false laziness with view/cust_main/packages/services.html
275 my $num_cust_svc = $cust_pkg->num_cust_svc( $part_svc->svcpart );
277 if ( $large_pkg_size > 0 and $large_pkg_size <= $num_cust_svc ) {
278 my $href = $p.'search/cust_pkg_svc.html?svcpart='.$part_svc->svcpart.
279 ';pkgnum='.$cust_pkg->pkgnum;
281 { 'data' => $part_svc->svc . ':',
284 { 'data' => mt('(view all [_1])', $num_cust_svc),
290 { 'data' => include('/elements/search-cust_svc.html',
291 'svcpart' => $part_svc->svcpart,
292 'pkgnum' => $cust_pkg->pkgnum,
298 foreach ( map { [ $_->label ] } @{ $part_svc->cust_pkg_svc } ) {
300 { 'data' => $_->[0]. ':',
301 'align'=> 'right', },
304 'link' => $p. 'view/' .
305 $_->[2]. '.cgi?'. $_->[3], },