3 # $Id: part_svc.cgi,v 1.10 1999-04-08 13:01:50 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.10 1999-04-08 13:01:50 ivan
14 # [ AND DOCUMENT! ] all svc_acct services should have a default
17 # Revision 1.9 1999/02/23 08:09:21 ivan
18 # beginnings of one-screen new customer entry and some other miscellania
20 # Revision 1.8 1999/02/07 09:59:21 ivan
21 # more mod_perl fixes, and bugfixes Peter Wemm sent via email
23 # Revision 1.7 1999/01/19 05:13:42 ivan
24 # for mod_perl: no more top-level my() variables; use vars instead
25 # also the last s/create/new/;
27 # Revision 1.6 1999/01/18 09:41:31 ivan
28 # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
31 # Revision 1.5 1998/12/30 23:03:21 ivan
32 # bugfixes; fields isn't exported by derived classes
34 # Revision 1.4 1998/12/17 06:17:07 ivan
35 # fix double // in relative URLs, s/CGI::Base/CGI/;
37 # Revision 1.3 1998/11/21 06:43:26 ivan
42 use vars qw( $cgi $part_svc $action $query $hashref $p %defs $svcdb );
44 use CGI::Carp qw(fatalsToBrowser);
45 use FS::UID qw(cgisuidsetup);
46 use FS::Record qw(qsearchs fields);
48 use FS::CGI qw(header menubar popurl table);
54 if ( $cgi->param('error') ) {
55 $part_svc = new FS::part_svc ( {
56 map { $_, scalar($cgi->param($_)) } fields('part_svc')
58 } elsif ( $cgi->keywords ) {
59 my ($query) = $cgi->keywords;
61 $part_svc=qsearchs('part_svc',{'svcpart'=>$1});
63 $part_svc = new FS::part_svc {};
65 $action = $part_svc->svcpart ? 'Edit' : 'Add';
66 $hashref = $part_svc->hashref;
69 print $cgi->header( '-expires' => 'now' ), header("$action Service Definition", menubar(
71 'View all services' => "${p}browse/part_svc.cgi",
74 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
76 if $cgi->param('error');
78 print '<FORM ACTION="', popurl(1), 'process/part_svc.cgi" METHOD=POST>';
80 print qq!<INPUT TYPE="hidden" NAME="svcpart" VALUE="$hashref->{svcpart}">!,
81 "Service Part #", $hashref->{svcpart} ? $hashref->{svcpart} : "(NEW)";
85 Service <INPUT TYPE="text" NAME="svc" VALUE="$hashref->{svc}">
87 Services are items you offer to your customers.
88 <UL><LI>svc_acct - Shell accounts, POP mailboxes, SLIP/PPP and ISDN accounts
89 <LI>svc_domain - Virtual domains
90 <LI>svc_acct_sm - Virtual domain mail aliasing
92 # <LI>svc_charge - One-time charges (Partially unimplemented)
93 # <LI>svc_wo - Work orders (Partially unimplemented)
96 For the selected table, you can give fields default or fixed (unchangable)
97 values. For example, a SLIP/PPP account may have a default (or perhaps fixed)
98 <B>slipip</B> of <B>0.0.0.0</B>, while a POP mailbox will probably have a fixed
99 blank <B>slipip</B> as well as a fixed shell something like <B>/bin/true</B> or
100 <B>/usr/bin/passwd</B>.
103 print table, '<TR><TH>Table<SELECT NAME="svcdb" SIZE=1>',
104 map '<OPTION'. ' SELECTED'x($_ eq $hashref->{svcdb}). ">$_\n", qw(
105 svc_acct svc_domain svc_acct_sm
108 # svc_acct svc_domain svc_acct_sm svc_charge svc_wo
112 <TH COLSPAN=2>Modifier</TH></TR>
115 #these might belong somewhere else for other user interfaces
116 #pry need to eventually create stuff that's shared amount UIs
119 'dir' => 'Home directory',
120 'uid' => 'UID (set to fixed and blank for dial-only)',
121 'slipip' => 'IP address',
122 'popnum' => qq!<A HREF="$p/browse/svc_acct_pop.cgi/">POP number</A>!,
123 'username' => 'Username',
124 'quota' => '(unimplemented)',
125 '_password' => 'Password',
126 'gid' => 'GID (when blank, defaults to UID)',
127 'shell' => 'Shell (all service definitions should have a default or fixed shell that is present in the <b>shells</b> configuration file)',
131 'domain' => 'Domain',
134 'domuser' => 'domuser@virtualdomain.com',
135 'domuid' => 'UID where domuser@virtualdomain.com mail is forwarded',
136 'domsvc' => 'svcnum from svc_domain for virtualdomain.com',
139 'amount' => 'amount',
142 'worker' => 'Worker',
147 # svc_acct svc_domain svc_acct_sm svc_charge svc_wo
149 svc_acct svc_domain svc_acct_sm
152 my(@rows)=map { /^${svcdb}__(.*)$/; $1 }
156 my($rowspan)=scalar(@rows);
158 my($ptmp)="<TD ROWSPAN=$rowspan>$svcdb</TD>";
160 foreach $row (@rows) {
161 my $value = $part_svc->getfield($svcdb. '__'. $row);
162 my $flag = $part_svc->getfield($svcdb. '__'. $row. '_flag');
163 print "<TR>$ptmp<TD>$row";
164 print "- <FONT SIZE=-1>$defs{$svcdb}{$row}</FONT>"
165 if defined $defs{$svcdb}{$row};
167 print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE=""!.
168 ' CHECKED'x($flag eq ''). ">Off</TD>";
169 print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE="D"!.
170 ' CHECKED'x($flag eq 'D'). ">Default ";
171 print qq!<INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE="F"!.
172 ' CHECKED'x($flag eq 'F'). ">Fixed ";
173 print qq!<INPUT TYPE="text" NAME="${svcdb}__${row}" VALUE="$value">!,
180 print qq!\n<BR><INPUT TYPE="submit" VALUE="!,
181 $hashref->{svcpart} ? "Apply changes" : "Add service",