浏览代码

FIX Debug v16

Laurent Destailleur 2 年之前
父节点
当前提交
8edebcf314

+ 6 - 8
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 '<span class="opacitymedium">'.$langs->trans("NoDolibarrAccess").'</span>';
+			if (!$object->user_id && $user->rights->user->user->creer) {
+				print '<a class="aaa" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=create_user&token='.newToken().'">'.img_picto($langs->trans("CreateDolibarrLogin"), 'add').' '.$langs->trans("CreateDolibarrLogin").'</a>';
+			}
 		}
 		print '</td></tr>';
 
@@ -1563,10 +1565,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 				print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit&token='.newToken().'">'.$langs->trans('Modify').'</a>';
 			}
 
-			if (!$object->user_id && $user->rights->user->user->creer) {
-				print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=create_user&token='.newToken().'">'.$langs->trans("CreateDolibarrLogin").'</a>';
-			}
-
 			// Activer
 			if ($object->statut == 0 && $user->rights->societe->contact->creer) {
 				print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken().'">'.$langs->trans("Reactivate").'</a>';

+ 8 - 7
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

+ 24 - 7
htdocs/core/lib/company.lib.php

@@ -896,14 +896,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;
@@ -1137,13 +1138,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 '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.(!empty($search[$key]) ? dol_escape_htmltag($search[$key]) : '').'">';
 			}
 			print '</td>';
 		}
 	}
+	if ($showuserlogin) {
+		print '<td></td>';
+	}
 	// Extra fields
 	$extrafieldsobjectkey = $contactstatic->table_element;
 	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
@@ -1183,6 +1187,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 '<td>'.$langs->trans("DolibarrLogin").'</td>';
+	}
 	// Extra fields
 	$extrafieldsobjectkey = $contactstatic->table_element;
 	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
@@ -1281,6 +1288,16 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
 				print '<td class="center">'.$contactstatic->getLibStatut(5).'</td>';
 			}
 
+			if ($showuserlogin) {
+				print '<td>';
+				$tmpuser= new User($db);
+				$resfetch = $tmpuser->fetch(0, '', '', 0, -1, '', $contactstatic->id);
+				if ($resfetch > 0) {
+					print $tmpuser->getNomUrl(1, '', 0, 0, 24, 1);
+				}
+				print '</td>';
+			}
+
 			// Extra fields
 			$extrafieldsobjectkey = $contactstatic->table_element;
 			include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';

+ 16 - 0
htdocs/societe/card.php

@@ -3033,6 +3033,22 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 			print "</td></tr>\n";
 		}
 
+		// Link user (you must create a contact to get a user)
+		/*
+		print '<tr><td>'.$langs->trans("DolibarrLogin").'</td><td colspan="3">';
+		if ($object->user_id) {
+			$dolibarr_user = new User($db);
+			$result = $dolibarr_user->fetch($object->user_id);
+			print $dolibarr_user->getLoginUrl(-1);
+		} else {
+			//print '<span class="opacitymedium">'.$langs->trans("NoDolibarrAccess").'</span>';
+			if (!$object->user_id && $user->rights->user->user->creer) {
+				print '<a class="aaa" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=create_user&token='.newToken().'">'.img_picto($langs->trans("CreateDolibarrLogin"), 'add').' '.$langs->trans("CreateDolibarrLogin").'</a>';
+			}
+		}
+		print '</td></tr>';
+		*/
+
 		// Webservices url/key
 		if (!empty($conf->syncsupplierwebservices->enabled)) {
 			print '<tr><td>'.$langs->trans("WebServiceURL").'</td><td>'.dol_print_url($object->webservices_url).'</td>';

+ 1 - 1
htdocs/societe/contact.php

@@ -173,7 +173,7 @@ print '<br>';
 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);
 	}
 }
 

+ 7 - 4
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);
 		}
@@ -2751,10 +2754,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 .= '<br><b>'.$langs->trans("Type").':</b> '.dol_string_nohtmltag($type);
+		$type = ($this->socid ? $langs->trans("ExternalUser").$company : $langs->trans("InternalUser"));
+		$label .= '<br><b>'.$langs->trans("Type").':</b> '.$type;
 		$label .= '</div>';
 		if ($infologin > 0) {
 			$label .= '<br>';

+ 9 - 9
htdocs/user/home.php

@@ -163,7 +163,7 @@ if ($resql) {
 		$companystatic->canvas = $obj->canvas;
 
 		$lastcreatedbox .= '<tr class="oddeven">';
-		$lastcreatedbox .= '<td class="nowraponall">';
+		$lastcreatedbox .= '<td class="nowraponall tdoverflowmax150">';
 		$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 .= "</td>";
-		$lastcreatedbox .= '<td>'.$obj->login.'</td>';
-		$lastcreatedbox .= "<td>";
+		$lastcreatedbox .= '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->login).'">'.dol_escape_htmltag($obj->login).'</td>';
+		$texttoshow = '';
 		if ($obj->fk_soc) {
-			$lastcreatedbox .= $companystatic->getNomUrl(1);
+			$texttoshow .= $companystatic->getNomUrl(1);
 		} else {
-			$lastcreatedbox .= $langs->trans("InternalUser");
+			$texttoshow .= '<span class="opacitymedium">'.$langs->trans("InternalUser").'</span>';
 		}
 		if ($obj->ldap_sid) {
-			$lastcreatedbox .= ' ('.$langs->trans("DomainUser").')';
+			$texttoshow .= ' <span class="opacitymedium">('.$langs->trans("DomainUser").')</span>';
 		}
-
 		$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 ? ' <span class="opacitymedium">('.$entitystring.')</span>' : '');
+		$lastcreatedbox .= '<td class="tdoverflowmax150" title="'.dol_escape_htmltag(dol_string_nohtmltag($texttoshow)).'">';
+		$lastcreatedbox .= $texttoshow;
 		$lastcreatedbox .= '</td>';
 		$lastcreatedbox .= '<td class="center nowrap">'.dol_print_date($db->jdate($obj->datec), 'dayhour').'</td>';
 		$lastcreatedbox .= '<td class="right">';