Location: PHPKode > projects > Pnyx : des lections virtuelles! > pnyx1.0.1/mod_resp.php
<?

	#########################################################################################
	# Modifier un responsable de Pnyx														#
	# Auteur : V. Blais																		#
	# Création : 2006-05-02																	#
	# Modification : 2008-08-21																#
	# 																						#
	# 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_resp.php");

if (isset($HTTP_POST_VARS['type_action'])){
	if ($HTTP_POST_VARS['type_action'] == "modifier"){

	$requete_sql = "SELECT *
					FROM responsable
					WHERE resp_id = \"$HTTP_GET_VARS[id_resp]\"
					";
	$reponse_resp = bd_executer_sql($requete_sql);
	$ligne_resp = mysql_fetch_array($reponse_resp);

	$requete_sql = "UPDATE usager
    				SET login = \"$HTTP_POST_VARS[login]\"
					WHERE usager_id = \"$ligne_resp[usager_id]\"
  						";
	$reponse_mod_log = bd_executer_sql($requete_sql);
	
	if($HTTP_POST_VARS['password'] != ""){
		$requete_sql = "UPDATE usager
    				SET password = '" . sha1($HTTP_POST_VARS['password']) . "'
					WHERE usager_id = \"$ligne_resp[usager_id]\"
  						";
		$reponse_mod_pass = bd_executer_sql($requete_sql);
	}
	
	$requete_sql = "UPDATE responsable
    				SET fonction = \"$HTTP_POST_VARS[fonction]\"
					WHERE resp_id = \"$ligne_resp[resp_id]\"
  						";
	$reponse_mod_resp = bd_executer_sql($requete_sql);
	
	$requete_sql = "UPDATE responsable
    				SET ecole_id = \"$HTTP_POST_VARS[ecole]\"
					WHERE resp_id = \"$ligne_resp[resp_id]\"
  						";
	$reponse_mod_ecole = bd_executer_sql($requete_sql);
	
	$HTTP_SESSION_VARS['SESSION']['message'] = "Le compte du responsable est modifié.";
	
	}
} else {
	
	$requete_sql = "SELECT *
					FROM responsable
					WHERE resp_id = '" . $_GET['id_resp'] . "'
					";
	$reponse_resp = bd_executer_sql($requete_sql);
	$ligne_resp = mysql_fetch_array($reponse_resp);
	
	$requete_sql = "SELECT *
					FROM usager
					WHERE usager_id = \"$ligne_resp[usager_id]\"
					";
	$reponse_log = bd_executer_sql($requete_sql);
	$ligne_log = mysql_fetch_array($reponse_log);
	
	$requete_sql = "SELECT *
					FROM ecole
					WHERE ecole_id = \"$ligne_resp[ecole_id]\"
					";
	$reponse_ecole = bd_executer_sql($requete_sql);
	$ligne_ecole = mysql_fetch_array($reponse_ecole);
	
	$requete_sql = "SELECT *
					FROM commission_scolaire
					WHERE comscol_id = \"$ligne_ecole[comscol_id]\"
					";
	$reponse_cs = bd_executer_sql($requete_sql);
	$ligne_cs = mysql_fetch_array($reponse_cs);
	
	$requete_sql = "SELECT *
					FROM region
					WHERE region_id = \"$ligne_cs[region_id]\"
					";
	$reponse_region = bd_executer_sql($requete_sql);
	$ligne_region = mysql_fetch_array($reponse_region);
	
	$requete_sql = "SELECT titre
					FROM site_parametres
					";
	$reponse_titre = bd_executer_sql($requete_sql);
	$ligne_titre = mysql_fetch_array($reponse_titre);
}
?>
<!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" language="javascript" type="text/javascript"></script>
</head>
<body bgcolor="#FFFFFF">
<?
if (isset($HTTP_POST_VARS['type_action'])){	
	if ($HTTP_POST_VARS['type_action'] == "modifier"){
?>
		<script language="JavaScript">
			refresh_parent();
		</script>
<?
	}
}
	$tabEcole = array();
	$tabCS = array();
	$tabRegion = array();
	
	$requete_sql = "SELECT R.nom, R.region_id
					FROM commission_scolaire AS CS, ecole AS E, region AS R
					WHERE E.actif = 1
					AND E.comscol_id = CS.comscol_id
					AND CS.region_id = R.region_id
					GROUP BY R.nom
					";
	$reponse_regionTab = mysql_query($requete_sql);
	while($ligne_regionTab = mysql_fetch_array($reponse_regionTab)){
		$tabRegion[$ligne_regionTab['region_id']] = $ligne_regionTab['nom'];
	}
	
	foreach($tabRegion as $idRegion => $region){
		if ($idRegion == $ligne_region['region_id']){
			$requete_sql = "SELECT CS.nom, CS.comscol_id
					FROM commission_scolaire AS CS, ecole AS E
					WHERE E.actif = 1
					AND E.comscol_id = CS.comscol_id
					AND CS.region_id = '" . $idRegion . "'
					GROUP BY CS.nom
					";
			$reponse_csTab = mysql_query($requete_sql);
			while($ligne_csTab = mysql_fetch_array($reponse_csTab)){
				$tabCS[$ligne_csTab['comscol_id']] = $ligne_csTab['nom'];
			}
		}
	}
	
	foreach($tabCS as $idCS => $CS){
		if ($idCS == $ligne_cs['comscol_id']){
			$requete_sql = "SELECT nom, ecole_id
							FROM ecole
							WHERE actif = 1
							AND comscol_id = '" . $idCS . "'
							";
			$reponse_ecoleTab = mysql_query($requete_sql);
			while($ligne_ecoleTab = mysql_fetch_array($reponse_ecoleTab)){
				$tabEcole[$ligne_ecoleTab['ecole_id']] = $ligne_ecoleTab['nom'];
			}
		}
	}
?>

<form action="mod_resp.php?id_resp=<?= $ligne_resp['resp_id'] ?>" name="form_mod" method="post">
<table width="664" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2"><?
	if (isset($message)){
		echo "<br><h3 align=\"center\"><font color='#FF0000'>$message</font></h3>";
		$message="";
	}else{ 
		echo "&nbsp;";
	}
?>
</td>
</tr>
<tr>
<td width="256" valign="top"><p><strong>Nom d'utilisateur : </strong></p></td>
<td width="408"><input type="text" name="login" size="50" maxlength="255" value="<?= $ligne_log['login'] ?>"/> </td>
</tr>
<tr>
<td valign="top"><p><strong>Mot de passe <br />
(entre 6 et 15 caractères) : </strong></p></td>
<td><input name="password" type="password" size="30" maxlength="15" value=""/></td>
</tr>
<tr>
<td width="256" valign="top"><p><strong>Fonction : </strong></p></td>
<td width="408"><input type="text" name="fonction" size="50" maxlength="255" value="<?= $ligne_resp['fonction'] ?>"/> </td>
</tr>
<tr>
<td width="256" valign="top"><p><strong>Région : </strong></p></td>
<td width="408"><select name="region" id="lstRegion" size="1" onchange="mod_region()">
			<option value="">Choisissez une région</option>
<?
		foreach($tabRegion as $idRegion => $region){
		
			if ($idRegion == $ligne_region['region_id']){
				echo "<option value=\"".$idRegion."\" selected=\"selected\">".$region."</option>";
			}else{
				echo "<option value=\"".$idRegion."\">".$region."</option>"; 
			}
		}
?>
		</select>
</td>
</tr>
<tr>
<td valign="top"><p><strong>Commission scolaire : </strong></p></td>
<td><select name="com_scol" id="lstCS" size="1" onchange="mod_CS()">
    <option value="">Choisissez une commission scolaire</option>
<?
		foreach($tabCS as $idCS => $CS){
		
			if ($idCS == $ligne_cs['comscol_id']){
				echo "<option value=\"".$idCS."\" selected=\"selected\">".$CS."</option>";
			}else{
				echo "<option value=\"".$idCS."\">".$CS."</option>"; 
			}
		}
?>
	</select>
</td>
</tr>
<tr>
<td valign="top"><p><strong>École : </strong></p></td>
<td><select name="ecole" id="lstEcole" size="1">
                <option value="">Choisissez une école</option>
<?
		foreach($tabEcole as $idEcole => $ecole){
		
			if ($idEcole == $ligne_ecole['ecole_id']){
				echo "<option value=\"".$idEcole."\" selected=\"selected\">".$ecole."</option>";
			}else{
				echo "<option value=\"".$idEcole."\">".$ecole."</option>"; 
			}
		}								
?>
</select>
</td>
</tr>
<tr>
<td colspan="2"><p>&nbsp;</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_resp" value="<?=$ligne_resp['resp_id'] ?>" />
&nbsp;&nbsp;&nbsp;<input type="button" value="Fermer" onclick="refresh_parent('ges_resp.php?id_resp=<?=$ligne_resp['resp_id'] ?>')" />

</td>
</tr>
<tr>
<td colspan="2"><p>&nbsp;</p></td>
</tr>
 </table>
</form>
<?
	mysql_close();
?>
</body>
</html>
Return current item: Pnyx : des lections virtuelles!