summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorivan <ivan>2006-08-10 11:55:50 +0000
committerivan <ivan>2006-08-10 11:55:50 +0000
commit264ad081e68057c7bc30a8b2ad741b783e1342ff (patch)
treeee1376c0552c6a40f3c3d6cf05a4a25e6b16fcf8 /httemplate
parent6495ab5fb29dcdb8233f004b5d60d3d97db058b9 (diff)
agent-virtualize advertising sources
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/browse/part_referral.html (renamed from httemplate/browse/part_referral.cgi)73
-rwxr-xr-xhttemplate/edit/part_referral.cgi44
-rwxr-xr-xhttemplate/edit/part_referral.html9
-rwxr-xr-xhttemplate/edit/process/part_referral.cgi28
-rwxr-xr-xhttemplate/edit/process/part_referral.html5
-rw-r--r--httemplate/elements/menu.html52
6 files changed, 100 insertions, 111 deletions
diff --git a/httemplate/browse/part_referral.cgi b/httemplate/browse/part_referral.html
index 238ddace7..fff433ae0 100755
--- a/httemplate/browse/part_referral.cgi
+++ b/httemplate/browse/part_referral.html
@@ -1,11 +1,9 @@
-<!-- mason kludge -->
-<%= include("/elements/header.html","Advertising source Listing", menubar(
- 'Main Menu' => $p,
-# 'Add new referral' => "../edit/part_referral.cgi",
-)) %>
+<%= include("/elements/header.html","Advertising source Listing" ) %>
+
Where a customer heard about your service. Tracked for informational purposes.
<BR><BR>
-<A HREF="<%= $p %>edit/part_referral.cgi"><I>Add a new advertising source</I></A>
+
+<A HREF="<%= $p %>edit/part_referral.html"><I>Add a new advertising source</I></A>
<BR><BR>
<%
@@ -34,36 +32,73 @@ Where a customer heard about your service. Tracked for informational purposes.
'Total' => 86400, # 60sec * 60min * 24hrs
);
+ my $curuser = $FS::CurrentUser::CurrentUser;
+ my $extra_sql = $curuser->agentnums_sql;
+ $extra_sql .= ' OR agentnum IS NULL '
+ if $curuser->access_right('Edit global advertising sources');
+
+ $extra_sql = " WHERE $extra_sql";
+
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 = '';
%>
-<%= table() %>
<TR>
- <TH COLSPAN=2 ROWSPAN=2>Advertising source</TH>
- <TH COLSPAN=<%= scalar(keys %after) %>>Customers</TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=2 ROWSPAN=2>Advertising source</TH>
+ <% if ( $show_agentnums ) { %>
+ <TH CLASS="grid" BGCOLOR="#cccccc" ROWSPAN=2>Agent</TH>
+ <% } %>
+ <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=<%= scalar(keys %after) %>>Customers</TH>
</TR>
<% for my $period ( keys %after ) { %>
- <TH><FONT SIZE=-1><%= $period %></FONT></TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1><%= $period %></FONT></TH>
<% } %>
</TR>
<%
-foreach my $part_referral ( sort {
- $a->getfield('refnum') <=> $b->getfield('refnum')
-} qsearch('part_referral',{}) ) {
+foreach my $part_referral (
+
+ qsearch({
+ 'table' => 'part_referral',
+ 'extra_sql' => "$extra_sql ORDER BY refnum",
+ })
+
+) {
+
+ if ( $bgcolor eq $bgcolor1 ) {
+ $bgcolor = $bgcolor2;
+ } else {
+ $bgcolor = $bgcolor1;
+ }
+
%>
<TR>
- <TD><A HREF="<%= $p %>edit/part_referral.cgi?<%= $part_referral->refnum %>">
+
+ <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><A HREF="<%= $p %>edit/part_referral.html?<%= $part_referral->refnum %>">
<%= $part_referral->refnum %></A></TD>
- <TD><A HREF="<%= $p %>edit/part_referral.cgi?<%= $part_referral->refnum %>">
+ <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><A HREF="<%= $p %>edit/part_referral.html?<%= $part_referral->refnum %>">
<%= $part_referral->referral %></A></TD>
+
+ <% if ( $show_agentnums ) { %>
+ <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},
@@ -71,7 +106,7 @@ foreach my $part_referral ( sort {
) or die $sth->errstr;
my $number = $sth->fetchrow_arrayref->[0];
%>
- <TD ALIGN="right"><%= $number %></TD>
+ <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"><%= $number %></TD>
<% } %>
</TR>
<% } %>
@@ -82,14 +117,14 @@ foreach my $part_referral ( sort {
or die dbh->errstr;
%>
<TR>
- <TH COLSPAN=2>Total</TH>
+ <TD BGCOLOR="#dddddd" 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];
%>
- <TD ALIGN="right"><%= $number %></TD>
+ <TD BGCOLOR="#dddddd" ALIGN="right"><%= $number %></TD>
<% } %>
</TR>
</TABLE>
diff --git a/httemplate/edit/part_referral.cgi b/httemplate/edit/part_referral.cgi
deleted file mode 100755
index dce1e6394..000000000
--- a/httemplate/edit/part_referral.cgi
+++ /dev/null
@@ -1,44 +0,0 @@
-<%
-
-my $part_referral;
-if ( $cgi->param('error') ) {
- $part_referral = new FS::part_referral ( {
- map { $_, scalar($cgi->param($_)) } fields('part_referral')
- } );
-} elsif ( $cgi->keywords ) {
- my($query) = $cgi->keywords;
- $query =~ /^(\d+)$/;
- $part_referral = qsearchs( 'part_referral', { 'refnum' => $1 } );
-} else { #adding
- $part_referral = new FS::part_referral {};
-}
-my $action = $part_referral->refnum ? 'Edit' : 'Add';
-my $hashref = $part_referral->hashref;
-
-my $p1 = popurl(1);
-
-%><%= include('/elements/header.html', "$action Advertising source", menubar(
- 'Main Menu' => popurl(2),
- 'View all advertising sources' => popurl(2). "browse/part_referral.cgi",
-)) %>
-
-<% if ( $cgi->param('error') ) { %>
- <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT>
-<% } %>
-
-<FORM ACTION="<%= $p1 %>process/part_referral.cgi" METHOD=POST>
-
-<INPUT TYPE="hidden" NAME="refnum" VALUE="<%= $hashref->{refnum} %>">
-
-<%
-#print "Referral #", $hashref->{refnum} ? $hashref->{refnum} : "(NEW)";
-%>
-
-Advertising source <INPUT TYPE="text" NAME="referral" SIZE=32 VALUE="<%= $hashref->{referral} %>">
-
-<BR>
-<INPUT TYPE="submit" VALUE="<%= $hashref->{refnum} ? "Apply changes" : "Add advertising source" %>">
-
-</FORM>
-
-<%= include('/elements/footer.html') %>
diff --git a/httemplate/edit/part_referral.html b/httemplate/edit/part_referral.html
new file mode 100755
index 000000000..ec0f32f58
--- /dev/null
+++ b/httemplate/edit/part_referral.html
@@ -0,0 +1,9 @@
+<%= include( 'elements/edit.html',
+ 'name' => 'Advertising source',
+ 'table' => 'part_referral',
+ 'fields' => [ 'referral' ],
+ 'labels' => { 'referral' => 'Advertising source' },
+ 'viewall_dir' => 'browse',
+ 'html_table_bottom' => include('/elements/tr-select-agent.html'),
+ )
+%>
diff --git a/httemplate/edit/process/part_referral.cgi b/httemplate/edit/process/part_referral.cgi
deleted file mode 100755
index fd2c01506..000000000
--- a/httemplate/edit/process/part_referral.cgi
+++ /dev/null
@@ -1,28 +0,0 @@
-<%
-
-my $refnum = $cgi->param('refnum');
-
-my $new = new FS::part_referral ( {
- map {
- $_, scalar($cgi->param($_));
- } fields('part_referral')
-} );
-
-my $error;
-if ( $refnum ) {
- my $old = qsearchs( 'part_referral', { 'refnum' =>$ refnum } );
- die "(Old) Record not found!" unless $old;
- $error = $new->replace($old);
-} else {
- $error = $new->insert;
-}
-$refnum=$new->refnum;
-
-if ( $error ) {
- $cgi->param('error', $error);
- print $cgi->redirect(popurl(2). "part_referral.cgi?". $cgi->query_string );
-} else {
- print $cgi->redirect(popurl(3). "browse/part_referral.cgi");
-}
-
-%>
diff --git a/httemplate/edit/process/part_referral.html b/httemplate/edit/process/part_referral.html
new file mode 100755
index 000000000..0b5d959a0
--- /dev/null
+++ b/httemplate/edit/process/part_referral.html
@@ -0,0 +1,5 @@
+<%= include( 'elements/process.html',
+ 'table' => 'part_referral',
+ 'viewall_dir' => 'browse',
+ )
+%>
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index 8c62d9778..a5b41aefd 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -189,26 +189,36 @@
'View/Edit address blocks' => [ $fsurl.'browse/addr_block.cgi', 'Manage address blocks and block assignments to broadband routers' ],
;
- tie my %config_misc, 'Tie::IxHash',
- 'View/Edit advertising sources' => [ $fsurl.'browse/part_referral.cgi', 'Where a customer heard about your service. Tracked for informational purposes' ],
- 'View/Edit virtual fields' => [ $fsurl.'browse/part_virtual_field.cgi', 'Locally defined fields', ],
- 'View/Edit message catalog' => [ $fsurl.'browse/msgcat.cgi', 'Change error messages and other customizable labels' ],
- 'View/Edit inventory classes and inventory' => [ $fsurl.'browse/inventory_class.html', 'Setup inventory classes and stock inventory' ],
- ;
+ tie my %config_misc, 'Tie::IxHash';
+ $config_misc{'View/Edit advertising sources'} = [ $fsurl.'browse/part_referral.html', 'Where a customer heard about your service. Tracked for informational purposes' ]
+ if $curuser->access_right('Configuration')
+ || $curuser->access_right('Edit advertising sources')
+ || $curuser->access_right('Edit global advertising sources');
+ if ( $curuser->access_right('Configuration') ) {
+ $config_misc{'View/Edit virtual fields'} = [ $fsurl.'browse/part_virtual_field.cgi', 'Locally defined fields', ];
+ $config_misc{'View/Edit message catalog'} = [ $fsurl.'browse/msgcat.cgi', 'Change error messages and other customizable labels' ];
+ $config_misc{'View/Edit inventory classes and inventory'} = [ $fsurl.'browse/inventory_class.html', 'Setup inventory classes and stock inventory' ];
+ }
- tie my %config_menu, 'Tie::IxHash',
- 'Settings' => [ $fsurl.'config/config-view.cgi', '' ],
- 'separator' => '', #its a separator!
- 'Employees' => [ \%config_employees, '' ],
- 'Provisioning, services and packages'
- => [ \%config_export_svc_pkg, '' ],
- 'Resellers' => [ \%config_agent, '' ],
- 'Billing' => [ \%config_billing, '' ],
- 'Dialup' => [ \%config_dialup, '' ],
- 'Fixed (username-less) broadband'
- => [ \%config_broadband, '' ],
- 'Miscellaneous' => [ \%config_misc, '' ],
- ;
+ tie my %config_menu, 'Tie::IxHash';
+ if ( $curuser->access_right('Configuration' ) ) {
+ %config_menu = (
+ 'Settings' => [ $fsurl.'config/config-view.cgi', '' ],
+ 'separator' => '', #its a separator!
+ 'Employees' => [ \%config_employees, '' ],
+ 'Provisioning, services and packages'
+ => [ \%config_export_svc_pkg, '' ],
+ 'Resellers' => [ \%config_agent, '' ],
+ 'Billing' => [ \%config_billing, '' ],
+ 'Dialup' => [ \%config_dialup, '' ],
+ 'Fixed (username-less) broadband'
+ => [ \%config_broadband, '' ],
+ );
+ }
+ $config_menu{'Miscellaneous'} = [ \%config_misc, '' ]
+ if $curuser->access_right('Configuration')
+ || $curuser->access_right('Edit advertising sources')
+ || $curuser->access_right('Edit global advertising sources');
tie my %menu, 'Tie::IxHash',
'Billing Main' => [ $fsurl, 'Billing start page', ],
@@ -225,7 +235,9 @@
$menu{'Tools'} = [ \%tools_menu, 'Tools' ]
if keys %tools_menu;
$menu{'Configuration'} = [ \%config_menu, 'Configuraiton and setup' ]
- if $curuser->access_right('Configuration');
+ if $curuser->access_right('Configuration')
+ || $curuser->access_right('Edit advertising sources')
+ || $curuser->access_right('Edit global advertising sources');
use vars qw($gmenunum);
$gmenunum = 0;