Hi does anybody know how to generate a time sheet? like starts from 8:00 Am 8:15 AM 8:30 AM - - - - - - - 6:00 PM Please advice Thanks Ajit --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Aug 9, 2:21 pm, Ajit <ajitscor...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> does anybody know how to generate a time sheet?How about using pencil and paper? :-) -- A --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ha... pretty funny... but thanks.. i will try another option --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Aug 9, 2:26 pm, Ajit <ajitscor...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ha... pretty funny...Well you kind of asked a silly question: "how to generate a time sheet?". Are you asking what software people use? Are you asking if there''s some Rails software that can do that? Are you asking about coding software to generate timesheets? Are you asking about generating documents? PDFs? When asking on a list, its often better to BE SPECIFIC. So what EXACTLY are you asking? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I am trying to generate a list which will start from 8:00 AM and goes upto 6:00 PM e.g. 8:00 AM 8:15 AM 8:30 AM - - - - - 6:00 PM thats all.. using a for loop or do loop Ajit --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
def self.showtime() time_options = [''----''] step_val = 15 start_val = "#{Time.now.strftime(''%d/%m/%Y'')} 8:00".to_time(:local) end_val = "#{Time.now.strftime(''%d/%m/%Y'')} 18:00".to_time(:local) start_val.step(end_val, step_val) do |val| time_options << val end @showtime = time_options end i want output as follows: 8:00 AM 8:15 AM - - - - 5:45 PM 6:00 PM please advice --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Thu, 2007-08-09 at 19:53 +0000, Ajit wrote:> I am trying to generate a list which will start from 8:00 AM and goes > upto 6:00 PM > > e.g. > > 8:00 AM > 8:15 AM > 8:30 AM > - > - > - > - > - > 6:00 PM > > thats all.. using a for loop or do loop---- a loop would make more sense, presuming you want to create an array of values to populate a selection list. not that I really believe that this is going to help much, I am including my "InOuts" controller code which uses a substantial amount of this type of coding for recording like a punch clock (time in and time out)...I record actual time and then reduce it to 15 minute increments after subtracting the time_in from the time_out. watch out for artificial line wrapping caused by e-mail client... also note that I switched from using RAILS date_time helpers to flextimes plugin and the RAILS date_time helpers are now commented out. Craig class InOutsController < ApplicationController skip_before_filter :authorize, :authenticate, :only => ''list'' # layout "users" session :off, :only => ''list'' def index list render :action => ''list'', :layout => "in_outs_forms" end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def list if params[:fi_facility].to_s != '''' fi_facility = params[:fi_facility] else fi_facility = ''Main Office'' end @pager = ::Paginator.new(User.count(:all, :conditions => ["personnels.facility = ?", fi_facility], :joins => ''LEFT JOIN personnels on personnels.id = personnel_id'' ), 7) do |offset, per_page| User.find(:all, :conditions => ["personnels.facility = ?", fi_facility], :joins => ''LEFT JOIN personnels on personnels.id = personnel_id'', :order => ''users.name'', :select => ''users.id AS id, users.personnel_id AS personnel_id, users.name AS name, users.in_out AS in_out, users.will_return AS will_return, personnels.facility AS facility, personnels.image AS image, users.personnel_id AS personnel'', :limit => per_page, :offset => offset) end @page = @pager.page(params[:page]) @in_outs = @pager.page(params[:page]) @fi_facility = fi_facility calc_date = (Time.now.monday - 2.days).to_date @date_range = [calc_date - 84, calc_date - 77, calc_date - 70, calc_date - 63, calc_date - 56, calc_date - 49, calc_date - 42, calc_date - 35, calc_date - 28, calc_date - 21, calc_date - 14] render :action => ''list'', :layout => "in_outs_forms" end def new @in_out = InOut.new render :action => ''new'', :layout => "in_outs_forms" end def create @in_out = InOut.new(params[:in_out]) if @in_out.save flash[:notice] = ''InOut was successfully created.'' redirect_to :action => ''list'' else render :action => ''new'' end end def edit @in_out = InOut.find(params[:id]) render :action => ''edit'', :layout => "in_outs_forms" end def edit_io @facility = Valuelist.find(:all, :conditions => ["list_name ''Facilities''"], :order => ''list_value'') @user = User.find_by_id(params[:id]) if @user.in_out == nil @in_out = InOut.new else @in_out = InOut.find(:first, :conditions => ["user_id = ?", params[:id] ], :order => ''pair_id DESC, id DESC'') end if @in_out == nil @in_out = InOut.new end if @in_out.time_in != nil @user.in_out = "Out" @in_out.message = ''Your last recorded time sheet entry '' + @in_out.time_in.strftime("%I:%M %p") + " on " + @in_out.time_in.strftime("%m-%d-%Y") + "<br /><strong>You are currently marked as ''In'', you probably want to clock ''Out'' from your last entry</strong>" @user.pair_id = @in_out.pair_id @user.ufacility = @in_out.facility # 2 choices for time automatically presented to users @user.data_time_date = Time.now # presents actual time # @user.data_time_date = @in_out.time_in # presents their clock in time elsif @in_out.time_out != nil @user.ufacility = @user.personnel.facility @user.data_time_date = Time.now @user.in_out = "In" @user.pair_id = @in_out.pair_id + 1 # @in_out.message = "Your last recorded time sheet entry was " + format_hours_minutes(@in_out.time_out) + " <br />You are currently marked as ''Out'', you probably want to check ''In''" @in_out.message = "Your last recorded time sheet entry was " + @in_out.time_out.strftime("%I:%M %p") + " on " + @in_out.time_out.strftime("%m-%d-%Y") +" <br /><strong>You are currently marked as ''Out'', you probably want to check ''In''</strong>" else @user.ufacility = @user.personnel.facility @user.data_time_date = Time.now @user.in_out = "In" @user.pair_id = 1 flash[:notice] = ''You have no previously recorded time sheet entries <br /> You want to check "In"'' end @user.rec_time = "Yes" @user.will_return = "" end def edit_in_out @in_out = InOut.new @in_out.user_id = params[:id] if (params[''user''][:data_time_date][''ampm''] == "PM" && params[''user''][:data_time_date][''hour''].to_i < 12) params[''user''][:data_time_date][''hour''] params[''user''][:data_time_date][''hour''].to_i + 12 end this_time = Time.local(params[''user''][:data_time_date][''year''], params[''user''][:data_time_date][''month''], params[''user''][:data_time_date][''day''], params[''user''][:data_time_date][''hour''].to_s, params[''user''][:data_time_date][''minute'']) # this_time = Time.local(params[''user''][''data_time_date(1i)''].to_i, # params[''user''][''data_time_date(2i)''].to_i, # params[''user''][''data_time_date(3i)''].to_i, # params[''user''][''data_time_date(4i)''].to_i, # params[''user''][''data_time_date(5i)''].to_i) if params[:user][:in_out] == "In" @in_out.time_in = this_time elsif params[:user][:in_out] == "Out" @in_out.time_out = this_time end @in_out.facility = params[:user][:ufacility] params[:user].delete("ufacility") # params[:user].delete("data_time_date(1i)") # params[:user].delete("data_time_date(2i)") # params[:user].delete("data_time_date(3i)") # params[:user].delete("data_time_date(4i)") # params[:user].delete("data_time_date(5i)") @in_out.subj_date = this_time.strftime("%m/%d/%Y") @in_out.pair_id = params[:user][:pair_id] @in_out.will_return = params[:user][:will_return] @in_out.updated_by = session[:user_name] @user = User.find_by_id(@in_out.user_id) # session[:test] = @in_out.user_id if params[:user][:rec_time] == "Yes" if params[:user][:in_out] == "Out" && InOut.find(:first, :conditions => ["user_id = ? AND pair_id = ?", params[:id], params[:user][:pair_id] ]) == nil flash[:notice] = "Your last recorded time sheet entry has you marked as ''Out''<br />You probably want to check ''In''" redirect_to :action => ''edit_io'', :id => @in_out.user_id return elsif params[:user][:in_out] == "In" && InOut.find(:first, :conditions => ["user_id = ? AND pair_id = ?", params[:id], params[:user][:pair_id] ]) != nil flash[:notice] = "Your last recorded time sheet entry has you marked as ''In''<br />You probably want to check ''Out''" # redirect_to :action => ''edit_io'', :id => @in_out.user_id redirect_to :back return end if params[:user][:in_out] == "Out" && InOut.find(:first, :conditions => ["user_id = ? AND pair_id = ?", params[:id], params[:user][:pair_id] ]).time_in > @in_out.time_out flash[:notice] = "You are trying to record an entry for" + format_date_and_time(@in_out.time_out) + " <br /> which is earlier than your last ''Time In'' entry shown below. <br /> It is assumed that this is not what you intended - try again" # redirect_to :action => ''edit_io'', :id => @in_out.user_id redirect_to :back return end if @in_out.save @user.update_attributes(params[:user]) flash[:notice] = ''In/Out was successfully recorded.'' # redirect_to :action => ''edit_io'' redirect_to :back else # render :action => ''edit_io'', :id => @in_out.user_id redirect_to :back end else @user.update_attributes(params[:user]) flash[:notice] = ''In/Out was successfully recorded.'' # redirect_to :action => ''edit_io'', :id => @in_out.user_id redirect_to :back end end def time_sheet_selected_week start_date = params[:in_out][:time_sheet_selected_week].to_date # start_date = start_date.strftime("%m/%d/%Y").to_date time_sheet start_date end def time_sheet_this_week start_date = Time.now.monday - 2.days start_date = start_date.strftime("%m/%d/%Y").to_date time_sheet start_date end def time_sheet_last_week start_date = Time.now.monday - 9.days start_date = start_date.strftime("%m/%d/%Y").to_date time_sheet start_date session[:st] = start_date end def time_sheet(start_day) @sat_day = start_day @sun_day = @sat_day + 1 @mon_day = @sat_day + 2 @tue_day = @sat_day + 3 @wed_day = @sat_day + 4 @thu_day = @sat_day + 5 @fri_day = @sat_day + 6 @user = User.find_by_id(params[:id]) @in_out_sat = InOut.find(:all, :conditions => ["user_id = ? AND subj_date = ?", params[:id], @sat_day], :order => "pair_id, updated_at") @in_out_sun = InOut.find(:all, :conditions => ["user_id = ? AND subj_date = ?", params[:id], @sun_day], :order => "pair_id, updated_at") @in_out_mon = InOut.find(:all, :conditions => ["user_id = ? AND subj_date = ?", params[:id], @mon_day], :order => "pair_id, updated_at") @in_out_tue = InOut.find(:all, :conditions => ["user_id = ? AND subj_date = ?", params[:id], @tue_day], :order => "pair_id, updated_at") @in_out_wed = InOut.find(:all, :conditions => ["user_id = ? AND subj_date = ?", params[:id], @wed_day], :order => "pair_id, updated_at") @in_out_thu = InOut.find(:all, :conditions => ["user_id = ? AND subj_date = ?", params[:id], @thu_day], :order => "pair_id, updated_at") @in_out_fri = InOut.find(:all, :conditions => ["user_id = ? AND subj_date = ?", params[:id], @fri_day], :order => "pair_id, updated_at") @tot_hrs_sat = tot_hrs_day @sat_day, params[:id] @tot_hrs_sun = tot_hrs_day @sun_day, params[:id] @tot_hrs_mon = tot_hrs_day @mon_day, params[:id] @tot_hrs_tue = tot_hrs_day @tue_day, params[:id] @tot_hrs_wed = tot_hrs_day @wed_day, params[:id] @tot_hrs_thu = tot_hrs_day @thu_day, params[:id] @tot_hrs_fri = tot_hrs_day @fri_day, params[:id] @tot_hrs_week = @tot_hrs_mon + @tot_hrs_tue + @tot_hrs_wed + @tot_hrs_thu + @tot_hrs_fri + @tot_hrs_sat + @tot_hrs_sun end def update @in_out = InOut.find(params[:id]) if @in_out.update_attributes(params[:in_out]) flash[:notice] = ''InOut was successfully updated.'' redirect_to :action => ''show'', :id => @in_out else render :action => ''edit'' end end def destroy InOut.find(params[:id]).destroy redirect_to :action => ''list'' end def show_person_week start_date = params[:in_out][:time_sheet_selected_week].to_date end_date = (params[:in_out][:time_sheet_selected_week].to_date + 7) @person = params[:in_out][:personnel] employee = User.find(:first, :conditions => ["name = ?", @person]).id cond = EZ::Where::Condition.new do user_id == employee subj_date <=> (start_date.. end_date) end @start_date = start_date @end_date = end_date @in_outs = InOut.find(:all, :conditions => cond.to_sql, :order => ''pair_id, id'') render :action => ''show_person_week'', :layout => "utilities" end def edit_io_record_in @facility = Valuelist.find(:all, :conditions => ["list_name ''Facilities''"], :order => ''list_value'') @user = User.find_by_id(params[:u_id]) @in_out = InOut.find(params[:id]) @in_out.message = "Now editing time record" render :action => ''edit_io_record_in'' end def edit_io_record_out @facility = Valuelist.find(:all, :conditions => ["list_name ''Facilities''"], :order => ''list_value'') @user = User.find_by_id(params[:u_id]) @in_out = InOut.find(params[:id]) @in_out.message = "Now editing time record" render :action => ''edit_io_record_out'' end def update_in @in_out = InOut.find(params[:id]) if (params[''in_out''][:time_in][''ampm''] == "PM" && params[''in_out''][:time_in][''hour''].to_i < 12) params[''in_out''][:time_in][''hour''] params[''in_out''][:time_in][''hour''].to_i + 12 end this_time = Time.local(params[''in_out''][:time_in][''year''], params[''in_out''][:time_in][''month''], params[''in_out''][:time_in][''day''], params[''in_out''][:time_in][''hour''].to_s, params[''in_out''][:time_in][''minute'']) @in_out.time_in = this_time @in_out.subj_date = this_time.strftime("%m/%d/%Y") @in_out.facility = params[:user][:ufacility] params[:user].delete("ufacility") @in_out.updated_by = session[:user_name] if @in_out.save flash[:notice] = ''In/Out was successfully recorded.'' # redirect_to :action => ''edit_io'' redirect_to :back else # render :action => ''edit_io'', :id => @in_out.user_id flash[:notice] = ''There was a problem recording your changes.'' redirect_to :back end end def update_out @in_out = InOut.find(params[:id]) if (params[''in_out''][:time_out][''ampm''] == "PM" && params[''in_out''][:time_out][''hour''].to_i < 12) params[''in_out''][:time_out][''hour''] params[''in_out''][:time_out][''hour''].to_i + 12 end this_time = Time.local(params[''in_out''][:time_out][''year''], params[''in_out''][:time_out][''month''], params[''in_out''][:time_out][''day''], params[''in_out''][:time_out][''hour''].to_s, params[''in_out''][:time_out][''minute'']) @in_out.time_out = this_time @in_out.subj_date = this_time.strftime("%m/%d/%Y") @in_out.facility = params[:user][:ufacility] params[:user].delete("ufacility") @in_out.updated_by = session[:user_name] if @in_out.save flash[:notice] = ''In/Out was successfully recorded.'' # redirect_to :action => ''edit_io'' redirect_to :back else # render :action => ''edit_io'', :id => @in_out.user_id flash[:notice] = ''There was a problem recording your changes.'' redirect_to :back end end private def tot_hrs_day(start_date, this_id) total_time = 0 @recs = InOut.find(:all, :conditions => ["user_id = ? AND subj_date = ? AND time_in IS NOT NULL", this_id, start_date]) for pair_total in @recs pair_amount = hrs_pair pair_total.pair_id, start_date, this_id total_time = pair_amount + total_time end # if total_time == 0 total_time # else # total_time.to_fl(2) # end end def hrs_pair(pair_id, start_date, this_id) @io = InOut.find(:all, :conditions => ["pair_id = ? AND subj_date = ? AND user_id = ?", pair_id, start_date, this_id], :order => ''updated_at DESC'') if @io[0][:time_out] == nil my_time = 0 else my_time = ((@io[0][:time_out] - @io[1][:time_in]) / 900.00 ).round * 0.25 end my_time end end -- Craig White <craig-CnJ8jr4MGtxl57MIdRCFDg@public.gmane.org> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
tmalone-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Aug-10 10:19 UTC
Re: generate time sheet
@Eno Don''t be such a dickhead. No one has time for that. It was obvious what Ajit was asking for. This is a Ruby on Rails discussion group,. It goes without saying that he wants to generate a timesheet with Rails. On Aug 9, 4:05 pm, Craig White <cr...-CnJ8jr4MGtxl57MIdRCFDg@public.gmane.org> wrote:> On Thu, 2007-08-09 at 19:53 +0000, Ajit wrote: > > I am trying to generate a list which will start from 8:00 AM and goes > > upto 6:00 PM > > > e.g. > > > 8:00 AM > > 8:15 AM > > 8:30 AM > > - > > - > > - > > - > > - > > 6:00 PM > > > thats all.. using a for loop or do loop > > ---- > a loop would make more sense, presuming you want to create an array of > values to populate a selection list. > > not that I really believe that this is going to help much, I am > including my "InOuts" controller code which uses a substantial amount of > this type of coding for recording like a punch clock (time in and time > out)...I record actual time and then reduce it to 15 minute increments > after subtracting the time_in from the time_out. > > watch out for artificial line wrapping caused by e-mail client... > > also note that I switched from using RAILS date_time helpers to > flextimes plugin and the RAILS date_time helpers are now commented out. > > Craig > > class InOutsController < ApplicationController > > skip_before_filter :authorize, :authenticate, :only => ''list'' > > # layout "users" > > session :off, :only => ''list'' > > def index > list > render :action => ''list'', :layout => "in_outs_forms" > end > > # GETs should be safe (seehttp://www.w3.org/2001/tag/doc/whenToUseGet.html) > verify :method => :post, :only => [ :destroy, :create, :update ], > :redirect_to => { :action => :list } > > def list > if params[:fi_facility].to_s != '''' > fi_facility = params[:fi_facility] > else > fi_facility = ''Main Office'' > end > @pager = ::Paginator.new(User.count(:all, > :conditions => ["personnels.facility = ?", fi_facility], > :joins => ''LEFT JOIN personnels on personnels.id = personnel_id'' > ), 7) do |offset, per_page| > User.find(:all, > :conditions => ["personnels.facility = ?", fi_facility], > :joins => ''LEFT JOIN personnels on personnels.id = personnel_id'', > :order => ''users.name'', > :select => ''users.id AS id, users.personnel_id AS personnel_id, > users.name AS name, users.in_out AS in_out, users.will_return AS > will_return, personnels.facility AS facility, personnels.image AS image, > users.personnel_id AS personnel'', > :limit => per_page, > :offset => offset) > end > @page = @pager.page(params[:page]) > @in_outs = @pager.page(params[:page]) > @fi_facility = fi_facility > calc_date = (Time.now.monday - 2.days).to_date > @date_range = [calc_date - 84, calc_date - 77, calc_date - 70, > calc_date - 63, calc_date - 56, calc_date - 49, calc_date - 42, > calc_date - 35, calc_date - 28, calc_date - 21, calc_date - 14] > render :action => ''list'', :layout => "in_outs_forms" > end > > def new > @in_out = InOut.new > render :action => ''new'', :layout => "in_outs_forms" > end > > def create > @in_out = InOut.new(params[:in_out]) > if @in_out.save > flash[:notice] = ''InOut was successfully created.'' > redirect_to :action => ''list'' > else > render :action => ''new'' > end > end > > def edit > @in_out = InOut.find(params[:id]) > render :action => ''edit'', :layout => "in_outs_forms" > end > > def edit_io > @facility = Valuelist.find(:all, :conditions => ["list_name > ''Facilities''"], :order => ''list_value'') > @user = User.find_by_id(params[:id]) > > if @user.in_out == nil > @in_out = InOut.new > else > @in_out = InOut.find(:first, :conditions => ["user_id = ?", > params[:id] ], :order => ''pair_id DESC, id DESC'') > end > > if @in_out == nil > @in_out = InOut.new > end > > if @in_out.time_in != nil > @user.in_out = "Out" > @in_out.message = ''Your last recorded time sheet entry '' + > @in_out.time_in.strftime("%I:%M %p") + " on " + > @in_out.time_in.strftime("%m-%d-%Y") + "<br /><strong>You are currently > marked as ''In'', you probably want to clock ''Out'' from your last > entry</strong>" > @user.pair_id = @in_out.pair_id > @user.ufacility = @in_out.facility > > # 2 choices for time automatically presented to users > @user.data_time_date = Time.now # presents actual time > # @user.data_time_date = @in_out.time_in # presents their clock in > time > elsif @in_out.time_out != nil > @user.ufacility = @user.personnel.facility > @user.data_time_date = Time.now > @user.in_out = "In" > @user.pair_id = @in_out.pair_id + 1 > # @in_out.message = "Your last recorded time sheet entry was " + > format_hours_minutes(@in_out.time_out) + " <br />You are currently > marked as ''Out'', you probably want to check ''In''" > @in_out.message = "Your last recorded time sheet entry was " + > @in_out.time_out.strftime("%I:%M %p") + " on " + > @in_out.time_out.strftime("%m-%d-%Y") +" <br /><strong>You are currently > marked as ''Out'', you probably want to check ''In''</strong>" > else > @user.ufacility = @user.personnel.facility > @user.data_time_date = Time.now > @user.in_out = "In" > @user.pair_id = 1 > flash[:notice] = ''You have no previously recorded time sheet > entries <br /> You want to check "In"'' > end > > @user.rec_time = "Yes" > @user.will_return = "" > end > > def edit_in_out > @in_out = InOut.new > @in_out.user_id = params[:id] > > if (params[''user''][:data_time_date][''ampm''] == "PM" && > params[''user''][:data_time_date][''hour''].to_i < 12) > params[''user''][:data_time_date][''hour''] > params[''user''][:data_time_date][''hour''].to_i + 12 > end > > this_time = Time.local(params[''user''][:data_time_date][''year''], > params[''user''][:data_time_date][''month''], > params[''user''][:data_time_date][''day''], > params[''user''][:data_time_date][''hour''].to_s, > params[''user''][:data_time_date][''minute'']) > > # this_time = Time.local(params[''user''][''data_time_date(1i)''].to_i, > # params[''user''][''data_time_date(2i)''].to_i, > # params[''user''][''data_time_date(3i)''].to_i, > # params[''user''][''data_time_date(4i)''].to_i, > # params[''user''][''data_time_date(5i)''].to_i) > > if params[:user][:in_out] == "In" > @in_out.time_in = this_time > elsif params[:user][:in_out] == "Out" > @in_out.time_out = this_time > end > @in_out.facility = params[:user][:ufacility] > params[:user].delete("ufacility") > # params[:user].delete("data_time_date(1i)") > # params[:user].delete("data_time_date(2i)") > # params[:user].delete("data_time_date(3i)") > # params[:user].delete("data_time_date(4i)") > # params[:user].delete("data_time_date(5i)") > @in_out.subj_date = this_time.strftime("%m/%d/%Y") > @in_out.pair_id = params[:user][:pair_id] > @in_out.will_return = params[:user][:will_return] > @in_out.updated_by = session[:user_name] > @user = User.find_by_id(@in_out.user_id) > # session[:test] = @in_out.user_id > if params[:user][:rec_time] == "Yes" > > if params[:user][:in_out] == "Out" && > InOut.find(:first, :conditions => ["user_id = ? AND pair_id = ?", > params[:id], params[:user][:pair_id] ]) == nil > flash[:notice] = "Your last recorded time sheet entry has you > marked as ''Out''<br />You probably want to check ''In''" > redirect_to :action => ''edit_io'', :id => @in_out.user_id > return > elsif params[:user][:in_out] == "In" && > InOut.find(:first, :conditions => ["user_id = ? AND pair_id = ?", > params[:id], params[:user][:pair_id] ]) != nil > flash[:notice] = "Your last recorded time sheet entry has you > marked as ''In''<br />You probably want to check ''Out''" > # redirect_to :action => ''edit_io'', :id => @in_out.user_id > redirect_to :back > return > end > > if params[:user][:in_out] == "Out" && > InOut.find(:first, :conditions => ["user_id = ? AND pair_id = ?", > params[:id], params[:user][:pair_id] ]).time_in > @in_out.time_out > flash[:notice] = "You are trying to record an entry for" + > format_date_and_time(@in_out.time_out) + " <br /> which is earlier than > your last ''Time In'' entry shown below. <br /> It is assumed that this is > not what you intended - try again" > # redirect_to :action => ''edit_io'', :id => @in_out.user_id > redirect_to :back > return > end > > if @in_out.save > @user.update_attributes(params[:user]) > flash[:notice] = ''In/Out was successfully recorded.'' > # redirect_to :action => ''edit_io'' > redirect_to :back > else > # render :action => ''edit_io'', :id => @in_out.user_id > redirect_to :back > end > else > @user.update_attributes(params[:user]) > flash[:notice] = ''In/Out was successfully recorded.'' > # redirect_to :action => ''edit_io'', :id => @in_out.user_id > redirect_to :back > end > end > > def time_sheet_selected_week > start_date = params[:in_out][:time_sheet_selected_week].to_date > # start_date = start_date.strftime("%m/%d/%Y").to_date > time_sheet start_date > end > > def time_sheet_this_week > start_date = Time.now.monday - 2.days > start_date = start_date.strftime("%m/%d/%Y").to_date > time_sheet start_date > end > > def time_sheet_last_week > start_date = Time.now.monday - 9.days > start_date = start_date.strftime("%m/%d/%Y").to_date > time_sheet start_date > session[:st] = start_date > end > > def time_sheet(start_day) > @sat_day = start_day > @sun_day = @sat_day + 1 > @mon_day = @sat_day + 2 > @tue_day = @sat_day + 3 > @wed_day = @sat_day + 4 > @thu_day = @sat_day + 5 > @fri_day = @sat_day + 6 > @user = User.find_by_id(params[:id]) > > @in_out_sat = InOut.find(:all, > :conditions => ["user_id = ? AND subj_date = ?", params[:id], > @sat_day], > :order => "pair_id, updated_at") > @in_out_sun = InOut.find(:all, > :conditions => ["user_id = ? AND subj_date = ?", params[:id], > @sun_day], > :order => "pair_id, updated_at") > @in_out_mon = InOut.find(:all, > :conditions => ["user_id = ? AND subj_date = ?", params[:id], > @mon_day], > :order => "pair_id, updated_at") > @in_out_tue = InOut.find(:all, > :conditions => ["user_id = ? AND subj_date = ?", > ... > > read more >>--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Aug 10, 6:19 am, "tmal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <tmal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> It was obvious what Ajit was asking for.After he explained what he meant, yes.> This is a Ruby on Rails discussion groupAnd his question was a Ruby question. Next time, you can keep your personal abusive remarks to yourself, thank you. -- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---