diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index 7e38119641b..1243ac5eaba 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -171,6 +171,24 @@ if ($action == 'setdated') $result=$object->setValueFrom('dated',$dated,'','','date'); if ($result < 0) dol_print_error($db, $object->error); } +if ($action == 'setkm') +{ + $object->fetch($id); + $result=$object->setValueFrom('km',GETPOST('km')); + if ($result < 0) dol_print_error($db, $object->error); +} +if ($action == 'setnote_public') +{ + $object->fetch($id); + $result=$object->setValueFrom('note_public',GETPOST('note_public')); + if ($result < 0) dol_print_error($db, $object->error); +} +if ($action == 'setnote') +{ + $object->fetch($id); + $result=$object->setValueFrom('note',GETPOST('note')); + if ($result < 0) dol_print_error($db, $object->error); +} /* @@ -309,7 +327,9 @@ else if ($id) // Public note print ''.$langs->trans("NotePublic").''; print ''; - print '
"; + require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); + $doleditor=new DolEditor('note_public',$object->note_public,600,200,'dolibarr_notes','In',false,true,true,ROWS_8,'100'); + print $doleditor->Create(1); print ""; // Private note @@ -317,7 +337,9 @@ else if ($id) { print ''.$langs->trans("NotePrivate").''; print ''; - print '
"; + require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); + $doleditor=new DolEditor('note_private',$object->note_private,600,200,'dolibarr_notes','In',false,true,true,ROWS_8,'100'); + print $doleditor->Create(1); print ""; } @@ -353,8 +375,10 @@ else if ($id) print ''; // Type - print ''.$langs->trans("Type").''; - print $form->editInPlace($langs->trans($object->type), 'type', $user->rights->deplacement->creer, 'select', 'types_fees'); + print ''; + print $form->editfieldkey("Type",'type',$langs->trans($object->type),'id',$object->id,$user->rights->deplacement->creer,'select:type_fees'); + print ''; + print $form->editfieldval("Type",'type',$langs->trans($object->type),'id',$object->id,$user->rights->deplacement->creer,'select:type_fees'); print ''; // Who @@ -366,16 +390,17 @@ else if ($id) // Date print ''; - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) print $langs->trans('Date'); - else print $form->editfieldkey("Date",'dated',$object->date,'id',$object->id,$user->rights->deplacement->creer,'datepicker'); - print ''; - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) print $form->editInPlace($object->date, 'dated', $user->rights->deplacement->creer, 'datepicker'); - else print $form->editfieldval("Date",'dated',$object->date,'id',$object->id,$user->rights->deplacement->creer,'datepicker'); + print $form->editfieldkey("Date",'dated',$object->date,'id',$object->id,$user->rights->deplacement->creer,'datepicker'); + print ''; + print $form->editfieldval("Date",'dated',$object->date,'id',$object->id,$user->rights->deplacement->creer,'datepicker'); print ''; // Km/Price - print ''.$langs->trans("FeesKilometersOrAmout").''; - print ''.$form->editInPlace($object->km, 'km', $user->rights->deplacement->creer, 'numeric').''; + print ''; + print $form->editfieldkey("FeesKilometersOrAmout",'km',$object->km,'id',$object->id,$user->rights->deplacement->creer,'numeric:6'); + print ''; + print $form->editfieldval("FeesKilometersOrAmout",'km',$object->km,'id',$object->id,$user->rights->deplacement->creer,'numeric:6'); + print ""; // Where print ''.$langs->trans("CompanyVisited").''; @@ -417,18 +442,20 @@ else if ($id) print ''.$langs->trans("Status").''.$object->getLibStatut(4).''; // Public note - print ''.$langs->trans("NotePublic").''; - print ''; - print $form->editInPlace($object->note_public, 'note_public', $user->rights->deplacement->creer, 'ckeditor', 'dolibarr_notes'); + print ''; + print $form->editfieldkey("NotePublic",'note_public',$object->note_public,'id',$object->id,$user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180:100:6'); + print ''; + print $form->editfieldval("NotePublic",'note_public',$object->note_public,'id',$object->id,$user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180:100:6'); print ""; // Private note if (! $user->societe_id) { - print ''.$langs->trans("NotePrivate").''; - print ''; - print $form->editInPlace($object->note_private, 'note', $user->rights->deplacement->creer, 'ckeditor', 'dolibarr_notes'); - print ""; + print ''; + print $form->editfieldkey("NotePrivate",'note',$object->note_private,'id',$object->id,$user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180:100:6'); + print ''; + print $form->editfieldval("NotePrivate",'note',$object->note_private,'id',$object->id,$user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180:100:6'); + print ""; } print ""; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 08c5afd4b85..648938a7c8c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -74,20 +74,24 @@ class Form * @param string $paramkey Key of parameter for Url (unique if there is several parameter to show). In most cases "id". * @param string $paramvalue Value of parameter for Url * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'text' or 'textarea', 'day' or 'datepicker', ...) + * @param string $typeofdata Type of data ('string' by default, 'email', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz', 'select:xxx'...) * @return string HTML edit field - * TODO no GET or POST in class file, use a param */ function editfieldkey($text,$htmlname,$preselected,$paramkey,$paramvalue,$perm,$typeofdata='string') { - global $langs; - $ret=''; - $ret.=''; - if (GETPOST('action') != 'edit'.$htmlname && $perm) $ret.=''; - $ret.='
'; - $ret.=$langs->trans($text); - $ret.=''.img_edit($langs->trans('Edit'),1).'
'; - return $ret; + global $conf,$langs; + + if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) return $langs->trans($text); + else + { + $ret=''; + $ret.=''; + if (GETPOST('action') != 'edit'.$htmlname && $perm) $ret.=''; + $ret.='
'; + $ret.=$langs->trans($text); + $ret.=''.img_edit($langs->trans('Edit'),1).'
'; + return $ret; + } } /** @@ -95,51 +99,67 @@ class Form * * @param string $text Text of label (not used in this function) * @param string $htmlname Name of select field - * @param string $preselected Value to show/edit + * @param string $value Value to show/edit * @param string $paramkey Key of parameter (unique if there is several parameter to show). In most cases "id". * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'text' or 'textarea', 'day' or 'datepicker', ...) - * @param string $editvalue Use this value instead $preselected + * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height:rows:cols', 'select:xxx'...) + * @param string $editvalue When in edit mode, use this value as $value instead of value * @return string HTML edit field - * TODO no GET or POST in class file, use a param */ - function editfieldval($text,$htmlname,$preselected,$paramkey,$paramvalue,$perm,$typeofdata='string',$editvalue='') + function editfieldval($text,$htmlname,$value,$paramkey,$paramvalue,$perm,$typeofdata='string',$editvalue='') { - global $langs,$db; + global $conf,$langs,$db; $ret=''; - if (GETPOST('action') == 'edit'.$htmlname) + + // When option to edit inline is activated + if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) { - $ret.="\n"; - $ret.='
'; - $ret.=''; - $ret.=''; - $ret.=''; - $ret.=''; - $ret.=''; - if ($typeofdata != 'day' && $typeofdata != 'datepicker') $ret.=''; - $ret.='
'; - if (in_array($typeofdata,array('string','email'))) - { - $ret.=''; - } - else if ($typeofdata == 'text' || $typeofdata == 'textarea') - { - $ret.=''; - } - else if ($typeofdata == 'day' || $typeofdata == 'datepicker') - { - $html=new Form($db); - $ret.=$html->form_date($_SERVER['PHP_SELF'].($paramkey?'?'.$paramkey.'='.$paramvalue:''),$preselected,$htmlname); - } - $ret.='
'."\n"; - $ret.='
'."\n"; + $ret.=$this->editInPlace($value, $htmlname, $perm, $typeofdata); } else { - if ($typeofdata == 'email') $ret.=dol_print_email($preselected,0,0,0,0,1); - elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret.=dol_print_date($preselected,'day'); - elseif ($typeofdata == 'text' || $typeofdata == 'textarea') $ret.=dol_htmlentitiesbr($preselected); - else $ret.=$preselected; + if (GETPOST('action') == 'edit'.$htmlname) + { + $ret.="\n"; + $ret.='
'; + $ret.=''; + $ret.=''; + $ret.=''; + $ret.=''; + $ret.=''; + if ($typeofdata != 'day' && $typeofdata != 'datepicker') $ret.=''; + $ret.='
'; + if (preg_match('/^(string|email|numeric)/',$typeofdata)) + { + $tmp=explode(':',$typeofdata); + $ret.=''; + } + else if ($typeofdata == 'text' || $typeofdata == 'textarea') + { + $ret.=''; + } + else if ($typeofdata == 'day' || $typeofdata == 'datepicker') + { + $ret.=$this->form_date($_SERVER['PHP_SELF'].($paramkey?'?'.$paramkey.'='.$paramvalue:''),$value,$htmlname); + } + else if (preg_match('/^ckeditor/',$typeofdata)) + { + $tmp=explode(':',$typeofdata); + require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); + $doleditor=new DolEditor($htmlname,($editvalue?$editvalue:$value),($tmp[2]?$tmp[2]:''),($tmp[3]?$tmp[3]:'100'),($tmp[1]?$tmp[1]:'dolibarr_notes'),'In',false,true,true,($tmp[4]?$tmp[4]:ROWS_4),($tmp[5]?$tmp[5]:'100')); + $ret.=$doleditor->Create(1); + //$ret.=''; + } + $ret.='
'."\n"; + $ret.='
'."\n"; + } + else + { + if ($typeofdata == 'email') $ret.=dol_print_email($value,0,0,0,0,1); + elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret.=dol_print_date($value,'day'); + elseif ($typeofdata == 'text' || $typeofdata == 'textarea') $ret.=dol_htmlentitiesbr($value); + else $ret.=$value; + } } return $ret; } @@ -150,11 +170,10 @@ class Form * @param string $value Value to show/edit * @param string $htmlname DIV ID (field name) * @param int $condition Condition to edit - * @param string $inputType Type of input - * @param string $inputOption Input option + * @param string $inputType Type of input ('numeric', 'datepicker', 'textarea', 'ckeditor:dolibarr_zzz', 'select:xxx') * @return string HTML edit in place */ - function editInPlace($value, $htmlname, $condition, $inputType='textarea', $inputOption='') + function editInPlace($value, $htmlname, $condition, $inputType='textarea') { global $conf; @@ -162,21 +181,30 @@ class Form // Check parameters if ($inputType == 'textarea') $value = dol_nl2br($value); - else if ($inputType == 'numeric') $value = price($value); + else if (preg_match('/^numeric/',$inputType)) $value = price($value); else if ($inputType == 'datepicker') $value = dol_print_date($value, 'day'); if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && $condition) { - if ($inputType == 'datepicker') + if (preg_match('/^(string|email|numeric)/',$inputType)) + { + $tmp=explode(':',$inputType); + $inputType=$tmp[0]; $inputOption=$tmp[1]; + } + if ($inputType == 'datepicker') { $out.= ''; // Use for timestamp format } - else if ($inputType == 'select' && ! empty($inputOption)) + else if (preg_match('/^select/',$inputType)) { + $tmp=explode(':',$inputType); + $inputType=$tmp[0]; $inputOption=$tmp[1]; $out.= ''; } - else if ($inputType == 'ckeditor' && ! empty($inputOption)) + else if (preg_match('/^ckeditor/',$inputType)) { + $tmp=explode(':',$inputType); + $inputType=$tmp[0]; $inputOption=$tmp[1]; if (! empty($conf->fckeditor->enabled)) { $out.= ''; diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 38a150a52a4..027d8fba2ce 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -816,11 +816,9 @@ else if ($id > 0 || ! empty($ref)) // Description (must be a textarea and not html must be allowed (used in list view) print ''; - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) print $langs->trans('Description'); - else print $form->editfieldkey("Description",'description',$object->description,'id',$object->id,$object->statut == 0 && $user->rights->ficheinter->creer,'textarea'); + print $form->editfieldkey("Description",'description',$object->description,'id',$object->id,$object->statut == 0 && $user->rights->ficheinter->creer,'textarea'); print ''; - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) print $form->editInPlace($object->description, 'description', $user->rights->ficheinter->creer && $object->statut == 0, 'textarea'); - else print $form->editfieldval("Description",'description',$object->description,'id',$object->id,$object->statut == 0 && $user->rights->ficheinter->creer,'textarea'); + print $form->editfieldval("Description",'description',$object->description,'id',$object->id,$object->statut == 0 && $user->rights->ficheinter->creer,'textarea'); print ''; print ''; @@ -859,22 +857,18 @@ else if ($id > 0 || ! empty($ref)) // Public note print ''; - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) print $langs->trans('NotePublic'); - else print $form->editfieldkey("NotePublic",'note_public',$object->note_public,'id',$object->id,$user->rights->ficheinter->creer,'textarea'); + print $form->editfieldkey("NotePublic",'note_public',$object->note_public,'id',$object->id,$user->rights->ficheinter->creer,'textarea'); print ''; - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) print $form->editInPlace($object->note_public, 'note_public', $user->rights->ficheinter->creer, 'textarea'); - else print $form->editfieldval("NotePublic",'note_public',$object->note_public,'id',$object->id,$user->rights->ficheinter->creer,'textarea'); + print $form->editfieldval("NotePublic",'note_public',$object->note_public,'id',$object->id,$user->rights->ficheinter->creer,'textarea'); print ""; // Private note if (! $user->societe_id) { print ''; - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) print $langs->trans('NotePrivate'); - else print $form->editfieldkey("NotePrivate",'note_private',$object->note_private,'id',$object->id,$user->rights->ficheinter->creer,'textarea'); + print $form->editfieldkey("NotePrivate",'note_private',$object->note_private,'id',$object->id,$user->rights->ficheinter->creer,'textarea'); print ''; - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) print $form->editInPlace($object->note_private, 'note_private', $user->rights->ficheinter->creer, 'textarea'); - else print $form->editfieldval("NotePrivate",'note_private',$object->note_private,'id',$object->id,$user->rights->ficheinter->creer,'textarea'); + print $form->editfieldval("NotePrivate",'note_private',$object->note_private,'id',$object->id,$user->rights->ficheinter->creer,'textarea'); print ""; }