{% extends "protocoloadm/pesquisa_documento_detail.html" %}
{% load i18n %}
{% load crispy_forms_tags %}

{% block detail_content %}
	<fieldset>
		<legend>Pesquisa Básica</legend>
		{% if documentos %}
			Total: {{ documentos|length }} 
		
			<table>
				{% for d in documentos %}
					<tr>
						<td>
							<a href="{% url 'detail_doc_adm' d.id %}"><b>{{ d.tipo.sigla }} {{ d.numero }}/{{ d.ano }} - {{ d.tipo }}</b></a> <br />
							{{ d.assunto }} <br />
							<b>Interessado:</b> {{ d.interessado }}
						</td>
					</tr>
				{% endfor %}
			</table>
		{% else %}
			<form method="POST">
				{% csrf_token %}

				{% if error %}
					<h5 align="center"><font color="#FF0000">{{ error }}</font></h5>
				{% endif %}

				Tipo Documento: 
				<select name="tipo_documento">
					<option value=""> --- </option>
					{% for tipo in tipos_doc %}
						<option value="{{tipo.id}}">{{tipo.descricao}}</option>
					{%  endfor %}
				</select> <br>
				Número: <input type="text" name="numero" id="numero" /> <br>
				Ano: <input type="text" name="ano" id="ano" /> <br>
				Núm. Protocolo: <input type="text" name="numero_protocolo" id="numero_protocolo" /> <br>
				Período Data: <br>
				Inicial: <input type="text" name="periodo_inicial" id="periodo_inicial" class="dateinput"/> 
				Final: <input type="text" name="periodo_final" id="periodo_final" class="dateinput"/> <br>
				Interessado: <input type="text" name="interessado" id="interessado" /> <br>
				Assunto: <input type="text" name="assunto" id="assunto" /> <br>
				Tramitando:
				<select name="tramitacao">
					<option value="1">Sim</option>
					<option value="0">Não</option>
					<option value="" selected>Tanto Faz</option>
				</select> <br>
				<!-- TODO
				Localização Atual:
				<select name="localizacao">
					<option value=""> - </option>
				</select> <br>
				Situação:
				<select name="situacao">
					<option value=""> - </option>
				</select> <br><br>
				-->

				<input type="submit" value="Pesquisar" class="primary button"/>
			</form>
		{% endif %}
	</fieldset>
{% endblock %}