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

{% block title %}{% trans "Corporate Membership Approve / Disapprove" %}{% endblock %}

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

{% block body %}
<div class="t">
{% corpmemb_nav request.user corporate_membership %} 

     <h1>{% trans "Corporate Membership Submission" %}</h1>
     {% if corporate_membership.is_pending %}
     <div class="alert-message fade in" data-alert="alert" align="center">
     	<strong>Pending</strong>
     </div>
     {% endif %}
     
	<table>
		<tr>
			<td>Corp. Name:</td>
			<td>
			<strong><a href="{% url corp_memb.view corporate_membership.id %}" target="_blank">{{ corporate_membership.name }}</a></strong>
			</td>
		</tr>
		<tr>
			<td>Address:</td>
			<td>
				{% if corporate_membership.address %}
		  			{{ corporate_membership.address }} 
		  		{% endif %}
		  		{% if corporate_membership.address2 %}
		  			{{ corporate_membership.address2 }} 
		  		{% endif %}
		  		<br />
		  		{% if corporate_membership.city %}
		  			{{ corporate_membership.city }} 
		  		{% endif %}
		  		{% if corporate_membership.state %}
		  			{{ corporate_membership.state }}
		  		{% endif %}
		  		{% if corporate_membership.zip %}
		  			{{ corporate_membership.zip }} 
		  		{% endif %}
			</td>
		</tr>
     	
  		{% if corporate_membership.phone %}
  		<tr>
  			<td>Phone:</td>
  			<td>{{ corporate_membership.phone|phonenumber }}</td>
  		</tr>
  		{% endif %}
     	{% if corporate_membership.email %}
     	<tr>
     		<td>email:</td>
     		<td>{{ corporate_membership.email }}</td>
     	</tr>
     	{% endif %}
     	<tr>
     		<td>{% trans "Join Date: " %}</td>
     		<td>{{ corporate_membership.join_dt }}</td>
     	</tr>
     	<tr>
     		<td>{% trans "Expiration Date: " %}</td>
     		<td>{{ corporate_membership.expiration_dt }}
     			{% if corporate_membership.is_expired %}
		     		{% if corporate_membership.is_in_grace_period %}
		     			<span style="color:#F79D3D">{% trans "(in grace period)" %}</span>
		     		{% else %}
		     			<span style="color:red">{% trans "(expired)" %}</span>
		     		{% endif %}
		     	{% endif %}
     			</td>
     	</tr>
     </table>
     
   {% if renew_entry %}
	   <div style="height:1px;width:80%;border-bottom:1px dashed #ccc;margin-bottom:1em;">&nbsp;</div>
	   <div>
	   	{% blocktrans with renew_entry.create_dt|date:"d-M-Y" as create_date %}Renewed on {{ create_date }} by:{% endblocktrans %} <a href="{% url profile renew_entry.creator.username %}">{{ renew_entry.creator.get_full_name }}</a>
	   	<br />
	   	<a href="{% url invoice.view renew_entry.invoice.id %}">{% trans "View Invoice" %}</a>
	   	<br />
	   	{% trans "New expiration date upon approval: " %}<b>{{ new_expiration_dt }}</b>
	   	
	   	<br /><br />
	   	{% trans "The number of individual memberships renewed in this transaction: " %}<b>{{ indiv_renew_entries.count }}</b>
	   	{% if indiv_renew_entries.count > 0 %}
	   		
		   <small>(<span id="toggle-indiv-entries"><a href="javascript:;">{% trans "Show Details" %}</a></span>)</small>
		   <div id="indiv-entries">
			   <table width="70%">
				<tr><td width="50%" class="indiv-header">{% trans "Name" %}</td><td width="50%" class="indiv-header">{% trans "Member Number" %}</td></tr>
				{% for indiv_renew_entry in indiv_renew_entries %}
					<tr>
					<td><a href="{% url profile indiv_renew_entry.membership.user.username %}">{{ indiv_renew_entry.membership.user.get_full_name }}</a></td>
					<td>{{ indiv_renew_entry.membership.member_number }}</td>
					</tr>
				{% endfor %}
				</table>
		   </div>
		{% endif %}
	   
	   </div>
   {% else %}
   	  {% if corporate_membership.anonymous_creator  %}
   	  <dl class="">
   	  <dt>This corporate membership was submitted by: </dt>
   	  	<dd>
   	  	{{ corporate_membership.anonymous_creator.first_name }}
   	  	{{ corporate_membership.anonymous_creator.last_name }}
   	  	{{ corporate_membership.anonymous_creator.email }} (not logged in)
   	  	</dd>
   	  </dl>
   	  {% endif %}
   {% endif %}

<div class="corp-approv-form">   
<form action="" method="post">{% csrf_token %}
	{{ approve_form.as_p }}
<input type="submit" id="approve-btn" name="approve" value="Approve" />&nbsp;&nbsp; or &nbsp;&nbsp;
<input type="submit" id="disapprove-btn" name="disapprove" value="Disapprove" />
</form>
</div> 
                     
</div>



{% endblock %}

{% block extra_body %}
    {{ block.super }}
    <script type="text/javascript">
    
	$(document).ready(function()
	{
		$("#toggle-indiv-entries").click(function()				
		{
			if ($('#indiv-entries').is(':hidden')){
				$('#toggle-indiv-entries a').html("Hide Details");
			}else{
				$('#toggle-indiv-entries a').html("Show Details");
			}
			$("#indiv-entries").toggle();
		});	

					
	});

	
	
	</script>
   
    

{% endblock %}
