From 1464929fed70efe0c75e83aa2d07fce114675335 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 27 Oct 2011 18:55:07 +0200 Subject: [PATCH] Fix: load only textarea for nl2br --- htdocs/compta/deplacement/fiche.php | 2 +- htdocs/core/ajax/loadinplace.php | 5 +++-- htdocs/core/ajax/saveinplace.php | 20 +++++++++++++++++--- htdocs/core/js/editinplace.js | 7 ------- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index b704fa5a016..dfd532eb36c 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -361,7 +361,7 @@ else if ($id) // Km/Price print ''.$langs->trans("FeesKilometersOrAmout").''; - print ''.$form->editInPlace($object->km, 'km', $object->element, 'numeric').''; + print ''.$form->editInPlace(price($object->km), 'km', $user->rights->deplacement->creer, 'numeric').''; // Where print ''.$langs->trans("CompanyVisited").''; diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php index c287e8ce67a..88af8e50ef5 100644 --- a/htdocs/core/ajax/loadinplace.php +++ b/htdocs/core/ajax/loadinplace.php @@ -48,14 +48,15 @@ if((isset($_GET['field']) && ! empty($_GET['field'])) $table_element = GETPOST('table_element'); $field = GETPOST('field'); $fk_element = GETPOST('fk_element'); + $type = GETPOST('type'); if ($element == 'fichinter') $element = 'ficheinter'; if ($user->rights->$element->lire || $user->rights->$element->read) { $object = new GenericObject($db); - $ret=$object->getValueFrom($table_element, $fk_element, $field); - echo $ret; + $value=$object->getValueFrom($table_element, $fk_element, $field); + echo $value; } else { diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index 147f5888d9c..efae5b326a2 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -52,6 +52,8 @@ if((isset($_POST['field']) && ! empty($_POST['field'])) $value = GETPOST('value'); $type = GETPOST('type'); + $error=0; + if ($element == 'fichinter') $element = 'ficheinter'; if ($user->rights->$element->creer || $user->rights->$element->write) @@ -65,11 +67,23 @@ if((isset($_POST['field']) && ! empty($_POST['field'])) $value = price2num($value); // Check parameters - if (! is_numeric($value)) $value = 0; + if (! is_numeric($value)) + { + $error++; + } } - $ret=$object->setValueFrom($table_element, $fk_element, $field, $value); - if ($ret > 0) echo (! empty($value) ? dol_nl2br($value) : ' '); + if (! $error) + { + $ret=$object->setValueFrom($table_element, $fk_element, $field, $value); + if ($ret > 0) + { + if ($type == 'numeric') $value = price($value); + else $value = (! empty($value) ? dol_nl2br($value) : ' '); + + echo $value; + } + } } else { diff --git a/htdocs/core/js/editinplace.js b/htdocs/core/js/editinplace.js index e3db88f3d50..fe68febdd65 100644 --- a/htdocs/core/js/editinplace.js +++ b/htdocs/core/js/editinplace.js @@ -57,13 +57,6 @@ $(document).ready(function() { cancel : cancelInPlace, submit : submitInPlace, indicator : indicatorInPlace, - loadurl : urlLoadInPlace, - loaddata : { - type: 'numeric', - element: element, - table_element: table_element, - fk_element: fk_element - }, submitdata : { type: 'numeric', element: element,