3 # $Id: part_svc.cgi,v 1.8 1999-02-07 09:59: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.8 1999-02-07 09:59:21 ivan
14 # more mod_perl fixes, and bugfixes Peter Wemm sent via email
16 # Revision 1.7 1999/01/19 05:13:42 ivan
17 # for mod_perl: no more top-level my() variables; use vars instead
18 # also the last s/create/new/;
20 # Revision 1.6 1999/01/18 09:41:31 ivan
21 # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
24 # Revision 1.5 1998/12/30 23:03:21 ivan
25 # bugfixes; fields isn't exported by derived classes
27 # Revision 1.4 1998/12/17 06:17:07 ivan
28 # fix double // in relative URLs, s/CGI::Base/CGI/;
30 # Revision 1.3 1998/11/21 06:43:26 ivan
35 use vars qw( $cgi $part_svc $action $query $hashref $p %defs $svcdb );
37 use CGI::Carp qw(fatalsToBrowser);
38 use FS::UID qw(cgisuidsetup);
39 use FS::Record qw(qsearchs fields);
41 use FS::CGI qw(header menubar popurl table);
47 if ( $cgi->param('error') ) {
48 $part_svc = new FS::part_svc ( {
49 map { $_, scalar($cgi->param($_)) } fields('part_svc')
51 } elsif ( $cgi->keywords ) {
52 my ($query) = $cgi->keywords;
54 $part_svc=qsearchs('part_svc',{'svcpart'=>$1});
56 $part_svc = new FS::part_svc {};
58 $action = $part_svc->svcpart ? 'Edit' : 'Add';
59 $hashref = $part_svc->hashref;
62 print $cgi->header( '-expires' => 'now' ), header("$action Service Definition", menubar(
64 'View all services' => "${p}browse/part_svc.cgi",
67 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
69 if $cgi->param('error');
71 print '<FORM ACTION="', popurl(1), 'process/part_svc.cgi" METHOD=POST>';
73 print qq!<INPUT TYPE="hidden" NAME="svcpart" VALUE="$hashref->{svcpart}">!,
74 "Service Part #", $hashref->{svcpart} ? $hashref->{svcpart} : "(NEW)";
78 Service <INPUT TYPE="text" NAME="svc" VALUE="$hashref->{svc}">
80 Services are items you offer to your customers.
81 <UL><LI>svc_acct - Shell accounts, POP mailboxes, SLIP/PPP and ISDN accounts
82 <LI>svc_domain - Virtual domains
83 <LI>svc_acct_sm - Virtual domain mail aliasing
85 # <LI>svc_charge - One-time charges (Partially unimplemented)
86 # <LI>svc_wo - Work orders (Partially unimplemented)
89 For the selected table, you can give fields default or fixed (unchangable)
90 values. For example, a SLIP/PPP account may have a default (or perhaps fixed)
91 <B>slipip</B> of <B>0.0.0.0</B>, while a POP mailbox will probably have a fixed
92 blank <B>slipip</B> as well as a fixed shell something like <B>/bin/true</B> or
93 <B>/usr/bin/passwd</B>.
96 print table, '<TR><TH>Table<SELECT NAME="svcdb" SIZE=1>',
97 map '<OPTION'. ' SELECTED'x($_ eq $hashref->{svcdb}). ">$_\n", qw(
98 svc_acct svc_domain svc_acct_sm
101 # svc_acct svc_domain svc_acct_sm svc_charge svc_wo
105 <TH COLSPAN=2>Modifier</TH></TR>
108 #these might belong somewhere else for other user interfaces
109 #pry need to eventually create stuff that's shared amount UIs
112 'dir' => 'Home directory',
113 'uid' => 'UID (set to fixed and blank for dial-only)',
114 'slipip' => 'IP address',
115 'popnum' => qq!<A HREF="$p/browse/svc_acct_pop.cgi/">POP number</A>!,
116 'username' => 'Username',
117 'quota' => '(unimplemented)',
118 '_password' => 'Password',
119 'gid' => 'GID (when blank, defaults to UID)',
124 'domain' => 'Domain',
127 'domuser' => 'domuser@virtualdomain.com',
128 'domuid' => 'UID where domuser@virtualdomain.com mail is forwarded',
129 'domsvc' => 'svcnum from svc_domain for virtualdomain.com',
132 'amount' => 'amount',
135 'worker' => 'Worker',
140 # svc_acct svc_domain svc_acct_sm svc_charge svc_wo
142 svc_acct svc_domain svc_acct_sm
145 my(@rows)=map { /^${svcdb}__(.*)$/; $1 }
149 my($rowspan)=scalar(@rows);
151 my($ptmp)="<TD ROWSPAN=$rowspan>$svcdb</TD>";
153 foreach $row (@rows) {
154 my($value)=$part_svc->getfield($svcdb.'__'.$row);
155 my($flag)=$part_svc->getfield($svcdb.'__'.$row.'_flag');
156 print "<TR>$ptmp<TD>$row - <FONT SIZE=-1>$defs{$svcdb}{$row}</FONT></TD>";
157 print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE=""!.
158 ' CHECKED'x($flag eq ''). ">Off</TD>";
159 print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE="D"!.
160 ' CHECKED'x($flag eq 'D'). ">Default ";
161 print qq!<INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE="F"!.
162 ' CHECKED'x($flag eq 'F'). ">Fixed ";
163 print qq!<INPUT TYPE="text" NAME="${svcdb}__${row}" VALUE="$value">!,
170 print qq!\n<BR><INPUT TYPE="submit" VALUE="!,
171 $hashref->{svcpart} ? "Apply changes" : "Add service",