X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fbrowse%2Fpart_pkg.cgi;h=0b83fc000fc2773e9ab430b3f956426efddf2e89;hp=0afa54750f89cc29a2edb8886790157b2ff710e3;hb=eb4ff7f73c5d4bdf74a3472448b5a195598ff4cd;hpb=1a033848671cad2cbe7687b37fc718b3b2a68b83 diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index 0afa54750..0b83fc000 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -1,18 +1,33 @@ -<% +<% 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'; if ( $cgi->param('active') ) { - $orderby = 'num_active'; - + $orderby = 'num_active DESC'; +} $select = " *, @@ -33,13 +48,13 @@ if ( $cgi->param('active') ) { "; -} +#} my $conf = new FS::Conf; my $taxclasses = $conf->exists('enable_taxclasses'); my $html_init; -unless ( $cgi->param('active') ) { +#unless ( $cgi->param('active') ) { $html_init = qq! One or more service definitions are grouped together into a package definition and given pricing information. Customers purchase packages @@ -47,16 +62,7 @@ unless ( $cgi->param('active') ) { Add a new package definition

!; -} - -my $posttotal; -if ( $cgi->param('showdisabled') ) { - $cgi->param('showdisabled', 0); - $posttotal = '( hide disabled packages )'; -} else { - $cgi->param('showdisabled', 1); - $posttotal = '( show disabled packages )'; -} +#} # ------ @@ -66,18 +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 - 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'; @@ -85,31 +79,46 @@ unless ( 0 ) { #already showing only one class or something? $align .= 'l'; } -if ( $cgi->param('active') ) { +#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" : '' ), }, @@ -117,7 +126,7 @@ if ( $cgi->param('active') ) { } (qw( active suspended cancelled )) ]; }; $align .= 'r'; -} +#} push @header, 'Frequency'; push @fields, sub { shift->freq_pretty; }; @@ -146,7 +155,7 @@ push @fields, sub { shift->plan || '(legacy)' }, { 'data' => $1, 'align' => 'right', }, - { 'data' => $2, + { 'data' => $part_pkg->format($1,$2), 'align' => 'left', }, ]; @@ -212,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, - ) -%> + +