<?php
/*
Copyright (C) 2003 - Loc Dayot - Ville de Pierrefitte-sur-Seine
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");
if (!defined("FCT_TARIFS"))
{
echo $fctnonactive;
exit;
}
//require_once("constantes.inc.php"); // dfinition des constantes
//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=$starifs;
$titr = $stitretarifs;
define("COULEUR", COULEUR_TARIFS);
$datemaj="4 mai 2003";
require("entete.inc.php");
if (TARIFS<="~")
{
echo $pasledroit;
exit;
}
// Dbut du contenu de la page
switch($operation)
{
case 3 : // Confirmation d'effacement
echo cadre_debut($starifsuppr);
if (TARIFS_AUTRES<"w")
{
echo $pasledroit;
echo cadre_fin();
break;
}
$res = recherche("credits", "id_tarif", $id_tarif);
if (fetch_object($res))
{
echo "<p>$starifutilise</p>\n";
echo cadre_fin();
break;
}
$res=recherche("tarifs", "id", $id_tarif);
if (! $tarif=fetch_object($res))
{
echo "<p>$starifintrouvable</p>\n";
echo cadre_fin();
break;
}
echo "<form name=\"form\" method=\"post\" action=\"\">
<input type=\"hidden\" name=\"id_usage\" value=\"$id_usage\">
<input type=\"hidden\" name=\"id_usager\" value=\"$id_usager\">
<input type=\"hidden\" name=\"operation\" value=\"31\">
<p>$sconfirmersupprtarif <b><font color=\"#FF0000\">$tarif->tarif</font></b> ?</p>
<p><input type=\"submit\" name=\"Supprimer\" value=\"$ssupprtarif\"></p>
</form>"; //'
echo cadre_fin();
break;
case 31: // Efface final
echo cadre_debut($starifsuppr);
if (TARIFS_AUTRES<"w")
{
echo $pasledroit;
echo cadre_fin();
break;
}
$query = "DELETE FROM tarifs WHERE id='$id_tarif'";
if (executeRequete($query))
echo $starifsupprok;
echo cadre_fin();
break;
case 2: // Formulaire modification
echo cadre_debut($starifmaj);
if (TARIFS_AUTRES<"w")
{
echo $pasledroit;
echo cadre_fin();
break;
}
$res=recherche("tarifs", "id", $id_tarif);
if (! $tarif=fetch_object($res))
{
echo "<p>$starifintrouvable</p>\n";
echo cadre_fin();
break;
}
$operations=21;
case 1: // Formulaire d'ajout de tarif
if ($operation==1)
echo cadre_debut($starifmaj);
if (TARIFS_MOI<"w")
{
echo $pasledroit;
echo cadre_fin();
break;
}
if (!$operations) $operations=11;
echo "<table align=center border=1>
<tr><td colspan=2 align=center>$starif :</td></tr>
<form name=\"modi\" method=\"post\" action=\"$PHP_SELF\">\n";
if ($id_tarif)
echo "<input type=\"hidden\" name=\"id_tarif\" value=\"$id_tarif\">\n";
echo "<input type=\"hidden\" name=\"operation\" value=\"$operations\">
<tr><td>
$starif :
</td><td>
<input type=\"text\" name=\"tarif\" value=\"$tarif->tarif\" size=\"40\" maxlength=\"64\">
</td></tr>
<tr><td>
$scouleur :
</td><td>
<input type=\"text\" name=\"couleur\" value=\"$tarif->couleur\" size=\"12\" maxlength=\"6\">
</td></tr>
<tr><td colspan=2 align=center>
<input type=\"submit\" name=\"Envoyer\" value=\"$sconfirmer\">
</td></tr></table></form>\n";
echo cadre_fin();
// Affichage d'une grille de couleurs. C'est vraiment pour s'amuser...
echo "<table align=center cellspacing=0>\n";
function couleur($r, $v, $b)
{
echo "<td bgcolor='#";
echo $c=substr("000000".dechex($r*256*256+$v*256+$b), -6);
echo "'><a href='javascript:coul(\"$c\")'><img src='images/vide.png' width=10 height=10 border=0></a></td>\n";
}
for ($r=0; $r<=255; $r+=50)
{
for ($v=0; $v<=255; $v+=50)
{
echo "<tr>";
for ($b=0; $b<=255; $b+=25)
couleur($r, $v, $b);
$b=255; couleur($r, $v, $b);
echo "</tr>\n";
}
$v=255;
echo "<tr>";
for ($b=0; $b<=255; $b+=25)
couleur($r, $v, $b);
$b=255; couleur($r, $v, $b);
echo "</tr>\n";
} // for $r
$r=255;
for ($v=0; $v<=255; $v+=50)
{
echo "<tr>";
for ($b=0; $b<=255; $b+=25)
couleur($r, $v, $b);
$b=255; couleur($r, $v, $b);
echo "</tr>\n";
}
$v=255;
echo "<tr>";
for ($b=0; $b<=255; $b+=25)
couleur($r, $v, $b);
$b=255; couleur($r, $v, $b);
echo "</tr>\n";
echo "</table>\n";
echo "<script><!--
function coul(couleur)
{
window.document.modi.couleur.value=couleur;
}
//--></script>";
break;
case 11: // Ajout final
echo cadre_debut($starifmaj);
if (TARIFS_MOI<"w")
{
echo $pasledroit;
echo cadre_fin();
break;
}
$query = "INSERT INTO tarifs (tarif, couleur) VALUES (\"$tarif\", \"$couleur\")";
if (executeRequete($query))
echo "<p>$starifajoute</p>";
echo cadre_fin();
break;
case 21: // Modif final
echo cadre_debut($starifmaj);
if (TARIFS_AUTRES<"w")
{
echo $pasledroit;
echo cadre_fin();
break;
}
$query = "UPDATE tarifs SET tarif=\"$tarif\", couleur=\"$couleur\" WHERE id=$id_tarif";
if (executeRequete($query))
echo "<p>$starifmodifie</p>";
echo cadre_fin();
break;
default : // liste des tarifs
echo cadre_debut($slistetarifs);
$req = "SELECT * FROM tarifs ORDER BY tarif";
$res = executeRequete($req);
echo "<table align=center border=1>\n";
while ($tarif= fetch_object($res))
{
echo "<tr><td>$tarif->tarif</td><td bgcolor=\"$tarif->couleur\">$tarif->couleur</td>";
if (TARIFS_MOI>="w")
echo "<td><a href=\"$PHP_SELF?operation=2&id_tarif=$tarif->id\">$modifier</a></td>";
if (TARIFS_AUTRES>="w")
echo "<td><a href=\"$PHP_SELF?operation=3&id_tarif=$tarif->id\">$supprimer</a></td></tr>\n";
}
echo "<tr><td colspan=2 align=right></td><td colspan=2><a href=\"$PHP_SELF?operation=1\">$ajouter</a></td></tr>\n";
echo "</table>\n";
echo cadre_fin();
break;
} // switch
echo "<p><a href=\"$PHP_SELF\">$slistetarifs</a></p>\n";
include("basdepage.inc.php");
echo "</body></html>\n";
require("footer.inc.php");
?>