FIX Debug v16

This commit is contained in:
Laurent Destailleur
2022-07-18 11:51:28 +02:00
parent 311d69da4e
commit 076d93452f
7 changed files with 71 additions and 36 deletions

View File

@@ -1299,11 +1299,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$action = 'presend'; $action = 'presend';
} }
// View mode
if (!empty($id) && $action != 'edit' && $action != 'create') { if (!empty($id) && $action != 'edit' && $action != 'create') {
$objsoc = new Societe($db); $objsoc = new Societe($db);
// View mode
// Show errors // Show errors
dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors);
@@ -1528,9 +1527,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
if ($object->user_id) { if ($object->user_id) {
$dolibarr_user = new User($db); $dolibarr_user = new User($db);
$result = $dolibarr_user->fetch($object->user_id); $result = $dolibarr_user->fetch($object->user_id);
print $dolibarr_user->getLoginUrl(1); print $dolibarr_user->getLoginUrl(-1);
} else { } 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>'; 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>'; 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 // Activer
if ($object->statut == 0 && $user->rights->societe->contact->creer) { 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>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken().'">'.$langs->trans("Reactivate").'</a>';

View File

@@ -829,9 +829,10 @@ class FormCompany extends Form
* @param Contact $contact Contact Obejct * @param Contact $contact Contact Obejct
* @param string $rendermode view, edit * @param string $rendermode view, edit
* @param array $selected $key=>$val $val is selected Roles for input mode * @param array $selected $key=>$val $val is selected Roles for input mode
* @param string $morecss More css
* @return string String with contacts roles * @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') { if ($rendermode === 'view') {
$toprint = array(); $toprint = array();
@@ -856,7 +857,7 @@ class FormCompany extends Form
$selected = $newselected; $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 return 'ErrorBadValueForParameterRenderMode'; // Should not happened

View File

@@ -895,9 +895,10 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
* @param Societe $object Third party object * @param Societe $object Third party object
* @param string $backtopage Url to go once contact is created * @param string $backtopage Url to go once contact is created
* @param int $showuserlogin 1=Show also user login if it exists
* @return int * @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 $user, $conf, $extrafields, $hookmanager;
global $contextpage; global $contextpage;
@@ -1131,13 +1132,16 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
if (in_array($key, array('statut'))) { 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); 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'))) { } 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 { } else {
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.(!empty($search[$key]) ? dol_escape_htmltag($search[$key]) : '').'">'; print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.(!empty($search[$key]) ? dol_escape_htmltag($search[$key]) : '').'">';
} }
print '</td>'; print '</td>';
} }
} }
if ($showuserlogin) {
print '<td></td>';
}
// Extra fields // Extra fields
$extrafieldsobjectkey = $contactstatic->table_element; $extrafieldsobjectkey = $contactstatic->table_element;
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; 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"; 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 // Extra fields
$extrafieldsobjectkey = $contactstatic->table_element; $extrafieldsobjectkey = $contactstatic->table_element;
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; 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 '<td class="center">'.$contactstatic->getLibStatut(5).'</td>'; 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 // Extra fields
$extrafieldsobjectkey = $contactstatic->table_element; $extrafieldsobjectkey = $contactstatic->table_element;
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';

View File

@@ -3033,6 +3033,22 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print "</td></tr>\n"; 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 // Webservices url/key
if (!empty($conf->syncsupplierwebservices->enabled)) { if (!empty($conf->syncsupplierwebservices->enabled)) {
print '<tr><td>'.$langs->trans("WebServiceURL").'</td><td>'.dol_print_url($object->webservices_url).'</td>'; print '<tr><td>'.$langs->trans("WebServiceURL").'</td><td>'.dol_print_url($object->webservices_url).'</td>';

View File

@@ -173,7 +173,7 @@ print '<br>';
if ($action != 'presend') { if ($action != 'presend') {
// Contacts list // Contacts list
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { 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);
} }
} }

View File

@@ -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 $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 $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 $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 * @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; global $conf, $user;
@@ -486,6 +487,8 @@ class User extends CommonObject
$sql .= " AND u.login = '".$this->db->escape($login)."'"; $sql .= " AND u.login = '".$this->db->escape($login)."'";
} elseif ($email) { } elseif ($email) {
$sql .= " AND u.email = '".$this->db->escape($email)."'"; $sql .= " AND u.email = '".$this->db->escape($email)."'";
} elseif ($fk_socpeople > 0) {
$sql .= " AND u.fk_socpeople = ".((int) $fk_socpeople);
} else { } else {
$sql .= " AND u.rowid = ".((int) $id); $sql .= " AND u.rowid = ".((int) $id);
} }
@@ -2755,10 +2758,10 @@ class User extends CommonObject
if (empty($hidethirdpartylogo)) { if (empty($hidethirdpartylogo)) {
$companylink = ' '.$thirdpartystatic->getNomUrl(2, (($option == 'nolink') ? 'nolink' : '')); // picto only of company $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")); $type = ($this->socid ? $langs->trans("ExternalUser").$company : $langs->trans("InternalUser"));
$label .= '<br><b>'.$langs->trans("Type").':</b> '.dol_string_nohtmltag($type); $label .= '<br><b>'.$langs->trans("Type").':</b> '.$type;
$label .= '</div>'; $label .= '</div>';
if ($infologin > 0) { if ($infologin > 0) {
$label .= '<br>'; $label .= '<br>';

View File

@@ -163,7 +163,7 @@ if ($resql) {
$companystatic->canvas = $obj->canvas; $companystatic->canvas = $obj->canvas;
$lastcreatedbox .= '<tr class="oddeven">'; $lastcreatedbox .= '<tr class="oddeven">';
$lastcreatedbox .= '<td class="nowraponall">'; $lastcreatedbox .= '<td class="nowraponall tdoverflowmax150">';
$lastcreatedbox .= $fuserstatic->getNomUrl(-1); $lastcreatedbox .= $fuserstatic->getNomUrl(-1);
if (!empty($conf->multicompany->enabled) && $obj->admin && !$obj->entity) { if (!empty($conf->multicompany->enabled) && $obj->admin && !$obj->entity) {
$lastcreatedbox .= img_picto($langs->trans("SuperAdministrator"), 'redstar'); $lastcreatedbox .= img_picto($langs->trans("SuperAdministrator"), 'redstar');
@@ -171,17 +171,16 @@ if ($resql) {
$lastcreatedbox .= img_picto($langs->trans("Administrator"), 'star'); $lastcreatedbox .= img_picto($langs->trans("Administrator"), 'star');
} }
$lastcreatedbox .= "</td>"; $lastcreatedbox .= "</td>";
$lastcreatedbox .= '<td>'.$obj->login.'</td>'; $lastcreatedbox .= '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->login).'">'.dol_escape_htmltag($obj->login).'</td>';
$lastcreatedbox .= "<td>"; $texttoshow = '';
if ($obj->fk_soc) { if ($obj->fk_soc) {
$lastcreatedbox .= $companystatic->getNomUrl(1); $texttoshow .= $companystatic->getNomUrl(1);
} else { } else {
$lastcreatedbox .= $langs->trans("InternalUser"); $texttoshow .= '<span class="opacitymedium">'.$langs->trans("InternalUser").'</span>';
} }
if ($obj->ldap_sid) { if ($obj->ldap_sid) {
$lastcreatedbox .= ' ('.$langs->trans("DomainUser").')'; $texttoshow .= ' <span class="opacitymedium">('.$langs->trans("DomainUser").')</span>';
} }
$entity = $obj->entity; $entity = $obj->entity;
$entitystring = ''; $entitystring = '';
// TODO Set of entitystring should be done with a hook // TODO Set of entitystring should be done with a hook
@@ -193,8 +192,9 @@ if ($resql) {
$entitystring = $mc->label; $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>';
$lastcreatedbox .= '<td class="center nowrap">'.dol_print_date($db->jdate($obj->datec), 'dayhour').'</td>'; $lastcreatedbox .= '<td class="center nowrap">'.dol_print_date($db->jdate($obj->datec), 'dayhour').'</td>';
$lastcreatedbox .= '<td class="right">'; $lastcreatedbox .= '<td class="right">';