1 <& elements/search.html,
5 'count_query' => $count_query,
8 'align' => 'rrrl'. FS::UI::Web::cust_aligns(),
12 'cell_style' => [ $date_color_sub ],
15 my $curuser = $FS::CurrentUser::CurrentUser;
16 die 'access denied' unless $curuser->access_right('List packages');
19 'contract_end' => 'Contract end',
20 # We could put any of the date fields in cust_pkg in here, but keep in
22 # - for start_date, setup, and bill, make sure to include rows where
23 # the field is null, as that's effectively "right now".
24 # - for cancel and susp, and maybe expire, adjourn, and resume, add a
25 # column for the cancel or suspend reason.
26 # - for expire, also figure out if there's a future change scheduled.
27 # - for change_date, should probably show what it was changed from.
30 my $col = $cgi->param('date');
31 die "invalid date column" unless $cols{$col};
33 my $title = 'Packages by ' . lc($cols{$col}) . ' date';
34 my $cust_fields = $cgi->param('cust_fields');
35 my @header = ( $cols{$col},
39 # anything else? package status, maybe?
41 my @fields = ( sub { time2str('%b %d %Y', $_[0]->$col) },
46 my @sort_fields = ( map '', @fields ); # should only ever sort by $col
47 my @color = ( map '', @fields );
48 my @style = ( map '', @fields );
50 push @header, FS::UI::Web::cust_header($cust_fields);
51 push @fields, \&FS::UI::Web::cust_fields;
52 push @color, FS::UI::Web::cust_colors();
53 push @style, FS::UI::Web::cust_styles();
55 my $agentnums_sql = $curuser->agentnums_sql('table' => 'cust_main');
56 if ( $cgi->param('agentnum') =~ /^(\d+)$/ and $1 ) {
57 $agentnums_sql .= " AND agentnum = $1";
61 'table' => 'cust_pkg',
62 'addl_from' => FS::UI::Web::join_cust_main('cust_pkg', 'cust_pkg'),
64 $col => { op => '!=', value => '' },
67 'extra_sql' => ' AND '.$agentnums_sql,
68 'order_by' => "ORDER BY $col",
72 "SELECT COUNT(*) FROM cust_pkg JOIN cust_main USING (custnum) ".
73 "WHERE $col IS NOT NULL AND cancel IS NULL AND $agentnums_sql";
77 my $frag = 'cust_pkg'. $self->pkgnum;
78 [ "${p}view/cust_main.cgi?custnum=".$self->custnum.
79 ";show=packages;fragment=$frag#cust_pkg",
84 my @links = ( '', ($pkg_link) x 3,
85 FS::UI::Web::cust_links() );
87 my $date_color_sub = sub {
90 my $interval = ($self->$col - time) / 86400;
91 if ( $interval > 30 ) {
93 } elsif ( $interval > 0 ) {
98 "background-color: $color";