# encoding: utf-8
class StaticFood < ActiveRecord::Base
  self.table_name = "static_foods"
  validates :source,presence: true

  TYPE_ENUM = [["早餐",1],["中餐",2],["晚餐",3]]



  rails_admin do
    navigation_label '食堂管理'
    weight -499
    list do
      filters [:source,:food_date]
      field :id
      field :food_date
      field :source, :enum do
        filterable true
        enum do
          TYPE_ENUM
        end
      end
      field :pre_nums
      field :single_nums
      field :nums
      field :comfirm_nums
      field :total do
        visible true
        label "金额(元)"
        formatted_value do
          value!=0 ? (value/100.0):0
        end
      end
      field :created_at
      # field :updated_at
    end
    show do
      field :id
      field :food_date
      field :source, :enum do
        filterable true
        enum do
          TYPE_ENUM
        end
      end
      field :pre_nums
      field :single_nums
      field :nums
      field :comfirm_nums
      field :total do
        visible true
        label "金额(元)"
        formatted_value do
          value!=0 ? (value/100.0):0
        end
      end
      field :created_at
      field :updated_at
    end
    edit do
      field :food_date
      field :source, :enum do
        filterable true
        enum do
          TYPE_ENUM
        end
      end
    end
  end
end
