X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fbrowse%2Fpart_pkg.cgi;h=0b83fc000fc2773e9ab430b3f956426efddf2e89;hp=b67a5e55f96d3a8d5ed43550c77eb1afc87aa423;hb=eb4ff7f73c5d4bdf74a3472448b5a195598ff4cd;hpb=8af88c7428552043516f529007645ab489b32063
diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi
index b67a5e55f..0b83fc000 100755
--- a/httemplate/browse/part_pkg.cgi
+++ b/httemplate/browse/part_pkg.cgi
@@ -1,11 +1,26 @@
-<%
+<% include( 'elements/browse.html',
+ 'title' => 'Package Definitions',
+ 'menubar' => [ 'Main Menu' => $p ],
+ 'html_init' => $html_init,
+ 'name' => 'package definitions',
+ 'disableable' => 1,
+ 'disabled_statuspos' => 3,
+ 'query' => { 'select' => $select,
+ 'table' => 'part_pkg',
+ 'hashref' => {},
+ 'extra_sql' => "ORDER BY $orderby",
+ },
+ 'count_query' => $count_query,
+ 'header' => \@header,
+ 'fields' => \@fields,
+ 'links' => \@links,
+ 'align' => $align,
+ )
+%>
+<%init>
-my %search = ();
-my $search = '';
-unless ( $cgi->param('showdisabled') ) {
- %search = ( 'disabled' => '' );
- $search = "( disabled = '' OR disabled IS NULL )";
-}
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
my $select = '*';
my $orderby = 'pkgpart';
@@ -49,18 +64,6 @@ my $html_init;
!;
#}
-my $posttotal;
-if ( $cgi->param('showdisabled') ) {
- $cgi->param('showdisabled', 0);
- $posttotal = '( hide disabled packages )';
- $cgi->param('showdisabled', 1);
-} else {
- $cgi->param('showdisabled', 1);
- $posttotal = '( show disabled packages )';
- $cgi->param('showdisabled', 0);
-}
-
-
# ------
my $link = [ $p.'edit/part_pkg.cgi?', 'pkgpart' ];
@@ -69,19 +72,6 @@ my @header = ( '#', 'Package', 'Comment' );
my @fields = ( 'pkgpart', 'pkg', 'comment' );
my $align = 'rll';
my @links = ( $link, $link, '' );
-my @style = ( '', '', '' );
-
-#unless ( $cgi->param('showdisabled') ) { #its been reversed already
-if ( $cgi->param('showdisabled') ) { #its been reversed already
- push @header, 'Status';
- push @fields, sub { shift->disabled
- ? 'DISABLED'
- : 'Active'
- };
- push @links, '';
- $align .= 'c';
- push @style, 'b';
-}
unless ( 0 ) { #already showing only one class or something?
push @header, 'Class';
@@ -92,28 +82,43 @@ unless ( 0 ) { #already showing only one class or something?
#if ( $cgi->param('active') ) {
push @header, 'Customer
packages';
my %col = (
- 'active' => '00CC00',
- 'suspended' => 'FF9900',
- 'cancelled' => 'FF0000',
+ 'active' => '00CC00',
+ 'suspended' => 'FF9900',
+ 'cancelled' => 'FF0000',
+ #'one-time charge' => '000000',
+ 'charge' => '000000',
);
my $cust_pkg_link = $p. 'search/cust_pkg.cgi?pkgpart=';
push @fields, sub { my $part_pkg = shift;
[
map {
+ my $magic = $_;
+ my $label = $_;
+ if ( $magic eq 'active' && $part_pkg->freq == 0 ) {
+ $magic = 'inactive';
+ #$label = 'one-time charge',
+ $label = 'charge',
+ }
+
[
{
- 'data' => ''.
+ 'data' => ''.
$part_pkg->get("num_$_").
'',
'align' => 'right',
},
{
- 'data' => $_,
+ 'data' => $label.
+ ( $part_pkg->get("num_$_") != 1
+ && $label =~ /charge$/
+ ? 's'
+ : ''
+ ),
'align' => 'left',
'link' => ( $part_pkg->get("num_$_")
? $cust_pkg_link.
$part_pkg->pkgpart.
- ";magic=$_"
+ ";magic=$magic"
: ''
),
},
@@ -150,7 +155,7 @@ push @fields, sub { shift->plan || '(legacy)' },
{ 'data' => $1,
'align' => 'right',
},
- { 'data' => $2,
+ { 'data' => $part_pkg->format($1,$2),
'align' => 'left',
},
];
@@ -216,25 +221,5 @@ $align .= 'lrl'; #rr';
# --------
my $count_query = 'SELECT COUNT(*) FROM part_pkg';
-$count_query .= " WHERE $search"
- if $search;
-
-%><%= include( 'elements/browse.html',
- 'title' => 'Package Definitions',
- 'menubar' => [ 'Main Menu' => $p ],
- 'html_init' => $html_init,
- 'html_posttotal' => $posttotal,
- 'name' => 'package definitions',
- 'query' => { 'select' => $select,
- 'table' => 'part_pkg',
- 'hashref' => \%search,
- 'extra_sql' => "ORDER BY $orderby",
- },
- 'count_query' => $count_query,
- 'header' => \@header,
- 'fields' => \@fields,
- 'links' => \@links,
- 'align' => $align,
- 'style' => \@style,
- )
-%>
+
+%init>