<?php 
require_once(dirname(__DIR__, 1) . '/config.php');
require_once(BASE_PATH . '/db/idl_connect.php');
echo '<meta charset="utf-8" />';
		
if(isset($_SESSION['user_droits'])) {
	if($_SESSION['user_droits'][5]!="2")
	{
		echo '<p class="noaccess">'.NOMODULE.'<br><a href="../index.php">'.ACCUEIL.'</a></p>';
	}
	else {
		?><style type="text/css">
		#mda8 { background-color: #fff; }
		#mda8 td { border: 3px #086A87 solid; }
		#mda7 td { border: 0; }
		</style><?php
		if(isset($_POST['supprmajdiv'])) {
			mysqli_query($bdd,"DELETE FROM ".$prefix."_elevesmaj");
			echo '<script language="Javascript">
			<!--
			document.location.replace("database.php?page=consulter");
			// -->
			</script>';
		}
		if(isset($_POST['maj_send'])) {
			include('db/proc/maj_eleves.php');
		}
		$academie = mysqli_query($bdd,"SELECT * FROM ".$prefix."_etab WHERE academie <> '' OR pays <> ''");
		$etab_nb = mysqli_num_rows($academie);
		if($etab_nb!=0) {
			$acad_info = mysqli_fetch_assoc($academie);
			if($acad_info['pays']=='fra') { $acadexist = $acad_info['academie']; }
			else { $acadexist = $acad_info['pays']; }
		}
		else { $acadexist = ""; }
		echo DATAC_MAJ1;
		echo '<form enctype="multipart/form-data" action="" method="POST">
		'.DATAC_MAJ2.DATAC_INST6.'
		<p><span class="signal">'.DATAC_MAJ4.'</span>';
		if($acadexist=='fnc'||$acadexist=='civ') {
			$anneesco1 = date("Y");
			$anneesco2 = (date("Y")+1);
		}
		else {
			$anneesco1 = (date("Y")-1).'/'.date("Y");
			$anneesco2 = date("Y").'/'.(date("Y")+1);
		}
		$month = date("n");
		$result_tables = mysqli_query($bdd,"SHOW TABLE STATUS LIKE '".$prefix."_%'");
		$_SESSION['nb_tables'] = mysqli_num_rows($result_tables);
		if($result_tables && $result_tables->num_rows) {
			while($obj_table = mysqli_fetch_assoc($result_tables)) {
				echo '<input type="hidden" id="'.$obj_table['Name'].'" name="'.$obj_table['Name'].'" checked />';
			}
		}
		echo '<input type="hidden" name="hidden_save" id="input_save" checked />';
		echo '<input type="radio" name="annee_effectifs" id="'.$anneesco1.'" value="'.$anneesco1.'"';
		if($month<=7) { echo ' checked '; }
		echo ' /><label for="'.$anneesco1.'">'.$anneesco1.'</label>
		<input type="radio" name="annee_effectifs" id="'.$anneesco2.'" value="'.$anneesco2.'"';
		if($month>=8) { echo ' checked '; }
		echo ' /><label for="'.$anneesco2.'">'.$anneesco2.'</label></p>
		<div style="float:left;width:30%;padding-right:20px;">'.DATAC_MET1.DATAC_MAJ3.'
		<input type="checkbox" name="input_nom" id="input_nom" checked disabled /><label for="input_nom"> '.NAME.'</label><br>
			<input type="checkbox" name="input_prenom" id="input_prenom" checked disabled /><label for="input_prenom"> '.FORNAME.'</label><br>
			<input type="checkbox" name="input_naiss" id="input_naiss" checked disabled /><label for="input_naiss"> '.BDAY.' '.DATAC_INST3.'</label><br>
			<input type="checkbox" name="input_sexe" id="input_sexe" checked disabled /><label for="input_sexe"> '.SEX.' '.DATAC_INST4.'</label><br>
			<input type="checkbox" name="input_div" id="input_div" checked disabled /><label for="input_div"> '.DIV.' '.DATAC_INST2.'</label><br>
			<input type="checkbox" name="input_code" id="input_code" /><label for="input_code"> '.CODE.' '.DATAC_INST5.'</label><br>
			<input type="checkbox" name="input_mail" id="input_mail" /><label for="input_mail"> '.MAIL2.' '.DATAC_INST5.'</label><br>
			<input type="checkbox" name="input_identifiant" id="input_identifiant" /><label for="input_identifiant"> '.IDENT5.' '.DATAC_INST5.'</label><br>
			<input type="checkbox" name="input_mdp" id="input_mdp" /><label for="input_mdp"> '.PW3.' '.DATAC_INST5.'</label><br>
			<input type="checkbox" name="input_adresse" id="input_adresse" /><label for="input_adresse"> '.ADRESS1.' '.DATAC_INST5.'</label><br>

			<input class="boutontab" name="file_csv" type="file" accept=".csv" />
		</div>
		<div style="float:left;width:40%;">'.DATAC_MET2.DATAC_MAJ5.'
			<input type="checkbox" name="input_nom_xml" id="input_nom_xml" checked disabled /><label for="input_nom_xml"> '.NAME.DATAC_XML1.'</label><br>
				<input type="checkbox" name="input_prenom_xml" id="input_prenom_xml" checked disabled /><label for="input_prenom_xml"> '.FORNAME.DATAC_XML2.'</label><br>
				<input type="checkbox" name="input_naiss_xml" id="input_naiss_xml" checked disabled /><label for="input_naiss_xml"> '.BDAY.DATAC_XML3.' '.DATAC_INST3.'</label><br>
				<input type="checkbox" name="input_sexe_xml" id="input_sexe_xml" checked disabled /><label for="input_sexe_xml"> '.SEX.DATAC_XML4.'</label><br>
				<input type="checkbox" name="input_div_xml" id="input_div_xml" checked disabled /><label for="input_div_xml"> '.DIV.DATAC_XML5.' '.DATAC_INST2.'</label><br>
				<input type="checkbox" name="input_code_xml" id="input_code_xml" /><label for="input_code_xml"> '.CODE.DATAC_XML6.' '.DATAC_INST5.'</label><br>
				<input type="checkbox" name="input_mail_xml" id="input_mail_xml" /><label for="input_mail_xml"> '.MAIL2.DATAC_XML7.' '.DATAC_INST5.'</label><br>
				<input type="checkbox" name="input_identifiant_xml" id="input_identifiant_xml" /><label for="input_identifiant_xml"> '.IDENT5.DATAC_XML8.' '.DATAC_INST5.'</label><br>
				<input type="checkbox" name="input_mdp_xml" id="input_mdp_xml" /><label for="input_mdp_xml"> '.PW3.DATAC_XML9.' '.DATAC_INST5.'</label><br>
				<input type="checkbox" name="input_adresse_xml" id="input_adresse_xml" /><label for="input_adresse_xml"> '.ADRESS2.' '.DATAC_INST5.'</label><br>

				<input class="boutontab" name="file_xml" type="file" accept=".xml" />
				<br><input class="boutontab" name="file_xml2" type="file" accept=".xml">
		</div>
		<div style="clear:both;">
		   	<br>&nbsp; <br><input class="bouton boutdb" name="maj_send" type="submit" value="'.SENDFILE.'" />
		   </div>
		</form>';
	}		
}
else {
	include('include/noaccess.php');
	echo '<br><a href="../index.php">'.ACCUEIL.'</a></p>';
}
?>
