diff --git a/htdocs/adherent.class.php b/htdocs/adherent.class.php
index 22b81e507da..b961e487f6e 100644
--- a/htdocs/adherent.class.php
+++ b/htdocs/adherent.class.php
@@ -234,7 +234,23 @@ class Adherent
$sql .= " WHERE rowid = $this->id";
$result = $this->db->query($sql);
-
+
+ if (!$result)
+ {
+ print $this->db->error();
+ print "
$sql
";
+ return 0;
+ }
+ if(sizeof($this->array_options) > 0 ){
+ $sql = "REPLACE INTO llx_adherent_options SET adhid = $this->id";
+ foreach($this->array_options as $key => $value){
+ // recupere le nom de l'attribut
+ $attr=substr($key,8);
+ $sql.=",$attr = '".$this->array_options[$key]."'";
+ }
+ $result = $this->db->query($sql);
+ }
+
if ($result)
{
return 1;
@@ -270,6 +286,14 @@ class Adherent
$result = 1;
}
}
+ $sql = "DELETE FROM llx_adherent_options WHERE adhid = $rowid";
+ if ( $this->db->query( $sql) )
+ {
+ if ( $this->db->affected_rows() )
+ {
+ $result = 1;
+ }
+ }
}
}
else
diff --git a/mysql/tables/llx_adherent.sql b/mysql/tables/llx_adherent.sql
index e31189730b4..f662ed7b082 100644
--- a/mysql/tables/llx_adherent.sql
+++ b/mysql/tables/llx_adherent.sql
@@ -51,5 +51,7 @@ create table llx_adherent
fk_user_mod integer NOT NULL,
fk_user_valid integer NOT NULL,
datefin datetime NOT NULL, -- date de fin de validité de la cotisation
- note text
+ note text,
+
+ UNIQUE INDEX(login)
);
diff --git a/mysql/tables/llx_adherent_options.sql b/mysql/tables/llx_adherent_options.sql
index c99b5f9b9cb..eef75a8c99c 100644
--- a/mysql/tables/llx_adherent_options.sql
+++ b/mysql/tables/llx_adherent_options.sql
@@ -29,7 +29,9 @@ create table llx_adherent_options
(
optid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
- adhid integer NOT NULL -- id de l'adherent auquel correspond ces attributs optionnel
+ adhid integer NOT NULL, -- id de l'adherent auquel correspond ces attributs optionnel
-- telfixe varchar(15),
-- teljob varchar(15)
+
+ UNIQUE INDEX(adhid)
);