From 1e37d24bf4a40ddca4ac313e4a5eb67ab6a5558d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 May 2009 23:30:49 +0000 Subject: [PATCH] Can make a link between a member and a user --- htdocs/adherents/adherent.class.php | 44 +++++- htdocs/adherents/fiche.php | 208 ++++++++++++++++------------ htdocs/admin/const.php | 23 +-- htdocs/langs/en_US/users.lang | 8 +- htdocs/langs/fr_FR/users.lang | 6 +- htdocs/lib/security.lib.php | 2 +- htdocs/main.inc.php | 84 ++++++----- htdocs/master.inc.php | 3 +- htdocs/user.class.php | 41 ++++-- htdocs/user/fiche.php | 131 +++++++++++------- mysql/tables/llx_adherent.key.sql | 1 + 11 files changed, 349 insertions(+), 202 deletions(-) diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php index 0a6bda9600a..c2d491c1f0e 100644 --- a/htdocs/adherents/adherent.class.php +++ b/htdocs/adherents/adherent.class.php @@ -58,7 +58,6 @@ class Adherent extends CommonObject var $login; var $pass; var $societe; - var $fk_soc; var $adresse; var $cp; var $ville; @@ -90,6 +89,8 @@ class Adherent extends CommonObject var $user_id; var $user_login; + var $fk_soc; + // Fields loaded by fetch_subscriptions() var $fistsubscription_date; var $fistsubscription_amount; @@ -296,13 +297,30 @@ class Adherent extends CommonObject $this->id=$id; // Update minor fields - $result=$this->update($user,1,1); + $result=$this->update($user,1,1); // nosync is 1 to avoid update data of user if ($result < 0) { $this->db->rollback(); return -1; } + // Add link to user + if ($this->user_id) + { + // Add link to user + $sql = "UPDATE ".MAIN_DB_PREFIX."user SET"; + $sql.= " fk_member = '".$this->id."'"; + $sql.= " WHERE rowid = ".$this->user_id; + dol_syslog("Adherent::create sql=".$sql); + $resql = $this->db->query($sql); + if (! $resql) + { + $this->error='Failed to update user to make link with member'; + $this->db->rollback(); + return -4; + } + } + $this->use_webcal=($conf->global->PHPWEBCALENDAR_MEMBERSTATUS=='always'?1:0); if (! $notrigger) @@ -456,9 +474,23 @@ class Adherent extends CommonObject } } - if ($nbrowsaffected) + // Remove link to user + $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL where fk_member = ".$this->id; + dol_syslog("Adherent::update sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -5; } + // If there is a user linked to this member + if ($this->user_id > 0) { - if ($this->user_id && ! $nosyncuser) + $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = ".$this->id." where rowid = ".$this->user_id; + dol_syslog("Adherent::update sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -5; } + } + + if ($nbrowsaffected) // If something has change in data + { + if ($this->user_id > 0 && ! $nosyncuser) { require_once(DOL_DOCUMENT_ROOT."/user.class.php"); @@ -1721,11 +1753,11 @@ class Adherent extends CommonObject if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe $this->nbtodo=$this->nbtodolate=0; - + $sql = "SELECT a.rowid, a.datefin"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; $sql.= " WHERE a.statut=1"; - + $resql=$this->db->query($sql); if ($resql) { diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 807529209f9..052b23e5202 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -133,6 +133,10 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"]) { $result=$adh->fetch($_POST["rowid"]); + // Is it a new link to a user ? + $nosyncuser=0; + if ($adh->user_id != $_POST["userid"]) $nosyncuser=1; + // If change (allowed on all members) or (allowed on myself and i am edited memeber) if ($user->rights->adherent->creer || ($user->rights->adherent->self->creer && $adh->user_id == $user->id)) { @@ -177,6 +181,9 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"]) $adh->statut = $_POST["statut"]; $adh->public = $_POST["public"]; + $adh->fk_soc = $_POST["socid"]; + $adh->user_id = $_POST["userid"]; + foreach($_POST as $key => $value) { if (ereg("^options_",$key)) @@ -187,7 +194,7 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"]) } } - $result=$adh->update($user,0); + $result=$adh->update($user,0,$nosyncuser); if ($result >= 0 && ! sizeof($adh->errors)) { if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) @@ -230,7 +237,7 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"]) } } -if ($user->rights->adherent->creer && $_POST["action"] == 'add') +if ($_POST["action"] == 'add' && $user->rights->adherent->creer) { $datenaiss=''; if (isset($_POST["naissday"]) && $_POST["naissday"] @@ -265,6 +272,9 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'add') $morphy=$_POST["morphy"]; $cotisation=$_POST["cotisation"]; + $userid=$_POST["userid"]; + $socid=$_POST["socid"]; + $adh->prenom = $prenom; $adh->nom = $nom; $adh->societe = $societe; @@ -283,8 +293,12 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'add') $adh->typeid = $typeid; $adh->note = $comment; $adh->morphy = $morphy; - foreach($_POST as $key => $value){ - if (ereg("^options_",$key)){ + $adh->user_id = $userid; + $adh->fk_soc = $socid; + foreach($_POST as $key => $value) + { + if (ereg("^options_",$key)) + { //escape values from POST, at least with addslashes, to avoid obvious SQL injections //(array_options is directly input in the DB in adherent.class.php::update()) $adh->array_options[$key]=addslashes($_POST[$key]); @@ -374,9 +388,8 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'add') } $db->commit(); - - Header("Location: liste.php?statut=-1"); - exit; + $rowid=$adh->id; + $action=''; } else { @@ -537,6 +550,7 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'confirm_add_spip' && llxHeader(); +$html = new Form($db); if ($errmsg) { @@ -577,25 +591,34 @@ if ($action == 'edit') dol_fiche_head($head, 'general', $langs->trans("Member")); + $rowspan=14; + $rowspan+=sizeof($adho->attribute_label); + if ($conf->societe->enabled) $rowspan++; print '
'; print ""; print ""; print "statut."\">"; - $htmls = new Form($db); - print ''; // Ref - print ''; + print ''; + + // Physique-Moral + $morphys["phy"] = $langs->trans("Physical"); + $morphys["mor"] = $langs->trans("Morale"); + print ""; + + // Societe + print ''; // Nom print ''; // Photo - $rowspan=16; - $rowspan+=sizeof($adho->attribute_label); print '"; - // Physique-Moral - $morphys["phy"] = $langs->trans("Physical"); - $morphys["mor"] = $langs->trans("Morale"); - print ""; - - // Societe - print ''; - // Adresse print ''; @@ -657,7 +670,7 @@ if ($action == 'edit') // Pays print ''; // Tel @@ -674,12 +687,12 @@ if ($action == 'edit') // Date naissance print "\n"; // Profil public print "\n"; // Attributs supplementaires @@ -688,6 +701,19 @@ if ($action == 'edit') print "\n"; } + // Third party Dolibarr + if ($conf->societe->enabled) + { + print ''; + } + + // Login Dolibarr + print ''; + print '\n"; // Value print ''; - + // Entity if ($conf->multicompany->enabled) { @@ -157,13 +161,14 @@ if ($result) { print ''; } - + print '\n"; print ''; + print "\n"; $i++; } } diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index cbe9598462f..f41561fd5e8 100755 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -71,8 +71,12 @@ ListOfGroupsForUser=List of groups for this user UsersToAdd=Users to add to this group GroupsToAdd=Groups to add to this user NoLogin=No login -CreateDolibarrLogin=Create Dolibarr account -CreateDolibarrThirdParty=Create third party +LinkToCompanyContact=Link to third party / contact +LinkedToDolibarrMember=Link to member +LinkedToDolibarrUser=Link to Dolibarr user +LinkedToDolibarrThirdParty=Link to Dolibarr third party +CreateDolibarrLogin=Create a user +CreateDolibarrThirdParty=Create a third party LoginAccountDisable=Account disabled, put a new login to activate it. LoginAccountDisableInDolibarr=Account disabled in Dolibarr. LoginAccountDisableInLdap=Account disabled in the domain. diff --git a/htdocs/langs/fr_FR/users.lang b/htdocs/langs/fr_FR/users.lang index b3a7dc1ec4f..937e21d1501 100755 --- a/htdocs/langs/fr_FR/users.lang +++ b/htdocs/langs/fr_FR/users.lang @@ -71,7 +71,11 @@ ListOfGroupsForUser=Liste des groupes pour cet utilisateur UsersToAdd=Utilisateur à ajouter à ce groupe GroupsToAdd=Groupes à ajouter pour cet utilisateur NoLogin=Pas de login -CreateDolibarrLogin=Créer un compte Dolibarr +LinkToCompanyContact=Lien tiers / contact +LinkedToDolibarrMember=Lien adhérent +LinkedToDolibarrUser=Lien utilisateur Dolibarr +LinkedToDolibarrThirdParty=Lien tiers Dolibarr +CreateDolibarrLogin=Créer un compte utilisateur CreateDolibarrThirdParty=Créer un tiers LoginAccountDisable=Le compte est désactivé, mettre un nouveau login pour l'activer. LoginAccountDisableInDolibarr=Le compte est désactivé sur Dolibarr. diff --git a/htdocs/lib/security.lib.php b/htdocs/lib/security.lib.php index 494818808cd..26e19084246 100644 --- a/htdocs/lib/security.lib.php +++ b/htdocs/lib/security.lib.php @@ -154,7 +154,7 @@ function dol_loginfunction($langs,$conf,$mysoc) print ''; print ''; } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 871c20bf597..c7dc6a809a5 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -81,21 +81,21 @@ function analyse_sql_injection(&$var) $result = array(); foreach ($var as $key => $value) { - if (test_sql_inject($key) > 0) - { - unset($var[$key]); - } - else - { - if (analyse_sql_injection($value)) - { - $var[$key] = $value; - } - else - { - unset($var[$key]); - } - } + if (test_sql_inject($key) > 0) + { + unset($var[$key]); + } + else + { + if (analyse_sql_injection($value)) + { + $var[$key] = $value; + } + else + { + unset($var[$key]); + } + } } return true; } @@ -112,12 +112,8 @@ analyse_sql_injection($_POST); // This is to make Dolibarr working with Plesk set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); -// Retrieve the entity in login form, and after in the cookie -$entityCookieName = "DOLENTITYID_dolibarr"; -if (isset($_POST["entity"])) $_SESSION["dol_entity"] = $_POST["entity"]; -if (isset($_COOKIE[$entityCookieName])) $_SESSION["dol_entity"] = $_COOKIE[$entityCookieName]; - // Set and init common variables +// This include will set $conf, $langs and $mysoc objects require_once("master.inc.php"); // Check if HTTPS @@ -166,7 +162,27 @@ session_name($sessionname); session_start(); dol_syslog("Start session name=".$sessionname." Session id()=".session_id().", _SESSION['dol_login']=".(isset($_SESSION["dol_login"])?$_SESSION["dol_login"]:'').", ".ini_get("session.gc_maxlifetime")); -// Disable modules (this must be after session_start) +// Retrieve the entity in login form and in the cookie. +// This must be after the init of session (session_start) or this create serious pb of corrupted session. +$entityCookieName = "DOLENTITYID_dolibarr"; +if (isset($_POST["loginfunction"]) && isset($_POST["entity"])) +{ + $_SESSION["dol_entity"] = $_POST["entity"]; + $conf->entity=$_SESSION["dol_entity"]; + dol_syslog("Will work on entity ".$conf->entity); + // Now we need to reload the conf with the choosed entity + $conf->setValues($db); +} +elseif (isset($_COOKIE[$entityCookieName])) +{ + $_SESSION["dol_entity"] = $_COOKIE[$entityCookieName]; + $conf->entity=$_SESSION["dol_entity"]; + dol_syslog("Will work on entity ".$conf->entity); + // Now we need to reload the conf with the choosed entity + $conf->setValues($db); +} + +// Disable modules (this must be after session_start and after conf has been reloaded) if (! empty($_REQUEST["disablemodules"])) $_SESSION["disablemodules"]=$_REQUEST["disablemodules"]; if (! empty($_SESSION["disablemodules"])) { @@ -663,7 +679,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs { print "\n"; - print "\n"; + print "\n"; // Affiche meta print ''."\n"; // Evite indexation par robots @@ -1088,8 +1104,8 @@ function llxFooter($foot='') } print '"'."\n"; - // Add Xdebug coverage of code - if (defined('XDEBUGCOVERAGE')) { var_dump(xdebug_get_code_coverage()); } + // Add Xdebug coverage of code + if (defined('XDEBUGCOVERAGE')) { var_dump(xdebug_get_code_coverage()); } } if ($conf->use_javascript_ajax) @@ -1098,21 +1114,21 @@ function llxFooter($foot='') } // If there is some logs in buffer to show - if (sizeof($conf->logbuffer)) - { + if (sizeof($conf->logbuffer)) + { print "\n"; print "\n"; - } + } print "\n"; - if ($foot) print ''."\n"; + if ($foot) print ''."\n"; print "\n"; print "\n"; diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index c6033b4c0c0..8cb47762ed2 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -115,7 +115,8 @@ require_once(DOL_DOCUMENT_ROOT."/core/conf.class.php"); $conf = new Conf(); // Retrieve the entity -if (isset($_SESSION["dol_entity"])) $conf->entity = $_SESSION["dol_entity"]; +// Removed: The session has not been initialized yet so using SESSION is forbidden here +//if (isset($_SESSION["dol_entity"])) $conf->entity = $_SESSION["dol_entity"]; // Identifiant propres au serveur base de donnee $conf->db->host = $dolibarr_main_db_host; diff --git a/htdocs/user.class.php b/htdocs/user.class.php index f6e75d666aa..375ac970b0b 100644 --- a/htdocs/user.class.php +++ b/htdocs/user.class.php @@ -209,7 +209,7 @@ class User extends CommonObject $this->societe_id = $obj->fk_societe; $this->contact_id = $obj->fk_socpeople; $this->fk_member = $obj->fk_member; - + $this->next_prev_filter = 'entity IN (0,'.$conf->entity.')'; if (! $this->lang) $this->lang='fr_FR'; @@ -273,7 +273,7 @@ class User extends CommonObject function addrights($rid,$allmodule='',$allperms='') { global $conf; - + dol_syslog("User::addrights $rid, $allmodule, $allperms"); $err=0; $whereforadd=''; @@ -371,7 +371,7 @@ class User extends CommonObject function delrights($rid,$allmodule='',$allperms='') { global $conf; - + $err=0; $wherefordel=''; @@ -474,7 +474,7 @@ class User extends CommonObject function getrights($moduletag='') { global $conf; - + if ($moduletag && isset($this->tab_loaded[$moduletag]) && $this->tab_loaded[$moduletag]) { // Le fichier de ce module est deja charge @@ -684,7 +684,7 @@ class User extends CommonObject } /** - * \brief Cree l'utilisateur en base + * \brief Create user in database * \param user Objet user qui demande la creation * \param notrigger 1 ne declenche pas les triggers, 0 sinon * \return int <0 si KO, id compte cree si OK @@ -693,8 +693,9 @@ class User extends CommonObject { global $conf,$langs; - // Nettoyage parametres + // Clean parameters $this->login = trim($this->login); + if (! isset($this->entity)) $this->entity=$conf->entity; // If not defined, we use default value dol_syslog("User::Create login=".$this->login.", user=".(is_object($user)?$user->id:''), LOG_DEBUG); @@ -920,7 +921,7 @@ class User extends CommonObject function set_default_rights() { global $conf; - + $sql = "SELECT id FROM ".MAIN_DB_PREFIX."rights_def"; $sql.= " WHERE bydefault = 1"; $sql.= " AND entity = ".$conf->entity; @@ -970,7 +971,7 @@ class User extends CommonObject dol_syslog("User::update notrigger=".$notrigger.", nosyncmember=".$nosyncmember); - // Nettoyage parametres + // Clean parameters $this->nom = trim($this->nom); $this->prenom = trim($this->prenom); $this->fullname = $this->prenom." ".$this->nom; @@ -1014,7 +1015,7 @@ class User extends CommonObject { $nbrowsaffected+=$this->db->affected_rows($resql); - // Mise a jour mot de passe + // Mise a jour mot de passe if ($this->pass) { if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) @@ -1025,9 +1026,23 @@ class User extends CommonObject } } - if ($nbrowsaffected) + // If user is linked to a member, remove old link to this member + if ($this->fk_member > 0) { - if ($this->fk_member && ! $nosyncmember) + $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL where fk_member = ".$this->fk_member; + dol_syslog("User::update sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -5; } + } + // Set link to user + $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member =".($this->fk_member>0?$this->fk_member:'null')." where rowid = ".$this->id; + dol_syslog("User::update sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -5; } + + if ($nbrowsaffected) // If something has changed in data + { + if ($this->fk_member > 0 && ! $nosyncmember) { require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php"); @@ -1042,7 +1057,7 @@ class User extends CommonObject $adh->nom=$this->nom; $adh->login=$this->login; $adh->pass=$this->pass; - $adh->societe=$this->societe_id; + $adh->societe=(empty($adh->societe) && $this->societe_id ? $this->societe_id : $adh->societe); $adh->email=$this->email; $adh->phone=$this->office_phone; @@ -1052,7 +1067,7 @@ class User extends CommonObject $adh->user_id=$this->id; $adh->user_login=$this->login; - + //$adh->entity=$this->entity; $result=$adh->update($user,0,1); diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index ef8c4c470c3..e96a6b9e197 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -829,7 +829,9 @@ else print ''; print "\n"; - $rowspan=12; + $rowspan=11; + if ($conf->societe->enabled) $rowspan++; + if ($conf->adherent->enabled) $rowspan++; // Login print ''; @@ -922,30 +924,6 @@ else } print ''; - // Company / Contact - print ''; - print ''; - print "\n"; - // Tel pro print ''; print ''; @@ -1000,12 +978,39 @@ else print "\n"; } + // Company / Contact + if ($conf->societe->enabled) + { + print ''; + print ''; + print "\n"; + } + // Module Adherent if ($conf->adherent->enabled) { $langs->load("members"); - print ''; - print ''; + print '
'.$langs->trans("Ref").''.$adh->id.' 
'.$langs->trans("Ref").''.$adh->id.'
".$langs->trans("Person").'*'; + $html->select_array("morphy", $morphys, $adh->morphy); + print "
'.$langs->trans("Company").'
'.$langs->trans("Lastname").'*'; if (file_exists($conf->adherent->dir_output."/".$adh->id.".jpg")) { @@ -629,7 +652,7 @@ if ($action == 'edit') print '
'.$langs->trans("Type").'*'; if ($user->rights->adherent->creer) // If $user->rights->adherent->self->creer, we do not allow. { - $htmls->select_array("typeid", $adht->liste_array(), $adh->typeid); + $html->select_array("typeid", $adht->liste_array(), $adh->typeid); } else { @@ -638,16 +661,6 @@ if ($action == 'edit') } print "
".$langs->trans("Person")."*"; - $htmls->select_array("morphy", $morphys, $adh->morphy); - print "
'.$langs->trans("Company").'
'.$langs->trans("Address").''; print '
'.$langs->trans("Country").''; - $htmls->select_pays($adh->pays_code?$adh->pays_code:$mysoc->pays_code,'pays'); + $html->select_pays($adh->pays_code?$adh->pays_code:$mysoc->pays_code,'pays'); print '
".$langs->trans("Birthday")."\n"; - $htmls->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'update'); + $html->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'update'); print "
".$langs->trans("Public")."\n"; - print $htmls->selectyesno("public",$adh->public,1); + print $html->selectyesno("public",$adh->public,1); print "
$valuearray_options["options_$key"]."\">
'.$langs->trans("LinkedToDolibarrThirdParty").''; + print $html->select_societes($adh->fk_soc,'socid','',1); + print '
'.$langs->trans("LinkedToDolibarrUser").''; + print $html->select_users($adh->user_id,'userid',1); + print '
'; print ''; print '       '; @@ -709,16 +735,25 @@ if ($action == 'create') /* */ /* ************************************************************************** */ - $htmls = new Form($db); $adht = new AdherentType($db); print_fiche_titre($langs->trans("NewMember")); - print ''; + print ''; print ''; print ''; + // Moral-Physique + $morphys["phy"] = "Physique"; + $morphys["mor"] = "Morale"; + print "\n"; + + // Company + print ''; + // Nom print ''; print ''; @@ -750,22 +785,12 @@ if ($action == 'create') $listetype=$adht->liste_array(); if (sizeof($listetype)) { - $htmls->select_array("typeid", $listetype, $typeid); + $html->select_array("typeid", $listetype, $typeid); } else { print ''.$langs->trans("NoTypeDefinedGoToSetup").''; } print "\n"; - - // Moral-Physique - $morphys["phy"] = "Physique"; - $morphys["mor"] = "Morale"; - print "\n"; - - print ''; - // Adresse print ''; @@ -775,7 +800,7 @@ if ($action == 'create') // Pays print ''; // Tel pro @@ -792,20 +817,32 @@ if ($action == 'create') // Date naissance print "\n"; - // Attribut optionnels + // Profil public + print "\n"; + + // Attribut optionnels foreach($adho->attribute_label as $key=>$value) { print "\n"; } - // Profil public - print "\n"; + // Third party Dolibarr + if ($conf->societe->enabled) + { + print ''; + } + // Login Dolibarr + print ''; print "
".$langs->trans("Person")."*\n"; + $html->select_array("morphy", $morphys, $adh->morphy); + print "
'.$langs->trans("Company").'
'.$langs->trans("Lastname").'*
".$langs->trans("Person")."*\n"; - $htmls->select_array("morphy", $morphys, $adh->morphy); - print "
'.$langs->trans("Company").'
'.$langs->trans("Address").''; print '
'.$langs->trans("Country").''; - $htmls->select_pays($adh->pays_id ? $adh->pays_id : $mysoc->pays_id,'pays_id'); + $html->select_pays($adh->pays_id ? $adh->pays_id : $mysoc->pays_id,'pays_id'); print '
".$langs->trans("Birthday")."\n"; - $htmls->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'add'); + $html->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'add'); print "
".$langs->trans("Public")."\n"; + print $html->selectyesno("public",$adh->public,1); + print "
$value
".$langs->trans("Public")."\n"; - print $htmls->selectyesno("public",$adh->public,1); - print "
'.$langs->trans("LinkedToDolibarrThirdParty").''; + print $html->select_societes($adh->fk_soc,'socid','',1); + print '
'.$langs->trans("LinkedToDolibarrUser").''; + print $html->select_users($adh->user_id,'userid',1); + print '
\n"; print '
'; @@ -939,6 +976,8 @@ if ($rowid && $action != 'edit') if ($ret == 'html') print '
'; } + $rowspan=14+sizeof($adho->attribute_label); + if ($conf->societe->enabled) $rowspan++; print ''; print ''; @@ -949,7 +988,13 @@ if ($rowid && $action != 'edit') print $html->showrefnav($adh,'rowid'); print ''; - // Nom + // Morphy + print ''; + + // Company + print ''; + + // Nom print ''; print ''; @@ -958,7 +1003,6 @@ if ($rowid && $action != 'edit') // Login print ''; - $rowspan=16+sizeof($adho->attribute_label); print '\n"; - // Morphy - print ''; - - // Company - print ''; - - // Adresse + // Address print ''; // CP / Ville @@ -1013,22 +1051,16 @@ if ($rowid && $action != 'edit') // Status print ''; - // Login Dolibarr - print ''; + // Other attributs + foreach($adho->attribute_label as $key=>$value) + { + print "\n"; + } // Third party Dolibarr if ($conf->societe->enabled) { - print ''; } - // Other attributs - foreach($adho->attribute_label as $key=>$value) - { - print "\n"; - } + // Login Dolibarr + print ''; print "
'.$langs->trans("Person").''.$adh->getmorphylib().'
'.$langs->trans("Company").''.$adh->societe.'
'.$langs->trans("Lastname").''.$adh->nom.' 
'.$langs->trans("Login").''.$adh->login.' '; if (file_exists($conf->adherent->dir_output."/".$adh->id.".jpg")) { @@ -977,13 +1021,7 @@ if ($rowid && $action != 'edit') // Type print '
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("Person").''.$adh->getmorphylib().'
'.$langs->trans("Company").''.$adh->societe.'
'.$langs->trans("Address").''.nl2br($adh->adresse).'
'.$langs->trans("Status").''.$adh->getLibStatut(4).'
'.$langs->trans("DolibarrLogin").''; - if ($adh->user_id) - { - $dolibarr_user=new User($db); - $dolibarr_user->id=$adh->user_id; - $result=$dolibarr_user->fetch(); - print $dolibarr_user->getLoginUrl(1); - } - else print $langs->trans("NoDolibarrAccess"); - print '
$value".$adh->array_options["options_$key"]." 
'.$langs->trans("ThirdPartyDolibarr").''; + print '
'.$langs->trans("LinkedToDolibarrThirdParty").''; if ($adh->fk_soc) { $company=new Societe($db); @@ -1042,11 +1074,17 @@ if ($rowid && $action != 'edit') print '
$value".$adh->array_options["options_$key"]." 
'.$langs->trans("LinkedToDolibarrUser").''; + if ($adh->user_id) + { + $dolibarr_user=new User($db); + $dolibarr_user->id=$adh->user_id; + $result=$dolibarr_user->fetch(); + print $dolibarr_user->getLoginUrl(1); + } + else print $langs->trans("NoDolibarrAccess"); + print '
\n"; print ''; @@ -1122,19 +1160,6 @@ if ($rowid && $action != 'edit') } } - // Create user - if (! $user->societe_id && ! $adh->user_id) - { - if ($user->rights->user->user->creer) - { - print ''.$langs->trans("CreateDolibarrLogin").''; - } - else - { - print "".$langs->trans("CreateDolibarrLogin").""; - } - } - // Create third party if ($conf->societe->enabled && ! $adh->fk_soc) { @@ -1148,6 +1173,19 @@ if ($rowid && $action != 'edit') } } + // Create user + if (! $user->societe_id && ! $adh->user_id) + { + if ($user->rights->user->user->creer) + { + print ''.$langs->trans("CreateDolibarrLogin").''; + } + else + { + print "".$langs->trans("CreateDolibarrLogin").""; + } + } + // Supprimer if ($user->rights->adherent->supprimer) { diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index a0a23f0f068..8827b2199c3 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -105,19 +105,22 @@ print ''; # Affiche lignes des constantes -if ($all==1){ +if ($all==1) +{ $sql = "SELECT rowid, name, value, note, entity "; $sql.= "FROM llx_const "; $sql.= "WHERE entity IN (0,".$conf->entity.") "; $sql.= "ORDER BY name ASC"; -}else{ +} +else +{ $sql = "SELECT rowid, name, value, note, entity "; $sql.= "FROM llx_const "; $sql.= "WHERE visible = 1 "; $sql.= "AND entity IN (0,".$conf->entity.") "; $sql.= "ORDER BY name ASC"; } -dol_syslog("Const::listConstant sql=".$sql,LOG_DEBUG); +dol_syslog("Const::listConstant sql=".$sql); $result = $db->query($sql); if ($result) { @@ -130,22 +133,23 @@ if ($result) $obj = $db->fetch_object($result); $var=!$var; - print '
'; + print "\n"; + print ''; print ''; - print ''; + print ''; print ''; print "
$obj->name'; - print ''; + print ''; print ''; // Note - print ''; + print ''; print ''; print '   '; print ''.img_delete().''; print "
  '.$langs->trans("Entity").'   '; - $html->select_array('entity',$entity); + print $html->selectarray('entity',$entity); print '
'.$fuser->prenom.'
'.$langs->trans("Login").'
'.$langs->trans("Company").' / '.$langs->trans("Contact").''; - if ($fuser->societe_id > 0) - { - $societe = new Societe($db); - $societe->fetch($fuser->societe_id); - print $societe->getNomUrl(1,''); - } - else - { - print $langs->trans("ThisUserIsNot"); - } - if ($fuser->contact_id) - { - $contact = new Contact($db); - $contact->fetch($fuser->contact_id); - if ($fuser->societe_id > 0) print ' / '; - else print '
'; - print ''.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).''; - } - print '
'.$langs->trans("PhonePro").''.dol_print_phone($fuser->office_phone,'',0,0,1).'
'.$langs->trans("LinkToCompanyContact").''; + if ($fuser->societe_id > 0) + { + $societe = new Societe($db); + $societe->fetch($fuser->societe_id); + print $societe->getNomUrl(1,''); + } + else + { + print $langs->trans("ThisUserIsNot"); + } + if ($fuser->contact_id) + { + $contact = new Contact($db); + $contact->fetch($fuser->contact_id); + if ($fuser->societe_id > 0) print ' / '; + else print '
'; + print ''.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).''; + } + print '
'.$langs->trans("MemberAccount").''; + print '
'.$langs->trans("LinkedToDolibarrMember").''; if ($fuser->fk_member) { $adh=new Adherent($db); @@ -1261,7 +1266,9 @@ else print ''; print ''; - $rowspan=10; + $rowspan=9; + if ($conf->societe->enabled) $rowspan++; + if ($conf->adherent->enabled) $rowspan++; print ''; print ''; - // Company / Contact - print ''; - print ''; - print "\n"; - // Tel pro print "".''; print ''; } + // Company / Contact + if ($conf->societe->enabled) + { + print ''; + print ''; + print "\n"; + } + + // Module Adherent + if ($conf->adherent->enabled) + { + $langs->load("members"); + print ''; + print ''; + print "\n"; + } + print '
'.$langs->trans("Ref").''; @@ -1398,28 +1405,6 @@ else } print '
'.$langs->trans("Company").' / '.$langs->trans("Contact").''; - if ($fuser->societe_id > 0) - { - $societe = new Societe($db); - $societe->fetch($fuser->societe_id); - print $societe->getNomUrl(1,''); - if ($fuser->contact_id) - { - $contact = new Contact($db); - $contact->fetch($fuser->contact_id); - print ' / '.''.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).''; - } - } - else - { - print $langs->trans("ThisUserIsNot"); - } - print '
'.$langs->trans("PhonePro").''; @@ -1511,6 +1496,52 @@ else print '
'.$langs->trans("LinkToCompanyContact").''; + if ($fuser->societe_id > 0) + { + $societe = new Societe($db); + $societe->fetch($fuser->societe_id); + print $societe->getNomUrl(1,''); + if ($fuser->contact_id) + { + $contact = new Contact($db); + $contact->fetch($fuser->contact_id); + print ' / '.''.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).''; + } + } + else + { + print $langs->trans("ThisUserIsNot"); + } + print '
'.$langs->trans("LinkedToDolibarrMember").''; + if ($fuser->fk_member) + { + $adh=new Adherent($db); + $adh->fetch($fuser->fk_member); + $adh->ref=$adh->login; // Force to show login instead of id + print $adh->getNomUrl(1); + } + else + { + print $langs->trans("UserNotLinkedToMember"); + } + print '
'; print ''; print '   '; diff --git a/mysql/tables/llx_adherent.key.sql b/mysql/tables/llx_adherent.key.sql index c6f467c6dcd..4fd40cb8e4d 100644 --- a/mysql/tables/llx_adherent.key.sql +++ b/mysql/tables/llx_adherent.key.sql @@ -20,6 +20,7 @@ ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_login (login); +ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_fk_soc (fk_soc); ALTER TABLE llx_adherent ADD INDEX idx_adherent_fk_soc (fk_soc); ALTER TABLE llx_adherent ADD INDEX idx_adherent_fk_adherent_type (fk_adherent_type);