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

  TYPE_ENUM = [["早餐",1],["中餐",2],["晚餐",3]]
  SINGLE_ENUM = [["预订",false],["单点",true]]
  STATUS_ENUM = [["待用餐",1],["已用餐",2],["已过期",3],["已退餐",4]]


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