# -*- coding: utf-8 -*-
#
# This file is part of the "e-PRTR P-Modul Datenbank Generator".
# For more information, see the release information on main.en.rb. 
#
# Diese Datei ist Teil des "e-PRTR P-Modul Datenbank Generator".
# Fuer weitere Informationen und Release-Informationen siehe mein.en.rb.
#

class Betrieb < Entry
#  attr_accessor :taet, :freis, :vabw, :vabf
#  @initialized = false
  def write_out
    $db_target.execute("INSERT INTO facilities (
      id,
      year,
      name,
      administrative_number,
      wgs84_x,
      wgs84_y,
      street,
      house_number,
      postcode,
      city,
      federal_state,
      river_basin,
      parent_company,
      owner,
      operator,
      production_volume,
      number_of_production_lines,
      operating_hours,
      prtr_info,
      nace_code,
      nace_text,
      predecessor_id
      ) VALUES (
      #{sqlize('id')},
      #{sqlize('jahr')},
      #{sqlize('name')},
      #{sqlize('kennnr')},
      #{sqlize('geo_x')},
      #{sqlize('geo_y')},
      #{sqlize('street')},
      #{sqlize('house_number')},
      #{sqlize('postcode')},
      #{sqlize('city')},
      #{sqlize('buland')},
      #{sqlize('flusseinzugsgebiet')},
      #{sqlize('muttergesellschaft')},
      #{sqlize('eigname')},
      #{sqlize('betname')},
      #{sqlize('prodvol')},
      #{sqlize('anlzahl')},
      #{sqlize('betriebh')},
      #{sqlize('prtrinfo')},
      #{sqlize('nace_key')},
      #{sqlize('nace_text')},
      #{sqlize('p_betrieb_vorgaenger_id')}
      )")
    @geheimk.each do |gk|
      $db_target.execute("INSERT INTO facilities_pdcc (facility_id, reason) VALUES (#{@data['id']},'#{gk[1]}')")
    end

  end

end
