summaryrefslogtreecommitdiff
path: root/httemplate/browse
diff options
context:
space:
mode:
authorivan <ivan>2007-08-01 22:26:52 +0000
committerivan <ivan>2007-08-01 22:26:52 +0000
commiteb4ff7f73c5d4bdf74a3472448b5a195598ff4cd (patch)
treebb38241e8c865c3bca861da7749071feeadd2b5b /httemplate/browse
parent32b5d3a31f112a381f0a15ac5e3a2204242f3405 (diff)
event refactor, landing on HEAD!
Diffstat (limited to 'httemplate/browse')
-rw-r--r--httemplate/browse/access_group.html56
-rw-r--r--httemplate/browse/access_user.html81
-rwxr-xr-xhttemplate/browse/agent.cgi39
-rw-r--r--httemplate/browse/invoice_template.html124
-rwxr-xr-xhttemplate/browse/part_bill_event.cgi2
-rw-r--r--httemplate/browse/part_event.html157
-rwxr-xr-xhttemplate/browse/part_pkg.cgi68
-rwxr-xr-xhttemplate/browse/part_referral.html163
-rw-r--r--httemplate/browse/pkg_class.html1
-rw-r--r--httemplate/browse/reason.html19
10 files changed, 488 insertions, 222 deletions
diff --git a/httemplate/browse/access_group.html b/httemplate/browse/access_group.html
index ca162a094..ccb64e152 100644
--- a/httemplate/browse/access_group.html
+++ b/httemplate/browse/access_group.html
@@ -27,10 +27,7 @@
],
)
%>
-<%init>
-
-die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+<%once>
my $html_init =
"Internal access groups control access to the back-office interface.<BR><BR>".
@@ -58,20 +55,45 @@ my $agents_sub = sub {
};
+tie my %rights, 'Tie::IxHash', FS::AccessRight->rights_info;
+
my $rights_sub = sub {
my $access_group = shift;
- [ map { my $access_right = $_;
- [
- {
- 'data' => $access_right->rightname,
- 'align' => 'left',
- },
- ];
- }
- $access_group->access_rights,
+ #[ map { my $access_right = $_;
+ # [
+ # {
+ # 'data' => $access_right->rightname,
+ # 'align' => 'left',
+ # },
+ # ];
+ # }
+ # $access_group->access_rights,
+ #];
- ];
+ #some false laziness w/edit/access_group.html
+ my $columns = 3;
+ my $count = 0;
+
+ #include('/elements/table-grid.html', bgcolor=>'#cccccc' ).
+ '<TABLE>'.
+ '<TR>'. join( '', map {
+
+ '<TD CLASS="inv" VALIGN="top"><TABLE WIDTH=100%>'.
+ '<TR><TH BGCOLOR="#dcdcdc">'. $_. '</TH></TR>'.
+ '<TR><TD>'.
+
+ join('<BR>', grep { warn "$access_group->access_right($_): ".
+ $access_group->access_right($_). "\n";
+ $access_group->access_right($_); }
+ map { ref($_) ? $_->{'rightname'} : $_; }
+ @{ $rights{$_} }
+ ).
+
+ '</TD></TR></TABLE></TD>'.
+ ( ++$count % $columns ? '' : '</TR><TR>')
+
+ } keys %rights ). '</TR></TABLE>';
};
@@ -79,4 +101,10 @@ my $count_query = 'SELECT COUNT(*) FROM access_group';
my $link = [ $p.'edit/access_group.html?', 'groupnum' ];
+</%once>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
</%init>
diff --git a/httemplate/browse/access_user.html b/httemplate/browse/access_user.html
index 8eb3e330a..83fc36329 100644
--- a/httemplate/browse/access_user.html
+++ b/httemplate/browse/access_user.html
@@ -1,20 +1,21 @@
<% include( 'elements/browse.html',
- 'title' => 'Internal Users',
- 'menubar' => [ #'Main menu' => $p,
- 'Internal access groups' => $p.'browse/access_group.html',
- ],
- 'html_init' => $html_init,
- 'html_posttotal' => $posttotal,
- 'name' => 'internal users',
- 'query' => { 'table' => 'access_user',
- 'hashref' => \%search,
- 'extra_sql' => 'ORDER BY last, first',
- },
- 'count_query' => $count_query,
- 'header' => \@header,
- 'fields' => \@fields,
- 'links' => \@links,
- 'style' => \@style,
+ 'title' => 'Internal Users',
+ 'menubar' => [ #'Main menu' => $p,
+ 'Internal access groups' => $p.'browse/access_group.html',
+ ],
+ 'html_init' => $html_init,
+ 'name' => 'internal users',
+ 'disableable' => 1,
+ 'disabled_statuspos' => 2,
+ 'query' => { 'table' => 'access_user',
+ 'hashref' => {},
+ 'extra_sql' => 'ORDER BY last, first'
+ },
+ 'count_query' => $count_query,
+ 'header' => \@header,
+ 'fields' => \@fields,
+ 'links' => \@links,
+ 'align' => $align,
)
%>
<%init>
@@ -26,14 +27,6 @@ my $html_init =
"Internal users have access to the back-office interface. Typically, this is your employees and contractors, but in a VISP setup, you can also add accounts for your reseller's employees. It is <B>highly recommended</B> to add a <B>separate account for each person</B> rather than using role accounts.<BR><BR>".
qq!<A HREF="${p}edit/access_user.html"><I>Add an internal user</I></A><BR><BR>!;
-#false laziness w/part_pkg.cgi
-my %search = ();
-my $search = '';
-unless ( $cgi->param('showdisabled') ) {
- %search = ( 'disabled' => '' );
- $search = "( disabled = '' OR disabled IS NULL )";
-}
-
#false laziness w/access_group.html & agent_type.cgi
my $groups_sub = sub {
my $access_user = shift;
@@ -58,45 +51,13 @@ my $groups_sub = sub {
};
-my $posttotal;
-if ( $cgi->param('showdisabled') ) {
- $cgi->param('showdisabled', 0);
- $posttotal = '( <a href="'. $cgi->self_url. '">hide disabled users</a> )';
- $cgi->param('showdisabled', 1);
-} else {
- $cgi->param('showdisabled', 1);
- $posttotal = '( <a href="'. $cgi->self_url. '">show disabled users</a> )';
- $cgi->param('showdisabled', 0);
-}
-
my $count_query = 'SELECT COUNT(*) FROM access_user';
-$count_query .= " WHERE $search"
- if $search;
my $link = [ $p.'edit/access_user.html?', 'usernum' ];
-my @header = ( '#', 'Username' );
-my @fields = ( 'usernum', 'username' );
-my $align = 'rl';
-my @links = ( $link, $link );
-my @style = ( '', '' );
-
-#false laziness w/part_pkg.cgi
-#unless ( $cgi->param('showdisabled') ) { #its been reversed already
-if ( $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';
-}
-
-push @header, 'Full name', 'Groups';
-push @fields, 'name', $groups_sub;
-push @links, $link, '';
-$align .= 'll';
+my @header = ( '#', 'Username', 'Full name', 'Groups' );
+my @fields = ( 'usernum', 'username', 'name', $groups_sub );
+my $align = 'rlll';
+my @links = ( $link, $link, $link, '' );
</%init>
diff --git a/httemplate/browse/agent.cgi b/httemplate/browse/agent.cgi
index 83e79a2f3..46a924433 100755
--- a/httemplate/browse/agent.cgi
+++ b/httemplate/browse/agent.cgi
@@ -27,10 +27,11 @@ full offerings (via their type).<BR><BR>
<TR>
<TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=<% ( $cgi->param('showdisabled') || !dbdef->table('agent')->column('disabled') ) ? 2 : 3 %>>Agent</TH>
<TH CLASS="grid" BGCOLOR="#cccccc">Type</TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Invoice<BR>Template</FONT></TH>
<TH CLASS="grid" BGCOLOR="#cccccc">Customers</TH>
<TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Customer<BR>packages</FONT></TH>
<TH CLASS="grid" BGCOLOR="#cccccc">Reports</TH>
- <TH CLASS="grid" BGCOLOR="#cccccc">Registration codes</TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Registration<BR>codes</FONT></TH>
<TH CLASS="grid" BGCOLOR="#cccccc">Prepaid cards</TH>
% if ( $conf->config('ticket_system') ) {
@@ -39,8 +40,6 @@ full offerings (via their type).<BR><BR>
<TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Payment Gateway Overrides</FONT></TH>
<TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Configuration Overrides</FONT></TH>
- <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Freq.</FONT></TH>
- <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Prog.</FONT></TH>
</TR>
%
%# <TH><FONT SIZE=-1>Agent #</FONT></TH>
@@ -66,18 +65,29 @@ full offerings (via their type).<BR><BR>
<TR>
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><A HREF="<%$p%>edit/agent.cgi?<% $agent->agentnum %>">
- <% $agent->agentnum %></A></TD>
-% if ( dbdef->table('agent')->column('disabled')
-% && !$cgi->param('showdisabled') ) {
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $agent->disabled ? 'DISABLED' : '' %></TD>
-% }
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+ <A HREF="<%$p%>edit/agent.cgi?<% $agent->agentnum %>"><% $agent->agentnum %></A>
+ </TD>
+
+% if ( dbdef->table('agent')->column('disabled')
+% && !$cgi->param('showdisabled') ) {
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+ <% $agent->disabled ? 'DISABLED' : '' %>
+ </TD>
+% }
+
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+ <A HREF="<%$p%>edit/agent.cgi?<% $agent->agentnum %>"><% $agent->agent %></A>
+ </TD>
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+ <A HREF="<%$p%>edit/agent_type.cgi?<% $agent->typenum %>"><% $agent->agent_type->atype %></A>
+ </TD>
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><A HREF="<%$p%>edit/agent.cgi?<% $agent->agentnum %>">
- <% $agent->agent %></A></TD>
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><A HREF="<%$p%>edit/agent_type.cgi?<% $agent->typenum %>"><% $agent->agent_type->atype %></A></TD>
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+ <% $agent->invoice_template || '(Default)' %>
+ </TD>
<TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
<TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
@@ -366,11 +376,6 @@ Unused
</TABLE>
</TD>
-<!--
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $agent->freq %></TD>
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $agent->prog %></TD>
--->
-
</TR>
% }
diff --git a/httemplate/browse/invoice_template.html b/httemplate/browse/invoice_template.html
new file mode 100644
index 000000000..0bbfb2452
--- /dev/null
+++ b/httemplate/browse/invoice_template.html
@@ -0,0 +1,124 @@
+<% include("/elements/header.html", 'Invoice templates') %>
+
+<% include('/elements/table-grid.html') %>
+% my $bgcolor1 = '#eeeeee';
+% my $bgcolor2 = '#ffffff';
+% my $bgcolor = '';
+
+<TR>
+ <TH CLASS="grid" BGCOLOR="#cccccc">Template</TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc">HTML</TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc">Print/PDF (typeset)</TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc">Plaintext</TH>
+</TR>
+
+% foreach my $templatename ( '', @templatenames ) {
+% my $tname = length($templatename) ? "_$templatename" : '';
+%
+% if ( $bgcolor eq $bgcolor1 ) {
+% $bgcolor = $bgcolor2;
+% } else {
+% $bgcolor = $bgcolor1;
+% }
+%
+% my $display = length($templatename) ? $templatename : '<i>(Default)</i>';
+
+ <TR>
+
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+ <% $display %>
+ </TD>
+
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+
+% my( $logo_label, $logo_link_label)= length( $templatename )
+% ? labels("logo_$templatename.png")
+% : ( '', 'edit' );
+ <% $logo_label %> Logo
+ (<A HREF="<% $p %>edit/invoice_logo.html?type=png;name=<% $templatename %>"><% $logo_link_label %></A>)
+ <BR>
+
+% foreach my $suffix (qw( returnaddress notes footer), '' ) {
+% my $file = "invoice_html$suffix$tname";
+% my($label, $link_label) = length($templatename)
+% ? labels($file)
+% : ( '', 'edit' );
+
+ <% $label %> <% $suffix2name{$suffix} %>
+ (<A HREF="<% $p %>edit/invoice_template.html?type=html;suffix=<% $suffix %>;name=<% $templatename %>"><% $link_label %></A>)
+ <BR>
+
+% }
+
+ </TD>
+
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+
+% my( $logo_label, $logo_link_label)= length( $templatename )
+% ? labels("logo_$templatename.eps")
+% : ( '', 'edit' );
+ <% $logo_label %> Logo
+ (<A HREF="<% $p %>edit/invoice_logo.html?type=eps;name=<% $templatename %>"><% $logo_link_label %></A>)
+ <BR>
+
+% foreach my $suffix (qw( returnaddress notes footer smallfooter), '' ) {
+% my $file = "invoice_latex$suffix$tname";
+% my($label, $link_label) = length($templatename)
+% ? labels($file)
+% : ( '', 'edit' );
+
+ <% $label %> <% $suffix2name{$suffix} %>
+ (<A HREF="<% $p %>edit/invoice_template.html?type=latex;suffix=<% $suffix %>;name=<% $templatename %>"><% $link_label %></A>)
+ <BR>
+
+% }
+
+ </TD>
+
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+
+% my( $txt_label, $txtlink_label)=
+% length( $templatename )
+% ? labels("invoice_template_$templatename.png")
+% : ( 'Main template', 'edit' );
+ <% $txt_label %>
+ (<A HREF="<% $p %>edit/invoice_template.html?type=text;name=<% $templatename %>"><% $txtlink_label %></A>)
+
+ </TD>
+
+ </TR>
+
+% }
+
+<% include("/elements/footer.html") %>
+
+<%once>
+
+my %suffix2name = (
+ 'returnaddress' => 'Return address',
+ 'notes' => 'Notes',
+ 'footer' => 'Footer',
+ 'smallfooter' => 'Small footer',
+ '' => 'Main template',
+);
+
+my $conf = new FS::Conf;
+
+sub labels {
+ my $filename = shift;
+ if ( $conf->exists($filename) ) {
+ ( 'Custom', 'edit' );
+ } else {
+ ( 'Standard', 'customize' );
+ }
+}
+
+</%once>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my @templatenames = $conf->invoice_templatenames;
+
+</%init>
diff --git a/httemplate/browse/part_bill_event.cgi b/httemplate/browse/part_bill_event.cgi
index 682058b1d..a7071bcde 100755
--- a/httemplate/browse/part_bill_event.cgi
+++ b/httemplate/browse/part_bill_event.cgi
@@ -1,6 +1,6 @@
<% include("/elements/header.html",'Invoice Event Listing', menubar( 'Main Menu' => $p) ) %>
- Invoice events are actions taken on open invoices.<BR><BR>
+ <FONT SIZE="+1">Invoice events are the deprecated, old-style actions taken on open invoices. Any events still listed here should be migrated to new-style events.</FONT><BR><BR>
<A HREF="<% $p %>edit/part_bill_event.cgi"><I>Add a new invoice event</I></A>
<BR><BR>
diff --git a/httemplate/browse/part_event.html b/httemplate/browse/part_event.html
new file mode 100644
index 000000000..4a0582633
--- /dev/null
+++ b/httemplate/browse/part_event.html
@@ -0,0 +1,157 @@
+<% include( 'elements/browse.html',
+ 'title' => 'Billing Event Definitions',
+ 'html_init' => $html_init,
+ 'name' => 'billing event definitions',
+ 'disableable' => 1,
+ 'disabled_statuspos' => 2,
+ 'agent_virt' => 1,
+ 'agent_null_right' => 'Edit global billing events',
+ 'agent_pos' => 3,
+ 'query' => { 'select' => 'part_event.*',
+ 'table' => 'part_event',
+ 'addl_from' => $join_conditions,
+ 'hashref' => {},
+ 'order_by' => $order_conditions,
+ },
+ 'count_query' => $count_query,
+ 'header' => [ '#',
+ 'Event',
+ 'Type',
+ 'Check freq.',
+ 'Conditions',
+ 'Action',
+ ],
+ 'fields' => [ 'eventpart',
+ 'event',
+ $eventtable_sub,
+ $check_freq_sub,
+ $conditions_sub,
+ $action_sub,
+ ],
+ 'links' => [ $link,
+ $link,
+ '',
+ '',
+ '',
+ '',
+ ],
+ 'align' => 'rllccc',
+ )
+%>
+<%once>
+
+my $eventtable_labels = FS::part_event->eventtable_labels;
+my $eventtable_sub = sub { $eventtable_labels->{ shift->eventtable }; };
+
+my $check_freq_labels = FS::part_event->check_freq_labels;
+my $check_freq_sub = sub { $check_freq_labels->{ shift->check_freq }; };
+
+my $conditions_sub = sub {
+ my $part_event = shift;
+ my $addl = 0;
+
+ [
+ map {
+ my $part_event_condition = $_;
+ my %options = $part_event_condition->options;
+
+ [
+ {
+ 'data' => $part_event_condition->description,
+ 'width' => '100%',
+ 'align' => 'center',
+ 'colspan' => 2,
+ 'style' => ( $addl++ ? 'border-top: 1px solid gray' : '' ),
+ },
+ ],
+
+ map {
+
+ my $data = $options{$_};
+ if ( ref($data) ) {
+ $data = join('<BR>', keys %$data); #XXX display hash values too?
+ }
+
+ [
+ {
+ 'data' => $part_event_condition->option_label($_). ':',
+ 'align' => 'right',
+ 'valign' => 'top',
+ 'size' => '-1',
+ },
+ {
+ 'data' => $data,
+ 'align' => 'left',
+ 'size' => '-1',
+ },
+ ];
+
+ } keys %options
+
+ }
+ $part_event->part_event_condition
+
+ ];
+
+};
+
+my $action_sub = sub {
+ my $part_event = shift;
+
+ my %options = $part_event->options;
+
+ [
+
+ [
+ {
+ 'data' => $part_event->description,
+ 'width' => '100%',
+ 'align' => 'center',
+ 'colspan' => 2,
+ },
+ ],
+
+ map {
+ [
+ {
+ 'data' => $part_event->option_label($_). ':',
+ 'align' => 'right',
+ 'size' => '-1',
+ },
+ {
+ 'data' => $options{$_},
+ 'align' => 'left',
+ 'size' => '-1',
+ },
+ ];
+ }
+
+ keys %options
+ ];
+
+};
+
+my $link = [ $p.'edit/part_event.html?', 'eventpart' ];
+
+</%once>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Edit billing events')
+ || $FS::CurrentUser::CurrentUser->access_right('Edit global billing events');
+
+my $html_init =
+ #XXX better description
+ 'Events are billing, collection or other actions triggered when certain '.
+ 'customer, invoice, package or other conditions are met.<BR><BR>'.
+ qq!<A HREF="${p}edit/part_event.html"><I>Add a new event</I></A><BR><BR>!;
+
+my $count_query = 'SELECT COUNT(*) FROM part_event WHERE '.
+ $FS::CurrentUser::CurrentUser->agentnums_sql(
+ 'null_right' => 'Edit global billing events',
+ );
+
+my $join_conditions = FS::part_event_condition->join_conditions_sql;
+my $order_conditions = FS::part_event_condition->order_conditions_sql;
+
+</%init>
diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi
index 5acf17ef2..0b83fc000 100755
--- a/httemplate/browse/part_pkg.cgi
+++ b/httemplate/browse/part_pkg.cgi
@@ -1,20 +1,20 @@
<% 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,
+ '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>
@@ -22,14 +22,6 @@
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
-#false laziness w/access_user.html
-my %search = ();
-my $search = '';
-unless ( $cgi->param('showdisabled') ) {
- %search = ( 'disabled' => '' );
- $search = "( disabled = '' OR disabled IS NULL )";
-}
-
my $select = '*';
my $orderby = 'pkgpart';
if ( $cgi->param('active') ) {
@@ -72,18 +64,6 @@ my $html_init;
!;
#}
-my $posttotal;
-if ( $cgi->param('showdisabled') ) {
- $cgi->param('showdisabled', 0);
- $posttotal = '( <a href="'. $cgi->self_url. '">hide disabled packages</a> )';
- $cgi->param('showdisabled', 1);
-} else {
- $cgi->param('showdisabled', 1);
- $posttotal = '( <a href="'. $cgi->self_url. '">show disabled packages</a> )';
- $cgi->param('showdisabled', 0);
-}
-
-
# ------
my $link = [ $p.'edit/part_pkg.cgi?', 'pkgpart' ];
@@ -92,20 +72,6 @@ my @header = ( '#', 'Package', 'Comment' );
my @fields = ( 'pkgpart', 'pkg', 'comment' );
my $align = 'rll';
my @links = ( $link, $link, '' );
-my @style = ( '', '', '' );
-
-#false laziness w/access_user.html
-#unless ( $cgi->param('showdisabled') ) { #its been reversed already
-if ( $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';
@@ -255,7 +221,5 @@ $align .= 'lrl'; #rr';
# --------
my $count_query = 'SELECT COUNT(*) FROM part_pkg';
-$count_query .= " WHERE $search"
- if $search;
</%init>
diff --git a/httemplate/browse/part_referral.html b/httemplate/browse/part_referral.html
index 065d8c1c1..21ee8736b 100755
--- a/httemplate/browse/part_referral.html
+++ b/httemplate/browse/part_referral.html
@@ -5,54 +5,11 @@ Where a customer heard about your service. Tracked for informational purposes.
<A HREF="<% $p %>edit/part_referral.html"><I>Add a new advertising source</I></A>
<BR><BR>
-%
-% my $today = timelocal(0, 0, 0, (localtime(time))[3..5] );
-% my %after;
-% tie %after, 'Tie::IxHash',
-% 'Today' => 0,
-% 'Yesterday' => 86400, # 60sec * 60min * 24hrs
-% 'Past week' => 518400, # 60sec * 60min * 24hrs * 6days
-% 'Past 30 days' => 2505600, # 60sec * 60min * 24hrs * 29days
-% 'Past 60 days' => 5097600, # 60sec * 60min * 24hrs * 59days
-% 'Past 90 days' => 7689600, # 60sec * 60min * 24hrs * 89days
-% 'Past 6 months' => 15724800, # 60sec * 60min * 24hrs * 182days
-% 'Past year' => 31486000, # 60sec * 60min * 24hrs * 364days
-% 'Total' => $today,
-% ;
-% my %before = (
-% 'Today' => 86400, # 60sec * 60min * 24hrs
-% 'Yesterday' => 0,
-% 'Past week' => 86400, # 60sec * 60min * 24hrs
-% 'Past 30 days' => 86400, # 60sec * 60min * 24hrs
-% 'Past 60 days' => 86400, # 60sec * 60min * 24hrs
-% 'Past 90 days' => 86400, # 60sec * 60min * 24hrs
-% 'Past 6 months' => 86400, # 60sec * 60min * 24hrs
-% 'Past year' => 86400, # 60sec * 60min * 24hrs
-% 'Total' => 86400, # 60sec * 60min * 24hrs
-% );
-%
-% my $curuser = $FS::CurrentUser::CurrentUser;
-%
-% my $statement = "SELECT COUNT(*) FROM h_cust_main
-% WHERE history_action = 'insert'
-% AND refnum = ?
-% AND history_date >= ?
-% AND history_date < ?
-% AND ". $curuser->agentnums_sql;
-% my $sth = dbh->prepare($statement)
-% or die dbh->errstr;
-%
-% my $show_agentnums = scalar($curuser->agentnums);
-%
-%
-
<% include('/elements/table-grid.html') %>
% my $bgcolor1 = '#eeeeee';
% my $bgcolor2 = '#ffffff';
% my $bgcolor = '';
-%
-
<TR>
<TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=2 ROWSPAN=2>Advertising source</TH>
@@ -61,7 +18,7 @@ Where a customer heard about your service. Tracked for informational purposes.
<TH CLASS="grid" BGCOLOR="#cccccc" ROWSPAN=2>Agent</TH>
% }
- <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=<% scalar(keys %after) %>>Customers</TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=<% scalar(keys %after) %>>Customers and Packages</TH>
</TR>
% for my $period ( keys %after ) {
@@ -69,7 +26,7 @@ Where a customer heard about your service. Tracked for informational purposes.
% }
</TR>
-%
+
%foreach my $part_referral ( FS::part_referral->all_part_referral(1) ) {
%
% if ( $bgcolor eq $bgcolor1 ) {
@@ -79,8 +36,6 @@ Where a customer heard about your service. Tracked for informational purposes.
% }
%
% $a = 0;
-%
-%
<TR>
@@ -105,34 +60,63 @@ Where a customer heard about your service. Tracked for informational purposes.
<TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $part_referral->agentnum ? $part_referral->agent->agent : '(global)' %></TD>
% }
% for my $period ( keys %after ) {
-% $sth->execute( $part_referral->refnum,
-% $today-$after{$period},
-% $today+$before{$period},
-% ) or die $sth->errstr;
-% my $number = $sth->fetchrow_arrayref->[0];
-%
-
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="right"><% $number %></TD>
+% my @param = ( $part_referral->refnum,
+% $today-$after{$period},
+% $today+$before{$period},
+% );
+% $cust_sth->execute(@param) or die $cust_sth->errstr;
+% my $num_cust = $cust_sth->fetchrow_arrayref->[0];
+% $pkg_sth->execute(@param) or die $pkg_sth->errstr;
+% my $num_pkg = $pkg_sth->fetchrow_arrayref->[0];
+
+ <TD CLASS="inv" BGCOLOR="<% $bgcolor %>" ALIGN="right">
+ <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
+ <TR>
+ <TD ALIGN="right"><B><% $num_cust %></B></TD>
+ <TD ALIGN="left">customers</TD>
+ </TR>
+ <TR>
+ <TD ALIGN="right"><B><% $num_pkg %></B></TD>
+ <TD ALIGN="left">packages</TD>
+ </TR>
+ </TABLE>
+ </TD>
% }
</TR>
% }
%
-% $statement =~ s/AND refnum = \?//;
-% $sth = dbh->prepare($statement)
+% $cust_statement =~ s/AND refnum = \?//;
+% $cust_sth = dbh->prepare($cust_statement)
+% or die dbh->errstr;
+% $pkg_statement =~ s/AND h_pkg_referral\.refnum = \?//;
+% $pkg_sth = dbh->prepare($pkg_statement)
% or die dbh->errstr;
-%
<TR>
<TD BGCOLOR="#dddddd" ALIGN="center" COLSPAN=3><B>Total</B></TD>
% for my $period ( keys %after ) {
-% $sth->execute( $today-$after{$period},
-% $today+$before{$period},
-% ) or die $sth->errstr;
-% my $number = $sth->fetchrow_arrayref->[0];
-%
+% my @param = ( $today-$after{$period},
+% $today+$before{$period},
+% );
+% $cust_sth->execute( @param ) or die $cust_sth->errstr;
+% my $num_cust = $cust_sth->fetchrow_arrayref->[0];
+% $pkg_sth->execute(@param) or die $pkg_sth->errstr;
+% my $num_pkg = $pkg_sth->fetchrow_arrayref->[0];
+
+ <TD CLASS="inv" BGCOLOR="#dddddd" ALIGN="right">
+ <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
+ <TR>
+ <TD ALIGN="right"><B><% $num_cust %></B></TD>
+ <TD ALIGN="left">customers</TD>
+ </TR>
+ <TR>
+ <TD ALIGN="right"><B><% $num_pkg %></B></TD>
+ <TD ALIGN="left">packages</TD>
+ </TR>
+ </TABLE>
+ </TD>
- <TD BGCOLOR="#dddddd" ALIGN="right"><B><% $number %><B></TD>
% }
</TR>
@@ -140,8 +124,59 @@ Where a customer heard about your service. Tracked for informational purposes.
</BODY>
</HTML>
<%init>
+
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Configuration')
|| $FS::CurrentUser::CurrentUser->access_right('Edit advertising sources')
|| $FS::CurrentUser::CurrentUser->access_right('Edit global advertising sources');
+
+my $today = timelocal(0, 0, 0, (localtime(time))[3..5] );
+
+tie my %after, 'Tie::IxHash',
+ 'Today' => 0,
+ 'Yesterday' => 86400, # 60sec * 60min * 24hrs
+ 'Past week' => 518400, # 60sec * 60min * 24hrs * 6days
+ 'Past 30 days' => 2505600, # 60sec * 60min * 24hrs * 29days
+ 'Past 60 days' => 5097600, # 60sec * 60min * 24hrs * 59days
+ 'Past 90 days' => 7689600, # 60sec * 60min * 24hrs * 89days
+ 'Past 6 months' => 15724800, # 60sec * 60min * 24hrs * 182days
+ 'Past year' => 31486000, # 60sec * 60min * 24hrs * 364days
+ 'Total' => $today,
+;
+my %before = (
+ 'Today' => 86400, # 60sec * 60min * 24hrs
+ 'Yesterday' => 0,
+ 'Past week' => 86400, # 60sec * 60min * 24hrs
+ 'Past 30 days' => 86400, # 60sec * 60min * 24hrs
+ 'Past 60 days' => 86400, # 60sec * 60min * 24hrs
+ 'Past 90 days' => 86400, # 60sec * 60min * 24hrs
+ 'Past 6 months' => 86400, # 60sec * 60min * 24hrs
+ 'Past year' => 86400, # 60sec * 60min * 24hrs
+ 'Total' => 86400, # 60sec * 60min * 24hrs
+);
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+
+my $show_agentnums = ( scalar($curuser->agentnums) > 1 );
+
+my $cust_statement = "SELECT COUNT(*) FROM h_cust_main
+ WHERE history_action = 'insert'
+ AND refnum = ?
+ AND history_date >= ?
+ AND history_date < ?
+ AND ". $curuser->agentnums_sql;
+my $cust_sth = dbh->prepare($cust_statement)
+ or die dbh->errstr;
+
+my $pkg_statement = "SELECT COUNT(*) FROM h_pkg_referral
+ LEFT JOIN cust_pkg USING ( pkgnum )
+ LEFT JOIN cust_main USING ( custnum )
+ WHERE history_action = 'insert'
+ AND h_pkg_referral.refnum = ?
+ AND history_date >= ?
+ AND history_date < ?
+ AND ". $curuser->agentnums_sql;
+my $pkg_sth = dbh->prepare($pkg_statement)
+ or die dbh->errstr;
+
</%init>
diff --git a/httemplate/browse/pkg_class.html b/httemplate/browse/pkg_class.html
index 886029df5..4f02ca22d 100644
--- a/httemplate/browse/pkg_class.html
+++ b/httemplate/browse/pkg_class.html
@@ -3,6 +3,7 @@
'html_init' => $html_init,
'name' => 'package classes',
'disableable' => 1,
+ 'disabled_statuspos' => 2,
'query' => { 'table' => 'pkg_class',
'hashref' => {},
'extra_sql' => 'ORDER BY classnum',
diff --git a/httemplate/browse/reason.html b/httemplate/browse/reason.html
index b017f8f58..94141eea3 100644
--- a/httemplate/browse/reason.html
+++ b/httemplate/browse/reason.html
@@ -7,10 +7,12 @@
],
'html_init' => $html_init,
'name' => $classname . ' reasons',
+ 'disableable' => 1,
+ 'disabled_statuspos' => 3,
'query' => { 'table' => 'reason',
'hashref' => {},
- 'extra_sql' => $where_clause .
- 'ORDER BY reason_type',
+ 'extra_sql' => $where_clause.
+ ' ORDER BY reason_type',
'addl_from' => 'LEFT JOIN reason_type ON reason_type.typenum = reason.reason_type',
},
'count_query' => $count_query,
@@ -47,18 +49,7 @@ my $html_init = ucfirst($classname) .
qq!<A HREF="${p}edit/reason.html?class=$class">!.
"<I>Add a $classname reason</I></A><BR><BR>";
-my $where_clause = "WHERE class='$class'";
-$where_clause .= " AND (disabled = '' OR disabled IS NULL)"
-unless $cgi->param('showdisabled');
-
-my $disabledurl = $cgi->param('showdisabled')
- ? do { $cgi->param('showdisabled', 0);
- '( <a href="'. $cgi->self_url. '">hide disabled reasons</a> )'; }
- : do { $cgi->param('showdisabled', 1);
- '( <a href="'. $cgi->self_url. '">show disabled reasons</a> )'; }
- ;
-
-$html_init .= $disabledurl;
+my $where_clause = " WHERE class='$class' ";
my $count_query = 'SELECT COUNT(*) FROM reason LEFT JOIN reason_type on ' .
'reason_type.typenum = reason.reason_type ' . $where_clause;