diff options
author | ivan <ivan> | 2009-05-31 06:59:37 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-05-31 06:59:37 +0000 |
commit | 9832f4d4086970d7612ff2a6facd797fa85d7814 (patch) | |
tree | 1a4be172ef73fd9b9584022599fb3eccf868c6a5 /httemplate | |
parent | 650c968bf1493c601dcf1b57d98ef0bdb1a2caa6 (diff) |
package definition browse/search, filter by package class, RT#5255
Diffstat (limited to 'httemplate')
-rwxr-xr-x | httemplate/browse/part_pkg.cgi | 61 | ||||
-rw-r--r-- | httemplate/elements/select-table.html | 9 |
2 files changed, 55 insertions, 15 deletions
diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index 26028b6ad..886c6c849 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -1,6 +1,7 @@ <% include( 'elements/browse.html', 'title' => 'Package Definitions', 'html_init' => $html_init, + 'html_posttotal' => $html_posttotal, 'name' => 'package definitions', 'disableable' => 1, 'disabled_statuspos' => 3, @@ -48,10 +49,10 @@ if ( $cgi->param('active') ) { $orderby = 'num_active DESC'; } -my $extra_sql = ''; +my @where = (); #if ( $cgi->param('activeONLY') ) { -# $extra_sql = ' WHERE num_active > 0 '; #XXX doesn't affect count... +# push @where, ' WHERE num_active > 0 '; #XXX doesn't affect count... #} if ( $cgi->param('recurring') ) { @@ -59,21 +60,30 @@ if ( $cgi->param('recurring') ) { $extra_count = ' freq != 0 '; } -if ( $cgi->param('missing_recur_fee') ) { - my $missing = "0 = ( SELECT COUNT(*) FROM part_pkg_option - WHERE optionname = 'recur_fee' - AND part_pkg_option.pkgpart = part_pkg.pkgpart - AND CAST ( optionvalue AS NUMERIC ) > 0 - )"; - $extra_sql .= ( ( scalar(keys %hash) || $extra_sql ) ? ' AND ' : ' WHERE ' ). - $missing; +my $classnum = ''; +if ( $cgi->param('classnum') =~ /^(\d+)$/ ) { + $classnum = $1; + push @where, $classnum ? "classnum = $classnum" + : "classnum IS NULL"; } +$cgi->delete('classnum'); -unless ( $acl_edit_global ) { - $extra_sql .= ( ( scalar(keys %hash) || $extra_sql ) ? ' AND ' : ' WHERE ' ). - FS::part_pkg->curuser_pkgs_sql; +if ( $cgi->param('missing_recur_fee') ) { + push @where, "0 = ( SELECT COUNT(*) FROM part_pkg_option + WHERE optionname = 'recur_fee' + AND part_pkg_option.pkgpart = part_pkg.pkgpart + AND CAST ( optionvalue AS NUMERIC ) > 0 + )"; } +push @where, FS::part_pkg->curuser_pkgs_sql + unless $acl_edit_global; + +my $extra_sql = scalar(@where) + ? ( scalar(keys %hash) ? ' AND ' : ' WHERE ' ). + join( 'AND ', @where) + : ''; + my $agentnums = join(',', $curuser->agentnums); my $count_cust_pkg = " SELECT COUNT(*) FROM cust_pkg LEFT JOIN cust_main USING ( custnum ) @@ -117,6 +127,31 @@ my $html_init; !; #} +$cgi->param('dummy', 1); + +my $filter_change = + qq(\n<SCRIPT TYPE="text/javascript">\n). + "function filter_change() {". + " window.location = '". $cgi->self_url. + ";classnum=' + document.getElementById('classnum').options[document.getElementById('classnum').selectedIndex].value". + "}". + "\n</SCRIPT>\n"; + +#restore this so pagination works +$cgi->param('classnum', $classnum) if length($classnum); + +my $html_posttotal = + "$filter_change\n<BR>( show class: ". + include('/elements/select-pkg_class.html', + #'curr_value' => $classnum, + 'value' => $classnum, #insist on 0 :/ + 'onchange' => 'filter_change()', + 'pre_options' => [ '-1' => 'all', + '0' => '(none)', ], + 'disable_empty' => 1, + ). + ' )'; + # ------ my $link = [ $p.'edit/part_pkg.cgi?', 'pkgpart' ]; diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html index e7baaf53b..1a440f07e 100644 --- a/httemplate/elements/select-table.html +++ b/httemplate/elements/select-table.html @@ -64,8 +64,13 @@ Example: > % while ( @pre_options ) { - <OPTION VALUE="<% shift(@pre_options) %>"><% shift(@pre_options) %> - +% my $pre_opt = shift(@pre_options); +% my $pre_label = shift(@pre_options); +% my $selected = ( ref($value) && $value->{$pre_opt} ) +% || ( $value eq $pre_opt ); + <OPTION VALUE="<% $pre_opt %>" + <% $selected ? 'SELECTED' : '' %> + ><% $pre_label %> % } % unless ( $opt{'multiple'} || $opt{'disable_empty'} ) { |