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