X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Felements%2Fsvc_Common.html;h=ca336a1261c9700d533315f065f859b9ba748217;hb=10614457fd7db63cbcc0bf9bfeebbbb99258eaa3;hp=5a8afbd6ca61604cbce1e57a86a178e9b4ff5814;hpb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924;p=freeside.git

diff --git a/httemplate/edit/process/elements/svc_Common.html b/httemplate/edit/process/elements/svc_Common.html
index 5a8afbd6c..ca336a126 100644
--- a/httemplate/edit/process/elements/svc_Common.html
+++ b/httemplate/edit/process/elements/svc_Common.html
@@ -1,6 +1,7 @@
 <% include( 'process.html',
                  'edit_ext' => 'cgi',
                  'redirect' => popurl(3)."view/$table.cgi?",
+                 'args_callback' => $args_callback,
                  %opt,
            )
 %>
@@ -10,5 +11,31 @@ my %opt = @_;
 my $table = $opt{'table'};
 $opt{'fields'} ||= [ fields($table) ];
 push @{ $opt{'fields'} }, qw( pkgnum svcpart );
+push @{ $opt{'fields'} }, @{ "FS::$table"->table_info->{'addl_process_fields'} }
+  if UNIVERSAL::can("FS::$table", 'table_info')
+  && "FS::$table"->table_info->{'addl_process_fields'};
+foreach (fields($table)) {
+  if ( $cgi->param($_.'_classnum') ) {
+    push @{ $opt{'fields'} }, $_.'_classnum';
+  }
+}
+
+my $args_callback = sub {
+  my ($cgi, $svc) = @_;
+  my $part_svc = FS::part_svc->by_key($cgi->param('svcpart'))
+    or die "svcpart required";
+  if ( $part_svc->has_router ) {
+    my $router = FS::router->new({
+      map { $_ => $cgi->param("router_$_") }
+      qw( routernum routername blocknum )
+    });
+   if ($router->blocknum and length($router->routername) == 0) {
+      #sensible default
+      $router->set('routername', $svc->label);
+    }
+    return (child_objects => [ $router ]);
+  }
+  ();
+};
 
 </%init>