1 <& elements/search.html,
2 'html_init' => $html_init,
3 'title' => emt('Package Search Results'),
6 'count_query' => $count_query,
7 'header' => [ emt('#'),
26 FS::UI::Web::cust_header(
27 $cgi->param('cust_fields')
36 sub { ucfirst(shift->status); },
37 sub { sprintf( $money_char.'%.2f',
38 shift->part_pkg->option('setup_fee'),
42 sprintf( $money_char.'%.2f',
43 $c->part_pkg->base_recur($c)
46 sub { FS::part_pkg::freq_pretty(shift); },
48 ( map { time_or_blank($_) }
49 qw( setup last_bill bill adjourn susp dundate expire contract_end change_date cancel ) ),
51 sub { my $self = shift;
53 foreach my $action ( qw ( cancel susp ) ) {
54 my $reason = $self->last_reason($action);
55 $return = $reason->reason if $reason;
61 \&FS::UI::Web::cust_fields,
64 my $type = $cgi->param('_type') || '';
65 if ($type =~ /xls|csv/) {
66 my $cust_svc = $cust_pkg->primary_cust_svc;
68 return join ": ",($cust_svc->label)[0,1];
75 [ $process_svc_labels->( $cust_pkg ) ]
84 sub { shift->statuscolor; },
99 FS::UI::Web::cust_colors(),
102 'style' => [ '', '', '', '', 'b', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
103 FS::UI::Web::cust_styles() ],
104 'size' => [ '', '', '', '', '-1' ],
105 'align' => 'rrlccrrlrrrrrrrrrrl'. FS::UI::Web::cust_aligns(). 'r',
122 '', # link to changed-from package?
126 ( map { $_ ne 'Cust. Status' ? $clink : '' }
127 FS::UI::Web::cust_header(
128 $cgi->param('cust_fields')
136 my $curuser = $FS::CurrentUser::CurrentUser;
139 unless $curuser->access_right('List packages');
141 my $conf = new FS::Conf;
142 my $money_char = $conf->config('money_char') || '$';
144 my %search_hash = ();
146 #some false laziness w/misc/bulk_change_pkg.cgi
148 $search_hash{'query'} = $cgi->keywords;
151 for (qw( agentnum custnum magic status custom cust_fields pkgbatch )) {
152 $search_hash{$_} = $cgi->param($_) if $cgi->param($_);
156 for my $param (qw( pkgpart classnum )) {
157 $search_hash{$param} = [ $cgi->param($param) ]
158 if grep { $_ eq $param } $cgi->param;
161 #scalars that need to be passed if empty
162 for my $param (qw( censustract censustract2 )) {
163 $search_hash{$param} = $cgi->param($param) || ''
164 if grep { $_ eq $param } $cgi->param;
167 my $report_option = $cgi->param('report_option');
168 $search_hash{report_option} = $report_option if $report_option;
170 for my $param (grep /^report_option_any/, $cgi->param) {
171 $search_hash{$param} = $cgi->param($param);
178 #false laziness w/report_cust_pkg.html
181 'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, 'contract_end'=>1, 'dundate'=>1, },
182 'active' => { 'susp'=>1, 'cancel'=>1 },
183 'suspended' => { 'cancel' =>1, 'dundate'=>1, },
188 foreach my $field (qw( setup last_bill bill adjourn susp expire contract_end change_date cancel active )) {
190 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field);
192 next if $beginning == 0 && $ending == 4294967295
193 or $disable{$cgi->param('status')}->{$field};
195 $search_hash{$field} = [ $beginning, $ending ];
199 my $sql_query = FS::cust_pkg->search(\%search_hash);
200 my $count_query = delete($sql_query->{'count_query'});
202 my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/
208 my $frag = 'cust_pkg'. $self->pkgnum; #hack for IE ignoring real #fragment
209 [ "${p}view/cust_main.cgi?custnum=".$self->custnum.
210 "$show;fragment=$frag#cust_pkg",
216 my $cust_pkg = shift;
217 $cust_pkg->cust_main_custnum
218 ? [ "${p}view/cust_main.cgi?", 'custnum' ]
226 my $value = $record->get($column); #mmm closures
227 $value ? time2str('%b %d %Y', $value ) : '';
231 my $html_init = sub {
234 my $curuser = $FS::CurrentUser::CurrentUser;
236 if ( $curuser->access_right('Bulk change customer packages') ) {
237 $text .= include('/elements/init_overlib.html').
238 include( '/elements/popup_link.html',
239 'label' => emt('Change these packages'),
240 'action' => "${p}misc/bulk_change_pkg.cgi?$query",
241 'actionlabel' => emt('Change Packages'),
246 if ( $curuser->access_right('Edit customer package dates') ) {
247 $text .= include( '/elements/popup_link.html',
248 'label' => emt('Increment next bill date'),
249 'action' => "${p}misc/bulk_pkg_increment_bill.cgi?$query",
250 'actionlabel' => emt('Increment Bill Date'),
255 $text .= include( '/elements/email-link.html',
256 'search_hash' => \%search_hash,
257 'table' => 'cust_pkg',
263 my $large_pkg_size = $conf->config('cust_pkg-large_pkg_size');
265 my $process_svc_labels = sub {
266 my $cust_pkg = shift;
268 foreach my $part_svc ( $cust_pkg->part_svc) {
269 # some false laziness with view/cust_main/packages/services.html
271 my $num_cust_svc = $cust_pkg->num_cust_svc( $part_svc->svcpart );
273 if ( $large_pkg_size > 0 and $large_pkg_size <= $num_cust_svc ) {
274 my $href = $p.'search/cust_pkg_svc.html?svcpart='.$part_svc->svcpart.
275 ';pkgnum='.$cust_pkg->pkgnum;
277 { 'data' => $part_svc->svc . ':',
280 { 'data' => mt('(view all [_1])', $num_cust_svc),
286 { 'data' => include('/elements/search-cust_svc.html',
287 'svcpart' => $part_svc->svcpart,
288 'pkgnum' => $cust_pkg->pkgnum,
294 foreach ( map { [ $_->label ] } @{ $part_svc->cust_pkg_svc } ) {
296 { 'data' => $_->[0]. ':',
297 'align'=> 'right', },
300 'link' => $p. 'view/' .
301 $_->[2]. '.cgi?'. $_->[3], },