Class BackendController
In: app/controllers/backend_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/backend_controller.rb, line 159
159:   def get_calendar_array_by_month(room_id, year, month, language, username, password)
160:     if user=User.login(username ,password)
161:       Locale.set language
162:       @year = year
163:       @month = month
164:       @month_var = month_vars(@month.to_i, @year)
165:       @room = Room.find(:all, :conditions => ["user_id = ? && id = ?",user.id, room_id])
166:       @calendar = Contract.get_calendar_data(@room, @month, @year, @month_var["end"].to_i)
167:       @calendar[room_id]
168:     else
169:       render(:text => "Not logged in" + user.inspect)
170:     end
171:   end

[Source]

     # File app/controllers/backend_controller.rb, line 173
173:   def get_free_rooms(arrival,departure, adults, children, language, username, password)
174:     if user=User.login(username ,password)
175:       Locale.set language
176:       room_array = Array.new
177:       convert_arrival = ::DateTime.strptime(arrival, user.datestring)
178:       convert_departure = ::DateTime.strptime(departure, user.datestring)
179:       free_rooms = Public.get_free_rooms(user, convert_arrival, convert_departure, adults, children)
180:       free_rooms.each do |rooms|
181:         #room_string = rooms["room"].id.to_s + ";" + rooms["room"].property.name + ";" + rooms["room"].name + ";" + rooms["price"].to_s
182:         #room_array << room_string
183:         freeroom = FreeRoom.new
184:         freeroom.id = rooms["room"].id
185:         freeroom.name = rooms["room"].name
186:         freeroom.property = rooms["room"].property.name
187:         freeroom.price = rooms["price"]
188:         #freeroom.addons = rooms["room"].addons
189:         room_array << freeroom
190:       end
191:       room_array
192:     else
193:       render(:text => "Not logged in" + user.inspect)
194:     end
195:   end

[Source]

    # File app/controllers/backend_controller.rb, line 18
18:   def show_calendar_by_room(property_id, year, month, language, username, password)
19:     if user=User.login(username ,password)
20:       Locale.set language
21:       @year = year
22:       @month = month
23:       @month_var = month_vars(@month.to_i, @year)
24:       @room = Room.find(:all, :conditions => ["user_id = ? && property_id = ?",user.id, property_id])
25:       @calendar = Contract.get_calendar_data(@room, @month, @year, @month_var["end"].to_i)
26:       content = "<style type='text/css'>
27:                  <!--
28:                  #calendar_av {
29:                  width: 15px;
30:                  background-color: green;
31:                  color: white;
32:                  font-weight: bold;
33:                  padding: 0px;
34:                  margin: 0px;
35:                  }
36: 
37:                  #calendar_not_av {
38:                  width: 15px;
39:                  background-color: #c0c0c0;
40:                  color: white;
41:                  font-weight: bold;
42:                  padding: 0px;
43:                  margin: 0px;
44:                  }
45:                  #calendar_tr {
46:                  font-family: Verdana, Arial, Helvetica, sans-serif;
47:                  font-size: 11px;
48:                  }
49:                   -->
50:                  </style><table id='table_calendar'><tr id='calendar_tr'><td nowrap>" + "Room".t + "</td>"
51: 
52: 
53:        (1 .. @month_var["end"].to_i).each do |days|
54: 
55:         content = content + "<td id='calendar' align='center'>" + days.to_s + "</td>"
56: 
57:       end
58:       content = content + "</tr>"
59: 
60:       @room.each do |room|
61:         content = content + "<tr id='calendar_tr'><td>" + room.name + "</td>"
62: 
63:         @calendar[room.id].each_with_index do |days, i|
64: 
65:         date = ::Date.new(@year.to_i,@month.to_i,i+1).strftime(user.datestring)
66: 
67:           if (days == 1 || ::Date.new(@year.to_i,@month.to_i,i+1) < ::DateTime.now-(1))
68:             content = content + "<td id='calendar_not_av' align='center' title='" + date + "'>B"
69:           elsif days == 2
70:             content = content + "<td id='calendar_av' align='center' title='" + date + "'>A"
71:           elsif days == 3
72:             content = content + "<td id='calendar_av' align='center' title='" + date + "'>D"
73:           else
74:             content = content + "<td id='calendar_av' align='center' title='" + date + "'>F"
75:           end
76:           content = content + "</td>"
77:         end
78:         content = content + "</tr>"
79:       end
80:       content = content + "</table>"
81: 
82:       render(:text => content)
83:     else
84:       render(:text => "Not logged in" + user.inspect)
85:     end
86:   end

[Source]

     # File app/controllers/backend_controller.rb, line 88
 88:   def show_calendar_by_year(room_id, year, language, username,password)
 89:     if user=User.login(username ,password)
 90:       Locale.set language
 91:       @year = year
 92:       @room = Room.find(:first, :conditions => ["user_id = ? && id = ?",user.id, room_id])
 93:       @calendar = Contract.get_calendar_data_by_year(@room, @year)
 94:       content = "<style type='text/css'>
 95:                  <!--
 96:                  #calendar_av {
 97:                  width: 15px;
 98:                  background-color: green;
 99:                  color: white;
100:                  font-weight: bold;
101:                  padding: 0px;
102:                  margin: 0px;
103:                  }
104: 
105:                  #calendar_not_av {
106:                  width: 15px;
107:                  background-color: #c0c0c0;
108:                  color: white;
109:                  font-weight: bold;
110:                  padding: 0px;
111:                  margin: 0px;
112:                  }
113:                  #calendar {
114:                  width: 15px;
115:                  padding: 0px;
116:                  margin: 0px;
117:                  }
118:                  #calendar_tr {
119:                  font-family: Verdana, Arial, Helvetica, sans-serif;
120:                  font-size: 11px;
121:                  }
122:                   -->
123:                  </style><table id='table_calendar'><tr id='calendar_tr'><td width='100'><b>" + "Month".t + "</b></td>"
124: 
125: 
126:        (1 .. 31).each do |days|
127: 
128:         content = content + "<td id='calendar' align='center'>" + days.to_s + "</td>"
129: 
130:       end
131:       content = content + "</tr></table>"
132: 
133:        (1 .. 12).each do |x|
134:         @month = month_vars(x, @year)
135:         content = content + "<table id='table_calendar'><tr id='calendar_tr'><td width='100'><b>" + @month["name"].t + "</b></td>"
136:          (1 .. @month["end"].to_i).each do |y|
137: 
138:           date = ::Date.new(@year.to_i,x,y).strftime(user.datestring)
139: 
140:           if (@calendar[x][y] == 1 || ::Date.new(@year.to_i,x,y) < ::DateTime.now-(1))
141:             content = content + "<td id='calendar_not_av' align='center' title='" + date + "'>B"
142:           elsif @calendar[x][y] == 2
143:             content = content + "<td id='calendar_av' align='center' title='" + date + "'>A"
144:           elsif @calendar[x][y] == 3
145:             content = content + "<td id='calendar_av' align='center' title='" + date + "'>D"
146:           else
147:             content = content + "<td id='calendar_av' align='center' title='" + date + "'>F"
148:           end
149:           content = content + "</td>"
150:         end
151:         content = content + "</tr> </table>"
152:       end
153:       render(:text => content)
154:     else
155:       render(:text => "Not logged in" + user.inspect)
156:     end
157:   end

[Validate]