+<%once>
+
+sub label_fixup {
+ my( $part_svc, $opt ) = @_;
+
+ $opt->{'name'} ||= $part_svc->svc;
+
+ my $svcdb = $part_svc->svcdb;
+ require "FS/$svcdb.pm";
+
+ if ( UNIVERSAL::can("FS::$svcdb", 'table_info') ) {
+ #$opt->{'name'} ||= "FS::$svcdb"->table_info->{'name'};
+
+ my $fields = "FS::$svcdb"->table_info->{'fields'};
+ $opt->{'fields'} ||= [ grep { $_ ne 'svcnum' } keys %$fields ];
+
+ $opt->{labels} ||= {
+ map { $_ => ( ref($fields->{$_})
+ ? $fields->{$_}{'label'}
+ : $fields->{$_}
+ );
+ }
+ keys %$fields
+ };
+ }
+
+ #false laziness w/view/svc_Common.html
+ #override default labels with service-definition labels if applicable
+ my $labels = $opt->{labels}; # with -> here
+ foreach my $field ( keys %{ $opt->{labels} } ) {
+ my $col = $part_svc->part_svc_column($field);
+ $labels->{$field} = $col->columnlabel if $col->columnlabel !~ /^\s*$/;
+ }
+
+ if ( $part_svc->has_router ) {
+ # these will be set up as pseudo-fields in the new_ and edit_ callbacks
+ push @{ $opt->{'fields'} }, (
+ { field => 'router_routernum', type => 'hidden' },
+ { field => 'router_routername', type => 'text', size => 32 },
+ # router address block selection
+ # (one-to-one for now)
+ { field => 'router_blocknum',
+ type => 'select-table',
+ table => 'addr_block',
+ hashref => { 'routernum' => '0' },
+ agent_virt => 1,
+ agent_null => 1,
+ name_col => 'cidr',
+ order_by => 'ORDER BY ip_gateway, ip_netmask',
+ empty_label => '(none)',
+ disable_empty => 0,
+ },
+ );
+ $labels->{router_routername} = 'Attached router name';
+ $labels->{router_blocknum} = 'Attached address block';
+ }
+}
+
+</%once>
+<%init>
+
+my %opt = @_;
+
+#my( $svcnum, $pkgnum, $svcpart, $part_svc );
+my( $pkgnum, $svcpart, $part_svc );
+
+#get & untaint pkgnum & svcpart
+if ( ! $cgi->param('error')
+ && $cgi->param('pkgnum') && $cgi->param('svcpart')
+ )
+{
+ $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum';
+ $pkgnum = $1;
+ $cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart';
+ $svcpart = $1;
+ #$cgi->delete_all(); #so edit.html treats this correctly as new??
+}
+
+</%init>