diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php
index 4e38149717e..1808f400e23 100644
--- a/htdocs/compta/deplacement/fiche.php
+++ b/htdocs/compta/deplacement/fiche.php
@@ -170,7 +170,7 @@ if ($action == 'classin')
llxHeader();
-$html = new Form($db);
+$form = new Form($db);
/*
* Action create
@@ -191,17 +191,17 @@ if ($action == 'create')
print "
";
print '| '.$langs->trans("Type").' | ';
- print $html->select_type_fees(GETPOST("type"),'type',1);
+ print $form->select_type_fees(GETPOST("type"),'type',1);
print ' |
';
print "";
print '| '.$langs->trans("Person").' | ';
- print $html->select_users(GETPOST("fk_user"),'fk_user',1);
+ print $form->select_users(GETPOST("fk_user"),'fk_user',1);
print ' |
';
print "";
print '| '.$langs->trans("Date").' | ';
- print $html->select_date($datec?$datec:-1,'','','','','add',1,1);
+ print $form->select_date($datec?$datec:-1,'','','','','add',1,1);
print ' |
';
// Km
@@ -210,7 +210,7 @@ if ($action == 'create')
// Company
print "";
print '| '.$langs->trans("CompanyVisited").' | ';
- print $html->select_societes(GETPOST("socid"),'socid','',1);
+ print $form->select_societes(GETPOST("socid"),'socid','',1);
print ' |
';
// Public note
@@ -272,18 +272,18 @@ else if ($id)
// Type
print "";
print '| '.$langs->trans("Type").' | ';
- print $html->select_type_fees($_POST["type"]?$_POST["type"]:$object->type,'type',0);
+ print $form->select_type_fees($_POST["type"]?$_POST["type"]:$object->type,'type',0);
print ' |
';
// Who
print "";
print '| '.$langs->trans("Person").' | ';
- print $html->select_users($_POST["fk_user"]?$_POST["fk_user"]:$object->fk_user,'fk_user',0);
+ print $form->select_users($_POST["fk_user"]?$_POST["fk_user"]:$object->fk_user,'fk_user',0);
print ' |
';
// Date
print '| '.$langs->trans("Date").' | ';
- print $html->select_date($object->date,'','','','','update');
+ print $form->select_date($object->date,'','','','','update');
print ' |
';
// Km
@@ -294,7 +294,7 @@ else if ($id)
// Where
print "";
print '| '.$langs->trans("CompanyVisited").' | ';
- print $html->select_societes($soc->id,'socid','',1);
+ print $form->select_societes($soc->id,'socid','',1);
print ' |
';
// Public note
@@ -329,7 +329,7 @@ else if ($id)
*/
if ($action == 'delete')
{
- $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$id,$langs->trans("DeleteTrip"),$langs->trans("ConfirmDeleteTrip"),"confirm_delete");
+ $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$id,$langs->trans("DeleteTrip"),$langs->trans("ConfirmDeleteTrip"),"confirm_delete");
if ($ret == 'html') print '
';
}
@@ -346,7 +346,7 @@ else if ($id)
// Ref
print "";
print '| '.$langs->trans("Ref").' | ';
- print $html->showrefnav($object,'id','',1,'rowid','ref','');
+ print $form->showrefnav($object,'id','',1,'rowid','ref','');
print ' |
';
// Type
@@ -366,7 +366,7 @@ else if ($id)
// Km/Price
print '| '.$langs->trans("FeesKilometersOrAmout").' | ';
- print ''.$object->km.' |
';
+ print ''.$form->editInPlace($object->km, 'km', $object->element, 'text').' | ';
// Where
print '| '.$langs->trans("CompanyVisited").' | ';
@@ -384,7 +384,7 @@ else if ($id)
print '| ';
print $langs->trans('Project');
print ' | ';
- if ($action != 'classify')
+ if ($action != 'classify' && $user->rights->deplacement->creer)
{
print 'id.'">';
print img_edit($langs->trans('SetProject'),1);
@@ -394,11 +394,11 @@ else if ($id)
print ' | ';
if ($action == 'classify')
{
- $html->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'projectid');
+ $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'projectid');
}
else
{
- $html->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'none');
+ $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project,'none');
}
print ' | ';
print '
';
@@ -410,9 +410,7 @@ else if ($id)
// Public note
print '| '.$langs->trans("NotePublic").' | ';
print '';
- print ' ';
- print ($object->note_public ? dol_nl2br($object->note_public) : " ");
- print ' ';
+ print $form->editInPlace(($object->note_public ? dol_nl2br($object->note_public) : " "), 'note_public', $object->element);
print " |
";
// Private note
@@ -420,9 +418,7 @@ else if ($id)
{
print '| '.$langs->trans("NotePrivate").' | ';
print '';
- print ' ';
- print ($object->note_private ? dol_nl2br($object->note_private) : " ");
- print ' ';
+ print $form->editInPlace(($object->note_private ? dol_nl2br($object->note_private) : " "), 'note', $object->element);
print " |
";
}
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 79d3dc57eb6..db8265ddfbb 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -4,7 +4,7 @@
* Copyright (C) 2004 Benoit Mortier
* Copyright (C) 2004 Sebastien Di Cintio
* Copyright (C) 2004 Eric Seigne
- * Copyright (C) 2005-2010 Regis Houssin
+ * Copyright (C) 2005-2011 Regis Houssin
* Copyright (C) 2006 Andre Cianfarani
* Copyright (C) 2006 Marc Barilley/Ocebo
* Copyright (C) 2007 Franky Van Liedekerke
@@ -141,6 +141,35 @@ class Form
}
return $ret;
}
+
+ /**
+ * Output edit in place form
+ *
+ * @param string $value Value to show/edit
+ * @param string $htmlname DIV ID (field name)
+ * @param string $element Type of element
+ * @param string $area Type of edit
+ * @return string HTML edit in place
+ */
+ function editInPlace($value, $htmlname, $element, $type='area')
+ {
+ global $user;
+
+ $out='';
+
+ if ($user->rights->$element->creer || $user->rights->$element->write)
+ {
+ $out.= '';
+ $out.= $value;
+ $out.= '
';
+ }
+ else
+ {
+ $out = $value;
+ }
+
+ return $out;
+ }
/**
* Show a text and picto with tooltip on text or picto
diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php
index 7483cbd8e0f..4af19179e25 100644
--- a/htdocs/core/lib/functions2.lib.php
+++ b/htdocs/core/lib/functions2.lib.php
@@ -1,6 +1,7 @@
- * Copyright (C) 2008 Raphael Bertrand (Resultic)
+/* Copyright (C) 2008-2011 Laurent Destailleur
+ * Copyright (C) 2008-2011 Regis Houssin
+ * Copyright (C) 2008 Raphael Bertrand (Resultic)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by