{% extends 'base-print.html' %}
{% load membership_tags %}
{% load base_tags %}
{% load base_filters %}
{% load i18n %}

{% block title %}{% blocktrans with membership.user as mem_user %}Membership for {{ mem_user }}{% endblocktrans %}{% endblock %}
{% block meta_description %}{{ membership.get_description }}{% endblock %}
{% block meta_keywords %}{{ membership.get_keywords }}{% endblock %}
{% block meta_canonical_url %}<link rel="canonical" href="{{ membership.get_canonical_url }}" />{% endblock %}

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

<style>
    .t .membership-details-status {
        border-left: none;
        width: 220px;
        text-align: right;
    }
    .t .membership-details-status .status-label {
        color: black;
        font-size: 1.2em;
        background-color: white;
        padding: 0;
        border-bottom: none;
    }
    .t .membership-detail-nav {
        display: none;
    }
</style>

{% endblock %}

{% block body %}
<div class="t">
    <div class="membership-detail-wrap">

        <fieldset>
            <div class="membership-details-inner-wrap">
                <div class="membership-details-name">
                    <h1>{% blocktrans with membership.user.get_full_name as memname %}
                    {{ memname }}{% endblocktrans %}</h1>

                    <div class="membership-detail-nav">
                        {% if request.user.is_authenticated %}
                        <a href="{% url profile membership.user.username %}">
                            {% trans "Profile" %}</a>
                        {% endif %}

                        {% if membership.get_invoice %}
                        <a href="{% url invoice.view membership.get_invoice.pk membership.get_invoice.guid %}">
                            {% trans "Invoice" %}</a>
                        {% endif %}

                        {% if user.is_superuser %}
                        <a href="{% url admin:memberships_membershipdefault_change membership.pk %}?next={{ request.path }}">
                            {% trans "Edit Membership" %}</a>
                        {% endif %}
                    </div>
                </div>

                <div class="membership-details-info">
                    <p>Member <strong>{{ membership.member_number }}</strong></p>

                    <p>Group <strong>{{ membership.membership_type }}</strong></p>

                    <p title="{{ membership.get_since_dt|timesince }} ago">
                        Since <strong>{{ membership.get_since_dt|date:"N j, Y" }}</strong></p>

                    {% if membership.renewal %}
                    <p title="{{ membership.subscribe_dt|timesince }} ago">
                        Renewed <strong>{{ membership.subscribe_dt|date:"N j, Y" }}</strong></p>
                    {% endif %}                        

                    {% if membership.is_approved %}
                        {% if membership.is_forever %}
                            <p>{% trans "Never expires" %}</p>
                        {% else %}
                            <p>Expires <strong>{{ membership.expire_dt|date:"N j, Y" }}</strong> (grace period: {{ membership.membership_type.expiration_grace_period }} days)</p>    
                        {% endif %}

                    {% else %}
                        {% if membership.is_expired %}
                            <p>Expired <strong>{{ membership.expire_dt|date:"N j, Y" }}</strong> (grace period: {{ membership.membership_type.expiration_grace_period }} days)</p>
                        {% endif %}
                    {% endif %}

                    {% if membership.get_renewal_period_dt %}
                        <p>Renew between {{ membership.get_renewal_period_dt.0|date:"N j, Y" }} and {{ membership.get_renewal_period_dt.1|date:"N j, Y" }}</p>
                    {% else %}
                        <p>Membership type does not allow renewals.</p>
                    {% endif %}

                    <div class="membership-details-status">
                        
                        <div class="status-label {{ membership.get_status }}">
                            {{ membership.get_status|capfirst }} Membership</div>

                        <div class="status-label">
                            Balance Due: ${{ membership.get_invoice.balance|floatformat:"2" }}</div>

                    </div>

                </div>

            </div>
        </fieldset>

        <fieldset>
            <label>More Details</label>

            {% if membership.certifications %}
            <div class="field">
                <div class="label">Certifications</div>
                <div class="value">{{ membership.certifications }}</div>
            </div>
            {% endif %}

            {% if membership.work_experience %}
            <div class="field">
                <div class="label">Work Experience</div>
                <div class="value">{{ membership.work_experience }}</div>
            </div>
            {% endif %}

            {% if membership.referral_source %}
            <div class="field">
                <div class="label">Referral Source</div>
                <div class="value">{{ membership.referral_source }}</div>
            </div>
            {% endif %}

            {% if membership.referral_source_other %}
            <div class="field">
                <div class="label">Referral Source (other)</div>
                <div class="value">{{ membership.referral_source_other }}</div>
            </div>
            {% endif %}

            {% if membership.referral_source_member_name %}
            <div class="field">
                <div class="label">Referral Source Member Name</div>
                <div class="value">{{ membership.referral_source_member_name }}</div>
            </div>
            {% endif %}

            {% if membership.referral_source_member_number %}
            <div class="field">
                <div class="label">Referral Source Member Number</div>
                <div class="value">{{ membership.referral_source_member_number }}</div>
            </div>
            {% endif %}

            {% if membership.affiliation_member_number %}
            <div class="field">
                <div class="label">Affiliation Member Number</div>
                <div class="value">{{ membership.affiliation_member_number }}</div>
            </div>
            {% endif %}

            {% if membership.primary_practice %}
            <div class="field">
                <div class="label">Primary Practice</div>
                <div class="value">{{ membership.primary_practice }}</div>
            </div>
            {% endif %}

            {% if membership.how_long_in_practice %}
            <div class="field">
                <div class="label">How Long in Practice</div>
                <div class="value">{{ membership.how_long_in_practice }}</div>
            </div>
            {% endif %}

            {% if membership.notes %}
            <div class="field">
                <div class="label">Notes</div>
                <div class="value">{{ membership.notes|linebreaks }}</div>
            </div>
            {% endif %}

            {% if membership.admin_notes %}
            <div class="field">
                <div class="label">Admin Notes</div>
                <div class="value">{{ membership.admin_notes|linebreaks }}</div>
            </div>
            {% endif %}

            {% if membership.newsletter_type %}
            <div class="field">
                <div class="label">Newsletter Type</div>
                <div class="value">{{ membership.newsletter_type }}</div>
            </div>
            {% endif %}

            {% if membership.directory_type %}
            <div class="field">
                <div class="label">Directory Type</div>
                <div class="value">{{ membership.directory_type }}</div>
            </div>
            {% endif %}

            {% if membership.app %}
            <div class="field">
                <div class="label">Application</div>
                <div class="value">{{ membership.app }}</div>
            </div>
            {% endif %}

            {% if membership.application_complete_dt %}
            <div class="field">
                <div class="label">Application Complete Date &amp; Time</div>
                <div class="value">{{ membership.application_complete_dt }}</div>
            </div>
            {% endif %}

            {% if membership.application_approved_dt %}
            <div class="field">
                <div class="label">Application Approved Date &amp; Time</div>
                <div class="value">{{ membership.application_approved_dt }}</div>
            </div>
            {% endif %}

            {% if membership.personnel_notified_dt %}
            <div class="field">
                <div class="label">Personnel Notified Date</div>
                <div class="value">{{ membership.personnel_notified_dt }}</div>
            </div>
            {% endif %}

            {% if membership.payment_received_dt %}
            <div class="field">
                <div class="label">Payment Received Date &amp; Time</div>
                <div class="value">{{ membership.payment_received_dt }}</div>
            </div>
            {% endif %}

            {% if membership.payment_method %}
            <div class="field">
                <div class="label">Payment Method</div>
                <div class="value">{{ membership.payment_method }}</div>
            </div>
            {% endif %}

            {% if membership.override %}
            <div class="field">
                <div class="label">Override</div>
                <div class="value">{{ membership.override }}</div>
            </div>
            {% endif %}

            {% if membership.override_price %}
            <div class="field">
                <div class="label">Override Price</div>
                <div class="value">{{ membership.override_price }}</div>
            </div>
            {% endif %}

            {% if membership.exported %}
            <div class="field">
                <div class="label">Exported</div>
                <div class="value">{{ membership.exported }}</div>
            </div>
            {% endif %}

            {% if membership.chapter %}
            <div class="field">
                <div class="label">Chapter</div>
                <div class="value">{{ membership.chapter }}</div>
            </div>
            {% endif %}

            {% if membership.areas_of_expertise %}
            <div class="field">
                <div class="label">Areas of Expertise</div>
                <div class="value">{{ membership.areas_of_expertise }}</div>
            </div>
            {% endif %}

            {% if membership.get_corporate_membership %}
            <div class="field">
                <div class="label">Corporate Membership</div>
                {% if request.user.profile.is_superuser %}
                <div class="value"><a href="{{ membership.get_corporate_membership.get_absolute_url }}">
                    {{ membership.get_corporate_profile.name }} - {{ membership.get_corporate_membership.corporate_membership_type.name }}</a></div>
                {% else %}
                <div class="value">
                    {{ membership.get_corporate_profile.name }} - {{ membership.get_corporate_membership.corporate_membership_type.name }}</div>
                {% endif %}
            </div>
            {% endif %}

            {% if membership.home_state %}
            <div class="field">
                <div class="label">Home State</div>
                <div class="value">{{ membership.home_state }}</div>
            </div>
            {% endif %}

            {% if membership.year_left_native_country %}
            <div class="field">
                <div class="label">Year Left Native Country</div>
                <div class="value">{{ membership.year_left_native_country }}</div>
            </div>
            {% endif %}

            {% if membership.network_sectors %}
            <div class="field">
                <div class="label">Network Sectors</div>
                <div class="value">{{ membership.network_sectors }}</div>
            </div>
            {% endif %}

            {% if membership.networking %}
            <div class="field">
                <div class="label">Networking</div>
                <div class="value">{{ membership.networking }}</div>
            </div>
            {% endif %}

            {% if membership.government_worker %}
            <div class="field">
                <div class="label">Government Worker</div>
                <div class="value">{{ membership.government_worker }}</div>
            </div>
            {% endif %}

            {% if membership.government_agency %}
            <div class="field">
                <div class="label">Government Agency</div>
                <div class="value">{{ membership.government_agency }}</div>
            </div>
            {% endif %}

            {% if membership.license_number %}
            <div class="field">
                <div class="label">License Number</div>
                <div class="value">{{ membership.license_number }}</div>
            </div>
            {% endif %}

            {% if membership.license_state %}
            <div class="field">
                <div class="label">License State</div>
                <div class="value">{{ membership.license_state }}</div>
            </div>
            {% endif %}

            {% if membership.industry %}
            <div class="field">
                <div class="label">Industry</div>
                <div class="value">{{ membership.industry }}</div>
            </div>
            {% endif %}

            {% if membership.region %}
            <div class="field">
                <div class="label">Region</div>
                <div class="value">{{ membership.region }}</div>
            </div>
            {% endif %}

            {% if membership.company_size %}
            <div class="field">
                <div class="label">Company Size</div>
                <div class="value">{{ membership.company_size }}</div>
            </div>
            {% endif %}

            {% if membership.promotion_code %}
            <div class="field">
                <div class="label">Promotion Code</div>
                <div class="value">{{ membership.promotion_code }}</div>
            </div>
            {% endif %}

            {% if membership.directory %}
            <div class="field">
                <div class="label">Directory</div>
                <div class="value">{{ membership.directory }}</div>
            </div>
            {% endif %}

        </fieldset>

        {% if membership.get_demographics %}
        <fieldset>
            <label>Even More Details (custom fields)</label>
            {% for label, value in membership.get_demographics %}
                {% if value %}
                <div class="field">
                    <div class="label">{{ label }}</div>
                    <div class="value">{{ value }}</div>
                </div>
                {% endif %}
            {% endfor %}
        </fieldset>
        {% endif %}

        {% if membership.get_archived_memberships %}
        <fieldset>
            <div class="fieldset-label">Archived Memberships</div>
            <div style="clear:both;"></div>

            {% for archive in membership.get_archived_memberships %}
                <div class="field">
                    <div class="label">
                        {% firstof archive.join_dt|date:"F Y" archive.create_dt|date:"F Y" %} - {% firstof archive.expire_dt|date:"F Y" "Forever" %}

                        {% if membership == archive %}
                            (you are here)
                        {% endif %}

                    </div>
                    <div class="value"><a href="{% url membership.details archive.pk %}">{{ archive.membership_type.name }}</a></div>
                </div>
            {% endfor %}
        </fieldset>
        {% endif %}

    </div>
</div>
{% endblock %}
