{{ header }}
<div id="account-payment-method" class="container">
  <ul class="breadcrumb">
    {% for breadcrumb in breadcrumbs %}
      <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
    {% endfor %}
  </ul>
  {% if attention %}
    <div class="alert alert-info"><i class="fa fa-info-circle"></i> {{ attention }}
      <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
  {% endif %}
  {% if success %}
    <div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> {{ success }}
      <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
  {% endif %}
  <div class="row">{{ column_left }}
    {% if column_left and column_right %}
      {% set class = 'col-sm-6' %}
    {% elseif column_left or column_right %}
      {% set class = 'col-sm-9' %}
    {% else %}
      {% set class = 'col-sm-12' %}
    {% endif %}
    <div id="content" class="{{ class }}">{{ content_top }}
      <h2>{{ text_payment_method_book }}</h2>
      <form class="form-horizontal" id="form-payment_method">
        <div class="table-responsive">
          <table class="table table-bordered table-hover">
            <thead>
              <tr>
                <th class="text-left">{{ column_payment_method }}</th>
                <th></th>
                <th class="text-left">{{ column_type }}</th>
                <th class="text-left">{{ column_date_expire }}</th>
                <th class="text-right">{{ column_action }}</th>
              </tr>
            </thead>
            <tbody>
              {% if payment_methods %}
                {% for payment_method in payment_methods %}
                  <tr>
                    <td class="text-left">{{ payment_method.name }}</td>
                    <td class="text-left">{{ payment_method.image }}</td>
                    <td class="text-left">{{ payment_method.type }}</td>
                    <td class="text-left">{{ payment_method.date_expire }}</td>
                    <td class="text-right"><button type="button" data-toggle="tooltip" title="{{ button_delete }}" onclick="payment.remove('{{ payment_method.customer_payment_id }}');return false;" class="btn btn-danger"><i class="fa fa-times-circle"></i></button></td>
                  </tr>
                {% endfor %}
              {% else %}
                <tr>
                  <td class="text-center" colspan="5">{{ text_no_results }}</td>
                </tr>
              {% endif %}
            </tbody>
          </table>
        </div>
      </form>
      <div class="buttons clearfix">
        <div class="pull-left"><a href="{{ back }}" class="btn btn-default">{{ button_back }}</a></div>
      </div>
      {{ content_bottom }}
    </div>
    {{ column_right }}
  </div>
</div>
<script type="text/javascript"><!--
    // Payment method remove function
    var payment = {
        'remove': function (key) {
            $('.alert-dismissible').remove();

            $.ajax({
                url: 'index.php?route=account/payment_method/delete&customer_token={{ customer_token }}&customer_payment_id=' + key,
                type: 'post',
                dataType: 'json',
                success: function (json) {
                    if (json['redirect']) {
                        location = json['redirect'];
                    }

                    if (json['error']) {
                        $('#account-payment-method > .breadcrumb').after('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');
                    } else {
                        var result = confirm('{{ text_confirm }}');

                        if (!result) {
                            return false;
                        }
                    }

                    if (json['success']) {
                        location = json['success'];
                    }
                }
            });
        }
    }
//--></script>
{{ footer }}