Fonteijne

rails

Jun 4th, 2013
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 1.45 KB | None | 0 0
  1. # -----------------
  2. # Controller.rb
  3. # -----------------
  4. gtbl = Calculations::GoogleTable.new()
  5. @data = gtbl.get_data(current_user.regio, @start_date, @end_date, @is_paid, @open)
  6.  
  7. g = GoogleVisualr::DataTable.new()
  8. g.new_column('string', 'Fac. nr.')
  9. g.new_column('date', 'Fac. datum')
  10. g.new_column('boolean', 'Bet.')
  11. g.new_column('string', 'Bet. op')
  12. g.new_column('number', 'Klnr')
  13. g.new_column('string', 'Klant')
  14. g.new_column('string', 'Student')
  15. g.new_column('number', 'Uren')
  16. g.new_column('number', 'Marge')
  17. g.new_column('number', 'Bruto')
  18. g.new_column('number', 'BTW')
  19. g.new_column('number', 'Netto')
  20. g.new_column('number', 'Verg. St.')
  21. g.new_column('number', 'Bem.fee')
  22. g.new_column('number', 'Werving')
  23.  
  24.     g.add_rows(@data)
  25.     options_g = {
  26.         :width => "100%",
  27.         :height => "560px",
  28.         #:page => 'enable',
  29.         #:pageSize => 20,
  30.     }
  31.     options_g[:sortColumn] = 1
  32.     options_g[:sortColumn] = 3 if @is_paid
  33.  
  34.     @table = GoogleVisualr::Interactive::Table.new(g, options_g)
  35.     @table.add_listener("select", "function(e) {tableRegiofactuursEventHandler(e, chart, data_table)}")
  36.  
  37.  
  38. # -----------------
  39. # google_table.rb
  40. # -----------------
  41. def get_data regio = 0, start_date = nil, end_date = nil, is_paid = false, is_open = false
  42.   ret = []
  43.   (0..1000).to_a.each do |i|
  44.     ret.push [i, DateTime.now, true, DateTime.now + 2.days, i+1230000, 'John Doe', 'Foo Bar', i, i, i, i, i, i, i, i]
  45.   end
  46.   ret
  47. end
Advertisement
Add Comment
Please, Sign In to add comment