RT# 78356 keys on hashref deprecated in perl 5.24
[freeside.git] / httemplate / edit / process / elements / svc_Common.html
1 <% include( 'process.html',
2                  'edit_ext' => 'cgi',
3                  'redirect' => popurl(3)."view/$table.cgi?",
4                  'args_callback' => $args_callback,
5                  %opt,
6            )
7 %>
8 <%init>
9
10 my %opt = @_;
11 my $table = $opt{'table'};
12 $opt{'fields'} ||= [ fields($table) ];
13 push @{ $opt{'fields'} }, qw( pkgnum svcpart );
14 push @{ $opt{'fields'} }, @{ "FS::$table"->table_info->{'addl_process_fields'} }
15   if UNIVERSAL::can("FS::$table", 'table_info')
16   && "FS::$table"->table_info->{'addl_process_fields'};
17 foreach (fields($table)) {
18   if ( $cgi->param($_.'_classnum') ) {
19     push @{ $opt{'fields'} }, $_.'_classnum';
20   }
21 }
22
23 my $args_callback = sub {
24   my ($cgi, $svc) = @_;
25   my $part_svc = FS::part_svc->by_key($cgi->param('svcpart'))
26     or die "svcpart required";
27   if ( $part_svc->has_router ) {
28     my $router = FS::router->new({
29       map { $_ => scalar($cgi->param("router_$_")) }
30       qw( routernum routername blocknum )
31     });
32    if ($router->blocknum and length($router->routername) == 0) {
33       #sensible default
34       $router->set('routername', $svc->label);
35     }
36     return (child_objects => [ $router ]);
37   }
38   ();
39 };
40
41 </%init>