{% extends "balafon/_bs_section.html" %}
{% load i18n favorite_tags %}

{% block section_title %}
  <span class="glyphicon glyphicon-tag"></span> {% trans "Opportunities" %}
{% endblock %}
  
{% block section_data %}
{% if opportunities %}
<table class="table table-striped">
  <tr>
    <th>{% trans "Name" %}</th>
    <th>{% trans "Description" %}</th>
    <th>{% trans "Actions count" %}</th>

    <th>{% trans "Date" %}</th>

    <th></th>
  </tr>
  {% for o in opportunities %}
  <tr class="{% if o.ended %}old-opportunity{% endif %} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}">
    <td>
      {% favorite_item object=o %}
      {{o.name}}
    </td>
    
    <td><span class="contenteditable description inline-block" rel="{% url "auto_save_data" "opportunity" "detail" o.id %}" contenteditable="true">
      {{o.detail|linebreaksbr}}
    </span></td>

    <td>{{o.action_set.count}}</td>

    <td>{{ o.get_start_date|date:'j F Y'|default:'&nbsp;'}} : {{ o.get_end_date|date:'j F Y'|default:'&nbsp;'}}</td>
    
    <td>
      <a class="btn btn-xs btn-default pull-right" href="{% url "crm_view_opportunity" o.id %}">
        <span class="glyphicon glyphicon-tag"></span>
        {%  trans "View" %}
      </a>
    </td>
  </tr>
  {% endfor %}
</table>
{% include "coop_cms/_pagination.html" %}
{% endif %}
{% endblock %}


{% block section_menu_name %}
  <span class="glyphicon glyphicon-plus"></span> {% trans "Add" %}
{% endblock %}

{% block section_buttons %}
  {% if not entity and not contact %}
  <li><a class="colorbox-form" href="{% url "crm_add_opportunity" %}">
    <span class="glyphicon glyphicon-tag"></span>
    {% trans "New opportunity" %}</a>
  </li>
  {% endif %}
{% endblock %}
