[edit in place] Add edit_text and edit_numeric

This commit is contained in:
Regis Houssin 2011-10-26 10:20:27 +02:00
parent 5be8bb87a2
commit e2b539ee7d
7 changed files with 57 additions and 9 deletions

View File

@ -362,7 +362,8 @@ else if ($id)
print '</td></tr>';
// Km/Price
print '<tr><td>'.$langs->trans("FeesKilometersOrAmout").'</td><td>'.$object->km.'</td></tr>';
print '<tr><td>'.$langs->trans("FeesKilometersOrAmout").'</td>';
print '<td><div class="edit_numeric" id="km">'.$object->km.'</div></td></tr>';
// Where
print '<tr><td>'.$langs->trans("CompanyVisited").'</td>';

View File

@ -25,7 +25,7 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','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');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
require('../../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php");
@ -46,6 +46,13 @@ if((isset($_POST['field']) && ! empty($_POST['field'])) && (isset($_POST['table_
// Clean parameters
$value = trim($_POST['value']);
if ($_POST['type'] == 'numeric')
{
$value = price2num($value);
// Check parameters
if (! is_numeric($value)) $value = 0;
}
$ret=$object->setValueFrom($_POST['table_element'], $_POST['fk_element'], $_POST['field'], $value);
if ($ret > 0) echo (! empty($value) ? dol_nl2br($value) : '&nbsp;');

View File

@ -30,11 +30,51 @@ $(document).ready(function() {
submit : '<?php echo $langs->trans('Ok'); ?>',
indicator : '<img src="<?php echo DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif"; ?>">',
loadurl : '<?php echo DOL_URL_ROOT.'/core/ajax/loadinplace.php'; ?>',
loaddata : {
loaddata : {
type: 'textarea',
table_element: "<?php echo $object->table_element; ?>",
fk_element: "<?php echo $object->id; ?>"
},
submitdata : {
submitdata : {
type: 'textarea',
table_element: "<?php echo $object->table_element; ?>",
fk_element: "<?php echo $object->id; ?>"
}
});
$('.edit_text').editable('<?php echo DOL_URL_ROOT.'/core/ajax/saveinplace.php'; ?>', {
type : 'text',
id : 'field',
tooltip : '<?php echo $langs->trans('ClickToEdit'); ?>',
cancel : '<?php echo $langs->trans('Cancel'); ?>',
submit : '<?php echo $langs->trans('Ok'); ?>',
indicator : '<img src="<?php echo DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif"; ?>">',
loadurl : '<?php echo DOL_URL_ROOT.'/core/ajax/loadinplace.php'; ?>',
loaddata : {
type: 'text',
table_element: "<?php echo $object->table_element; ?>",
fk_element: "<?php echo $object->id; ?>"
},
submitdata : {
type: 'text',
table_element: "<?php echo $object->table_element; ?>",
fk_element: "<?php echo $object->id; ?>"
}
});
$('.edit_numeric').editable('<?php echo DOL_URL_ROOT.'/core/ajax/saveinplace.php'; ?>', {
type : 'text',
id : 'field',
tooltip : '<?php echo $langs->trans('ClickToEdit'); ?>',
cancel : '<?php echo $langs->trans('Cancel'); ?>',
submit : '<?php echo $langs->trans('Ok'); ?>',
indicator : '<img src="<?php echo DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif"; ?>">',
loadurl : '<?php echo DOL_URL_ROOT.'/core/ajax/loadinplace.php'; ?>',
loaddata : {
type: 'numeric',
table_element: "<?php echo $object->table_element; ?>",
fk_element: "<?php echo $object->id; ?>"
},
submitdata : {
type: 'numeric',
table_element: "<?php echo $object->table_element; ?>",
fk_element: "<?php echo $object->id; ?>"
}

View File

@ -1657,7 +1657,7 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
/* jQuery - jeditable */
/* ============================================================================== */
.edit_area:hover {
.edit_area:hover, .edit_text:hover, .edit_numeric:hover {
background: white url(<?php echo dol_buildpath($path.'/theme/auguria/img/edit.png',1) ?>) right center no-repeat;
cursor: pointer;
}

View File

@ -1863,7 +1863,7 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
/* jQuery - jeditable */
/* ============================================================================== */
.edit_area:hover {
.edit_area:hover, .edit_text:hover, .edit_numeric:hover {
background: white url(<?php echo dol_buildpath($path.'/theme/bureau2crea/img/edit.png',1) ?>) right center no-repeat;
cursor: pointer;
}

View File

@ -1813,7 +1813,7 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
/* jQuery - jeditable */
/* ============================================================================== */
.edit_area:hover {
.edit_area:hover, .edit_text:hover, .edit_numeric:hover {
background: white url(<?php echo dol_buildpath($path.'/theme/cameleo/img/edit.png',1) ?>) right center no-repeat;
cursor: pointer;
}

View File

@ -1713,8 +1713,8 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
/* jQuery - jeditable */
/* ============================================================================== */
.edit_area:hover {
background: white url(<?php echo dol_buildpath($path.'/theme/eldy/img/edit.png',1) ?>) right center no-repeat;
.edit_area:hover, .edit_text:hover, .edit_numeric:hover {
background: white url(<?php echo dol_buildpath($path.'/theme/eldy/img/edit.png',1) ?>) right top no-repeat;
cursor: pointer;
}