Module: Achoo::UI::Commands

Includes:
Common, DateChoosers
Included in:
App
Defined in:
lib/achoo/ui/commands.rb

Instance Method Summary collapse

Methods included from Common

#confirm

Methods included from DateChoosers

#date_chooser, #month_chooser, #optionally_ranged_date_chooser

Instance Method Details

#lock_monthObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/achoo/ui/commands.rb', line 33

def lock_month
  month = month_chooser
  form  = Achievo::LockMonthForm.new
  form.lock_month(month)
  form.print_values
  if confirm
    form.submit
  else
    puts "Cancelled"
  end
end

#show_flexi_timeObject



25
26
27
28
29
30
# File 'lib/achoo/ui/commands.rb', line 25

def show_flexi_time
  date = date_chooser
  form = Achievo::HourAdministrationForm.new
  balance = form.flexi_time(date)
  puts "Flexi time balance: #{Term::underline(balance)}"
end

#show_holiday_reportObject



46
47
48
49
50
# File 'lib/achoo/ui/commands.rb', line 46

def show_holiday_report
  page = AGENT.get(RC[:holiday_report_url])
  page.body.match(/<b>(\d+,\d+)<\/b>/)
  puts "Balance: #{Term::underline($1)}"
end

#show_registered_hours_for_dayObject



12
13
14
15
16
# File 'lib/achoo/ui/commands.rb', line 12

def show_registered_hours_for_day
  date = date_chooser
  form = Achievo::HourAdministrationForm.new
  form.show_registered_hours_for_day(date)
end

#show_registered_hours_for_weekObject



18
19
20
21
22
# File 'lib/achoo/ui/commands.rb', line 18

def show_registered_hours_for_week
  date = date_chooser
  form = Achievo::HourAdministrationForm.new
  form.show_registered_hours_for_week(date)
end

#view_reportObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/achoo/ui/commands.rb', line 53

def view_report
  choices = RC[:reports].keys
  answer = Term.choose('Report', choices)
  key = choices[answer.to_i - 1]
  
  puts "Fetching data ..."
  page = AGENT.get(RC[:url] + RC[:reports][key])
  
  table = Achievo::Table.new(page.search('#rl_1 tr'))
  table.select_columns do |c|
    ['Date', 'Project', 'Phase', 'Remark', 'Time'].include?(c[0])
  end
  
  Term::Table.new(table.first,
                  table[2...table.length-1],
                  table.last).print
end