Class: TimeTracker::TimeSheet

Inherits:
Object
  • Object
show all
Defined in:
lib/time_tracker.rb

Instance Method Summary collapse

Constructor Details

#initialize(month, config) ⇒ TimeSheet

Returns a new instance of TimeSheet.



96
97
98
99
# File 'lib/time_tracker.rb', line 96

def initialize month, config
  @month = month
  @config = config
end

Instance Method Details



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/time_tracker.rb', line 101

def print
  # you worked this month
  if @month.entries.length > 0 then	
	# get localized month name
	config = @config
	temp_name = @month.entries[0].start_time.strftime("%B")				
    month_name = config["time_sheet"][temp_name]
    # why namespace clashing here? 
    entries = @month.entries
    month = @month	      
    Prawn::Document.generate("#{month_name}.pdf") do
      #heading        
      font_size 16
      text "#{config["time_sheet"]["title"]}", :style => :bold, :align => :center
      font_size 12
      move_down 5
      text "#{config["time_sheet"]["name"]}: #{config["name"]}"
      text "#{config["time_sheet"]["month"]}: #{month_name}"
      text "#{config["time_sheet"]["monthly_working_time"]}: #{month.fixed_monthly_working_time}"
      text "#{config["time_sheet"]["department"]}: #{config["department"]}"
      table_data = Array.new
      # fill table header
      table_data.push [#{config["time_sheet"]["date"]}, 
      								 #{config["time_sheet"]["begin"]}, 
      								 #{config["time_sheet"]["end"]},
      								 #{config["time_sheet"]["description"]}, 
      								 #{config["time_sheet"]["hours_without_break"]},
      								 #{config["time_sheet"]["break_time"]}
      								 ]
      								 
      entries.each do |entry|
        row_data = Array.new
        row_data.push "#{entry.start_time.strftime("%d")}."
        row_data.push "#{entry.start_time.strftime("%H")}:#{entry.start_time.strftime("%M")}"
        row_data.push "#{entry.end_time.strftime("%H")}:#{entry.end_time.strftime("%M")}"
        row_data.push entry.summary
        row_data.push entry.duration
        row_data.push entry.break_time          
        table_data.push row_data
      end            
      move_down 5
      table table_data  
      move_down 5
      text "#{config["time_sheet"]["sum"]}: #{month.monthly_working_time}"
      move_down 5    
      text "#{config["time_sheet"]["carry"]}: #{month.global_offset}"
      move_down 50
      text "__________________________"
      text "#{config["time_sheet"]["correctness"]}"
      move_down 50
      text "__________________________"
      text "#{config["time_sheet"]["signature"]}"
    end
  end        
end