<h2>
  <i class="fa fa-user" aria-hidden="true"></i>
	<% if @user && !@user.new_record? %>
	  <%= I18n.t(:edit_user)%>
    <strong><%= @user.username %></strong>
	<% else %>
	  <%= I18n.t(:new_user)%>
	<% end %>
</h2>

<% if current_user.is_admin? %>
<p><%= raw I18n.t(:add_user_intro) %></p>
<% else %>
<p><%= raw I18n.t(:edit_user_intro) %></p>
<% end %>

<form action="/users/update" class="form-horizontal"  method="POST">

	<input type="hidden" name="user_id" value="<%= @user.id rescue nil %>"/>

  <div class="form-group form-group-sm row">
    <label class="col-sm-2 col-form-label form-control-label" for="password"><%= I18n.t(:username)%>  <% if @user.new_record? %><span class="mandatory">*</span><% end %></label>
    <div class="col-sm-6">
			<input type="text" name="username" value="<%= @user.username rescue nil %>" class="form-control"/>
    </div>
  </div>

  <div class="form-group form-group-sm row">
    <label class="col-sm-2 col-form-label form-control-label" for="password"><%= I18n.t(:password)%> <% if @user.new_record? %><span class="mandatory">*</span><% end %></label>
    <div class="col-sm-6">
			<input type="password" name="password" class="form-control"/>
    </div>
  </div>

  <div class="form-group form-group-sm row">
    <label class="col-sm-2 col-form-label form-control-label" for="password"><%= I18n.t(:password_confirmation)%> <% if @user.new_record? %><span class="mandatory">*</span><% end %></label>
    <div class="col-sm-6">
			<input type="password" name="password_confirmation" class="form-control"/>
    </div>
  </div>
	
  <div class="form-group form-group-sm row">
    <label class="col-sm-2 col-form-label form-control-label" for="email"><%= I18n.t(:email)%></label>
    <div class="col-sm-6">
			<input type="email" name="email" value="<%= @user.email rescue nil %>" class="form-control"/>
    </div>
  </div>
	
	
	<% if current_user.is_admin? %>
	<div class="form-group form-group-sm row">
    <label class="col-sm-2 col-form-label form-control-label" for="role"><%= I18n.t(:roles)%> :</label>
    <div class="col-sm-6">			
			
		<% Project.retrieve_all.each do |project| %>
		
			<div style="margin-top: 8px; margin-bottom: 2px;"><%= I18n.t(:project)%>: <strong><a href="/projects/<%= project.identifier %>/edit"><%= project.name %></a></strong></div>

			<% Role.all_roles.each do |role| %>	
				<input type="hidden" name="project_<%= project.id %>[<%= role %>]" value="false"/>
				<div style="display: inline; padding-left: 0px; padding-top: 4px; padding-right: 10px;">

					<input type="checkbox" name="project_<%= project.id %>[<%= role  %>]" value="true"
						<% if @user.has_role?(role.to_sym, project) %> checked="true" <% end %>
					/>				
					<%= I18n.t(role) %> &nbsp;&nbsp;  
				</div>
				
		  <% end %>

		<% end %>
	
		</div>
	</div>
	<% end %>

	 
	<hr/>
	<div class="form-group form-group-mini row">
    <label class="col-sm-2 col-form-label form-control-label" for="role"></label>
	  <div class="form-actions col-sm-6" style="padding-bottom: 20px;">
	    <input type="submit" value="<% if @user.new_record? %><%=I18n.t(:create) %><% else %><%=I18n.t(:update) %><% end %>" class="btn btn-primary"/>
	    <a href="/" class="btn btn-default"><%= I18n.t(:cancel)%></a>
	  </div>
  </div>

</form>
<br/>
