Add support for choosing what date/time is used for new entries
This commit is contained in:
parent
81e6db24ef
commit
49bfdff822
|
@ -3,6 +3,10 @@
|
||||||
# Time resolution in minutes
|
# Time resolution in minutes
|
||||||
#time_resolution: 1
|
#time_resolution: 1
|
||||||
|
|
||||||
|
# Which date to use for new entries
|
||||||
|
# Supported values are: previous, today, none
|
||||||
|
#date_new_entry: today
|
||||||
|
|
||||||
# The default hourly rate
|
# The default hourly rate
|
||||||
#hourly_rate: 20.0
|
#hourly_rate: 20.0
|
||||||
|
|
||||||
|
|
30
stoptime.rb
30
stoptime.rb
|
@ -166,6 +166,7 @@ module StopTime::Models
|
||||||
"invoice_template" => "invoice",
|
"invoice_template" => "invoice",
|
||||||
"hourly_rate" => 20.0,
|
"hourly_rate" => 20.0,
|
||||||
"time_resolution" => 1,
|
"time_resolution" => 1,
|
||||||
|
"date_new_entry" => "today",
|
||||||
"vat_rate" => 21.0 }
|
"vat_rate" => 21.0 }
|
||||||
|
|
||||||
# Creates a new configuration object and loads the configuation.
|
# Creates a new configuration object and loads the configuation.
|
||||||
|
@ -888,6 +889,22 @@ module StopTime::Models
|
||||||
|
|
||||||
end # StopTime::Models
|
end # StopTime::Models
|
||||||
|
|
||||||
|
# = The Stop… Camping Time! helpers
|
||||||
|
module StopTime::Helpers
|
||||||
|
|
||||||
|
def date_time_new_entry(last_entry = nil)
|
||||||
|
case @config["date_new_entry"]
|
||||||
|
when "previous"
|
||||||
|
TimeEntry.last.end
|
||||||
|
when "today"
|
||||||
|
DateTime.now
|
||||||
|
when "none"
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
# = The Stop… Camping Time! controllers
|
# = The Stop… Camping Time! controllers
|
||||||
module StopTime::Controllers
|
module StopTime::Controllers
|
||||||
|
|
||||||
|
@ -1550,9 +1567,11 @@ module StopTime::Controllers
|
||||||
@task_list[t.customer.shortest_name] << [t.id, t.name]
|
@task_list[t.customer.shortest_name] << [t.id, t.name]
|
||||||
end
|
end
|
||||||
@input["bill"] = true
|
@input["bill"] = true
|
||||||
@input["date"] = DateTime.now.to_date
|
date_time_new = date_time_new_entry(TimeEntry.last)
|
||||||
@input["start"] = Time.now.to_formatted_s(:time_only)
|
if date_time_new
|
||||||
|
@input["date"] = date_time_new.to_date.to_formatted_s
|
||||||
|
@input["start"] = date_time_new.to_formatted_s(:time_only)
|
||||||
|
end
|
||||||
@target = [Timeline]
|
@target = [Timeline]
|
||||||
@button = "enter"
|
@button = "enter"
|
||||||
render :time_entry_form
|
render :time_entry_form
|
||||||
|
@ -3123,6 +3142,7 @@ module StopTime::Views
|
||||||
# @param [Customer, nil] task a task to show time entries for
|
# @param [Customer, nil] task a task to show time entries for
|
||||||
# @return [Mab::Mixin::Tag] the main menu
|
# @return [Mab::Mixin::Tag] the main menu
|
||||||
def _time_entries(customer=nil, task=nil)
|
def _time_entries(customer=nil, task=nil)
|
||||||
|
date_time_new = date_time_new_entry(@time_entries.first)
|
||||||
form.form_inline action: R(Timeline), method: :post do
|
form.form_inline action: R(Timeline), method: :post do
|
||||||
table.table.table_condensed.table_striped.table_hover do
|
table.table.table_condensed.table_striped.table_hover do
|
||||||
thead do
|
thead do
|
||||||
|
@ -3156,11 +3176,11 @@ module StopTime::Views
|
||||||
end
|
end
|
||||||
td.col_md_1 do
|
td.col_md_1 do
|
||||||
input.form_control type: :text, name: "date",
|
input.form_control type: :text, name: "date",
|
||||||
value: DateTime.now.to_date.to_formatted_s
|
value: date_time_new && date_time_new.to_date.to_formatted_s
|
||||||
end
|
end
|
||||||
td.col_md_1 do
|
td.col_md_1 do
|
||||||
input.form_control type: :text, name: "start",
|
input.form_control type: :text, name: "start",
|
||||||
value: DateTime.now.to_time.to_formatted_s(:time_only)
|
value: date_time_new && date_time_new.to_formatted_s(:time_only)
|
||||||
end
|
end
|
||||||
td.col_md_1 do
|
td.col_md_1 do
|
||||||
input.form_control type: :text, name: "end"
|
input.form_control type: :text, name: "end"
|
||||||
|
|
Loading…
Reference in New Issue