# encoding: UTF-8
#encoding: utf-8
class StartController < ApplicationController
  before_action :login_required

  layout "application"

  include ApplicationHelper

  def index
    user = theUser(session)
    last_version = user.version
    unless (last_version == ::VERSION)
      @versions = []
      # ::VERSIONS are defined in the ApplicationController
      ::VERSIONS.each do |v|
        if (v[0] > last_version) && (v[0] <= ::VERSION)
          @versions.unshift(v)
        end
      end
      user.update_attributes(:version => ::VERSION)
    end
  end

  def versions
    last_version = "0.1.0"
    unless (last_version == ::VERSION)
      @versions = []
      ::VERSIONS.each do |v|
        if (v[0] > last_version) && (v[0] <= ::VERSION)
          @versions.push(v)
        end
      end
    end
  end

  def impressum

  end

  def required_fields
    @cols = ActiveRecord::Base.connection.execute("SELECT * FROM model.columns WHERE visibility = 1 ORDER BY table_name, field_mode DESC, order_key")
  end

end
