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