<div class="plans-menu">
  <ul>
    <% @plans.each do |plan| %>
      <%= content_tag :li,  link_to(h(plan.name), '#', "data-plan-id" => plan.id) %>
    <% end %>

    <p>
      <%= credit_card_stored_status(current_account, true).html_safe %>
    </p>

  </ul>
</div>

<div id="plans-content">

<% @plans.each do |plan| %>
  <div class='plan-preview' data-plan-id='<%= plan.id %>' style='display:none;'>
    <h2>
      <%= plan.name %>
    </h2>

    <div class='plan-overview'>
      <% unless plan.free? %>
        <%= render :partial => 'provider/admin/account/change_plans/widget/pricing',
                   :locals => {:plan => plan} %>
      <% end %>

      <% unless plan.usage_limits.visible.empty? %>
        <%= render :partial => 'provider/admin/account/change_plans/widget/limits',
                   :locals => {:plan => plan} %>
      <% end %>

      <% unless plan.issuer.features.visible.empty? %>
        <%= render :partial => 'provider/admin/account/change_plans/widget/features',
                   :locals => {:plan => plan} %>
      <% end %>
    </div>

    <% if current_account.can_upgrade_by_email?(plan) %>
      <p class='contact-by-email-notice'>
        Upgrading to enterprise plan cannot be done automatically. Please, contact
        <%= mail_to Rails.configuration.three_scale.sales_email %> to upgrade.
      </p>
    <% elsif current_account.can_upgrade_to?(plan) %>
      <% if current_account.credit_card_stored? %>
      <a href="#" class="select-plan-button plan-selector important-button"
         data-plan-name='<%= plan.name %>'
         data-plan-id='<%= plan.id %>'
         data-can-upgrade='true'>
        Upgrade to '<%= plan.name %>'
      </a>
      <% else %>
        <p id="credit-card-status">
          You need to <%= link_to('enter your billing information', edit_provider_admin_account_braintree_blue_path) %>
          in order to upgrade automatically.
        </p>
      <% end %>
    <% end %>

    <div class="current-plan-notice" style='display:none;'>
      <p>Your current plan</p>
    </div>

    <% if plan.system_name == "enterprise" -%>
      <div id="contact-3scale-to-be-enterprise">
	<p>To upgrade to enterprise, please contact
	  <%= mail_to Rails.configuration.three_scale.support_email %></p>
      </div>
    <% end -%>

  </div>
<% end %>
</div>

<%= javascript_tag do %>
  $(function(){
    PlanWidget.bind_events("plan-preview-box-new");
  });
<% end %>
