3 # $Id: part_svc.cgi,v 1.14 2001-05-30 14:42:11 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.14 2001-05-30 14:42:11 ivan
14 # Adam Rose <adamr@eaze.net>: "In the /edit/part_svc.cgi is there a need to add
15 # another section for svc_www?". Yes. Thanks Adam.
17 # Revision 1.13 2000/06/15 11:10:31 ivan
18 # update to the inline documentation, hopefully will make things more clear
20 # Revision 1.12 1999/04/09 04:22:34 ivan
23 # Revision 1.11 1999/04/09 03:52:55 ivan
24 # explicit & for table/itable/ntable
26 # Revision 1.10 1999/04/08 13:01:50 ivan
27 # [ AND DOCUMENT! ] all svc_acct services should have a default
30 # Revision 1.9 1999/02/23 08:09:21 ivan
31 # beginnings of one-screen new customer entry and some other miscellania
33 # Revision 1.8 1999/02/07 09:59:21 ivan
34 # more mod_perl fixes, and bugfixes Peter Wemm sent via email
36 # Revision 1.7 1999/01/19 05:13:42 ivan
37 # for mod_perl: no more top-level my() variables; use vars instead
38 # also the last s/create/new/;
40 # Revision 1.6 1999/01/18 09:41:31 ivan
41 # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
44 # Revision 1.5 1998/12/30 23:03:21 ivan
45 # bugfixes; fields isn't exported by derived classes
47 # Revision 1.4 1998/12/17 06:17:07 ivan
48 # fix double // in relative URLs, s/CGI::Base/CGI/;
50 # Revision 1.3 1998/11/21 06:43:26 ivan
55 use vars qw( $cgi $part_svc $action $query $hashref $p %defs $svcdb );
57 use CGI::Carp qw(fatalsToBrowser);
58 use FS::UID qw(cgisuidsetup);
59 use FS::Record qw(qsearchs fields);
61 use FS::CGI qw(header menubar popurl table);
67 if ( $cgi->param('error') ) {
68 $part_svc = new FS::part_svc ( {
69 map { $_, scalar($cgi->param($_)) } fields('part_svc')
71 } elsif ( $cgi->keywords ) {
72 my ($query) = $cgi->keywords;
74 $part_svc=qsearchs('part_svc',{'svcpart'=>$1});
76 $part_svc = new FS::part_svc {};
78 $action = $part_svc->svcpart ? 'Edit' : 'Add';
79 $hashref = $part_svc->hashref;
82 print $cgi->header( '-expires' => 'now' ), header("$action Service Definition", menubar(
84 'View all services' => "${p}browse/part_svc.cgi",
87 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
89 if $cgi->param('error');
91 print '<FORM ACTION="', popurl(1), 'process/part_svc.cgi" METHOD=POST>';
93 print qq!<INPUT TYPE="hidden" NAME="svcpart" VALUE="$hashref->{svcpart}">!,
94 "Service Part #", $hashref->{svcpart} ? $hashref->{svcpart} : "(NEW)";
98 Service <INPUT TYPE="text" NAME="svc" VALUE="$hashref->{svc}">
100 Services are items you offer to your customers.
101 <UL><LI>svc_acct - Shell accounts, POP mailboxes, SLIP/PPP and ISDN accounts
102 <LI>svc_domain - Virtual domains
103 <LI>svc_acct_sm - Virtual domain mail aliasing
104 <LI>svc_www - Virtual domain website
106 # <LI>svc_charge - One-time charges (Partially unimplemented)
107 # <LI>svc_wo - Work orders (Partially unimplemented)
110 For the selected table, you can give fields default or fixed (unchangable)
111 values. For example, a SLIP/PPP account may have a default (or perhaps fixed)
112 <B>slipip</B> of <B>0.0.0.0</B>, while a POP mailbox will probably have a fixed
113 blank <B>slipip</B> as well as a fixed shell something like <B>/bin/true</B> or
114 <B>/usr/bin/passwd</B>.
117 print &table(), '<TR><TH>Table<SELECT NAME="svcdb" SIZE=1>',
118 map '<OPTION'. ' SELECTED'x($_ eq $hashref->{svcdb}). ">$_\n", qw(
119 svc_acct svc_domain svc_acct_sm svc_www
122 # svc_acct svc_domain svc_acct_sm svc_charge svc_wo
126 <TH COLSPAN=2>Modifier</TH></TR>
129 #these might belong somewhere else for other user interfaces
130 #pry need to eventually create stuff that's shared amount UIs
133 'dir' => 'Home directory',
134 'uid' => 'UID (set to fixed and blank for dial-only)',
135 'slipip' => 'IP address (set to fixed and blank to disable dialin)',
136 'popnum' => qq!<A HREF="$p/browse/svc_acct_pop.cgi/">POP number</A>!,
137 'username' => 'Username',
138 'quota' => '(unimplemented)',
139 '_password' => 'Password',
140 'gid' => 'GID (when blank, defaults to UID)',
141 'shell' => 'Shell (all service definitions should have a default or fixed shell that is present in the <b>shells</b> configuration file)',
145 'domain' => 'Domain',
148 'domuser' => 'domuser@virtualdomain.com',
149 'domuid' => 'UID where domuser@virtualdomain.com mail is forwarded',
150 'domsvc' => 'svcnum from svc_domain for virtualdomain.com',
153 'amount' => 'amount',
156 'worker' => 'Worker',
165 # svc_acct svc_domain svc_acct_sm svc_charge svc_wo
167 svc_acct svc_domain svc_acct_sm svc_www
170 my(@rows)=map { /^${svcdb}__(.*)$/; $1 }
174 my($rowspan)=scalar(@rows);
176 my($ptmp)="<TD ROWSPAN=$rowspan>$svcdb</TD>";
178 foreach $row (@rows) {
179 my $value = $part_svc->getfield($svcdb. '__'. $row);
180 my $flag = $part_svc->getfield($svcdb. '__'. $row. '_flag');
181 print "<TR>$ptmp<TD>$row";
182 print "- <FONT SIZE=-1>$defs{$svcdb}{$row}</FONT>"
183 if defined $defs{$svcdb}{$row};
185 print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE=""!.
186 ' CHECKED'x($flag eq ''). ">Off</TD>";
187 print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE="D"!.
188 ' CHECKED'x($flag eq 'D'). ">Default ";
189 print qq!<INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE="F"!.
190 ' CHECKED'x($flag eq 'F'). ">Fixed ";
191 print qq!<INPUT TYPE="text" NAME="${svcdb}__${row}" VALUE="$value">!,
198 print qq!\n<BR><INPUT TYPE="submit" VALUE="!,
199 $hashref->{svcpart} ? "Apply changes" : "Add service",