{% include 'header.twig' %}

{% if contentText is not empty %}
	<div class="container">
		<div class="row">
			<div class="col-md-8 col-md-offset-2">
				<div class="well ">
					{{ contentText }}
				</div>
			</div>
		</div>
	</div>
{% endif %}
<div class="container-fluid">

	<div class="row">
		<div class="col-lg-12">
			<ul class="nav nav-pills ">
				<li class="pull-right search">
					<form action="" method="get">
						<div class="input-group">
							<input type="text" name="search" class="form-control" value="{{ search }}" placeholder="Search Updates">
							<span class="input-group-btn">
								<button type="submit" class="btn btn-default">
									<i class="fa fa-search" aria-hidden="true"></i>
								</button>
							</span>
						</div>
					</form>
				</li>

			</ul>
		</div>
	</div>
	<div class="row">
		<div class="col-lg-12">


			<div class="well well-float">
				<table class="table ">

					<thead>
						<tr>
							<th>{{ lang['services.id'] }}</th>
							<th class="width-service-name">{{ lang['services.name'] }}</th>

							<th class="nowrap">{{ lang['service_log.update'] }}</th>
							<th class="nowrap">{{ lang['service_log.date'] }}</th>


						</tr>
					</thead>
					<tbody>

						{% for log in service_logs %}
							<tr>
								<td>{{ log["id"] }}</td>
								<td>{{ log["service_name"] }}</td>
								<td>

									<button class="btn   {% if log[" alert_type"] == 1 %}
																														                             btn-danger {% elseif log[" alert_type"] == 2 %}  btn-success
																														                             {% elseif log[" alert_type"] == 3 %} btn-warning {% elseif log[" alert_type"] == 4 %} btn-info  {% elseif log[" alert_type"] == 5 %} btn-primary  {% else %} btn-black  {% endif %} ">
										{{ log["serviceapi_alert"] }}


									</button>
								</td>
								<td>{{ show_date(log["servicealert_date"]) }}</td>


							</tr>
						{% endfor %}
					</tbody>

				</table>
			</div>

			{% if pagination["count"] > 1 %}
				<ul class="pagination">

					{% if pagination["current"] != 1 %}
						<li>
							<a href="updates/{{ pagination[" previous"] }}{% if search %}?search={{ search }}{% endif %}" aria-label="Previous">
								<span aria-hidden="true">&laquo;</span>
							</a>
						</li>
					{% endif %}

					{% set r, l = 3, 3 %}

					{% if pagination['current'] == 1 %}
						{% set r = 7 %}
					{% endif %}

					{% if pagination['current'] == 2 %}
						{% set r = 5 %}
					{% endif %}

					{% if pagination['current'] >= pagination['count'] %}
						{% set l = 5 %}
					{% endif %}

					{% for page in 1..pagination["count"] %}
						{% if page >= (pagination['current']-l) and page <= (pagination['current']+r) %}
							<li {% if page == pagination['current'] %} class="active" {% endif %}>
								<a href="updates/{{ page }}{% if search %}?search={{ search }}{% endif %}">{{ page }}</a>
							</li>
							{%endif%}
						{% endfor %}

						{% if pagination['current'] < pagination['count'] %}
							<li>
								<a href="updates/{{ pagination['next'] }}{% if search %}?search={{ search }}{% endif %}" aria-label="Next">
									<span aria-hidden="true">&raquo;</span>
								</a>
							</li>
						{% endif %}

					</ul>
				{% endif %}

			</div>
		</div>
	</div>
	{% include 'footer.twig' %}
	<br>
