Commit 08fb9c8b authored by slopez's avatar slopez

bleh

parent 084c49fd
<?php
/* Copyright 2009
*
* Ce fichier est adapté du site de l'association des étudiants de
* l'UTBM, http://ae.utbm.fr.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License a
* 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.
*/
$topdir = "../";
/**
*/
require_once($topdir. "include/site.inc.php");
require_once($topdir. "include/cts/sqltable.inc.php");
$site = new site ();
if ( !$site->user->is_in_group("gestion_bds") )
$site->error_forbidden();
$site->start_page ("none", "Gestion des certificats");
function add_search_form()
{
global $topdir, $ch;
$cts = new contents("Gestion des certificats");
$frm = new form("searchstudent","certificats.php",true,"POST","Recherche d'un utilisateur existant");
$frm->add_hidden("action","searchstudent");
$subfrm = new form("quicksearch","certificats.php",false,"POST","Recherche rapide ...");
$subfrm->add_user_fieldv2("id_utilisateur","Prenom Nom/Surnom");
$subfrm->add_submit("valid","Rechercher");
$frm->add($subfrm,false,false,false,false,false,true,true);
$subfrm = new form("searchemail","certificats.php",false,"POST","Recherche par email ...");
$subfrm->add_text_field("email","Adresse e-mail");
$subfrm->add_submit("valid","Rechercher");
$frm->add($subfrm,false,false,false,false,false,true,false);
$cts->add($frm,true);
return $cts;
}
/** Actions */
if ( $_REQUEST["action"] == "validcertif" )
{
$user = new utilisateur($site->db);
$user->load_by_id($_REQUEST['id_utilisateur']);
if ( $user->id < 0 )
{
$site->error_not_found();
exit();
}
if($_REQUEST['date_fin'] > time())
{
$user->set_certificat($_REQUEST['date_fin']);
$info = new contents("Enregistrement certificat","Certificatt enregistré, <a href='".$topdir."user.php?id_utilisateur=".$_REQUEST['id_utilisateur']."'>Voir la fiche</a>.");
}
else
$info = new contents("Date invalide !");
$info->set_toolbox(new toolbox(array($topdir . "admin/certificats.php" => "Retour")));
$site->add_contents($info);
}
elseif ( $_REQUEST["action"] == "searchstudent" )
{
$conds="";
$user = array();
if ( $_REQUEST["nom"] )
{
$by = "nom";
$on = $_REQUEST['nom'];
if ($on)
$conds .= " AND utilisateurs.nom_utl LIKE '".mysql_real_escape_string($on)."%'";
}
if ( $_REQUEST["prenom"] )
{
$by = "prénom";
$on = $_REQUEST['prenom'];
if ($on)
$conds .= " AND utilisateurs.prenom_utl LIKE '".mysql_real_escape_string($on)."%'";
}
if ( $_REQUEST["email"] )
{
$by = "E Mail";
$on = $_REQUEST['email'];
if ($on)
$conds .= " AND (`utilisateurs`.`email_utl` = '" . mysql_real_escape_string($on) . "' OR " .
"`utl_etu_utbm`.`email_utbm` = '" . mysql_real_escape_string($on) . "') ";
}
if ( isset($_REQUEST['id_utilisateur']) && ($_REQUEST['id_utilisateur'] > 0))
{
$by = "Identifiant BDS";
$on = intval($_REQUEST['id_utilisateur']);
$conds .= " AND utilisateurs.id_utilisateur = '" . mysql_real_escape_string($on) . "'";
}
$req = new requete($site->db,"SELECT utilisateurs.nom_utl AS nom_utilisateur, " .
"utilisateurs.prenom_utl AS prenom_utilisateur, ".
"utilisateurs.id_utilisateur AS id_utl, utilisateurs.bds_utl, cotisations.date_fin_cotis, " .
"utl_etu_utbm.departement_utbm, utl_etu_utbm.semestre_utbm" .
"FROM utilisateurs " .
"LEFT JOIN cotisations ON (utilisateurs.id_utilisateur=cotisations.id_utilisateur AND cotisations.date_fin_cotis > NOW()) " .
"LEFT JOIN cartes ON `cotisations`.`id_cotisation`=`cartes`.`id_cotisation` " .
"LEFT JOIN `utl_etu_utbm` ON `utl_etu_utbm`.`id_utilisateur` = `utilisateurs`.`id_utilisateur` " .
"WHERE 1 $conds " .
"ORDER BY utilisateurs.nom_utl, utilisateurs.prenom_utl");
$nb = $req->lines;
if ($nb == 0)
{
$cts_2 = add_new_form($_REQUEST['search_id']);
$cts_2->set_toolbox(new toolbox(array($_SERVER['SCRIPT_NAME']=>"Rechercher un cotisant")));
$site->add_contents($cts_2);
}
else
{
$res = $req->get_row();
$tbl = new sqltable(
"listutl",
$nb." Résultats de la recherche de cotisants par ".$by." sur ".$on, $req, "certificats.php",
"id_utilisateur",
array("nom_utilisateur"=>"Nom",
"prenom_utilisateur"=>"Prénom",
"departement_utbm"=>"Branche",
"semestre_utbm"=>"Semestre",
"bds_utl"=>"Cotisant",
"date_fin_cotis"=>"Jusqu'au"),
array("newcertif"=>"Nouveau certificat"), array(), array("bds_utl"=>array(0=>"Non",1=>"Oui"))
);
$site->add_contents($tbl);
}
}
elseif ( $_REQUEST["action"] == "newcertif" )
{
$user = new utilisateur($site->db);
$user->load_by_id($_REQUEST['id_utilisateur']);
if ( $user->id < 0 )
{
$site->error_not_found();
exit();
}
$cts = new contents("Mise à jour du certificat");
$frm = new form("infos","certificats.php?id_utilisateur=".$user->id,true,"POST",null);
$frm->add_hidden("action","validcertif");
$frm->add_date_field("date_fin","Date de validité");
$frm->add_submit("submit","Enregistrer");
$cts->add($frm);
$site->add_contents($cts);
}
else
{
$cts = add_search_form();
$cts->add(add_new_form());
$site->add_contents($cts);
}
$site->end_page ();
?>
......@@ -709,9 +709,13 @@ else
"<a href=\"user.php?page=edit&amp;id_utilisateur=".$user->id.
"&amp;see=photo\">Photo d'identit&eacute; non pr&eacute;sente !</a>");
if(!$limit)
{
$cts2->add_paragraph("<img src=\"".$topdir."images/actions/delete.png\"><b>ATTENTION</b>: " .
"Vous n'avez pas de certificat médical à jour, vous n'avez donc pas le droit de ".
"pratiquer de sport. Merci de ramener un certificat au bureau du BDS !");
if($site->user->is_in_group("gestion_bds"))
$cts2->add_paragraph("<a href='".$topdir."admin/certificats.php?action=validcertif&id_utilisateur=".$user->id."'>Enregistrer un certficat</a>");
}
else
$cts2->add_paragraph("Certificat médical valide jusqu'au ".date(strtotime($limit)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment