Start to work on new generation combo box.
This commit is contained in:
parent
168e97e6ee
commit
ceba894d57
@ -1151,6 +1151,7 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
@ -1236,12 +1237,13 @@ if ($action == 'create')
|
|||||||
print '<form name="addprop" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
|
print '<form name="addprop" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
|
||||||
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
|
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
|
||||||
print '<input type="hidden" name="action" value="add">';
|
print '<input type="hidden" name="action" value="add">';
|
||||||
|
|
||||||
if ($origin != 'project' && $originid) {
|
if ($origin != 'project' && $originid) {
|
||||||
print '<input type="hidden" name="origin" value="' . $origin . '">';
|
print '<input type="hidden" name="origin" value="' . $origin . '">';
|
||||||
print '<input type="hidden" name="originid" value="' . $originid . '">';
|
print '<input type="hidden" name="originid" value="' . $originid . '">';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dol_fiche_head();
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Reference
|
// Reference
|
||||||
@ -1435,16 +1437,13 @@ if ($action == 'create')
|
|||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
|
|
||||||
|
|
||||||
print '<br>';
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Combobox pour la fonction de copie
|
* Combobox pour la fonction de copie
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) print '<input type="hidden" name="createmode" value="empty">';
|
if (empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) print '<input type="hidden" name="createmode" value="empty">';
|
||||||
|
|
||||||
if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE) || ! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) print '<table>';
|
if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE) || ! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) print '<br><table>';
|
||||||
if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE))
|
if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE))
|
||||||
{
|
{
|
||||||
// For backward compatibility
|
// For backward compatibility
|
||||||
@ -1514,9 +1513,10 @@ if ($action == 'create')
|
|||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE) || ! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) print '</table><br>';
|
if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE) || ! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) print '</table>';
|
||||||
|
|
||||||
|
|
||||||
|
dol_fiche_end();
|
||||||
|
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
print '<div class="center">';
|
print '<div class="center">';
|
||||||
print '<input type="submit" class="button" value="' . $langs->trans("CreateDraft") . '">';
|
print '<input type="submit" class="button" value="' . $langs->trans("CreateDraft") . '">';
|
||||||
|
|||||||
@ -432,6 +432,9 @@ class Conf
|
|||||||
// Define list of limited modules
|
// Define list of limited modules
|
||||||
if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,facture,categorie,commande,fournisseur,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda,adherent'; // '' means 'all'. Note that contact is added here as it should be a module later.
|
if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,facture,categorie,commande,fournisseur,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda,adherent'; // '' means 'all'. Note that contact is added here as it should be a module later.
|
||||||
|
|
||||||
|
// Enable select2
|
||||||
|
if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)) $conf->global->MAIN_USE_JQUERY_MULTISELECT='select2';
|
||||||
|
|
||||||
// Timeouts
|
// Timeouts
|
||||||
if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT=10;
|
if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT=10;
|
||||||
if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) $this->global->MAIN_USE_RESPONSE_TIMEOUT=30;
|
if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) $this->global->MAIN_USE_RESPONSE_TIMEOUT=30;
|
||||||
|
|||||||
@ -825,9 +825,22 @@ class Form
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (! $forcecombo)
|
||||||
|
{
|
||||||
|
$out.='
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function () {
|
||||||
|
$(\'#'.$htmlname.'\').select2({
|
||||||
|
width: \'resolve\',
|
||||||
|
minimumInputLength: 0,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>';
|
||||||
|
}
|
||||||
|
|
||||||
if (count($events)) // Add management of event
|
if (count($events)) // Add management of event
|
||||||
{
|
{
|
||||||
print '<script type="text/javascript">
|
$out.='<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
jQuery("#'.$htmlname.'").change(function () {
|
jQuery("#'.$htmlname.'").change(function () {
|
||||||
var obj = '.json_encode($events).';
|
var obj = '.json_encode($events).';
|
||||||
@ -1077,7 +1090,7 @@ class Form
|
|||||||
{
|
{
|
||||||
$num=$this->db->num_rows($resql);
|
$num=$this->db->num_rows($resql);
|
||||||
|
|
||||||
if ($conf->use_javascript_ajax && $conf->global->CONTACT_USE_SEARCH_TO_SELECT && ! $forcecombo && ! $options_only)
|
if ($conf->use_javascript_ajax && ! $forcecombo && ! $options_only)
|
||||||
{
|
{
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
||||||
$out.= ajax_combobox($htmlname, $events, $conf->global->CONTACT_USE_SEARCH_TO_SELECT);
|
$out.= ajax_combobox($htmlname, $events, $conf->global->CONTACT_USE_SEARCH_TO_SELECT);
|
||||||
@ -1338,10 +1351,20 @@ class Form
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$out.= '<select class="flat" name="'.$htmlname.'" disabled="disabled">';
|
$out.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'" disabled="disabled">';
|
||||||
$out.= '<option value="">'.$langs->trans("None").'</option>';
|
$out.= '<option value="">'.$langs->trans("None").'</option>';
|
||||||
}
|
}
|
||||||
$out.= '</select>';
|
$out.= '</select>';
|
||||||
|
|
||||||
|
$out.= '<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
$(\'#'.$htmlname.'\').select2({
|
||||||
|
width: \'resolve\',
|
||||||
|
minimumInputLength: 0
|
||||||
|
});
|
||||||
|
})
|
||||||
|
</script>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -4119,10 +4142,11 @@ class Form
|
|||||||
* @param int $disabled Html select box is disabled
|
* @param int $disabled Html select box is disabled
|
||||||
* @param int $sort 'ASC' or 'DESC' = Sort on label, '' or 'NONE' = Do not sort
|
* @param int $sort 'ASC' or 'DESC' = Sort on label, '' or 'NONE' = Do not sort
|
||||||
* @param string $morecss Add more class to css styles
|
* @param string $morecss Add more class to css styles
|
||||||
|
* @param int $addjscombo Add js combo
|
||||||
* @return string HTML select string.
|
* @return string HTML select string.
|
||||||
* @see multiselectarray
|
* @see multiselectarray
|
||||||
*/
|
*/
|
||||||
static function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='')
|
static function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='', $addjscombo=0)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
@ -4131,13 +4155,15 @@ class Form
|
|||||||
$out='';
|
$out='';
|
||||||
|
|
||||||
// Add code for jquery to use multiselect
|
// Add code for jquery to use multiselect
|
||||||
if (empty($conf->dol_use_jmobile) && (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')))
|
if ($addjscombo && empty($conf->dol_use_jmobile) && (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')))
|
||||||
{
|
{
|
||||||
$tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT;
|
$tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT;
|
||||||
$out='<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
|
$out.='<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$(\'#'.$htmlname.'\').'.$tmpplugin.'({
|
$(\'#'.$htmlname.'\').'.$tmpplugin.'({
|
||||||
|
width: \'off\',
|
||||||
|
minimumInputLength: 0
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>';
|
</script>';
|
||||||
|
|||||||
@ -520,118 +520,105 @@ class FormCompany
|
|||||||
* @param string $htmlname Name of HTML form
|
* @param string $htmlname Name of HTML form
|
||||||
* @param array $limitto Disable answers that are not id in this array list
|
* @param array $limitto Disable answers that are not id in this array list
|
||||||
* @param int $forceid This is to force another object id than object->id
|
* @param int $forceid This is to force another object id than object->id
|
||||||
* @param array $events More js events option. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
|
|
||||||
* @param string $moreparam String with more param to add into url when noajax search is used.
|
* @param string $moreparam String with more param to add into url when noajax search is used.
|
||||||
* @return int The selected third party ID
|
* @return int The selected third party ID
|
||||||
*/
|
*/
|
||||||
function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname='newcompany', $limitto='', $forceid=0, $events=array(), $moreparam='')
|
function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname='newcompany', $limitto='', $forceid=0, $moreparam='')
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
// On recherche les societes
|
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT))
|
||||||
$sql = "SELECT s.rowid, s.nom as name FROM";
|
{
|
||||||
$sql.= " ".MAIN_DB_PREFIX."societe as s";
|
// Use Ajax search
|
||||||
$sql.= " WHERE s.entity IN (".getEntity('societe', 1).")";
|
$minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2);
|
||||||
if ($selected && $conf->use_javascript_ajax && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) $sql.= " AND s.rowid = ".$selected;
|
|
||||||
|
$socid=0; $name='';
|
||||||
|
if ($selected > 0)
|
||||||
|
{
|
||||||
|
$tmpthirdparty=new Societe($this->db);
|
||||||
|
$result = $tmpthirdparty->fetch($selected);
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
$socid = $selected;
|
||||||
|
$name = $tmpthirdparty->name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh contacts list on thirdparty list change
|
||||||
|
$htmloption='';
|
||||||
|
|
||||||
|
$events=array();
|
||||||
|
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
|
||||||
|
if (count($events)) // If there is some ajax events to run once selection is done, we add code here to run events
|
||||||
|
{
|
||||||
|
print '<script type="text/javascript">
|
||||||
|
jQuery(document).ready(function() {
|
||||||
|
$("#search_'.$htmlname.'").change(function() {
|
||||||
|
var obj = '.json_encode($events).';
|
||||||
|
$.each(obj, function(key,values) {
|
||||||
|
if (values.method.length) {
|
||||||
|
runJsCodeForEvent'.$htmlname.'(values);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
/* Clean contact */
|
||||||
|
$("div#s2id_contactid>a>span").html(\'\');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Function used to execute events when search_htmlname change
|
||||||
|
function runJsCodeForEvent'.$htmlname.'(obj) {
|
||||||
|
var id = $("#'.$htmlname.'").val();
|
||||||
|
var method = obj.method;
|
||||||
|
var url = obj.url;
|
||||||
|
var htmlname = obj.htmlname;
|
||||||
|
$.getJSON(url,
|
||||||
|
{
|
||||||
|
action: method,
|
||||||
|
id: id,
|
||||||
|
htmlname: htmlname
|
||||||
|
},
|
||||||
|
function(response) {
|
||||||
|
if (response != null)
|
||||||
|
{
|
||||||
|
$.each(obj.params, function(key,action) {
|
||||||
|
if (key.length) {
|
||||||
|
var num = response.num;
|
||||||
|
if (num > 0) {
|
||||||
|
$("#" + key).removeAttr(action);
|
||||||
|
} else {
|
||||||
|
$("#" + key).attr(action, action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$("select#" + htmlname).html(response.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
</script>';
|
||||||
|
}
|
||||||
|
|
||||||
|
print "\n".'<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->'."\n";
|
||||||
|
print '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="'.$name.'" '.$htmloption.' />';
|
||||||
|
print ajax_autocompleter(($socid?$socid:-1),$htmlname,DOL_URL_ROOT.'/societe/ajaxcompanies.php','',$minLength);
|
||||||
|
return $socid;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Search to list thirdparties
|
||||||
|
$sql = "SELECT s.rowid, s.nom as name FROM";
|
||||||
|
$sql.= " ".MAIN_DB_PREFIX."societe as s";
|
||||||
|
$sql.= " WHERE s.entity IN (".getEntity('societe', 1).")";
|
||||||
// For ajax search we limit here. For combo list, we limit later
|
// For ajax search we limit here. For combo list, we limit later
|
||||||
if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT
|
if (is_array($limitto) && count($limitto))
|
||||||
&& is_array($limitto) && count($limitto))
|
|
||||||
{
|
{
|
||||||
$sql.= " AND s.rowid IN (".join(',',$limitto).")";
|
$sql.= " AND s.rowid IN (".join(',',$limitto).")";
|
||||||
}
|
}
|
||||||
}
|
$sql.= " ORDER BY s.nom ASC";
|
||||||
$sql.= " ORDER BY s.nom ASC";
|
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
|
||||||
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT))
|
|
||||||
{
|
{
|
||||||
// Use Ajax search
|
|
||||||
$minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2);
|
|
||||||
|
|
||||||
$socid=0;
|
|
||||||
if ($selected)
|
|
||||||
{
|
|
||||||
$obj = $this->db->fetch_object($resql);
|
|
||||||
$socid = $obj->rowid?$obj->rowid:'';
|
|
||||||
}
|
|
||||||
|
|
||||||
// We recall a page after a small delay when a new input has been selected
|
|
||||||
$htmloption='';
|
|
||||||
//$javaScript = "window.location=\'".$_SERVER['PHP_SELF']."?".$var_id."=".($forceid>0?$forceid:$object->id)."&".$htmlname."=\' + document.getElementById(\'".$htmlname."\').value;";
|
|
||||||
//$htmloption.= 'onChange="ac_delay(\''.$javaScript.'\',\'500\');"'; // When we select with mouse
|
|
||||||
//$htmloption.= 'onKeyUp="if (event.keyCode== 13) { ac_delay(\''.$javaScript.'\',\'500\'); }"'; // When we select with keyboard
|
|
||||||
|
|
||||||
if (count($events)) // If there is some ajax events to run once selection is done, we add code here to run events
|
|
||||||
{
|
|
||||||
print '<script type="text/javascript">
|
|
||||||
jQuery(document).ready(function() {
|
|
||||||
$("#search_'.$htmlname.'").change(function() {
|
|
||||||
var obj = '.json_encode($events).';
|
|
||||||
$.each(obj, function(key,values) {
|
|
||||||
if (values.method.length) {
|
|
||||||
runJsCodeForEvent'.$htmlname.'(values);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Function used to execute events when search_htmlname change
|
|
||||||
function runJsCodeForEvent'.$htmlname.'(obj) {
|
|
||||||
var id = $("#'.$htmlname.'").val();
|
|
||||||
var method = obj.method;
|
|
||||||
var url = obj.url;
|
|
||||||
var htmlname = obj.htmlname;
|
|
||||||
$.getJSON(url,
|
|
||||||
{
|
|
||||||
action: method,
|
|
||||||
id: id,
|
|
||||||
htmlname: htmlname
|
|
||||||
},
|
|
||||||
function(response) {
|
|
||||||
if (response != null)
|
|
||||||
{
|
|
||||||
$.each(obj.params, function(key,action) {
|
|
||||||
if (key.length) {
|
|
||||||
var num = response.num;
|
|
||||||
if (num > 0) {
|
|
||||||
$("#" + key).removeAttr(action);
|
|
||||||
} else {
|
|
||||||
$("#" + key).attr(action, action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$("select#" + htmlname).html(response.value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
});
|
|
||||||
</script>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print "\n".'<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->'."\n";
|
|
||||||
//print '<table class="nobordernopadding"><tr class="nobordernopadding">';
|
|
||||||
//print '<td class="nobordernopadding">';
|
|
||||||
if ($obj->rowid == 0)
|
|
||||||
{
|
|
||||||
print '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="" '.$htmloption.' />';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="'.$obj->name.'" '.$htmloption.' />';
|
|
||||||
}
|
|
||||||
print ajax_autocompleter(($socid?$socid:-1),$htmlname,DOL_URL_ROOT.'/societe/ajaxcompanies.php','',$minLength);
|
|
||||||
//print '</td>';
|
|
||||||
//print '</tr>';
|
|
||||||
//print '</table>';
|
|
||||||
//print "\n";
|
|
||||||
return $socid;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// No Ajax search
|
|
||||||
print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"';
|
print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"';
|
||||||
if ($conf->use_javascript_ajax)
|
if ($conf->use_javascript_ajax)
|
||||||
{
|
{
|
||||||
@ -668,10 +655,11 @@ class FormCompany
|
|||||||
print "</select>\n";
|
print "</select>\n";
|
||||||
return $firstCompany;
|
return $firstCompany;
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
dol_print_error($this->db);
|
||||||
dol_print_error($this->db);
|
print 'Error sql';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -323,34 +323,23 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0)
|
|||||||
if (! empty($conf->browser->phone)) return ''; // combobox disabled for smartphones (does not works)
|
if (! empty($conf->browser->phone)) return ''; // combobox disabled for smartphones (does not works)
|
||||||
if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return '';
|
if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return '';
|
||||||
|
|
||||||
/* Some properties for combobox:
|
|
||||||
minLengthToAutocomplete: 2,
|
|
||||||
comboboxContainerClass: "comboboxContainer",
|
|
||||||
comboboxValueContainerClass: "comboboxValueContainer",
|
|
||||||
comboboxValueContentClass: "comboboxValueContent",
|
|
||||||
comboboxDropDownClass: "comboboxDropDownContainer",
|
|
||||||
comboboxDropDownButtonClass: "comboboxDropDownButton",
|
|
||||||
comboboxDropDownItemClass: "comboboxItem",
|
|
||||||
comboboxDropDownItemHoverClass: "comboboxItemHover",
|
|
||||||
comboboxDropDownGroupItemHeaderClass: "comboboxGroupItemHeader",
|
|
||||||
comboboxDropDownGroupItemContainerClass: "comboboxGroupItemContainer",
|
|
||||||
animationType: "slide",
|
|
||||||
width: "500px" */
|
|
||||||
|
|
||||||
$msg = '<script type="text/javascript">
|
$msg = '<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#'.$htmlname.'").combobox({
|
|
||||||
minLengthToAutocomplete : '.$minLengthToAutocomplete.',
|
$(\'#'.$htmlname.'\').select2({
|
||||||
selected : function(event,ui) {
|
width: \'resolve\',
|
||||||
var obj = '.json_encode($events).';
|
minimumInputLength: '.$minLengthToAutocomplete.',
|
||||||
$.each(obj, function(key,values) {
|
});
|
||||||
|
jQuery("#'.$htmlname.'").change(function () {
|
||||||
|
var obj = '.json_encode($events).';
|
||||||
|
$.each(obj, function(key,values) {
|
||||||
if (values.method.length) {
|
if (values.method.length) {
|
||||||
runJsCodeForEvent'.$htmlname.'(values);
|
runJsCodeForEvent'.$htmlname.'(values);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function runJsCodeForEvent'.$htmlname.'(obj) {
|
function runJsCodeForEvent'.$htmlname.'(obj) {
|
||||||
var id = $("#'.$htmlname.'").val();
|
var id = $("#'.$htmlname.'").val();
|
||||||
var method = obj.method;
|
var method = obj.method;
|
||||||
|
|||||||
@ -20,12 +20,8 @@
|
|||||||
* $withproject (if we are on task contact)
|
* $withproject (if we are on task contact)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (! class_exists('Contact')) {
|
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||||
require DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||||
}
|
|
||||||
if (! class_exists('FormCompany')) {
|
|
||||||
require DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
$module = $object->element;
|
$module = $object->element;
|
||||||
|
|
||||||
@ -96,13 +92,9 @@ $userstatic=new User($db);
|
|||||||
<input type="hidden" name="source" value="external" />
|
<input type="hidden" name="source" value="external" />
|
||||||
<?php if ($withproject) print '<input type="hidden" name="withproject" value="'.$withproject.'">'; ?>
|
<?php if ($withproject) print '<input type="hidden" name="withproject" value="'.$withproject.'">'; ?>
|
||||||
<div class="tagtd nowrap"><?php echo img_object('','contact').' '.$langs->trans("ThirdPartyContacts"); ?></div>
|
<div class="tagtd nowrap"><?php echo img_object('','contact').' '.$langs->trans("ThirdPartyContacts"); ?></div>
|
||||||
<?php
|
|
||||||
$events=array();
|
|
||||||
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
|
|
||||||
?>
|
|
||||||
<div class="tagtd nowrap maxwidthonsmartphone">
|
<div class="tagtd nowrap maxwidthonsmartphone">
|
||||||
<?php $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$object->socid; ?>
|
<?php $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$object->socid; ?>
|
||||||
<?php $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', '', 0, $events); ?>
|
<?php $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', '', 0); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="tagtd maxwidthonsmartphone">
|
<div class="tagtd maxwidthonsmartphone">
|
||||||
<?php $nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid'); ?>
|
<?php $nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid'); ?>
|
||||||
|
|||||||
@ -1912,7 +1912,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
if (this.opts.width === "off") {
|
if (this.opts.width === "off") {
|
||||||
return null;
|
return null;
|
||||||
} else if (this.opts.width === "element"){
|
} else if (this.opts.width === "element"){
|
||||||
return this.opts.element.outerWidth(false) === 0 ? 'auto' : this.opts.element.outerWidth(false) + 'px';
|
return this.opts.element.outerWidth(false) === 0 ? 'auto' : 20+this.opts.element.outerWidth(false) + 'px';
|
||||||
} else if (this.opts.width === "copy" || this.opts.width === "resolve") {
|
} else if (this.opts.width === "copy" || this.opts.width === "resolve") {
|
||||||
// check if there is inline style on the element that contains width
|
// check if there is inline style on the element that contains width
|
||||||
style = this.opts.element.attr('style');
|
style = this.opts.element.attr('style');
|
||||||
@ -1933,7 +1933,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
if (style.indexOf("%") > 0) return style;
|
if (style.indexOf("%") > 0) return style;
|
||||||
|
|
||||||
// finally, fallback on the calculated width of the element
|
// finally, fallback on the calculated width of the element
|
||||||
return (this.opts.element.outerWidth(false) === 0 ? 'auto' : this.opts.element.outerWidth(false) + 'px');
|
return (this.opts.element.outerWidth(false) === 0 ? 'auto' : 20+this.opts.element.outerWidth(false) + 'px');
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -56,6 +56,8 @@ UseSearchToSelectCompany=Use autocompletion fields to choose third parties inste
|
|||||||
ActivityStateToSelectCompany= Add a filter option to show/hide thirdparties which are currently in activity or has ceased it
|
ActivityStateToSelectCompany= Add a filter option to show/hide thirdparties which are currently in activity or has ceased it
|
||||||
UseSearchToSelectContactTooltip=Also if you have a large number of third parties (> 100 000), you can increase speed by setting constant CONTACT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string.
|
UseSearchToSelectContactTooltip=Also if you have a large number of third parties (> 100 000), you can increase speed by setting constant CONTACT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string.
|
||||||
UseSearchToSelectContact=Use autocompletion fields to choose contact (instead of using a list box).
|
UseSearchToSelectContact=Use autocompletion fields to choose contact (instead of using a list box).
|
||||||
|
DelaiedFullListToSelectCompany=Wait you press a key before loading content of thirdparties combo list (This may increase performance if you have a large number of thirdparties)
|
||||||
|
DelaiedFullListToSelectContact=Wait you press a key before loading content of contact combo list (This may increase performance if you have a large number of contact)
|
||||||
SearchFilter=Search filters options
|
SearchFilter=Search filters options
|
||||||
NumberOfKeyToSearch=Nbr of characters to trigger search: %s
|
NumberOfKeyToSearch=Nbr of characters to trigger search: %s
|
||||||
ViewFullDateActions=Show full dates events in the third sheet
|
ViewFullDateActions=Show full dates events in the third sheet
|
||||||
|
|||||||
@ -348,12 +348,9 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
print '<td colspan="1">';
|
print '<td colspan="1">';
|
||||||
$events=array();
|
|
||||||
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
|
|
||||||
|
|
||||||
$thirdpartyofproject=$projectstatic->getListContactId('thirdparty');
|
$thirdpartyofproject=$projectstatic->getListContactId('thirdparty');
|
||||||
$selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$projectstatic->societe->id;
|
$selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$projectstatic->societe->id;
|
||||||
$selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', $thirdpartyofproject, 0, $events, '&withproject='.$withproject);
|
$selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', $thirdpartyofproject, 0, '&withproject='.$withproject);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
print '<td colspan="1">';
|
print '<td colspan="1">';
|
||||||
|
|||||||
@ -58,10 +58,15 @@ print $form->multiselectarray('testmulti', $array, $arrayselected, '', 0, '', 0,
|
|||||||
print '<br><br>'."\n";
|
print '<br><br>'."\n";
|
||||||
|
|
||||||
// Test5: a select
|
// Test5: a select
|
||||||
print "Test 5: a select<br>\n";
|
print "Test 5a: a select<br>\n";
|
||||||
|
$array=array(1=>'Value 1',2=>'Value 2',3=>'Value 3 ith a very long text. aze eazeae e ae aeae a e a ea ea ea e a e aea e ae aeaeaeaze.');
|
||||||
|
$selected=3;
|
||||||
|
print $form->selectarray('testselecta', $array, $selected, 1, 0, 0, 'style="min-width: 250px;"', 0, 0, 0, '', '', 1);
|
||||||
|
print '<br>';
|
||||||
|
print "Test 5b: a select<br>\n";
|
||||||
$array=array(1=>'Value 1',2=>'Value 2',3=>'Value 3');
|
$array=array(1=>'Value 1',2=>'Value 2',3=>'Value 3');
|
||||||
$selected=3;
|
$selected=3;
|
||||||
print $form->selectarray('testselect', $array, $selected, 1, 0, 0, 'style="min-width: 250px;"');
|
print $form->selectarray('testselectb', $array, $selected, 1, 0, 0, 'style="min-width: 250px;"', 0, 0, 0, '', '', 1);
|
||||||
|
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|||||||
@ -711,7 +711,7 @@ print '<td width="80"> </td></tr>'."\n";
|
|||||||
// Utilisation formulaire Ajax sur choix societe
|
// Utilisation formulaire Ajax sur choix societe
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print "<tr ".$bc[$var].">";
|
print "<tr ".$bc[$var].">";
|
||||||
print '<td width="80%">'.$form->textwithpicto($langs->trans("UseSearchToSelectCompany"),$langs->trans('UseSearchToSelectCompanyTooltip'),1).' </td>';
|
print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectCompany"),$langs->trans('UseSearchToSelectCompanyTooltip'),1).' </td>';
|
||||||
if (! $conf->use_javascript_ajax)
|
if (! $conf->use_javascript_ajax)
|
||||||
{
|
{
|
||||||
print '<td class="nowrap" align="right" colspan="2">';
|
print '<td class="nowrap" align="right" colspan="2">';
|
||||||
@ -726,7 +726,7 @@ else
|
|||||||
'2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')',
|
'2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')',
|
||||||
'3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')',
|
'3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')',
|
||||||
);
|
);
|
||||||
print $form->selectarray("activate_COMPANY_USE_SEARCH_TO_SELECT",$arrval,$conf->global->COMPANY_USE_SEARCH_TO_SELECT);
|
print $form->selectarray("activate_COMPANY_USE_SEARCH_TO_SELECT", $arrval, $conf->global->COMPANY_USE_SEARCH_TO_SELECT);
|
||||||
print '</td><td align="right">';
|
print '</td><td align="right">';
|
||||||
print '<input type="submit" class="button" name="COMPANY_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
|
print '<input type="submit" class="button" name="COMPANY_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
|
||||||
print "</td>";
|
print "</td>";
|
||||||
@ -735,7 +735,7 @@ print '</tr>';
|
|||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print "<tr ".$bc[$var].">";
|
print "<tr ".$bc[$var].">";
|
||||||
print '<td width="80%">'.$form->textwithpicto($langs->trans("UseSearchToSelectContact"),$langs->trans('UseSearchToSelectContactTooltip'),1).'</td>';
|
print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectContact"),$langs->trans('UseSearchToSelectContactTooltip'),1).'</td>';
|
||||||
if (! $conf->use_javascript_ajax)
|
if (! $conf->use_javascript_ajax)
|
||||||
{
|
{
|
||||||
print '<td class="nowrap" align="right" colspan="2">';
|
print '<td class="nowrap" align="right" colspan="2">';
|
||||||
@ -750,7 +750,7 @@ else
|
|||||||
'2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')',
|
'2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')',
|
||||||
'3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')',
|
'3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')',
|
||||||
);
|
);
|
||||||
print $form->selectarray("activate_CONTACT_USE_SEARCH_TO_SELECT",$arrval,$conf->global->CONTACT_USE_SEARCH_TO_SELECT);
|
print $form->selectarray("activate_CONTACT_USE_SEARCH_TO_SELECT", $arrval, $conf->global->CONTACT_USE_SEARCH_TO_SELECT);
|
||||||
print '</td><td align="right">';
|
print '</td><td align="right">';
|
||||||
print '<input type="submit" class="button" name="CONTACT_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
|
print '<input type="submit" class="button" name="CONTACT_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
|
||||||
print "</td>";
|
print "</td>";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user