diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index 1f3c6438536730d9c7d4f84f468cceaf5210d471..cf5647ae055e8534d00b0182874ac32080859d8b 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -345,7 +345,7 @@ else if ($id) // Type print '<tr><td>'.$langs->trans("Type").'</td><td>'; - 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 '</td></tr>'; diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php index f45dc8dd80cdc08bd791dab4a1644992b6bc0c9c..ca3f04b46028cf3cd698321f1c6f1e9a023ec8ee 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 f710797c8fd87170495a2f0b5876b3596e6f66e7..097266bcc883d47daed49ed0f5701bd251ee171e 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 cae596a28270b8e42ce0233b25499a506bd84ce3..6372ede364bd4672b919e8602406352b1a3c5c3e 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.= '<input id="timeStamp" type="hidden"/>'; + else if ($type == 'select' && ! empty($loadmethod)) $out.= '<input id="loadmethod" value="'.$loadmethod.'" type="hidden"/>'; $out.= '<div class="edit_'.$type.'" id="'.$htmlname.'">'; $out.= $value; diff --git a/htdocs/core/js/editinplace.js b/htdocs/core/js/editinplace.js index 1ea15604de6883169bcb0c75498ef4edfc9608f6..b36e0aa6b4899675cb8d4755b0f3b0d351534d8c 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