summaryrefslogtreecommitdiff
path: root/httemplate/edit/router.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/edit/router.cgi')
-rwxr-xr-xhttemplate/edit/router.cgi110
1 files changed, 38 insertions, 72 deletions
diff --git a/httemplate/edit/router.cgi b/httemplate/edit/router.cgi
index c08e54449..180dcb7a7 100755
--- a/httemplate/edit/router.cgi
+++ b/httemplate/edit/router.cgi
@@ -1,78 +1,44 @@
-<% include('/elements/header.html', "$action Router", menubar(
- 'View all routers' => "${p}browse/router.cgi",
- ))
+<% include('elements/edit.html',
+ 'post_url' => popurl(1).'process/router.cgi',
+ 'name' => 'router',
+ 'table' => 'router',
+ 'viewall_url' => "${p}browse/router.cgi",
+ 'labels' => { 'routernum' => 'Router',
+ 'routername' => 'Name',
+ 'svc_part' => 'Service',
+ },
+ 'fields' => [
+ { 'field'=>'routername', 'type'=>'text', 'size'=>32 },
+ { 'field'=>'agentnum', 'type'=>'select-agent' },
+ ],
+ 'error_callback' => $callback,
+ 'edit_callback' => $callback,
+ 'new_callback' => $callback,
+ )
%>
-
-<% include('/elements/error.html') %>
-
-<FORM ACTION="<%popurl(1)%>process/router.cgi" METHOD=POST>
- <INPUT TYPE="hidden" NAME="table" VALUE="router">
- <INPUT TYPE="hidden" NAME="redirect_ok" VALUE="<%$p3%>/browse/router.cgi">
- <INPUT TYPE="hidden" NAME="redirect_error" VALUE="<%$p3%>/edit/router.cgi">
- <INPUT TYPE="hidden" NAME="routernum" VALUE="<%$routernum%>">
- <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$router->svcnum%>">
- Router #<%$routernum or "(NEW)"%>
-
-<BR><BR>Name <INPUT TYPE="text" NAME="routername" SIZE=32 VALUE="<%$router->routername%>">
-
-<BR><BR>
-Custom fields:
-<BR>
-<%table() %>
-%
-%foreach my $field ($router->virtual_fields) {
-% print $router->pvf($field)->widget('HTML', 'edit',
-% $router->getfield($field));
-%}
-%
-
-</TABLE>
-%
-%unless ($router->svcnum) {
-%
-
-<BR><BR>Select the service types available on this router<BR>
-%
-%
-% foreach my $part_svc ( qsearch('part_svc', { svcdb => 'svc_broadband',
-% disabled => '' }) ) {
-%
-
- <BR>
- <INPUT TYPE="checkbox" NAME="svcpart_<%$part_svc->svcpart%>"<%
- qsearchs('part_svc_router', { svcpart => $part_svc->svcpart,
- routernum => $routernum } ) ? ' CHECKED' : ''%> VALUE="ON">
- <A HREF="<%${p}%>edit/part_svc.cgi?<%$part_svc->svcpart%>">
- <%$part_svc->svcpart%>: <%$part_svc->svc%></A>
-% }
-% }
-
-
- <BR><BR><INPUT TYPE="submit" VALUE="Apply changes">
- </FORM>
-
-<% include('/elements/footer.html') %>
-
<%init>
-die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+my $curuser = $FS::CurrentUser::CurrentUser;
-my $router;
-if ( $cgi->keywords ) {
- my($query) = $cgi->keywords;
- $query =~ /^(\d+)$/;
- $router = qsearchs('router', { routernum => $1 })
- or print $cgi->redirect(popurl(2)."browse/router.cgi") ;
-} else {
- $router = new FS::router ( {
- map { $_, scalar($cgi->param($_)) } fields('router')
- } );
-}
-
-my $routernum = $router->routernum;
-my $action = $routernum ? 'Edit' : 'Add';
-
-my $p3 = popurl(3);
+die "access denied"
+ unless $curuser->access_right('Engineering configuration')
+ || $curuser->access_right('Engineering global configuration');
+
+my $callback = sub {
+ my ($cgi, $object, $fields) = (shift, shift, shift);
+ unless ($object->svcnum) {
+ push @{$fields},
+ { 'type' => 'tablebreak-tr-title',
+ 'value' => 'Select the service types available on this router',
+ },
+ { 'field' => 'svc_part',
+ 'type' => 'checkboxes-table',
+ 'target_table' => 'part_svc',
+ 'link_table' => 'part_svc_router',
+ 'name_col' => 'svc',
+ 'hashref' => { 'svcdb' => 'svc_broadband', 'disabled' => '' },
+ };
+ }
+};
</%init>