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

This file is part of Gibii.

Gibii 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 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; 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");
include("../incorporation/individus.class.php");
include("../incorporation/importation.php");
include("../incorporation/enluminures.inc.php");
include("../include/utiljs.php");
include("../include/html.class.php");
include("./verifie.inc.php");

opensession('Admin',false);
connecte($host,$user,$mdp,$db);

function traiternocompte($elvprof) {
global $etab_id,$qui;
$table=$elvprof.'s';
if ($elvprof=='eleve') {$indiv='Élèves'; $indivmin='élèves'; }
else {$indiv='Professeurs';$indivmin='professeurs'; }
$indivminsing=substr($indivmin,-1);
$quidam=new $elvprof();
$res=query("SELECT $table.$quidam->champ_id FROM $table LEFT JOIN comptes ON $table.compte_id=comptes.compte_id
	         WHERE comptes.compte_id IS NULL and $table.etab_id=$etab_id");
if (!mysql_num_rows($res)) return false;
entete("$indiv qui n'ont pas de compte dans la table comptes");

print "<br /><font size=\"4\">\n";
print "<form name=\"incorp\" action=\"verifie_compte_2.php?qui=$qui&url=verifie_nocompte.php\" method=\"post\">";

$html=new htmlcreator();
$html->begintable();
while(list($nid)=mysql_fetch_array($res)) {
  $quidam->setbyid($nid);
  $html->beginrow();
  $html->colonnes(
         "<input name=\"box[]\" type=\"checkbox\" value=\"$nid\">",
         $quidam->nom,
         $quidam->prenom,
         $quidam->civil,
         " d. naiss : $quidam->dnaiss",
         " ".$quidam->getgroupname().' : '.$quidam->getgroupvalue(),
         " id_gep : $quidam->ident_nat",
         "<a href=\"verifie_compte_2.php?elvprof=$elvprof&nid=$nid&op=creer&qui=$qui&url=verifie_nocompte.php\" title=\"Créer un nouveau compte\">Créer compte</a>",
         "<a href=\"verifie_compte_2.php?elvprof=$elvprof&nid=$nid&op=supprimer&qui=$qui&url=verifie_nocompte.php\" title=\"Ne pas garder cet individu\">Supprimer élève</a>"
         );
  $html->endrow();
  $existe=$quidam->findnext();
  }
coches_tout_rien($indivmin);
$html->endtable();
print "<input name=\"elvprof\" type=\"hidden\" value=\"$elvprof\">\n";
print "<input name=\"op\" type=\"hidden\" value=\"multiple\">\n";
print "</form></font>";

print "<br /><font size=\"3\">\n";
print "<a href=\"../outils/verifie_base.php\" title=\"Si vous n'avez pas le temps maintenant\nou pas assez d'éléments pour décider,\nvous trouverez un lien dans le menu principal\npour régler ultérieurement le sort des incertains\">";
print "[Remettre à plus tard la gestion des cas ci-dessus]</a>";
print "</font>\n";
return true;
}


//##############################################################################

if ($qui=='e') {
    if (!traiternocompte('eleve')) plusrien("Il ne reste plus d'élève sans enregistrement dans la table comptes");
    }
else {
	if (!traiternocompte('prof')) plusrien("Il ne reste plus de profs sans enregistrement dans la table comptes");
    }
print enqueue();
?>