summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorivan <ivan>2009-04-02 00:14:30 +0000
committerivan <ivan>2009-04-02 00:14:30 +0000
commitd983a08166ca2bfcc16062a4e6820f8985569394 (patch)
tree9d4845bc40a85fc84784a533014543b0b4e87adc /httemplate
parent9483773ebd5056d28ca55fa0895492dd255c2542 (diff)
add some (undocumented/unaccessable to web UI yet) options to package browse to track down packages missing recurring fees
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/browse/part_pkg.cgi37
1 files changed, 31 insertions, 6 deletions
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";
</%init>