forked from Wavyzz/dolibarr
Merge remote-tracking branch 'origin/3.7' into develop
Conflicts: htdocs/core/class/html.form.class.php htdocs/core/lib/ajax.lib.php
This commit is contained in:
@@ -816,84 +816,15 @@ class Form
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
{
|
||||
if (! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT) && ! $forcecombo)
|
||||
if ($conf->use_javascript_ajax && ! $forcecombo)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
||||
$out.= ajax_combobox($htmlname, $events, $conf->global->COMPANY_USE_SEARCH_TO_SELECT);
|
||||
}
|
||||
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
|
||||
{
|
||||
$out.='<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
jQuery("#'.$htmlname.'").change(function () {
|
||||
var obj = '.json_encode($events).';
|
||||
$.each(obj, function(key,values) {
|
||||
if (values.method.length) {
|
||||
runJsCodeForEvent'.$htmlname.'(values);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function runJsCodeForEvent'.$htmlname.'(obj) {
|
||||
var id = $("#'.$htmlname.'").val();
|
||||
var method = obj.method;
|
||||
var url = obj.url;
|
||||
var htmlname = obj.htmlname;
|
||||
var showempty = obj.showempty;
|
||||
$.getJSON(url,
|
||||
{
|
||||
action: method,
|
||||
id: id,
|
||||
htmlname: htmlname,
|
||||
showempty: showempty
|
||||
},
|
||||
function(response) {
|
||||
$.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);
|
||||
if (response.num) {
|
||||
var selecthtml_str = response.value;
|
||||
var selecthtml_dom=$.parseHTML(selecthtml_str);
|
||||
$("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
|
||||
} else {
|
||||
$("#inputautocomplete"+htmlname).val("");
|
||||
}
|
||||
$("select#" + htmlname).change(); /* Trigger event change */
|
||||
});
|
||||
}
|
||||
})
|
||||
</script>';
|
||||
}
|
||||
}
|
||||
$nodatarole=' data-role="none"';
|
||||
}
|
||||
|
||||
// Construct $out and $outarray
|
||||
$out.= '<select id="'.$htmlname.'" class="flat minwidth100" name="'.$htmlname.'">'."\n";
|
||||
$out.= '<select id="'.$htmlname.'" class="flat minwidth100" name="'.$htmlname.'"'.$nodatarole.'>'."\n";
|
||||
|
||||
$textifempty='';
|
||||
// Do not use textempty = ' ' or ' ' here, or search on key will search on ' key'.
|
||||
@@ -1094,9 +1025,10 @@ class Form
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
||||
$out.= ajax_combobox($htmlname, $events, $conf->global->CONTACT_USE_SEARCH_TO_SELECT);
|
||||
$nodatarole=' data-role="none"';
|
||||
}
|
||||
|
||||
if ($htmlname != 'none' || $options_only) $out.= '<select class="flat'.($moreclass?' '.$moreclass:'').'" id="'.$htmlname.'" name="'.$htmlname.'">';
|
||||
if ($htmlname != 'none' || $options_only) $out.= '<select class="flat'.($moreclass?' '.$moreclass:'').'" id="'.$htmlname.'" name="'.$htmlname.'"'.$nodatarole.'>';
|
||||
if ($showempty == 1) $out.= '<option value="0"'.($selected=='0'?' selected="selected"':'').'></option>';
|
||||
if ($showempty == 2) $out.= '<option value="0"'.($selected=='0'?' selected="selected"':'').'>'.$langs->trans("Internal").'</option>';
|
||||
$num = $this->db->num_rows($resql);
|
||||
@@ -1280,7 +1212,15 @@ class Form
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
$out.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled?' disabled="disabled"':'').'>';
|
||||
// Enhance with select2
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
||||
$out.= ajax_combobox($htmlname);
|
||||
$nodatarole=' data-role="none"';
|
||||
}
|
||||
|
||||
$out.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled?' disabled="disabled"':'').$nodatarole.'>';
|
||||
if ($show_empty) $out.= '<option value="-1"'.((empty($selected) || $selected==-1)?' selected="selected"':'').'> </option>'."\n";
|
||||
|
||||
$userstatic=new User($this->db);
|
||||
@@ -1355,18 +1295,6 @@ class Form
|
||||
$out.= '<option value="">'.$langs->trans("None").'</option>';
|
||||
}
|
||||
$out.= '</select>';
|
||||
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
{
|
||||
$out.= '<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$(\'#'.$htmlname.'\').select2({
|
||||
width: \'resolve\',
|
||||
minimumInputLength: 0
|
||||
});
|
||||
})
|
||||
</script>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4587,11 +4515,20 @@ class Form
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
// Enhance with select2
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
||||
$out.= ajax_combobox($htmlname);
|
||||
$nodatarole=' data-role="none"';
|
||||
}
|
||||
|
||||
$out.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled?' disabled="disabled"':'').$nodatarole.'>';
|
||||
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
$out.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled?' disabled="disabled"':'').'>';
|
||||
if ($show_empty) $out.= '<option value="-1"'.($selected==-1?' selected="selected"':'').'> </option>'."\n";
|
||||
|
||||
while ($i < $num)
|
||||
@@ -4620,8 +4557,8 @@ class Form
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.= '<select class="flat" name="'.$htmlname.'" disabled="disabled">';
|
||||
$out.= '<option value="">'.$langs->trans("None").'</option>';
|
||||
if ($show_empty) $out.= '<option value="-1"'.($selected==-1?' selected="selected"':'').'></option>'."\n";
|
||||
$out.= '<option value="" disabled="disabled">'.$langs->trans("NoUserGroupDefined").'</option>';
|
||||
}
|
||||
$out.= '</select>';
|
||||
}
|
||||
|
||||
@@ -70,36 +70,13 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
||||
{
|
||||
print '<tr>';
|
||||
print '<td class="nowrap">';
|
||||
//print $langs->trans("ActionsAskedBy");
|
||||
//print ' </td><td class="nowrap maxwidthonsmartphone">';
|
||||
//print $form->select_dolusers($filtera, 'userasked', 1, '', ! $canedit);
|
||||
//print ' '.$langs->trans("or") . ' ';
|
||||
print $langs->trans("ActionsOwnedBy").' ';
|
||||
print '</td><td class="nowrap maxwidthonsmartphone">';
|
||||
//print $langs->trans("User");
|
||||
print $form->select_dolusers($filtert, 'usertodo', 1, '', ! $canedit);
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
||||
print ajax_combobox('usertodo');
|
||||
}
|
||||
if (empty($conf->dol_optimize_smallscreen)) print ' '.$langs->trans("or") . ' ';
|
||||
else print '<br>';
|
||||
print $langs->trans("Group").' ';
|
||||
if (empty($conf->dol_optimize_smallscreen)) print ' '.$langs->trans("or") . ' '.$langs->trans("Group").' ';
|
||||
print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', ! $canedit);
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
{
|
||||
print ajax_combobox('usergroup');
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
/*print '<tr>';
|
||||
print '<td class="nowrap">';
|
||||
print $langs->trans("or") . ' ' . $langs->trans("ActionsDoneBy");
|
||||
print ' </td><td class="nowrap maxwidthonsmartphone">';
|
||||
print $form->select_dolusers($filterd, 'userdone', 1, '', ! $canedit);
|
||||
print '</td></tr>';*/
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
|
||||
$formactions=new FormActions($db);
|
||||
|
||||
@@ -147,16 +124,18 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
||||
print '<tr>';
|
||||
print '<td class="nowrap">'.$langs->trans("WorkingTimeRange").'</td>';
|
||||
print "<td class='nowrap maxwidthonsmartphone'>";
|
||||
print '<input type="number" class="short" name="begin_h" value="'.$begin_h.'" min="0" max="23"> - ';
|
||||
print '<input type="number" class="short" name="begin_h" value="'.$begin_h.'" min="0" max="23">';
|
||||
if (empty($conf->dol_use_jmobile)) print ' - ';
|
||||
print '<input type="number" class="short" name="end_h" value="'.$end_h.'" min="1" max="24">';
|
||||
print ' '.$langs->trans("H");
|
||||
if (empty($conf->dol_use_jmobile)) print ' '.$langs->trans("H");
|
||||
print '</td></tr>';
|
||||
|
||||
// Filter on days
|
||||
print '<tr>';
|
||||
print '<td class="nowrap">'.$langs->trans("WorkingDaysRange").'</td>';
|
||||
print "<td class='nowrap maxwidthonsmartphone'>";
|
||||
print '<input type="number" class="short" name="begin_d" value="'.$begin_d.'" min="1" max="7"> - ';
|
||||
print '<input type="number" class="short" name="begin_d" value="'.$begin_d.'" min="1" max="7">';
|
||||
if (empty($conf->dol_use_jmobile)) print ' - ';
|
||||
print '<input type="number" class="short" name="end_d" value="'.$end_d.'" min="1" max="7">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@@ -320,16 +320,23 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
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->dol_use_jmobile)) return ''; // select2 works with jmobile
|
||||
if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return '';
|
||||
if (empty($conf->use_javascript_ajax)) return '';
|
||||
|
||||
if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete=0;
|
||||
|
||||
$msg = '<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
|
||||
$(\'#'.$htmlname.'\').select2({
|
||||
width: \'resolve\',
|
||||
minimumInputLength: '.$minLengthToAutocomplete.',
|
||||
});
|
||||
});';
|
||||
|
||||
if (count($event))
|
||||
{
|
||||
$msg.= '
|
||||
jQuery("#'.$htmlname.'").change(function () {
|
||||
var obj = '.json_encode($events).';
|
||||
$.each(obj, function(key,values) {
|
||||
@@ -339,7 +346,6 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0)
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function runJsCodeForEvent'.$htmlname.'(obj) {
|
||||
var id = $("#'.$htmlname.'").val();
|
||||
var method = obj.method;
|
||||
@@ -373,10 +379,12 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0)
|
||||
$("#inputautocomplete"+htmlname).val("");
|
||||
}
|
||||
$("select#" + htmlname).change(); /* Trigger event change */
|
||||
});
|
||||
}
|
||||
);
|
||||
}';
|
||||
}
|
||||
|
||||
});'."\n";
|
||||
$msg.= '});'."\n";
|
||||
$msg.= "</script>\n";
|
||||
|
||||
return $msg;
|
||||
|
||||
@@ -169,6 +169,7 @@ User=User
|
||||
Users=Users
|
||||
Group=Group
|
||||
Groups=Groups
|
||||
NoUserGroupDefined=No user group defined
|
||||
Password=Password
|
||||
PasswordRetype=Retype your password
|
||||
NoteSomeFeaturesAreDisabled=Note that a lot of features/modules are disabled in this demonstration.
|
||||
|
||||
Reference in New Issue
Block a user