3 # part_svc.cgi: Add/Edit service (output form)
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
14 use CGI::Carp qw(fatalsToBrowser);
15 use FS::UID qw(cgisuidsetup);
16 use FS::Record qw(qsearchs);
17 use FS::part_svc qw(fields);
18 use FS::CGI qw(header menubar);
20 my($cgi) = new CGI::Base;
25 SendHeaders(); # one guess.
27 my($part_svc,$action);
28 if ( $cgi->var('QUERY_STRING') =~ /^(\d+)$/ ) { #editing
29 $part_svc=qsearchs('part_svc',{'svcpart'=>$1});
32 $part_svc=create FS::part_svc {};
35 my($hashref)=$part_svc->hashref;
37 print header("$action Service Definition", menubar(
39 'View all services' => '../browse/part_svc.cgi',
40 )), '<FORM ACTION="process/part_svc.cgi" METHOD=POST>';
44 print qq!<INPUT TYPE="hidden" NAME="svcpart" VALUE="$hashref->{svcpart}">!,
45 "Service Part #", $hashref->{svcpart} ? $hashref->{svcpart} : "(NEW)";
49 Service <INPUT TYPE="text" NAME="svc" VALUE="$hashref->{svc}">
50 Table <SELECT NAME="svcdb" SIZE=1>
53 print map '<OPTION'. ' SELECTED'x($_ eq $hashref->{svcdb}). ">$_\n", qw(
54 svc_acct svc_domain svc_acct_sm svc_charge svc_wo
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
63 <LI>svc_charge - One-time charges (Partially unimplemented)
64 <LI>svc_wo - Work orders (Partially unimplemented)
66 For the columns in the table selected above, you can set default or fixed
67 values. For example, a SLIP/PPP account may have a default (or perhaps fixed)
68 <B>slipip</B> of <B>0.0.0.0</B>, while a POP mailbox will probably have a fixed
69 blank <B>slipip</B> as well as a fixed shell something like <B>/bin/true</B> or
70 <B>/usr/bin/passwd</B>.
72 <TABLE BORDER CELLPADDING=4><TR><TH>Table</TH><TH>Field</TH>
73 <TH COLSPAN=2>Modifier</TH></TR>
76 #these might belong somewhere else for other user interfaces
77 #pry need to eventually create stuff that's shared amount UIs
80 'dir' => 'Home directory',
81 'uid' => 'UID (set to fixed and blank for dial-only)',
82 'slipip' => 'IP address',
83 'popnum' => '<A HREF="../browse/svc_acct_pop.cgi/">POP number</A>',
84 'username' => 'Username',
85 'quota' => '(unimplemented)',
86 '_password' => 'Password',
87 'gid' => 'GID (when blank, defaults to UID)',
95 'domuser' => 'domuser@virtualdomain.com',
96 'domuid' => 'UID where domuser@virtualdomain.com mail is forwarded',
97 'domsvc' => 'svcnum from svc_domain for virtualdomain.com',
100 'amount' => 'amount',
103 'worker' => 'Worker',
110 svc_acct svc_domain svc_acct_sm svc_charge svc_wo
113 my(@rows)=map { /^${svcdb}__(.*)$/; $1 }
117 my($rowspan)=scalar(@rows);
119 my($ptmp)="<TD ROWSPAN=$rowspan>$svcdb</TD>";
121 foreach $row (@rows) {
122 my($value)=$part_svc->getfield($svcdb.'__'.$row);
123 my($flag)=$part_svc->getfield($svcdb.'__'.$row.'_flag');
124 print "<TR>$ptmp<TD>$row - <FONT SIZE=-1>$defs{$svcdb}{$row}</FONT></TD>";
125 print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE=""!.
126 ' CHECKED'x($flag eq ''). "><BR>Off</TD>";
127 print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE="D"!.
128 ' CHECKED'x($flag eq 'D'). ">Default ";
129 print qq!<INPUT TYPE="radio" NAME="${svcdb}__${row}_flag" VALUE="F"!.
130 ' CHECKED'x($flag eq 'F'). ">Fixed ";
131 print qq!<BR><INPUT TYPE="text" NAME="${svcdb}__${row}" VALUE="$value">!,
138 print qq!\n<CENTER><BR><INPUT TYPE="submit" VALUE="!,
139 $hashref->{svcpart} ? "Apply changes" : "Add service",