Fix selection of contact into creation of event

This commit is contained in:
Laurent Destailleur 2017-11-12 13:40:05 +01:00
parent 836f6bf3c9
commit 186c8cdbf0
5 changed files with 15 additions and 8 deletions

View File

@ -771,9 +771,9 @@ if ($action == 'create')
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
//For external user force the company to user company
if (!empty($user->societe_id)) {
print $form->select_company($user->societe_id, 'socid', '', 1, 1, 0, $events);
print $form->select_company($user->societe_id, 'socid', '', 1, 1, 0, $events, 0, 'minwidth300');
} else {
print $form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, $events);
print $form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, $events, 0, 'minwidth300');
}
}
@ -781,7 +781,7 @@ if ($action == 'create')
// Related contact
print '<tr><td class="nowrap">'.$langs->trans("ActionOnContact").'</td><td>';
$form->selectcontacts(GETPOST('socid','int'), GETPOST('contactid'), 'contactid', 1, '', '', 0, 'minwidth200');
print $form->selectcontacts(GETPOST('socid','int'), GETPOST('contactid'), 'contactid', 1, '', '', 0, 'minwidth300');
print '</td></tr>';

View File

@ -1331,7 +1331,7 @@ class Form
}
if ($htmlname != 'none' || $options_only) $out.= '<select class="flat'.($moreclass?' '.$moreclass:'').'" id="'.$htmlname.'" name="'.$htmlname.'">';
if ($showempty == 1) $out.= '<option value="0"'.($selected=='0'?' selected':'').'></option>';
if ($showempty == 1) $out.= '<option value="0"'.($selected=='0'?' selected':'').'>&nbsp;</option>';
if ($showempty == 2) $out.= '<option value="0"'.($selected=='0'?' selected':'').'>'.$langs->trans("Internal").'</option>';
$num = $this->db->num_rows($resql);
$i = 0;

View File

@ -582,7 +582,6 @@ class FormCompany
print '<script type="text/javascript">
jQuery(document).ready(function() {
$("#search_'.$htmlname.'").change(function() {
console.log("Call runJsCodeForEvent'.$htmlname.'");
var obj = '.json_encode($events).';
$.each(obj, function(key,values) {
if (values.method.length) {
@ -599,6 +598,7 @@ class FormCompany
var method = obj.method;
var url = obj.url;
var htmlname = obj.htmlname;
console.log("Run runJsCodeForEvent-'.$htmlname.' from selectCompaniesForNewContact id="+id+" method="+method+" showempty="+showempty+" url="+url+" htmlname="+htmlname);
$.getJSON(url,
{
action: method,
@ -608,6 +608,7 @@ class FormCompany
function(response) {
if (response != null)
{
console.log("Change select#"+htmlname+" with content "+response.value)
$.each(obj.params, function(key,action) {
if (key.length) {
var num = response.num;
@ -618,7 +619,6 @@ class FormCompany
}
}
});
/* console.log("Change select#"+htmlname+" with content "+response.value) */
$("select#" + htmlname).html(response.value);
}
}

View File

@ -443,13 +443,13 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $
});
function runJsCodeForEvent'.$htmlname.'(obj) {
console.log("Run runJsCodeForEvent'.$htmlname.'");
var id = $("#'.$htmlname.'").val();
var method = obj.method;
var url = obj.url;
var htmlname = obj.htmlname;
var showempty = obj.showempty;
$.getJSON(url,
console.log("Run runJsCodeForEvent-'.$htmlname.' from ajax_combobox id="+id+" method="+method+" showempty="+showempty+" url="+url+" htmlname="+htmlname);
$.getJSON(url,
{
action: method,
id: id,

View File

@ -2160,6 +2160,13 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete')
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
$MAXEVENT = 10;
// List of actions on element
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
$formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'product', 0, 1, '', $MAXEVENT);
print '</div></div></div>';
}