Commit 6b7a6f10 authored by Feu's avatar Feu
Browse files

lettre cle carte AE

parent 5a1856a8
......@@ -35,6 +35,9 @@ define("CETAT_EXPIRE",10);
define("CETAT_PERDUE",12);
define("CETAT_VOLEE",14);
/*
* UPDATE `ae_carte` SET cle_carteae = CHAR( ASCII( 'A' ) + CEIL( RAND( ) *26 ) -1 ) WHERE cle_carteae IS NULL
*/
$EtatsCarteAE = array (
CETAT_ATTENTE => "Attente de fabrication",
......@@ -53,7 +56,8 @@ class carteae extends stdentity
var $id_cotisation;
var $etat_vie_carte;
var $date_expiration;
var $cle;
/** Charge une carte en fonction de son id
* $this->id est égal à -1 en cas d'erreur
* @param $id id de la fonction
......@@ -76,9 +80,24 @@ class carteae extends stdentity
*/
function load_by_cbarre ( $num )
{
list($id,$extra) = explode(" ",$num);
$this->load_by_id($id);
if ( ereg("^([0-9]+)([a-zA-Z]{1})$", $num, $regs) )
{
$this->load_by_id($regs[1]);
if ( strtoupper($this->cle) != strtoupper($regs[2]) ) // Verifie la cle de contrôle
{
$this->id=null;
$this->id_cotisation=null;
}
}
elseif ( ereg("^([0-9]+) ([a-zA-Z\\-]{1,6})\\.([a-zA-Z\\-]{1,6})$", $num, $regs) )
{
$this->load_by_id($regs[1]);
}
else // voué à disparaitre
{
$this->load_by_id(intval($num));
}
}
/** Charge une carte en fonction de l'id de son propriétaire
......@@ -111,6 +130,8 @@ class carteae extends stdentity
$this->id_cotisation = $row['id_cotisation'];
$this->etat_vie_carte = $row['etat_vie_carte_ae'];
$this->date_expiration = $row['date_expiration'];
$this->cle = $row['cle_carteae'];
}
function add ( $id_cotisation, $expire )
......@@ -118,13 +139,15 @@ class carteae extends stdentity
$this->id_cotisation = $id_cotisation;
$this->etat_vie_carte = CETAT_ATTENTE;
$this->date_expiration = $expire;
$this->cle = chr(ord('A')+rand(0,25));
$sql = new insert ($this->dbrw,
"ae_carte",
array(
"id_cotisation" => $this->id_cotisation,
"etat_vie_carte_ae" => $this->etat_vie_carte,
"date_expiration" => date("Y-m-d",$this->date_expiration)
"date_expiration" => date("Y-m-d",$this->date_expiration),
"cle_carteae" => $this->cle
)
);
......@@ -183,6 +206,4 @@ class carteae extends stdentity
}
?>
?>
\ No newline at end of file
......@@ -180,12 +180,25 @@ class utilisateur extends stdentity
function load_by_carteae ( $num )
{
$this->vol = false;
list($id,$extra) = explode(" ",$num);
if ( ereg("^([0-9]+)([a-zA-Z]{1})$", $num, $regs) )
{
$cond = "`ae_carte`.`id_carte_ae` = '" . mysql_real_escape_string($regs[1]) . "' AND ".
"`ae_carte`.`cle_carteae` = '" . strtoupper(mysql_real_escape_string($regs[2])) . "'";
}
elseif ( ereg("^([0-9]+) ([a-zA-Z\\-]{1,6})\\.([a-zA-Z\\-]{1,6})$", $num, $regs) )
{
$cond = "`ae_carte`.`id_carte_ae` = '" . mysql_real_escape_string($regs[1]) . "'";
}
else // voué à disparaitre
{
$cond = "`ae_carte`.`id_carte_ae` = '" . mysql_real_escape_string(intval($num)) . "'";
}
$req = new requete($this->db, "SELECT * FROM `utilisateurs` " .
"INNER JOIN `ae_cotisations` ON `ae_cotisations`.`id_utilisateur`=`utilisateurs`.`id_utilisateur` " .
"INNER JOIN `ae_carte` ON `ae_cotisations`.`id_cotisation`=`ae_carte`.`id_cotisation` " .
"WHERE `ae_carte`.`id_carte_ae` = '" . mysql_real_escape_string($id) . "' " .
"WHERE $cond " .
"AND `ae_carte`.`etat_vie_carte_ae`<=".CETAT_EXPIRE." " .
"LIMIT 1");
......
......@@ -874,13 +874,13 @@ else
"Cotisant(e) AE jusqu'au " .
HumanReadableDate($res['date_fin_cotis'], null, false) . " $year !");
$req = new requete($site->db,"SELECT `id_carte_ae`, `etat_vie_carte_ae` FROM `ae_carte` INNER JOIN `ae_cotisations` ON `ae_cotisations`.`id_cotisation`=`ae_carte`.`id_cotisation` WHERE `ae_cotisations`.`id_utilisateur`='".$user->id."' AND `ae_carte`.`etat_vie_carte_ae`<".CETAT_EXPIRE."");
$req = new requete($site->db,"SELECT `id_carte_ae`, `etat_vie_carte_ae`, `cle_carteae` FROM `ae_carte` INNER JOIN `ae_cotisations` ON `ae_cotisations`.`id_cotisation`=`ae_carte`.`id_cotisation` WHERE `ae_cotisations`.`id_utilisateur`='".$user->id."' AND `ae_carte`.`etat_vie_carte_ae`<".CETAT_EXPIRE."");
$tbl = new sqltable(
"listasso",
"Ma carte AE", $req, "user.php?id_utilisateur=".$user->id,
"id_carte_ae",
array("id_carte_ae"=>"N°","etat_vie_carte_ae"=>"Etat"),
array("id_carte_ae"=>"N°","cle_carteae"=>"Lettre clé","etat_vie_carte_ae"=>"Etat"),
$site->user->is_in_group("gestion_ae")?array("reprint"=>"Re-imprimer carte"):array(),
array(), array("etat_vie_carte_ae"=>$EtatsCarteAE )
);
......
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