{% extends 'sstreasury/base.html' %}

{#
    Society Self-Service
    Copyright © 2018  Yingtong Li (RunasSudo)

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
#}

{% block title %}Your budgets{% endblock %}

{% macro listbudgets(budgets) %}
	<table class="ui selectable celled table">
		<thead>
			<tr>
				<th class="twelve wide">Name</th>
				<th class="four wide">Status</th>
			</tr>
		</thead>
		<tbody>
			{% for revision in budgets %}
				<tr>
					<td class="selectable"><a href="{{ url('budget_view', kwargs={'id': revision.budget.id}) }}">{{ revision.name }}</a></td>
					<td class="selectable"><a href="{{ url('budget_view', kwargs={'id': revision.budget.id}) }}">{{ import('sstreasury.models').BudgetState(revision.state).description }}</a></td>
				</tr>
			{% endfor %}
		</tbody>
	</table>
{% endmacro %}

{% block maincontent %}
	<h1>Your budgets</h1>
	
	{% if not budgets_action and not budgets_open and not budgets_closed %}
		<p>You have no budgets to view. To create a budget, click <a href="{{ url('budget_new') }}">Create new budget</a>.</p>
	{% endif %}
	
	{% if budgets_action %}
		<h2>Budgets requiring action</h2>
		
		{{ listbudgets(budgets_action) }}
	{% endif %}
	
	{% if budgets_open %}
		<h2>Open budgets</h2>
		
		{% for budget in budgets_open %}
			{{ budget.name }}
		{% endfor %}
	{% endif %}
	
	{% if budgets_closed %}
		<h2>Closed budgets</h2>
		
		{% for budget in budgets_closed %}
			{{ budget.name }}
		{% endfor %}
	{% endif %}
{% endblock %}

{% block head %}
	{{ super() }}
{% endblock %}