{% load base_tags %}
{% load perm_tags %}
{% load corporate_memberships_tags %}
{% load i18n %}

{% has_perm user site_settings.change_setting as can_edit_setting %}
{#{% has_perm user corporate_memberships.add_corpmembership as can_add_corpmemb %}#}

{% if nav_object %}
    {% has_perm user corporate_memberships.view_corpmembership nav_object as can_view_corpmemb %}
    {% allow_view_corp nav_object user as allow_view %}
    {% has_perm user corporate_memberships.change_corpmembership nav_object as can_edit_corpmemb %}
    {% allow_edit_corp nav_object user as allow_edit %}
    {% has_perm user corporate_memberships.delete_corpemembership nav_object as can_delete %}
{% else %}
    {% has_perm user corporate_memberships.view_corpmembership as can_view_corpmemb %}
    {% has_perm user corporate_memberships.change_corpmembership as can_edit_corpmemb %}
{% endif %}


<ul id="module-tabs" class="tabs">
    {% if user.is_authenticated %}
    <li class="dropdown" data-dropdown="dropdown">
        <a href="#" class="dropdown-toggle">{% trans "Tendenci" %}</a>
        <ul class="dropdown-menu">
            <a href="{% url dashboard %}" title="Tendenci Home Page">{% trans "Dashboard" %}</a>
            <li><a href="{% url profile.index %}">{% trans "My Profile" %}</a></li>
            <li><a href="{% url auth_logout %}">{% trans "Log Off" %}</a></li>
        </ul>
    </li>
    {% endif %}
    {% if MODULE_MEMBERSHIPS_ENABLED %}
    <li><a href="{% url membership.search %}">{% firstof MODULE_MEMBERSHIPS_LABEL 'Memberships' %}</a></li>
    {% endif %}
    <li class="dropdown active" data-dropdown="dropdown">
        <a href="#" class="dropdown-toggle">{% firstof MODULE_CORPORATEMEMBERSHIPS_LABEL trans 'Corp. Memberships' %}</a>
        {% if nav_object %}
        <div class="dropdown-menu">
        <ul class="first">
            <li class="heading">{% trans "All Corp. Members" %}</li>
            <li class="divider"></li>
        {% else %}
            <div>
            <ul class="dropdown-menu">
        {% endif %}
            {% if can_edit_setting %}
            <li><a href="{% url settings.index "module" "corporate_memberships" %}">{% trans "Settings" %}</a></li>
            {% endif %}
            {% if user.profile.is_superuser %}
            <li><a href="{% url corpmembership.index %}">{% trans 'Index Page' %}</a></li>
            {% endif %}
           <li><a href="{% url corpmembership.add %}">{% trans "Add Corp. Member" %}</a></li>

            <li><a href="{% url corpmembership.search %}">{% trans "Search All" %}</a></li> 
            <li><a href="{% url corpmembership.mycorps %}">{% trans "My Corp. Members" %}</a></li> 
            {% if user.profile.is_superuser %}
            <li><a href="{% url corpmembership.pending_list %}">{% trans "Pending Corp. Members" %}</a></li>
            <li class="divider"></li>
            <li><a href="/admin/corporate_memberships/">Admin Backend</a></li>
            <li><a href="{% url admin:corporate_memberships_corpmembershipapp_changelist %}">{% trans "Application" %}</a></li>
            <li><a href="{% url admin:corporate_memberships_corporatemembershiptype_changelist %}">{% trans "Types" %}</a></li>
            <li><a href="{% url admin:corporate_memberships_notice_changelist %}">{% trans "Notices" %}</a></li>
            <li class="divider"></li>
            <li><a href="{% url corp_membership.summary_report %}">{% trans "Summary Report" %}</a></li>
            <li><a href="{% url corpmembership.import %}">{% trans "Import" %}</a></li>
            <li><a href="{% url corpmembership.export %}">{% trans "Export" %}</a></li>
            {% endif %}
        </ul>
        {% if nav_object %}
            {% if can_view_corpmemb or can_edit_corpmemb %}
            <ul>
                <li class="heading">{% trans "This Corp. Member" %}</li>
                {% if can_view_corpmemb or allow_view %}
                <li><a href="{% url corpmembership.view nav_object.pk %}">{% trans "View Corp. Member" %}</a></li>
                {% endif %}
                {% if can_edit_corpmemb and not nav_object.is_archive %}
                <li><a href="{% url corpmembership.edit nav_object.pk %}">{% trans "Edit Corp. Member" %}</a></li>
                <li><a class="option-link roster" href="{% url corpmembership.roster_search %}?cm_id={{ nav_object.id }}&active_only=1">{% trans "View Roster" %}</a></li>
               <li><a href="{% url memberships.default_export %}?cp_id={{ nav_object.corp_profile.pk }}">{% trans "Export Roster" %}</a></li>
                {% endif %}
                {% if nav_object.can_renew %}
			        <li><a href="{% url corpmembership.renew nav_object.id %}">{% trans "Renew" %}</a></li>
			    {% else %}
			    	{% if nav_object.is_expired and request.user.is_superuser %}
			    	 <li><a href="{% url corpmembership.renew nav_object.id %}">{% trans "Admin: Renew" %}</a></li>
			
			    	{% endif %}
			    {% endif %}
                {% if can_delete %}
                <li class="divider"></li>
                <li><a class="option-link delete" href="{% url corpmembership.delete nav_object.pk %}">{% trans "Delete" %}</a></li>
                {% endif %}
            </ul>
            {% endif %}
        {% endif %}
        </div>
    </li>
</ul>
