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