summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2005-10-03 01:42:22 +0000
committerivan <ivan>2005-10-03 01:42:22 +0000
commita5bbbed61e09dffffc5d7022cddb3f9ff62a955a (patch)
treef0e0a5d47a996f624da9d602e7022b0acd45d4ec
parent90cdac3ff61ad57b42d2fc4743ad53f7c537e6fe (diff)
update account view and edit: convert to proper templates, make sure usage information displays for any usage-capable export, add ability to edit uid/gid
-rw-r--r--FS/FS/Conf.pm17
-rw-r--r--FS/FS/cust_svc.pm6
-rw-r--r--FS/FS/part_svc.pm16
-rw-r--r--FS/FS/svc_acct.pm9
-rwxr-xr-xhttemplate/edit/svc_acct.cgi449
-rw-r--r--httemplate/elements/small_custview.html2
-rwxr-xr-xhttemplate/view/svc_acct.cgi224
7 files changed, 462 insertions, 261 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 37d649bf9..237ab1e58 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -668,7 +668,7 @@ httemplate/docs/config.html
{
'key' => 'invoice_send_receipts',
- 'section' => 'deprecated',q
+ 'section' => 'deprecated',
'description' => '<b>DEPRECATED</b>, this used to send an invoice copy on payments and credits. See the payment_receipt_email and XXXX instead.',
'type' => 'checkbox',
},
@@ -1569,6 +1569,21 @@ httemplate/docs/config.html
'type' => 'checkbox',
},
+ {
+ 'key' => 'svc_acct-edit_uid',
+ 'section' => 'shell',
+ 'description' => 'Allow UID editing.',
+ 'type' => 'checkbox',
+ },
+
+ {
+ 'key' => 'svc_acct-edit_gid',
+ 'section' => 'shell',
+ 'description' => 'Allow GID editing.',
+ 'type' => 'checkbox',
+ },
+
+
);
1;
diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm
index 2e349f6bd..e69befca2 100644
--- a/FS/FS/cust_svc.pm
+++ b/FS/FS/cust_svc.pm
@@ -384,10 +384,8 @@ sub seconds_since_sqlradacct {
my $svc_x = $self->svc_x;
- my @part_export = $self->part_svc->part_export('sqlradius');
- push @part_export, $self->part_svc->part_export('sqlradius_withdomain');
- die "no sqlradius or sqlradius_withdomain export configured for this".
- "service type"
+ my @part_export = $self->part_svc->part_export_usage;
+ die "no usage-capable export configured for this service type"
unless @part_export;
#or return undef;
diff --git a/FS/FS/part_svc.pm b/FS/FS/part_svc.pm
index 2bb8ab59e..0ece185f7 100644
--- a/FS/FS/part_svc.pm
+++ b/FS/FS/part_svc.pm
@@ -393,8 +393,8 @@ sub all_part_svc_column {
=item part_export [ EXPORTTYPE ]
-Returns all exports (see L<FS::part_export>) for this service, or, if an
-export type is specified, only returns exports of the given type.
+Returns a list of all exports (see L<FS::part_export>) for this service, or,
+if an export type is specified, only returns exports of the given type.
=cut
@@ -406,6 +406,18 @@ sub part_export {
qsearch('export_svc', { 'svcpart' => $self->svcpart } );
}
+=item part_export_usage
+
+Returns a list of any exports (see L<FS::part_export>) for this service that
+are capable of reporting usage information.
+
+=cut
+
+sub part_export_usage {
+ my $self = shift;
+ grep $_->can('usage_sessions'), $self->part_export;
+}
+
=item cust_svc
Returns a list of associated FS::cust_svc records.
diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm
index 4a618108f..167fcee88 100644
--- a/FS/FS/svc_acct.pm
+++ b/FS/FS/svc_acct.pm
@@ -467,7 +467,14 @@ sub replace {
{
#no warnings 'numeric'; #alas, a 5.006-ism
local($^W) = 0;
- return "Can't change uid!" if $old->uid != $new->uid;
+
+ foreach my $xid (qw( uid gid )) {
+
+ return "Can't change $xid!"
+ if ! $conf->exists("svc_acct-edit_$xid")
+ && $old->$xid() != $new->$xid();
+ }
+
}
#change homdir when we change username
diff --git a/httemplate/edit/svc_acct.cgi b/httemplate/edit/svc_acct.cgi
index a730531f5..bc5d96aab 100755
--- a/httemplate/edit/svc_acct.cgi
+++ b/httemplate/edit/svc_acct.cgi
@@ -1,4 +1,3 @@
-<!-- mason kludge -->
<%
my $conf = new FS::Conf;
@@ -6,6 +5,7 @@ my @shells = $conf->config('shells');
my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_acct, @groups);
if ( $cgi->param('error') ) {
+
$svc_acct = new FS::svc_acct ( {
map { $_, scalar($cgi->param($_)) } fields('svc_acct')
} );
@@ -15,7 +15,9 @@ if ( $cgi->param('error') ) {
$part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
die "No part_svc entry for svcpart $svcpart!" unless $part_svc;
@groups = $cgi->param('radius_usergroup');
+
} else {
+
my($query) = $cgi->keywords;
if ( $query =~ /^(\d+)$/ ) { #editing
$svcnum=$1;
@@ -46,35 +48,43 @@ if ( $cgi->param('error') ) {
$svcnum='';
- #set gecos
- my($cust_pkg)=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
- if ($cust_pkg) {
- my($cust_main)=qsearchs('cust_main',{'custnum'=> $cust_pkg->custnum } );
- unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) {
- $svc_acct->setfield('finger',
- $cust_main->getfield('first') . " " . $cust_main->getfield('last')
- );
- }
- }
+ }
+}
+
+my( $cust_pkg, $cust_main ) = ( '', '' );
+if ( $pkgnum ) {
+ $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum } );
+ $cust_main = $cust_pkg->cust_main;
+}
+
+unless ( $svcnum || $cgi->param('error') ) { #adding
- #set fixed and default fields from part_svc
- foreach my $part_svc_column (
- grep { $_->columnflag } $part_svc->all_part_svc_column
- ) {
- if ( $part_svc_column->columnname eq 'usergroup' ) {
- @groups = split(',', $part_svc_column->columnvalue);
- } else {
- $svc_acct->setfield( $part_svc_column->columnname,
- $part_svc_column->columnvalue,
- );
- }
+ #set gecos
+ if ($cust_main) {
+ unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) {
+ $svc_acct->setfield('finger',
+ $cust_main->getfield('first') . " " . $cust_main->getfield('last')
+ );
}
+ }
+ #set fixed and default fields from part_svc
+ foreach my $part_svc_column (
+ grep { $_->columnflag } $part_svc->all_part_svc_column
+ ) {
+ if ( $part_svc_column->columnname eq 'usergroup' ) {
+ @groups = split(',', $part_svc_column->columnvalue);
+ } else {
+ $svc_acct->setfield( $part_svc_column->columnname,
+ $part_svc_column->columnvalue,
+ );
+ }
}
+
}
#fixed radius groups always override & display
-if ( $part_svc->part_svc_column('usergroup')->columnflag eq "F" ) {
+if ( $part_svc->part_svc_column('usergroup')->columnflag eq 'F' ) {
@groups = split(',', $part_svc->part_svc_column('usergroup')->columnvalue);
}
@@ -106,47 +116,81 @@ my $pmax = $conf->config('passwordmax') || 8;
my $pmax2 = $pmax+2;
my $p1 = popurl(1);
-print header("$action $svc account");
-
-print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
- "</FONT><BR><BR>"
- if $cgi->param('error');
-
-print 'Service # '. ( $svcnum ? "<B>$svcnum</B>" : " (NEW)" ). '<BR>'.
- 'Service: <B>'. $part_svc->svc. '</B><BR><BR>'.
- <<END;
- <FORM NAME="OneTrueForm" ACTION="${p1}process/svc_acct.cgi" METHOD=POST>
- <INPUT TYPE="hidden" NAME="svcnum" VALUE="$svcnum">
- <INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">
- <INPUT TYPE="hidden" NAME="svcpart" VALUE="$svcpart">
-END
-
-print &ntable("#cccccc",2), <<END;
-<TR><TD ALIGN="right">Username</TD>
-<TD><INPUT TYPE="text" NAME="username" VALUE="$username" SIZE=$ulen2 MAXLENGTH=$ulen></TD></TR>
-<TR><TD ALIGN="right">Password</TD>
-<TD><INPUT TYPE="text" NAME="_password" VALUE="$password" SIZE=$pmax2 MAXLENGTH=$pmax>
-(blank to generate)</TD>
+
+%>
+
+<%= header("$action $svc account") %>
+
+<% if ( $cgi->param('error') ) { %>
+ <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT>
+ <BR><BR>
+<% } %>
+
+<% if ( $cust_main ) { %>
+ <%= include( '/elements/small_custview.html', $cust_main, '', 1 ) %>
+ <BR>
+<% } %>
+
+<FORM NAME="OneTrueForm" ACTION="<%= $p1 %>process/svc_acct.cgi" METHOD=POST>
+<INPUT TYPE="hidden" NAME="svcnum" VALUE="<%= $svcnum %>">
+<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<%= $pkgnum %>">
+<INPUT TYPE="hidden" NAME="svcpart" VALUE="<%= $svcpart %>">
+
+Service # <%= $svcnum ? "<B>$svcnum</B>" : " (NEW)" %><BR>
+
+<%= ntable("#cccccc",2) %>
+
+<TR>
+ <TD ALIGN="right">Service</TD>
+ <TD BGCOLOR="#eeeeee"><%= $part_svc->svc %></TD>
+</TR>
+
+<TR>
+ <TD ALIGN="right">Username</TD>
+ <TD>
+ <INPUT TYPE="text" NAME="username" VALUE="<%= $username %>" SIZE=<%= $ulen2 %> MAXLENGTH=<%= $ulen %>>
+ </TD>
+</TR>
+
+<TR>
+ <TD ALIGN="right">Password</TD>
+ <TD>
+ <INPUT TYPE="text" NAME="_password" VALUE="<%= $password %>" SIZE=<%= $pmax2 %> MAXLENGTH=<%= $pmax %>>
+ (blank to generate)
+ </TD>
</TR>
-END
+
+<%
my $sec_phrase = $svc_acct->sec_phrase;
if ( $conf->exists('security_phrase') ) {
- print <<END;
- <TR><TD ALIGN="right">Security phrase</TD>
- <TD><INPUT TYPE="text" NAME="sec_phrase" VALUE="$sec_phrase" SIZE=32>
- (for forgotten passwords)</TD>
+%>
+
+ <TR>
+ <TD ALIGN="right">Security phrase</TD>
+ <TD>
+ <INPUT TYPE="text" NAME="sec_phrase" VALUE="<%= $sec_phrase %>" SIZE=32>
+ (for forgotten passwords)
+ </TD>
</TD>
-END
-} else {
- print qq!<INPUT TYPE="hidden" NAME="sec_phrase" VALUE="$sec_phrase">!;
-}
+<% } else { %>
+
+ <INPUT TYPE="hidden" NAME="sec_phrase" VALUE="<%= $sec_phrase %>">
+
+<% } %>
+
+
+<%
#domain
my $domsvc = $svc_acct->domsvc || 0;
if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'F' ) {
- print qq!<INPUT TYPE="hidden" NAME="domsvc" VALUE="$domsvc">!;
-} else {
+%>
+
+ <INPUT TYPE="hidden" NAME="domsvc" VALUE="<%= $domsvc %>">
+
+<% } else {
+
my %svc_domain = ();
if ( $domsvc ) {
@@ -170,7 +214,6 @@ if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'F' ) {
}
}
- my $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum } );
if ($cust_pkg && !$conf->exists('svc_acct-alldomains') ) {
my @cust_svc =
map { qsearch('cust_svc', { 'pkgnum' => $_->pkgnum } ) }
@@ -183,121 +226,223 @@ if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'F' ) {
} else {
%svc_domain = map { $_->svcnum => $_ } qsearch('svc_domain', {} );
}
- print qq!<TR><TD ALIGN="right">Domain</TD>!.
- qq!<TD><SELECT NAME="domsvc" SIZE=1>\n!;
- foreach my $svcnum (
- sort { $svc_domain{$a}->domain cmp $svc_domain{$b}->domain }
- keys %svc_domain
- ) {
- my $svc_domain = $svc_domain{$svcnum};
- print qq!<OPTION VALUE="!. $svc_domain->svcnum. qq!"!.
- ( $svc_domain->svcnum == $domsvc ? ' SELECTED' : '' ).
- '>'. $svc_domain->domain. "\n" ;
- }
- print "</SELECT></TD></TR>";
-}
+%>
+
+ <TR>
+ <TD ALIGN="right">Domain</TD>
+ <TD>
+ <SELECT NAME="domsvc" SIZE=1>
+
+ <% foreach my $svcnum (
+ sort { $svc_domain{$a}->domain cmp $svc_domain{$b}->domain }
+ keys %svc_domain
+ ) {
+ my $svc_domain = $svc_domain{$svcnum};
+ %>
+
+ <OPTION VALUE="<%= $svc_domain->svcnum %>" <%= $svc_domain->svcnum == $domsvc ? ' SELECTED' : '' %>><%= $svc_domain->domain %>
+
+ <% } %>
+ </SELECT>
+ </TD>
+ </TR>
+
+<% } %>
+
+
+<%
#pop
my $popnum = $svc_acct->popnum || 0;
-if ( $part_svc->part_svc_column('popnum')->columnflag eq "F" ) {
- print qq!<INPUT TYPE="hidden" NAME="popnum" VALUE="$popnum">!;
-} else {
- print qq!<TR><TD ALIGN="right">Access number</TD>!.
- qq!<TD>!. FS::svc_acct_pop::popselector($popnum). '</TD></TR>';
-}
+if ( $part_svc->part_svc_column('popnum')->columnflag eq 'F' ) {
+%>
-my($uid,$gid,$finger,$dir)=(
- $svc_acct->uid,
- $svc_acct->gid,
- $svc_acct->finger,
- $svc_acct->dir,
-);
+ <INPUT TYPE="hidden" NAME="popnum" VALUE="<%= $popnum %>">
-print <<END;
-<INPUT TYPE="hidden" NAME="uid" VALUE="$uid">
-<INPUT TYPE="hidden" NAME="gid" VALUE="$gid">
-END
-if ( !$finger && $part_svc->part_svc_column('uid')->columnflag eq 'F' ) {
- print '<INPUT TYPE="hidden" NAME="finger" VALUE="">';
-} else {
- print '<TR><TD ALIGN="right">GECOS</TD>'.
- qq!<TD><INPUT TYPE="text" NAME="finger" VALUE="$finger"></TD></TR>!;
-}
-print qq!<INPUT TYPE="hidden" NAME="dir" VALUE="$dir">!;
+<% } else { %>
+
+ <TR>
+ <TD ALIGN="right">Access number</TD>
+ <TD><%= FS::svc_acct_pop::popselector($popnum) %></TD>
+ </TR>
+
+<% } %>
+
+<% #uid/gid %>
+<% foreach my $xid (qw( uid gid )) { %>
+
+ <%
+ if ( $part_svc->part_svc_column($xid)->columnflag eq 'F'
+ || ! $conf->exists("svc_acct-edit_$xid")
+ ) {
+ %>
+
+ <% if ( length($svc_acct->$xid()) ) { %>
+
+ <TR>
+ <TD ALIGN="right"><%= uc($xid) %></TD>
+ <TD BGCOLOR="#eeeeee"><%= $svc_acct->$xid() %></TD>
+ <TD>
+ </TD>
+ </TR>
+
+ <% } else { %>
+
+ <INPUT TYPE="hidden" NAME="<%= $xid %>" VALUE="<%= $svc_acct->$xid() %>">
+
+ <% } %>
+
+ <% } else { %>
+
+ <TR>
+ <TD ALIGN="right"><%= uc($xid) %></TD>
+ <TD>
+ <INPUT TYPE="text" NAME="<%= $xid %>" SIZE=8 MAXLENGTH=6 VALUE="<%= $svc_acct->$xid() %>">
+ </TD>
+ </TR>
+
+ <% } %>
+
+<% } %>
+
+
+<%
+#finger
+if ( $part_svc->part_svc_column('uid')->columnflag eq 'F'
+ && ! $svc_acct->finger ) {
+%>
+
+ <INPUT TYPE="hidden" NAME="finger" VALUE="">
+
+<% } else { %>
+
+ <TR>
+ <TD ALIGN="right">GECOS</TD>
+ <TD>
+ <INPUT TYPE="text" NAME="finger" VALUE="<%= $svc_acct->finger %>">
+ </TD>
+ </TR>
+
+<% } %>
+
+
+<INPUT TYPE="hidden" NAME="dir" VALUE="<%= $svc_acct->dir %>">
+
+
+<%
+#shell
my $shell = $svc_acct->shell;
-if ( $part_svc->part_svc_column('shell')->columnflag eq "F"
+if ( $part_svc->part_svc_column('shell')->columnflag eq 'F'
|| ( !$shell && $part_svc->part_svc_column('uid')->columnflag eq 'F' )
) {
- print qq!<INPUT TYPE="hidden" NAME="shell" VALUE="$shell">!;
-} else {
- print qq!<TR><TD ALIGN="right">Shell</TD><TD><SELECT NAME="shell" SIZE=1>!;
- my($etc_shell);
- foreach $etc_shell (@shells) {
- print "<OPTION", $etc_shell eq $shell ? ' SELECTED' : '', ">",
- $etc_shell, "\n";
- }
- print "</SELECT></TD></TR>";
-}
+%>
-my($quota,$slipip)=(
- $svc_acct->quota,
- $svc_acct->slipip,
-);
+ <INPUT TYPE="hidden" NAME="shell" VALUE="<%= $shell %>">
-if ( $part_svc->part_svc_column('quota')->columnflag eq "F" )
-{
- print qq!<INPUT TYPE="hidden" NAME="quota" VALUE="$quota">!;
-} else {
- print <<END;
- <TR><TD ALIGN="right">Quota:</TD>
- <TD> <INPUT TYPE="text" NAME="quota" VALUE="$quota" ></TD>
- </TR>
-END
-}
+<% } else { %>
+
+ <TR>
+ <TD ALIGN="right">Shell</TD>
+ <TD>
+ <SELECT NAME="shell" SIZE=1>
+
+ <%
+ my($etc_shell);
+ foreach $etc_shell (@shells) {
+ %>
+
+ <OPTION<%= $etc_shell eq $shell ? ' SELECTED' : '' %>><%= $etc_shell %>
+
+ <% } %>
+
+ </SELECT>
+ </TD>
+ </TR>
+
+<% } %>
+
+
+<% if ( $part_svc->part_svc_column('quota')->columnflag eq 'F' ) { %>
+
+ <INPUT TYPE="hidden" NAME="quota" VALUE="<%= $svc_acct->quota %>">
+
+<% } else { %>
+
+ <TR>
+ <TD ALIGN="right">Quota:</TD>
+ <TD><INPUT TYPE="text" NAME="quota" VALUE="<%= $svc_acct->quota %>"></TD>
+ </TR>
+
+<% } %>
-if ( $part_svc->part_svc_column('slipip')->columnflag eq "F" ) {
- print qq!<INPUT TYPE="hidden" NAME="slipip" VALUE="$slipip">!;
-} else {
- print qq!<TR><TD ALIGN="right">IP</TD><TD><INPUT TYPE="text" NAME="slipip" VALUE="$slipip"></TD></TR>!;
-}
+<% if ( $part_svc->part_svc_column('slipip')->columnflag eq 'F' ) { %>
+
+ <INPUT TYPE="hidden" NAME="slipip" VALUE="<%= $svc_acct->slipip %>">
+
+<% } else { %>
+
+ <TR>
+ <TD ALIGN="right">IP</TD>
+ <TD><INPUT TYPE="text" NAME="slipip" VALUE="<%= $svc_acct->slipip %>"></TD>
+ </TR>
+
+<% } %>
+
+
+<%
foreach my $r ( grep { /^r(adius|[cr])_/ } fields('svc_acct') ) {
$r =~ /^^r(adius|[cr])_(.+)$/ or next; #?
my $a = $2;
- if ( $part_svc->part_svc_column($r)->columnflag eq 'F' ) {
- print qq!<INPUT TYPE="hidden" NAME="$r" VALUE="!.
- $svc_acct->getfield($r). '">';
- } else {
- print qq!<TR><TD ALIGN="right">$FS::raddb::attrib{$a}</TD><TD><INPUT TYPE="text" NAME="$r" VALUE="!.
- $svc_acct->getfield($r). '"></TD></TR>';
- }
-}
+%>
-print '<TR><TD ALIGN="right">RADIUS groups</TD>';
-if ( $part_svc->part_svc_column('usergroup')->columnflag eq "F" ) {
- print '<TD BGCOLOR="#ffffff">'. join('<BR>', @groups);
-} else {
- print '<TD>'. &FS::svc_acct::radius_usergroup_selector( \@groups );
-}
-print '</TD></TR>';
+ <% if ( $part_svc->part_svc_column($r)->columnflag eq 'F' ) { %>
-foreach my $field ($svc_acct->virtual_fields) {
- if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) {
- # If the flag is X, it won't even show up in $svc_acct->virtual_fields.
- print $svc_acct->pvf($field)->widget('HTML', 'edit',
- $svc_acct->getfield($field));
- }
-}
+ <INPUT TYPE="hidden" NAME="<%= $r %>" VALUE="<%= $svc_acct->getfield($r) %>">
+
+ <% } else { %>
+
+ <TR>
+ <TD ALIGN="right"><%= $FS::raddb::attrib{$a} %></TD>
+ <TD><INPUT TYPE="text" NAME="<%= $r %>" VALUE="<%= $svc_acct->getfield($r) %>"></TD>
+ </TR>
+
+ <% } %>
+
+<% } %>
+
+
+<TR>
+ <TD ALIGN="right">RADIUS groups</TD>
+
+ <% if ( $part_svc->part_svc_column('usergroup')->columnflag eq 'F' ) { %>
+
+ <TD BGCOLOR="#eeeeee"><%= join('<BR>', @groups) %></TD>
+
+ <% } else { %>
+
+ <TD><%= FS::svc_acct::radius_usergroup_selector( \@groups ) %></TD>
+
+ <% } %>
+
+</TR>
+
+<% foreach my $field ($svc_acct->virtual_fields) { %>
+
+ <% # If the flag is X, it won't even show up in $svc_acct->virtual_fields. %>
+ <% if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) { %>
+
+ <%= $svc_acct->pvf($field)->widget('HTML', 'edit', $svc_acct->getfield($field)) %>
+
+ <% } %>
+
+<% } %>
-#submit
-print qq!</TABLE><BR><INPUT TYPE="submit" VALUE="Submit">!;
+</TABLE>
+<BR>
-print <<END;
- </FORM>
- </BODY>
-</HTML>
-END
+<INPUT TYPE="submit" VALUE="Submit">
-%>
+</FORM></BODY></HTML>
diff --git a/httemplate/elements/small_custview.html b/httemplate/elements/small_custview.html
index 1e8ae739a..e0c22e0c4 100644
--- a/httemplate/elements/small_custview.html
+++ b/httemplate/elements/small_custview.html
@@ -1,2 +1,2 @@
<% my $conf = new FS::Conf; %>
-<%= small_custview( shift, shift || $conf->config('countrydefault') ) %>
+<%= small_custview( shift, shift || scalar($conf->config('countrydefault')), @_ ) %>
diff --git a/httemplate/view/svc_acct.cgi b/httemplate/view/svc_acct.cgi
index 1486d7b11..7257fc3e4 100755
--- a/httemplate/view/svc_acct.cgi
+++ b/httemplate/view/svc_acct.cgi
@@ -1,4 +1,3 @@
-<!-- mason kludge -->
<%
my $conf = new FS::Conf;
@@ -24,41 +23,46 @@ if ($pkgnum) {
my $part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } );
die "Unknown svcpart" unless $part_svc;
+my $svc = $part_svc->svc;
-my $domain;
-if ( $svc_acct->domsvc ) {
- my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $svc_acct->domsvc } );
- die "Unknown domain" unless $svc_domain;
- $domain = $svc_domain->domain;
-} else {
- die "No svc_domain.svcnum record for svc_acct.domsvc: ". $cust_svc->domsvc;
-}
+die 'Empty domsvc for svc_acct.svcnum '. $svc_acct->svcnum
+ unless $svc_acct->domsvc;
+my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $svc_acct->domsvc } );
+die 'Unknown domain (domsvc '. $svc_acct->domsvc.
+ ' for svc_acct.svcnum '. $svc_acct->svcnum. ')'
+ unless $svc_domain;
+my $domain = $svc_domain->domain;
%>
-<SCRIPT>
-function areyousure(href) {
- if (confirm("Permanently delete this account?") == true)
- window.location.href = href;
-}
-</SCRIPT>
+<% if ( $custnum ) { %>
-<%= header('Account View', menubar(
- ( ( $pkgnum || $custnum )
- ? ( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum",
- )
- : ( "Cancel this (unaudited) account" =>
- "javascript:areyousure(\'${p}misc/cancel-unaudited.cgi?$svcnum\')" )
- ),
- "Main menu" => $p,
-)) %>
+ <%= header("View $svc account", menubar(
+ "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum",
+ "Main menu" => $p,
+ )) %>
-<%
+ <%= include( '/elements/small_custview.html', $custnum, '', 1 ) %>
+ <BR>
+
+<% } else { %>
-#if ( $cust_pkg && $cust_pkg->part_pkg->plan eq 'sqlradacct_hour' ) {
-if ( $part_svc->part_export('sqlradius')
- || $part_svc->part_export('sqlradius_withdomain')
-) {
+ <SCRIPT>
+ function areyousure(href) {
+ if (confirm("Permanently delete this account?") == true)
+ window.location.href = href;
+ }
+ </SCRIPT>
+
+ <%= header('Account View', menubar(
+ "Cancel this (unaudited) account" =>
+ "javascript:areyousure(\'${p}misc/cancel-unaudited.cgi?$svcnum\')",
+ "Main menu" => $p,
+ )) %>
+
+<% } %>
+
+<% if ( $part_svc->part_export_usage ) {
my $last_bill;
my %plandata;
@@ -151,60 +155,73 @@ function enable_change () {
}
%>
-Service Information
-| <A HREF="<%=$p%>edit/svc_acct.cgi?<%=$svcnum%>">Edit this information</A>
+Service #<B><%= $svcnum %></B>
+| <A HREF="<%=$p%>edit/svc_acct.cgi?<%=$svcnum%>">Edit this service</A>
<% if ( @part_svc ) { %>
| <SELECT NAME="svcpart" onChange="enable_change()">
<OPTION VALUE="">Change service</OPTION>
<OPTION VALUE="">--------------</OPTION>
- <% foreach my $part_svc ( @part_svc ) { %>
- <OPTION VALUE="<%= $part_svc->svcpart %>"><%= $part_svc->svc %></OPTION>
+ <% foreach my $opt_part_svc ( @part_svc ) { %>
+ <OPTION VALUE="<%= $part_svc->svcpart %>"><%= $opt_part_svc->svc %></OPTION>
<% } %>
</SELECT>
<INPUT NAME="submit" TYPE="submit" VALUE="Change" disabled>
<% } %>
<%= &ntable("#cccccc") %><TR><TD><%= &ntable("#cccccc",2) %>
-<TR><TD ALIGN="right">Service number</TD>
- <TD BGCOLOR="#ffffff"><%= $svcnum %></TD></TR>
-<TR><TD ALIGN="right">Service</TD>
- <TD BGCOLOR="#ffffff"><%= $part_svc->svc %></TD></TR>
-<TR><TD ALIGN="right">Username</TD>
- <TD BGCOLOR="#ffffff"><%= $svc_acct->username %></TD></TR>
-<TR><TD ALIGN="right">Domain</TD>
- <TD BGCOLOR="#ffffff"><%= $domain %></TD></TR>
-
-<TR><TD ALIGN="right">Password</TD>
- <TD BGCOLOR="#ffffff"><%
-
-my $password = $svc_acct->_password;
-if ( $password =~ /^\*\w+\* (.*)$/ ) {
- $password = $1;
- print "<I>(login disabled)</I> ";
-}
-if ( $conf->exists('showpasswords') ) {
- print '<PRE>'. encode_entities($password). '</PRE>';
-} else {
- print "<I>(hidden)</I>";
-}
-print "</TR></TD>";
-$password = '';
-if ( $conf->exists('security_phrase') ) {
- my $sec_phrase = $svc_acct->sec_phrase;
- print '<TR><TD ALIGN="right">Security phrase</TD><TD BGCOLOR="#ffffff">'.
- $svc_acct->sec_phrase. '</TD></TR>';
-}
+<TR>
+ <TD ALIGN="right">Service</TD>
+ <TD BGCOLOR="#ffffff"><%= $part_svc->svc %></TD>
+</TR>
+<TR>
+ <TD ALIGN="right">Username</TD>
+ <TD BGCOLOR="#ffffff"><%= $svc_acct->username %></TD>
+</TR>
+<TR>
+ <TD ALIGN="right">Domain</TD>
+ <TD BGCOLOR="#ffffff"><%= $domain %></TD>
+</TR>
+
+<TR>
+ <TD ALIGN="right">Password</TD>
+ <TD BGCOLOR="#ffffff">
+
+ <% my $password = $svc_acct->_password; %>
+ <% if ( $password =~ /^\*\w+\* (.*)$/ ) {
+ $password = $1;
+ %>
+ <I>(login disabled)</I>
+ <% } %>
+
+ <% if ( $conf->exists('showpasswords') ) { %>
+ <PRE><%= encode_entities($password) %></PRE>
+ <% } else { %>
+ <I>(hidden)</I>
+ <% } %>
+
+ </TD>
+</TR>
+<% $password = ''; %>
-my $svc_acct_pop = $svc_acct->popnum
- ? qsearchs('svc_acct_pop',{'popnum'=>$svc_acct->popnum})
- : '';
-print "<TR><TD ALIGN=\"right\">Access number</TD>".
- "<TD BGCOLOR=\"#ffffff\">". $svc_acct_pop->text. '</TD></TR>'
- if $svc_acct_pop;
+<% if ( $conf->exists('security_phrase') ) {
+ my $sec_phrase = $svc_acct->sec_phrase;
+%>
+ <TR>
+ <TD ALIGN="right">Security phrase</TD>
+ <TD BGCOLOR="#ffffff"><%= $svc_acct->sec_phrase %></TD>
+ </TR>
+<% } %>
+<% if ( $svc_acct->popnum ) {
+ my $svc_acct_pop = qsearchs('svc_acct_pop',{'popnum'=>$svc_acct->popnum});
%>
+ <TR>
+ <TD ALIGN="right">Access number</TD>
+ <TD BGCOLOR="#ffffff"><%= $svc_acct_pop->text %></TD>
+ </TR>
+<% } %>
<% if ($svc_acct->uid ne '') { %>
<TR>
@@ -260,49 +277,56 @@ print "<TR><TD ALIGN=\"right\">Access number</TD>".
</TR>
<% } %>
-<%
-
-my($attribute);
-foreach $attribute ( grep /^radius_/, $svc_acct->fields ) {
- #warn $attribute;
+<% foreach my $attribute ( grep /^radius_/, $svc_acct->fields ) {
$attribute =~ /^radius_(.*)$/;
my $pattribute = $FS::raddb::attrib{$1};
- print "<TR><TD ALIGN=\"right\">Radius (reply) $pattribute</TD>".
- "<TD BGCOLOR=\"#ffffff\">". $svc_acct->getfield($attribute).
- "</TD></TR>";
-}
-foreach $attribute ( grep /^rc_/, $svc_acct->fields ) {
- #warn $attribute;
+%>
+ <TR>
+ <TD ALIGN="right">Radius (reply) <%= $pattribute %></TD>
+ <TD BGCOLOR="#ffffff"><%= $svc_acct->getfield($attribute) %></TD>
+ </TR>
+<% } %>
+
+<% foreach my $attribute ( grep /^rc_/, $svc_acct->fields ) {
$attribute =~ /^rc_(.*)$/;
my $pattribute = $FS::raddb::attrib{$1};
- print "<TR><TD ALIGN=\"right\">Radius (check) $pattribute: </TD>".
- "<TD BGCOLOR=\"#ffffff\">". $svc_acct->getfield($attribute).
- "</TD></TR>";
-}
+%>
+ <TR>
+ <TD ALIGN="right">Radius (check) <%= $pattribute %></TD>
+ <TD BGCOLOR="#ffffff"><%= $svc_acct->getfield($attribute) %></TD>
+ </TR>
+<% } %>
-print '<TR><TD ALIGN="right">RADIUS groups</TD><TD BGCOLOR="#ffffff">'.
- join('<BR>', $svc_acct->radius_groups). '</TD></TR>';
+<TR>
+ <TD ALIGN="right">RADIUS groups</TD>
+ <TD BGCOLOR="#ffffff"><%= join('<BR>', $svc_acct->radius_groups) %></TD>
+</TR>
-if ( $svc_acct->seconds =~ /^\d+$/ ) {
- print '<TR><TD ALIGN="right">Prepaid time</TD><TD BGCOLOR="#ffffff">'.
- duration_exact($svc_acct->seconds). '</TD></TR>';
-}
+<% if ( $svc_acct->seconds =~ /^\d+$/ ) { %>
+ <TR>
+ <TD ALIGN="right">Prepaid time</TD>
+ <TD BGCOLOR="#ffffff"><%= duration_exact($svc_acct->seconds) %></TD>
+ </TR>
+<% } %>
+<%
# Can this be abstracted further? Maybe a library function like
# widget('HTML', 'view', $svc_acct) ? It would definitely make UI
# style management easier.
-
-foreach (sort { $a cmp $b } $svc_acct->virtual_fields) {
- print $svc_acct->pvf($_)->widget('HTML', 'view', $svc_acct->getfield($_)),
- "\n";
-}
%>
-</TABLE></TD></TR></TABLE></FORM>
-<%
-print '<BR><BR>';
+<% foreach (sort { $a cmp $b } $svc_acct->virtual_fields) { %>
+ <%= $svc_acct->pvf($_)->widget('HTML', 'view', $svc_acct->getfield($_)) %>
+<% } %>
+
+</TABLE></TD></TR></TABLE>
+</FORM>
+<BR><BR>
-print join("\n", $conf->config('svc_acct-notes') ). '<BR><BR>'.
- joblisting({'svcnum'=>$svcnum}, 1). '</BODY></HTML>';
+<%= join("<BR>", $conf->config('svc_acct-notes') ) %>
+<BR><BR>
-%>
+<%= joblisting({'svcnum'=>$svcnum}, 1) %>
+
+</BODY>
+</HTML>