Class: MyselvesController

Inherits:
AdminController show all
Defined in:
app/controllers/myselves_controller.rb

Overview

License

Ekylibre - Simple ERP Copyright (C) 2008-2011 Brice Texier, Thibaud Merigon

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <www.gnu.org/licenses/>.

Instance Attribute Summary

Attributes inherited from AdminController

#current_user

Instance Method Summary (collapse)

Methods inherited from AdminController

#accessible?, authorized?

Methods inherited from BaseController

#has_notifications?, #human_action_name, human_action_name, #notify, #notify_error, #notify_error_now, #notify_now, #notify_success, #notify_success_now, #notify_warning, #notify_warning_now

Instance Method Details

- (Object) change_password



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/myselves_controller.rb', line 27

def change_password
  @user = User.find(session[:user_id])
  if request.post?
    if @user.authenticated? params[:user][:old_password]
      @user.password = params[:user][:password]
      @user.password_confirmation = params[:user][:password_confirmation]
      if @user.save
        notify_success(:password_successfully_changed)
        redirect_to :controller=>:dashboards, :action=>:general
      end
      @user.password = @user.password_confirmation = ''
    else
      @user.errors.add(:old_password, :invalid)
    end
  end
end

- (Object) statistics



22
23
24
25
# File 'app/controllers/myselves_controller.rb', line 22

def statistics
  params[:stopped_on] = params[:stopped_on].to_date rescue Date.today
  params[:started_on] = params[:started_on].to_date rescue params[:stopped_on] << 12
end