summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2001-09-27 20:41:37 +0000
committerivan <ivan>2001-09-27 20:41:37 +0000
commit3eb749fd79fec377d4975f69b077b14e5aaf94dd (patch)
tree932fffba626492db739d98c380eafab53a7c9be3
parentcbf08fd900f3e1ddc82b2f4c4a5f753e951ff0a3 (diff)
pop selector!
-rw-r--r--FS/FS/svc_acct_pop.pm92
-rwxr-xr-xhttemplate/edit/cust_main.cgi27
-rwxr-xr-xhttemplate/edit/svc_acct.cgi59
-rwxr-xr-xhttemplate/view/svc_acct.cgi68
4 files changed, 171 insertions, 75 deletions
diff --git a/FS/FS/svc_acct_pop.pm b/FS/FS/svc_acct_pop.pm
index 8ce551c..3b8e978 100644
--- a/FS/FS/svc_acct_pop.pm
+++ b/FS/FS/svc_acct_pop.pm
@@ -1,10 +1,11 @@
package FS::svc_acct_pop;
use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearchs );
+use vars qw( @ISA @EXPORT_OK @svc_acct_pop %svc_acct_pop );
+use FS::Record qw( qsearch qsearchs );
-@ISA = qw( FS::Record );
+@ISA = qw( FS::Record Exporter );
+@EXPORT_OK = qw( popselector );
=head1 NAME
@@ -25,6 +26,8 @@ FS::svc_acct_pop - Object methods for svc_acct_pop records
$error = $record->check;
+ $html = FS::svc_acct_pop::popselector( $popnum, $state );
+
=head1 DESCRIPTION
An FS::svc_acct object represents an point of presence. FS::svc_acct_pop
@@ -94,16 +97,97 @@ sub check {
}
+=item text
+
+Returns:
+
+"$city, $state ($ac)/$exch"
+
+=cut
+
+sub text {
+ my $self = shift;
+ $self->city. ', '. $self->state. ' ('. $self->ac. ')/'. $self->exch;
+}
+
+=back
+
+=head1 SUBROUTINES
+
+=over 4
+
+=item popselector [ POPNUM [ STATE ] ]
+
+=cut
+
+sub popselector {
+ my( $popnum, $state ) = @_;
+
+ unless ( @svc_acct_pop ) { #cache pop list
+ @svc_acct_pop = qsearch('svc_acct_pop', {} );
+ %svc_acct_pop = ();
+ push @{$svc_acct_pop{$_->state}}, $_ foreach @svc_acct_pop;
+ }
+
+ my $size = 0;
+ my $text = <<END;
+ <SCRIPT>
+ function opt(what,href,text) {
+ var optionName = new Option(text, href, false, false)
+ var length = what.length;
+ what.options[length] = optionName;
+ }
+
+ function popstate_changed(what) {
+ state = what.options[what.selectedIndex].text;
+ for (var i = what.form.popnum.length;i > 0;i--)
+ what.form.popnum.options[i] = null;
+ what.form.popnum.options[0] = new Option("", "", false, true);
+END
+
+ foreach my $popstate ( sort { $a cmp $b } keys %svc_acct_pop ) {
+ $text .= "\nif ( state == \"$popstate\" ) {\n";
+
+ foreach my $pop ( @{$svc_acct_pop{$popstate}}) {
+ my $o_popnum = $pop->popnum;
+ my $poptext = $pop->text;
+ $size = length($poptext) if length($poptext) > $size;
+ $text .= "opt(what.form.popnum, \"$o_popnum\", \"$poptext\");\n"
+ }
+ $text .= "}\n";
+ }
+
+ $text .= "}\n</SCRIPT>\n";
+
+ $text .=
+ qq!<SELECT NAME="popstate" SIZE=1 onChange="popstate_changed(this)">!.
+ qq!<OPTION> !;
+ $text .= "<OPTION>$_" foreach sort { $a cmp $b } keys %svc_acct_pop;
+ $text .= '</SELECT>'; #callback? return 3 html pieces? #'</TD><TD>';
+
+ $text .= qq!<SELECT NAME="popnum" SIZE=1><OPTION> !;
+ foreach my $pop ( @svc_acct_pop ) {
+ $text .= qq!<OPTION VALUE="!. $pop->popnum. '"'.
+ ( ( $popnum && $pop->popnum == $popnum ) ? ' SELECTED' : '' ). ">".
+ $pop->text;
+ }
+ $text .= '</SELECT>';
+
+}
+
=back
=head1 VERSION
-$Id: svc_acct_pop.pm,v 1.3 2001-09-26 09:17:06 ivan Exp $
+$Id: svc_acct_pop.pm,v 1.4 2001-09-27 20:41:37 ivan Exp $
=head1 BUGS
It should be renamed to part_pop.
+popselector? putting web ui components in here? they should probably live
+somewhere else...
+
=head1 SEE ALSO
L<FS::Record>, L<FS::svc_acct>, L<FS::part_pop_local>, schema.html from the
diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi
index 47e18d7..d5b0d0f 100755
--- a/httemplate/edit/cust_main.cgi
+++ b/httemplate/edit/cust_main.cgi
@@ -1,5 +1,5 @@
<%
-#<!-- $Id: cust_main.cgi,v 1.4 2001-08-28 14:34:14 ivan Exp $ -->
+#<!-- $Id: cust_main.cgi,v 1.5 2001-09-27 20:41:36 ivan Exp $ -->
use vars qw( $cgi $custnum $action $cust_main $p1 @agents $agentnum
$last $first $ss $company $address1 $address2 $city $zip
@@ -22,7 +22,7 @@ use FS::cust_main_county;
#for misplaced logic below
use FS::part_pkg;
- #for false laziness below
+ #for false laziness below (now more properly lazy)
use FS::svc_acct_pop;
#for (other) false laziness below
@@ -80,7 +80,7 @@ print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $error, "</FONT>"
print qq!<FORM ACTION="${p1}process/cust_main.cgi" METHOD=POST NAME="form1">!,
qq!<INPUT TYPE="hidden" NAME="custnum" VALUE="$custnum">!,
- qq!Customer # !, ( $custnum ? $custnum : " (NEW)" ),
+ qq!Customer # !, ( $custnum ? "<B>$custnum</B>" : " (NEW)" ),
;
@@ -408,7 +408,7 @@ unless ( $custnum ) {
if ( @part_pkg ) {
- print "<BR><BR>First package", &itable("#cccccc"),
+ print "<BR><BR>First package", &itable("#cccccc", "0 ALIGN=LEFT"), #apiabuse
qq!<TR><TD COLSPAN=2><SELECT NAME="pkgpart_svcpart">!;
print qq!<OPTION VALUE="">(none)!;
@@ -433,19 +433,12 @@ unless ( $custnum ) {
<TD><INPUT TYPE="text" NAME="_password" VALUE="$password" SIZE=10 MAXLENGTH=8>
(blank to generate)</TD></TR>
END
- print qq!<TR><TD ALIGN="right">POP</TD><TD><SELECT NAME="popnum" SIZE=1><OPTION> !;
- my($svc_acct_pop);
- foreach $svc_acct_pop ( qsearch ('svc_acct_pop',{} ) ) {
- print qq!<OPTION VALUE="!, $svc_acct_pop->popnum, '"',
- ( $popnum && $svc_acct_pop->popnum == $popnum ) ? ' SELECTED' : '', ">",
- $svc_acct_pop->popnum, ": ",
- $svc_acct_pop->city, ", ",
- $svc_acct_pop->state,
- " (", $svc_acct_pop->ac, ")/",
- $svc_acct_pop->exch, "\n"
- ;
- }
- print "</SELECT></TD></TR></TABLE>";
+
+ print '<TR><TD ALIGN="right">POP</TD><TD WIDTH="100%">'
+ .
+ &FS::svc_acct_pop::popselector($popnum).
+ '</TD></TR></TABLE>'
+ ;
}
}
diff --git a/httemplate/edit/svc_acct.cgi b/httemplate/edit/svc_acct.cgi
index f594bd2..16b2957 100755
--- a/httemplate/edit/svc_acct.cgi
+++ b/httemplate/edit/svc_acct.cgi
@@ -1,5 +1,5 @@
<%
-#<!-- $Id: svc_acct.cgi,v 1.7 2001-09-11 23:44:01 ivan Exp $ -->
+#<!-- $Id: svc_acct.cgi,v 1.8 2001-09-27 20:41:36 ivan Exp $ -->
use strict;
use vars qw( $conf $cgi @shells $action $svcnum $svc_acct $pkgnum $svcpart
@@ -9,9 +9,10 @@ use vars qw( $conf $cgi @shells $action $svcnum $svc_acct $pkgnum $svcpart
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use FS::UID qw(cgisuidsetup getotaker);
-use FS::CGI qw(header popurl);
+use FS::CGI qw(header popurl itable);
use FS::Record qw(qsearch qsearchs fields);
use FS::svc_acct;
+use FS::svc_acct_pop qw(popselector);
use FS::Conf;
use FS::raddb;
@@ -103,19 +104,26 @@ $p1 = popurl(1);
print $cgi->header( '-expires' => 'now' ), header("$action $svc account");
print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
- "</FONT>"
+ "</FONT><BR><BR>"
if $cgi->param('error');
-print <<END;
+print 'Service # '. ( $svcnum ? "<B>$svcnum</B>" : " (NEW)" ). '<BR>'.
+ 'Service: <B>'. $part_svc->svc. '</B><BR><BR>'.
+ <<END;
<FORM 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">
-Username:
-<INPUT TYPE="text" NAME="username" VALUE="$username" SIZE=$ulen2 MAXLENGTH=$ulen>
-<BR>Password:
-<INPUT TYPE="text" NAME="_password" VALUE="$password" SIZE=10 MAXLENGTH=8>
-(blank to generate)
+END
+
+print &itable("#cccccc"), <<END;
+<TR><TD>
+<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=10 MAXLENGTH=8>
+(blank to generate)</TD>
+</TR>
END
#domain
@@ -148,14 +156,15 @@ if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'F' ) {
} else {
@svc_domain = qsearch('svc_domain', {} );
}
- print qq!<BR>Domain: <SELECT NAME="domsvc" SIZE=1>\n!;
+ print qq!<TR><TD ALIGN="right">Domain</TD>!.
+ qq!<TD><SELECT NAME="domsvc" SIZE=1>\n!;
foreach my $svc_domain ( sort { $a->domain cmp $b->domain } @svc_domain ) {
print qq!<OPTION VALUE="!, $svc_domain->svcnum, qq!"!,
$svc_domain->svcnum == $domsvc ? ' SELECTED' : '',
">", $svc_domain->domain, "\n"
;
}
- print "</SELECT>";
+ print "</SELECT></TD><TR>";
}
#pop
@@ -163,18 +172,8 @@ $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!<BR>POP: <SELECT NAME="popnum" SIZE=1><OPTION>\n!;
- my($svc_acct_pop);
- foreach $svc_acct_pop ( qsearch ('svc_acct_pop',{} ) ) {
- print "<OPTION", $svc_acct_pop->popnum == $popnum ? ' SELECTED' : '', ">",
- $svc_acct_pop->popnum, ": ",
- $svc_acct_pop->city, ", ",
- $svc_acct_pop->state,
- " (", $svc_acct_pop->ac, ")/",
- $svc_acct_pop->exch, "\n"
- ;
- }
- print "</SELECT>";
+ print qq!<TR><TD ALIGN="right">Access number</TD>!.
+ qq!<TD>!. FS::svc_acct_pop::popselector($popnum). '</TD></TR>';
}
($uid,$gid,$finger,$dir)=(
@@ -187,7 +186,7 @@ if ( $part_svc->part_svc_column('popnum')->columnflag eq "F" ) {
print <<END;
<INPUT TYPE="hidden" NAME="uid" VALUE="$uid">
<INPUT TYPE="hidden" NAME="gid" VALUE="$gid">
-<BR>GECOS: <INPUT TYPE="text" NAME="finger" VALUE="$finger">
+<TR><TD ALIGN="right">GECOS</TD><TD><INPUT TYPE="text" NAME="finger" VALUE="$finger"></TD></TR>
<INPUT TYPE="hidden" NAME="dir" VALUE="$dir">
END
@@ -195,13 +194,13 @@ $shell = $svc_acct->shell;
if ( $part_svc->part_svc_column('shell')->columnflag eq "F" ) {
print qq!<INPUT TYPE="hidden" NAME="shell" VALUE="$shell">!;
} else {
- print qq!<BR>Shell: <SELECT NAME="shell" SIZE=1>!;
+ 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>";
+ print "</SELECT></TD></TR>";
}
($quota,$slipip)=(
@@ -214,7 +213,7 @@ print qq!<INPUT TYPE="hidden" NAME="quota" VALUE="$quota">!;
if ( $part_svc->part_svc_column('slipip')->columnflag eq "F" ) {
print qq!<INPUT TYPE="hidden" NAME="slipip" VALUE="$slipip">!;
} else {
- print qq!<BR>IP: <INPUT TYPE="text" NAME="slipip" VALUE="$slipip">!;
+ print qq!<TR><TD ALIGN="right">IP</TD><TD><INPUT TYPE="text" NAME="slipip" VALUE="$slipip"></TD></TR>!;
}
foreach my $r ( grep { /^r(adius|[cr])_/ } fields('svc_acct') ) {
@@ -224,13 +223,13 @@ foreach my $r ( grep { /^r(adius|[cr])_/ } fields('svc_acct') ) {
print qq!<INPUT TYPE="hidden" NAME="$r" VALUE="!.
$svc_acct->getfield($r). '">';
} else {
- print qq!<BR>$FS::raddb::attrib{$a}: <INPUT TYPE="text" NAME="$r" VALUE="!.
- $svc_acct->getfield($r). '">';
+ print qq!<TR><TD ALIGN="right">$FS::raddb::attrib{$a}</TD><TD><INPUT TYPE="text" NAME="$r" VALUE="!.
+ $svc_acct->getfield($r). '"></TD></TR>';
}
}
#submit
-print qq!<P><INPUT TYPE="submit" VALUE="Submit">!;
+print qq!</TABLE><BR><INPUT TYPE="submit" VALUE="Submit">!;
print <<END;
</FORM>
diff --git a/httemplate/view/svc_acct.cgi b/httemplate/view/svc_acct.cgi
index aacf8b1..01019c5 100755
--- a/httemplate/view/svc_acct.cgi
+++ b/httemplate/view/svc_acct.cgi
@@ -1,14 +1,14 @@
<%
-# <!-- $Id: svc_acct.cgi,v 1.5 2001-09-27 18:33:18 ivan Exp $ -->
+# <!-- $Id: svc_acct.cgi,v 1.6 2001-09-27 20:41:37 ivan Exp $ -->
use strict;
use vars qw( $conf $cgi $domain $query $svcnum $svc_acct $cust_svc $pkgnum
$cust_pkg $custnum $part_svc $p $svc_acct_pop $password
- $mydomain );
+ $mydomain $svc_domain );
use CGI;
use CGI::Carp qw( fatalsToBrowser );
use FS::UID qw( cgisuidsetup );
-use FS::CGI qw( header popurl menubar);
+use FS::CGI qw( header popurl menubar ntable);
use FS::Record qw( qsearchs fields );
use FS::Conf;
use FS::svc_acct;
@@ -68,63 +68,83 @@ print $cgi->header( '-expires' => 'now' ), header('Account View', menubar(
#print qq!<BR><A HREF="../misc/sendconfig.cgi?$svcnum">Send account information</A>!;
-print qq!<A HREF="${p}edit/svc_acct.cgi?$svcnum">Edit this information</A>!,
- "<BR>Service #$svcnum",
- "<BR>Service: <B>", $part_svc->svc, "</B>",
- "<BR><BR>Username: <B>", $svc_acct->username, "</B>"
+print qq!<A HREF="${p}edit/svc_acct.cgi?$svcnum">Edit this information</A><BR>!.
+ &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>"
;
-print "<BR>Domain: <B>", $domain, "</B>";
+print "<TR><TD ALIGN=\"right\">Domain</TD>".
+ "<TD BGCOLOR=\"#ffffff\">". $domain, "</TD></TR>";
-print "<BR>Password: ";
+print "<TR><TD ALIGN=\"right\">Password</TD><TD BGCOLOR=\"#ffffff\">";
$password = $svc_acct->_password;
if ( $password =~ /^\*\w+\* (.*)$/ ) {
$password = $1;
print "<I>(login disabled)</I> ";
}
if ( $conf->exists('showpasswords') ) {
- print "<B>$password</B>";
+ print "$password";
} else {
print "<I>(hidden)</I>";
}
+print "</TR></TD>";
$password = '';
$svc_acct_pop = qsearchs('svc_acct_pop',{'popnum'=>$svc_acct->popnum});
-print "<BR>POP: <B>", $svc_acct_pop->city, ", ", $svc_acct_pop->state,
- " (", $svc_acct_pop->ac, ")/", $svc_acct_pop->exch, "</B>"
+print "<TR><TD ALIGN=\"right\">Access number</TD>".
+ "<TD BGCOLOR=\"#ffffff\">". $svc_acct_pop->text. '</TD></TR>'
if $svc_acct_pop;
if ($svc_acct->uid ne '') {
- print "<BR><BR>Uid: <B>", $svc_acct->uid, "</B>",
- "<BR>Gid: <B>", $svc_acct->gid, "</B>",
- "<BR>Finger name: <B>", $svc_acct->finger, "</B>",
- "<BR>Home directory: <B>", $svc_acct->dir, "</B>",
- "<BR>Shell: <B>", $svc_acct->shell, "</B>",
- "<BR>Quota: <B>", $svc_acct->quota, "</B> <I>(unimplemented)</I>"
+ print "<TR><TD ALIGN=\"right\">Uid</TD>".
+ "<TD BGCOLOR=\"#ffffff\">". $svc_acct->uid. "</TD></TR>",
+ "<TR><TD ALIGN=\"right\">Gid</TD>".
+ "<TD BGCOLOR=\"#ffffff\">". $svc_acct->gid. "</TD></TR>",
+ "<TR><TD ALIGN=\"right\">GECOS</TD>".
+ "<TD BGCOLOR=\"#ffffff\">". $svc_acct->finger. "</TD></TR>",
+ "<TR><TD ALIGN=\"right\">Home directory</TD>".
+ "<TD BGCOLOR=\"#ffffff\">". $svc_acct->dir. "</TD></TR>",
+ "<TR><TD ALIGN=\"right\">Shell</TD>".
+ "<TD BGCOLOR=\"#ffffff\">". $svc_acct->shell. "</TD></TR>",
+ "<TR><TD ALIGN=\"right\">Quota</TD>".
+ "<TD BGCOLOR=\"#ffffff\">". $svc_acct->quota. "</TD></TR>"
;
} else {
- print "<BR><BR>(No shell account)";
+ print "<TR><TH COLSPAN=2>(No shell account)</TH></TR>";
}
if ($svc_acct->slipip) {
- print "<BR><BR>IP address: <B>", ( $svc_acct->slipip eq "0.0.0.0" || $svc_acct->slipip eq '0e0' ) ? "<I>(Dynamic)</I>" : $svc_acct->slipip ,"</B>";
+ print "<TR><TD ALIGN=\"right\">IP address</TD><TD BGCOLOR=\"#ffffff\">".
+ ( ( $svc_acct->slipip eq "0.0.0.0" || $svc_acct->slipip eq '0e0' )
+ ? "<I>(Dynamic)</I>"
+ : $svc_acct->slipip
+ ). "</TD>";
my($attribute);
foreach $attribute ( grep /^radius_/, fields('svc_acct') ) {
#warn $attribute;
$attribute =~ /^radius_(.*)$/;
my $pattribute = $FS::raddb::attrib{$1};
- print "<BR>Radius (reply) $pattribute: <B>". $svc_acct->getfield($attribute), "</B>";
+ print "<TR><TD ALIGN=\"right\">Radius (reply) $pattribute</TD>".
+ "<TD BGCOLOR=\"#ffffff\">". $svc_acct->getfield($attribute).
+ "</TD></TR>";
}
foreach $attribute ( grep /^rc_/, fields('svc_acct') ) {
#warn $attribute;
$attribute =~ /^rc_(.*)$/;
my $pattribute = $FS::raddb::attrib{$1};
- print "<BR>Radius (check) $pattribute: <B>". $svc_acct->getfield($attribute), "</B>";
+ print "<TR><TD ALIGN=\"right\">Radius (check) $pattribute: </TD>".
+ "<TD BGCOLOR=\"#ffffff\">". $svc_acct->getfield($attribute).
+ "</TD></TR>";
}
} else {
- print "<BR><BR>(No SLIP/PPP account)";
+ print "<TR><TH COLSPAN=2>(No SLIP/PPP account)</TH></TR>";
}
-print "</BODY></HTML>";
+print "</TABLE></TD></TR></TABLE></BODY></HTML>";
%>