X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_pkg_discount.html;h=ab6ad2bd07eb9e1062472250ed3af567db7c56cb;hp=23af1802eee6bb1ace3d6db22ed11e78daf09076;hb=11bbf29de447fe39e9d7155fe280a0df70fa8c3c;hpb=c13c6407510f6fd1783ce0fbd97800afa27c30b5 diff --git a/httemplate/search/cust_pkg_discount.html b/httemplate/search/cust_pkg_discount.html index 23af1802e..ab6ad2bd0 100644 --- a/httemplate/search/cust_pkg_discount.html +++ b/httemplate/search/cust_pkg_discount.html @@ -6,6 +6,7 @@ #'redirect' => $link, 'header' => [ 'Status', 'Discount', + 'Class', 'Months used', 'Employee', 'Package', @@ -16,9 +17,8 @@ 'fields' => [ sub { ucfirst( shift->status ) }, sub { shift->discount->description }, - sub { my $m = shift->months_used; - $m =~ /\./ ? sprintf('%.2f',$m) : $m; - }, + sub { shift->discount->classname }, + $months_used_sub, 'otaker', 'pkg', \&FS::UI::Web::cust_fields, @@ -29,17 +29,19 @@ '', '', '', + '', ( map { $_ ne 'Cust. Status' ? $clink : ''} FS::UI::Web::cust_header() ), ], - 'align' => 'clrll'. FS::UI::Web::cust_aligns(), + 'align' => 'clcrll'. FS::UI::Web::cust_aligns(), 'color' => [ '', '', '', '', '', + '', FS::UI::Web::cust_colors(), ], 'style' => [ @@ -48,6 +50,7 @@ '', '', '', + '', FS::UI::Web::cust_styles(), ], @@ -78,6 +81,47 @@ if ( $cgi->param('status') eq 'active' ) { "; #XXX also end date } +#classnum +#false laziness w/cust_pkg.pm::search +if ( grep { $_ eq 'classnum' } $cgi->param ) { + +# my @classnum = (); +# if ( ref($params->{'classnum'}) ) { +# +# if ( ref($params->{'classnum'}) eq 'HASH' ) { +# @classnum = grep $params->{'classnum'}{$_}, keys %{ $params->{'classnum'} }; +# } elsif ( ref($params->{'classnum'}) eq 'ARRAY' ) { +# @classnum = @{ $params->{'classnum'} }; +# } else { +# die 'unhandled classnum ref '. $params->{'classnum'}; +# } +# +# +# } elsif ( $params->{'classnum'} =~ /^(\d*)$/ && $1 ne '0' ) { +# @classnum = ( $1 ); +# } +# +# if ( @classnum ) { + + if ( $cgi->param('classnum') =~ /^(\d*)$/ && $1 ne '0' ) { + my @classnum = ( $1 ); + + my @c_where = (); + my @nums = grep $_, @classnum; + push @c_where, 'discount.classnum IN ('. join(',',@nums). ')' if @nums; + my $null = scalar( grep { $_ eq '' } @classnum ); + push @c_where, 'discount.classnum IS NULL' if $null; + + if ( scalar(@c_where) == 1 ) { + push @where, @c_where; + } elsif ( @c_where ) { + push @where, ' ( '. join(' OR ', @c_where). ' ) '; + } + + } + +} + #usernum if ( $cgi->param('usernum') =~ /^(\d+)$/ ) { push @where, "cust_pkg_discount.usernum = $1"; @@ -119,4 +163,9 @@ my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; my $conf = new FS::Conf; +my $months_used_sub = sub { + my $cust_pkg_discount = shift; + return 'Setup only' if $cust_pkg_discount->setuprecur eq 'setup'; + return sprintf('%.2f', $cust_pkg_discount->months_used); +};