class Ability
  include CanCan::Ability

  def initialize(user)
    user ||= Employee.new

    if user.role == "administrator"

        can :manage, :all

    elsif user.role == "manager"

        can :manage, Menu
        can :manage, MenuCategory
        can :manage, MenuItemAttribute
        can :manage, MenuItemInstance
        can :manage, MenuItemOption
        can :manage, SetMenuItem
        can :manage, OrderQueueStation
        can :manage, Zone
        can :manage, CashierTerminal
        can :manage, Employee
        # can :manage, MembershipSetting
        # can :manage, MembershipAction
        # can :manage, PaymentMethodSetting
        can :manage, TaxProfile
        can :manage, PrintSetting
        can :manage, Account

        can :manage, Order
        can :manage, Sale

        can :manage, Customer
        can :manage, DiningQueue

        can :index, :dailysale
        can :index, :saleitem
        can :index, :receipt_no
        can :index, :shiftsale

        can :add_customer, Customer  
        can :update_sale_by_customer, Customer  

        can :index, :other_charge
        can :create, :other_charge
        can :index, :discount
        can :create, :discount
        can :remove_discount_items, :discount
        can :remove_all_discount, :discount

        can :first_bill, :payment
        can :show, :payment
        can :create, :payment
        can :reprint, :payment
        can :rounding_adj, :payment

        can :move_dining, :movetable 
        can :moving, :movetable

        can :move_dining, :moveroom

        can :edit, :sale_edit
        can :item_void, :sale_edit
        can :item_void_cancel, :sale_edit
        can :cancel_all_void, :sale_edit
        can :apply_void, :sale_edit

        can :overall_void, :void

    elsif user.role == "cashier"

        can :read, Order
        can :update, Order
      
        can :read, Sale  
        can :update, Sale      
      
        can :add_customer, Customer  
        can :update_sale_by_customer, Customer  

        can :index, :other_charge
        can :create, :other_charge
        can :index, :discount
        can :create, :discount
        can :remove_discount_items, :discount
        can :remove_all_discount, :discount

        can :first_bill, :payment
        can :show, :payment
        can :create, :payment
        can :reprint, :payment
        can :rounding_adj, :payment

        can :move_dining, :movetable 
        can :moving, :movetable

        can :move_dining, :moveroom

        can :first_bill, :payment
        can :show, :payment
        can :create, :payment
        can :reprint, :payment
                                               
    elsif user.role == "accountant"

        can :index, :dailysale
        can :index, :saleitem
        can :index, :receipt_no
        can :index, :shiftsale

    elsif user.role == "supervisour"

        can :index, :dailysale
        can :index, :saleitem
        can :index, :receipt_no
        can :index, :shiftsale        

    end

  end

end
