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);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
if (! empty($conf->use_javascript_ajax))
|
if ($conf->use_javascript_ajax && ! $forcecombo)
|
||||||
{
|
{
|
||||||
if (! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT) && ! $forcecombo)
|
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
||||||
{
|
$out.= ajax_combobox($htmlname, $events, $conf->global->COMPANY_USE_SEARCH_TO_SELECT);
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
$nodatarole=' data-role="none"';
|
||||||
$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>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct $out and $outarray
|
// 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='';
|
$textifempty='';
|
||||||
// Do not use textempty = ' ' or ' ' here, or search on key will search on ' key'.
|
// 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';
|
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);
|
||||||
|
$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 == 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>';
|
if ($showempty == 2) $out.= '<option value="0"'.($selected=='0'?' selected="selected"':'').'>'.$langs->trans("Internal").'</option>';
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
@@ -1280,7 +1212,15 @@ class Form
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
if ($num)
|
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";
|
if ($show_empty) $out.= '<option value="-1"'.((empty($selected) || $selected==-1)?' selected="selected"':'').'> </option>'."\n";
|
||||||
|
|
||||||
$userstatic=new User($this->db);
|
$userstatic=new User($this->db);
|
||||||
@@ -1355,18 +1295,6 @@ class Form
|
|||||||
$out.= '<option value="">'.$langs->trans("None").'</option>';
|
$out.= '<option value="">'.$langs->trans("None").'</option>';
|
||||||
}
|
}
|
||||||
$out.= '</select>';
|
$out.= '</select>';
|
||||||
|
|
||||||
if (! empty($conf->use_javascript_ajax))
|
|
||||||
{
|
|
||||||
$out.= '<script type="text/javascript">
|
|
||||||
$(document).ready(function() {
|
|
||||||
$(\'#'.$htmlname.'\').select2({
|
|
||||||
width: \'resolve\',
|
|
||||||
minimumInputLength: 0
|
|
||||||
});
|
|
||||||
})
|
|
||||||
</script>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -4587,11 +4515,20 @@ class Form
|
|||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows($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;
|
$i = 0;
|
||||||
if ($num)
|
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";
|
if ($show_empty) $out.= '<option value="-1"'.($selected==-1?' selected="selected"':'').'> </option>'."\n";
|
||||||
|
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
@@ -4620,8 +4557,8 @@ class Form
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$out.= '<select class="flat" name="'.$htmlname.'" disabled="disabled">';
|
if ($show_empty) $out.= '<option value="-1"'.($selected==-1?' selected="selected"':'').'></option>'."\n";
|
||||||
$out.= '<option value="">'.$langs->trans("None").'</option>';
|
$out.= '<option value="" disabled="disabled">'.$langs->trans("NoUserGroupDefined").'</option>';
|
||||||
}
|
}
|
||||||
$out.= '</select>';
|
$out.= '</select>';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,36 +70,13 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
|||||||
{
|
{
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td class="nowrap">';
|
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 $langs->trans("ActionsOwnedBy").' ';
|
||||||
print '</td><td class="nowrap maxwidthonsmartphone">';
|
print '</td><td class="nowrap maxwidthonsmartphone">';
|
||||||
//print $langs->trans("User");
|
|
||||||
print $form->select_dolusers($filtert, 'usertodo', 1, '', ! $canedit);
|
print $form->select_dolusers($filtert, 'usertodo', 1, '', ! $canedit);
|
||||||
if (! empty($conf->use_javascript_ajax))
|
if (empty($conf->dol_optimize_smallscreen)) print ' '.$langs->trans("or") . ' '.$langs->trans("Group").' ';
|
||||||
{
|
|
||||||
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").' ';
|
|
||||||
print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', ! $canedit);
|
print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', ! $canedit);
|
||||||
if (! empty($conf->use_javascript_ajax))
|
|
||||||
{
|
|
||||||
print ajax_combobox('usergroup');
|
|
||||||
}
|
|
||||||
print '</td></tr>';
|
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';
|
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
|
||||||
$formactions=new FormActions($db);
|
$formactions=new FormActions($db);
|
||||||
|
|
||||||
@@ -147,16 +124,18 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
|||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td class="nowrap">'.$langs->trans("WorkingTimeRange").'</td>';
|
print '<td class="nowrap">'.$langs->trans("WorkingTimeRange").'</td>';
|
||||||
print "<td class='nowrap maxwidthonsmartphone'>";
|
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 '<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>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Filter on days
|
// Filter on days
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td class="nowrap">'.$langs->trans("WorkingDaysRange").'</td>';
|
print '<td class="nowrap">'.$langs->trans("WorkingDaysRange").'</td>';
|
||||||
print "<td class='nowrap maxwidthonsmartphone'>";
|
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 '<input type="number" class="short" name="end_d" value="'.$end_d.'" min="1" max="7">';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -320,63 +320,71 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0)
|
|||||||
{
|
{
|
||||||
global $conf;
|
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->global->MAIN_DISABLE_AJAX_COMBOX)) return '';
|
||||||
|
if (empty($conf->use_javascript_ajax)) return '';
|
||||||
|
|
||||||
|
if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete=0;
|
||||||
|
|
||||||
$msg = '<script type="text/javascript">
|
$msg = '<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
$(\'#'.$htmlname.'\').select2({
|
||||||
|
width: \'resolve\',
|
||||||
|
minimumInputLength: '.$minLengthToAutocomplete.',
|
||||||
|
});';
|
||||||
|
|
||||||
$(\'#'.$htmlname.'\').select2({
|
if (count($event))
|
||||||
width: \'resolve\',
|
{
|
||||||
minimumInputLength: '.$minLengthToAutocomplete.',
|
$msg.= '
|
||||||
});
|
jQuery("#'.$htmlname.'").change(function () {
|
||||||
jQuery("#'.$htmlname.'").change(function () {
|
|
||||||
var obj = '.json_encode($events).';
|
var obj = '.json_encode($events).';
|
||||||
$.each(obj, function(key,values) {
|
$.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;
|
var url = obj.url;
|
||||||
var url = obj.url;
|
var htmlname = obj.htmlname;
|
||||||
var htmlname = obj.htmlname;
|
var showempty = obj.showempty;
|
||||||
var showempty = obj.showempty;
|
$.getJSON(url,
|
||||||
$.getJSON(url,
|
{
|
||||||
{
|
action: method,
|
||||||
action: method,
|
id: id,
|
||||||
id: id,
|
htmlname: htmlname,
|
||||||
htmlname: htmlname,
|
showempty: showempty
|
||||||
showempty: showempty
|
},
|
||||||
},
|
function(response) {
|
||||||
function(response) {
|
$.each(obj.params, function(key,action) {
|
||||||
$.each(obj.params, function(key,action) {
|
if (key.length) {
|
||||||
if (key.length) {
|
var num = response.num;
|
||||||
var num = response.num;
|
if (num > 0) {
|
||||||
if (num > 0) {
|
$("#" + key).removeAttr(action);
|
||||||
$("#" + key).removeAttr(action);
|
} else {
|
||||||
} else {
|
$("#" + key).attr(action, action);
|
||||||
$("#" + 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 */
|
||||||
$("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 */
|
);
|
||||||
});
|
}';
|
||||||
}
|
}
|
||||||
|
|
||||||
});'."\n";
|
$msg.= '});'."\n";
|
||||||
$msg.= "</script>\n";
|
$msg.= "</script>\n";
|
||||||
|
|
||||||
return $msg;
|
return $msg;
|
||||||
|
|||||||
@@ -169,6 +169,7 @@ User=User
|
|||||||
Users=Users
|
Users=Users
|
||||||
Group=Group
|
Group=Group
|
||||||
Groups=Groups
|
Groups=Groups
|
||||||
|
NoUserGroupDefined=No user group defined
|
||||||
Password=Password
|
Password=Password
|
||||||
PasswordRetype=Retype your password
|
PasswordRetype=Retype your password
|
||||||
NoteSomeFeaturesAreDisabled=Note that a lot of features/modules are disabled in this demonstration.
|
NoteSomeFeaturesAreDisabled=Note that a lot of features/modules are disabled in this demonstration.
|
||||||
|
|||||||
Reference in New Issue
Block a user