summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/edit/elements/edit.html2
-rw-r--r--httemplate/edit/elements/part_svc_column.html13
-rw-r--r--httemplate/edit/elements/svc_Common.html58
-rw-r--r--httemplate/edit/process/elements/svc_Common.html19
-rwxr-xr-xhttemplate/edit/process/svc_acct.cgi19
-rwxr-xr-xhttemplate/edit/svc_acct.cgi46
-rw-r--r--httemplate/view/elements/svc_Common.html14
-rw-r--r--httemplate/view/svc_acct/basics.html2
8 files changed, 162 insertions, 11 deletions
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index ed677d7ab..3270f0443 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -322,7 +322,7 @@ Example:
% $include_common{$_} = $f->{$_} foreach grep exists($f->{$_}),
% qw( js_only html_only select_only layers_only cell_style ),#selectlayers,?
% qw( empty_label ), # select-*
-% qw( value_col compare_sub ), # select-table
+% qw( value_col compare_sub order_by ), # select-table
% qw( table name_col ), #(select,checkboxes)-table
% qw( target_table link_table ), #checkboxes-table
% qw( hashref agent_virt agent_null agent_null_right ),#*-table
diff --git a/httemplate/edit/elements/part_svc_column.html b/httemplate/edit/elements/part_svc_column.html
index 1c5b45314..aa3c647b8 100644
--- a/httemplate/edit/elements/part_svc_column.html
+++ b/httemplate/edit/elements/part_svc_column.html
@@ -248,6 +248,19 @@ that field.
</TD>
</TR>
% }
+% # special case: services with attached routers (false laziness...)
+% if ( $svcdb eq 'svc_acct' or $svcdb eq 'svc_broadband' or $svcdb eq 'svc_dsl' ) {
+% push @fields, 'has_router';
+ <TR>
+ <TD COLSPAN=3 ALIGN="right">
+ <% emt('This service has an attached router') %>
+ </TD>
+ <TD>
+ <INPUT TYPE="checkbox" NAME="has_router" VALUE="Y" \
+ <% $part_svc->has_router ? 'CHECKED' : '' %>>
+ </TD>
+ </TR>
+% }
</TABLE>
<& /elements/progress-init.html,
$svcdb, #form name
diff --git a/httemplate/edit/elements/svc_Common.html b/httemplate/edit/elements/svc_Common.html
index d46d1cb42..321c68545 100644
--- a/httemplate/edit/elements/svc_Common.html
+++ b/httemplate/edit/elements/svc_Common.html
@@ -21,6 +21,7 @@
: ''; #?
&{ $cb }( $cgi,$svc_x, $part_svc,$cust_pkg, $fields,$opt);
}
+
},
'edit_callback' => sub {
@@ -43,6 +44,27 @@
: ''; #?
&{ $cb }( $cgi,$svc_x, $part_svc,$cust_pkg, $fields,$opt);
}
+
+ if ( $part_svc->has_router ) {
+ my $router = qsearchs('router', {svcnum => $svc_x->svcnum});
+ if ( $router ) {
+ $svc_x->set("router_$_", $router->get($_))
+ foreach ('routername', 'routernum');
+ my ($block) = $router->addr_block; # one-to-one for now
+ if ( $block ) {
+ $svc_x->set('router_blocknum', $block->blocknum);
+ # silly, but necessary...make the currently
+ # assigned block appear on the list
+ my ($field) = grep {ref($_) and
+ $_->{field} eq 'router_blocknum'}
+ @$fields;
+ $field->{extra_sql} =
+ ' OR routernum = '.$router->routernum;
+ $field->{curr_value} = $block->blocknum;
+ }
+ }
+ }
+
},
'new_hashref_callback' => sub {
@@ -72,7 +94,6 @@
}
$svc_x->set_default_and_fixed;
-
},
'field_callback' => sub {
@@ -125,20 +146,21 @@
},
'html_init' => sub {
+ my $html;
my $cust_main;
if ( $pkgnum ) {
my $cust_pkg = qsearchs('cust_pkg', {'pkgnum' => $pkgnum});
$cust_main = $cust_pkg->cust_main if $cust_pkg;
- }
- $cust_main
- ? include( '/elements/small_custview.html',
+ if ( $cust_main ) {
+ $html = include( '/elements/small_custview.html',
$cust_main,
'',
1,
popurl(2). "view/cust_main.cgi"
- ). '<BR>'
- : '';
-
+ ). '<BR>';
+ }
+ }
+ $html;
},
'html_table_bottom' => sub {
@@ -200,6 +222,28 @@ sub label_fixup {
$labels->{$field} = $col->columnlabel if $col->columnlabel !~ /^\s*$/;
}
+ if ( $part_svc->has_router ) {
+ # these will be set up as pseudo-fields in the new_ and edit_ callbacks
+ push @{ $opt->{'fields'} }, (
+ { field => 'router_routernum', type => 'hidden' },
+ { field => 'router_routername', type => 'text', size => 32 },
+ # router address block selection
+ # (one-to-one for now)
+ { field => 'router_blocknum',
+ type => 'select-table',
+ table => 'addr_block',
+ hashref => { 'routernum' => '0' },
+ agent_virt => 1,
+ agent_null => 1,
+ name_col => 'cidr',
+ order_by => 'ORDER BY ip_gateway, ip_netmask',
+ empty_label => '(none)',
+ disable_empty => 0,
+ },
+ );
+ $labels->{router_routername} = 'Attached router name';
+ $labels->{router_blocknum} = 'Attached address block';
+ }
}
</%once>
diff --git a/httemplate/edit/process/elements/svc_Common.html b/httemplate/edit/process/elements/svc_Common.html
index 06f4c00b1..e1b7cbe1a 100644
--- a/httemplate/edit/process/elements/svc_Common.html
+++ b/httemplate/edit/process/elements/svc_Common.html
@@ -1,6 +1,7 @@
<% include( 'process.html',
'edit_ext' => 'cgi',
'redirect' => popurl(3)."view/$table.cgi?",
+ 'args_callback' => $args_callback,
%opt,
)
%>
@@ -16,4 +17,22 @@ foreach (fields($table)) {
}
}
+my $args_callback = sub {
+ my ($cgi, $svc) = @_;
+ my $part_svc = FS::part_svc->by_key($cgi->param('svcpart'))
+ or die "svcpart required";
+ if ( $part_svc->has_router ) {
+ my $router = FS::router->new({
+ map { $_ => $cgi->param("router_$_") }
+ qw( routernum routername blocknum )
+ });
+ if (length($router->routername) == 0) {
+ #sensible default
+ $router->set('routername', $svc->label);
+ }
+ return (child_objects => [ $router ]);
+ }
+ ();
+};
+
</%init>
diff --git a/httemplate/edit/process/svc_acct.cgi b/httemplate/edit/process/svc_acct.cgi
index d4bcd35ed..ca614cbd8 100755
--- a/httemplate/edit/process/svc_acct.cgi
+++ b/httemplate/edit/process/svc_acct.cgi
@@ -88,7 +88,7 @@ if ( ! $error ) {
my $export_info = FS::part_export::export_info();
- my @svc_export_machine =
+ my @child_objects =
map FS::svc_export_machine->new({
'svcnum' => $svcnum,
'exportnum' => $_->exportnum,
@@ -97,6 +97,19 @@ if ( ! $error ) {
grep { $_->machine eq '_SVC_MACHINE' }
$part_svc->part_export;
+ if ( $part_svc->has_router ) {
+ my $router = FS::router->new({
+ map { $_ => $cgi->param("router_$_") }
+ qw( routernum routername blocknum )
+ });
+ if (length($router->routername == 0)) {
+ #sensible default
+ $router->set('routername', $new->label);
+ }
+ push @child_objects, $router;
+ }
+
+
if ( $svcnum ) {
foreach ( grep { $old->$_ != $new->$_ }
qw( seconds upbytes downbytes totalbytes )
@@ -110,9 +123,9 @@ if ( ! $error ) {
$error ||= $new->set_usage(\%hash); #unoverlimit and trigger radius changes
last; #once is enough
}
- $error ||= $new->replace($old, 'child_objects'=>\@svc_export_machine);
+ $error ||= $new->replace($old, 'child_objects'=>\@child_objects);
} else {
- $error ||= $new->insert('child_objects'=>\@svc_export_machine);
+ $error ||= $new->insert('child_objects'=>\@child_objects);
$svcnum = $new->svcnum;
}
}
diff --git a/httemplate/edit/svc_acct.cgi b/httemplate/edit/svc_acct.cgi
index 574fb51eb..2c694a8fe 100755
--- a/httemplate/edit/svc_acct.cgi
+++ b/httemplate/edit/svc_acct.cgi
@@ -345,6 +345,35 @@
% }
</TR>
+
+% if ( $part_svc->has_router ) {
+<& /elements/hidden.html,
+ field => 'router_routernum',
+ curr_value => $svc_acct->router_routernum
+&>
+<& /elements/tr-input-text.html,
+ label => 'Attached router name',
+ field => 'router_routername',
+ size => 32,
+ curr_value => $svc_acct->router_routername
+&>
+<& /elements/tr-select-table.html,
+ label => 'Attached address block',
+ field => 'router_blocknum',
+ table => 'addr_block',
+ hashref => { 'routernum' => '0' },
+ extra_sql => ($svc_acct->router_routernum ?
+ ' OR routernum = '.$svc_acct->router_routernum : ''),
+ agent_virt => 1,
+ agent_null => 1,
+ name_col => 'cidr',
+ order_by => 'ORDER BY ip_gateway, ip_netmask',
+ empty_label => '(none)',
+ disable_empty => 0,
+ curr_value => $svc_acct->router_blocknum
+&>
+% }
+
% foreach my $field ($svc_acct->virtual_fields) {
% # If the flag is X, it won't even show up in $svc_acct->virtual_fields.
% if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) {
@@ -525,4 +554,21 @@ if ( $export_google ) {
} #if $error
}
+if ( $part_svc->has_router ) { # duplicates the one in elements/svc_Common
+ if ( $svcnum ) {
+ my $router = qsearchs('router', {svcnum => $svc_acct->svcnum});
+ if ( $router ) {
+ $svc_acct->set("router_$_", $router->get($_))
+ foreach ('routername', 'routernum');
+ my ($block) = $router->addr_block;
+ $svc_acct->set('router_blocknum', $block->blocknum) if ( $block );
+ }
+ }
+ foreach (qw(router_routername router_routernum router_blocknum)) {
+ if ( $cgi->param($_) =~ /^(\w+)$/ ) {
+ $svc_acct->set($_, $1);
+ }
+ }
+}
+
</%init>
diff --git a/httemplate/view/elements/svc_Common.html b/httemplate/view/elements/svc_Common.html
index 02484341b..bc1cd45fc 100644
--- a/httemplate/view/elements/svc_Common.html
+++ b/httemplate/view/elements/svc_Common.html
@@ -214,6 +214,20 @@ if ($pkgnum) {
$custnum = '';
}
+# attached routers
+if ( my $router = qsearchs('router', { svcnum => $svc_x->svcnum }) ) {
+ push @$fields, qw(router_routername router_block);
+ $labels->{'router_routername'} = 'Attached router';
+ $labels->{'router_block'} = 'Attached address block';
+ $svc_x->set('router_routername', $router->routername);
+ my $block = qsearchs('addr_block', { routernum => $router->routernum });
+ if ( $block ) {
+ $svc_x->set('router_block', $block->cidr);
+ } else {
+ $svc_x->set('router_block', '<i>(none)</i>');
+ }
+}
+
&{ $opt{'svc_callback'} }( $cgi, $svc_x, $part_svc, $cust_pkg, $fields, \%opt )
if $opt{'svc_callback'};
</%init>
diff --git a/httemplate/view/svc_acct/basics.html b/httemplate/view/svc_acct/basics.html
index 04e7bcff8..441c20add 100644
--- a/httemplate/view/svc_acct/basics.html
+++ b/httemplate/view/svc_acct/basics.html
@@ -152,6 +152,8 @@ sub slipip {
<& /view/elements/tr.html, label=>mt('RADIUS groups'),
value=>join('<BR>', $svc_acct->radius_groups('long_description')) &>
+<& router.html, 'svc_acct' => $svc_acct &>
+
%# Can this be abstracted further? Maybe a library function like
%# widget('HTML', 'view', $svc_acct) ? It would definitely make UI
%# style management easier.