mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix: Gestion erreur sur cration compte Dolibarr depuis contact
Ajout cration compte Dolibarr depuis adherent
This commit is contained in:
parent
d9154c7a07
commit
f882a35fc2
|
|
@ -47,6 +47,9 @@ class Adherent
|
|||
{
|
||||
var $id;
|
||||
var $db;
|
||||
var $error;
|
||||
var $errors=array();
|
||||
|
||||
var $prenom;
|
||||
var $nom;
|
||||
var $fullname;
|
||||
|
|
@ -81,11 +84,13 @@ class Adherent
|
|||
var $type; // Libellé type adherent
|
||||
var $need_subscription;
|
||||
|
||||
var $user_id;
|
||||
var $user_login;
|
||||
|
||||
|
||||
// var $public;
|
||||
var $array_options;
|
||||
|
||||
var $error;
|
||||
var $errors=array();
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -687,9 +692,11 @@ class Adherent
|
|||
$sql.= " ".$this->db->pdate("d.datevalid")." as datev,";
|
||||
$sql.= " d.pays,";
|
||||
$sql.= " p.rowid as pays_id, p.code as pays_code, p.libelle as pays_lib,";
|
||||
$sql.= " t.libelle as type, t.cotisation as cotisation";
|
||||
$sql.= " t.libelle as type, t.cotisation as cotisation,";
|
||||
$sql.= " u.rowid as user_id, u.login as user_login";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.pays = p.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON d.rowid = u.fk_member";
|
||||
$sql.= " WHERE d.rowid = ".$rowid." AND d.fk_adherent_type = t.rowid";
|
||||
dolibarr_syslog("Adherent::fetch sql=".$sql);
|
||||
|
||||
|
|
@ -736,6 +743,9 @@ class Adherent
|
|||
$this->typeid = $obj->fk_adherent_type;
|
||||
$this->type = $obj->type;
|
||||
$this->need_subscription = ($obj->cotisation=='yes'?1:0);
|
||||
|
||||
$this->user_id = $obj->user_id;
|
||||
$this->user_login = $obj->user_login;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,33 @@ $typeid=isset($_GET["typeid"])?$_GET["typeid"]:$_POST["typeid"];
|
|||
* Actions
|
||||
*/
|
||||
|
||||
// Creation utilisateur depuis adherent
|
||||
if ($user->rights->user->user->creer)
|
||||
{
|
||||
if ($_GET["action"] == 'create_user')
|
||||
{
|
||||
// Recuperation contact actuel
|
||||
$adh = new Adherent($db);
|
||||
$result = $adh->fetch($_GET["rowid"]);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
// Creation user
|
||||
$nuser = new User($db);
|
||||
$result=$nuser->create_from_member($adh);
|
||||
|
||||
if ($result < 0)
|
||||
{
|
||||
$msg=$nuser->error;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg=$adh->error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST["action"] == 'confirm_sendinfo' && $_POST["confirm"] == 'yes')
|
||||
{
|
||||
$adh->id = $rowid;
|
||||
|
|
@ -750,6 +777,7 @@ if ($rowid && $action != 'edit')
|
|||
|
||||
dolibarr_fiche_head($head, 'general', $langs->trans("Member"));
|
||||
|
||||
if ($msg) print '<div class="error">'.$msg.'</div>';
|
||||
|
||||
$result=$adh->load_previous_next_id($adh->next_prev_filter);
|
||||
if ($result < 0) dolibarr_print_error($db,$adh->error);
|
||||
|
|
@ -889,6 +917,19 @@ if ($rowid && $action != 'edit')
|
|||
|
||||
// Status
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$adh->getLibStatut(4).'</td></tr>';
|
||||
|
||||
// Login Dolibarr
|
||||
print '<tr><td>'.$langs->trans("DolibarrLogin").'</td><td class="valeur">';
|
||||
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 '</td></tr>';
|
||||
|
||||
|
||||
// Autres attributs
|
||||
foreach($adho->attribute_label as $key=>$value){
|
||||
|
|
@ -933,6 +974,15 @@ if ($rowid && $action != 'edit')
|
|||
{
|
||||
print "<a class=\"butAction\" href=\"fiche.php?rowid=$rowid&action=resign\">".$langs->trans("Resiliate")."</a>\n";
|
||||
}
|
||||
|
||||
// Barre d'actions
|
||||
if (! $user->societe_id)
|
||||
{
|
||||
if (! $adh->user_id && $user->rights->user->user->creer)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?rowid='.$adh->id.'&action=create_user">'.$langs->trans("CreateDolibarrLogin").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
// Supprimer
|
||||
if ($user->rights->adherent->supprimer)
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ foreach ($arrayhandler as $key => $module)
|
|||
// Affiche example
|
||||
print '<td width="60">'.$module->getExample().'</td>';
|
||||
|
||||
print '<td width="50" align="center">';
|
||||
print '<td width="100" align="center">';
|
||||
if ($conf->global->USER_PASSWORD_GENERATED == $key)
|
||||
{
|
||||
$title='';
|
||||
|
|
@ -253,7 +253,7 @@ print '</tr>';
|
|||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<td colspan="3">'.$langs->trans("DoNotStoreClearPassword").'</td>';
|
||||
print '<td align="center" width="20">';
|
||||
print '<td align="center" width="60">';
|
||||
if($conf->global->DATABASE_PWD_ENCRYPTED == 1)
|
||||
{
|
||||
print img_tick();
|
||||
|
|
@ -291,7 +291,7 @@ print '</tr>';
|
|||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<td colspan="3">'.$langs->trans("MainDbPasswordFileConfEncrypted").'</td>';
|
||||
print '<td align="center" width="20">';
|
||||
print '<td align="center" width="60">';
|
||||
if($conf->global->MAIN_DATABASE_PWD_CONFIG_ENCRYPTED == 1)
|
||||
{
|
||||
print img_tick();
|
||||
|
|
@ -323,7 +323,7 @@ $text = $langs->trans("ProtectAndEncryptPdfFiles");
|
|||
$desc = $html->textwithwarning($text,$langs->transnoentities("ProtectAndEncryptPdfFilesDesc"),1);
|
||||
print $desc;
|
||||
print '</td>';
|
||||
print '<td align="center" width="20">';
|
||||
print '<td align="center" width="60">';
|
||||
if($conf->global->PDF_SECURITY_ENCRYPTION == 1)
|
||||
{
|
||||
print img_tick();
|
||||
|
|
|
|||
|
|
@ -65,6 +65,10 @@ class Contact
|
|||
var $ref_commande; // Nb de reference commande pour lequel il est contact
|
||||
var $ref_propal; // Nb de reference propal pour lequel il est contact
|
||||
|
||||
var $user_id;
|
||||
var $user_login;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Constructeur de l'objet contact
|
||||
* \param DB Habler d'accès base
|
||||
|
|
|
|||
|
|
@ -81,11 +81,21 @@ if ($user->rights->user->user->creer)
|
|||
$contact = new Contact($db);
|
||||
$result = $contact->fetch($_GET["id"]);
|
||||
|
||||
// Creation user
|
||||
$nuser = new User($db);
|
||||
$nuser->nom = $contact->name;
|
||||
$nuser->prenom = $contact->firstname;
|
||||
$nuser->create_from_contact($contact);
|
||||
if ($result > 0)
|
||||
{
|
||||
// Creation user
|
||||
$nuser = new User($db);
|
||||
$result=$nuser->create_from_contact($contact);
|
||||
|
||||
if ($result < 0)
|
||||
{
|
||||
$msg=$nuser->error;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg=$contact->error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -445,6 +455,7 @@ if ($user->rights->societe->contact->creer)
|
|||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Login Dolibarr
|
||||
print '<tr><td>'.$langs->trans("DolibarrLogin").'</td><td colspan="3">';
|
||||
if ($contact->user_id)
|
||||
{
|
||||
|
|
@ -473,6 +484,7 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
|
|||
* Fiche en mode visualisation
|
||||
*
|
||||
*/
|
||||
if ($msg) print '<div class="error">'.$msg.'</div>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
|
|
@ -598,7 +610,7 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
|
|||
print '<a class="tabAction" href="fiche.php?id='.$contact->id.'&action=edit">'.$langs->trans('Edit').'</a>';
|
||||
}
|
||||
|
||||
if (! $contact->user_id && $user->admin && $contact->socid > 0)
|
||||
if (! $contact->user_id && $user->rights->user->user->creer && $contact->socid > 0)
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?id='.$contact->id.'&action=create_user">'.$langs->trans("CreateDolibarrLogin").'</a>';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -653,6 +653,8 @@ class User
|
|||
// Nettoyage parametres
|
||||
$this->login = trim($this->login);
|
||||
|
||||
dolibarr_syslog("User::Create login=".$this->login.", user=".$user->id);
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "SELECT login FROM ".MAIN_DB_PREFIX."user";
|
||||
|
|
@ -744,7 +746,7 @@ class User
|
|||
$this->nom = $contact->nom;
|
||||
$this->prenom = $contact->prenom;
|
||||
|
||||
$this->login = strtolower(substr($contact->prenom, 0, 3)) . strtolower(substr($contact->nom, 0, 3));
|
||||
$this->login = strtolower(substr($contact->prenom, 0, 4)) . strtolower(substr($contact->nom, 0, 4));
|
||||
$this->admin = 0;
|
||||
|
||||
$this->email = $contact->email;
|
||||
|
|
@ -803,10 +805,64 @@ class User
|
|||
}
|
||||
|
||||
/**
|
||||
* \brief Affectation des permissions par défaut
|
||||
* \return si erreur <0, si ok renvoi le nbre de droits par defaut positionnés
|
||||
* \brief Créé en base un utilisateur depuis l'objet adherent
|
||||
* \param member Objet adherent source
|
||||
* \return int Si erreur <0, si ok renvoie id compte créé
|
||||
*/
|
||||
function set_default_rights()
|
||||
function create_from_member($member)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
// Positionne paramètres
|
||||
$this->nom = $member->nom;
|
||||
$this->prenom = $member->prenom;
|
||||
|
||||
$this->login = $member->login;
|
||||
$this->admin = 0;
|
||||
|
||||
$this->email = $member->email;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Crée et positionne $this->id
|
||||
$result=$this->create();
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."user";
|
||||
$sql.= " SET fk_member=".$member->id;
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
$resql=$this->db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error()." - ".$sql;
|
||||
dolibarr_syslog("User::create_from_member - 1 - ".$this->error);
|
||||
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// $this->error deja positionné
|
||||
dolibarr_syslog("User::create_from_member - 2 - ".$this->error);
|
||||
|
||||
$this->db->rollback();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Affectation des permissions par défaut
|
||||
* \return Si erreur <0, si ok renvoi le nbre de droits par defaut positionnés
|
||||
*/
|
||||
function set_default_rights()
|
||||
{
|
||||
$sql = "SELECT id FROM ".MAIN_DB_PREFIX."rights_def WHERE bydefault = 1";
|
||||
|
||||
|
|
|
|||
|
|
@ -732,15 +732,33 @@ alter table llx_user add column office_phone varchar(20);
|
|||
alter table llx_user add column office_fax varchar(20);
|
||||
alter table llx_user add column user_mobile varchar(20);
|
||||
|
||||
|
||||
alter table llx_user modify login varchar(24) NOT NULL;
|
||||
alter table llx_user drop code;
|
||||
|
||||
ALTER TABLE llx_user ADD UNIQUE uk_user_login (login);
|
||||
|
||||
update llx_user set pass_crypted = MD5(pass) where pass IS NOT NULL AND pass_crypted IS NULL and length(pass) < 32;
|
||||
update llx_user set pass_crypted = pass where pass IS NOT NULL AND pass_crypted IS NULL and length(pass) = 32;
|
||||
update llx_user set pass = NULL where length(pass) = 32;
|
||||
|
||||
ALTER TABLE llx_user modify fk_societe integer;
|
||||
ALTER TABLE llx_user modify fk_socpeople integer;
|
||||
alter table llx_user add column fk_member integer after fk_socpeople;
|
||||
|
||||
update llx_user set fk_societe = NULL where fk_societe = 0;
|
||||
update llx_user set fk_socpeople = NULL where fk_socpeople = 0;
|
||||
update llx_user set fk_member = NULL where fk_member = 0;
|
||||
|
||||
ALTER TABLE llx_user DROP INDEX login;
|
||||
|
||||
ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_login (login);
|
||||
|
||||
ALTER TABLE llx_user ADD INDEX uk_user_fk_societe (fk_societe);
|
||||
|
||||
ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_fk_socpeople (fk_socpeople);
|
||||
ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_fk_member (fk_member);
|
||||
|
||||
|
||||
alter table llx_boxes add column fk_user integer;
|
||||
|
||||
alter table llx_commande_fournisseur drop column fk_soc_contact;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
-- ============================================================================
|
||||
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
-- Copyright (C) 2007 Regis Houssin <regis.houssin@cap-networks.com>
|
||||
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
-- Copyright (C) 2007 Regis Houssin <regis.houssin@cap-networks.com>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -23,4 +23,9 @@
|
|||
-- ===========================================================================
|
||||
|
||||
|
||||
ALTER TABLE llx_user ADD UNIQUE uk_user_login (login);
|
||||
ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_login (login);
|
||||
|
||||
ALTER TABLE llx_user ADD INDEX uk_user_fk_societe (fk_societe);
|
||||
|
||||
ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_fk_socpeople (fk_socpeople);
|
||||
ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_fk_member (fk_member);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
-- ============================================================================
|
||||
-- Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
-- Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
-- Copyright (C) 2007 Regis Houssin <regis.houssin@cap-networks.com>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -40,8 +40,9 @@ create table llx_user
|
|||
webcal_login varchar(25),
|
||||
module_comm smallint DEFAULT 1,
|
||||
module_compta smallint DEFAULT 1,
|
||||
fk_societe integer DEFAULT 0,
|
||||
fk_socpeople integer DEFAULT 0,
|
||||
fk_societe integer,
|
||||
fk_socpeople integer,
|
||||
fk_member integer,
|
||||
note text DEFAULT NULL,
|
||||
datelastlogin datetime,
|
||||
datepreviouslogin datetime,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user