Class: Forge::OrdersController
Instance Method Summary
collapse
#get_menu_items, #load_help, #set_crumbs, #set_title, #uses_ckeditor
#app_init
Instance Method Details
#create ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 32
def create
@order = Order.new(params[:order])
if @order.save
flash[:notice] = 'Order was successfully created.'
redirect_to(forge_orders_path)
else
render :action => "new"
end
end
|
#destroy ⇒ Object
72
73
74
75
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 72
def destroy
@order.destroy
redirect_to(forge_orders_path)
end
|
#edit ⇒ Object
29
30
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 29
def edit
end
|
#fulfill ⇒ Object
51
52
53
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 51
def fulfill
mark_fulfillment(:action => "fulfill!", :success => "Order marked as fulfilled", :failure => "Error marking as fulfilled")
end
|
#index ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 4
def index
conditions = {"fulfill" => '=', "unfulfill" => '<>'}
unless params[:show].nil?
@orders = Order.not_pending.where("state #{conditions[params[:show]]} 'fulfilled'").order("orders.created_at DESC") else
@orders = Order.not_pending.order("orders.created_at DESC")
end
respond_to do |format|
format.html { @orders = @orders.paginate(:per_page => 10, :page => params[:page]).includes(:shipping_address, :billing_address) }
format.js {
params[:q] ||= ''
@orders = @orders.where("orders.id = ? OR orders.state = ? OR LOWER(addresses.first_name) LIKE ? OR LOWER(addresses.last_name) LIKE ? OR LOWER(addresses.email) LIKE ?", params[:q].to_i, params[:q], "%#{params[:q].downcase}%", "%#{params[:q].downcase}%", "%#{params[:q].downcase}%").includes(:shipping_address, :billing_address)
render :partial => "order", :collection => @orders
}
end
end
|
#mark_fulfillment(opts = {}) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 59
def mark_fulfillment(opts = {})
order = Order.find(params[:id])
respond_to do |format|
if order.send(opts[:action])
format.js { render :nothing => true }
format.html { flash[:notice] = opts[:success] and redirect_to forge_orders_path }
else
format.js { render :status => 500 }
format.html { flash[:warning] = opts[:failure] and redirect_to forge_orders_path }
end
end
end
|
#new ⇒ Object
21
22
23
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 21
def new
@order = Order.new
end
|
#show ⇒ Object
25
26
27
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 25
def show
@order = Order.find(params[:id])
end
|
#unfulfill ⇒ Object
55
56
57
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 55
def unfulfill
mark_fulfillment(:action => "unfulfill!", :success => "Order no longer marked as fulfilled.", :failure => "Error marking as unfulfilled")
end
|
#update ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'lib/forge/app/controllers/forge/orders_controller.rb', line 42
def update
if @order.update_attributes(params[:order])
flash[:notice] = 'Order was successfully updated.'
redirect_to(forge_orders_path)
else
render :action => "edit"
end
end
|