{% extends 'layout.twig' %}

{% import 'messagesysteme.twig' as msgSyst %}
{% import 'champs.twig' as form %}

{% block css %}
	<link rel="stylesheet" type="text/css" href="bootstrap/css/buttons.css?v={{d.versionCache}}">
{% endblock %}

{% block content %}

<div id="page-resa" class="col col-lg-12 col-md-12 col-xs-12">

	<h1 class="center">{{ trad.search_report_stats }}</h1>

	<form id="frmReport" method="get" action="?p=report">
		<input type="hidden" name="p" value="report">
		<input type="hidden" name="is_posted" value="y">

		<div class="col col-lg-4 col-md-4 col-xs-12">{{ trad.report_start }}{{ trad.deux_points }}</div>
		<div class="col col-lg-8 col-md-8 col-xs-12">{{ d.jQuery_DatePickerDebut |raw }}</div>

		<div class="col col-lg-4 col-md-4 col-xs-12">{{ trad.report_end }}{{ trad.deux_points }}</div>
		<div class="col col-lg-8 col-md-8 col-xs-12">{{ d.jQuery_DatePickerFin |raw }}</div>

		<div class="col col-lg-12 col-md-12 col-xs-12"><input type="radio" name="condition_et_ou" value="AND" {{ d.checkedAND }}> {{ trad.valide_toutes_les_conditions_suivantes }}</div>
		<div class="col col-lg-12 col-md-12 col-xs-12"><input type="radio" name="condition_et_ou" value="OR" {{ d.checkedOR }}> {{ trad.valide_au_moins_une_des_conditions_suivantes }}</div>

		{% for condition in conditions %}
			<div class="col col-lg-12 col-md-12 col-xs-12">
				<div class="form-inline">
					<div class="form-group">
						<select class="form-control" name="champ[]" size="1">
							<option value="" {%if condition.selectCritere == "" %}selected{%endif%}>{{ trad.choose }}</option>
							{% if settings.module_multisite == "Oui" %}
							<option value="site" {%if condition.selectCritere == "site" %}selected{%endif%}>{{ trad.site }}</option>
							{% endif %}
							<option value="area" {%if condition.selectCritere == "area" %}selected{%endif%}>{{ trad.match_area }}</option>
							<option value="room" {%if condition.selectCritere == "room" %}selected{%endif%}>{{ trad.room }}</option>
							<option value="type" {%if condition.selectCritere == "type" %}selected{%endif%}>{{ trad.type }}</option>
							<option value="name" {%if condition.selectCritere == "name" %}selected{%endif%}>{{ trad.namebooker }}</option>
                            <option value="descr" {%if condition.selectCritere == "descr" %}selected{%endif%}>{{ trad.match_descr }}</option>
							<option value="login" {%if condition.selectCritere == "login" %}selected{%endif%}>{{ trad.match_login }}</option>
							{% for champadd in condition.champAdd %}
								<option value="addon_{{champadd.id}}" {%if champadd.select == 1 %}selected{%endif%}>{{champadd.nom}}</option>
							{% endfor %}
						</select>
					</div>
					<div class="form-group">
						<select class="form-control" name="type_recherche[]" size="1">
							<option value="1" {%if condition.selectType == 1 %}selected{%endif%}>{{ trad.contient }}{{ trad.deux_points }}</option>
							<option value="0" {%if condition.selectType == 0 %}selected{%endif%}>{{ trad.ne_contient_pas }}{{ trad.deux_points }}</option>
						</select>
					</div>
					<div class="form-group">
						<input class="form-control" type="text" name="texte[]" value="{{condition.motRecherche}}" size="20" />
					</div>
				</div>						
			</div>
		{% endfor %}

		<p>{{ trad.include }}{{ trad.deux_points }}</p>
		<div class="col col-lg-12 col-md-12 col-xs-12"><input type="radio" name="summarize" value="1" {% if d.summarize == 1 %}checked{%endif%}> {{ trad.report_only }}</div>
		<div class="col col-lg-12 col-md-12 col-xs-12"><input type="radio" name="summarize" value="2" {% if d.summarize == 2 %}checked{%endif%}> {{ trad.summary_only }}</div>
		<div class="col col-lg-12 col-md-12 col-xs-12"><input type="radio" name="summarize" value="3" {% if d.summarize == 3 %}checked{%endif%}> {{ trad.report_and_summary }}</div>

		<div class="col col-lg-4 col-md-4 col-xs-12">{{ trad.summarize_by }} {{ trad.summarize_by_precisions }}{{ trad.deux_points }}</div>
		<div class="col col-lg-8 col-md-8 col-xs-12">
			<select class="form-control" name="sumby" size="1">
				<option value="6" {%if d.sumby == "6" %}selected{%endif%}>{{ trad.sum_by_creator }}</option>
				<option value="3" {%if d.sumby == "3" %}selected{%endif%}>{{ trad.sum_by_descrip }}</option>
				<option value="5" {%if d.sumby == "5" %}selected{%endif%}>{{ trad.type }}</option>
				{% for champadd in champsaddresume %}
					<option value="addon_{{champadd.id}}" {%if champadd.select == 1 %}selected{%endif%}>{{champadd.nom}}</option>
				{% endfor %}
			</select>
		</div>
		<div>
			<input class="btn btn-primary" type="submit" name="submit" value="{{trad.submit}}">
		</div>
	</form>

	{%if d.resultat == 1 %}
		<div class="col col-xs-12">

			<hr>
			{%if d.nbResultat == 0 %}
				<p><b>{{ trad.nothing_found }}</b></p>
			{% else %}
				<p><b>{{ d.nbResultat }} {%if d.nbResultat == 1 %}{{ trad.entry_found }}{% else %}{{ trad.entries_found }}{% endif %}</b></p>

				{%if d.summarize == 1 or d.summarize == 3 %}
					<div id="example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap">

						<div class="row">
							<div class="col col-sm-12">
								<table id="example" class="table table-striped table-bordered dataTable" style="width: 100%;" role="grid" aria-describedby="example_info">
									<thead>
										<tr role="row">
											{% if settings.module_multisite == "Oui" %}
												<th class="sorting" tabindex="0" aria-controls="example" rowspan="1" colspan="1">{{trad.site}}</th>
											{% endif %}
											<th class="sorting sorting_desc" tabindex="0" aria-controls="example" rowspan="1" colspan="1">{{trad.match_area}}</th>
											<th class="sorting" tabindex="0" aria-controls="example" rowspan="1" colspan="1">{{trad.room}}</th>
											<th class="sorting" tabindex="0" aria-controls="example" rowspan="1" colspan="1">{{trad.namebooker}}</th>
                                            <th class="sorting" tabindex="0" aria-controls="example" rowspan="1" colspan="1">{{trad.date}}</th>
											<th class="sorting" tabindex="0" aria-controls="example" rowspan="1" colspan="1">{{trad.time}}</th>
											<th class="sorting" tabindex="0" aria-controls="example" rowspan="1" colspan="1">{{trad.duration}}</th>
                                            <th class="sorting" tabindex="0" aria-controls="example" rowspan="1" colspan="1">{{trad.datefin}}</th>
											<th class="sorting" tabindex="0" aria-controls="example" rowspan="1" colspan="1">{{trad.time}}</th>
											<th class="sorting" tabindex="0" aria-controls="example" rowspan="1" colspan="1">{{trad.match_descr}}</th>
											<th class="sorting" tabindex="0" aria-controls="example" rowspan="1" colspan="1">{{trad.type}}</th>
											<th class="sorting" tabindex="0" aria-controls="example" rowspan="1" colspan="1">{{trad.match_login}}</th>
											<th class="sorting" tabindex="0" aria-controls="example" rowspan="1" colspan="1">{{trad.lastupdate}}</th>
											<th class="sorting" tabindex="0" aria-controls="example" rowspan="1" colspan="1">{{trad.moderation}}</th>
											{% for champadd in champsaddresume %}
												<th class="sorting" tabindex="0" aria-controls="example" rowspan="1" colspan="1">{{champadd.nom}}</th>
											{% endfor %}
										</tr>
									</thead>
									<tbody>
										{% for resa in listeresa %}
											<tr class="odd">
												{% if settings.module_multisite == "Oui" %}
													<td>{{resa.site}}</td>
												{% endif %}
												<td title="{{resa.domainedesc}}">{{resa.domaine}}</td>
												<td>{{resa.ressource}}</td>
												<td><a href="app.php?p=vuereservation&id={{resa.idresa}}">{{resa.descriptionc}}</a></td>
												<td data-order="{{resa.datedebutts}}">{{resa.datedebut}}</td>
                                                <td>{{resa.heuredebut}}</td>
												<td>{{resa.duree}}</td>
												<td data-order="{{resa.datefints}}">{{resa.datefin}}</td>
												<td>{{resa.heurefin}}</td>
												<td>{{resa.descriptionl}}</td>
												<td>{{resa.type}}</td>
												<td>{{resa.beneficiaire}}</td>
												<td data-order="{{resa.datemajts}}">{{resa.datemaj}}</td>
												<td>
													{% if resa.moderate == 1 %}
														{{trad.en_attente_moderation}}
													{% elseif resa.moderate == 2 %}
														{{trad.moderation_acceptee}}
													{% elseif resa.moderate == 3 %}
														{{trad.moderation_refusee}}
													{% endif %}
												</td>

												{% for champaddval in resa.champaddvaleur %}
													<td>{{champaddval.val}}</td>
												{% endfor %}
											</tr>
										{% endfor %}
									</tbody>
									<tfoot>
										<tr>
											{% if settings.module_multisite == "Oui" %}
											<th rowspan="1" colspan="1">{{trad.site}}</th>
											{% endif %}
											<th rowspan="1" colspan="1">{{trad.match_area}}</th>
											<th rowspan="1" colspan="1">{{trad.room}}</th>
											<th rowspan="1" colspan="1">{{trad.namebooker}}</th>
                                            <th rowspan="1" colspan="1">{{trad.date}}</th>
											<th rowspan="1" colspan="1">{{trad.time}}</th>
											<th rowspan="1" colspan="1">{{trad.duration}}</th>
											<th rowspan="1" colspan="1">{{trad.match_descr}}</th>
											<th rowspan="1" colspan="1">{{trad.type}}</th>
											<th rowspan="1" colspan="1">{{trad.match_login}}</th>
											<th rowspan="1" colspan="1">{{trad.lastupdate}}</th>
											<th rowspan="1" colspan="1">{{trad.moderation}}</th>
											{% for champadd in champsaddresume %}
												<th rowspan="1" colspan="1">{{champadd.nom}}</th>
											{% endfor %}
										</tr>
									</tfoot>
								</table>
							</div>
						</div>
						<div class="row">
							<div class="col col-sm-5"><div class="dataTables_info" id="example_info" role="status" aria-live="polite"></div></div>
							<div class="col col-sm-7"><div class="dataTables_paginate paging_simple_numbers" id="example_paginate"><ul class="pagination"></ul></div></div>
						</div>
					</div>
				{% endif %}
				{% if d.summarize == 2 or d.summarize == 3 %}
					<h1>{% if d.enablePeriods == y %}{{ trad.summary_header_per }}{% else %}{{ trad.summary_header }}{% endif %}</h1>
					<div id="resume_wrapper" class="dataTables_wrapper form-inline dt-bootstrap">

						<div class="row">
							<div class="col col-sm-12">
								<table id="resume" class="table table-striped table-bordered dataTable" style="width: 100%;" role="grid" aria-describedby="example_info">
									<thead>
										<tr role="row">
											{{listeresume.premLigne |raw}}
										</tr>
									</thead>
									<tbody>
											{% for lignex in listeresume.xLignes %}
												<tr class="odd">{{lignex.ligne |raw}}</tr>
											{% endfor %}
											<tr>
												{{listeresume.dernLigne |raw}}
											</tr>
									</tbody>
									<tfoot>
										<tr>{{listeresume.footLigne |raw}}</tr>
									</tfoot>
								</table>
							</div>
						</div>
						<div class="row">
							<div class="col col-sm-5"><div class="dataTables_info" id="resume_info" role="status" aria-live="polite"></div></div>
							<div class="col col-sm-7"><div class="dataTables_paginate paging_simple_numbers" id="resume_paginate"><ul class="pagination"></ul></div></div>
						</div>
					</div>
				{% endif %}
			{% endif %}
		</div>
	{% endif %}

</div>

{% endblock %}

{% block javascript %}
<!--
<script type="text/javascript" language="javascript" src="node_modules/datatables/media/js/jquery.dataTables.min.js"></script>
	-->
	<script type="text/javascript" language="javascript" src="js/jquery.js"></script>
	
	<script type="text/javascript" language="javascript" src="js/dataTables.js"></script>
	<script type="text/javascript" language="javascript" src="js/dataTables_002.js"></script>
	<script type="text/javascript" language="javascript" src="js/buttons_002.js"></script>
	<script type="text/javascript" language="javascript" src="js/jszip.min.js"></script>
	<script type="text/javascript" language="javascript" src="js/pdfmake.js"></script>
	<script type="text/javascript" language="javascript" src="js/vfs_fonts.js"></script>
	<script type="text/javascript" language="javascript" src="js/buttons_004.js"></script>
	<script type="text/javascript" language="javascript" src="js/buttons_003.js"></script>

	<script type="text/javascript" language="javascript" src="node_modules/datatables/media/js/dataTables.buttons.min.js"></script>


	<script type="text/javascript" language="javascript" src="node_modules/datatables/media/js/buttons.html5.min.js"></script>
	<script type="text/javascript" language="javascript" src="node_modules/datatables/media/js/buttons.print.min.js"></script>
	<script type="text/javascript" language="javascript" src="node_modules/datatables/media/js/buttons.colVis.min.js"></script>


	<script type="text/javascript" class="init">
		$(document).ready(function() {
			var table = $('#example').DataTable( {
				lengthMenu: [
					[10, 25, 50, 100, -1],
					[10, 25, 50, 100, 'All']
				],
				buttons: [ 'copy', 'excel', 'csv',
					{
						extend: 'pdfHtml5',
						orientation: 'landscape',
						pageSize: 'LEGAL'
					}
					, 'colvis' 
				],
			} );

			table.buttons().container()
				.appendTo( '#example_wrapper .col-sm-6:eq(0)' );
		} );
		$(document).ready(function() {
			var table = $('#resume').DataTable( {
				lengthChange: false,
				buttons: [ 'copy', 'excel', 'csv',
					{
						extend: 'pdfHtml5',
						orientation: 'landscape',
						pageSize: 'LEGAL'
					}
					, 'colvis' 
				],
			} );

			table.buttons().container()
				.appendTo( '#resume_wrapper .col-sm-6:eq(0)' );
		} );
	</script>
{% endblock %}