X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fbrowse%2Fpart_pkg.cgi;h=cb74bed665ab3c838e79a344bdf9d191c26ff7e2;hb=66fc0c9ba5d3f460a26a51ee72ee25923d644da8;hp=766806044848ffc3349d7712cc906ea1c9624e1e;hpb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924;p=freeside.git
diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi
index 766806044..cb74bed66 100755
--- a/httemplate/browse/part_pkg.cgi
+++ b/httemplate/browse/part_pkg.cgi
@@ -1,6 +1,8 @@
<% include( 'elements/browse.html',
'title' => 'Package Definitions',
+ 'menubar' => \@menubar,
'html_init' => $html_init,
+ 'html_form' => $html_form,
'html_posttotal' => $html_posttotal,
'name' => 'package definitions',
'disableable' => 1,
@@ -8,7 +10,7 @@
'agent_virt' => 1,
'agent_null_right' => [ $edit, $edit_global ],
'agent_null_right_link' => $edit_global,
- 'agent_pos' => 6,
+ 'agent_pos' => 7, #5?
'query' => { 'select' => $select,
'table' => 'part_pkg',
'hashref' => \%hash,
@@ -20,8 +22,24 @@
'fields' => \@fields,
'links' => \@links,
'align' => $align,
+ 'link_field' => 'pkgpart',
+ 'html_init' => $html_init,
+ 'html_foot' => $html_foot,
)
%>
+<%def .style>
+
+
+%def>
<%init>
my $curuser = $FS::CurrentUser::CurrentUser;
@@ -33,18 +51,22 @@ my $acl_edit_global = $curuser->access_right($edit_global);
my $acl_config = $curuser->access_right('Configuration'); #to edit services
#and agent types
#and bulk change
+my $acl_edit_bulk = $curuser->access_right('Bulk edit package definitions');
die "access denied"
unless $acl_edit || $acl_edit_global;
my $conf = new FS::Conf;
my $taxclasses = $conf->exists('enable_taxclasses');
+my $taxvendor = $conf->config('tax_data_vendor');
my $money_char = $conf->config('money_char') || '$';
+my $disable_counts = $conf->exists('config-disable_counts') ? 1 : 0;
my $select = '*';
my $orderby = 'pkgpart';
my %hash = ();
my $extra_count = '';
+my $family_pkgpart;
if ( $cgi->param('active') ) {
$orderby = 'num_active DESC';
@@ -69,12 +91,34 @@ if ( $cgi->param('classnum') =~ /^(\d+)$/ ) {
}
$cgi->delete('classnum');
+if ( $cgi->param('pkgpartbatch') =~ /^([\w\/\-\:\. ]+)$/ ) {
+ push @where, "pkgpartbatch = '$1' ";
+}
+
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, "NOT EXISTS ( SELECT 1 FROM part_pkg_option
+ WHERE optionname = 'recur_fee'
+ AND part_pkg_option.pkgpart = part_pkg.pkgpart
+ AND CAST( optionvalue AS NUMERIC ) > 0
+ )";
+}
+
+if ( $cgi->param('ratenum') =~ /^(\d+)$/ ) {
+ push @where, "EXISTS( SELECT 1 FROM part_pkg_option
+ WHERE optionname LIKE '%ratenum'
+ AND optionvalue = '$1'
+ AND part_pkg_option.pkgpart = part_pkg.pkgpart
+ )";
+}
+
+if ( $cgi->param('family') =~ /^(\d+)$/ ) {
+ $family_pkgpart = $1;
+ push @where, "family_pkgpart = $1";
+ # Hiding disabled or one-time charges and limiting by classnum aren't
+ # very useful in this mode, so all links should still refer back to the
+ # non-family-limited display.
+ $cgi->param('showdisabled', 1);
+ $cgi->delete('family');
}
push @where, FS::part_pkg->curuser_pkgs_sql
@@ -91,41 +135,62 @@ my $count_cust_pkg = "
WHERE cust_pkg.pkgpart = part_pkg.pkgpart
AND $agentnums_sql
";
+my $count_cust_pkg_cancel = "
+ SELECT COUNT(*) FROM cust_pkg LEFT JOIN cust_main USING ( custnum )
+ LEFT JOIN cust_pkg AS cust_pkg_next
+ ON (cust_pkg.pkgnum = cust_pkg_next.change_pkgnum)
+ WHERE cust_pkg.pkgpart = part_pkg.pkgpart
+ AND $agentnums_sql
+ AND cust_pkg.cancel IS NOT NULL AND cust_pkg.cancel != 0
+";
-$select = "
-
- *,
-
- ( $count_cust_pkg
- AND ( setup IS NULL OR setup = 0 )
- AND ( cancel IS NULL OR cancel = 0 )
- AND ( susp IS NULL OR susp = 0 )
- ) AS num_not_yet_billed,
-
- ( $count_cust_pkg
- AND setup IS NOT NULL AND setup != 0
- AND ( cancel IS NULL OR cancel = 0 )
- AND ( susp IS NULL OR susp = 0 )
- ) AS num_active,
-
- ( $count_cust_pkg
- AND ( cancel IS NULL OR cancel = 0 )
- AND susp IS NOT NULL AND susp != 0
- ) AS num_suspended,
+unless ( $disable_counts ) {
+ $select = "
+
+ *,
+
+ ( $count_cust_pkg
+ AND ( setup IS NULL OR setup = 0 )
+ AND ( cancel IS NULL OR cancel = 0 )
+ AND ( susp IS NULL OR susp = 0 )
+ ) AS num_not_yet_billed,
+
+ ( $count_cust_pkg
+ AND setup IS NOT NULL AND setup != 0
+ AND ( cancel IS NULL OR cancel = 0 )
+ AND ( susp IS NULL OR susp = 0 )
+ ) AS num_active,
+
+ ( $count_cust_pkg
+ AND ( cancel IS NULL OR cancel = 0 )
+ AND susp IS NOT NULL AND susp != 0
+ AND setup IS NOT NULL AND setup != 0
+ ) AS num_suspended,
+
+ ( $count_cust_pkg
+ AND ( cancel IS NULL OR cancel = 0 )
+ AND susp IS NOT NULL AND susp != 0
+ AND ( setup IS NULL OR setup = 0 )
+ ) AS num_on_hold,
+
+ ( $count_cust_pkg_cancel
+ AND (cust_pkg_next.pkgnum IS NULL
+ OR cust_pkg_next.pkgpart != cust_pkg.pkgpart)
+ ) AS num_cancelled
+
+ ";
+}
- ( $count_cust_pkg
- AND cancel IS NOT NULL AND cancel != 0
- ) AS num_cancelled
+# About the num_cancelled expression: packages that were changed, but
+# kept the same pkgpart, are considered "moved", not "canceled" (because
+# this is the part_pkg UI). We could show the count of those but it's
+# probably not interesting.
-";
-
-my $html_init;
-#unless ( $cgi->param('active') ) {
- $html_init = qq!
+my $html_init = qq!
One or more service definitions are grouped together into a package
definition and given pricing information. Customers purchase packages
rather than purchase services directly.