{% extends 'members_template.html' %}
{% block members_content %}
<div class="row">
<div class="col-md-12">
	<p>Please enter the new expiry dates for the forms you wish to add. To not include a form leave that field blank. Dates must be in the format <strong>DD/MM/YYYY</strong>.</p>
	<p>The fill <i class="fa fa-arrows" /></i> button copies all the values in that row into all rows.</p>
	<form action="." method="POST">
		{{ formset.management_form }}
		<input type="hidden" name="userset" value="{{userset}}" />
		{% csrf_token %}
<table class="table table-sm table-striped">
	<tr><th>Name</th><th>Club Expiry</th><th>BSAC Expiry</th><th>Medical Form Expiry</th><th>Fill</th></tr>
{% for form in formset %}
		<tr>{{form.member_id}}
			<td>{{form.full_name}}</td>
			<td>{{form.club_expiry}}</td>
			<td>{{form.bsac_expiry}}</td>
			<td>{{form.medical_form_expiry}}</td>
			<td><a href="#" class="fill btn"><i class="fa fa-arrows" /></a></td>
		</tr>
{% endfor %}
</table>
<div class="ret-form-actions">
    <button type="submit" class="btn btn-success"><i class="fa fa-save"></i> Add Forms</button>
</div>
</div>
</div>

<script type="text/javascript">
	$('a.fill').click(function(event) {
		var club_expiry			= $('input:eq(1)', $(this).closest('tr')).val()
		var bsac_expiry			= $('input:eq(2)', $(this).closest('tr')).val()
		var medical_form_expiry	= $('input:eq(3)', $(this).closest('tr')).val()

		$('input:eq(1)', $('a.fill').closest('tr')).val(club_expiry)
		$('input:eq(2)', $('a.fill').closest('tr')).val(bsac_expiry)
		$('input:eq(3)', $('a.fill').closest('tr')).val(medical_form_expiry)
	});

</script>
{% endblock %}
