import torrus 1.0.9
[freeside.git] / httemplate / browse / addr_block.cgi
index d597ee1..1bbcdcb 100644 (file)
@@ -2,17 +2,18 @@
                 'title'         => 'Address Blocks',
                 'name'          => 'address block',
                 'html_init'     => $html_init,
-                'html_form'     => $html_form,
+                'html_foot'     => $html_foot,
                 'query'         => { 'table'     => 'addr_block',
                                      'hashref'   => {},
                                      'extra_sql' => $extra_sql,
                                      'order_by'  => $order_by,
                                    },
-                'count_query'   => "SELECT count(*) from addr_block $extra_sql",
+                'count_query'   => "SELECT count(*) from addr_block $count_sql",
                 'header'        => [ 'Address Block',
                                      'Router',
                                      'Action(s)',
                                      '',
+                                     '',
                                    ],
                 'fields'        => [ 'NetAddr',
                                      sub { my $block = shift;
                                          },
                                      $allocate_text,
                                      sub { shift->router ? '' : '<FONT SIZE="-2">(split)</FONT>' },
+                                     sub { '<FONT SIZE="-2">('. (shift->manual_flag ? 'allow' : 'prevent'). ' automatic ip assignment)</FONT>' },
                                    ],
                 'links'         => [ '',
                                      '',
                                      [ 'javascript:void(0)', '' ],
                                      $split_link,
+                                     $autoassign_link,
                                    ],
                 'link_onclicks' => [ '',
                                      '',
                                      'border-right:none;',
                                      'border-left:none;',
                                    ],
+                'agent_virt'    => 1,
+                'agent_null_right' => 'Broadband global configuration',
+                'agent_pos'     => 1,
           )
 %>
 <%init>
 
 die "access denied"
-  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+  unless $FS::CurrentUser::CurrentUser->access_right('Broadband configuration')
+  || $FS::CurrentUser::CurrentUser->access_right('Broadband global configuration');
 
 my $p2 = popurl(2);
 my $path = $p2 . "edit/process/addr_block";
 
-my $extra_sql = " ";
+my $extra_sql = "";
+
+my $count_sql = "WHERE ". $FS::CurrentUser::CurrentUser->agentnums_sql(
+  'null_right' => 'Broadband global configuration',
+);
+
 my $order_by = "ORDER BY ";
 $order_by .= "inet(ip_gateway), " if driver_name =~ /^Pg/i;
 $order_by .= "inet_aton(ip_gateway), " if driver_name =~ /^mysql/i;
@@ -74,10 +86,15 @@ my $confirm = sub {
   "javascript:addr_block_areyousure('$path/$verb.cgi?blocknum=$num', '$verb')";
 };
 
-my $html_form = qq(
+my $html_foot = qq(
   <FORM ACTION="$path/add.cgi" METHOD="POST">
   Gateway/Netmask: 
   <INPUT TYPE="text" NAME="ip_gateway" SIZE="15">/<INPUT TYPE="text" NAME="ip_netmask" SIZE="2">
+);
+$html_foot .= include( '/elements/select-agent.html',
+                         'agent_null_right' => 'Broadband global configuration',
+                     );
+$html_foot .= qq(
   <INPUT TYPE="submit" NAME="submit" VALUE="Add">
   </FORM>
 );
@@ -118,4 +135,11 @@ my $split_link = sub {
   $ref;
 }; 
 
+my $autoassign_link = sub {
+  my $block = shift;
+  my $url = "$path/manual_flag.cgi?manual_flag=";
+  $url .=  $block->manual_flag ? '' : 'Y';
+  [ "$url;blocknum=", 'blocknum' ];
+}; 
+
 </%init>