<?php
/*
Copyright (C) 2002 Loc Dayot - Mairie de Pierrefitte (93)
EPNadmin - Version 0.6
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; either version 2 of the License, or
(at your option) any later version.
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; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
http://epnadmin.pierrefitte93.fr/
*/
require_once("header.inc.php");
require_once("constantes.inc.php"); // dfinition des constantes
if (! defined("FCT_LOCALISATIONS"))
{
echo $fctnonactive;
exit;
}
//require_once("fonctions.inc.php"); // concernant des fonctions transversales inclassables
require_once("mysql.inc.php"); // concernant mysql
//require_once("sessions.inc.php"); // concernant les sessions et initiations
//require_once("usagers.inc.php"); // concernant la gestion des usagers
//require_once("reservations.inc.php"); // concernant les rservations des postes en accs individuel par des usagers
//require_once("tableaux.inc.php"); // Concernant l'affichage transpos d'un tableau
//require_once("siteweb.inc.php"); // concernant les pages perso des usagers et les sites web des structures
//require_once("dateheure.inc.php"); // concernant la manipulation des heures et des dates, formulaire, conversion...
require_once("structures.inc.php"); // concernant les structures
//require_once("initiations.inc.php"); // concernant les initiations et les thmes
//require_once("parcours.inc.php"); // concernant les parcours des usagers et leur positionnement
$ptitr=$slocalisations;
$titr = $stitrelocalisations;
$datemaj="3 mai 2003";
define("COULEUR", COULEUR_LOCALISATIONS);
require("entete.inc.php");
function verifiedroits($droit="r", $affichage=true)
{
global $id_localisation, $id_structure,
$pasledroit, $localisationintrouvable, $manqueinforlocalisation;
if (!$id_localisation)
{
if ($affichage)
echo $manqueinfolocalisation;
return FALSE;
}
$req="SELECT id_structure FROM localisations
WHERE id=\"$id_localisation\"";
$res=executeRequete($req);
if (! $localisation=fetch_object($res))
{
if ($affichage)
echo $localisationintrouvable;
return FALSE;
}
if (! (LOCALISATIONS_AUTRES>=$droit || (LOCALISATIONS_MOI>=$droit && $localisation->id_structure==$id_structure)))
{
if ($affichage)
echo $pasledroit;
return FALSE;
}
return TRUE;
}
// Dbut du contenu de la page
if (LOCALISATIONS<="~")
{
echo $pasledroit;
exit;
}
switch($operation)
{
case 3 : // Confirmation d'effacement
echo cadre_debut($slocalsuppr);
if (! verifiedroits("w"))
{
echo cadre_fin();
break;
}
$mes="";
$res = recherche("materiels", "id_localisation", $id_localisation);
if (fetch_object($res))
$mes.=$localsertmateriel;
$res = recherche("sessions", "id_localisation", $id_localisation);
if (fetch_object($res))
$mes.=$localsertsession;
if ($mes!="")
{
echo $mes;
echo cadre_fin();
break;
}
echo "<table align=center>
<form name=\"form\" method=\"post\" action=\"localisations.php\">
<input type=\"hidden\" name=\"id_localisation\" value=\"$id_localisation\">
<input type=\"hidden\" name=\"operation\" value=\"31\">
<tr><td><b>$slocalconfirmesuppr ";
echo localisation($id_localisation, TRUE);
echo " ?</b></td></tr>
<tr><td><input type=\"submit\"
name=\"Annuler\" value=\"$confirmer\"></td></tr>
</form>
</table>\n";
echo cadre_fin();
break;
case 31: // Efface final
echo cadre_debut($slocalsuppr);
if (! verifiedroits("w"))
{
echo cadre_fin();
break;
}
$mes="";
$res = recherche("materiels", "id_localisation", $id_localisation);
if (fetch_object($res))
$mes.=$localsertmateriel;
$res = recherche("sessions", "id_localisation", $id_localisation);
if (fetch_object($res))
$mes.=$localsertsession;
if ($mes!="")
{
echo $mes;
echo cadre_fin();
break;
}
$query = "DELETE FROM localisations WHERE id='$id_localisation'";
$result = executeRequete($query);
echo "<p>$slocalsupprok</p>";
$query = "DELETE FROM calendrier WHERE id_localisation='$id_localisation'";
$result = executeRequete($query);
$query = "DELETE FROM modeles_horaires WHERE id_localisation='$id_localisation'";
$result = executeRequete($query);
echo "<p>$slocalsuppravertissement</p>";
echo cadre_fin();
break;
case 2: // Formulaire modification
echo cadre_debut($slocalmaj);
if (! verifiedroits("r"))
{
echo cadre_fin();
break;
}
$result = recherche("localisations", "id", $id_localisation);
if (! $u=fetch_array($result))
{
echo "<p>$localisationintrouvable</p>\n";
echo cadre_fin();
break;
}
$operation=21;
$id_stru2=$id_structure; // sauvegarde de la structure qui visite
extract($u);
$id_stru=$id_structure;
$id_structure=$id_stru2; // restauration de la structuer qui visite.
case 1: // Ajoute une nouvelle localisation (ou la modifie)
if ($operation==1)
echo cadre_debut($slocalnouveau);
if ($operation!=21)
$operation=11;
if (LOCALISATIONS_MOI<"w" && LOCALISATIONS_AUTRES<"w")
{
echo $pasledroit;
echo cadre_fin();
break;
}
echo "<table align=center border=1>
<form name=\"modilocal\" method=\"post\" action=\"localisations.php\">\n";
if ($operation==21)
echo "<input type=\"hidden\" name=\"id_localisation\" value=\"$id_localisation\">\n";
echo "<input type=\"hidden\" name=\"operation\" value=\"$operation\">
<tr><td>$sStructure* :</td><td>";
// TODO changer les 7 lignes suivantes
//if ($isadmin=="super")
if (!$id_stru)
$id_stru=$id_structure;
choix_structure($id_stru, "id_stru");
/*else
{
echo structure($id_structure);
echo "<input type=\"hidden\" name=\"id_stru\" value=\"$id_structure\">\n";
} */
echo "</td></tr>
<tr><td>$sSalle :</td>
<td><input type=\"text\" name=\"salle\" value=\"$salle\" size=\"50\" maxlength=\"100\"></td></tr>
<tr><td>$sCommentaire :</td>
<td><textarea name=\"description\" cols=\"40\" rows=\"5\">$description</textarea></td></tr>
<tr><td>$slienimage 1 :</td>
<td><input type=\"text\" name=\"image\" value=\"$image\" size=\"50\" maxlength=\"120\"></td></tr>
<tr><td>$slienimage 2 :</td>
<td><input type=\"text\" name=\"image2\" value=\"$image2\" size=\"50\" maxlength=\"120\"></td></tr>\n";
echo "<tr><td align=center colspan=2>
<input type=\"submit\" name=\"Envoyer\" value=\"$envoyer\">
</td></tr></table></form>\n";
echo cadre_fin();
break;
case 11: // Ajout final
echo cadre_debut($slocalnouveau);
if (LOCALISATIONS_MOI<"w" && LOCALISATIONS_AUTRES<"w")
{
echo $pasledroit;
echo cadre_fin();
break;
}
// vrification des paramtres
$mes="";
if ($salle=="") $mes.=$slocalmanquenom;
if ($id_stru=="") $mes.=$smanquestructure;
if ($mes!="")
{
echo "$mes\n";
echo cadre_fin();
break;
}
$query = "INSERT INTO localisations
(id_structure, salle, description, image, image2)
VALUES (\"$id_stru\", \"$salle\", \"$description\", \"$image\", \"$image2\")";
if (executeRequete($query))
echo "<p>$slocalnouveauok</p>";
echo cadre_fin();
break;
case 21: // Modif finale
echo cadre_debut($slocalmaj);
// vrification des paramtres
$mes="";
if ($salle=="") $mes.=$slocalmanquenom;
if ($id_stru=="") $mes.=$smanquestructure;
if ($id_localisation=="") $mes.=$salleintrouvable;
if ($mes!="")
{
echo "$mes\n";
echo cadre_fin();
break;
}
$query = "UPDATE localisations SET
id_structure=\"$id_stru\", salle=\"$salle\", description=\"$description\",
image=\"$image\", image2=\"$image2\"
WHERE id=\"$id_localisation\"";
if ($result = executeRequete($query))
echo "<p>$slocalmajok</p>";
echo cadre_fin();
break;
case 5 : // liste des localisations
default : // liste des localisations
echo cadre_debut($slistelocalisations);
if (LOCALISATIONS<="~")
{
echo $pasledroit;
echo cadre_fin();
break;
}
$req = "SELECT * FROM localisations";
if (LOCALISATIONS_AUTRES<"r")
$req.=" WHERE id_structure=$id_structure";
$req.=" ORDER BY id_structure, salle";
$res = executeRequete($req);
echo "<table align=center border=1>\n";
while ($u=fetch_object($res))
{
$id_localisation=$u->id;
if (verifiedroits("r"))
{
echo "<tr><td>".localisation($u->id, TRUE)."</td>";
if (verifiedroits("w", false))
echo " <td><a href=\"localisations.php?operation=2&id_localisation=$u->id\">$modifier</a></td>
<td><a href=\"localisations.php?operation=3&id_localisation=$u->id\">$supprimer</a></td>";
echo "</tr>\n";
}
}
if (LOCALISATIONS_MOI>="w" || LOCALISATIONS_AUTRES>="w")
echo "<tr><td colspan=5 align=right><a href=\"localisations.php?operation=1\">$ajouter</a></td></tr>\n";
echo "</table>\n";
echo cadre_fin();
break;
} // switch
include("basdepage.inc.php");
echo "</body></html>\n";
require("footer.inc.php");
?>