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_month(agent) ⇒ Object



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

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

#show_flexi_time(agent) ⇒ Object



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

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

#show_holiday_report(agent) ⇒ Object



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

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

#show_registered_hours_for_day(agent) ⇒ Object



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

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

#show_registered_hours_for_week(agent) ⇒ Object



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

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

#view_report(agent) ⇒ Object



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(agent)
  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