{% extends 'calaccess_campaign_browser/base.html' %}
{% load humanize %}

{% block title %}Contributions - {{ committee.name }} - Committee - {{ block.super }}{% endblock %}

{% block javascript %}
    <script>
        $('.pagination').twbsPagination({
            totalPages: {{ paginator.count }},
            visiblePages: 5,
            startPage: {{ page_obj.number }},
            prev: '&laquo;',
            next: '&rsaquo;',
            onPageClick: function (event, page) {
                window.location.href = "/committee/" + {{ committee.id }} + "/contributions/" + page + '/';
            }
        });
    </script>
{% endblock %}

{% block content %}
 {% include "calaccess_campaign_browser/committee_nav.html" %}

  <div class="row">
    <div class="col-12-lg">
        <h3>
              Contributions
              <div class="btn-group">
                  <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                    Download data <span class="caret"></span>
                  </button>
                  <ul class="dropdown-menu" role="menu">
                    <li><a href="{% url 'committee_contribution_list' committee.pk 1 %}?format=csv">Download CSV</a></li>
                    <li><a href="{% url 'committee_contribution_list' committee.pk 1 %}?format=json">Download JSON</a></li>
                  </ul>
              </div>
        </h3>
        <p class="totals">Total contributions: ${{committee.total_contributions  | intcomma}}</p>
    </div>
  </div>

    {% include "calaccess_campaign_browser/paginator.html" %}

  <div class="row">
    <div class="col-12-lg">
          <div class="table-responsive">
            <table class="table table-bordered table-hover"> <!-- table table-bordered table-hover -->
              <thead>
                <tr>
                    <th>cycle</th>
                    <th>filing</th>
                    <th>raw_org_name</th>
                    <th class="success">amount</th>
                    <!-- <th>person_flag</th> -->
                </tr>
              </thead>
              <tbody>
                  {% for contribution in committee_contributions %}
                    <tr>
                        <td>{{ contribution.cycle }}</td>
                        <td><a href="{{ contribution.filing.get_absolute_url }}">{{ contribution.filing.pk }}</a></td>
                        <td>{{ contribution.raw_org_name }}</td>
                        <td class="success"><a href="{{ contribution.get_absolute_url }}">${{ contribution.amount | intcomma }}</a></td>
                        <!-- <td>{{ contribution.person_flag }}</td> -->
                    </tr>
                  {% endfor %}
              </tbody>
            </table>
          </div>
    </div>
  </div>
  {% include "calaccess_campaign_browser/paginator.html" %}
{% endblock %}
