Added seperate date support for time entries.

This commit is contained in:
Paul van Tilburg 2011-11-11 14:55:17 +01:00
parent 8b00714bf3
commit 8ddd31f662
2 changed files with 51 additions and 15 deletions

View File

@ -38,6 +38,7 @@ unless defined? PUBLIC_DIR
:default => "%Y-%m-%d %H:%M",
:month_and_year => "%B %Y",
:date_only => "%Y-%m-%d",
:time_only => "%H:%M",
:day_code => "%Y%m%d")
ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS.merge!(
:default => "%Y-%m-%d",
@ -328,6 +329,20 @@ module StopTime::Models
end
end
class TimeEntryDateSupport < V 1.8 # :nodoc:
def self.up
add_column(TimeEntry.table_name, :date, :datetime)
TimeEntry.all.each do |te|
te.date = te.start.at_beginning_of_day
te.save
end
end
def self.down
remove_column(TimeEntry.table_name, :date)
end
end
end # StopTime::Models
# = The Stop… Camping Time! controllers
@ -787,8 +802,10 @@ module StopTime::Controllers
# If the provided information was invalid, the errors are retrieved.
def post
if @input.has_key? "enter"
@time_entry = TimeEntry.create(
:task_id => @input.task,
:date => @input.date,
:start => @input.start,
:end => @input.end,
:comment => @input.comment,
@ -1075,6 +1092,7 @@ module StopTime::Views
h2 "Timeline"
table.timeline do
col.task {}
col.date {}
col.start_time {}
col.end_time {}
col.comment {}
@ -1082,6 +1100,7 @@ module StopTime::Views
col.flag {}
tr do
th "Project/Task"
th "Date"
th "Start time"
th "End time"
th "Comment"
@ -1091,10 +1110,11 @@ module StopTime::Views
form :action => R(Timeline), :method => :post do
tr do
td { _form_select("task", @task_list) }
td { input :type => :text, :name => "date",
:value => DateTime.now.to_date.to_formatted_s }
td { input :type => :text, :name => "start",
:value => DateTime.now.to_date.to_formatted_s + " " }
td { input :type => :text, :name => "end",
:value => DateTime.now.to_date.to_formatted_s + " " }
:value => DateTime.now.to_time.to_formatted_s(:time_only) }
td { input :type => :text, :name => "end" }
td { input :type => :text, :name => "comment" }
td { "N/A" }
td { _form_input_checkbox("bill") }
@ -1108,9 +1128,10 @@ module StopTime::Views
tr do
td { a entry.task.name,
:href => R(CustomersNTasksN, entry.customer.id, entry.task.id) }
td { a entry.start,
td { a entry.date.to_date,
:href => R(TimelineN, entry.id) }
td { entry.end }
td { entry.start.to_formatted_s(:time_only) }
td { entry.end.to_formatted_s(:time_only)}
td { entry.comment }
td { "%.2fh" % entry.hours_total }
td do
@ -1439,6 +1460,7 @@ module StopTime::Views
h2 "Registered Time"
table.time_entries do
col.flag {}
col.date {}
col.start_time {}
col.end_time {}
col.comment {}
@ -1446,6 +1468,7 @@ module StopTime::Views
col.amount {}
tr do
th ""
th "Date"
th "Start time"
th "End time"
th "Comment"
@ -1460,7 +1483,9 @@ module StopTime::Views
@hourly_rate_tasks[task].each do |entry|
tr do
td { _form_input_checkbox("time_entries[]", entry.id) }
td { label entry.start, :for => "time_entries[]_#{entry.id}" }
td { label entry.date.to_date,
:for => "time_entries[]_#{entry.id}" }
td { entry.start }
td { entry.end }
td { entry.comment }
td.right { "%.2fh" % entry.hours_total }

View File

@ -57,19 +57,21 @@ ol#menu
padding-bottom: 6px
background: $light-grey
/* Table layout */
/* Table layout */
table
padding: 3px 0px
border-spacing: 0px 4px
col.amount, col.hours, col.hourly_rate
width: 15%
width: 10%
col.flag
width: 3%
width: 4%
col.date
width: 8%
col.start_time, col.end_time
width: 15%
width: 5%
col.comment
width: 30%
width: 20%
col.task
width: 25%
col.name, col.period
@ -78,7 +80,7 @@ table
width: 20%
col.address
width: 20%
col.email, col.phone, col.date
col.email, col.phone
width: 15%
col.number
width: 7%
@ -99,9 +101,11 @@ table
width: 50%
td
padding: 0px 5px
vertical-align: top
th
padding: 0px 5px
text-align: left
background: $dark-grey
@ -113,8 +117,14 @@ table
width: 80px
padding-bottom: 5px
input
width: 100%
input[type="submit"], input[type="reset"]
width: auto
/* Form layout */
form
form
ol
list-style: none
padding: 10px
@ -125,8 +135,6 @@ form
margin-right: 10px
float: left
input, select
width: 250px
ol.radio
margin-left: 195px
@ -141,5 +149,8 @@ form
li
padding-bottom: 10px
input, select
width: 250px
input[type="submit"], input[type="reset"]
width: auto