X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Felements%2Ftr-select-router_block_ip.html;h=2aa715e29c605968cfb63eed5114900ea6102c5d;hb=4d77cd40a01ff3526aa92adccca89d305f232eea;hp=45d1dacd873451798882ba2f67e6e0b8d2698a04;hpb=d64984bbfe839fbe71830862a6841380425f3dbe;p=freeside.git
diff --git a/httemplate/elements/tr-select-router_block_ip.html b/httemplate/elements/tr-select-router_block_ip.html
index 45d1dacd8..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,33 +50,36 @@ 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 ) {
@@ -66,6 +88,8 @@ if ( $svc_x ) {
}
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 ) {
@@ -73,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 {
@@ -91,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>