diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php index 360bb5760ff..e9b84cbe79c 100644 --- a/htdocs/adherents/adherent.class.php +++ b/htdocs/adherents/adherent.class.php @@ -24,7 +24,7 @@ * */ -/*! \file htdocs/adherents/adherent.class.php +/*! \file htdocs/adherents/adherent.class.php \ingroup adherent \brief Fichier de la classe permettant la gestion d'un adhérent \author Rodolphe Qiedeville @@ -85,10 +85,10 @@ class Adherent /*! - \brief function envoyant un email au destinataire (recipient) avec le text fourni en parametre. - \param recipients destinataires - \param text contenu du message - \param subject sujet du message + \brief function envoyant un email au destinataire (recipient) avec le text fourni en parametre. + \param recipients destinataires + \param text contenu du message + \param subject sujet du message \remarks La particularite de cette fonction est de remplacer certains champs \remarks par leur valeur pour l'adherent en l'occurrence : \remarks %PRENOM% : est remplace par le prenom @@ -316,67 +316,72 @@ class Adherent function update() { - $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET "; - $sql .= "prenom = '".$this->prenom ."'"; - $sql .= ",nom='" .$this->nom."'"; - $sql .= ",societe='".$this->societe."'"; - $sql .= ",adresse='".$this->adresse."'"; - $sql .= ",cp='" .$this->cp."'"; - $sql .= ",ville='" .$this->ville."'"; - $sql .= ",pays='" .$this->pays."'"; - $sql .= ",note='" .$this->commentaire."'"; - $sql .= ",email='" .$this->email."'"; - $sql .= ",login='" .$this->login."'"; - $sql .= ",pass='" .$this->pass."'"; - $sql .= ",naiss='" .$this->naiss."'"; - $sql .= ",photo='" .$this->photo."'"; - $sql .= ",public='" .$this->public."'"; - $sql .= ",statut=" .$this->statut; - $sql .= ",fk_adherent_type=".$this->typeid; - $sql .= ",morphy='".$this->morphy."'"; - - $sql .= " WHERE rowid = $this->id"; - - $result = $this->db->query($sql); + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET "; + $sql .= "prenom = '".$this->prenom ."'"; + $sql .= ",nom='" .$this->nom."'"; + $sql .= ",societe='".$this->societe."'"; + $sql .= ",adresse='".$this->adresse."'"; + $sql .= ",cp='" .$this->cp."'"; + $sql .= ",ville='" .$this->ville."'"; + $sql .= ",pays='" .$this->pays."'"; + $sql .= ",note='" .$this->commentaire."'"; + $sql .= ",email='" .$this->email."'"; + $sql .= ",login='" .$this->login."'"; + $sql .= ",pass='" .$this->pass."'"; + $sql .= ",naiss='" .$this->naiss."'"; + $sql .= ",photo='" .$this->photo."'"; + $sql .= ",public='" .$this->public."'"; + $sql .= ",statut=" .$this->statut; + $sql .= ",fk_adherent_type=".$this->typeid; + $sql .= ",morphy='".$this->morphy."'"; - if (!$result) - { - dolibarr_print_error($this->db); - return 0; - } - - if (sizeof($this->array_options) > 0 ) - { - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."adherent_options WHERE adhid = $this->id;"; - $this->db->query($sql_del); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_options (adhid"; - foreach($this->array_options as $key => $value) - { - // recupere le nom de l'attribut - $attr=substr($key,8); - $sql.=",$attr"; - } - $sql .= ") VALUES ($this->id"; - foreach($this->array_options as $key => $value) - { - - $sql.=",'".$this->array_options[$key]."'"; - } - $sql.=");"; - - $result = $this->db->query($sql); - } - - if ($result) - { - return 1; - } - else - { - dolibarr_print_error($this->db); - return 0; - } + $sql .= " WHERE rowid = $this->id"; + + $result = $this->db->query($sql); + + if (!$result) + { + dolibarr_print_error($this->db); + return 0; } + + if (sizeof($this->array_options) > 0 ) + { + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."adherent_options WHERE adhid = $this->id;"; + $this->db->query($sql_del); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_options (adhid"; + foreach($this->array_options as $key => $value) + { + // recupere le nom de l'attribut + $attr=substr($key,8); + $sql.=",$attr"; + } + $sql .= ") VALUES ($this->id"; + foreach($this->array_options as $key => $value) + { + + $sql.=",'".$this->array_options[$key]."'"; + } + $sql.=");"; + + $result = $this->db->query($sql); + + if ($result) + { + return 1; + } + else + { + dolibarr_print_error($this->db); + return 0; + } + + } + + return 1; + } + /*! \brief fonction qui supprime l'adhérent et les données associées @@ -422,25 +427,28 @@ class Adherent } /*! - \brief fonction qui récupére l'adhérent en donnant son login - \param login login de l'adhérent + \brief Fonction qui récupére l'adhérent en donnant son login + \param login login de l'adhérent */ function fetch_login($login) { $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent WHERE login='$login' LIMIT 1"; - if ( $this->db->query( $sql) ) - { - if ($this->db->num_rows()) - { - $obj = $this->db->fetch_object(); - $this->fetch($obj->rowid); - } - } + + $result=$this->db->query( $sql); + + if ($result) + { + if ($this->db->num_rows()) + { + $obj = $this->db->fetch_object($result); + $this->fetch($obj->rowid); + } + } else - { - dolibarr_print_error($this->db); - } + { + dolibarr_print_error($this->db); + } } /*! @@ -456,12 +464,14 @@ class Adherent $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " WHERE d.rowid = $rowid AND d.fk_adherent_type = t.rowid"; - if ( $this->db->query( $sql) ) + $result=$this->db->query( $sql); + + if ($result) { if ($this->db->num_rows()) { - $obj = $this->db->fetch_object(); + $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; $this->typeid = $obj->fk_adherent_type; @@ -494,8 +504,8 @@ class Adherent } /*! - \brief fonction qui récupére les données optionelles de l'adhérent - \param rowid + \brief Fonction qui récupére les données optionelles de l'adhérent + \param rowid */ function fetch_optionals($rowid) @@ -505,19 +515,26 @@ class Adherent $sql .= " FROM ".MAIN_DB_PREFIX."adherent_options"; $sql .= " WHERE adhid=$rowid"; - if ( $this->db->query( $sql) ){ - if ($this->db->num_rows()){ - - $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{ + $result=$this->db->query( $sql); + + if ($result) + { + if ($this->db->num_rows()) + { + $tab = $this->db->fetch_array($result); + + 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 + { dolibarr_print_error($this->db); } @@ -530,28 +547,38 @@ class Adherent { $array_name_options=array(); $sql = "SHOW COLUMNS FROM ".MAIN_DB_PREFIX."adherent_options"; + + $result=$this->db->query( $sql); - if ( $this->db->query( $sql) ){ - if ($this->db->num_rows()){ - //$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{ - dolibarr_print_error($this->db); - return array() ; + if ($result) + { + if ($this->db->num_rows()) + { + //$array_name_options[]=$tab->Field; + while ($tab = $this->db->fetch_object($result)) + { + 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 + { + dolibarr_print_error($this->db); + return array() ; } } /*! - \brief fonction qui insèe la cotisation dans la base de données + \brief fonction qui insère la cotisation dans la base de données \param date \param montant */ @@ -563,33 +590,35 @@ class Adherent $sql = "INSERT INTO ".MAIN_DB_PREFIX."cotisation (fk_adherent, dateadh, cotisation)"; $sql .= " VALUES ($this->id, ".$this->db->idate($date).", $montant)"; - if ( $this->db->query( $sql) ) - { - if ( $this->db->affected_rows() ) - { - $rowid=$this->db->last_insert_id(); - $datefin = mktime(12, 0 , 0, - strftime("%m",$date), - strftime("%d",$date), - strftime("%Y",$date)+1) - (24 * 3600); - - $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET datefin = ".$this->db->idate($datefin)." WHERE rowid =". $this->id; - - if ( $this->db->query( $sql) ) - { - return $rowid; - } - } - else - { - return 0; - } - } + $result=$this->db->query( $sql); + + if ($result) + { + if ( $this->db->affected_rows() ) + { + $rowid=$this->db->last_insert_id(MAIN_DB_PREFIX."cotisation"); + $datefin = mktime(12, 0 , 0, + strftime("%m",$date), + strftime("%d",$date), + strftime("%Y",$date)+1) - (24 * 3600); + + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET datefin = ".$this->db->idate($datefin)." WHERE rowid =". $this->id; + + if ( $this->db->query( $sql) ) + { + return $rowid; + } + } + else + { + return 0; + } + } else - { - dolibarr_print_error($this->db); - return 0; - } + { + dolibarr_print_error($this->db); + return 0; + } } /*! @@ -691,6 +720,7 @@ class Adherent } } + /*! \brief fonction qui supprime l'adhérent des abonnements automatiques \param adht @@ -795,44 +825,57 @@ class Adherent } /*! - \brief fonction qui dit si cet utilisateur est rédacteur dans spip + \brief Fonction qui dit si cet utilisateur est un rédacteur existant dans spip + \return int 1=existe, 0=n'existe pas, -1=erreur */ function is_in_spip() { - if (defined("ADHERENT_USE_SPIP") && ADHERENT_USE_SPIP ==1 && - defined('ADHERENT_SPIP_SERVEUR') && ADHERENT_SPIP_SERVEUR != '' && - defined('ADHERENT_SPIP_USER') && ADHERENT_SPIP_USER != '' && - defined('ADHERENT_SPIP_PASS') && ADHERENT_SPIP_PASS != '' && - defined('ADHERENT_SPIP_DB') && ADHERENT_SPIP_DB != '' - ){ - $query = "SELECT login FROM spip_auteurs WHERE login='".$this->login."'"; - $mydb=new DoliDb('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB); - $result = $mydb->query($query); - - if ($result) - { - if ($mydb->num_rows()){ - # nous avons au moins une reponse - $mydb->close(); - return 1; - }else{ - # nous n'avons pas de reponse => n'existe pas - $mydb->close(); - return 0; - } - } - else - { - # error - $this->errorstr=$mydb->error(); - return -1; - } - } + if (defined("ADHERENT_USE_SPIP") && ADHERENT_USE_SPIP ==1 && + defined('ADHERENT_SPIP_SERVEUR') && ADHERENT_SPIP_SERVEUR != '' && + defined('ADHERENT_SPIP_USER') && ADHERENT_SPIP_USER != '' && + defined('ADHERENT_SPIP_PASS') && ADHERENT_SPIP_PASS != '' && + defined('ADHERENT_SPIP_DB') && ADHERENT_SPIP_DB != '') + { + + $query = "SELECT login FROM spip_auteurs WHERE login='".$this->login."'"; + $mydb=new DoliDb('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB); + + if ($mydb->ok) { + + $result = $mydb->query($query); + + if ($result) + { + if ($mydb->num_rows()) + { + # nous avons au moins une reponse + $mydb->close(); + return 1; + } + else + { + # nous n'avons pas de reponse => n'existe pas + $mydb->close(); + return 0; + } + } + else + { + # error + $this->errorstr=$mydb->error(); + return -1; + } + } else { + $this->errorstr="Echec de connexion avec les identifiants ".ADHERENT_SPIP_SERVEUR." ".ADHERENT_SPIP_USER." ".ADHERENT_SPIP_PASS." ".ADHERENT_SPIP_DB; + return -1; + } + } } + /*! - \brief fonction qui ajoute l'utilisateur dans glasnost + \brief Fonction qui ajoute l'utilisateur dans glasnost */ function add_to_glasnost() diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 131073f6a64..df1e5887143 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -81,7 +81,7 @@ if ($_POST["action"] == 'cotisation') $insertid=$acct->addline($dateop, $_POST["operation"], $_POST["label"], $amount, $_POST["num_chq"],ADHERENT_BANK_CATEGORIE); if ($insertid == '') { - print "

Probleme d'insertion : ".$db->error(); + dolibarr_print_error($db); } else { @@ -94,7 +94,7 @@ if ($_POST["action"] == 'cotisation') } else { - print "

Probleme d'insertion $sql : ".$db->error(); + dolibarr_print_error($db); } } } @@ -159,37 +159,37 @@ if ($_POST["action"] == 'add') if ($result) { $num = $db->num_rows(); } - if (!isset($nom) || !isset($prenom) || $prenom=='' || $nom==''){ + if (!isset($nom) || !isset($prenom) || $prenom=='' || $nom=='') { $error+=1; - $errmsg .="Nom et Prenom obligatoires
\n"; + $errmsg .="Nom et Prénom obligatoires
\n"; } - if (!isset($email) || $email == '' || !ereg('@',$email)){ + if (ADHERENT_MAIL_REQUIRED && ADHERENT_MAIL_REQUIRED == 1 && ! ValidEMail($email)) { $error+=1; $errmsg .="Adresse Email invalide
\n"; } - if ($num !=0){ + if ($num !=0) { $error+=1; - $errmsg .="Login deja utilise. Veuillez en changer
\n"; + $errmsg .="Login deja utilise. Veuillez en changer
\n"; } - if (!isset($pass) || $pass == '' ){ + if (!isset($pass) || $pass == '' ) { $error+=1; $errmsg .="Password invalide
\n"; } if (isset($naiss) && $naiss !=''){ - if (!preg_match("/^\d\d\d\d-\d\d-\d\d$/",$naiss)){ + if (!preg_match("/^\d\d\d\d-\d\d-\d\d$/",$naiss)) { $error+=1; $errmsg .="Date de naissance invalide (Format AAAA-MM-JJ)
\n"; } } - if (isset($public)){ + if (isset($public)) { $public=1; - }else{ + } else { $public=0; } - if (!$error){ + if (!$error) { // Email a peu pres correct et le login n'existe pas - if ($adh->create($user->id) ) + if ($adh->create($user->id)) { if ($cotisation > 0) { @@ -345,7 +345,7 @@ if ($_POST["action"] == 'confirm_add_spip' && $_POST["confirm"] == yes) /* ************************************************************************** */ if ($errmsg != '') { - print ''; + print '
'; print ''; print "\n"; print '
Erreur dans l\'execution du formulaire
$errmsg
'; @@ -355,9 +355,9 @@ if ($errmsg != '') $adho->fetch_optionals(); if ($action == 'create') { - print_titre("Nouvel adhérent"); + print_titre($langs->trans("NewMember")); print "

\n"; - print ''; + print '
'; print ''; @@ -379,17 +379,17 @@ if ($action == 'create') { print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; foreach($adho->attribute_label as $key=>$value){ print "\n"; @@ -452,7 +452,7 @@ if ($rowid > 0) $h = 0; $head[$h][0] = DOL_URL_ROOT.'/adherents/fiche.php?rowid='.$rowid; - $head[$h][1] = "Fiche adhérent"; + $head[$h][1] = $langs->trans("Member"); $hselected=$h; $h++; @@ -519,28 +519,28 @@ if ($rowid > 0) print "\n"; print '
'.$langs->trans("Firstname").'
'.$langs->trans("LastName").'
'.$langs->trans("Firstname").'*
'.$langs->trans("LastName").'*
'.$langs->trans("Company").'
'.$langs->trans("Address").''; print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").'
'.$langs->trans("Country").'
'.$langs->trans("EMail").'
'.$langs->trans("Login").'
'.$langs->trans("Password").'
Date de Naissance
Format AAAA-MM-JJ
'.$langs->trans("EMail").(ADHERENT_MAIL_REQUIRED&&ADHERENT_MAIL_REQUIRED==1?'*':'').'
'.$langs->trans("Login").'*
'.$langs->trans("Password").'*
'.$langs->trans("Birthday").'
(AAAA-MM-JJ)
Url photo
$value
'; - print ''; + print ''; print ''; - print '\n"; + print '\n"; print ''; print ''; - print ''; + print ''; - print ''; + print ''; print ''; print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; // print ''; - print ''; + print ''; print ''; print '
Numero'.$adh->id.' 
'.$langs->trans("Ref").''.$adh->id.' '.$langs->trans("Comments").'
'.$langs->trans("Type").''.$adh->type."
'.$langs->trans("Type").'*'.$adh->type."'; print nl2br($adh->commentaire).' 
Personne'.$adh->getmorphylib().' 
'.$langs->trans("Firstname").''.$adh->prenom.' 
'.$langs->trans("Firstname").'*'.$adh->prenom.' 
'.$langs->trans("LastName").''.$adh->nom.' 
'.$langs->trans("LastName").'*'.$adh->nom.' 
'.$langs->trans("Company").''.$adh->societe.' 
'.$langs->trans("Address").''.nl2br($adh->adresse).' 
'.$langs->trans("Zip").' / '.$langs->trans("Town").''.$adh->cp.' '.$adh->ville.' 
'.$langs->trans("Country").''.$adh->pays.' 
'.$langs->trans("EMail").''.$adh->email.' 
'.$langs->trans("Login").''.$adh->login.' 
'.$langs->trans("EMail").(ADHERENT_MAIL_REQUIRED&&ADHERENT_MAIL_REQUIRED==1?'*':'').''.$adh->email.' 
'.$langs->trans("Login").'*'.$adh->login.' 
Pass'.$adh->pass.' 
Date de Naissance'.$adh->naiss.' 
'.$langs->trans("Birthday").''.$adh->naiss.' 
URL Photo'.$adh->photo.' 
Public ?'; if ($adh->public==1){ @@ -555,54 +555,67 @@ foreach($adho->attribute_label as $key=>$value){ } print "
\n"; +print "
"; print "\n"; + /* * Barre d'actions * */ print '
'; -if ($user->admin) + +print "".$langs->trans("Edit").""; + +if ($adh->statut < 1) { - print "".$langs->trans("Edit").""; + print "Valider l'adhésion\n"; +} - if ($adh->statut < 1) +if ($adh->statut == 1) +{ + print "Résilier l'adhésion\n"; +} + +print "id&action=delete\">".$langs->trans("Delete")."\n"; + +// Envoi fiche par mail +print "id&action=sendinfo\">Envoyer sa fiche a l'adhérent\n"; + +// Action Glasnost +if ($adht->vote == 'yes' && defined("ADHERENT_USE_GLASNOST") && ADHERENT_USE_GLASNOST ==1) +{ + define("XMLRPC_DEBUG", 1); + $isinglasnost=$adh->is_in_glasnost(); + if ($isinglasnost == 1) { - print "Valider l'adhésion\n"; - } - - if ($adh->statut == 1) - { - print "Résilier l'adhésion\n"; - } - - print "id&action=delete\">".$langs->trans("Delete")."\n"; - - /* - * bouton : "Envoie des informations" - */ - print "id&action=sendinfo\">Envoyer sa fiche a l'adhérent\n"; - - if ($adht->vote == 'yes' && defined("ADHERENT_USE_GLASNOST") && ADHERENT_USE_GLASNOST ==1){ - define("XMLRPC_DEBUG", 1); - - if ($adh->is_in_glasnost() == 1){ - print "id&action=del_glasnost\">Suppression dans Glasnost\n"; - } - print "id&action=add_glasnost\">Ajout dans Glasnost\n"; print "id&action=del_glasnost\">Suppression dans Glasnost\n"; } + if ($isinglasnost == 0) { + print "id&action=add_glasnost\">Ajout dans Glasnost\n"; + } + if ($isinglasnost == -1) { + print '
Failed to connect to SPIP: '.$adh->errorstr.''; + } +} - if (defined("ADHERENT_USE_SPIP") && ADHERENT_USE_SPIP ==1){ - if ($adh->is_in_spip() == 1){ - print "id&action=del_spip\">Suppression dans Spip\n"; - }else{ +// Action SPIP +if (defined("ADHERENT_USE_SPIP") && ADHERENT_USE_SPIP ==1) +{ + $isinspip=$adh->is_in_spip(); + if ($isinspip == 1) + { + print "id&action=del_spip\">Suppression dans Spip\n"; + } + if ($isinspip == 0) + { print "id&action=add_spip\">Ajout dans Spip\n"; } - -} + if ($isinspip == -1) { + print '
Failed to connect to SPIP: '.$adh->errorstr.''; + } } print '
'; @@ -615,7 +628,7 @@ print "
\n"; * */ -print ''; +print '
'; print ''; if (defined("ADHERENT_BANK_USE") && ADHERENT_BANK_USE !=0 && @@ -640,7 +653,7 @@ if ($result) $num = $db->num_rows(); $i = 0; - print "
\n"; + print "
\n"; print ''; print "\n"; diff --git a/htdocs/adherents/pre.inc.php b/htdocs/adherents/pre.inc.php index fc1a27a9321..8458489a672 100644 --- a/htdocs/adherents/pre.inc.php +++ b/htdocs/adherents/pre.inc.php @@ -30,27 +30,20 @@ require("../main.inc.php"); function llxHeader($head = "") { - global $user, $conf; + global $user, $conf, $langs; - /* - * - * - */ top_menu($head); $menu = new Menu(); - $menu->add("index.php","Adherents"); + + $menu->add("index.php",$langs->trans("Members")); + $menu->add_submenu("fiche.php?action=create",$langs->trans("NewMember")); $menu->add_submenu("liste.php?statut=-1","Adhésions à valider"); $menu->add_submenu("liste.php?statut=1","Adhérents à ce jour"); $menu->add_submenu("liste.php?statut=0","Adhésions résiliées"); - if ($user->admin) - { - $menu->add("fiche.php?action=create","Nouvel adhérent"); - } - $menu->add(DOL_URL_ROOT."/public/adherents/","Espace adherents public"); $menu->add("index.php","Export"); @@ -58,18 +51,19 @@ function llxHeader($head = "") { $menu->add_submenu("cartes/carte.php","Cartes d'adhérents"); $menu->add_submenu("cartes/etiquette.php","Etiquettes d'adhérents"); - $menu->add("index.php","Comptabilite"); + $langs->load("compta"); + $menu->add("index.php",$langs->trans("Accountancy")); $menu->add_submenu("cotisations.php","Cotisations"); - $menu->add_submenu(DOL_URL_ROOT."/compta/bank/","Bank"); + $menu->add_submenu(DOL_URL_ROOT."/compta/bank/",$langs->trans("Bank")); - if ($user->admin) - { - $menu->add("index.php","Configuration"); - $menu->add_submenu("type.php","Type d'adhérent"); - $menu->add_submenu("options.php","Champs optionnels"); - $menu->add_submenu(DOL_URL_ROOT."/admin/adherent.php","Constantes"); - } + $menu->add("index.php",$langs->trans("Setup")); + $menu->add_submenu("type.php","Type d'adhérent"); + $menu->add_submenu("options.php","Champs optionnels"); + if ($user->admin) { + $menu->add_submenu(DOL_URL_ROOT."/admin/adherent.php",$langs->trans("Module")); + } + left_menu($menu->liste); } diff --git a/htdocs/admin/adherent.php b/htdocs/admin/adherent.php index 391af735737..5540754452b 100644 --- a/htdocs/admin/adherent.php +++ b/htdocs/admin/adherent.php @@ -49,6 +49,8 @@ $main_use_spip_auto = ADHERENT_USE_SPIP_AUTO; $typeconst=array('yesno','texte','chaine'); $var=True; + +// Action mise a jour ou ajout d'une constante if ($_POST["action"] == 'update' || $_POST["action"] == 'add') { if (isset($_POST["consttype"]) && $_POST["consttype"] != '') @@ -74,20 +76,31 @@ if ($_POST["action"] == 'update' || $_POST["action"] == 'add') } +// Action activation d'un sous module du module adhérent if ($_GET["action"] == 'set') { - $sql = "DELETE FROM ".MAIN_DB_PREFIX." WHERE name = '".$_GET["name"]."' ;"; - $db->query($sql); - - $sql =''; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."const(name,value,visible) values ('".$_GET["name"]."','".$_GET["value"]."', 0);"; - - if ($db->query($sql)) + $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = '".$_GET["name"]."' ;"; + $result=$db->query($sql); + if (! $result) { + dolibarr_print_error($db); + exit; + } + + $sql =''; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."const(name,value,visible) values ('".$_GET["name"]."','".$_GET["value"]."', 0);"; + + $result=$db->query($sql); + if ($result) { - Header("Location: adherent.php"); + Header("Location: adherent.php"); + } + else { + dolibarr_print_error($db); + exit; } } +// Action désactivation d'un sous module du module adhérent if ($_GET["action"] == 'unset') { $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = '".$_GET["name"]."'"; @@ -210,7 +223,9 @@ $var=!$var; /* * Edition des varibales globales non rattache a un theme specifique */ -$constantes=array('ADHERENT_TEXT_NEW_ADH', +$constantes=array( + 'ADHERENT_MAIL_REQUIRED', + 'ADHERENT_TEXT_NEW_ADH', 'ADHERENT_MAIL_COTIS_SUBJECT', 'ADHERENT_MAIL_COTIS', 'ADHERENT_MAIL_EDIT_SUBJECT', @@ -233,6 +248,9 @@ form_constantes($constantes); $db->close(); +print '
'; + + llxFooter(); @@ -286,10 +304,8 @@ function form_constantes($tableau){ } print '\n"; print ''; @@ -298,4 +314,5 @@ function form_constantes($tableau){ } print '
Date cotisations'; - // print ''; - // print ''; print '  '; - print ''.img_delete().''; +// print ''.img_delete().''; print "
'; } + ?> diff --git a/mysql/data/data.sql b/mysql/data/data.sql index fc673f12712..6172edf1afb 100644 --- a/mysql/data/data.sql +++ b/mysql/data/data.sql @@ -80,6 +80,7 @@ insert into llx_const (name, value, type) values ('DONS_FORM','fsfe.fr.php','cha -- -- Mail Adherent -- +insert into llx_const (name, value, type, note, visible) values ('ADHERENT_MAIL_REQUIRED','1','yesno','Le mail est obligatoire pour créer un adhérent',0); insert into llx_const (name, value, type, note, visible) values ('ADHERENT_MAIL_FROM','adherents@domain.com','chaine','From des mails adherents',0); insert into llx_const (name, value, type, note, visible) values ('ADHERENT_MAIL_RESIL','Votre adhesion sur %SERVEUR% vient d\'etre resilie.\r\nNous esperons vous revoir tres bientot','texte','Mail de Resiliation',0); insert into llx_const (name, value, type, note, visible) values ('ADHERENT_MAIL_VALID','MAIN\r\nVotre adhesion vient d\'etre validee. \r\nVoici le rappel de vos coordonnees (toute information erronee entrainera la non validation de votre inscription) :\r\n\r\n%INFO%\r\n\r\nVous pouvez a tout moment, grace a votre login et mot de passe, modifier vos coordonnees a l\'adresse suivante : \r\n%SERVEUR%public/adherents/','texte','Mail de validation',0); diff --git a/mysql/migration/1.1.0-1.2.0-RC1.sql b/mysql/migration/1.1.0-1.2.0-RC1.sql index 81976ba51e8..1d8b46a1a71 100644 --- a/mysql/migration/1.1.0-1.2.0-RC1.sql +++ b/mysql/migration/1.1.0-1.2.0-RC1.sql @@ -19,7 +19,7 @@ alter table llx_societe add capital real after tva_intra; alter table llx_societe add rubrique varchar(255); alter table llx_societe add remise_client real default 0; - +insert into llx_const (name, value, type, note, visible) values ('ADHERENT_MAIL_REQUIRED','1','yesno','Le mail est obligatoire pour créer un adhérent',0); alter table llx_societe add fk_forme_juridique integer default 0 after fk_typent;