


  <% role_disable = @user.roles.include?(user_role_data) ?   false : true    %> 

  <div class="attributes <%= role_disable ? 'disabled hide' : '' %>">
  <div class="attributes-header clearfix">
    
        <%= hidden_field_tag("user[disable_role][id][#{user_role_data.id}]",role_disable,:for=>@form_index,:value=>role_disable)%>
        
    <h4><%= user_role_data.title %><%= t(:role_info)%></h4>
  </div>

  <div class="attributes-body">

      <% @form_index = @form_index +1 %>

      <div class="control-group">
        <%= label_tag t(:status), nil, {:func=>"field_label", :for=>"1", :class=>"control-label muted"} %>
        <div class="controls">
        <% user_role_data.role_statuses.where(:disable => false).each_with_index do |rrs, i|%>
          <%= hidden_field_tag("user[role_status][id][#{rrs.id}]", false,:for=>"#{@form_index}")%>
          <%= label_tag(i,check_box_tag( "user[role_status][id][#{rrs.id}]", true, @user.role_statuses.include?(rrs))+rrs.title,:class=>"checkbox inline") %>
        <% end %>
        </div>
      </div>


      <% @form_index = @form_index +1 %>

      <div class="control-group">
        <%= label_tag t(:category), nil, {:func=>"field_label", :for=>"1", :class=>"control-label muted"} %>
        <div class="controls">
        <% user_role_data.role_categorys.where(:disable => false).each_with_index do |rrcg, i|%>
          <%= hidden_field_tag("user[role_category][id][#{rrcg.id}]", false,:for=>"#{@form_index}")%>
          <%= label_tag(i,check_box_tag( "user[role_category][id][#{rrcg.id}]", true, @user.role_categorys.include?(rrcg))+rrcg.title,:class=>"checkbox inline") %>
        <% end %>
        </div>
      </div>



      <% user_role_data.attribute_fields.asc(:_id).each  do |rf|%>
      
    	<%= rf.block_helper(@user,@form_index)%>
    	<% @form_index = @form_index +1 %>
      
      <% end %>
      


      <% @form_index = @form_index +1 %>

      <div class="input-area sub-role">

        <% user_role_data.sub_roles.where(:disabled=>false).asc("_id").each do |sub_role| %> 

        <% sub_role_disable = @user.sub_roles.include?(sub_role) ?   false : true    %> 

          <div class="attributes <%= sub_role_disable ? 'disabled hide' : '' %>">

            <div class="attributes-header clearfix">
              <%= hidden_field_tag("user[disable_sub_role][id][#{sub_role.id}]",sub_role_disable,:for=>@form_index,:value=>sub_role_disable)%>
              <h4><%= sub_role.title %><%= t(:role_info)%></h4>
            </div>

            <div class="attributes-body">

              <% sub_role.attribute_fields.asc(:_id).each  do |af|%>
                  <%= af.block_helper(@user,@form_index)%>
                  <% @form_index = @form_index +1 %>
              <% end %>

            </div>

          </div>
          
        <% end %>

      </div>





    </div>

  </div>



