<?php
#=
/****************************************************************************
Copyright 2002, Daniel Deycard, Jacques Messines, Alain Pomirol
(CATICE Académie de Bordeaux)

This file is part of GiBii/Melia.

GiBii/Melia 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.

GiBii/Melia 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 GiBii/Melia; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

****************************************************************************/
include("../include/vars_adm.php");
include("../include/util.inc.php");
$PHP_SELF=basename($_SERVER['PHP_SELF']);
opensession("Sadmin",false);
if ($sess_login=='admstats') {
	aneantir_session();
	goto("./index.php");
	}
?>

<?php
    print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
       <title>Prise en main des étabs</title>
<link rel="stylesheet" href="../include/general.css">
</head>
<body class="arial_sadmin" bgcolor="white" text="black" link="white" vlink="white" alink="blue">


<?php


include("../include/utiljs.php");
print "<p class='titre'>Prise en main des Etablissements</p>";

switch(@$tri) {
   case "id":
        $ordre="etab_id";
        break;
   case "rne":
        $ordre="rne";
        break;
   case "codepostal":
        $ordre="codepostal";
        break;
   case "ville":
        $ordre="ville";
        break;
   case "nom":
        $ordre="nom";
        break;
   default :
        $ordre="etab_id";
}
if (@$order=="d") $ordre=$ordre." DESC";

$conn  = connecte($host,$user,$mdp,$db);
$sql="SELECT * ".
             " FROM etablissements ".
             " ORDER BY $ordre" ;
$resetab=query ($sql);
$nbetabs=0;
//alert($sql);
//début du tableau
print "<table border='1' align='center' cellspacing='0' >\n";
print "<tr class='rubrique'>\n";
print "\t<td>Action</td>";
print "<td><a href=\"$PHP_SELF?tri=id\"><img src=\"./images/haut.gif\" border=\"0\" align=\"middle\"></a>&nbsp;Num&nbsp;<a href=\"$PHP_SELF?tri=id&order=d\"><img src=\"./images/bas.gif\" border=\"0\" align=\"middle\"></a></td>";
print "<td><a href=\"$PHP_SELF?tri=rne\"><img src=\"./images/haut.gif\" border=\"0\" align=\"middle\"></a>&nbsp;RNE&nbsp;<a href=\"$PHP_SELF?tri=rne&order=d\"><img src=\"./images/bas.gif\" border=\"0\" align=\"middle\"></a></td>";
print "<td><a href=\"$PHP_SELF?tri=nom\"><img src=\"./images/haut.gif\" border=\"0\" align=\"middle\"></a>&nbsp;Nom&nbsp;<a href=\"$PHP_SELF?tri=nom&order=d\"><img src=\"./images/bas.gif\" border=\"0\" align=\"middle\"></a></td>";
print "<td><a href=\"$PHP_SELF?tri=adresse\"><img src=\"./images/haut.gif\" border=\"0\" align=\"middle\"></a>&nbsp;Adresse&nbsp;<a href=\"$PHP_SELF?tri=adresse&order=d\"><img src=\"./images/bas.gif\" border=\"0\" align=\"middle\"></a></td>";
print "<td><a href=\"$PHP_SELF?tri=codepostal\"><img src=\"./images/haut.gif\" border=\"0\" align=\"middle\"></a>&nbsp;Code postal&nbsp;<a href=\"$PHP_SELF?tri=codepostal&order=d\"><img src=\"./images/bas.gif\" border=\"0\" align=\"middle\"></a></td>";
print "<td><a href=\"$PHP_SELF?tri=ville\"><img src=\"./images/haut.gif\" border=\"0\" align=\"middle\"></a>&nbsp;Ville&nbsp;<a href=\"$PHP_SELF?tri=ville&order=d\"><img src=\"./images/bas.gif\" border=\"0\" align=\"middle\"></a></td></tr>\n";


while ($rowetab=mysql_fetch_array($resetab)) {
      $etab_id=$rowetab["etab_id"];
      $nbetabs++;
      $rne=$rowetab["rne"];
      $nom=$rowetab["nom"];
      $adresse=$rowetab["adresse"];
      $codepost=$rowetab["codepostal"];
      $ville=$rowetab["ville"];
      $nom=stripslashes($nom);
      $adresse=stripslashes($adresse);
      $ville=stripslashes($ville);



     //couleur de la ligne suivant sa parité
     $cl=($nbetabs%2==0) ? "sadmin_paire" : "sadmin_impaire";

     //Affichage d'une ligne
     print "\t<tr class=$cl>\n";
     print "\t<td class=\"rubrique\">
              <a href=\"../admin/admin_ut.php?etab_id=$etab_id&rne=$rne&statut=Sadmin\" target=\"_top\">
              Prendre en main
              </a></td>\n";
     print "\t<td align=\"center\">$etab_id</td>\n";
     print "\t<td >$rne</td>\n";
     print "\t<td >$nom</td>\n";
     print "\t<td >$adresse</td>\n";
     print "\t<td >$codepost</td>\n";
     print "\t<td >$ville</td>\n";

     print "\t</tr>\n";
}

 print "</table><br>\n";
 print $nbetabs." établissement".pluriel($nbetabs);

?>
</body>

</html>