{% extends 'base.html' %}
{% load crispy_forms_tags %}
{% load static %}

{% block modals%}
{% endblock %}

{% block script %}
{% endblock %}

{% block main %}
{% regroup items by PIC_L_Site as item_by_site %}

{% for site in item_by_site %}
	{% regroup site.list by PIC_L_Service as item_by_service %}
	<table class="table table-sm mb-2">
	{% for service in item_by_service %}
		{% for item in service.list %}
				<tr {% if item.PIC_L_Statut == "ADEPROD" %}class="table-danger"{%elif item.PIC_L_Statut == "PREPROD"%}class="table-success"{%elif item.PIC_L_Statut == "HS"%}class="table-warning"{% endif %}>
					{% if forloop.first %}<td class="table-active" rowspan="{{ service.list|length }}"><span style="writing-mode: vertical-lr;">{{ site.grouper }} - {{ service.grouper }}</span></td>{% endif %}
					<td>
						{% if item.PIC_L_Chassi_Type == "PC"%}
							<i class="fas fa-hdd"></i>
						{% elif item.PIC_L_Chassi_Type == "CL" %}
							<i class="fas fa-network-wired"></i>
						{% elif item.PIC_L_Chassi_Type == "PORTABLE" %}
							<i class="fas fa-laptop"></i>
						{% elif item.PIC_L_Chassi_Type == "PANEL-PC" %}
							<i class="fas fa-tablet-alt"></i>
						{% endif %}
						 {{item.get_PIC_L_Chassi_Type_display}} {% if item.PIC_Deg == 1%}/ DEG{% endif %}
					</td>
					<td>{% for accessoir in item.accessoir %}{% if accessoir.Accessory_N_slugify == "double-ecrans"%}<i class="{{accessoir.Accessory_icone}}" alt="{{accessoir.Accessory_icone}}"></i><i class="{{accessoir.Accessory_icone}}" alt="{{accessoir.Accessory_icone}}"></i>{% else %}<i class="{{accessoir.Accessory_icone}}"></i>{% endif %}&nbsp;{% endfor %}</td>
					<td>{{ item.PIC_Nom_netbios }}</td>
					<td>{{ item.PIC_Utilisateur }}</td>
					<td>{% if item.PIC_OS != none %}{{ item.PIC_OS }}{% else %}&nbsp;{% endif %}</td>
					
				</tr>
				{% if forloop.last %}
					<tr class="table-active">
						<td >&nbsp;</td>
						<td colspan="2">
							{% regroup items_imp by PIC_L_Site as imp_by_site %}
							{% for imp_site in imp_by_site %}
							{% regroup imp_site.list by PIC_L_Service as imp_by_service %}
								{% for imp_service in imp_by_service %}
									{% if imp_site.grouper == site.grouper and imp_service.grouper == service.grouper %}
										Nb d'imprimantes : {{imp_service.list|length}}
									{% endif %}
								{% endfor %}
							{% endfor %}
							&nbsp;
						</td>
						<td colspan="2">Nb de postes informatique : {{ forloop.counter }}</td>
						<td >&nbsp;</td>
					</tr>
				{% endif %}
		{% endfor %}
		<tr><td>&nbsp;</td></tr>
		
	{% endfor %}
	</table>

{% endfor %}
{% endblock %}

{% block right_panel %}
<div class="card-body">
	<div class="d-grid gap-2"><a class="btn btn-primary" href="/parc" role="button"><i class="fas fa-undo-alt"></i> Retour</a></div>
</div>
{% endblock %}