enable CardFortress in test database, #71513
[freeside.git] / httemplate / edit / svc_acct.cgi
1 <& /elements/header.html, mt("$action [_1] account",$svc) &>
2
3 <& /elements/error.html &>
4
5 % if ( $cust_main ) { 
6
7   <& /elements/small_custview.html, $cust_main, '', 1,
8               popurl(2) . "view/cust_main.cgi" &>
9   <BR>
10 % } 
11
12 <FORM NAME="OneTrueForm" ACTION="<% $p1 %>process/svc_acct.cgi" METHOD=POST>
13 <INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>">
14 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
15 <INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
16
17 % if ( $svcnum ) {
18 % my $svclabel = emt("Service #[_1]",$svcnum);
19 % $svclabel =~ s/$svcnum/<B>$svcnum<\/B>/;
20 <% $svclabel %>
21 % } else {
22 <% mt("Service # (NEW)") |h %>
23 % }
24 <BR>
25
26 <% ntable("#cccccc",2) %>
27
28 <TR>
29   <TD ALIGN="right"><% mt('Service') |h %></TD>
30   <TD BGCOLOR="#eeeeee"><% $part_svc->svc %></TD>
31 </TR>
32
33 <% include('/elements/tr-td-label.html',
34      'label'    => $part_svc->part_svc_column('username')->columnlabel || mt('Username'),
35      'required' => $part_svc->part_svc_column('username')->required ) %>
36 % if ( $svcnum && $conf->exists('svc_acct-no_edit_username') ) {
37     <TD BGCOLOR="#eeeeee"><% $svc_acct->username() %></TD>
38     <INPUT TYPE="hidden" NAME="username" VALUE="<% $username %>">
39 % } else {
40     <TD>
41       <INPUT TYPE="text" NAME="username" VALUE="<% $username %>" SIZE=<% $ulen2 %> MAXLENGTH=<% $ulen %>>
42     </TD>
43 % }
44 </TR>
45
46 %if ( $part_svc->part_svc_column('_password')->columnflag ne 'F' ) {
47 % #XXX eventually should require "Edit Password" ACL
48 <% include('/elements/tr-td-label.html',
49      'label'    => $part_svc->part_svc_column('_password')->columnlabel || mt('Password'),
50      'required' => $part_svc->part_svc_column('_password')->required ) %>
51   <TD>
52     <INPUT TYPE="text" ID="clear_password" NAME="clear_password" VALUE="<% $password %>" SIZE=<% $pmax2 %> MAXLENGTH=<% $pmax %>>
53     <& /elements/random_pass.html, 'clear_password' &><BR>
54     <DIV ID="clear_password_result" STYLE="font-size: smaller"></DIV>
55     <& '/elements/validate_password.html', 
56          'fieldid' => 'clear_password',
57          'svcnum' => $svcnum 
58     &>
59   </TD>
60 </TR>
61 %}else{
62     <INPUT TYPE="hidden" NAME="clear_password" VALUE="<% $password %>">
63 %}
64 <INPUT TYPE="hidden" NAME="_password_encoding" VALUE="<% $svc_acct->_password_encoding %>">
65 %
66 %my $sec_phrase = $svc_acct->sec_phrase;
67 %if ( $conf->exists('security_phrase') 
68 %  && $part_svc->part_svc_column('sec_phrase')->columnflag ne 'F' ) {
69
70 <% include('/elements/tr-td-label.html',
71      'label'    => $part_svc->part_svc_column('sec_phrase')->columnlabel || mt('Security phrase'),
72      'required' => $part_svc->part_svc_column('sec_phrase')->required ) %>
73     <TD>
74       <INPUT TYPE="text" NAME="sec_phrase" VALUE="<% $sec_phrase %>" SIZE=32>
75       (<% mt('for forgotten passwords') |h %>)
76     </TD>
77   </TD>
78 % } else { 
79
80   <INPUT TYPE="hidden" NAME="sec_phrase" VALUE="<% $sec_phrase %>">
81 % } 
82 %
83 %#domain
84 %my $domsvc = $svc_acct->domsvc || 0;
85 %if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'F' ) {
86 %
87
88   <INPUT TYPE="hidden" NAME="domsvc" VALUE="<% $domsvc %>">
89 % } else { 
90 %
91 %  my %svc_domain = ();
92 %
93 %  if ( $domsvc ) {
94 %    my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $domsvc, } );
95 %    if ( $svc_domain ) {
96 %      $svc_domain{$svc_domain->svcnum} = $svc_domain->domain;
97 %    } else {
98 %      warn "unknown svc_domain.svcnum for svc_acct.domsvc: $domsvc";
99 %    }
100 %  }
101 %
102 %  %svc_domain = (%svc_domain,
103 %                 domain_select_hash FS::svc_acct('svcpart' => $svcpart,
104 %                                                 'pkgnum'  => $pkgnum,
105 %                                                )
106 %                );
107
108 <% include('/elements/tr-td-label.html',
109      'label'    => $part_svc->part_svc_column('domsvc')->columnlabel || mt('Domain'),
110      'required' => $part_svc->part_svc_column('domsvc')->required ) %>
111     <TD>
112       <SELECT NAME="domsvc" SIZE=1>
113 % foreach my $svcnum (
114 %             sort { $svc_domain{$a} cmp $svc_domain{$b} }
115 %                  keys %svc_domain
116 %           ) {
117 %             my $svc_domain = $svc_domain{$svcnum};
118 %        
119
120              <OPTION VALUE="<% $svcnum %>" <% $svcnum == $domsvc ? ' SELECTED' : '' %>><% $svc_domain{$svcnum} %>
121 % } 
122
123       </SELECT>
124     </TD>
125   </TR>
126 % } 
127
128
129 % if ( $communigate ) {
130
131     <TR>
132       <TD ALIGN="right"><% mt('Aliases') |h %></TD>
133       <TD><INPUT TYPE="text" NAME="cgp_aliases" VALUE="<% $svc_acct->cgp_aliases %>"></TD>
134     </TR>
135
136 % } else {
137     <INPUT TYPE="hidden" NAME="cgp_aliases" VALUE="<% $svc_acct->cgp_aliases %>">
138 % }
139
140
141 <& /elements/tr-select-svc_pbx.html,
142              'curr_value' => $svc_acct->pbxsvc,
143              'part_svc'   => $part_svc,
144              'cust_pkg'   => $cust_pkg,
145              'label'      => $part_svc->part_svc_column('pbxsvc')->columnlabel || 'PBX',
146 &>
147
148 %#pop
149 %my $popnum = $svc_acct->popnum || 0;
150 %if ( $part_svc->part_svc_column('popnum')->columnflag eq 'F' ) {
151 %
152
153   <INPUT TYPE="hidden" NAME="popnum" VALUE="<% $popnum %>">
154 % } else { 
155
156 <% include('/elements/tr-td-label.html',
157      'label'    => $part_svc->part_svc_column('popnum')->columnlabel || mt('Access number'),
158      'required' => $part_svc->part_svc_column('popnum')->required ) %>
159     <TD><% FS::svc_acct_pop::popselector($popnum) %></TD>
160   </TR>
161 % } 
162
163 %#tower (huh)
164 %if ( $conf->exists('svc_acct-tower_sector')
165 %     && $part_svc->part_svc_column('sectornum')->columnflag ne 'F' ) {
166     <& /elements/tr-select-tower_sector.html,
167          'curr_value' => $svc_acct->sectornum,
168          #'part_svc'   => $part_svc,
169          #'cust_pkg'   => $cust_pkg,
170          'required'   => $part_svc->part_svc_column('sectornum')->required,
171          'label'       => $part_svc->part_svc_column('sectornum')->columnlabel || mt('Tower sector'),
172     &>
173 %} else {
174     <INPUT TYPE="hidden" NAME="sectornum" VALUE="<% $svc_acct->sectornum %>">
175 %}
176
177 <& /elements/tr-svc_export_machine.html,
178      'svc'      => $svc_acct,
179      'part_svc' => $part_svc,
180      'cgi'      => $cgi,
181 &>
182
183 % #uid/gid 
184 % foreach my $xid (qw( uid gid )) { 
185 %
186 %  if ( $part_svc->part_svc_column($xid)->columnflag =~ /^[FA]$/
187 %       || ! $conf->exists("svc_acct-edit_$xid")
188 %     ) {
189 %  
190 % if ( length($svc_acct->$xid()) ) { 
191
192 <% include('/elements/tr-td-label.html',
193      'label'    => $part_svc->part_svc_column($xid)->columnlabel || uc($xid),
194      'required' => $part_svc->part_svc_column($xid)->required ) %>
195 %#      <TR>
196 %#        <TD ALIGN="right"><% uc($xid) %></TD>
197           <TD BGCOLOR="#eeeeee"><% $svc_acct->$xid() %></TD>
198         <TD>
199         </TD>
200       </TR>
201 % } 
202   
203     <INPUT TYPE="hidden" NAME="<% $xid %>" VALUE="<% $svc_acct->$xid() %>">
204 % } else { 
205   
206 <% include('/elements/tr-td-label.html',
207      'label'    => $part_svc->part_svc_column($xid)->columnlabel || uc($xid),
208      'required' => $part_svc->part_svc_column($xid)->required ) %>
209       <TD>
210         <INPUT TYPE="text" NAME="<% $xid %>" SIZE=8 MAXLENGTH=6 VALUE="<% $svc_acct->$xid() %>">
211       </TD>
212     </TR>
213 % } 
214 % } 
215 %
216 %#finger
217 %if ( $part_svc->part_svc_column('uid')->columnflag eq 'F'
218 %     && ! $svc_acct->finger ) { 
219 %
220
221   <INPUT TYPE="hidden" NAME="finger" VALUE="">
222 % } else { 
223
224
225 <% include('/elements/tr-td-label.html',
226      'label'    => $part_svc->part_svc_column('finger')->columnlabel || mt('Real Name'),
227      'required' => $part_svc->part_svc_column('finger')->required ) %>
228     <TD>
229       <INPUT TYPE="text" NAME="finger" VALUE="<% $svc_acct->finger %>">
230     </TD>
231   </TR>
232 % } 
233 %
234 %#dir
235 %if ( $part_svc->part_svc_column('dir')->columnflag eq 'F'
236 %     || !$curuser->access_right('Edit home dir')
237 %   ) { 
238
239
240 <INPUT TYPE="hidden" NAME="dir" VALUE="<% $svc_acct->dir %>">
241 % } else {
242
243
244 <% include('/elements/tr-td-label.html',
245      'label'    => $part_svc->part_svc_column('dir')->columnlabel || mt('Home directory'),
246      'required' => $part_svc->part_svc_column('dir')->required ) %>
247     <TD><INPUT TYPE="text" NAME="dir" VALUE="<% $svc_acct->dir %>"></TD>
248   </TR>
249 % } 
250 %
251 %#shell
252 %my $shell = $svc_acct->shell;
253 %if ( $part_svc->part_svc_column('shell')->columnflag eq 'F'
254 %     || ( !$shell && $part_svc->part_svc_column('uid')->columnflag eq 'F' )
255 %   ) {
256 %
257
258   <INPUT TYPE="hidden" NAME="shell" VALUE="<% $shell %>">
259 % } else { 
260
261
262 <% include('/elements/tr-td-label.html',
263      'label'    => $part_svc->part_svc_column('shell')->columnlabel || mt('Shell'),
264      'required' => $part_svc->part_svc_column('shell')->required ) %>
265     <TD>
266       <SELECT NAME="shell" SIZE=1>
267 %
268 %           my($etc_shell);
269 %           foreach $etc_shell (@shells) {
270 %        
271
272           <OPTION<% $etc_shell eq $shell ? ' SELECTED' : '' %>><% $etc_shell %>
273 % } 
274
275
276       </SELECT>
277     </TD>
278   </TR>
279 % } 
280
281 <& svc_acct/communigate.html,
282              'svc_acct'    => $svc_acct,
283              'part_svc'    => $part_svc,
284              'communigate' => $communigate,
285 &>
286
287 % if ( $conf->exists('svc_acct-ip_addr') ) {
288 %   # router/block selection UI
289 %   # (should we show this if slipip is fixed?)
290 <& /elements/tr-select-router_block_ip.html, 
291   'object' => $svc_acct,
292   'ip_field' => 'slipip',
293   'required' => $part_svc->part_svc_column('routernum')->required,
294   'label'    => $part_svc->part_svc_column('routernum')->columnlabel,
295   'ip_addr_required' => $part_svc->part_svc_column('slipip')->required,
296   'ip_addr_label' => $part_svc->part_svc_column('slipip')->columnlabel,
297 &>
298 % } else {
299 %   # don't expose these to the user--they're only useful in the other case
300   <INPUT TYPE="hidden" NAME="routernum" VALUE="<% $svc_acct->routernum %>">
301   <INPUT TYPE="hidden" NAME="blocknum"  VALUE="<% $svc_acct->blocknum  %>">
302 %   if ( $part_svc->part_svc_column('slipip')->columnflag =~ /^[FA]$/ ) { 
303     <INPUT TYPE="hidden" NAME="slipip" VALUE="<% $svc_acct->slipip %>">
304 %   } else { 
305 <% include('/elements/tr-td-label.html',
306      'label'    => $part_svc->part_svc_column('slipip')->columnlabel || mt('IP'),
307      'required' => $part_svc->part_svc_column('slipip')->required ) %>
308       <TD><INPUT TYPE="text" NAME="slipip" VALUE="<% $svc_acct->slipip %>"></TD>
309     </TR>
310 %   }
311 % }
312
313 % my %label = ( seconds => 'Time',
314 %               upbytes => 'Upload bytes',
315 %               downbytes => 'Download bytes',
316 %               totalbytes => 'Total bytes',
317 %             );
318 % foreach my $uf (keys %label) {
319 %   my $tf = $uf . "_threshold";
320 %   if ( $curuser->access_right('Edit usage') ) { 
321   <TR>
322     <TD ALIGN="right"><% mt("[_1] remaining",$label{$uf}) |h %> </TD>
323     <TD><INPUT TYPE="text" NAME="<% $uf %>" VALUE="<% $svc_acct->$uf %>">(<% mt('blank disables') |h %>)</TD>
324   </TR>
325   <TR>
326     <TD ALIGN="right"><% mt("[_1] threshold",$label{$uf}) |h %> </TD>
327     <TD><INPUT TYPE="text" NAME="<% $tf %>" VALUE="<% $svc_acct->$tf %>">(<% mt('blank disables') |h %>)</TD>
328   </TR>
329 %   }else{
330       <INPUT TYPE="hidden" NAME="<% $uf %>" VALUE="<% $svc_acct->$uf %>">
331       <INPUT TYPE="hidden" NAME="<% $tf %>" VALUE="<% $svc_acct->$tf %>">
332 %   } 
333 % }
334 %
335 %foreach my $r ( grep { /^r(adius|[cr])_/ } fields('svc_acct') ) {
336 %  $r =~ /^^r(adius|[cr])_(.+)$/ or next; #?
337 %  my $a = $2;
338 %
339 % if ( $part_svc->part_svc_column($r)->columnflag =~ /^[FA]$/ ) { 
340
341     <INPUT TYPE="hidden" NAME="<% $r %>" VALUE="<% $svc_acct->getfield($r) %>">
342 % } else { 
343
344     <TR>
345       <TD ALIGN="right"><% $FS::raddb::attrib{$a} %></TD>
346       <TD><INPUT TYPE="text" NAME="<% $r %>" VALUE="<% $svc_acct->getfield($r) %>"></TD>
347     </TR>
348 % } 
349 % } 
350
351
352 <% include('/elements/tr-td-label.html',
353      'label'    => $part_svc->part_svc_column('usergroup')->columnlabel || mt('RADIUS groups'),
354      'required' => $part_svc->part_svc_column('usergroup')->required ) %>
355 % if ( $part_svc_usergroup->columnflag eq 'F' ) { 
356     <TD BGCOLOR="#eeeeee"><% join('<BR>', @groupnames) %></TD>
357 % } else { 
358 %   my $radius_group_selected = '';
359 %   if ( $svc_acct->svcnum ) {
360 %      $radius_group_selected = join(',',$svc_acct->radius_groups('groupnum'));
361 %   }
362 %   elsif ( !$svc_acct->svcnum && $part_svc_usergroup->columnflag eq 'D' ) {
363 %       $radius_group_selected = $part_svc_usergroup->columnvalue;
364 %   }
365     <TD><& /elements/select-radius_group.html, 
366                 curr_value => $radius_group_selected,
367                 element_name => 'radius_usergroup',
368                 multiple => 1,
369         &>
370     </TD>
371 % } 
372
373 </TR>
374
375 % if ( $part_svc->has_router ) {
376 <& /elements/hidden.html,
377     field => 'router_routernum',
378     curr_value => $svc_acct->router_routernum
379 &>
380 <& /elements/tr-input-text.html,
381     label => 'Attached router name',
382     field => 'router_routername',
383     size  => 32,
384     curr_value => $svc_acct->router_routername
385 &>
386 <& /elements/tr-select-table.html,
387     label         => 'Attached address block',
388     field         => 'router_blocknum',
389     table         => 'addr_block',
390     hashref       => { 'routernum' => '0' },
391     extra_sql     => ($svc_acct->router_routernum ?
392                         ' OR routernum = '.$svc_acct->router_routernum : ''),
393     agent_virt    => 1,
394     agent_null    => 1,
395     name_col      => 'cidr',
396     order_by      => 'ORDER BY ip_gateway, ip_netmask',
397     empty_label   => '(none)',
398     disable_empty => 0,
399     curr_value    => $svc_acct->router_blocknum
400 &>
401 % }
402
403 % foreach my $field ($svc_acct->virtual_fields) { 
404 % # If the flag is X, it won't even show up in $svc_acct->virtual_fields. 
405 % if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) { 
406
407     <% $svc_acct->pvf($field)->widget('HTML', 'edit', $svc_acct->getfield($field)) %>
408 % } 
409 % } 
410   
411 </TABLE>
412 <BR>
413
414 % if ( $captcha_url ) {
415 <IMG SRC="<% $captcha_url %>"><BR>
416 <% mt('Enter the word shown above:') |h %> <INPUT TYPE="text" NAME="captcha_response"><BR>
417 <BR>
418 % }
419
420 <INPUT TYPE="submit" VALUE="Submit">
421
422 </FORM>
423
424 <& /elements/footer.html &>
425
426 <%init>
427
428 die "access denied"
429   unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
430
431 my $conf = new FS::Conf;
432 my @shells = $conf->config('shells');
433
434 my $curuser = $FS::CurrentUser::CurrentUser;
435
436 my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_acct, @groups);
437 if ( $cgi->param('error') ) {
438
439   $svc_acct = new FS::svc_acct ( {
440     map { $_, scalar($cgi->param($_)) } fields('svc_acct')
441   } );
442   $svcnum = $svc_acct->svcnum;
443   $pkgnum = $cgi->param('pkgnum');
444   $svcpart = $cgi->param('svcpart');
445   $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
446   die "No part_svc entry for svcpart $svcpart!" unless $part_svc;
447   @groups = $cgi->param('radius_usergroup');
448
449 } elsif ( $cgi->param('pkgnum') && $cgi->param('svcpart') ) { #adding
450
451   $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum';
452   $pkgnum = $1;
453   $cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart';
454   $svcpart = $1;
455
456   $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
457   die "No part_svc entry!" unless $part_svc;
458
459   $svc_acct = new FS::svc_acct({svcpart => $svcpart}); 
460
461   $svcnum='';
462
463   $svc_acct->password_recover('Y'); #default. hmm.
464
465 } else { #editing
466
467   my($query) = $cgi->keywords;
468   $query =~ /^(\d+)$/ or die "unparsable svcnum";
469   $svcnum=$1;
470   $svc_acct=qsearchs('svc_acct',{'svcnum'=>$svcnum})
471     or die "Unknown (svc_acct) svcnum!";
472
473   my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
474     or die "Unknown (cust_svc) svcnum!";
475
476   $pkgnum=$cust_svc->pkgnum;
477   $svcpart=$cust_svc->svcpart;
478
479   $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
480   die "No part_svc entry for svcpart $svcpart!" unless $part_svc;
481
482   @groups = $svc_acct->radius_groups;
483
484 }
485
486 my $communigate = scalar($part_svc->part_export('communigate_pro'));
487                 # || scalar($part_svc->part_export('communigate_pro_singledomain'));
488
489 my( $cust_pkg, $cust_main ) = ( '', '' );
490 if ( $pkgnum ) {
491   $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum } );
492   $cust_main = $cust_pkg->cust_main;
493 }
494
495 unless ( $svcnum || $cgi->param('error') ) { #adding
496
497   #set gecos
498   if ($cust_main) {
499     unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) {
500       $svc_acct->setfield('finger',
501         $cust_main->getfield('first') . " " . $cust_main->getfield('last')
502       );
503     }
504   }
505
506   $svc_acct->set_default_and_fixed( {
507     #false laziness w/svc-acct::_fieldhandlers
508     'usergroup' => sub { 
509                          my( $self, $groups ) = @_;
510                          if ( ref($groups) eq 'ARRAY' ) {
511                            @groups = @$groups;
512                            $groups;
513                          } elsif ( length($groups) ) {
514                            @groups = split(/\s*,\s*/, $groups);
515                            [ @groups ];
516                          } else {
517                            @groups = ();
518                            [];
519                          }
520                        }
521   } );
522
523 }
524
525 my $part_svc_usergroup = $part_svc->part_svc_column('usergroup');
526 #fixed radius groups always override & display
527 my @groupnames; # only used for display of Fixed RADIUS groups
528 if ( $part_svc_usergroup->columnflag eq 'F' ) {
529   @groups = split(',',$part_svc_usergroup->columnvalue);
530   @groupnames = map { $_->long_description } 
531                     qsearch({ 'table'         => 'radius_group',
532                            'extra_sql'     => "where groupnum in (".$part_svc_usergroup->columnvalue.")",
533                         }) if length($part_svc_usergroup->columnvalue);
534 }
535
536 my $action = $svcnum ? 'Edit' : 'Add';
537
538 my $svc = $part_svc->getfield('svc');
539
540 my $username = $svc_acct->username;
541
542 my $password = '';
543 if ( $cgi->param('error') ) {
544   $password = $cgi->param('clear_password');
545 } elsif ( $svcnum ) {
546   my $password_encryption = $svc_acct->_password_encryption;
547   if ( $password = $svc_acct->get_cleartext_password ) {
548     $password = '*HIDDEN*' unless $conf->exists('showpasswords');
549   } elsif( $svc_acct->_password and $password_encryption ne 'plain' ) {
550     $password = "(".uc($password_encryption)." encrypted)";
551   }
552 }
553
554 my $ulen = 
555   $conf->exists('usernamemax')
556   ? $conf->config('usernamemax')
557   : dbdef->table('svc_acct')->column('username')->length;
558 my $ulen2 = $ulen+2;
559
560 my $pmax = max($conf->config('passwordmax') || 12);
561 my $pmax2 = $pmax+2;
562
563 my $p1 = popurl(1);
564
565 sub max {
566   (sort(@_))[-1]
567 }
568
569 my $captcha_url;
570 my ($export_google) = $part_svc->part_export('acct_google');
571 if ( $export_google ) {
572   my $error = $export_google->auth_error;
573   if ( $error ) {
574     if ( $error->{'captcha_url'} ) {
575       $captcha_url = $error->{'captcha_url'};
576     }
577     else {
578       $cgi->param('error', $error->{'message'});
579     }
580   } #if $error
581 }
582
583 if ( $part_svc->has_router ) { # duplicates the one in elements/svc_Common
584   if ( $svcnum ) {
585     my $router = qsearchs('router', {svcnum => $svc_acct->svcnum});
586     if ( $router ) {
587       $svc_acct->set("router_$_", $router->get($_))
588         foreach ('routername', 'routernum');
589       my ($block) = $router->addr_block;
590       $svc_acct->set('router_blocknum', $block->blocknum) if ( $block );
591     }
592   }
593   foreach (qw(router_routername router_routernum router_blocknum)) {
594     if ( $cgi->param($_) =~ /^(\w+)$/ ) {
595       $svc_acct->set($_, $1);
596     }
597   }
598 }
599
600 </%init>