X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Felements%2Ftr-select-router_block_ip.html;h=2aa715e29c605968cfb63eed5114900ea6102c5d;hp=a4ce6644bb7223136340b5d524a63b0bbe951fc5;hb=ff27c3f36240aee48ed50153dd5d8fe3ac3f2443;hpb=a8f686dd5c3b0ad85a5cdd1785081be9db552fb7 diff --git a/httemplate/elements/tr-select-router_block_ip.html b/httemplate/elements/tr-select-router_block_ip.html index a4ce6644b..2aa715e29 100644 --- a/httemplate/elements/tr-select-router_block_ip.html +++ b/httemplate/elements/tr-select-router_block_ip.html @@ -1,17 +1,36 @@ -<& /elements/tr-td-label.html, label => ($opt{'label'} || 'Router') &> +<& /elements/tr-td-label.html, label => ($opt{'label'} || 'Router'), required => $opt{'required'} &> <& /elements/select-tiered.html, prefix => 'router_', tiers => [ { @@ -19,7 +38,7 @@ function hide_if_auto_addr(obj, i) { records => \@routers, name_col => 'routername', value_col => 'routernum', - onchange => 'hide_if_auto_addr', + onchange => 'update_ip_addr', curr_value=> $opt{'routernum'}, }, { @@ -31,38 +50,46 @@ function hide_if_auto_addr(obj, i) { name_col => 'cidr', link_col => 'routernum', empty_label => '(any)', + onchange => 'update_ip_addr', curr_value => $opt{'blocknum'}, }, ] &> -<& /elements/tr-td-label.html, label => 'IP address' &> +<& /elements/tr-td-label.html, label => ($opt{'ip_addr_label'} || 'IP address'), required => $opt{'ip_addr_required'} &> -% if ( $fixed{'ip_addr'} ) { - <% $opt{'ip_addr'} || '' %> % } % else { - + % } - <% $opt{'ip_addr'} || '' %> - (automatic) <%init> + my %opt = @_; my @routers; +my $conf = FS::Conf->new; my $svc_x = $opt{'object'}; if ( $svc_x ) { + # $svc_x->ip_addr does work, even for non-svc_broadband. $opt{$_} = $svc_x->$_ foreach qw(routernum blocknum ip_addr svcpart); + if ( $svc_x->svcnum ) { + $opt{'svcpart'} = $svc_x->cust_svc->svcpart; + } } my $svcpart = $opt{'svcpart'} || ''; +my $ip_field = $opt{'ip_field'} || 'ip_addr'; + my %fixed; # which fields are fixed $svcpart =~ /^\d*$/ or die "invalid svcpart '$svcpart'"; if ( $svcpart ) { @@ -70,13 +97,13 @@ if ( $svcpart ) { # Traditionally, columnflag 'F' on IP address means that it MUST # be auto-assigned (or, if null IP addresses are allowed, that # it must be null). - foreach (qw(routernum blocknum ip_addr)) { + foreach (qw(routernum blocknum), $ip_field) { my $psc = $part_svc->part_svc_column($_); if ( $psc and $psc->columnflag eq 'F' ) { $fixed{$_} = $psc->columnvalue; } } - if ( $fixed{'routernum'} ) { + if ( exists $fixed{'routernum'} ) { @routers = (FS::router->by_key($fixed{'routernum'})) } else { @@ -88,5 +115,17 @@ else { @routers = qsearch('router', {}); } -my %auto_addr_routernum = map { $_->routernum, $_->auto_addr } @routers; +my %manual_addr_routernum = map { $_->routernum, $_->manual_addr } @routers; + +if ( $conf->exists('auto_router') ) { + # Then show an "(automatic)" router, with no blocks. manual_addr is on + # so that the ip_addr field will be unlocked. + unshift @routers, FS::router->new({ + 'routernum' => '', + 'routername' => '(automatic)', + 'manual_addr' => 'Y', + }); + $manual_addr_routernum{''} = 'Y'; +} +