X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=httemplate%2Felements%2Ftr-select-router_block_ip.html;h=2aa715e29c605968cfb63eed5114900ea6102c5d;hb=3fc0a546caf38b444b63744726c5080ce5d9bbbb;hp=e6b7bfe7e12a3ecbeee4f137019ea091ddc041d6;hpb=eb9d1063e1203231ee0c6922ea5638370f7b5ece;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..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,40 +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;
+ }
}
-warn Dumper(\%opt);
-
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 ) {
@@ -72,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 {
@@ -90,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';
+}
+
%init>