let only triggers part

This commit is contained in:
florian HENRY
2019-09-02 22:01:48 +02:00
parent 405c92640c
commit d811de4da2
6 changed files with 179 additions and 28 deletions

View File

@@ -6484,6 +6484,46 @@ class Form
return 'ErrorBadValueForParameterRenderMode'; // Should not happened
}
/**
* 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
*/
public function showRoles($htmlname = '', Contact $contact, $rendermode = 'view', $selected = array())
{
if ($rendermode === 'view') {
$toprint = array();
foreach ($contact->roles as $key => $val) {
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa;">' . $val['label'] . '</li>';
}
return '<div class="select2-container-multi-dolibarr" style="width: 90%;" id="'.$htmlname.'"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
}
if ($rendermode === 'edit')
{
$contactType=$contact->listeTypeContacts('external', '', 1);
if (count($selected)>0) {
$newselected=array();
foreach($selected as $key=>$val) {
if (is_array($val) && array_key_exists('id', $val) && in_array($val['id'], array_keys($contactType))) {
$newselected[]=$val['id'];
} else {
break;
}
}
if (count($newselected)>0) $selected=$newselected;
}
return $this->multiselectarray($htmlname, $contactType, $selected);
}
return 'ErrorBadValueForParameterRenderMode'; // Should not happened
}
/**
* Show linked object block.