Class PublicController
In: app/controllers/public_controller.rb
Parent: ApplicationController

************************************************************************/

  • SOLUNAS BOOKING ENGINE */
  • ====================== */
  • */
  • Copyright © 2006 by Marc Isemann */
  • sourceforge.net/projects/solunas */
  • */
  • 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 2 of the License. */

************************************************************************/

Methods

Public Instance methods

[Source]

    # File app/controllers/public_controller.rb, line 80
80:   def add_to_cart
81:     @room = Room.find(params[:room_id])
82:     @arrival = ::DateTime.strptime(params[:arrival], @user.datestring)
83:     @departure = ::DateTime.strptime(params[:departure], @user.datestring)
84:     @addons = Addon.find(:all, :conditions => ["user_id = ? && room_id = ? && force_cart = ?", @user_id, params[:room_id], true])
85:     if @cart.add_line(@addons, @room, params[:total], @arrival, @departure, params[:adults], params[:children]) == false
86:       flash[:notice] = 'Room already in cart.'
87:     end
88:     redirect_to(:action=> 'display_cart')
89:   end

[Source]

    # File app/controllers/public_controller.rb, line 50
50:   def calendar
51:     @property_id = params[:property_id]
52:     @month = params[:month] ||= ::Time.now.month
53:     @year = params[:year] ||= ::Time.now.year
54:   end

[Source]

    # File app/controllers/public_controller.rb, line 56
56:   def calendar_by_year
57:     @room = Room.find(:first, :conditions => ["user_id = ? && id = ?",@user_id, params[:room_id]])
58:     @year = params[:year] ||= ::Time.now.year
59:   end

[Source]

     # File app/controllers/public_controller.rb, line 107
107:   def checkout
108:     @items = @cart.items
109:     if @items.empty?
110:       redirect_to(:action=> 'display_cart')
111:     end
112:   end

[Source]

    # File app/controllers/public_controller.rb, line 33
33:   def choose_calendar
34:     @properties = Property.find(:all, :conditions => ["user_id = ?",@user_id])
35:     render(:layout => false)
36:   end

[Source]

    # File app/controllers/public_controller.rb, line 38
38:   def choose_calendar_by_year
39:     @rooms = Room.find(:all, :conditions => ["user_id = ?",@user_id])
40:     render(:layout => false)
41:   end

[Source]

     # File app/controllers/public_controller.rb, line 100
100:   def delete_cart_item
101:     @cart.change_total(@cart.items[params[:cart_item_id].to_i].total)
102:     @cart.items.delete_at(params[:cart_item_id].to_i)
103:     flash[:notice] = 'Cart item deleted.'
104:     redirect_to(:action=> 'display_cart')
105:   end

[Source]

    # File app/controllers/public_controller.rb, line 91
91:   def display_cart
92: 
93:   end

[Source]

    # File app/controllers/public_controller.rb, line 95
95:   def empty_cart
96:     @cart.empty!
97:     redirect_to(:action=> 'display_cart')
98:   end

[Source]

    # File app/controllers/public_controller.rb, line 19
19:   def index
20:   end

[Source]

     # File app/controllers/public_controller.rb, line 114
114:   def save_booking
115: 
116: 
117:     @items = @cart.items
118:     @customer = Customer.new(params[:customer])
119:     @customer.user_id = @user_id
120:     @customer.save
121:     @items.each do |item|
122:       @contract = Contract.new(params[:contract])
123:       @contract.room_id = item.room.id
124:       @contract.total = item.total
125:       @contract.arrival = item.arrival
126:       @contract.departure = item.departure
127:       @contract.adults = item.adults
128:       @contract.children = item.children
129:       @contract.customer_id = @customer.id
130:       @contract.pending = 1
131:       @contract.unconfirmed = 1
132:       @contract.user_id = @user_id
133:       @contract.addons << item.addons
134:       if @contract.is_possible
135:         @contract.save
136:       end
137:     end
138:     @cart.empty!
139:   end

[Source]

    # File app/controllers/public_controller.rb, line 21
21:   def show_calendar
22:     @month = params[:month] ||= ::Time.now.month
23:     @year = params[:year] ||= ::Time.now.year
24:     @month_var = month_vars(@month.to_i, @year)
25:     @property = Property.find(params[:property_id])
26:     @properties = Property.find(:all, :conditions => ["user_id = ?",@user_id])
27:     @rooms = Room.find(:all, :conditions => ["user_id = ? && property_id = ?",@user_id, params[:property_id]])
28: 
29:     @calendar = Contract.get_calendar_data(@rooms, @month, @year, @month_var["end"].to_i)
30:     render(:layout => false)
31:   end

[Source]

    # File app/controllers/public_controller.rb, line 43
43:   def show_calendar_by_year
44:     @year = params[:year] || ::Date.today.year
45:     @room = Room.find(:first, :conditions => ["user_id = ? && id = ?",@user_id, params[:room_id]])
46:     @calendar = Contract.get_calendar_data_by_year(@room, @year)
47:     render(:layout => false)
48:   end

[Source]

    # File app/controllers/public_controller.rb, line 61
61:   def show_form
62:   end

[Source]

    # File app/controllers/public_controller.rb, line 64
64:   def show_rooms
65:     @arrival = ::DateTime.strptime(params[:arrival], @user.datestring)
66:     @departure = ::DateTime.strptime(params[:departure], @user.datestring)
67:     @free_rooms = Public.get_free_rooms(@user, @arrival, @departure, params[:adults], params[:children])
68:     if @free_rooms == false
69:       redirect_to(:action=> 'show_form')
70:       flash[:notice] = 'Choose correct Arrival and Departure dates'.t
71:     elsif @free_rooms.length == 0
72:       redirect_to(:action=> 'show_form')
73:       flash[:notice] = 'No rooms available'.t
74:     else
75:       @adults = params[:adults]
76:       @children = params[:children]
77:     end
78:   end

[Validate]