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

{% block title %}Expenditures - {{ 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 }} + "/expenditures/" + page + '/';
            }
        });
    </script>
{% endblock %}

{% block content %}

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

<div class="row">
    <div class="col-12-lg">
    <h3>
          Expenditures
          <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_expenditure_list' committee.pk 1 %}?format=csv">Download CSV</a></li>
                <li><a href="{% url 'committee_expenditure_list' committee.pk 1 %}?format=json">Download JSON</a></li>
              </ul>
          </div>
    </h3>
    <p class="totals">Total expenditures: ${{committee.total_expenditures  | 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="danger">amount</th>
                    <!-- <th>person_flag</th> -->
                </tr>
              </thead>
              <tbody>
                  {% for expenditure in committee_expenditures %}
                    <tr>
                        <td>{{ expenditure.cycle }}</td>
                        <td><a href="{{ expenditure.filing.get_absolute_url }}">{{ expenditure.filing.pk }}</a></td>
                        <td>{{ expenditure.raw_org_name }}</td>
                        <td class="danger">${{ expenditure.amount | intcomma }}</td>
                        <!-- <td>{{ expenditure.person_flag }}</td> -->
                    </tr>
                  {% endfor %}
              </tbody>
            </table>
          </div>
    </div>
  </div>

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