<header>
	<?php	
	switch ($page_header) {
		case 'index' :
			echo '<table id="index">
			<tr>
			<td id="titre">';
			echo '<div style="display:inline;float:left;">';			
			if (count($languages) > 1) {
				echo '<form id="language-form"><select name="language" id="language-select" onchange="changeLanguage(this.value)">';
	                foreach ($languages as $code => $name) {
	                    echo '<option value="' . htmlspecialchars($code) . '"' . ($code === $selectedLang ? ' selected' : '') . '>' . htmlspecialchars($name) . '</option>';
	                }
	                echo '
		            </select>
		        </form>';
		    }
		    else {
		    	echo '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;';
		    }
	        echo '</div><center>InfodocLog &nbsp; <i class="fa-solid fa-user-lock"></i>  &nbsp; '.ACCUEIL.'</center></td>';					
		break;
		case 'eval' :
			echo '<table id="eval">
					<tr>
					<td id="titre">InfodocLog &nbsp; <i class="fa-solid fa-ellipsis"></i>  &nbsp; '.EVALT.'</div></td>
					<style type="text/css">
					#td_eval {
					background-color: #fff;
					padding-bottom:0px; }
					</style>';
		break;
		case 'evals' :
			echo '<table id="eval">
					<tr>
					<td id="titre">InfodocLog &nbsp; <i class="fa-solid fa-ellipsis"></i>  &nbsp; '.EVALT.' & '.SEQUT.'</div></td>
					<style type="text/css">
					#td_eval {
					background-color: #fff;
					padding-bottom:0px; }
					</style>';
		break;
		case 'edit' :
			echo '<table id="edit">
					<tr>
					<td id="titre">InfodocLog &nbsp; <i class="fa-solid fa-ellipsis"></i>  &nbsp; '.SEQUT.'</td>
					<style type="text/css">
					#td_edit {
					background-color: #fff;
					padding-bottom:0px; }
					</style>';
		break;
		case 'edt' :
			echo '<table id="edt">
					<tr>
					<td id="titre">InfodocLog &nbsp; <i class="fa-solid fa-ellipsis"></i>  &nbsp; '.EDT1.'</td>
					<style type="text/css">
					#td_edt {
					background-color: #fff;
					padding-bottom:0px; }
					</style>';
		break;
		case 'freq' :
			echo '<table id="freq">
					<tr>
					<td id="titre">InfodocLog &nbsp; <i class="fa-solid fa-ellipsis"></i>  &nbsp; '.FREQT.'</td>
					<style type="text/css">
					#td_freq {
					background-color: #fff;
					padding-bottom:0px; }
					</style>';
		break;
		case 'freqr' :
			echo '<table id="freq">
					<tr>
					<td id="titre">InfodocLog &nbsp; <i class="fa-solid fa-ellipsis"></i>  &nbsp; '.RESA6.'</td>
					<style type="text/css">
					#td_freq {
					background-color: #fff;
					padding-bottom:0px; }
					</style>';
		break;
		case 'database' :
			echo '<table id="database">
					<tr>
					<td id="titre">InfodocLog &nbsp; <i class="fa-solid fa-ellipsis"></i>  &nbsp; '.DATAT.'</td>
					<style type="text/css">
					#td_data {
					background-color: #fff; 
					}
					</style>';
		break;
		case 'param' :
			echo '<table id="param">
					<tr>
					<td id="titre">InfodocLog &nbsp; <i class="fa-solid fa-ellipsis"></i>  &nbsp; '.PARAT.'</td>
					<style type="text/css">
					#td_param {
					background-color: #fff;
					padding-bottom:0px; }
					</style>';
		break;
		case 'aide' :
			echo '<table id="aide">
					<tr>
					<td id="titre">InfodocLog &nbsp; <i class="fa-solid fa-ellipsis"></i>  &nbsp; '.TUTOT.'</td>
					<style type="text/css">
					#td_aide {
					background-color: #fff;
					padding-bottom:0px; }
					</style>';
		break;
		}
		if(isset($_SESSION['user_id'])) {
			$table_name = $prefix . "_agenda";
			$check_table = mysqli_query($bdd, "SHOW TABLES LIKE '$table_name'");
			if (mysqli_num_rows($check_table) > 0) {
				$blocnotes = mysqli_query($bdd,"SELECT * FROM ".$prefix."_agenda WHERE SUBSTRING(options, 1, 1) = '1' 
					AND
					(
				        users = '".$_SESSION['user_id']."' 
				        OR users LIKE '".$_SESSION['user_id'].";%'  
				        OR users LIKE '%;".$_SESSION['user_id'].";%'
				        OR users LIKE '%;".$_SESSION['user_id']."'
				    ) ORDER BY date1 ASC");
				if(mysqli_num_rows($blocnotes)>0) {
					echo '<td class="agenda_todo">';
					$i=1;
					foreach($blocnotes as $blocnote) {
						$date1 = DateTime::createFromFormat('Y-m-d', $blocnote['date1']);
						$date2 = DateTime::createFromFormat('Y-m-d', $blocnote['date2']);
						echo '<li>';
						if($blocnote['texte']!='') { echo '<span title="'.htmlspecialchars(html_entity_decode(strip_tags($blocnote['texte']))).'">'; }
						if($blocnote['date2']!='0000-00-00') {
							echo FROM21.' '.$date1->format('d/m/Y').' '.TO2.' '.$date2->format('d/m/Y').DOTS.' ';
						}
						else {
							echo FOR1.' '.$date1->format('d/m/Y').DOTS.' ';
						}
						echo $blocnote['titre'];
						if($blocnote['texte']!='') { echo ' <i class="fa-solid fa-circle-info"></i></span>'; }
						echo '</li>';
						$i++;
						if($i==4) {
							if(mysqli_num_rows($blocnotes)>3) {
								echo '<li style="list-style-type: none;"><a onmousedown="toggleDiv(\'agenda_notes\');"><i class="fas fa-angle-double-right"></i> '.EDTC_AGE14.'</a></li>';
							}
							break;						
						}
					}				
					echo '</td>';
				}
				if(mysqli_num_rows($blocnotes)>3) {
					echo '<div id="agenda_notes" style="display:none;"><b>'.EDTC_AGE1.DOTS.'</b><br>';
					$blocnotes = mysqli_query($bdd,"SELECT * FROM ".$prefix."_agenda WHERE SUBSTRING(options, 1, 1) = '1' 
						AND
						(
					        users = '".$_SESSION['user_id']."' 
					        OR users LIKE '".$_SESSION['user_id'].";%'  
					        OR users LIKE '%;".$_SESSION['user_id'].";%'
					        OR users LIKE '%;".$_SESSION['user_id']."'
					    ) ORDER BY date1 ASC");
					foreach($blocnotes as $blocnote) {
						$date1 = DateTime::createFromFormat('Y-m-d', $blocnote['date1']);
						$date2 = DateTime::createFromFormat('Y-m-d', $blocnote['date2']);
						echo '<hr><i class="fas fa-bullseye"></i> ';
						if($blocnote['date2']!='0000-00-00') {
							echo FROM21.' '.$date1->format('d/m/Y').' '.TO2.' '.$date2->format('d/m/Y').DOTS.' ';
						}
						else {
							echo FOR1.' '.$date1->format('d/m/Y').DOTS.' ';
						}
						echo $blocnote['titre'].'</span>';
						if($blocnote['texte']!='') {
							echo $blocnote['texte'];
						}
						if($blocnote['notes']!='') {
							echo '<span title="'.htmlspecialchars(html_entity_decode(strip_tags($blocnote['notes']))).'" style="float:right;"><i class="fa-solid fa-circle-info"></i></span>';
						}
						echo '<br>';
					}
					echo '<hr><a href="edt.php?page=agenda"><i class="fas fa-angle-double-right"></i> '.EDTC_AGE3.'</a></div>';
				}
			}
		}
		$smart = 'nosmart';
		include('header_links.php');
		echo '</tr></table>';
		$smart = 'smart';
		echo '<div class="smart"><br><table class="headsmart"><tr>';
		include('header_links.php');
		echo '</tr></table></div>';
	?>
</header>
