<form action="<?php echo $tpl['current_url']; ?>" method="post">
	<div>
		<p class="field">
			<input<?php if (empty($_POST) || isset($_POST['files_status'])) : ?> checked<?php endif; ?> id="files_status" name="files_status" type="checkbox">
			<label for="files_status"><?php echo __('Activer les nouveaux fichiers'); ?></label>
		</p>
		<p class="field">
			<input<?php if (isset($_POST['delete_rejected_files'])) : ?> checked<?php endif; ?> id="delete_rejected_files" name="delete_rejected_files" type="checkbox">
			<label for="delete_rejected_files"><?php echo __('Supprimer les fichiers et répertoires rejetés'); ?></label>
		</p>
<?php if (isset($tpl['notify_groups_exclude'])) : ?>
		<input name="notify_groups_exclude" type="hidden" value="<?php echo $tpl['notify_groups_exclude']; ?>">
<?php endif; ?>
		<input name="anticsrf" type="hidden" value="<?php echo $tpl['anticsrf'](); ?>">
		<input type="hidden" name="action" value="scan">
		<input type="submit" class="submit" value="<?php echo __('Scanner le répertoire des albums'); ?>" data-help-icon="scan">
	</div>
</form>

<?php if (isset($tpl['scan'])) : ?>
<div class="report_classic" id="scan_report">

<?php if (isset($tpl['error'])) : ?>
	<div class="report_msg report_error"><p><?php echo $tpl['error']; ?></p></div>
<?php else : ?>
<?php if (isset($tpl['time_exceeded'])) : ?>
	<div class="report_msg report_info"><p><?php echo $tpl['time_exceeded']; ?></p></div>
	<br>
<?php endif; ?>
<?php if (isset($tpl['datetime_link'])) : ?>
	<p id="datetime_link"><a href="<?php echo $tpl['datetime_link']; ?>"><?php echo __('Gérer les nouveaux fichiers'); ?></a></p>
	<br>
<?php endif; ?>
	<h3><?php echo __('Rapport résumé'); ?></h3>
<?php if (isset($tpl['error_files'])) : ?>
	<div class="report_msg report_error"><p><?php echo $tpl['error_files']; ?></p></div>
<?php endif; ?>
<?php if (isset($tpl['added_none'])) : ?>
	<div class="report_msg report_info"><p><?php echo $tpl['added_none']; ?></p></div>
<?php endif; ?>
<?php if (isset($tpl['added_files'])) : ?>
	<div class="report_msg report_success"><p><?php echo $tpl['added_files']; ?></p></div>
<?php endif; ?>
<?php if (isset($tpl['updated_none'])) : ?>
	<div class="report_msg report_info"><p><?php echo $tpl['updated_none']; ?></p></div>
<?php endif; ?>
<?php if (isset($tpl['updated_files'])) : ?>
	<div class="report_msg report_success"><p><?php echo $tpl['updated_files']; ?></p></div>
<?php endif; ?>
<?php if (isset($tpl['rejected'])) : ?>
	<div class="report_msg report_warning"><p><?php echo $tpl['rejected']; ?></p></div>
<?php endif; ?>
<?php if (isset($tpl['details'])) : ?>
	<h3 id="report_details">
		<a class="js showhide" rel="#scan_report_details" href="javascript:;"><?php echo __('Rapport détaillé'); ?></a>
	</h3>
	<div id="scan_report_details" class="show">
<?php if (isset($tpl['details']['files_errors'])) : ?>
		<div class="report_details report_details_errors">
			<table>
				<tr>
					<th><?php echo __('Objet'); ?></th>
					<th><?php echo __('Erreur'); ?></th>
				</tr>
<?php foreach ($tpl['details']['files_errors'] as &$i) : ?>
				<tr>
					<td class="object"><?php echo $i['file']; ?></td>
					<td><?php echo $i['message']; ?></td>
				</tr>
<?php endforeach; ?>
			</table>
		</div>
<?php endif; ?>
<?php if (isset($tpl['details']['albums_added'])) : ?>
		<div class="report_details">
			<table>
				<tr>
					<th><?php echo __('Album ajouté'); ?></th>
					<th><?php echo __('Nombre d\'images'); ?></th>
					<th><?php echo __('Nombre de vidéos'); ?></th>
					<th><?php echo __('Poids'); ?></th>
				</tr>
<?php foreach ($tpl['details']['albums_added'] as &$i) : ?>
				<tr>
					<td class="object"><?php echo $i['album']; ?></td>
					<td class="number"><?php echo $i['nb_images']; ?></td>
					<td class="number"><?php echo $i['nb_videos']; ?></td>
					<td class="number"><?php echo $i['filesize']; ?></td>
				</tr>
<?php endforeach; ?>
			</table>
		</div>
<?php endif; ?>
<?php if (isset($tpl['details']['albums_updated'])) : ?>
		<div class="report_details">
			<table>
				<tr>
					<th><?php echo __('Album mis à jour'); ?></th>
					<th><?php echo __('Nombre d\'images ajoutées'); ?></th>
					<th><?php echo __('Nombre de vidéos ajoutées'); ?></th>
					<th><?php echo __('Poids ajouté'); ?></th>
				</tr>
<?php foreach ($tpl['details']['albums_updated'] as &$i) : ?>
				<tr>
					<td class="object"><?php echo $i['album']; ?></td>
					<td class="number"><?php echo $i['nb_images']; ?></td>
					<td class="number"><?php echo $i['nb_videos']; ?></td>
					<td class="number"><?php echo $i['filesize']; ?></td>
				</tr>
<?php endforeach; ?>
			</table>
		</div>
<?php endif; ?>
<?php if (isset($tpl['details']['dirs_rejected'])) : ?>
		<div class="report_details report_details_warning">
			<table>
				<tr>
					<th><?php echo __('Catégorie rejetée'); ?></th>
					<th><?php echo __('Cause'); ?></th>
				</tr>
<?php foreach ($tpl['details']['dirs_rejected'] as &$i) : ?>
				<tr>
					<td class="object"><?php echo $i['dir']; ?></td>
					<td><?php echo $i['message']; ?></td>
				</tr>
<?php endforeach; ?>
			</table>
		</div>
<?php endif; ?>
<?php if (isset($tpl['details']['files_rejected'])) : ?>
		<div class="report_details report_details_warning">
			<table>
				<tr>
					<th><?php echo __('Fichier rejeté'); ?></th>
					<th><?php echo __('Album'); ?></th>
					<th><?php echo __('Cause'); ?></th>
				</tr>
<?php foreach ($tpl['details']['files_rejected'] as &$i) : ?>
				<tr>
					<td class="object"><?php echo $i['file']; ?></td>
					<td><?php echo $i['dir']; ?></td>
					<td><?php echo $i['message']; ?></td>
				</tr>
<?php endforeach; ?>
			</table>
		</div>
<?php endif; ?>
	</div>
	<script nonce="<?php echo CSP_NONCE; ?>" type="text/javascript">document.querySelector('#scan_report_details').classList.remove('show');</script>
<?php endif; ?>
</div>
<?php endif; ?>
<?php endif; ?>