-<%
+<% include( 'elements/browse.html',
+ 'title' => 'Package Definitions',
+ 'html_init' => $html_init,
+ 'name' => 'package definitions',
+ 'disableable' => 1,
+ 'disabled_statuspos' => 3,
+ 'agent_virt' => 1,
+ 'agent_null_right' => 'Edit global package definitions',
+ 'agent_pos' => 5,
+ 'query' => { 'select' => $select,
+ 'table' => 'part_pkg',
+ 'hashref' => {},
+ 'order_by' => "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('Edit package definitions')
+ || $FS::CurrentUser::CurrentUser->access_right('Edit global package definitions');
my $select = '*';
my $orderby = 'pkgpart';
my $conf = new FS::Conf;
my $taxclasses = $conf->exists('enable_taxclasses');
+my $money_char = $conf->config('money_char') || '$';
my $html_init;
#unless ( $cgi->param('active') ) {
!;
#}
-my $posttotal;
-if ( $cgi->param('showdisabled') ) {
- $cgi->param('showdisabled', 0);
- $posttotal = '( <a href="'. $cgi->self_url. '">hide disabled packages</a> )';
-} else {
- $cgi->param('showdisabled', 1);
- $posttotal = '( <a href="'. $cgi->self_url. '">show disabled packages</a> )';
-}
-
# ------
my $link = [ $p.'edit/part_pkg.cgi?', 'pkgpart' ];
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
- ? '<FONT COLOR="#FF0000">DISABLED</FONT>'
- : '<FONT COLOR="#00CC00">Active</FONT>'
- };
- push @links, '';
- $align .= 'c';
- push @style, 'b';
-}
unless ( 0 ) { #already showing only one class or something?
push @header, 'Class';
$align .= 'l';
}
+tie my %plans, 'Tie::IxHash', %{ FS::part_pkg::plan_info() };
+
+tie my %plan_labels, 'Tie::IxHash',
+ map { $_ => ( $plans{$_}->{'shortname'} || $plans{$_}->{'name'} ) }
+ keys %plans;
+
+push @header, 'Pricing';
+$align .= 'r'; #?
+push @fields, sub {
+ my $part_pkg = shift;
+
+ [
+ [
+ { data=>$plan_labels{$part_pkg->plan},
+ align=>'center'
+ },
+ ],
+ [
+ { data=>$money_char.
+ sprintf('%.2f setup', $part_pkg->option('setup_fee') ),
+ align=>'right'
+ },
+ ],
+ [
+ { data=>( $part_pkg->freq ne '0'
+ ? $money_char.sprintf('%.2f ', $part_pkg->option('recur_fee') )
+ : ''
+ ).
+ $part_pkg->freq_pretty,
+ align=>'right'
+ },
+ ],
+ ];
+
+# $plan_labels{$part_pkg->plan}.'<BR>'.
+# $money_char.sprintf('%.2f setup<BR>', $part_pkg->option('setup_fee') ).
+# ( $part_pkg->freq ne '0'
+# ? $money_char.sprintf('%.2f ', $part_pkg->option('recur_fee') )
+# : ''
+# ).
+# $part_pkg->freq_pretty; #.'<BR>'
+};
+
#if ( $cgi->param('active') ) {
push @header, 'Customer<BR>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' => '<B><FONT COLOR="#'. $col{$_}. '">'.
+ 'data' => '<B><FONT COLOR="#'. $col{$label}. '">'.
$part_pkg->get("num_$_").
'</FONT></B>',
'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"
: ''
),
},
$align .= 'r';
#}
-push @header, 'Frequency';
-push @fields, sub { shift->freq_pretty; };
-$align .= 'l';
-
if ( $taxclasses ) {
push @header, 'Taxclass';
push @fields, sub { shift->taxclass() || ' '; };
$align .= 'l';
}
-push @header, 'Plan',
- 'Data',
+push @header, 'Plan options',
'Services';
#'Service', 'Quan', 'Primary';
-push @fields, sub { shift->plan || '(legacy)' },
-
+push @fields,
sub {
my $part_pkg = shift;
if ( $part_pkg->plan ) {
{ 'data' => $1,
'align' => 'right',
},
- { 'data' => $2,
+ { 'data' => $part_pkg->format($1,$2),
'align' => 'left',
},
];
# --------
-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,
- )
-%>
+my $count_query = 'SELECT COUNT(*) FROM part_pkg WHERE '.
+ $FS::CurrentUser::CurrentUser->agentnums_sql(
+ 'null_right' => 'Edit global package definitions',
+ );
+
+</%init>