add ability to view/edit access groups of an agent
[freeside.git] / httemplate / edit / agent.cgi
index 830862f..215542d 100755 (executable)
@@ -1,12 +1,8 @@
 <% include("/elements/header.html","$action Agent", menubar(
-  'Main Menu' => $p,
   'View all agents' => $p. 'browse/agent.cgi',
 )) %>
-% if ( $cgi->param('error') ) { 
-
-<FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT>
-% } 
 
+<% include('/elements/error.html') %>
 
 <FORM ACTION="<%popurl(1)%>process/agent.cgi" METHOD=POST>
 <INPUT TYPE="hidden" NAME="agentnum" VALUE="<% $agent->agentnum %>">
@@ -34,6 +30,18 @@ Agent #<% $agent->agentnum ? $agent->agentnum : "(NEW)" %>
   </TR>
 
   <TR>
+    <TH ALIGN="right">Master customer</TH>
+    <TD>
+      <% include('/elements/search-cust_main.html',
+                   'field_name'  => 'agent_custnum',
+                   'curr_value'  => $agent->agent_custnum,
+                   'find_button' => 1,
+                )
+      %>
+    </TD>
+  </TR>
+
+  <TR>
     <TD ALIGN="right">Disable</TD>
     <TD><INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<% $agent->disabled eq 'Y' ? ' CHECKED' : '' %>></TD>
   </TR>
@@ -69,6 +77,19 @@ Agent #<% $agent->agentnum ? $agent->agentnum : "(NEW)" %>
     </TR>
 % } 
 
+  <TR>
+    <TD ALIGN="right">Access Groups</TD>
+    <TD><% include('/elements/checkboxes-table.html',
+                     'source_obj'   => $agent,
+                     'link_table'   => 'access_groupagent',
+                     'target_table' => 'access_group',
+                     'name_col'     => 'groupname',
+                     'target_link'  => $p. 'edit/access_group.html?',
+                  )
+        %>
+    </TD>
+  </TR>
+
 </TABLE>
 
 <BR>
@@ -80,6 +101,9 @@ Agent #<% $agent->agentnum ? $agent->agentnum : "(NEW)" %>
 
 <%init>
 
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
 my $agent;
 if ( $cgi->param('error') ) {
   $agent = new FS::agent ( {
@@ -97,5 +121,3 @@ my $action = $agent->agentnum ? 'Edit' : 'Add';
 my $conf = new FS::Conf;
 
 </%init>
-
-