?
| Current Path : /home/webyoo/www/backup/allback/myagenda/admin/ |
| Current File : /home/webyoo/www/backup/allback/myagenda/admin/membres_actions.php |
<?php
if (!defined('IN_WWW') || !defined('IN_ADMIN'))
exit();
$site_Content .= '<h2>Gestion des Utilisateurs</h2>
<p><a href="./?a=membres">La liste des Utilisateurs</a> - <a href="./?a=membres_actions&action=new"">Ajouter un utilisateur</a></p>';
$action = '';
if(!empty($_GET["action"]))
$action = $_GET["action"];
//cas ou on edite un membre
if (!empty($_GET["id"]) && $action == "edit")
{
$id = (int)$_GET['id'];
$select = "SELECT * FROM agenda_membre WHERE id='$id' LIMIT 1";
$result = mysql_query($select);
$row = mysql_fetch_assoc($result);
if($_POST)
{
$site_Content .= '<br /><br/><div class="operation">Mise à jour en cours ...';
$prenom = smartQuote($_POST['prenom']);
$login = smartQuote($_POST['login']);
$nom = smartQuote($_POST['nom']);
$rank = smartQuote($_POST['rank']);
$password = $row['mdp'];
if(!empty($_POST['mdp']))
{
$password = md5($_POST['mdp'] . $CFG['salt']);
}
if (count($dept) > 0) {
for ($i=0;$i<count($dept);$i++) {
mysql_query("UPDATE agenda_dept SET id_membre='{$id}' WHERE num_dept='{$dept[$i]}'");
}
}
$amount_util = count($_POST['util']);
for($i = 0; $i < $amount_util; $i++) {
mysql_query("UPDATE agenda_membre SET managed_by='{$id}' WHERE id='{$_POST['util'][$i]}'");
}
mysql_query("UPDATE agenda_membre SET
login='$login' ,
mdp='$password' ,
nom='$nom' ,
rank='$rank' ,
prenom='$prenom' WHERE id='$_GET[id]'");
$site_Content .= '<br />La fiche de ' . safest($row["nom"]) . ' ' . safest($row["prenom"]) . ' est bien mis à jour !</div>';
}
else
{
$site_Content .= '<br /><br />Fiche de <b>' . safest($row["nom"]) . ' ' . safest($row["prenom"]) . '</b> <br /><br />';
$id = $row["id"];
$login = $row["login"];
$nom = $row["nom"];
$prenom = $row["prenom"];
$rank = $row["rank"];
$managed_by = $row["managed_by"];
include("./form_membres.php");
}
//cas ou on ajoute un membre
}
elseif ($action == "new")
{
$site_Content .= '<br /><br /><b>Ajouter un utilisateur</b> <br /><br />';
if (!$_POST) {
include("form_membres.php");
}
else
{
if (!$_POST['login'] OR !$_POST['mdp'] OR !$_POST['prenom']) {
exit("Les champs Login, mot de passe et prénom sont obligatoire.");
}
//print_r($_POST);exit;
$util = null;
$prenom = smartQuote($_POST['prenom']);
$login = smartQuote($_POST['login']);
$nom = smartQuote($_POST['nom']);
$rank = smartQuote($_POST['rank']);
$password = md5($_POST['mdp'] . $CFG['salt']);
$requete = "INSERT INTO agenda_membre
SET login='$login' ,
mdp='$password' ,
nom='$nom' ,
prenom='$prenom' ,
rank='$rank'";
$resultat = mysql_query($requete);
$id = mysql_insert_id();
if (count($dept) > 0) {
for ($i=0;$i<count($dept);$i++) {
mysql_query("UPDATE agenda_dept SET id_membre='{$id}' WHERE num_dept='{$dept[$i]}'");
}
}
$amount_util = count($_POST['util']);
for($i = 0; $i < $amount_util; $i++) {
mysql_query("UPDATE agenda_membre SET managed_by='{$id}' WHERE id='{$_POST['util'][$i]}'");
}
$site_Content .= '<div class="operation">';
$site_Content .= 'Le commercial ' . safest($_POST['nom']) . ' ' . safest($_POST['prenom']) . ' est bien ajouté à la base </div>';
}
//sinon, on pourrai aussi supprimer non?
}
elseif ($action == "supprimer" && !empty($_GET["id"]))
{
$id = (int)$_GET['id'];
if (!isset($_GET['verif']))
{
$site_Content .= '<p>Confirmer la suppression ? - <a href="./?a=membres_actions&id='.$id.'&action=supprimer&verif=ok">Oui</a> - <a href="./?a=membres">Non</a>';
}
elseif ($_GET['verif'] == 'ok')
{
mysql_query("DELETE FROM agenda_membre WHERE id='$id'");
$site_Content .= '<br /><br />Commercial supprimé.';
}
}