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';
21 #" onLoad=\"visualize()\""
24 <%= header("$action Service Definition",
25 menubar( 'Main Menu' => $p,
26 'View all service definitions' => "${p}browse/part_svc.cgi"
31 <% if ( $cgi->param('error') ) { %>
32 <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT>
37 Service Part #<%= $part_svc->svcpart ? $part_svc->svcpart : "(NEW)" %>
39 Service <INPUT TYPE="text" NAME="svc" VALUE="<%= $hashref->{svc} %>"><BR>
40 Disable new orders <INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<%= $hashref->{disabled} eq 'Y' ? ' CHECKED' : '' %>><BR>
41 <INPUT TYPE="hidden" NAME="svcpart" VALUE="<%= $hashref->{svcpart} %>">
43 Services are items you offer to your customers.
44 <UL><LI>svc_acct - Shell accounts, POP mailboxes, SLIP/PPP and ISDN accounts
45 <LI>svc_domain - Domains
46 <LI>svc_acct_sm - <B>deprecated</B> (use svc_forward for new installations) Virtual domain mail aliasing.
47 <LI>svc_forward - mail forwarding
48 <LI>svc_www - Virtual domain website
49 <!-- <LI>svc_charge - One-time charges (Partially unimplemented)
50 <LI>svc_wo - Work orders (Partially unimplemented)
53 For the selected table, you can give fields default or fixed (unchangable)
54 values. For example, a SLIP/PPP account may have a default (or perhaps fixed)
55 <B>slipip</B> of <B>0.0.0.0</B>, while a POP mailbox will probably have a fixed
56 blank <B>slipip</B> as well as a fixed shell something like <B>/bin/true</B> or
57 <B>/usr/bin/passwd</B>.
61 #these might belong somewhere else for other user interfaces
62 #pry need to eventually create stuff that's shared amount UIs
65 'dir' => 'Home directory',
66 'uid' => 'UID (set to fixed and blank for dial-only)',
67 '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.)',
68 # 'popnum' => qq!<A HREF="$p/browse/svc_acct_pop.cgi/">POP number</A>!,
70 desc => 'Access number',
72 select_table => 'svc_acct_pop',
73 select_key => 'popnum',
74 select_label => 'city',
76 'username' => 'Username',
78 '_password' => 'Password',
79 'gid' => 'GID (when blank, defaults to UID)',
80 'shell' => 'Shell (all service definitions should have a default or fixed shell that is present in the <b>shells</b> configuration file)',
83 desc =>'svcnum from svc_domain',
85 select_table => 'svc_domain',
86 select_key => 'svcnum',
87 select_label => 'domain',
90 desc =>'ICRADIUS/FreeRADIUS groups',
91 type =>'radius_usergroup_selector',
98 'domuser' => 'domuser@virtualdomain.com',
99 'domuid' => 'UID where domuser@virtualdomain.com mail is forwarded',
100 'domsvc' => 'svcnum from svc_domain for virtualdomain.com',
103 'srcsvc' => 'service from which mail is to be forwarded',
104 'dstsvc' => 'service to which mail is to be forwarded',
105 'dst' => 'someone@another.domain.com to use when dstsvc is 0',
108 'amount' => 'amount',
111 'worker' => 'Worker',
120 my @dbs = $hashref->{svcdb}
121 ? ( $hashref->{svcdb} )
122 : qw( svc_acct svc_domain svc_acct_sm svc_forward svc_www );
124 tie my %svcdb, 'Tie::IxHash', map { $_=>$_ } @dbs;
125 my $widget = new HTML::Widgets::SelectLayers(
126 #'selected_layer' => $p_svcdb,
127 'selected_layer' => $hashref->{svcdb} || 'svc_acct',
128 'options' => \%svcdb,
129 'form_name' => 'dummy',
130 'form_action' => 'process/part_svc.cgi',
131 'form_text' => [ qw( svc svcpart ) ],
132 'form_checkbox' => [ 'disabled' ],
133 'layer_callback' => sub {
135 my $html = qq!<INPUT TYPE="hidden" NAME="svcdb" VALUE="$layer">!;
140 grep { $layer eq FS::part_export::exporttype2svcdb($_->exporttype) }
141 qsearch( 'part_export', {} );
142 $html .= '<BR><BR>'. table().
143 table(). "<TR><TH COLSPAN=$columns>Exports</TH></TR><TR>";
144 foreach my $part_export ( @part_export ) {
145 $html .= '<TD><INPUT TYPE="checkbox"'.
146 ' NAME="exportnum'. $part_export->exportnum. '" VALUE="1" ';
148 if qsearchs( 'export_svc', {
149 exportnum => $part_export->exportnum,
150 svcpart => $part_svc->svcpart });
151 $html .= '> '. $part_export->exporttype. ' to '. $part_export->machine.
154 $html .= '</TR><TR>' unless $count % $columns;
156 $html .= '</TR></TABLE><BR><BR>';
158 $html .= table(). "<TH>Field</TH><TH COLSPAN=2>Modifier</TH>";
160 my @fields = defined( $FS::Record::dbdef->table($layer) )
161 ? grep { $_ ne 'svcnum' } fields($layer)
163 push @fields, 'usergroup' if $layer eq 'svc_acct'; #kludge
164 foreach my $field (@fields) {
165 my $part_svc_column = $part_svc->part_svc_column($field);
166 my $value = $cgi->param('error')
167 ? $cgi->param("${layer}__${field}")
168 : $part_svc_column->columnvalue;
169 my $flag = $cgi->param('error')
170 ? $cgi->param("${layer}__${field}_flag")
171 : $part_svc_column->columnflag;
172 my $def = $defs{$layer}{$field};
173 my $desc = ref($def) ? $def->{desc} : $def;
175 $html .= "<TR><TD>$field";
176 $html .= "- <FONT SIZE=-1>$desc</FONT>" if $desc;
179 qq!<TD><INPUT TYPE="radio" NAME="${layer}__${field}_flag" VALUE=""!.
180 ' CHECKED'x($flag eq ''). ">Off</TD>".
181 qq!<TD><INPUT TYPE="radio" NAME="${layer}__${field}_flag" VALUE="D"!.
182 ' CHECKED'x($flag eq 'D'). ">Default ".
183 qq!<INPUT TYPE="radio" NAME="${layer}__${field}_flag" VALUE="F"!.
184 ' CHECKED'x($flag eq 'F'). ">Fixed ".
187 if ( $def->{type} eq 'select' ) {
188 $html .= qq!<SELECT NAME="${layer}__${field}">!;
189 $html .= '<OPTION> </OPTION>' unless $value;
190 foreach my $record ( qsearch( $def->{select_table}, {} ) ) {
191 my $rvalue = $record->getfield($def->{select_key});
192 $html .= qq!<OPTION VALUE="$rvalue"!.
193 ( $rvalue==$value ? ' SELECTED>' : '>' ).
194 $record->getfield($def->{select_label}). '</OPTION>';
196 $html .= '</SELECT>';
197 } elsif ( $def->{type} eq 'radius_usergroup_selector' ) {
198 $html .= FS::svc_acct::radius_usergroup_selector(
199 [ split(',', $value) ], "${layer}__${field}" );
201 $html .= '<font color="#ff0000">unknown type'. $def->{type};
205 qq!<INPUT TYPE="text" NAME="${layer}__${field}" VALUE="$value">!;
207 $html .= "</TD></TR>\n";
211 $html .= '<BR><INPUT TYPE="submit" VALUE="'.
212 ($hashref->{svcpart} ? 'Apply changes' : 'Add service'). '">';
220 Table <%= $widget->html %>