<% content_for :secondary do %>
<% end %>

<!-- Remove if CSS done-->
<br />
<br />
<br />
<!-- Remove if CSS done-->
<h3><%= @module_app.title %></h3>

<div id="manager_management">
	<h1>Manager</h1>
	
	<dl id="manager">
		<dt>Manager</ht>
		<% @module_app.managers.each do |manager| %>
			<dd><%= manager.user.name %>  <%= get_auth_by(manager) %> <%= link_to '[X]',remove_manager_admin_module_app_path(@module_app,manager),:method => :delete if if_permit_to_delete(:manager) && manager.user != current_user %> </dd>
		<% end %>
		<dd>Add:
			<%= form_tag(assign_manager_admin_module_app_path) do %>
				<%= collection_select(:manager,:id, User.all, :id, :name, :prompt => true,:disabled  => !if_permit_to_assign(:manager))%>
				<%= submit_tag 'Add Manager' %>
			<% end %>
		</dd>
	</dl>
	<dl id="sub_manager">
		<dt>Sub Manager</ht>
		<% @module_app.sub_managers.each do |manager| %>
			<dd><%= manager.user.name %>  -AuthBy:<%= manager.rule_creator.name %> <%= link_to '[X]',remove_sub_manager_admin_module_app_path(@module_app,manager),:method => :delete if if_permit_to_delete(:sub_manager) && manager.user != current_user %> </dd>
		<% end %>
		<dd>Add:
			<%= form_tag(assign_sub_manager_admin_module_app_path) do %>
			<%= collection_select(:sub_manager,:id, User.all, :id, :name, :prompt => true,:disabled  => !if_permit_to_assign(:sub_manager))%>
				<%= submit_tag 'Add Sub Manager' %>
			<% end %>
		</dd>
	</dl>
</div>
<div id="user_role_management">
	<h1>User Role</h1>
	<%= form_tag(admin_module_app_app_auths_path(@module_app),:method => :post) do %>
		<%= collection_select(:new,:role, Role.all, :id, :key, :prompt => true) %>
		<%= submit_tag 'Add Role' %><br/>
		<%= collection_select(:new,:sub_role, SubRole.all, :id, :key, :prompt => true) %>
		<%= submit_tag 'Add SubRole' %><br/>
		<%= collection_select(:new,:privilege_user, User.all, :id, :name, :prompt => true) %>	
		<%= submit_tag 'Add PrivilegeList' %><br/>
		<%= collection_select(:new,:blocked_user, User.all, :id, :name, :prompt => true) %>
		<%= submit_tag 'Add BlockedList' %><br/>
	<% end %>
	<ul>Roles </ul>
	<% unless @module_app.app_auth.nil? %>
		<% @module_app.app_auth.roles.each do |role| %>
			<li> <%= role.key %> Build in:<%= role.built_in ? 'Yes' : 'No' %> <%= link_to '[X]',remove_admin_module_app_app_auth_path(@module_app,@module_app.app_auth,'role',role),:method => :delete %></li>
		<% end %>
	<ul>Sub Roles </ul>
		<% @module_app.app_auth.sub_roles.each do |role| %>
			<li> <%= role.key %> Build in:<%= role.built_in ? 'Yes' : 'No' %> </li><%= link_to '[X]',remove_admin_module_app_app_auth_path(@module_app,@module_app.app_auth,'sub_role',role),:method => :delete %>
			<% end %>
	<ul>PrivilegeList </ul>
			<% @module_app.app_auth.privilege_users.each do |user| %>
				<li> <%= user.name %> <%= link_to '[X]',remove_admin_module_app_app_auth_path(@module_app,@module_app.app_auth,'privilege_user',user),:method => :delete %> </li>
			<% end %>
	<ul>BlockedList </ul>
			<% @module_app.app_auth.blocked_users.each do |user| %>
				<li> <%= user.name %><%= link_to '[X]',remove_admin_module_app_app_auth_path(@module_app,@module_app.app_auth,'blocked_user',user),:method => :delete %> </li>
			<% end %>
<% end %>
</div>
