Skip to content

Commit

Permalink
changedate
Browse files Browse the repository at this point in the history
  • Loading branch information
LED committed May 4, 2012
1 parent 89056c9 commit 321642e
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 25 deletions.
28 changes: 14 additions & 14 deletions app/admin/reservations.rb
Expand Up @@ -11,11 +11,11 @@
column "Guest Name", :name, :sortable => false
column "Service Type", :service, :sortable => false
column "Booked Date", :date, :sortable => false
column "Time Start", :timeStart, :sortable => false do |ts|
ts.timeStart.strftime('%l:%M - %P')
column "Time Start", :time_start, :sortable => false do |ts|
ts.time_start.strftime('%l:%M - %P')
end
column "Time End",:timeEnd, :sortable => false do |te|
te.timeEnd.strftime('%l:%M - %P')
column "Time End",:time_end, :sortable => false do |te|
te.time_end.strftime('%l:%M - %P')
end
column "Number of guest", :numGuest, :sortable => false
column "Last update", :updated_at, :sortable => false
Expand Down Expand Up @@ -50,11 +50,11 @@
row :address
row :contact
row :date
row :timeStart do |ts|
ts.timeStart.strftime('%l:%M - %P')
row :time_start do |ts|
ts.time_start.strftime('%l:%M - %P')
end
row :timeEnd do |te|
te.timeEnd.strftime('%l:%M - %P')
row :time_end do |te|
te.time_end.strftime('%l:%M - %P')
end
row :created_at
row :service
Expand All @@ -76,11 +76,11 @@
column :date do |d|
d.date.strftime("%B %d,%Y")
end
column :timeStart do |ts|
ts.timeStart.strftime('%l:%M - %P')
column :time_start do |ts|
ts.time_start.strftime('%l:%M - %P')
end
column :timeEnd do |time|
time.timeEnd.strftime('%l:%M - %P')
column :time_end do |time|
time.time_end.strftime('%l:%M - %P')
end
column :numGuest
column :service do |s|
Expand Down Expand Up @@ -116,8 +116,8 @@
f.input :date, :as => :date, :hint => 'Select a date',
:prompt => {:day => "Day", :month => "Month", :year => "Year"},
:start_year => Time.now.year
f.input :timeStart ,:label => "Time Start", :twelve_hour => true
f.input :timeEnd ,:label => "Time End" , :twelve_hour => true
f.input :time_start ,:label => "Time Start", :twelve_hour => true
f.input :time_end ,:label => "Time End" , :twelve_hour => true
f.input :numGuest, :as => :string
f.input :email
end
Expand Down
6 changes: 3 additions & 3 deletions app/models/reservation.rb
Expand Up @@ -11,8 +11,8 @@ class Reservation < ActiveRecord::Base
has_many :reservation_recipes, :dependent => :destroy

##### validation #####
validates :timeStart,:timeEnd, :overlap => {:scope => :date,:message => "time already taken"}
validates :name,:address,:contact,:email,:date,:timeStart,:timeEnd,:numGuest,:reservation_option,:service,:presence => :true
validates :time_start,:time_end, :overlap => {:scope => :date,:message => "time already taken"}
validates :name,:address,:contact,:email,:date,:time_start,:time_end,:numGuest,:reservation_option,:service,:presence => :true
# validates_numericality_of :contact , :only_integer => true, :message => "must be numbers only."
#validates_format_of :name, :with => /^[-a-z]+$/
#validates_format_of :numGuest, :with => /[0-9]/
Expand Down Expand Up @@ -69,7 +69,7 @@ def remove_all_associated(reservation_id)
end

def compute_for_total_hours
differences=Time.diff(Time.parse(self.timeStart.to_s), Time.parse(self.timeEnd.to_s))
differences=Time.diff(Time.parse(self.time_start.to_s), Time.parse(self.time_end.to_s))
min = ("." +"#{differences[:minute]}").to_d
min = min / ".60".to_d
min = sprintf("%.1f",(min))
Expand Down
4 changes: 2 additions & 2 deletions app/views/reservations/_form.html.erb
Expand Up @@ -55,11 +55,11 @@
</tr>
<tr>
<td>Event Time Start*</td>
<td><%= f.time_select :timeStart, :class => 'time_select' ,:twelve_hour => true, :prompt => {:hour => "00", :minute => "00"}%></td>
<td><%= f.time_select :time_start, :class => 'time_select' ,:twelve_hour => true, :prompt => {:hour => "00", :minute => "00"}%></td>
</tr>
<tr>
<td>Event Time End*</td>
<td><%= f.time_select :timeEnd, :class => 'time_select', :twelve_hour => true , :prompt => {:hour => "00", :minute => "00"} %></td>
<td><%= f.time_select :time_end, :class => 'time_select', :twelve_hour => true , :prompt => {:hour => "00", :minute => "00"} %></td>
</tr>
<tr>
<td>Number of Guest expected Guest*</td>
Expand Down
4 changes: 2 additions & 2 deletions app/views/reservations/index.html.erb
Expand Up @@ -39,8 +39,8 @@
<% @reservations.each do |reservation| %>
<tr>
<td><%= reservation.date.strftime("%B %d,%Y") %></td>
<td><%= reservation.timeStart.strftime('%l:%M - %P') %></td>
<td><%= reservation.timeEnd.strftime('%l:%M - %P') %></td>
<td><%= reservation.time_start.strftime('%l:%M - %P') %></td>
<td><%= reservation.time_end.strftime('%l:%M - %P') %></td>
</tr>
<% end %>
</tbody>
Expand Down
6 changes: 3 additions & 3 deletions app/views/reservations/show.html.erb
Expand Up @@ -26,12 +26,12 @@


<tr>
<td colspan="2"><strong>Time Start: </strong> <%= @reservation.timeStart.strftime('%l:%M - %P')%></td>
<td colspan="2"><strong>Time Start: </strong> <%= @reservation.time_start.strftime('%l:%M - %P')%></td>
<td>&nbsp;</td>
<td colspan="3"><strong>Time End: </strong><%= @reservation.timeEnd.strftime('%l:%M - %P')%></td>
<td colspan="3"><strong>Time End: </strong><%= @reservation.time_end.strftime('%l:%M - %P')%></td>
</tr>
<tr>
<td><strong>Total Hours you will render: </strong><%timex=Time.diff(Time.parse(@reservation.timeStart.to_s), Time.parse(@reservation.timeEnd.to_s), '%H %N')%>
<td><strong>Total Hours you will render: </strong><%timex=Time.diff(Time.parse(@reservation.time_start.to_s), Time.parse(@reservation.time_end.to_s), '%H %N')%>
<%= timex[:diff]%></td>
</tr>

Expand Down
6 changes: 6 additions & 0 deletions db/migrate/20120504055702_add_time_start_to_reservation.rb
@@ -0,0 +1,6 @@
class AddTimeStartToReservation < ActiveRecord::Migration
def change
add_column :reservations, :time_start, :time

end
end
6 changes: 6 additions & 0 deletions db/migrate/20120504055739_add_time_end_to_reservation.rb
@@ -0,0 +1,6 @@
class AddTimeEndToReservation < ActiveRecord::Migration
def change
add_column :reservations, :time_end, :time

end
end
4 changes: 3 additions & 1 deletion db/schema.rb
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20120502162152) do
ActiveRecord::Schema.define(:version => 20120504055739) do

create_table "active_admin_comments", :force => true do |t|
t.string "resource_id", :null => false
Expand Down Expand Up @@ -314,6 +314,8 @@
t.decimal "total_price", :precision => 10, :scale => 0, :default => 0
t.date "booked_at"
t.boolean "reservation_option"
t.time "time_start"
t.time "time_end"
end

create_table "services", :force => true do |t|
Expand Down

0 comments on commit 321642e

Please sign in to comment.