#encoding
module RailsAdmin
  module Config
    module Actions

      class RefuseTakecash < RailsAdmin::Config::Actions::Base
        # RailsAdmin::Config::Actions.register(self)
        register_instance_option :visible?  do
          if not bindings[:object].blank?
            authorized? && bindings[:object].pay_state==0 && bindings[:object].audit_state == 0    
          else
            authorized?
          end
        end

        register_instance_option :member do
          true
        end

        register_instance_option :link_icon do
          'icon-thumbs-down'
        end

        register_instance_option :pjax? do
          false
        end

        register_instance_option :controller do
          Proc.new do
            if @object.pay_state==0 && @object.audit_state == 0
              render "rails_admin/cash_balance/refuse_takecash"
            else                    
              redirect_to "#{CONFIG_FILE["admin_host"]}/admin/take_cash_order", notice: "拒绝失败（或重复拒绝）"
            end
          end
        end

      end

    end
  end
end