X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Frouter.cgi;h=70eaa4576e8c2367fde6932f14293047bfb95138;hp=b524c649441ae65063c5e4ab07ac7df00f615e44;hb=74e058c8a010ef6feb539248a550d0bb169c1e94;hpb=c0567c688084e89fcd11bf82348b6c418f1254ac diff --git a/httemplate/edit/router.cgi b/httemplate/edit/router.cgi index b524c6494..70eaa4576 100755 --- a/httemplate/edit/router.cgi +++ b/httemplate/edit/router.cgi @@ -1,92 +1,54 @@ - - -<% - -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 $hashref = $router->hashref; - -print header("$action Router", menubar( - 'Main Menu' => "$p", - 'View all routers' => "${p}browse/router.cgi", -)); - -if($cgi->param('error')) { -%> Error: <%=$cgi->param('error')%> -<% } %> - -
- - Router #<%=$routernum or "(NEW)"%> - -

Name - -

-Custom fields: -
-<%=table() %> - -<% -# I know, I know. Massive false laziness with edit/svc_broadband.cgi. But -# Kristian won't let me generalize the custom field mechanism to every table in -# the database, so this is what we get. -# -- MW - -my @part_router_field = qsearch('part_router_field', { }); -my %rf = map { $_->part_router_field->name, $_->value } $router->router_field; -foreach (sort { $a->name cmp $b->name } @part_router_field) { - %> - - <%=$_->name%> - <% - if(my @opts = $_->list_values) { - %> - <% } else { %> - length ? 'SIZE="'.$_->length.'"' : ''%>> - <% } %> - -<% } %> - - - - -

Select the service types available on this router
-<% - -foreach my $part_svc ( qsearch('part_svc', { svcdb => 'svc_broadband', - disabled => '' }) ) { - %> -
- $part_svc->svcpart, - routernum => $routernum } ) ? 'CHECKED' : ''%> VALUE="ON"> - - <%=$part_svc->svcpart%>: <%=$part_svc->svc%> - <% } %> - -

- - - +<% 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' }, + { 'field'=>'svcnum', 'type'=>'hidden' }, + ], + 'error_callback' => $callback, + 'edit_callback' => $callback, + 'new_callback' => $callback, + 'html_table_bottom' => $html_table_bottom, + ) +%> +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; + +die "access denied" + unless $curuser->access_right('Broadband configuration') + || $curuser->access_right('Broadband 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' => '' }, + }; + } +}; + +my $html_table_bottom = sub { + my $router = shift; + my $html = ''; + foreach my $field ($router->virtual_fields) { + $html .= $router->pvf($field)->widget('HTML', 'edit', $router->get($field)); + } + $html; +}; +