Class: ODDB::View::Companies::FiPiCsv

Inherits:
HtmlGrid::Component show all
Includes:
AdditionalInformation, FiPiMethods
Defined in:
src/view/companies/fipi_csv.rb

Constant Summary

COMPONENTS =
[
  :name_base,
  :galenic_form,
  :dose,
  :comparable_size,
  :barcode,
  :swissmedic_numbers,
  :date_fi_de,
  :date_fi_fr,
  :date_pi_de,
  :date_pi_fr,
]

Instance Method Summary (collapse)

Methods included from FiPiMethods

#date_fi_de, #date_fi_fr, #date_pi_de, #date_pi_fr, #info_date, #swissmedic_numbers

Methods included from AdditionalInformation

#_fachinfo, #atc_ddd_link, #atc_description, #comarketing, #complementary_type, #compositions, #ddd_price, #deductible, #fachinfo, #feedback, #google_search, #ikscat, #limitation_link, #limitation_text, #minifi, #narcotic, #notify, #patent, #patinfo, #qty_unit, #square, #twitter_share

Methods included from PartSize

#comparable_size, #part_size

Methods included from Drugs::AtcDddLink

#atc_ddd_link

Methods inherited from HtmlGrid::Component

#additional_javascripts, #dynamic_html

Instance Method Details

- (Object) http_headers



27
28
29
30
31
32
33
# File 'src/view/companies/fipi_csv.rb', line 27

def http_headers
  name = @model.name.gsub(/[\s]+/u, '_')
  {
    'Content-Type'         =>  'text/csv',
    'Content-Disposition'  =>  "attachment;filename=#{name}.csv",
  }
end

- (Object) to_csv(keys)



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'src/view/companies/fipi_csv.rb', line 34

def to_csv(keys)
  result = ''
  lang = @session.language
  CSV::Writer.generate(result, ';') { |writer|
    writer << [@lookandfeel.lookup(:fachinfos), model.fi_count]
    writer << [@lookandfeel.lookup(:patinfos), model.pi_count]
    writer << keys.collect { |key| 
      @lookandfeel.lookup("th_#{key}") { key.to_s }
    }
    @model.packages.each { |pac|
      writer << keys.collect { |key|
        if(self.respond_to?(key))
          item = self.send(key, pac)
          case item
          when SimpleLanguage
            item.send(lang)
          when HtmlGrid::Value
            item.value
          else
            item
          end
        else
          pac.send(key)
        end.to_s
      }
    }
  }
  result
end

- (Object) to_html(context)



63
64
65
# File 'src/view/companies/fipi_csv.rb', line 63

def to_html(context)
  to_csv(COMPONENTS)
end