debut de support des champs optionnels
This commit is contained in:
parent
5db147d829
commit
b800f9ee16
@ -43,6 +43,7 @@ class Adherent
|
||||
var $naiss;
|
||||
var $photo;
|
||||
var $public;
|
||||
var $array_options;
|
||||
|
||||
var $errorstr;
|
||||
/*
|
||||
@ -56,6 +57,8 @@ class Adherent
|
||||
$this->statut = -1;
|
||||
// l'adherent n'est pas public par defaut
|
||||
$this->public = 0;
|
||||
// les champs optionnels sont vides
|
||||
$this->array_options=array();
|
||||
}
|
||||
/*
|
||||
*
|
||||
@ -338,8 +341,64 @@ class Adherent
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* fetch optional attribute
|
||||
*/
|
||||
Function fetch_optionals($rowid)
|
||||
{
|
||||
$tab=array();
|
||||
$sql = "SELECT *";
|
||||
$sql .= " FROM llx_adherent_options";
|
||||
$sql .= " WHERE adhid=$rowid";
|
||||
|
||||
if ( $this->db->query( $sql) ){
|
||||
if ($this->db->num_rows()){
|
||||
|
||||
//$obj = $this->db->fetch_object(0);
|
||||
$tab = $this->db->fetch_array();
|
||||
|
||||
foreach ($tab as $key => $value){
|
||||
if ($key != 'optid' && $key != 'tms' && $key != 'adhid'){
|
||||
// we can add this attribute to adherent object
|
||||
$this->array_options["options_$key"]=$value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
print $this->db->error();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* fetch optional attribute name
|
||||
*/
|
||||
Function fetch_name_optionals()
|
||||
{
|
||||
$array_name_options=array();
|
||||
$sql = "SHOW COLUMNS FROM llx_adherent_options";
|
||||
|
||||
if ( $this->db->query( $sql) ){
|
||||
if ($this->db->num_rows()){
|
||||
//$tab = $this->db->fetch_object();
|
||||
//$array_name_options[]=$tab->Field;
|
||||
while ($tab = $this->db->fetch_object()){
|
||||
if ($tab->Field != 'optid' && $tab->Field != 'tms' && $tab->Field != 'adhid'){
|
||||
// we can add this attribute to adherent object
|
||||
$array_name_options[]=$tab->Field;
|
||||
}
|
||||
}
|
||||
return $array_name_options;
|
||||
}else{
|
||||
return array();
|
||||
}
|
||||
}else{
|
||||
print $this->db->error();
|
||||
return array() ;
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Cotisation
|
||||
*
|
||||
|
||||
@ -123,6 +123,9 @@ if ($action == 'create') {
|
||||
$total = $obj->total;
|
||||
}
|
||||
}
|
||||
$adh = new Adherent($db);
|
||||
$myattr=$adh->fetch_name_optionals();
|
||||
|
||||
print_titre("Nouvel adhérent");
|
||||
print "<form action=\"$PHP_SELF\" method=\"post\">\n";
|
||||
print '<table cellspacing="0" border="1" width="100%" cellpadding="3">';
|
||||
@ -164,6 +167,9 @@ if ($action == 'create') {
|
||||
print '<tr><td>Password</td><td><input type="text" name="pass" size="40"></td></tr>';
|
||||
print '<tr><td>Date de Naissance<BR>Format AAAA-MM-JJ</td><td><input type="text" name="naiss" size="10"></td></tr>';
|
||||
print '<tr><td>Url photo</td><td><input type="text" name="photo" size="40"></td></tr>';
|
||||
foreach($myattr as $key){
|
||||
print "<tr><td>$key</td><td><input type=\"text\" name=\"options_$key\" size=\"40\"></td></tr>\n";
|
||||
}
|
||||
|
||||
print "<tr><td>Date de cotisation</td><td>\n";
|
||||
print_date_select();
|
||||
@ -195,6 +201,8 @@ if ($rowid > 0)
|
||||
$adh = new Adherent($db);
|
||||
$adh->id = $rowid;
|
||||
$adh->fetch($rowid);
|
||||
$adh->fetch_optionals($rowid);
|
||||
$myattr=$adh->fetch_name_optionals();
|
||||
|
||||
print_titre("Edition de la fiche adhérent");
|
||||
|
||||
@ -309,8 +317,14 @@ if ($rowid > 0)
|
||||
}
|
||||
print ' </td></tr>';
|
||||
|
||||
print "</table>\n";
|
||||
// print "</table>\n";
|
||||
|
||||
// print '<table cellspacing="0" border="1" width="100%" cellpadding="3">';
|
||||
// print '<tr><td colspan="2">Champs optionnels</td></tr>';
|
||||
foreach($myattr as $key){
|
||||
print "<tr><td>$key</td><td>".$adh->array_options["options_$key"]." </td></tr>\n";
|
||||
}
|
||||
print "</table>\n";
|
||||
|
||||
if ($user->admin)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user