<?
#########################################################################################
# Modifier un projet de Pnyx #
# Auteur : V. Blais #
# Création : 2006-05-02 #
# Modification : 2008-11-17 #
# #
# Pnyx - une application Web (PHP/MySQL) d'élections virtuelles conçue pour des élèves #
# du primaire et du secondaire, dans lequel ils sont amenés à faire des propositions #
# en ligne et voter pour leur favorite, sous la supervision d'un enseignant. #
# #
# Copyright (C) <2008 - 2009> #
# <Service national du RÉCIT de l'univers social de la Commission scolaire de la #
# Pointe-de-l'Île> #
# #
# This program is free software; you can redistribute it and/or modify it under the #
# terms of the GNU General Public License as published by the Free Software Foundation. #
# This program is distributed in the hope that it will be useful, but WITHOUT ANY #
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A #
# PARTICULAR PURPOSE. See the GNU General Public License for more details. #
# You should have received a copy of the GNU General Public License along with this #
# program as the file LICENSE.txt; if not, please see #
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. #
# #
# Service national du RÉCIT de l'univers social #
# http://www.recitus.qc.ca #
# Contact e-mail : steve-hide@address.com #
#########################################################################################
require "entete_php.php";
# ou verifier si la session est valide
# puis verifier si l'usager dispose des autorisations requises
# pour la saisie
verifier_session();
acces_admin("mod_projet.php");
if(isset($HTTP_POST_VARS['type_action'])){
if ($HTTP_POST_VARS['type_action'] == "modifier"){
/*
$requete_sql = "SELECT *
FROM projet
WHERE projet_id = \"$HTTP_POST_VARS[id_projet]\"
";
$reponse_projet = bd_executer_sql($requete_sql);
$ligne_projet = mysql_fetch_array($reponse_projet);
# $nom = str_replace(" ", "_",$HTTP_POST_VARS[nom]);
# $nom = accents($nom);
# $dir = "pancartes/".$HTTP_POST_VARS[id_projet]."_".$nom;
# $nom_anc = str_replace(" ", "_",$ligne_projet[nom]);
# $nom_anc = accents($nom_anc);
# $dir_anc = "pancartes/".$ligne_projet[projet_id]."_".$nom_anc;
rename($dir_anc, $dir);
*/
$international = 0;
$national = 0;
$local = 0;
$cycle1p = 0;
$cycle2p = 0;
$cycle3p = 0;
$cycle1s = 0;
$cycle2s = 0;
$classe = 0;
$parasco = 0;
$conseil = 0;
$autre = 0;
if(isset($HTTP_POST_VARS['niv_international'])){
$international = 1;
}
if(isset($HTTP_POST_VARS['niv_national'])){
$national = 1;
}
if(isset($HTTP_POST_VARS['niv_local'])){
$local = 1;
}
if(isset($HTTP_POST_VARS['nivScol_1'])){
$cycle1p = 1;
}
if(isset($HTTP_POST_VARS['nivScol_2'])){
$cycle2p = 1;
}
if(isset($HTTP_POST_VARS['nivScol_3'])){
$cycle3p = 1;
}
if(isset($HTTP_POST_VARS['nivScol_4'])){
$cycle1s = 1;
}
if(isset($HTTP_POST_VARS['nivScol_5'])){
$cycle2s = 1;
}
if(isset($HTTP_POST_VARS['typeGrp_1'])){
$classe = 1;
}
if(isset($HTTP_POST_VARS['typeGrp_3'])){
$parasco = 1;
}
if(isset($HTTP_POST_VARS['typeGrp_2'])){
$conseil = 1;
}
if(isset($HTTP_POST_VARS['typeGrp_4'])){
$autre = 1;
}
$requete_sql = "UPDATE projet
SET nom = '" . $HTTP_POST_VARS['nom'] . "',
international = '" . $international . "',
national = '" . $national . "',
local = '" . $local . "',
cycle1p = '" . $cycle1p . "',
cycle2p = '" . $cycle2p . "',
cycle3p = '" . $cycle3p . "',
cycle1s = '" . $cycle1s . "',
cycle2s = '" . $cycle2s . "',
classe_reg = '" . $classe . "',
conseil = '" . $conseil . "',
parasco = '" . $parasco . "',
autre = '" . $autre . "'
WHERE projet_id = '" . $HTTP_POST_VARS['id_projet'] . "'
";
$reponse_mod_proj = bd_executer_sql($requete_sql);
$requete_sql = mysql_query("SELECT COUNT(*)
AS nbCat
FROM categorie_prop
");
$nbCat = mysql_fetch_array($requete_sql);
$nbCatF = $nbCat['nbCat'];
for($i=1; $i<=$nbCatF; $i++){
$quelCat = "catProp_" . $i;
if(isset($HTTP_POST_VARS[$quelCat])){
if($HTTP_POST_VARS[$quelCat] == 1){
mysql_query("UPDATE categorie_prop
SET actif = '1'
WHERE cat_id = " . $i . "");
}
}else{
mysql_query("UPDATE categorie_prop
SET actif = '0'
WHERE cat_id = " . $i . "");
}
}
if($_POST['choixCSEco'] == 'autre'){
mysql_query("UPDATE ecole
SET actif = '0'");
mysql_query("UPDATE ecole
SET actif = '1'
WHERE nom = 'autre'");
}
else{
$requete_sql = "SELECT * FROM ecole WHERE actif = '1'";
$reponse_ecole = mysql_query($requete_sql);
$nb_ecole = mysql_num_rows($reponse_ecole);
if($nb_ecole < 1){
mysql_query("UPDATE ecole
SET actif = '1'
WHERE nom = 'autre'");
}
else{
mysql_query("UPDATE ecole
SET actif = '0'
WHERE nom = 'autre'");
}
}
$HTTP_SESSION_VARS['SESSION']['message'] = "Le projet est modifié. N'oubliez pas d'avertir les responsables du changement effectué.";
}
}
$requete_sql = "SELECT *
FROM projet
WHERE statut = \"actif\"
";
$reponse_projet = bd_executer_sql($requete_sql);
$ligne_projet = mysql_fetch_array($reponse_projet);
$requete_sql = "SELECT *
FROM categorie_prop
";
$reponse_catProp = bd_executer_sql($requete_sql);
$requete_sql = "SELECT titre
FROM site_parametres
";
$reponse_titre = bd_executer_sql($requete_sql);
$ligne_titre = mysql_fetch_array($reponse_titre);
$requete_sql = "SELECT *
FROM ecole
WHERE actif = 1
";
$reponse_ecole = bd_executer_sql($requete_sql);
$nb_ecole = mysql_num_rows($reponse_ecole);
$ligne_ecoleS = mysql_fetch_array($reponse_ecole);
$requete_sql = "SELECT *
FROM commission_scolaire
WHERE comscol_id = " . $ligne_ecoleS['comscol_id'] . "
";
$reponse_cs = bd_executer_sql($requete_sql);
$ligne_csS = mysql_fetch_array($reponse_cs);
$requete_sql = "SELECT *
FROM region
WHERE region_id = " . $ligne_csS['region_id'] . "
";
$reponse_region = bd_executer_sql($requete_sql);
$ligne_regionS = mysql_fetch_array($reponse_region);
$requete_sql = "SELECT *
FROM ecole
WHERE comscol_id = " . $ligne_csS['comscol_id'] . "
AND actif = 0
";
$reponse_ecoleCSG = bd_executer_sql($requete_sql);
$requete_sql = "SELECT *
FROM ecole
WHERE actif = 1
";
$reponse_ecoleCSD = bd_executer_sql($requete_sql);
$requete_sql = "SELECT *
FROM ecole
WHERE comscol_id = " . $ligne_csS['comscol_id'] . "
";
$reponse_ecole = bd_executer_sql($requete_sql);
$requete_sql = "SELECT *
FROM commission_scolaire
WHERE region_id = " . $ligne_regionS['region_id'] . "
";
$reponse_cs = bd_executer_sql($requete_sql);
$requete_sql = "SELECT *
FROM region
";
$reponse_region = bd_executer_sql($requete_sql);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?= $ligne_titre['titre'] ?></title>
<script type="text/javascript" src="lib/fonctions.js"></script>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-1684383-1";
urchinTracker();
</script>
<script src="lib/ajax.js" type="text/javascript"></script>
<?
if(isset($HTTP_POST_VARS['type_action'])){
if ($HTTP_POST_VARS['type_action'] == "modifier"){
?>
<script language="JavaScript">
refresh_parent();
</script>
<?
}
}
?>
</head>
<body>
<form action="mod_projet.php?id=<?=$ligne_projet['projet_id']?>" name="form_mod_projet" method="post">
<table width="664" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td colspan="2">
<h2>Modifier un projet</h2>
</td>
</tr>
<tr>
<td colspan="2"><?
if (isset($message)){
echo "<br><h3 align=\"center\"><font color='#FF0000'>$message</font></h3>";
$message="";
}else{
echo " ";
}
?></td>
</tr>
<tr>
<td width="194" valign="top"><strong>Nom du nouveau projet :</strong></td>
<td width="470"><input type="text" name="nom" size="50" maxlength="255" value="<?= $ligne_projet['nom'] ?>"/> </td>
</tr>
<tr>
<td colspan="2"><p> </p></td>
</tr>
<tr>
<td valign="top"><strong>Projet :</strong></td>
<td>
<?
if($nb_ecole > 1){
?>
<input type="radio" name="choixCSEco" value="CS" onclick="afficherChoixRegion('CS')" checked="checked" /> Commission scolaire du Québec
<input type="radio" name="choixCSEco" value="autre" onclick="afficherChoixRegion('autre')" /> Autre
<?
}
else{
if($ligne_ecoleS['nom'] == "autre"){
?>
<input type="radio" name="choixCSEco" value="CS" onclick="afficherChoixRegion('CS')" /> Commission scolaire du Québec
<input type="radio" name="choixCSEco" value="autre" onclick="afficherChoixRegion('autre')" checked="checked" /> Autre
<?
}
else{
?>
<input type="radio" name="choixCSEco" value="CS" onclick="afficherChoixRegion('CS')" checked="checked" /> Commission scolaire du Québec
<input type="radio" name="choixCSEco" value="autre" onclick="afficherChoixRegion('autre')" /> Autre
<?
}
}
?>
</td>
</tr>
<tr>
<td id="CSRegion" colspan="2">
<?
if($nb_ecole > 1){
?>
<form name="frmCSRegion" method="get">
Choix de région administrative :<br />
<select onchange="afficherListeCS('listeRegion', 'CS')" id="listeRegion" name="listeRegion">
<option value="">Région administrative</option>
<?
while($ligne_region = mysql_fetch_array($reponse_region)){
if($ligne_region['region_id'] == $ligne_regionS['region_id']){
$selected = ' selected="selected"';
}
else{
$selected = '';
}
if($ligne_region['nom'] != 'autre'){
echo '<option value="' . $ligne_region['region_id'] . '"' . $selected . '>' . $ligne_region['nom'] . '</option>';
}
}
?>
<option value="toute">Toutes les régions</option>
</select>
<div id="choixCS">
<br />
Choix de commission scolaire :<br />
<select onchange="afficherTableauEcoleCS('listeCS', 'CS')" id="listeCS" name="listeCS">
<option value="">Commission scolaire</option>
<?
while($ligne_cs = mysql_fetch_array($reponse_cs)){
if($ligne_cs['comscol_id'] == $ligne_csS['comscol_id']){
$selected = ' selected="selected"';
}
else{
$selected = '';
}
if($ligne_cs['nom'] != 'autre'){
echo '<option value="' . $ligne_cs['comscol_id'] . '"' . $selected . '>' . $ligne_cs['nom'] . '</option>';
}
}
?>
<option value="toute">Toutes les Commissions scolaire</option>
</select>
</div>
</form>
<div id="ecoleChoix">
<br />
<table id="tabEcole">
<tr>
<td rowspan="3">
<select size="10" name="listeEcoleG" id="listeEcoleG">
<?
while($ligne_ecoleCSG = mysql_fetch_array($reponse_ecoleCSG)){
if($ligne_ecoleCSG['nom'] != 'autre'){
echo "<option value='" . $ligne_ecoleCSG['ecole_id'] . "'>" . $ligne_ecoleCSG['nom'] . "</option>";
}
}
?>
<option value="toute">Toutes ces écoles</option>
</select>
</td>
<td></td>
<td rowspan="3">
<select size="10" name="listeEcoleD" id="listeEcoleD">
<?
while($ligne_ecoleCSD = mysql_fetch_array($reponse_ecoleCSD)){
if($ligne_ecoleCSD['nom'] != 'autre'){
echo "<option value='" . $ligne_ecoleCSD['ecole_id'] . "'>" . $ligne_ecoleCSD['nom'] . "</option>";
}
}
?>
<option value=\"toute\">Toutes ces écoles</option>";
</select>
</td>
</tr>
<tr>
<td>
<input type="button" value="ajouter" id="boutonEcole" onclick="ajouterEcole('listeCS', 'listeEcoleG', 'CS')" /><br />
<input type="button" value="supprimer" id="boutonEcole" onclick="supprimerEcole('listeCS', 'listeEcoleD', 'CS')" />
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
En supprimant une école d'un projet, il ne sera plus possible de la choisir lors de l'inscription. Toutefois, ceux déjà inscrits avec cet école peuvent continuer à participer au projet.
</div>
<?
}
else{
if($ligne_ecoleS['nom'] != "autre"){
?>
<form name="frmCSRegion" method="get">
Choix de région administrative :<br />
<select onchange="afficherListeCS('listeRegion', 'CS')" id="listeRegion" name="listeRegion">
<option value="">Région administrative</option>
<?
while($ligne_region = mysql_fetch_array($reponse_region)){
if($ligne_region['region_id'] == $ligne_regionS['region_id']){
$selected = ' selected="selected"';
}
else{
$selected = '';
}
if($ligne_region['nom'] != 'autre'){
echo '<option value="' . $ligne_region['region_id'] . '"' . $selected . '>' . $ligne_region['nom'] . '</option>';
}
}
?>
<option value="toute">Toutes les régions</option>
</select>
<div id="choixCS">
<br />
Choix de commission scolaire :<br />
<select onchange="afficherTableauEcoleCS('listeCS', 'CS')" id="listeCS" name="listeCS">
<option value="">Commission scolaire</option>
<?
while($ligne_cs = mysql_fetch_array($reponse_cs)){
if($ligne_cs['comscol_id'] == $ligne_csS['comscol_id']){
$selected = ' selected="selected"';
}
else{
$selected = '';
}
if($ligne_cs['nom'] != 'autre'){
echo '<option value="' . $ligne_cs['comscol_id'] . '"' . $selected . '>' . $ligne_cs['nom'] . '</option>';
}
}
?>
<option value="toute">Toutes les Commissions scolaire</option>
</select>
</div>
</form>
<div id="ecoleChoix">
<br />
<table id="tabEcole">
<tr>
<td rowspan="3">
<select size="10" name="listeEcoleG" id="listeEcoleG">
<?
while($ligne_ecoleCSG = mysql_fetch_array($reponse_ecoleCSG)){
if($ligne_ecoleCSG['nom'] != 'autre'){
echo "<option value='" . $ligne_ecoleCSG['ecole_id'] . "'>" . $ligne_ecoleCSG['nom'] . "</option>";
}
}
?>
<option value="toute">Toutes ces écoles</option>
</select>
</td>
<td></td>
<td rowspan="3">
<select size="10" name="listeEcoleD" id="listeEcoleD">
<?
while($ligne_ecoleCSD = mysql_fetch_array($reponse_ecoleCSD)){
if($ligne_ecoleCSD['nom'] != 'autre'){
echo "<option value='" . $ligne_ecoleCSD['ecole_id'] . "'>" . $ligne_ecoleCSD['nom'] . "</option>";
}
}
?>
<option value=\"toute\">Toutes ces écoles</option>";
</select>
</td>
</tr>
<tr>
<td>
<input type="button" value="ajouter" id="boutonEcole" onclick="ajouterEcole('listeCS', 'listeEcoleG', 'CS')" /><br />
<input type="button" value="supprimer" id="boutonEcole" onclick="supprimerEcole('listeCS', 'listeEcoleD', 'CS')" />
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</div>
<?
}
}
?>
</td>
</tr>
<tr>
<td colspan="2"><p> </p></td>
</tr>
<tr>
<td valign="top"><strong>Niveau(x) permis pour les propositions :</strong></td>
<td valign="top">
<?
if ($ligne_projet['international'] == 1){
$check = "checked='checked'";
} else {
$check = "";
}
?>
<input type="checkbox" name="niv_international" value='1' <?= $check ?> /> International
<?
if ($ligne_projet['national'] == 1){
$check = "checked='checked'";
} else {
$check = "";
}
?>
<input type="checkbox" name="niv_national" value='1' <?= $check ?> /> National
<?
if ($ligne_projet['local'] == 1){
$check = "checked='checked'";
} else {
$check = "";
}
?>
<input type="checkbox" name="niv_local" value='1' <?= $check ?> /> Local </td>
</tr>
<tr>
<td colspan="2"><p> </p></td>
</tr>
<tr>
<td valign="top"><strong>Niveau(x) scolaire(s) :</strong></td>
<td>
<?
if ($ligne_projet['cycle1p'] == 1){
$check = "checked='checked'";
} else {
$check = "";
}
?>
<input type="checkbox" name="nivScol_1" value='1' <?= $check ?> /> 1er cycle du primaire (6-7 ans) <br />
<?
if ($ligne_projet['cycle2p'] == 1){
$check = "checked='checked'";
} else {
$check = "";
}
?>
<input type="checkbox" name="nivScol_2" value='1' <?= $check ?> /> 2e cycle du primaire (8-9 ans) <br />
<?
if ($ligne_projet['cycle3p'] == 1){
$check = "checked='checked'";
} else {
$check = "";
}
?>
<input type="checkbox" name="nivScol_3" value='1' <?= $check ?> /> 3e cycle du primaire (10-11 ans) <br />
<?
if ($ligne_projet['cycle1s'] == 1){
$check = "checked='checked'";
} else {
$check = "";
}
?>
<input type="checkbox" name="nivScol_4" value='1' <?= $check ?> /> 1er cycle du secondaire (12-13 ans) <br />
<?
if ($ligne_projet['cycle2s'] == 1){
$check = "checked='checked'";
} else {
$check = "";
}
?>
<input type="checkbox" name="nivScol_5" value='1' <?= $check ?> /> 2e cycle du secondaire (14-16 ans)
</td>
</tr>
<tr>
<td colspan="2"><p> </p></td>
</tr>
<tr>
<td valign="top"><strong>Type(s) de groupe :</strong></td>
<td>
<?
if ($ligne_projet['classe_reg'] == 1){
$check = "checked='checked'";
} else {
$check = "";
}
?>
<input type='checkbox' name='typeGrp_1' value='1' <?= $check ?> /> Classe régulière <br />
<?
if ($ligne_projet['conseil'] == 1){
$check = "checked='checked'";
} else {
$check = "";
}
?>
<input type='checkbox' name='typeGrp_2' value='1' <?= $check ?> /> Conseil étudiants <br />
<?
if ($ligne_projet['parasco'] == 1){
$check = "checked='checked'";
} else {
$check = "";
}
?>
<input type='checkbox' name='typeGrp_3' value='1' <?= $check ?> /> Groupe parascolaire <br />
<?
if ($ligne_projet['autre'] == 1){
$check = "checked='checked'";
} else {
$check = "";
}
?>
<input type='checkbox' name='typeGrp_4' value='1' <?= $check ?> /> Autre
</td>
</tr>
<tr>
<td colspan="2"><p> </p></td>
</tr>
<tr>
<td valign="top"><strong>Catégorie(s) de proposition :</strong></td>
<td id="categorie">
<table>
<?
while($ligne_catProp = mysql_fetch_array($reponse_catProp)){
if ($ligne_catProp['actif'] == 1){
$check = "checked='checked'";
} else {
$check = "";
}
echo "<tr id='ligneCat_" . $ligne_catProp['cat_id'] . "'><td><input type='checkbox' name='catProp_" . $ligne_catProp['cat_id'] . "' value='1' " . $check . " /> " . $ligne_catProp['nom'] . " </td><td><a href='#' onClick='modifCat(".$ligne_catProp['cat_id'].")'>Modifier</a></td></tr>";
}
?>
</table>
</td>
</tr>
<tr>
<td valign="top">Ajouter une catégorie :</td>
<td>
<input type="text" name="catAjout" id="catAjout" />
<input type="button" value="Ajouter" onclick="ajouterCat('catAjout', 'mod')" />
</td>
</tr>
<tr>
<td colspan="2"><p> </p></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="Submit3" value="Modifier" />
<input type="hidden" name="type_action" value="modifier" />
<input type="hidden" name="id_projet" value="<?=$ligne_projet['projet_id']?>" />
<input type="button" value="Annuler" onclick="refresh_parent('adm_projet.php?id_projet=<?=$ligne_projet['projet_id']?>')" />
</td>
</tr>
<tr>
<td colspan="2"><p> </p></td>
</tr>
</table>
</form>
<?
mysql_close();
?>
</body>
</html>