1 <!-- $Id: part_svc.cgi,v 1.11 2001-09-11 19:16:41 ivan Exp $ -->
4 if ( $cgi->param('error') ) { #error
5 $part_svc = new FS::part_svc ( {
6 map { $_, scalar($cgi->param($_)) } fields('part_svc')
8 } elsif ( $cgi->keywords ) { #edit
9 my($query) = $cgi->keywords;
10 $query =~ /^(\d+)$/ or die "malformed query: $query";
11 $part_svc=qsearchs('part_svc', { 'svcpart'=>$1 } )
12 or die "unknown svcpart: $1";
14 $part_svc = new FS::part_svc {};
16 my $action = $part_svc->svcpart ? 'Edit' : 'Add';
17 my $hashref = $part_svc->hashref;
18 my $p_svcdb = $part_svc->svcdb || 'svc_acct';
23 function visualize(what) {
24 if (document.getElementById) {
25 document.getElementById('d<%= $p_svcdb %>').style.visibility = "visible";
27 document.l<%= $p_svcdb %>.visibility = "visible";
32 <%= header("$action Service Definition",
33 menubar( 'Main Menu' => $p,
34 'View all service definitions' => "${p}browse/part_svc.cgi"
36 " onLoad=\"visualize()\""
40 <% if ( $cgi->param('error') ) { %>
41 <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT>
46 Service Part #<%= $part_svc->svcpart ? $part_svc->svcpart : "(NEW)" %>
48 Service <INPUT TYPE="text" NAME="svc" VALUE="<%= $hashref->{svc} %>">
50 Services are items you offer to your customers.
51 <UL><LI>svc_acct - Shell accounts, POP mailboxes, SLIP/PPP and ISDN accounts
52 <LI>svc_domain - Domains
53 <LI>svc_acct_sm - <B>depreciated</B> (use svc_forward for new installations) Virtual domain mail aliasing.
54 <LI>svc_forward - mail forwarding
55 <LI>svc_www - Virtual domain website
56 <!-- <LI>svc_charge - One-time charges (Partially unimplemented)
57 <LI>svc_wo - Work orders (Partially unimplemented)
60 For the selected table, you can give fields default or fixed (unchangable)
61 values. For example, a SLIP/PPP account may have a default (or perhaps fixed)
62 <B>slipip</B> of <B>0.0.0.0</B>, while a POP mailbox will probably have a fixed
63 blank <B>slipip</B> as well as a fixed shell something like <B>/bin/true</B> or
64 <B>/usr/bin/passwd</B>.
69 function changed(what) {
70 svcdb = what.options[what.selectedIndex].value;
71 <% foreach my $svcdb ( qw( svc_acct svc_domain svc_acct_sm svc_forward svc_www ) ) { %>
72 if (svcdb == "<%= $svcdb %>" ) {
73 <% foreach my $not ( grep { $_ ne $svcdb } (
74 qw(svc_acct svc_domain svc_acct_sm svc_forward svc_www) ) ) { %>
75 if (document.getElementById) {
76 document.getElementById('d<%= $not %>').style.visibility = "hidden";
78 document.l<%= $not %>.visibility = "hidden";
81 if (document.getElementById) {
82 document.getElementById('d<%= $svcdb %>').style.visibility = "visible";
84 document.l<%= $svcdb %>.visibility = "visible";
90 <% my @dbs = $hashref->{svcdb}
91 ? ( $hashref->{svcdb} )
92 : qw( svc_acct svc_domain svc_acct_sm svc_forward svc_www ); %>
93 Table<SELECT NAME="svcdb" SIZE=1 onChange="changed(this)">
94 <% foreach my $svcdb (@dbs) { %>
95 <OPTION VALUE="<%= $svcdb %>" <%= ' SELECTED'x($svcdb eq $hashref->{svcdb}) %>><%= $svcdb %>
100 #these might belong somewhere else for other user interfaces
101 #pry need to eventually create stuff that's shared amount UIs
104 'dir' => 'Home directory',
105 'uid' => 'UID (set to fixed and blank for dial-only)',
106 'slipip' => 'IP address (Set to fixed and blank to disable dialin, or, set a value to be exported to RADIUS Framed-IP-Address. Use the special value <code>0e0</code> [zero e zero] to enable export to RADIUS without a Framed-IP-Address.)',
107 'popnum' => qq!<A HREF="$p/browse/svc_acct_pop.cgi/">POP number</A>!,
108 'username' => 'Username',
110 '_password' => 'Password',
111 'gid' => 'GID (when blank, defaults to UID)',
112 'shell' => 'Shell (all service definitions should have a default or fixed shell that is present in the <b>shells</b> configuration file)',
114 'domsvc' => 'svcnum from svc_domain',
117 'domain' => 'Domain',
120 'domuser' => 'domuser@virtualdomain.com',
121 'domuid' => 'UID where domuser@virtualdomain.com mail is forwarded',
122 'domsvc' => 'svcnum from svc_domain for virtualdomain.com',
125 'srcsvc' => 'service from which mail is to be forwarded',
126 'dstsvc' => 'service to which mail is to be forwarded',
127 'dst' => 'someone@another.domain.com to use when dstsvc is 0',
130 'amount' => 'amount',
133 'worker' => 'Worker',
142 # svc_acct svc_domain svc_acct_sm svc_charge svc_wo
143 foreach my $svcdb ( qw(
144 konq_kludge svc_acct svc_domain svc_acct_sm svc_forward svc_www
147 # my(@fields) = $svcdb eq 'konq_kludge'
149 # : grep { $_ ne 'svcnum' } fields($svcdb);
151 my(@fields) = defined( $FS::Record::dbdef->table($svcdb) )
152 ? grep { $_ ne 'svcnum' } fields($svcdb)
154 #my($rowspan)=scalar(@rows);
156 #my($ptmp)="<TD ROWSPAN=$rowspan>$svcdb</TD>";
157 # $visibility = $svcdb eq $part_svc->svcdb ? "SHOW" : "HIDDEN";
158 # $visibility = $svcdb eq $p_svcdb ? "visible" : "hidden";
159 my $visibility = "hidden";
162 if (document.getElementById) {
163 document.write("<DIV ID=\"d<%= $svcdb %>\" STYLE=\"visibility: <%= $visibility %>; position: absolute\">");
165 <% $visibility="show" if $visibility eq "visible"; %>
166 document.write("<LAYER ID=\"l<%= $svcdb %>\" VISIBILITY=\"<%= $visibility %>\">");
169 function fixup(what) {
170 what.svc.value = document.dummy.svc.value;
171 what.svcdb.value = document.dummy.svcdb.options[document.dummy.svcdb.selectedIndex].value
174 <FORM NAME="<%= $svcdb %>" ACTION="process/part_svc.cgi" METHOD=POST onSubmit="fixup(this)">
175 <INPUT TYPE="hidden" NAME="svcpart" VALUE="<%= $hashref->{svcpart} %>">
176 <INPUT TYPE="hidden" NAME="svc" VALUE="<%= $hashref->{svc} %>">
177 <INPUT TYPE="hidden" NAME="svcdb" VALUE="<%= $svcdb %>">
179 print "$svcdb" unless $svcdb eq 'konq_kludge';
180 print "<BR><TABLE BORDER=1><TH>Field</TH><TH COLSPAN=2>Modifier</TH>" unless $svcdb eq 'konq_kludge';
182 foreach my $field (@fields) {
183 my $part_svc_column = $part_svc->part_svc_column($field);
184 my $value = $cgi->param('error')
185 ? $cgi->param("${svcdb}__${field}")
186 : $part_svc_column->columnvalue;
187 my $flag = $cgi->param('error')
188 ? $cgi->param("${svcdb}__${field}_flag")
189 : $part_svc_column->columnflag;
190 #print "<TR>$ptmp<TD>$field";
191 print "<TR><TD>$field";
192 print "- <FONT SIZE=-1>$defs{$svcdb}{$field}</FONT>"
193 if defined $defs{$svcdb}{$field};
195 print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${field}_flag" VALUE=""!.
196 ' CHECKED'x($flag eq ''). ">Off</TD>";
197 print qq!<TD><INPUT TYPE="radio" NAME="${svcdb}__${field}_flag" VALUE="D"!.
198 ' CHECKED'x($flag eq 'D'). ">Default ";
199 print qq!<INPUT TYPE="radio" NAME="${svcdb}__${field}_flag" VALUE="F"!.
200 ' CHECKED'x($flag eq 'F'). ">Fixed ";
201 print qq!<INPUT TYPE="text" NAME="${svcdb}__${field}" VALUE="$value">!,
205 print "</TABLE>" unless $svcdb eq 'konq_kludge';
207 print qq!\n<BR><INPUT TYPE="submit" VALUE="!,
208 $hashref->{svcpart} ? "Apply changes" : "Add service",
209 qq!">! unless $svcdb eq 'konq_kludge';
214 if (document.getElementById) {
215 document.write("</DIV>");
217 document.write("</LAYER>");
226 if (document.getElementById) {
227 document.getElementById('d<%= $p_svcdb %>').style.visibility = 'visible';
229 document.l<%= $p_svcdb %>.visibility = 'visible';