<?php

//modification de couleurs de domaines
mysqli_query($bdd,"UPDATE ".$prefix."_edtcode SET bgcolor_code = '#EFD242' WHERE code_id = 'HDA' AND bgcolor_code = '#CCFFFF'");
mysqli_query($bdd,"UPDATE ".$prefix."_edtcode SET bgcolor_code = '#1E7FCB' WHERE code_id = 'SVT' AND bgcolor_code = '#003399'");
mysqli_query($bdd,"UPDATE ".$prefix."_edtcode SET bgcolor_code = '#FFF48D' WHERE code_id = 'Art pla.' AND bgcolor_code = '#333366'");
mysqli_query($bdd,"UPDATE ".$prefix."_edtcode SET bgcolor_code = '#E6E697' WHERE code_id = 'EPI' AND bgcolor_code = '#330033'");
mysqli_query($bdd,"UPDATE ".$prefix."_edtcode SET bgcolor_code = '#F4C430' WHERE code_id = 'Santé' AND bgcolor_code = '#993300'");

//ajout d'une option de gestion des exclusions (raisons, durées)
$verif_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_excluopt'"));
if($verif_nb==0) {
	mysqli_query($bdd,"INSERT INTO ".$prefix."_parametres (param_nom, valeur, comments) VALUES ('freq_excluopt', '0', 'Option de gestion des raisons et durées des exclusions.')");
}

// création de la table _exclucauses
mysqli_query($bdd,"CREATE TABLE IF NOT EXISTS ".$base.".".$prefix."_exclucauses (exclucause_id INT ( 11 ) NOT NULL AUTO_INCREMENT , exclucause_txt VARCHAR ( 50 ) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY ( exclucause_id ) ) ENGINE = MYISAM DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci;");

// création de la table _exclusions
mysqli_query($bdd,"CREATE TABLE IF NOT EXISTS ".$base.".".$prefix."_exclusions (exclusion_id INT ( 11 ) NOT NULL AUTO_INCREMENT, eleves_id INT( 11 ) DEFAULT NULL, exclucause_id INT( 11 ) DEFAULT NULL, date_exclusion date DEFAULT NULL, date_info date DEFAULT NULL, date_fin date DEFAULT NULL, excluactivs VARCHAR( 200 ) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY ( exclusion_id ) ) ENGINE = MYISAM DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci;");

// création de la table _limitstxt
mysqli_query($bdd,"CREATE TABLE IF NOT EXISTS ".$base.".".$prefix."_limitstxt (limittxt_id INT ( 11 ) NOT NULL AUTO_INCREMENT , limits_txt VARCHAR ( 100 ) COLLATE utf8_unicode_ci NOT NULL, espace_id INT ( 11 ) DEFAULT NULL, PRIMARY KEY ( limittxt_id ) ) ENGINE = MYISAM DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci;");

// création de la table _limits
mysqli_query($bdd,"CREATE TABLE IF NOT EXISTS ".$base.".".$prefix."_limits (limit_id INT ( 11 ) NOT NULL AUTO_INCREMENT, eleves_id INT( 11 ) DEFAULT NULL, limittxt_id INT( 11 ) DEFAULT NULL, date_debut date DEFAULT NULL, date_fin date DEFAULT NULL, PRIMARY KEY ( limit_id ) ) ENGINE = MYISAM DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci;");

// options pour les exclusions et limitations
$verif_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_excluopt_raisons'"));
if($verif_nb==0) {
	mysqli_query($bdd,"INSERT INTO ".$prefix."_parametres (param_nom, valeur, comments) VALUES ('freq_excluopt_raisons', '0', 'Option de gestion des raisons des exclusions.')");
}
$verif_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_excluopt_signal'"));
if($verif_nb==0) {
	mysqli_query($bdd,"INSERT INTO ".$prefix."_parametres (param_nom, valeur, comments) VALUES ('freq_excluopt_signal', '0', 'Option de signalement des exclusions.')");
}
$verif_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_excluopt_signalduree'"));
if($verif_nb==0) {
	mysqli_query($bdd,"INSERT INTO ".$prefix."_parametres (param_nom, valeur, comments) VALUES ('freq_excluopt_signalduree', '0', 'Durée par défaut de signalement des exclusions.')");
}
$verif_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_excluopt_exc'"));
if($verif_nb==0) {
	mysqli_query($bdd,"INSERT INTO ".$prefix."_parametres (param_nom, valeur, comments) VALUES ('freq_excluopt_exc', '0', 'Option d\'exclusions sur la durée.')");
}
$verif_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_excluopt_excduree'"));
if($verif_nb==0) {
	mysqli_query($bdd,"INSERT INTO ".$prefix."_parametres (param_nom, valeur, comments) VALUES ('freq_excluopt_excduree', '0', 'Durée par défaut des exclusions.')");
}
$verif_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_excluopt_limit'"));
if($verif_nb==0) {
	mysqli_query($bdd,"INSERT INTO ".$prefix."_parametres (param_nom, valeur, comments) VALUES ('freq_excluopt_limit', '0', 'Option de gestion de limitations d\'usages.')");
}
$verif_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_excluopt_limitduree'"));
if($verif_nb==0) {
	mysqli_query($bdd,"INSERT INTO ".$prefix."_parametres (param_nom, valeur, comments) VALUES ('freq_excluopt_limitduree', '0', 'Durée par défaut des limitations.')");
}
$verif_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_excluopt_activs'"));
if($verif_nb==0) {
	mysqli_query($bdd,"INSERT INTO ".$prefix."_parametres (param_nom, valeur, comments) VALUES ('freq_excluopt_activs', 'TOUTES', 'Activités concernées par une exclusion, par défaut.')");
}	

// version bdd :
mysqli_query($bdd,"UPDATE ".$prefix."_parametres SET valeur = '0.29' WHERE param_nom = 'version_bdd'");

?>