Class: InterfacersController
- Inherits:
-
AdminController
- Object
- ActionController::Base
- ApplicationController
- BaseController
- AdminController
- InterfacersController
- Defined in:
- app/controllers/interfacers_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
Class Method Summary (collapse)
Instance Method Summary (collapse)
- - (Object) product_trackings
- - (Object) product_units
-
- (Object) toggle_module
Saves the state of the side bar.
-
- (Object) toggle_side
Saves the state of the side bar.
-
- (Object) toggle_tab
Saves the last selected tab in a tabbox.
-
- (Object) toggle_view_mode
Saves the view mode.
- - (Object) unroll
-
- (Object) unroll_options
Returns the new list for a "dynamic select" using helper options_for_unroll.
Methods inherited from AdminController
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
Class Method Details
+ (Object) available_prices_conditions
82 83 84 85 86 87 88 89 90 |
# File 'app/controllers/interfacers_controller.rb', line 82 def self.available_prices_conditions code = "" code << "c=['#{Price.table_name}.active=? AND #{Product.table_name}.active=?', true, true]\n" code << "if session[:current_currency]\n" code << " c[0] << ' AND currency=?'\n" code << " c << session[:current_currency]\n" code << "end\n" return code end |
Instance Method Details
- (Object) product_trackings
71 72 73 74 |
# File 'app/controllers/interfacers_controller.rb', line 71 def product_trackings return unless @product = find_and_check(:product, params[:product_id]) render :inline=>"<%=options_for_select([['---', '']]+@product.trackings.collect{|x| [x.name, x.id]})-%>", :layout=>false end |
- (Object) product_units
76 77 78 79 |
# File 'app/controllers/interfacers_controller.rb', line 76 def product_units return unless @product = find_and_check(:product, params[:product_id]) render :inline=>"<%=options_for_select(@product.units.collect{|x| [x.name, x.id]})-%>", :layout=>false end |
- (Object) toggle_module
Saves the state of the side bar
30 31 32 33 34 35 36 37 |
# File 'app/controllers/interfacers_controller.rb', line 30 def toggle_module # Explicit conversion shown = (params[:shown].to_i>0 ? true : false) session[:modules] ||= {} session[:modules][params[:module]] = shown @current_user.preference("interface.show_modules.#{params[:module]}", true, :boolean).set(shown) render :text=>'' end |
- (Object) toggle_side
Saves the state of the side bar
23 24 25 26 27 |
# File 'app/controllers/interfacers_controller.rb', line 23 def toggle_side # Explicit conversion session[:side] = (params[:splitted] == "1" ? false : true) render :text=>'' end |
- (Object) toggle_tab
Saves the last selected tab in a tabbox
40 41 42 43 44 |
# File 'app/controllers/interfacers_controller.rb', line 40 def toggle_tab session[:tabbox] ||= {} session[:tabbox][params['id']] = params['index'] render :text=>nil end |
- (Object) toggle_view_mode
Saves the view mode
47 48 49 50 |
# File 'app/controllers/interfacers_controller.rb', line 47 def toggle_view_mode session[:view_mode] = params[:mode] render :text=>'' end |
- (Object) unroll
53 54 55 56 57 58 59 |
# File 'app/controllers/interfacers_controller.rb', line 53 def unroll @options = [:source, :filter, :model, :id, :label, :include_blank, :selected].inject({}) do |hash, key| hash[key] = params[key] if params.has_key?(key) hash end render :inline => '<%=options_for_unroll(@options)-%>' end |
- (Object) unroll_options
Returns the new list for a "dynamic select" using helper options_for_unroll
63 64 65 66 67 68 69 |
# File 'app/controllers/interfacers_controller.rb', line 63 def @options = {} for x in [:reflection, :order, :label, :include_blank] @options[x] = params[x] end render :inline=>'<%=options_for_select(options_for_unroll(@options), params[:selected].to_i)-%>' end |