diff options
author | Mark Wells <mark@freeside.biz> | 2012-10-30 12:16:17 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2012-10-30 12:16:17 -0700 |
commit | 87f255507af9f14dfbccd37eefd71a148f9af344 (patch) | |
tree | 7467e87ff6a27cdbe67fa60f4261e2d07a61f4b7 /httemplate | |
parent | d77fe06b27410a41855e1425114ab8d9cdae4ff0 (diff) |
IP address management for svc_acct, #19567
Diffstat (limited to 'httemplate')
-rwxr-xr-x | httemplate/edit/process/svc_acct.cgi | 5 | ||||
-rwxr-xr-x | httemplate/edit/router.cgi | 10 | ||||
-rwxr-xr-x | httemplate/edit/svc_acct.cgi | 28 | ||||
-rw-r--r-- | httemplate/elements/tr-select-router_block_ip.html | 14 | ||||
-rw-r--r-- | httemplate/view/svc_acct/basics.html | 26 |
5 files changed, 63 insertions, 20 deletions
diff --git a/httemplate/edit/process/svc_acct.cgi b/httemplate/edit/process/svc_acct.cgi index 41aca65ee..d4bcd35ed 100755 --- a/httemplate/edit/process/svc_acct.cgi +++ b/httemplate/edit/process/svc_acct.cgi @@ -31,6 +31,11 @@ foreach (map { $_,$_."_threshold" } qw( upbytes downbytes totalbytes )) { $cgi->param($_, FS::UI::bytecount::parse_bytecount($cgi->param($_)) ); } +#for slipip, convert '(automatic)' to null +my $ip_addr = $cgi->param('slipip'); +$ip_addr =~ s/[^\d\.]//g; +$cgi->param('slipip', $ip_addr); + #unmunge cgp_accessmodes (falze laziness-ish w/part_svc.pm::process &svc_domain) unless ( $cgi->param('cgp_accessmodes') ) { $cgi->param('cgp_accessmodes', diff --git a/httemplate/edit/router.cgi b/httemplate/edit/router.cgi index fdcd7b3b3..0df9b457e 100755 --- a/httemplate/edit/router.cgi +++ b/httemplate/edit/router.cgi @@ -29,8 +29,15 @@ die "access denied" unless $curuser->access_right('Broadband configuration') || $curuser->access_right('Broadband global configuration'); +my @svc_x = 'svc_broadband'; +if ( FS::Conf->new->exists('svc_acct-ip_addr') ) { + push @svc_x, 'svc_acct'; +} + my $callback = sub { my ($cgi, $object, $fields) = (shift, shift, shift); + + my $extra_sql = ' AND svcdb IN(' . join(',', map { "'$_'" } @svc_x) . ')'; unless ($object->svcnum) { push @{$fields}, { 'type' => 'tablebreak-tr-title', @@ -41,7 +48,8 @@ my $callback = sub { 'target_table' => 'part_svc', 'link_table' => 'part_svc_router', 'name_col' => 'svc', - 'hashref' => { 'svcdb' => 'svc_broadband', 'disabled' => '' }, + 'hashref' => { 'disabled' => '' }, + 'extra_sql' => $extra_sql, }; } }; diff --git a/httemplate/edit/svc_acct.cgi b/httemplate/edit/svc_acct.cgi index 142c11150..c1f74551d 100755 --- a/httemplate/edit/svc_acct.cgi +++ b/httemplate/edit/svc_acct.cgi @@ -276,14 +276,26 @@ function randomPass() { 'communigate' => $communigate, &> -% if ( $part_svc->part_svc_column('slipip')->columnflag =~ /^[FA]$/ ) { - <INPUT TYPE="hidden" NAME="slipip" VALUE="<% $svc_acct->slipip %>"> -% } else { - <TR> - <TD ALIGN="right"><% mt('IP') |h %></TD> - <TD><INPUT TYPE="text" NAME="slipip" VALUE="<% $svc_acct->slipip %>"></TD> - </TR> -% } +% if ( $conf->exists('svc_acct-ip_addr') ) { +% # router/block selection UI +% # (should we show this if slipip is fixed?) +<& /elements/tr-select-router_block_ip.html, + 'object' => $svc_acct, + 'ip_field' => 'slipip' +&> +% } else { +% # don't expose these to the user--they're only useful in the other case + <INPUT TYPE="hidden" NAME="routernum" VALUE="<% $svc_acct->routernum %>"> + <INPUT TYPE="hidden" NAME="blocknum" VALUE="<% $svc_acct->blocknum %>"> +% if ( $part_svc->part_svc_column('slipip')->columnflag =~ /^[FA]$/ ) { + <INPUT TYPE="hidden" NAME="slipip" VALUE="<% $svc_acct->slipip %>"> +% } else { + <TR> + <TD ALIGN="right"><% mt('IP') |h %></TD> + <TD><INPUT TYPE="text" NAME="slipip" VALUE="<% $svc_acct->slipip %>"></TD> + </TR> +% } +% } % my %label = ( seconds => 'Time', % upbytes => 'Upload bytes', diff --git a/httemplate/elements/tr-select-router_block_ip.html b/httemplate/elements/tr-select-router_block_ip.html index 95d1787b8..11f7c4831 100644 --- a/httemplate/elements/tr-select-router_block_ip.html +++ b/httemplate/elements/tr-select-router_block_ip.html @@ -58,12 +58,13 @@ function clearhint_ip_addr (what) { </td></tr> <& /elements/tr-td-label.html, label => 'IP address' &> <td> -% if ( $fixed{'ip_addr'} ) { - <input type="hidden" id="input_ip_addr" name="ip_addr" +% warn Dumper \%fixed; +% if ( exists $fixed{$ip_field} ) { + <input type="hidden" id="input_ip_addr" name="<% $ip_field %>" value="<% $opt{'ip_addr'} |h%>"><% $opt{'ip_addr'} || '' %> % } % else { - <input type="text" id="input_ip_addr" name="ip_addr" + <input type="text" id="input_ip_addr" name="<% $ip_field %>" value="<% $opt{'ip_addr'} |h%>" onfocus="clearhint_ip_addr(this)"> % } </td> </tr> @@ -78,6 +79,7 @@ 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 ) { @@ -86,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 ) { @@ -93,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 { diff --git a/httemplate/view/svc_acct/basics.html b/httemplate/view/svc_acct/basics.html index 1cdf77615..2d9953fcc 100644 --- a/httemplate/view/svc_acct/basics.html +++ b/httemplate/view/svc_acct/basics.html @@ -91,15 +91,29 @@ % } +<%perl> +# minor false laziness w/ view/svc_broadband.cgi +sub slipip { + my $svc_acct = shift; + my $out = $svc_acct->slipip or return ''; + if ( $out eq '0.0.0.0' or $out eq '0e0' ) { + return '<I>('.mt('Dynamic').'</I>'; + } + $out .= ' ('. + include('/elements/popup_link-ping.html', ip => $svc_acct->slipip). + ')'; + if ( my $addr_block = $svc_acct->addr_block ) { + $out .= '<br>Netmask: ' . $addr_block->NetAddr->mask . + '<br>Gateway: ' . $addr_block->ip_gateway; + } + $out; +} +</%perl> + % if ($svc_acct->slipip) { <& /view/elements/tr.html, label=>mt('IP address'), - value=> ( $svc_acct->slipip eq "0.0.0.0" || $svc_acct->slipip eq '0e0' ) - ? "<I>(".mt('Dynamic').")</I>" - : $svc_acct->slipip. ' '. - include('/elements/popup_link-ping.html', - 'ip'=>$svc_acct->slipip, - ) + value=> slipip($svc_acct) &> % } |