<%= title "User Settings".html_safe -%>

<div id='settings' class='grid_12 boxit page'>
	
	<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :multipart => true, :class => 'basic-form validate' }) do |f| %>
	  <%= devise_error_messages! %>

		<div id='form-holder' class=''>

			<div class='grid_5'>
				
				<% if Snorby::CONFIG[:authentication_mode] == "cas" %>
  				<p><%= f.label :name %> <i>(please use your complete CAS login)</i><br />
  			  <%= f.text_field :name, :placeholder => 'CAS login', :class => 'required' %></p>
        <% else %>
  				<p><%= f.label :name %> <i>(please use first and last name)</i><br />
  			  <%= f.text_field :name, :placeholder => 'Full Name', :class => 'required' %></p>        
        <% end %>

			  <p><%= f.label :email %> <i>(example: snorby@snorby.org)</i><br />
			  <%= f.text_field :email, :placeholder => 'E-mail Address', :class => 'required email' %></p>
        
        <% if Snorby::CONFIG[:authentication_mode] == "database"  %>
  				<p><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
  			  <%= f.password_field :password, :placeholder => 'Password' %></p>        
        
  			  <p><%= f.label :password_confirmation %><br />
  			  <%= f.password_field :password_confirmation, :placeholder => 'Password Confirmation' %></p>

  				<p><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
  			  <%= f.password_field :current_password, :placeholder => 'Current Password', :class => 'required password' %></p>

  				<p>
  			<% end %>	  
					<%= f.label 'Note Notifications:' %>
					<%= f.select :accept_notes, [['Yes', 1], ['No', 2], ['Only events I\'ve noted', 3]], { :include_blank => false } %><br />
					<i>(Would you like to receive notifications when new notes are added?)</i><br />
					<br />
				</p>

				<p>
					I would like to list <%= f.select :per_page_count, %w[25 45 65 100], { :include_blank => false } %>  <%= f.label "items per page." %><br />
					<i>(select the default amount of events to list per page view)</i><br />
					<br />
				</p>

			</div>

			<div class='grid_5 alpha'>
				
				<div class='user-show-avatar'>
					
					<%= image_tag(@user.gravatar ? get_gravatar_uri(@user.email) : @user.avatar.url(:small), :class => 'avatar') %>
					
					<p><strong>Login Count:</strong> <%= @user.sign_in_count %></p>
          
					<p><strong>Current Login IP:</strong> <%= @user.current_sign_in_ip || 'N/A' %></p>
          
					<p><strong>Last Login:</strong> <%= @user.last_sign_in_at.blank? ? Time.now.strftime('%a %b, %Y %I:%M %p') : @user.last_sign_in_at.strftime('%a %b, %Y %I:%M %p') %></p>
          
					<p><strong>Last Login IP:</strong> <%= @user.last_sign_in_ip || 'N/A' %></p>
          
					<p><strong>Queued Event Count:</strong> <%= @user.favorites_count %></p>
          
					<p><strong>Notes Count:</strong> <%= @user.notes_count %></p>
					
				</div>
				
				<p>
					<%= f.label 'Change Avatar' %><br />
          <%= f.file_field :avatar %><br />
          <br />
				</p>
				
				<p>
					<%= f.check_box :gravatar%> <%= f.label "Use Gravatar" %>
					<i>(Get avatar from gravatar.com)</i>
				</p>
								
				<% if current_user.admin? %>

					<p>
						<%= f.check_box :admin %> <%= f.label "Administrator" %>
						<i>(should this user have administrative rights?)</i>
					</p>

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

		<%= form_actions do %>

			<%= button "Update Settings", :class => 'success' %>

			<%= button "Cancel", :class => 'warning cancel' %>

		<% end %>

	<% end %>
	
</div>
