diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index 67b144ffd89..9e3036e29a0 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -1299,11 +1299,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$action = 'presend';
}
+ // View mode
if (!empty($id) && $action != 'edit' && $action != 'create') {
$objsoc = new Societe($db);
- // View mode
-
// Show errors
dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors);
@@ -1528,9 +1527,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
if ($object->user_id) {
$dolibarr_user = new User($db);
$result = $dolibarr_user->fetch($object->user_id);
- print $dolibarr_user->getLoginUrl(1);
+ print $dolibarr_user->getLoginUrl(-1);
} else {
- print $langs->trans("NoDolibarrAccess");
+ //print ''.$langs->trans("NoDolibarrAccess").' ';
+ if (!$object->user_id && $user->rights->user->user->creer) {
+ print ''.img_picto($langs->trans("CreateDolibarrLogin"), 'add').' '.$langs->trans("CreateDolibarrLogin").' ';
+ }
}
print '';
@@ -1563,10 +1565,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print ''.$langs->trans('Modify').' ';
}
- if (!$object->user_id && $user->rights->user->user->creer) {
- print ''.$langs->trans("CreateDolibarrLogin").' ';
- }
-
// Activer
if ($object->statut == 0 && $user->rights->societe->contact->creer) {
print ''.$langs->trans("Reactivate").' ';
diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php
index 32f2a9b1007..2a900ea53a4 100644
--- a/htdocs/core/class/html.formcompany.class.php
+++ b/htdocs/core/class/html.formcompany.class.php
@@ -825,13 +825,14 @@ class FormCompany extends Form
/**
* showContactRoles on view and edit mode
*
- * @param string $htmlname Html component name and id
- * @param Contact $contact Contact Obejct
- * @param string $rendermode view, edit
- * @param array $selected $key=>$val $val is selected Roles for input mode
- * @return string String with contacts roles
+ * @param string $htmlname Html component name and id
+ * @param Contact $contact Contact Obejct
+ * @param string $rendermode view, edit
+ * @param array $selected $key=>$val $val is selected Roles for input mode
+ * @param string $morecss More css
+ * @return string String with contacts roles
*/
- public function showRoles($htmlname, Contact $contact, $rendermode = 'view', $selected = array())
+ public function showRoles($htmlname, Contact $contact, $rendermode = 'view', $selected = array(), $morecss = 'minwidth500')
{
if ($rendermode === 'view') {
$toprint = array();
@@ -856,7 +857,7 @@ class FormCompany extends Form
$selected = $newselected;
}
}
- return $this->multiselectarray($htmlname, $contactType, $selected, 0, 0, 'minwidth500');
+ return $this->multiselectarray($htmlname, $contactType, $selected, 0, 0, $morecss);
}
return 'ErrorBadValueForParameterRenderMode'; // Should not happened
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index cc99471a69f..e6398065af1 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -890,14 +890,15 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel
/**
* Show html area for list of contacts
*
- * @param Conf $conf Object conf
- * @param Translate $langs Object langs
- * @param DoliDB $db Database handler
- * @param Societe $object Third party object
- * @param string $backtopage Url to go once contact is created
+ * @param Conf $conf Object conf
+ * @param Translate $langs Object langs
+ * @param DoliDB $db Database handler
+ * @param Societe $object Third party object
+ * @param string $backtopage Url to go once contact is created
+ * @param int $showuserlogin 1=Show also user login if it exists
* @return int
*/
-function show_contacts($conf, $langs, $db, $object, $backtopage = '')
+function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserlogin = 0)
{
global $user, $conf, $extrafields, $hookmanager;
global $contextpage;
@@ -1131,13 +1132,16 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
if (in_array($key, array('statut'))) {
print $form->selectarray('search_status', array('-1'=>'', '0'=>$contactstatic->LibStatut(0, 1), '1'=>$contactstatic->LibStatut(1, 1)), $search_status);
} elseif (in_array($key, array('role'))) {
- print $formcompany->showRoles("search_roles", $contactstatic, 'edit', $search_roles);
+ print $formcompany->showRoles("search_roles", $contactstatic, 'edit', $search_roles, 'minwidth200 maxwidth300');
} else {
print ' ';
}
print '';
}
}
+ if ($showuserlogin) {
+ print '
';
+ }
// Extra fields
$extrafieldsobjectkey = $contactstatic->table_element;
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
@@ -1177,6 +1181,9 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
print getTitleFieldOfList($arrayfields['sc.'.$key]['label'], 0, $_SERVER['PHP_SELF'], '', '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n";
}
}
+ if ($showuserlogin) {
+ print ''.$langs->trans("DolibarrLogin").' ';
+ }
// Extra fields
$extrafieldsobjectkey = $contactstatic->table_element;
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
@@ -1275,6 +1282,16 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
print ''.$contactstatic->getLibStatut(5).' ';
}
+ if ($showuserlogin) {
+ print '';
+ $tmpuser= new User($db);
+ $resfetch = $tmpuser->fetch(0, '', '', 0, -1, '', $contactstatic->id);
+ if ($resfetch > 0) {
+ print $tmpuser->getNomUrl(1, '', 0, 0, 24, 1);
+ }
+ print ' ';
+ }
+
// Extra fields
$extrafieldsobjectkey = $contactstatic->table_element;
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php
index 8e347a6d487..93540eb097c 100644
--- a/htdocs/societe/card.php
+++ b/htdocs/societe/card.php
@@ -3033,6 +3033,22 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print "\n";
}
+ // Link user (you must create a contact to get a user)
+ /*
+ print ''.$langs->trans("DolibarrLogin").' ';
+ if ($object->user_id) {
+ $dolibarr_user = new User($db);
+ $result = $dolibarr_user->fetch($object->user_id);
+ print $dolibarr_user->getLoginUrl(-1);
+ } else {
+ //print ''.$langs->trans("NoDolibarrAccess").' ';
+ if (!$object->user_id && $user->rights->user->user->creer) {
+ print ''.img_picto($langs->trans("CreateDolibarrLogin"), 'add').' '.$langs->trans("CreateDolibarrLogin").' ';
+ }
+ }
+ print ' ';
+ */
+
// Webservices url/key
if (!empty($conf->syncsupplierwebservices->enabled)) {
print ''.$langs->trans("WebServiceURL").' '.dol_print_url($object->webservices_url).' ';
diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php
index a09c9751f1f..4ecfc2a8cf4 100644
--- a/htdocs/societe/contact.php
+++ b/htdocs/societe/contact.php
@@ -173,7 +173,7 @@ print ' ';
if ($action != 'presend') {
// Contacts list
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
- $result = show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
+ $result = show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1);
}
}
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index ee6d0e7bd14..588dba10a19 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -416,9 +416,10 @@ class User extends CommonObject
* @param int $loadpersonalconf 1=also load personal conf of user (in $user->conf->xxx), 0=do not load personal conf.
* @param int $entity If a value is >= 0, we force the search on a specific entity. If -1, means search depens on default setup.
* @param int $email If defined, email to used for search
+ * @param int $fk_socpeople If defined, id of contact for search
* @return int <0 if KO, 0 not found, >0 if OK
*/
- public function fetch($id = '', $login = '', $sid = '', $loadpersonalconf = 0, $entity = -1, $email = '')
+ public function fetch($id = '', $login = '', $sid = '', $loadpersonalconf = 0, $entity = -1, $email = '', $fk_socpeople = 0)
{
global $conf, $user;
@@ -486,6 +487,8 @@ class User extends CommonObject
$sql .= " AND u.login = '".$this->db->escape($login)."'";
} elseif ($email) {
$sql .= " AND u.email = '".$this->db->escape($email)."'";
+ } elseif ($fk_socpeople > 0) {
+ $sql .= " AND u.fk_socpeople = ".((int) $fk_socpeople);
} else {
$sql .= " AND u.rowid = ".((int) $id);
}
@@ -2755,10 +2758,10 @@ class User extends CommonObject
if (empty($hidethirdpartylogo)) {
$companylink = ' '.$thirdpartystatic->getNomUrl(2, (($option == 'nolink') ? 'nolink' : '')); // picto only of company
}
- $company = ' ('.$langs->trans("Company").': '.dol_string_nohtmltag($thirdpartystatic->name).')';
+ $company = ' ('.$langs->trans("Company").': '.img_picto('', 'company').' '.dol_string_nohtmltag($thirdpartystatic->name).')';
}
- $type = ($this->socid ? $langs->trans("External").$company : $langs->trans("Internal"));
- $label .= ''.$langs->trans("Type").': '.dol_string_nohtmltag($type);
+ $type = ($this->socid ? $langs->trans("ExternalUser").$company : $langs->trans("InternalUser"));
+ $label .= ''.$langs->trans("Type").': '.$type;
$label .= '';
if ($infologin > 0) {
$label .= ' ';
diff --git a/htdocs/user/home.php b/htdocs/user/home.php
index c8dbdf2c1b8..a8b8bb92086 100644
--- a/htdocs/user/home.php
+++ b/htdocs/user/home.php
@@ -163,7 +163,7 @@ if ($resql) {
$companystatic->canvas = $obj->canvas;
$lastcreatedbox .= '';
- $lastcreatedbox .= '';
+ $lastcreatedbox .= ' ';
$lastcreatedbox .= $fuserstatic->getNomUrl(-1);
if (!empty($conf->multicompany->enabled) && $obj->admin && !$obj->entity) {
$lastcreatedbox .= img_picto($langs->trans("SuperAdministrator"), 'redstar');
@@ -171,17 +171,16 @@ if ($resql) {
$lastcreatedbox .= img_picto($langs->trans("Administrator"), 'star');
}
$lastcreatedbox .= " ";
- $lastcreatedbox .= ''.$obj->login.' ';
- $lastcreatedbox .= "";
+ $lastcreatedbox .= ' '.dol_escape_htmltag($obj->login).' ';
+ $texttoshow = '';
if ($obj->fk_soc) {
- $lastcreatedbox .= $companystatic->getNomUrl(1);
+ $texttoshow .= $companystatic->getNomUrl(1);
} else {
- $lastcreatedbox .= $langs->trans("InternalUser");
+ $texttoshow .= ''.$langs->trans("InternalUser").' ';
}
if ($obj->ldap_sid) {
- $lastcreatedbox .= ' ('.$langs->trans("DomainUser").')';
+ $texttoshow .= ' ('.$langs->trans("DomainUser").') ';
}
-
$entity = $obj->entity;
$entitystring = '';
// TODO Set of entitystring should be done with a hook
@@ -193,8 +192,9 @@ if ($resql) {
$entitystring = $mc->label;
}
}
- $lastcreatedbox .= ($entitystring ? ' ('.$entitystring.')' : '');
-
+ $texttoshow .= ($entitystring ? ' ('.$entitystring.') ' : '');
+ $lastcreatedbox .= '';
+ $lastcreatedbox .= $texttoshow;
$lastcreatedbox .= ' ';
$lastcreatedbox .= ''.dol_print_date($db->jdate($obj->datec), 'dayhour').' ';
$lastcreatedbox .= '';