{% load i18n %}
{% with type_id=action_type.id|default:0 %}
{% if contact %}
  <li><a class="colorbox-form" href="{% url 'crm_create_action_of_type' 0 contact.id type_id %}">
    {% if action_type %}{{ action_type.name }}{% else %}{% trans "Action" %}{% endif %}
  </a></li>
{% else %}
  {% if entity %}
    <li><a class="colorbox-form" href="{% url 'crm_create_action_of_type' entity.id 0 type_id %}">
      {% if action_type %}{{ action_type.name }}{% else %}{% trans "Action" %}{% endif %}
    </a></li>
  {% else %}
    {% if opportunity %}
      <li><a class="colorbox-form" href="{% url 'crm_create_action_of_type' 0 0 type_id %}?opportunity={{opportunity.id}}">
        {% if action_type %}{{ action_type.name }}{% else %}{% trans "Action" %}{% endif %}
      </a></li>
    {% else %}
      <li><a class="colorbox-form" href="{% url 'crm_create_action_of_type' 0 0 type_id %}">
          {% if action_type %}{{ action_type.name }}{% else %}{% trans "Action" %}{% endif %}
      </a></li>
    {% endif %}
  {% endif %}
{% endif %}
{% endwith %}
