Skip to content

Fix 'uninitialized constant Timesheet::FCSV'; fixes #58 #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app/helpers/timesheet_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ def link_to_csv_export(timesheet)
:class => 'icon icon-timesheet')
end

def form_for_to_timesheet(timesheet)
params_like_decode_url = CGI.unescape({:timesheet => timesheet.to_param}.to_query)
inputs = ""
form = form_tag :controller => 'timesheet', :action => 'report' do
params_like_decode_url.split("&").each do |param|
param_arr = param.split("=")
inputs << hidden_field_tag(param_arr.first, param_arr.last, :id => "")
end
inputs << submit_tag(l(:timesheet_permalink))
inputs.html_safe
end
form.html_safe
end


def toggle_arrows(element, js_function)
js = "#{js_function}('#{element}');"

Expand Down
14 changes: 14 additions & 0 deletions app/models/timesheet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,20 @@ def to_param

def to_csv
out = "";


handle_time_entries = {}
time_entries.each do |k,v|
if k.is_a? String
handle_time_entries[k] = v
next;
end
handle_time_entries[k.name] = v
end

time_entries = handle_time_entries


FCSV.generate(out, :encoding => 'utf-8', :force_quotes => true) do |csv|
csv << csv_header

Expand Down
2 changes: 1 addition & 1 deletion app/views/timesheet/report.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="contextual">
<%= link_to_csv_export(@timesheet) %>
<%= permalink_to_timesheet(@timesheet) %>
<%= form_for_to_timesheet(@timesheet) %>
</div>

<h2><%= l(:timesheet_title)%></h2>
Expand Down
14 changes: 7 additions & 7 deletions init.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
require 'redmine'

## Taken from lib/redmine.rb
#if RUBY_VERSION < '1.9'
# require 'faster_csv'
#else
# require 'csv'
# FCSV = CSV
#end
# Taken from lib/redmine.rb
if RUBY_VERSION < '1.9'
require 'faster_csv'
else
require 'csv'
FCSV = CSV
end

if Rails::VERSION::MAJOR < 3
require 'dispatcher'
Expand Down