3 # $Id: part_svc.cgi,v 1.5 1998-12-30 23:03:21 ivan Exp $
5 # ivan@sisd.com 97-nov-14
7 # Changes to allow page to work at a relative position in server
8 # bmccane@maxbaud.net 98-apr-3
10 # use FS::CGI, added inline documentation ivan@sisd.com 98-jul-12
12 # $Log: part_svc.cgi,v $
13 # Revision 1.5 1998-12-30 23:03:21 ivan
14 # bugfixes; fields isn't exported by derived classes
16 # Revision 1.4 1998/12/17 06:17:07 ivan
17 # fix double // in relative URLs, s/CGI::Base/CGI/;
19 # Revision 1.3 1998/11/21 06:43:26 ivan
25 use CGI::Carp qw(fatalsToBrowser);
26 use FS::UID qw(cgisuidsetup);
27 use FS::Record qw(qsearchs fields);
29 use FS::CGI qw(header menubar popurl table);
35 my($part_svc,$action);
36 my($query) = $cgi->keywords;
37 if ( $query && $query =~ /^(\d+)$/ ) { #editing
38 $part_svc=qsearchs('part_svc',{'svcpart'=>$1});
41 $part_svc=create FS::part_svc {};
44 my($hashref)=$part_svc->hashref;
47 print $cgi->header, header("$action Service Definition", menubar(
49 'View all services' => "${p}browse/part_svc.cgi",
50 )), '<FORM ACTION="', popurl(1), 'process/part_svc.cgi" METHOD=POST>';
52 print qq!<INPUT TYPE="hidden" NAME="svcpart" VALUE="$hashref->{svcpart}">!,
53 "Service Part #", $hashref->{svcpart} ? $hashref->{svcpart} : "(NEW)";
57 Service <INPUT TYPE="text" NAME="svc" VALUE="$hashref->{svc}">
59 Services are items you offer to your customers.
60 <UL><LI>svc_acct - Shell accounts, POP mailboxes, SLIP/PPP and ISDN accounts
61 <LI>svc_domain - Virtual domains
62 <LI>svc_acct_sm - Virtual domain mail aliasing
64 # <LI>svc_charge - One-time charges (Partially unimplemented)
65 # <LI>svc_wo - Work orders (Partially unimplemented)
68 For the selected table, you can give fields default or fixed (unchangable)
69 values. For example, a SLIP/PPP account may have a default (or perhaps fixed)
70 <B>slipip</B> of <B>0.0.0.0</B>, while a POP mailbox will probably have a fixed
71 blank <B>slipip</B> as well as a fixed shell something like <B>/bin/true</B> or
72 <B>/usr/bin/passwd</B>.
75 print table, '<TR><TH>Table<SELECT NAME="svcdb" SIZE=1>',
76 map '<OPTION'. ' SELECTED'x($_ eq $hashref->{svcdb}). ">$_\n", qw(
77 svc_acct svc_domain svc_acct_sm
80 # svc_acct svc_domain svc_acct_sm svc_charge svc_wo
84 <TH COLSPAN=2>Modifier</TH></TR>
87 #these might belong somewhere else for other user interfaces
88 #pry need to eventually create stuff that's shared amount UIs
91 'dir' => 'Home directory',
92 'uid' => 'UID (set to fixed and blank for dial-only)',
93 'slipip' => 'IP address',
94 'popnum' => qq!<A HREF="$p/browse/svc_acct_pop.cgi/">POP number</A>!,
95 'username' => 'Username',
96 'quota' => '(unimplemented)',
97 '_password' => 'Password',
98 'gid' => 'GID (when blank, defaults to UID)',
103 'domain' => 'Domain',
106 'domuser' => 'domuser@virtualdomain.com',
107 'domuid' => 'UID where domuser@virtualdomain.com mail is forwarded',
108 'domsvc' => 'svcnum from svc_domain for virtualdomain.com',
111 'amount' => 'amount',
114 'worker' => 'Worker',
120 # svc_acct svc_domain svc_acct_sm svc_charge svc_wo
122 svc_acct svc_domain svc_acct_sm
125 my(@rows)=map { /^${svcdb}__(.*)$/; $1 }
129 my($rowspan)=scalar(@rows);
131 my($ptmp)="<TD ROWSPAN=$rowspan>$svcdb</TD>";
133 foreach $row (@rows) {
134 my($value)=$part_svc->getfield($svcdb.'__'.$row);
135 my($flag)=$part_svc->getfield($svcdb.'__'.$row.'_flag');
136 print "<TR>$ptmp<TD>$row - <FONT SIZE=-1>$defs{$svcdb}{$row}</FONT></TD>";
137 print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE=""!.
138 ' CHECKED'x($flag eq ''). ">Off</TD>";
139 print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE="D"!.
140 ' CHECKED'x($flag eq 'D'). ">Default ";
141 print qq!<INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE="F"!.
142 ' CHECKED'x($flag eq 'F'). ">Fixed ";
143 print qq!<INPUT TYPE="text" NAME="${svcdb}__${row}" VALUE="$value">!,
150 print qq!\n<BR><INPUT TYPE="submit" VALUE="!,
151 $hashref->{svcpart} ? "Apply changes" : "Add service",