ActiveAdmin.register User, :as => 'User_Override' do

  menu :label => 'Subscription', :parent => 'Users'

  form title: 'Use This To Give a No-Payment Subscription' do |f|
    inputs 'Details' do
      input :admin_override_touch, :as => :hidden, value: 'true'
      input :admin_override_reason, :as => :text
      input :admin_override_plan_code, :as => :select, :collection => SubscriptionDefinitions::MONTHLY_PLANS + ['Remove Override']
      input :admin_override_ends_at, as: :datepicker,
              datepicker_options: {
                  min_date: Date.today,
                  max_date: "+10Y"
              }
      li "User has admin override set to #{f.object.admin_override_plan_code}. Lasts until #{f.object.admin_override_ends_at}" if !f.object.admin_override_plan_code.nil?
      li "User does not have admin override.  They are currently on the #{f.object.subscription_plan_code ? f.object.subscription_plan_code : 'Free'} plan" if f.object.admin_override_plan_code.nil?
    end
    panel 'Instructions' do
      "If you select a plan, the user will have their current subscription (if any) cancelled and set to the new plan for free.  If you instead select Remove Override, you can cancel the gifted plan and the user will be o normal free-tier user again."
    end
    para "Press cancel to return to the list without saving."
    actions
  end

end

