';
print '';
if ($obj->rowid == 0)
{
- //$langs->load("companies");
- //print ' ';
print ' ';
}
else
@@ -575,8 +620,14 @@ class FormCompany
}
else
{
- $javaScript = "window.location='".$_SERVER['PHP_SELF']."?".$var_id."=".($forceid>0?$forceid:$object->id)."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;";
- print '';
+ // No Ajax search
+ print 'use_javascript_ajax)
+ {
+ $javaScript = "window.location='".$_SERVER['PHP_SELF']."?".$var_id."=".($forceid>0?$forceid:$object->id).$moreparam."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;";
+ print ' onChange="'.$javaScript.'"';
+ }
+ print '>';
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php
index cc5ca841c52..aee2ff5dff6 100644
--- a/htdocs/core/lib/ajax.lib.php
+++ b/htdocs/core/lib/ajax.lib.php
@@ -25,7 +25,8 @@
/**
- * Get value of an HTML field, do Ajax process and show result
+ * Get value of an HTML field, do Ajax process and show result.
+ * The HTML field must be an input text with id=search_$htmlname.
*
* @param string $selected Preselecte value
* @param string $htmlname HTML name of input field
@@ -54,11 +55,12 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
$("#'.$htmlname.'").val("");
});
$("input#search_'.$htmlname.'").change(function() {
- //console.log(\'keyup\');
+ //console.log(\'change\');
$("#'.$htmlname.'").trigger("change");
});
// Check when keyup
$("input#search_'.$htmlname.'").onDelayedKeyup({ handler: function() {
+ //console.log(\'keyup\');
if ($(this).val().length == 0)
{
$("#search_'.$htmlname.'").val("");
@@ -120,9 +122,9 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
},
dataType: "json",
minLength: '.$minLength.',
- select: function( event, ui ) {
+ select: function( event, ui ) { // Function ran when new value is selected into javascript combo
//console.log(\'set value of id with \'+ui.item.id);
- $("#'.$htmlname.'").val(ui.item.id).trigger("change");
+ $("#'.$htmlname.'").val(ui.item.id).trigger("change"); // Select new value
// Disable an element
if (options.option_disabled) {
if (ui.item.disabled) {
@@ -162,6 +164,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
}
});
}
+ $("#search_'.$htmlname.'").trigger("change"); // To tell that input text field was modified
}
}).data( "autocomplete" )._renderItem = function( ul, item ) {
return $( " " )
@@ -169,6 +172,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
.append( \'\' + item.label + " " )
.appendTo(ul);
};
+
});';
$script.= '';
@@ -293,14 +297,16 @@ function ajax_dialog($title,$message,$w=350,$h=150)
}
/**
- * Convert a html select field into an ajax combobox
+ * Convert a html select field into an ajax combobox.
+ * Use ajax_combobox() only for small combo list! If not, use instead ajax_autocompleter().
+ * TODO: It is used when COMPANY_USE_SEARCH_TO_SELECT and CONTACT_USE_SEARCH_TO_SELECT are set by html.formcompany.class.php. Should use ajax_autocompleter instead like done by html.form.class.php for select_produits.
*
- * @param string $htmlname Name of html select field
- * @param array $event Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
- * @param int $minLengthToAutocomplete Minimum length of input string to start autocomplete
- * @return string Return html string to convert a select field into a combo
+ * @param string $htmlname Name of html select field
+ * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
+ * @param int $minLengthToAutocomplete Minimum length of input string to start autocomplete
+ * @return string Return html string to convert a select field into a combo
*/
-function ajax_combobox($htmlname, $event=array(), $minLengthToAutocomplete=0)
+function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0)
{
global $conf;
@@ -326,7 +332,7 @@ function ajax_combobox($htmlname, $event=array(), $minLengthToAutocomplete=0)
$("#'.$htmlname.'").combobox({
minLengthToAutocomplete : '.$minLengthToAutocomplete.',
selected : function(event,ui) {
- var obj = '.json_encode($event).';
+ var obj = '.json_encode($events).';
$.each(obj, function(key,values) {
if (values.method.length) {
getMethod(values);
diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php
index c2c2ef9a452..35849720e7d 100644
--- a/htdocs/core/tpl/contacts.tpl.php
+++ b/htdocs/core/tpl/contacts.tpl.php
@@ -17,6 +17,7 @@
*
* This template needs:
* $object
+ * $withproject (if we are on task contact)
*/
if (! class_exists('Contact')) {
@@ -34,6 +35,9 @@ elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer
elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; }
elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer; }
elseif ($module == 'project') { $permission=$user->rights->projet->creer; }
+elseif ($module == 'action') { $permission=$user->rights->agenda->myactions->create; }
+elseif ($module == 'shipping') { $permission=$user->rights->expedition->creer; }
+elseif ($module == 'project_task') { $permission=$user->rights->projet->creer; }
elseif (! isset($permission)) { $permission=$user->rights->$module->creer; } // If already defined by caller page
$formcompany= new FormCompany($db);
@@ -64,6 +68,7 @@ $userstatic=new User($db);
+ '; ?>
trans("Users"); ?>
global->MAIN_INFO_SOCIETE_NOM; ?>
select_dolusers($user->id, 'userid', 0, (! empty($userAlreadySelected)?$userAlreadySelected:null), 0, null, null, 0, 56); ?>
@@ -79,29 +84,24 @@ $userstatic=new User($db);
+ '; ?>
trans("ThirdPartyContacts"); ?>
- use_javascript_ajax && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) { ?>
+ 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
+ ?>
- 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
- print $form->select_company($object->socid,'socid','',1,0,0,$events);
- ?>
-
-
- select_contacts($object->socid, '', 'contactid'); ?>
-
-
-
socid; ?>
- selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany'); ?>
+ selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', '', 0, $events); ?>
select_contacts($selectedCompany, '', 'contactid'); ?>
-
- selectTypeContact($object, '', 'type','external'); ?>
+ element == 'shipping' && is_object($objectsrc)) $tmpobject=$objectsrc;
+ $formcompany->selectTypeContact($tmpobject, '', 'type','external'); ?>
@@ -124,7 +124,11 @@ $userstatic=new User($db);
liste_contact(-1,$source);
+
+ $tmpobject=$object;
+ if ($object->element == 'shipping' && is_object($objectsrc)) $tmpobject=$objectsrc;
+
+ $tab = $tmpobject->liste_contact(-1,$source);
$num=count($tab);
$i = 0;
diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php
index ef5faa79e3b..6cfd835925d 100644
--- a/htdocs/expedition/contact.php
+++ b/htdocs/expedition/contact.php
@@ -106,9 +106,9 @@ else if ($action == 'swapstatut' && $user->rights->expedition->creer)
}
// Efface un contact
-else if ($action == 'deleteline' && $user->rights->expedition->creer)
+else if ($action == 'deletecontact' && $user->rights->expedition->creer)
{
- $result = $objectsrc->delete_contact($_GET["lineid"]);
+ $result = $objectsrc->delete_contact(GETPOST("lineid"));
if ($result >= 0)
{
@@ -233,186 +233,20 @@ if ($id > 0 || ! empty($ref))
print "