Class: PurchasesController
- Inherits:
-
AdminController
- Object
- ApplicationController
- OfficeController
- AdminController
- PurchasesController
- Defined in:
- app/controllers/purchases_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #edit ⇒ Object
-
#index ⇒ Object
Uncomment for check abilities with CanCan authorize_resource.
-
#inventory ⇒ Object
receive the stuff (ie add to inventory).
- #new ⇒ Object
-
#order ⇒ Object
order this from supplier.
-
#receive ⇒ Object
receive the stuff (ie add to inventory).
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from AdminController
Methods inherited from OfficeController
Methods included from OfficeHelper
#best_euros, #current_basket, #current_basket_or_nil, #current_clerk, #date, #euros, #has_ssl?, #markdown, #new_basket, #paginate, #shipping_method
Instance Method Details
#create ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'app/controllers/purchases_controller.rb', line 50 def create @purchase = Purchase.create(params_for_model) if @purchase.save redirect_to purchase_path(@purchase), :notice => t(:create_success, :model => "purchase") else render :show end end |
#edit ⇒ Object
46 47 48 |
# File 'app/controllers/purchases_controller.rb', line 46 def edit end |
#index ⇒ Object
Uncomment for check abilities with CanCan authorize_resource
9 10 11 12 13 |
# File 'app/controllers/purchases_controller.rb', line 9 def index @q = Purchase.search params[:q] @purchase_scope = @q.result(:distinct => true) @purchases = @purchase_scope.includes(:basket => {:items => :product} ).paginate( :page => params[:page],:per_page => 20 ).to_a end |
#inventory ⇒ Object
receive the stuff (ie add to inventory)
32 33 34 35 36 |
# File 'app/controllers/purchases_controller.rb', line 32 def inventory items = @purchase.inventory! flash.notice = [t(:inventorized) ,items ,t(:items)].join(" ") redirect_to purchase_path(@purchase) end |
#new ⇒ Object
38 39 40 41 42 43 44 |
# File 'app/controllers/purchases_controller.rb', line 38 def new today = Date.today basket = Basket.create! @purchase = Purchase.new :name => "#{I18n.t(:purchase)} #{I18n.l(today)}" , :basket => basket @purchase.save! redirect_to edit_basket_path basket end |
#order ⇒ Object
order this from supplier
20 21 22 23 |
# File 'app/controllers/purchases_controller.rb', line 20 def order @purchase.order! redirect_to purchase_path(@purchase), :notice => t(:ordered) end |
#receive ⇒ Object
receive the stuff (ie add to inventory)
26 27 28 29 |
# File 'app/controllers/purchases_controller.rb', line 26 def receive items = @purchase.receive! redirect_to purchase_path(@purchase), :notice => [t(:received) ,items ,t(:items)].join(" ") end |
#show ⇒ Object
15 16 17 |
# File 'app/controllers/purchases_controller.rb', line 15 def show gon.purchase_id = @purchase.id end |
#update ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/purchases_controller.rb', line 59 def update respond_to do |format| if @purchase.update_attributes(params_for_model) format.html { redirect_to purchase_path(@purchase), :notice => t(:update_success, :model => "purchase") } format.json { respond_with_bip(@purchase) } else format.html { render :action => :show } format.json { respond_with_bip(@purchase) } end end end |