bugfix to work for regular aswell as custom pricing
[freeside.git] / htdocs / edit / part_svc.cgi
index 491c013..6f0a322 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -Tw
 #
-# part_svc.cgi: Add/Edit service (output form)
+# $Id: part_svc.cgi,v 1.3 1998-11-21 06:43:26 ivan Exp $
 #
 # ivan@sisd.com 97-nov-14
 #
@@ -8,24 +8,27 @@
 #       bmccane@maxbaud.net     98-apr-3
 #
 # use FS::CGI, added inline documentation ivan@sisd.com 98-jul-12
+#
+# $Log: part_svc.cgi,v $
+# Revision 1.3  1998-11-21 06:43:26  ivan
+# visual
+#
 
 use strict;
-use CGI::Base;
+use CGI;
 use CGI::Carp qw(fatalsToBrowser);
 use FS::UID qw(cgisuidsetup);
 use FS::Record qw(qsearchs);
 use FS::part_svc qw(fields);
-use FS::CGI qw(header menubar);
+use FS::CGI qw(header menubar popurl table);
 
-my($cgi) = new CGI::Base;
-$cgi->get;
+my($cgi) = new CGI;
 
 &cgisuidsetup($cgi);
 
-SendHeaders(); # one guess.
-
 my($part_svc,$action);
-if ( $cgi->var('QUERY_STRING') =~ /^(\d+)$/ ) { #editing
+my($query) = $cgi->keywords;
+if ( $query && $query =~ /^(\d+)$/ ) { #editing
   $part_svc=qsearchs('part_svc',{'svcpart'=>$1});
   $action='Edit';
 } else { #adding
@@ -34,12 +37,11 @@ if ( $cgi->var('QUERY_STRING') =~ /^(\d+)$/ ) { #editing
 }
 my($hashref)=$part_svc->hashref;
 
-print header("$action Service Definition", menubar(
-  'Main Menu' => '../',
-  'View all services' => '../browse/part_svc.cgi',
-)), '<FORM ACTION="process/part_svc.cgi" METHOD=POST>';
-
-
+my $p = popurl(2);
+print $cgi->header, header("$action Service Definition", menubar(
+  'Main Menu' => $p,
+  'View all services' => "$p/browse/part_svc.cgi",
+)), '<FORM ACTION="', popurl(1), '/process/part_svc.cgi" METHOD=POST>';
 
 print qq!<INPUT TYPE="hidden" NAME="svcpart" VALUE="$hashref->{svcpart}">!,
       "Service Part #", $hashref->{svcpart} ? $hashref->{svcpart} : "(NEW)";
@@ -47,29 +49,32 @@ print qq!<INPUT TYPE="hidden" NAME="svcpart" VALUE="$hashref->{svcpart}">!,
 print <<END;
 <PRE>
 Service  <INPUT TYPE="text" NAME="svc" VALUE="$hashref->{svc}">
-Table    <SELECT NAME="svcdb" SIZE=1>
-END
-
-print map '<OPTION'. ' SELECTED'x($_ eq $hashref->{svcdb}). ">$_\n", qw(
-  svc_acct svc_domain svc_acct_sm svc_charge svc_wo
-);
-
-print <<END;
-</SELECT></PRE>
+</PRE>
 Services are items you offer to your customers.
 <UL><LI>svc_acct - Shell accounts, POP mailboxes, SLIP/PPP and ISDN accounts
     <LI>svc_domain - Virtual domains
     <LI>svc_acct_sm - Virtual domain mail aliasing
-    <LI>svc_charge - One-time charges (Partially unimplemented)
-    <LI>svc_wo - Work orders (Partially unimplemented)
+END
+#    <LI>svc_charge - One-time charges (Partially unimplemented)
+#    <LI>svc_wo - Work orders (Partially unimplemented)
+print <<END;
 </UL>
-For the columns in the table selected above, you can set default or fixed 
+For the selected table, you can give fields default or fixed (unchangable)
 values.  For example, a SLIP/PPP account may have a default (or perhaps fixed)
 <B>slipip</B> of <B>0.0.0.0</B>, while a POP mailbox will probably have a fixed
 blank <B>slipip</B> as well as a fixed shell something like <B>/bin/true</B> or
 <B>/usr/bin/passwd</B>.
 <BR><BR>
-<TABLE BORDER CELLPADDING=4><TR><TH>Table</TH><TH>Field</TH>
+END
+print table, '<TR><TH>Table<SELECT NAME="svcdb" SIZE=1>',
+      map '<OPTION'. ' SELECTED'x($_ eq $hashref->{svcdb}). ">$_\n", qw(
+        svc_acct svc_domain svc_acct_sm
+      );
+      print "</SELECT>";
+#  svc_acct svc_domain svc_acct_sm svc_charge svc_wo
+
+print <<END;
+</TH><TH>Field</TH>
 <TH COLSPAN=2>Modifier</TH></TR>
 END
 
@@ -80,7 +85,7 @@ my(%defs)=(
     'dir'       => 'Home directory',
     'uid'       => 'UID (set to fixed and blank for dial-only)',
     'slipip'    => 'IP address',
-    'popnum'    => '<A HREF="../browse/svc_acct_pop.cgi/">POP number</A>',
+    'popnum'    => qq!<A HREF="$p/browse/svc_acct_pop.cgi/">POP number</A>!,
     'username'  => 'Username',
     'quota'     => '(unimplemented)',
     '_password' => 'Password',
@@ -106,8 +111,9 @@ my(%defs)=(
 );
 
 my($svcdb);
+#  svc_acct svc_domain svc_acct_sm svc_charge svc_wo
 foreach $svcdb ( qw(
-  svc_acct svc_domain svc_acct_sm svc_charge svc_wo
+  svc_acct svc_domain svc_acct_sm
 ) ) {
 
   my(@rows)=map { /^${svcdb}__(.*)$/; $1 }
@@ -123,21 +129,21 @@ foreach $svcdb ( qw(
     my($flag)=$part_svc->getfield($svcdb.'__'.$row.'_flag');
     print "<TR>$ptmp<TD>$row - <FONT SIZE=-1>$defs{$svcdb}{$row}</FONT></TD>";
     print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE=""!.
-      ' CHECKED'x($flag eq ''). "><BR>Off</TD>";
+      ' CHECKED'x($flag eq ''). ">Off</TD>";
     print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE="D"!.
       ' CHECKED'x($flag eq 'D'). ">Default ";
     print qq!<INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE="F"!.
       ' CHECKED'x($flag eq 'F'). ">Fixed ";
-    print qq!<BR><INPUT TYPE="text" NAME="${svcdb}__${row}" VALUE="$value">!,
-      "</TD></TR>";
+    print qq!<INPUT TYPE="text" NAME="${svcdb}__${row}" VALUE="$value">!,
+      "</TD></TR>\n";
     $ptmp='';
   }
 }
 print "</TABLE>";
 
-print qq!\n<CENTER><BR><INPUT TYPE="submit" VALUE="!,
+print qq!\n<BR><INPUT TYPE="submit" VALUE="!,
       $hashref->{svcpart} ? "Apply changes" : "Add service",
-      qq!"></CENTER>!;
+      qq!">!;
 
 print <<END;