X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_pkg-date.html;h=231bbac1654d43bab09727f250b202bd9e7e5941;hb=fba328864880d1375780b94911acd9ff33cba805;hp=1b93775467d7c41448a61d4e4c8cbacc08ab7840;hpb=4b05b20576ddb14577d59c87c8257c6804449410;p=freeside.git diff --git a/httemplate/search/cust_pkg-date.html b/httemplate/search/cust_pkg-date.html index 1b9377546..231bbac16 100644 --- a/httemplate/search/cust_pkg-date.html +++ b/httemplate/search/cust_pkg-date.html @@ -1,3 +1,16 @@ +<& elements/search.html, + 'title' => $title, + 'name' => 'packages', + 'query' => $query, + 'count_query' => $count_query, + 'header' => \@header, + 'fields' => \@fields, + 'align' => 'rrrl'. FS::UI::Web::cust_aligns(), + 'color' => \@color, + 'style' => \@style, + 'links' => \@links, + 'cell_style' => [ $date_color_sub ], +&> <%init> my $curuser = $FS::CurrentUser::CurrentUser; die 'access denied' unless $curuser->access_right('List packages'); @@ -18,8 +31,7 @@ my $col = $cgi->param('date'); die "invalid date column" unless $cols{$col}; my $title = 'Packages by ' . lc($cols{$col}) . ' date'; -# second option on the cust_fields_avail list, plus email -my $cust_fields = 'Cust# | Customer | Day phone | Night phone | Mobile phone | Invoicing email(s)'; +my $cust_fields = $cgi->param('cust_fields'); my @header = ( $cols{$col}, emt('#'), emt('Quan.'), @@ -32,9 +44,18 @@ my @fields = ( sub { time2str('%b %d %Y', $_[0]->$col) }, 'pkg_label', ); my @sort_fields = ( map '', @fields ); # should only ever sort by $col +my @color = ( map '', @fields ); +my @style = ( map '', @fields ); push @header, FS::UI::Web::cust_header($cust_fields); push @fields, \&FS::UI::Web::cust_fields; +push @color, FS::UI::Web::cust_colors(); +push @style, FS::UI::Web::cust_styles(); + +my $agentnums_sql = $curuser->agentnums_sql('table' => 'cust_main'); +if ( $cgi->param('agentnum') =~ /^(\d+)$/ and $1 ) { + $agentnums_sql .= " AND agentnum = $1"; +} my $query = { 'table' => 'cust_pkg', @@ -43,11 +64,13 @@ my $query = { $col => { op => '!=', value => '' }, 'cancel' => '', }, - 'order_by' => "ORDER BY $col", + 'extra_sql' => ' AND '.$agentnums_sql, + 'order_by' => "ORDER BY $col", }; my $count_query = - "SELECT COUNT(*) FROM cust_pkg WHERE $col IS NOT NULL AND cancel IS NULL"; + "SELECT COUNT(*) FROM cust_pkg JOIN cust_main USING (custnum) ". + "WHERE $col IS NOT NULL AND cancel IS NULL AND $agentnums_sql"; my $pkg_link = sub { my $self = shift; @@ -76,15 +99,4 @@ my $date_color_sub = sub { }; -<& elements/search.html, - 'title' => $title, - 'name' => 'packages', - 'query' => $query, - 'count_query' => $count_query, - 'header' => \@header, - 'fields' => \@fields, - 'align' => 'rrrl'. FS::UI::Web::cust_aligns(), - 'links' => \@links, - 'cell_style' => [ $date_color_sub ], -&>