diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php
index 1f3c6438536..cf5647ae055 100644
--- a/htdocs/compta/deplacement/fiche.php
+++ b/htdocs/compta/deplacement/fiche.php
@@ -345,7 +345,7 @@ else if ($id)
// Type
print '
| '.$langs->trans("Type").' | ';
- print $form->editInPlace($langs->trans($object->type), 'type', $user->rights->deplacement->creer, 'select');
+ print $form->editInPlace($langs->trans($object->type), 'type', $user->rights->deplacement->creer, 'select', 'types_fees');
//print $langs->trans($object->type);
print ' |
';
diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php
index f45dc8dd80c..ca3f04b4602 100644
--- a/htdocs/core/ajax/loadinplace.php
+++ b/htdocs/core/ajax/loadinplace.php
@@ -22,7 +22,7 @@
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
-if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
+//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
@@ -56,7 +56,12 @@ if((isset($_GET['field']) && ! empty($_GET['field']))
{
if ($type == 'select')
{
- echo json_encode(array("Aberdeen", "Ada", "Adamsville", "Addyston", "Adelphi", "Adena", "Adrian", "Akron"));
+ $methodname = 'load_cache_'.GETPOST('method');
+ $cachename = 'cache_'.GETPOST('method');
+
+ $form = new Form($db);
+ $ret = $form->$methodname();
+ if ($ret > 0) echo json_encode($form->$cachename);
}
else
{
diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php
index f710797c8fd..097266bcc88 100644
--- a/htdocs/core/ajax/saveinplace.php
+++ b/htdocs/core/ajax/saveinplace.php
@@ -22,7 +22,7 @@
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
-if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
+//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
@@ -51,7 +51,6 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
$fk_element = GETPOST('fk_element');
$value = GETPOST('value');
$type = GETPOST('type');
- $timestamp = GETPOST('timestamp');
$format='text';
$return=array();
@@ -65,6 +64,7 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
// Clean parameters
$newvalue = trim($value);
+
if ($type == 'numeric')
{
$newvalue = price2num($newvalue);
@@ -78,8 +78,22 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
}
else if ($type == 'datepicker')
{
- $format = 'date';
- $newvalue = ($timestamp / 1000);
+ $timestamp = GETPOST('timestamp');
+ $format = 'date';
+ $newvalue = ($timestamp / 1000);
+ }
+ else if ($type == 'select')
+ {
+ $methodname = 'load_cache_'.GETPOST('method');
+ $cachename = 'cache_'.GETPOST('method');
+
+ $form = new Form($db);
+ $ret = $form->$methodname();
+ if ($ret > 0)
+ {
+ $cache = $form->$cachename;
+ $value = $cache[$newvalue];
+ }
}
if (! $error)
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index cae596a2827..6372ede364b 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -150,9 +150,10 @@ class Form
* @param string $htmlname DIV ID (field name)
* @param int $condition Condition to edit
* @param string $area Type of edit
+ * @param string $loadmethod Name of load method
* @return string HTML edit in place
*/
- function editInPlace($value, $htmlname, $condition, $type='textarea')
+ function editInPlace($value, $htmlname, $condition, $type='textarea', $loadmethod='')
{
global $conf;
@@ -167,6 +168,7 @@ class Form
{
// Use for timestamp format
if ($type == 'datepicker') $out.= '';
+ else if ($type == 'select' && ! empty($loadmethod)) $out.= '';
$out.= '';
$out.= $value;
diff --git a/htdocs/core/js/editinplace.js b/htdocs/core/js/editinplace.js
index 1ea15604de6..b36e0aa6b48 100644
--- a/htdocs/core/js/editinplace.js
+++ b/htdocs/core/js/editinplace.js
@@ -138,12 +138,14 @@ $(document).ready(function() {
loadurl : urlLoadInPlace,
loaddata : {
type: 'select',
+ method: $('#loadmethod').val(),
element: element,
table_element: table_element,
fk_element: fk_element
},
submitdata : {
type: 'select',
+ method: $('#loadmethod').val(),
element: element,
table_element: table_element,
fk_element: fk_element