<?php
echo '<meta charset="utf-8" />';
if(isset($_SESSION['user_droits'])) {
	if($_SESSION['user_droits'][4]!="2")
	{
		echo '<p class="noaccess">'.NOMODULE.'<br><a href="./index.php">'.ACCUEIL.'</a></p>';
	}
	else {
	?><style type="text/css">
	#mpa1 { background-color: #fff; }
	#mpa1 td { border: 3px #7D7777 solid; }
	</style><?php	
	echo '<h1>'.PARAC_IND1.'</h1>';
	include('db/proc/etab_config_check.php');
	echo'<h2>'.PARANAV2.'</h2>';
	echo '<p><b><a href="param.php?page=users">'.PARAC_IND2.'</a>.</b></p>';
	//ETABLISSEMENT
	echo '<h2>'.PARANAV3.'</h2>';
	$etab = mysqli_query($bdd,"SELECT * FROM ".$prefix."_etab");
	$etab_nb = mysqli_num_rows($etab);
	if($etab_nb==0) {
		echo PARAC_IND3;
	}
	else {
		$etab_info = mysqli_fetch_assoc($etab);
		echo '<table class="paramform">';
		echo '<tr><th colspan="6">'.$etab_info['nom'].' - '.$etab_info['ville'].' ('.$etab_info['cp'].')</th></th>';
		echo '<tr><td colspan="6"><b>'.PARAC_ETAB2.'</b> '.$etab_info['adresse'].' '.$etab_info['cp'].' '.$etab_info['ville'].'</td></tr>';
		echo '<tr><td colspan="2"><b>'.PARAC_ETAB5_TINY.'</b> '.$etab_info['tel'].'.</td><td colspan="2"><b>'.PARAC_ETAB6.'</b> '.$etab_info['fax'].'.</td><td colspan="2"><b>'.MAIL.DOTS.'</b> '.$etab_info['mail'].'</td></tr>';
		echo '<tr><td colspan="3"><b>'.PARAC_ETAB7_TINY.'</b> '.$etab_info['rne'].'</td><td colspan="3"><b>'.PARAC_ETAB8_TINY.'</b> '.$etab_info['academie'].'</td></tr>';
		echo '</table><br>';
		echo '<p><b><a href="param.php?page=etab">'.PARAC_IND4.'</a>.</b></p>';
	}
	// HORAIRES
	echo'<h2>Horaires</h2>';
	$hor = mysqli_query($bdd,"SELECT * FROM ".$prefix."_horaires");
	$hor_nb = mysqli_num_rows($hor);
	if($hor_nb==0) {
		echo '<p><a href="param.php?page=horaires">'.FREQ_HORNEED.'</a>.</p>';
	}
	else {
		$creneau = mysqli_query($bdd,"SELECT * FROM ".$prefix."_horaires ORDER BY num_creneau ASC");
		$creneau_nb = mysqli_num_rows($creneau);
		echo '<table class="paramform">';
		echo '<tr><th>N°</th><th>'.PARAC_IND5.'</th><th>'.PARAC_HOR11.'</th><th>'.PARAC_HOR11.'</th></tr>';
		while($creneau_info = mysqli_fetch_assoc($creneau)) {
			echo '<tr>
			<td>'.$creneau_info['num_creneau'].'</td>
			<td>';
			$cren = $creneau_info['hor_name'];
			$deb_cren = substr("$cren", 0, 1);
			echo MOMENT[$deb_cren];
			$fin_cren = substr("$cren", 1, 1);
			echo ' '.$fin_cren.'';
			echo '</td>
			<td>';
			$deb = $creneau_info['debut'];
			$dh = substr("$deb", 0, 2);
			$dm = substr("$deb", 3, 2);
			echo ''.$dh.'h'.$dm.'</td><td>';
			$fin = $creneau_info['fin'];
			$fh = substr("$fin", 0, 2);
			$fm = substr("$fin", 3, 2);
			echo ''.$fh.'h'.$fm.'</td></tr>';
		}
		echo '</table>';
		echo '<p><b><a href="param.php?page=horaires">'.PARAC_IND6.'</a>.</b></p>';
	}
	// VERSION
	echo '<h2>'.PARAC_IND7.'</h2>
	<p>'.PARAC_IND8.' ';
	$versin = mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom='version_log'");
	$versin_info = mysqli_fetch_assoc($versin);
		if($versin_info['valeur']<0.21) {
			$vers_aff = substr($versin_info['valeur'],2,2);
			echo 'Alpha '.$vers_aff.' ('.$versin_info['valeur'].')</p>';
		}
		else if($versin_info['valeur']>=0.20&&$versin_info['valeur']<=0.24) {
			$vers_aff = substr($versin_info['valeur'],2,2);
			echo 'Bêta '.$vers_aff.' ('.$versin_info['valeur'].').</p>';
		}
		else {
			echo ''.$versin_info['valeur'].'</p>';
		}
	echo '<p>'.PARAC_IND9.' ';
	$version = mysqli_query($bdd,"SELECT valeur FROM ".$prefix."_parametres WHERE param_nom='version_bdd'");
	$version_info = mysqli_fetch_assoc($version);
	echo ''.$version_info['valeur'].'</p>';
	echo '<p><b><a href="param.php?page=majlog">'.PARAC_IND10.'</a>.</b></p>';
	}	
	
}
else {
	include('include/noaccess.php');
	echo '<br><a href="./index.php">'.ACCUEIL.'</a></p>';
}
?>