X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Frouter.cgi;h=72111ca57a4b96510e20fbf9784044e1270f688a;hb=14f234a943f1e4b5bbc6fe90254b8f5ca677f028;hp=c08e54449e31e7fea428d43381cd47336d13ecfb;hpb=c648976f0b7975f2328ebd7ba8c711fad0ca4195;p=freeside.git
diff --git a/httemplate/edit/router.cgi b/httemplate/edit/router.cgi
index c08e54449..72111ca57 100755
--- a/httemplate/edit/router.cgi
+++ b/httemplate/edit/router.cgi
@@ -1,78 +1,70 @@
-<% 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',
+ 'agentnum' => 'Agent',
+ 'manual_addr' => '
+ Assign IP addresses manually
+
+ Uncheck to assign IP address
+ from router/address block
+
+ ',
+ },
+ 'fields' => [
+ { 'field'=>'routername', 'type'=>'text', 'size'=>32 },
+ { 'field'=>'agentnum', 'type'=>'select-agent' },
+ { 'field'=>'svcnum', 'type'=>'hidden' },
+ { 'field'=>'manual_addr','type'=>'checkbox','value'=>'Y'},
+ ],
+ 'error_callback' => $callback,
+ 'edit_callback' => $callback,
+ 'new_callback' => $callback,
+ 'html_table_bottom' => $html_table_bottom,
+ )
%>
-
-<% include('/elements/error.html') %>
-
-
-
-<% include('/elements/footer.html') %>
-
<%init>
+my $curuser = $FS::CurrentUser::CurrentUser;
+
die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+ unless $curuser->access_right('Broadband configuration')
+ || $curuser->access_right('Broadband global configuration');
-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 @svc_x = 'svc_broadband';
+if ( FS::Conf->new->exists('svc_acct-ip_addr') ) {
+ push @svc_x, 'svc_acct';
}
-my $routernum = $router->routernum;
-my $action = $routernum ? 'Edit' : 'Add';
-
-my $p3 = popurl(3);
-
+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',
+ 'value' => 'Select the service types available on this router',
+ },
+ { 'type' => 'checkboxes-table',
+ 'target_table' => 'part_svc',
+ 'link_table' => 'part_svc_router',
+ 'name_col' => 'svc',
+ 'hashref' => { 'disabled' => '' },
+ 'extra_sql' => $extra_sql,
+ };
+ }
+};
+
+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;
+};
%init>