{% extends "memberships/base.html" %}
{% load membership_tags %}
{% load base_tags %}
{% load base_filters %}
{% load perm_tags %}
{% load i18n %}

{% block title %}Membership Application for {{ entry.name }}{% endblock %}
{% block meta_description %}{{ entry.get_description }}{% endblock %}
{% block meta_keywords %}{{ entry.get_keywords }}{% endblock %}
{% block meta_canonical_url %}<link rel="canonical" href="{{ entry.get_canonical_url }}" />{% endblock %}

{% block extra_head %}
{{ block.super }}
<link rel="stylesheet" href="{{ STATIC_URL }}css/memberships.css">
{% endblock %}

{% block body %}

<div class="t">
{% membership_nav request.user %}
    <div class="application-entry-wrap">

        {% if entry.is_renewal %}
        <h1>{{ entry.app.name }} {% trans "Renewal" %}</h1>
        {% else %}
        <h1>{{ entry.app.name }} {% trans "Submission" %}</h1>
        {% endif %}

        {% if is_confirmation and entry.app.confirmation_text %}
            <div>{{ entry.app.confirmation_text|safe|urlize }}</div>
            <hr />
        {% endif %}

        <div class="entry_dt">{% trans "Submitted" %} {{ entry.entry_time|date_short }}
            {% if request.user.is_superuser %}
            <a class="entry-link" href="{% url membership.entry_delete entry.pk %}">{% trans "Delete" %}</a>
            {% comment %}
            <a class="entry-link" href="{% url membership.entry_edit entry.pk %}">{% trans "Edit" %}</a>
            {% endcomment %}
            <a class="entry-link" href="{% url membership.application_entries_print entry.pk %}">{% trans "Print" %}</a>
            {% endif %}
        </div>

        <div class="approval-status {{ entry.status_msg|lower }}">
            {{ entry.status_msg }}
            {% if entry.decision_dt %}
                {{ entry.decision_dt|date_long }}
            {% endif %}
        </div>
    

        {% if entry.is_approved %}
        <div id="member-number">
            {{ entry.membership.member_number }}
            <div style="float:right">{{ entry.membership.subscribe_dt|date:"M j, Y" }} - {% firstof entry.membership.expire_dt|date:"M j, Y" "Forever" %}</div>
        </div>
        {% endif %}

    	{% for field in entry.ordered_fields %}
    		{% if field.field.field_type == 'FileField' %}
            <div class="field">
                <div class="label">{{ field.field.label }}</div>
    			<div class="value">
                    <a href="{{ MEDIA_URL }}{{ field.value }}">{{ field.value|basename }}</a>
    			</div>
            </div>
    		{% else %}
            <div class="field">
                <div class="label">{{ field.field.label }}</div>
    			<div class="value">
    			{% with field.corporate_membership_name as cm_name %}
    			{% if cm_name %}
    				{{ cm_name }} (ID:{{ field.value }})
    			{% else %}
    				{{ field.value }}
    			{% endif %}
    			{% endwith %}
    			</div>
            </div>
    		{% endif %}
    	{% endfor %}

        {% if can_approve %}
        {% if entry.is_approved == 0 or entry.is_approved == 1 %}
        {% else %}
            {% if form %}
            <form action="" method="post" class="connect-with">{% csrf_token %}
                <div>{{ form }}</div>
                
                {% if entry.is_renewal %}
                <input type="submit" name="status" value="Disapprove Renewal">
                <input type="submit" name="status" value="Approve Renewal">
                {% else %}
                <input type="submit" name="status" value="Disapprove">
                <input type="submit" name="status" value="Approve">
                {% endif %}
            </form>
            {% endif %}
        {% endif %}
        {% endif %}
    </div>

    {% if entry.membership %}
    <div class="profile-link">
        <a href="{% url profile  entry.membership.user %}#userview-memberships">{% trans "View Profile &amp; Membership" %}</a>
    </div>
    {% endif %}

</div>
{% endblock %}
