{% extends "corporate_memberships/base.html" %}
{% load pagination_tags %}
{% load bootstrap_pagination_tags %}
{% load avatar_tags %}
{% load base_filters %}
{% load corporate_memberships_tags %}
{% load i18n %}

{% block title %}{{ block.super }}{% trans "Corporate Membership Roster Search" %}{% endblock %}

{% block extra_head %}
{{ block.super }}
<link rel="stylesheet" href="{{ STATIC_URL }}bootstrap/bootstrap.css">
<link rel="stylesheet" href="{{ STATIC_URL }}css/corporate_memberships.css">
<link rel="stylesheet" href="{{ STATIC_URL }}css/corporate_memberships-roster_search.css">
<style>
     #corp-info table td{
        border-top: none;
    }
    .member-details{
        margin-left: 5px;
    }
    #id_first_name, #id_last_name, #id_email{
        width: 200px;
    }
    #id_search_criteria, #id_search_text{
        width: 150px;
    }
    #id_search_method{
        width: 100px;
    }
    .float-left{
        float: left;
    }
    .roster-search-form .form-field{
        margin: 3px 0;
    }

</style>
{% endblock %}
   
{% block body %}
<div class="t">
<div class="t-search">
 {% corpmemb_nav request.user corp_membership %}
 
<h1>Roster - 
    {% if corp_membership %}
    <a href="{% url corpmembership.view corp_membership.id %}">{{ corp_profile.name }}</a>
    {% else %}
    ALL
    {% endif %}
    </h1>

{% if corp_membership %}
<div id="corp-info">
	<table width="100%">
	    {% if corp_profile.address %}
		<tr>
			<td width="20%">{% trans "Address:" %}</td>
			<td width="80%" colspan="3">{{ corp_profile.address }} {{ corp_profile.address2 }}</td>
		</tr>
		{% endif %}
		{% if corp_profile.city or corp_profile.state or corp_profile.zip  %}
		<tr>
			<td width="20%">&nbsp;</td>
			<td width="80%" colspan="3">{{ corp_profile.city }} {{ corp_profile.state }} {{ corp_profile.zip }}</td>
		</tr>
		{% endif %}
		<tr>
			<td width="20%">{% trans "Phone:" %}</td>
			<td width="40%">{{ corp_profile.phone|phonenumber }}</td>
			<td width="20%">{% trans "Join Date:" %}</td>
			<td width="40%">{{ corp_membership.join_dt|date:'Y-n-j' }}</td>
		</tr>
		<tr>
			<td width="20%">{% trans "Member Type:" %}</td>
			<td width="40%">{{ corp_membership.corporate_membership_type.name }}</td>
			<td width="20%">{% trans "Expiration Date:" %}</td>
			<td width="40%">{% if corp_membership.expiration_dt %}
			    							{{ corp_membership.expiration_dt|date:'Y-n-j' }}
			    							{% else %}
			    							{% trans "Never Expire" %}
			    							{% endif %}</td>
		</tr>
	</table>

</div>
{% endif %}
<br />
<form name="roster-search" class="roster-search-form" method="get">
<div class="form-field">{{ form.cm_id.label }}: {{ form.cm_id }}</div>
<div class="float-left">
    <div class="form-field">
        {{ form.first_name.label }}: {{ form.first_name }}
    </div>
    <div class="form-field">
        {{ form.last_name.label }}:  {{ form.last_name }}
    </div>
</div>
<div class="float-left">
      <div class="form-field" style="margin-left: 3em;">
        {{ form.email.label }}: {{ form.email }}
    </div> 
     <div class="form-field" style="margin-left: 3em;">
    {{ form.active_only }} <label for="id_active_only" style="display: inline;">{{ form.active_only.label }}</label> 
    </div>
     
</div>
<div class="clear-left"></div>
<div class="form-field">
    {{ form.search_criteria }} {{ form.search_text }} {{ form.search_method }}
    <input type="submit" name="search" value="Search" />
</div>

</form>

{% autopaginate memberships 10 %}
<div class="roster-search-wrap">
<span><em>{{ paginator.count }} {% if active_only %}{% trans "Active" %}{% endif %} {% trans "Member" %}{{ paginator.count|pluralize }} {% trans "Found" %}</em></span>
    
    {% for membership in memberships %}
	    {% with membership|get_object as membership %}
			<div class="member-line {% if membership.status_detail != 'active' %}inactive{% endif %}">
				<div class="avatar">{% avatar membership.user 56 %}</div>
				<div class="member-details">
					<div class="member-name">
							<a href="{{ membership.user.profile.get_absolute_url }}">
							{{ membership.user.get_full_name }}
							</a>
							<br/>
							{% if membership.status_detail == 'inactive' %}
							<span class="label">Inactive</span>
							{% endif %}
					</div>
					
					<div class="member-left">
						<div>{% trans "Email: " %}{{ membership.user.email }}</div>
						<div>{% trans "Member Type: " %}{{ membership.membership_type }}</div>
					</div>
					<div class="member-right">
						<div>{% trans "Join Date: " %}{{ membership.join_dt|date:'Y-n-j' }}</div>
						<div>{% trans "Expiration Date: " %}{% if membership.expire_dt %}
				    							{{ membership.expire_dt|date:'Y-n-j' }}
				    							{% else %}
				    							{% trans "Never Expire" %}
				    							{% endif %}
				    	</div>
				    	<div class="status-{{ membership.status_detail }}">
				    	    {% trans "Status: " %}
				    	    {% if request.user.profile.is_superuser %}
				    	    <a href="{% url admin:memberships_membershipdefault_change membership.pk %}">{{ membership.status_detail|capfirst }}</a>
				    	    
				    	    {% else %}
				    	    {{ membership.status_detail|capfirst }}
				    	    {% endif %}
				    	</div>
					</div>
					
				</div>
	    	
	    	<div class="clear-left"></div>	
	    	</div>
	    	
		{% endwith %}	
	{% empty %}
		<div>{% trans "0 Results Found" %}</div>
	{% endfor %}
</div>


 {% paginate %}
 
 </div>
</div>

{% endblock %}

