From d983a08166ca2bfcc16062a4e6820f8985569394 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 2 Apr 2009 00:14:30 +0000 Subject: add some (undocumented/unaccessable to web UI yet) options to package browse to track down packages missing recurring fees --- httemplate/browse/part_pkg.cgi | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'httemplate/browse/part_pkg.cgi') diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index 801c09f8f..26028b6ad 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -10,7 +10,7 @@ 'agent_pos' => 5, 'query' => { 'select' => $select, 'table' => 'part_pkg', - 'hashref' => {}, + 'hashref' => \%hash, 'extra_sql' => $extra_sql, 'order_by' => "ORDER BY $orderby" }, @@ -41,14 +41,37 @@ my $money_char = $conf->config('money_char') || '$'; my $select = '*'; my $orderby = 'pkgpart'; +my %hash = (); +my $extra_count = ''; + if ( $cgi->param('active') ) { $orderby = 'num_active DESC'; } my $extra_sql = ''; +#if ( $cgi->param('activeONLY') ) { +# $extra_sql = ' WHERE num_active > 0 '; #XXX doesn't affect count... +#} + +if ( $cgi->param('recurring') ) { + $hash{'freq'} = { op=>'!=', value=>'0' }; + $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; +} + unless ( $acl_edit_global ) { - $extra_sql .= ' WHERE '. FS::part_pkg->curuser_pkgs_sql; + $extra_sql .= ( ( scalar(keys %hash) || $extra_sql ) ? ' AND ' : ' WHERE ' ). + FS::part_pkg->curuser_pkgs_sql; } my $agentnums = join(',', $curuser->agentnums); @@ -188,9 +211,7 @@ if ( $acl_edit_global ) { my $typelink = $p. 'edit/agent_type.cgi?'; push @fields, sub { my $part_pkg = shift; [ - map { warn $_; - my $agent_type = $_->agent_type; - warn $agent_type; + map { my $agent_type = $_->agent_type; [ { 'data' => $agent_type->atype, #escape? 'align' => 'left', @@ -362,6 +383,10 @@ $align .= 'lrl'; #rr'; # -------- -my $count_query = "SELECT COUNT(*) FROM part_pkg $extra_sql"; +my $count_extra_sql = $extra_sql; +$count_extra_sql =~ s/^\s*AND /WHERE /i; +$extra_count = ( $count_extra_sql ? ' AND ' : ' WHERE ' ). $extra_count + if $extra_count; +my $count_query = "SELECT COUNT(*) FROM part_pkg $count_extra_sql $extra_count"; -- cgit v1.2.1 From 9832f4d4086970d7612ff2a6facd797fa85d7814 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 31 May 2009 06:59:37 +0000 Subject: package definition browse/search, filter by package class, RT#5255 --- httemplate/browse/part_pkg.cgi | 61 +++++++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 13 deletions(-) (limited to 'httemplate/browse/part_pkg.cgi') 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\n"; + +#restore this so pagination works +$cgi->param('classnum', $classnum) if length($classnum); + +my $html_posttotal = + "$filter_change\n
( 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' ]; -- cgit v1.2.1 From 19701fd4538d5e3a00766a7ad88ae46d23f12f1a Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 31 May 2009 08:39:19 +0000 Subject: add "hide one-time charges" toggle, RT#5255 --- httemplate/browse/part_pkg.cgi | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'httemplate/browse/part_pkg.cgi') diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index 886c6c849..8c961b839 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -57,7 +57,7 @@ my @where = (); if ( $cgi->param('recurring') ) { $hash{'freq'} = { op=>'!=', value=>'0' }; - $extra_count = ' freq != 0 '; + $extra_count = " freq != '0' "; } my $classnum = ''; @@ -152,6 +152,14 @@ my $html_posttotal = ). ' )'; +my $recur_toggle = $cgi->param('recurring') ? 'show' : 'hide'; +$cgi->param('recurring', $cgi->param('recurring') ^ 1 ); + +$html_posttotal .= + '( '. "$recur_toggle one-time charges )"; + +$cgi->param('recurring', $cgi->param('recurring') ^ 1 ); #put it back + # ------ my $link = [ $p.'edit/part_pkg.cgi?', 'pkgpart' ]; -- cgit v1.2.1 From 04a69f9d197efee6fa396bd35d04ae553e669978 Mon Sep 17 00:00:00 2001 From: jeff Date: Sun, 21 Jun 2009 15:21:32 +0000 Subject: CUSTOM packages/actual flag for custom packages #3988 --- httemplate/browse/part_pkg.cgi | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'httemplate/browse/part_pkg.cgi') diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index 8c961b839..c6cbb81a3 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -4,11 +4,11 @@ 'html_posttotal' => $html_posttotal, 'name' => 'package definitions', 'disableable' => 1, - 'disabled_statuspos' => 3, + 'disabled_statuspos' => 4, 'agent_virt' => 1, 'agent_null_right' => [ $edit, $edit_global ], 'agent_null_right_link' => $edit_global, - 'agent_pos' => 5, + 'agent_pos' => 6, 'query' => { 'select' => $select, 'table' => 'part_pkg', 'hashref' => \%hash, @@ -164,10 +164,12 @@ $cgi->param('recurring', $cgi->param('recurring') ^ 1 ); #put it back my $link = [ $p.'edit/part_pkg.cgi?', 'pkgpart' ]; -my @header = ( '#', 'Package', 'Comment' ); -my @fields = ( 'pkgpart', 'pkg', 'comment' ); -my $align = 'rll'; -my @links = ( $link, $link, '' ); +my @header = ( '#', 'Package', 'Comment', 'Custom' ); +my @fields = ( 'pkgpart', 'pkg', 'comment', + sub{ ''.$_[0]->custom.'' } + ); +my $align = 'rllc'; +my @links = ( $link, $link, '', '' ); unless ( 0 ) { #already showing only one class or something? push @header, 'Class'; -- cgit v1.2.1