<?php
// Ajout d'une colonne sexe dans la table ".$prefix."_freq
$freqsex_alter = "ALTER TABLE ".$prefix."_freq ADD sexe CHAR(1)";
mysqli_query($bdd,$freqsex_alter);
// Transfert du sexe des élèves dans cette nouvelle colonne
$freq_select = "SELECT * FROM ".$prefix."_freq freq
INNER JOIN ".$prefix."_eleves eleves
ON freq.eleves_id = eleves.eleves_id";
$freq = mysqli_query($bdd,$freq_select);
$freq_nb = mysqli_num_rows($freq);
if($freq_nb!=0) {
	while($freq_info=mysqli_fetch_assoc($freq)) {
		$freq_update="UPDATE ".$prefix."_freq SET sexe = '".$freq_info['sexe']."' WHERE freq_id = ".$freq_info['freq_id']."";
		mysqli_query($bdd,$freq_update);
	}
}
// Ajout d'un paramètre de signalisation d'appel terminé
$appels_verif = "SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_appel'";
$appels = mysqli_query($bdd,$appels_verif);
$appels_nb = mysqli_num_rows($appels);
if($appels_nb==0) {
	$appel_insert = "INSERT INTO ".$prefix."_parametres (param_id, param_nom, valeur, comments) VALUES ('', 'freq_appel', '1:1', 'Option de signalisation d''appel en consultation de la fréquentation.')";
	$appel = mysqli_query($bdd,$appel_insert);
}
// Ajout d'une colonne consult dans la table ".$prefix."_freqactiv
$freqconsult_alter = "ALTER TABLE ".$prefix."_freqactiv ADD consult_activ INT(1) NOT NULL";
mysqli_query($bdd,$freqconsult_alter);
// Valeur 1 par défaut dans cette nouvelle colonne
$freqconsult_select = "SELECT * FROM ".$prefix."_freqactiv";
$freqconsult = mysqli_query($bdd,$freqconsult_select);
$freqconsult_nb = mysqli_num_rows($freqconsult);
if($freqconsult_nb!=0) {
	while($freqconsult_info=mysqli_fetch_assoc($freqconsult)) {
		$freqconsult_update="UPDATE ".$prefix."_freqactiv SET consult_activ = '1' WHERE activ_id = ".$freqconsult_info['activ_id']."";
		mysqli_query($bdd,$freqconsult_update);
	}
}
// version bdd :
$versbdd_up = "UPDATE ".$prefix."_parametres SET valeur = '0.14' WHERE param_nom = 'version_bdd'";
mysqli_query($bdd,$versbdd_up);
?>