Hi all,
Could any one help me how to edit all the timesheets at a time.
If i slect the month as december, i should get all teh timesheets from
the data base, I’m getting this one correctly, after getting this, i
should be able to edit these automatically all the timesheets.
See this is my controller::
def logic1
userId=@session[‘user’][‘id’]
user=User.find(userId)
#@timesheets = Timesheet.find(:all,:conditions=>[‘month(created_at)
= ?’, params[:timesheet][’:created_at(2i)’].to_i])
@timesheets = Timesheet.find_by_sql(“select * from timesheets where
user_id=’#{userId}’ and month(created_at)=
‘#{params[:timesheet][‘created_at(2i)’].to_i}’ and year(created_at)=
‘#{params[:timesheet][‘created_at(1i)’].to_i}’”)
@timesheets=Timesheet.find(@timesheets)
end
my rhtml file::
<%= link_to “Home”, :action=>“index”%>
Total hours worked in
<%=params[:timesheet][‘created_at(2i)’]%>th month of
Year <%=params[:timesheet][‘created_at(1i)’]%> =
<%=@total%> hours
<%= start_form_tag :action => ‘update’,:id=>@timesheets %>
Created At | Project | Hours Worked | Remarks |
---|---|---|---|
<%= date_select 'timesheet', 'created_at' %> | <%@projects=Project.find_all%><%= collection_select("timesheet", "project" , @projects, "name", "name") %> | <%= text_field 'timesheet', 'hours_worked', "size" => 31 %> | <%= text_area 'timesheet', 'remarks' ,"cols" => 22, "rows" => 5 %> |
<%= date_select 'timesheet', 'created_at' %> | <%@projects=Project.find_all%><%= collection_select("timesheet", "project" , @projects, "name", "name") %> | <%= text_field 'timesheet', 'hours_worked', "size" => 31 %> | <%= text_area 'timesheet', 'remarks' ,"cols" => 22, "rows" => 5 %> |
Thanks in Advance,
Harish