X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=httemplate%2Fbrowse%2Fpart_pkg.cgi;h=26028b6adfff4af4bf386b81d86026665e0beef8;hb=2b968bffd937b19d2314aa5e304fccc8ec1e1350;hp=780f40b9fa797ad7d51e307e8d3b6f756d5e3a86;hpb=8b72ad2a4d67f46e4bda36179e992d82d069689f;p=freeside.git
diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi
index 780f40b9f..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"
},
@@ -30,6 +30,7 @@ my $edit_global = 'Edit global package definitions';
my $acl_edit = $curuser->access_right($edit);
my $acl_edit_global = $curuser->access_right($edit_global);
my $acl_config = $curuser->access_right('Configuration'); #to edit services
+ #and agent types
die "access denied"
unless $acl_edit || $acl_edit_global;
@@ -40,29 +41,40 @@ 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 = '';
-my $agentnums = join(',', $curuser->agentnums);
+#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 (
- agentnum IS NOT NULL OR 0 < (
- SELECT COUNT(*)
- FROM type_pkgs
- LEFT JOIN agent_type USING ( typenum )
- LEFT JOIN agent AS typeagent USING ( typenum )
- WHERE type_pkgs.pkgpart = part_pkg.pkgpart
- AND typeagent.agentnum IN ($agentnums)
- )
- )
- ";
+ $extra_sql .= ( ( scalar(keys %hash) || $extra_sql ) ? ' AND ' : ' WHERE ' ).
+ FS::part_pkg->curuser_pkgs_sql;
}
+my $agentnums = join(',', $curuser->agentnums);
my $count_cust_pkg = "
SELECT COUNT(*) FROM cust_pkg LEFT JOIN cust_main USING ( custnum )
WHERE cust_pkg.pkgpart = part_pkg.pkgpart
@@ -95,7 +107,12 @@ my $html_init;
One or more service definitions are grouped together into a package
definition and given pricing information. Customers purchase packages
rather than purchase services directly.
+