X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=httemplate%2Felements%2Ftr-select-router_block_ip.html;h=95d1787b85565d39ed3f79b356f1fc37610bb3c4;hb=5bb3332639ffadd71b00ad41fd2a7cbb038092ab;hp=e6b7bfe7e12a3ecbeee4f137019ea091ddc041d6;hpb=759a410ce131e9c26213a40ca77de2386d414108;p=freeside.git
diff --git a/httemplate/elements/tr-select-router_block_ip.html b/httemplate/elements/tr-select-router_block_ip.html
index e6b7bfe7e..95d1787b8 100644
--- a/httemplate/elements/tr-select-router_block_ip.html
+++ b/httemplate/elements/tr-select-router_block_ip.html
@@ -1,14 +1,33 @@
<& /elements/tr-td-label.html, label => ($opt{'label'} || 'Router') &>
@@ -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,6 +50,7 @@ function hide_if_auto_addr(obj, i) {
name_col => 'cidr',
link_col => 'routernum',
empty_label => '(any)',
+ onchange => 'update_ip_addr',
curr_value => $opt{'blocknum'},
},
]
@@ -44,26 +64,27 @@ function hide_if_auto_addr(obj, i) {
% }
% else {
+ value="<% $opt{'ip_addr'} |h%>" onfocus="clearhint_ip_addr(this)">
% }
- <% $opt{'ip_addr'} || '' %>
- (automatic)
<%init>
+
my %opt = @_;
my @routers;
+my $conf = FS::Conf->new;
my $svc_x = $opt{'object'};
if ( $svc_x ) {
$opt{$_} = $svc_x->$_
foreach qw(routernum blocknum ip_addr svcpart);
+ if ( $svc_x->svcnum ) {
+ $opt{'svcpart'} = $svc_x->cust_svc->svcpart;
+ }
}
-warn Dumper(\%opt);
-
my $svcpart = $opt{'svcpart'} || '';
my %fixed; # which fields are fixed
$svcpart =~ /^\d*$/ or die "invalid svcpart '$svcpart'";
@@ -90,5 +111,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';
+}
+
%init>