mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
New: works on edit in place
This commit is contained in:
parent
5fe088334c
commit
1398a41add
|
|
@ -344,6 +344,8 @@ else if ($id)
|
|||
|
||||
$soc = new Societe($db);
|
||||
if ($object->socid) $soc->fetch($object->socid);
|
||||
|
||||
if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) include(DOL_DOCUMENT_ROOT.'/core/tpl/ajaxeditinplace.tpl.php');
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
|
|
@ -413,7 +415,9 @@ else if ($id)
|
|||
// Public note
|
||||
print '<tr><td valign="top">'.$langs->trans("NotePublic").'</td>';
|
||||
print '<td valign="top" colspan="3">';
|
||||
print ($object->note_public ? nl2br($object->note_public) : " ");
|
||||
print '<div class="edit_area" id="note_public">';
|
||||
print ($object->note_public ? dol_nl2br($object->note_public) : " ");
|
||||
print '</div>';
|
||||
print "</td></tr>";
|
||||
|
||||
// Private note
|
||||
|
|
@ -421,7 +425,9 @@ else if ($id)
|
|||
{
|
||||
print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td>';
|
||||
print '<td valign="top" colspan="3">';
|
||||
print ($object->note_private ? nl2br($object->note_private) : " ");
|
||||
print '<div class="edit_area" id="note">';
|
||||
print ($object->note_private ? dol_nl2br($object->note_private) : " ");
|
||||
print '</div>';
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
|
|
|
|||
49
htdocs/core/ajax/loadinplace.php
Normal file
49
htdocs/core/ajax/loadinplace.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
/* Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/ajax/loadinplace.php
|
||||
* \brief File to load field value
|
||||
*/
|
||||
|
||||
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
|
||||
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');
|
||||
|
||||
require('../../main.inc.php');
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php");
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
top_httphead();
|
||||
|
||||
//print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
|
||||
|
||||
// Load original field value
|
||||
if((isset($_GET['field']) && ! empty($_GET['field'])) && (isset($_GET['table_element']) && ! empty($_GET['table_element'])) && (isset($_GET['fk_element']) && ! empty($_GET['fk_element'])))
|
||||
{
|
||||
$object = new GenericObject($db);
|
||||
$ret=$object->getValueFrom($_GET['table_element'], $_GET['fk_element'], $_GET['field']);
|
||||
echo $ret;
|
||||
}
|
||||
|
||||
?>
|
||||
54
htdocs/core/ajax/saveinplace.php
Normal file
54
htdocs/core/ajax/saveinplace.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
/* Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/ajax/saveinplace.php
|
||||
* \brief File to save field value
|
||||
*/
|
||||
|
||||
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
|
||||
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');
|
||||
|
||||
require('../../main.inc.php');
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php");
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
top_httphead();
|
||||
|
||||
//print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
|
||||
//var_dump($_POST);
|
||||
|
||||
// Load original field value
|
||||
if((isset($_POST['field']) && ! empty($_POST['field'])) && (isset($_POST['table_element']) && ! empty($_POST['table_element'])) && (isset($_POST['fk_element']) && ! empty($_POST['fk_element'])))
|
||||
{
|
||||
$object = new GenericObject($db);
|
||||
|
||||
// Clean parameters
|
||||
$value = trim($_POST['value']);
|
||||
|
||||
$ret=$object->setValueFrom($_POST['table_element'], $_POST['fk_element'], $_POST['field'], $value);
|
||||
if ($ret > 0) echo (! empty($value) ? dol_nl2br($value) : ' ');
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -589,25 +589,50 @@ abstract class CommonObject
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load value from specific field
|
||||
*
|
||||
* @param string $table Table of element or element line
|
||||
* @param int $id Element id
|
||||
* @param string $field Field selected
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function getValueFrom($table, $id, $field)
|
||||
{
|
||||
$result=false;
|
||||
|
||||
$sql = "SELECT ".$field." FROM ".MAIN_DB_PREFIX.$table;
|
||||
$sql.= " WHERE rowid = ".$id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$row = $this->db->fetch_row($resql);
|
||||
$result = $row[0];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a specific field from an object
|
||||
* Update a specific field from an object
|
||||
*
|
||||
* @param table Table element or element line
|
||||
* @param id Object id
|
||||
* @param field Field to update
|
||||
* @param value New value
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param string $table Table element or element line
|
||||
* @param int $id Object id
|
||||
* @param string $field Field to update
|
||||
* @param mixte $value New value
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function updateObjectField($table,$id,$field,$value)
|
||||
function setValueFrom($table, $id, $field, $value)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET ";
|
||||
$sql.= $field." = '".$value."'";
|
||||
$sql.= $field." = '".$this->db->escape($value)."'";
|
||||
$sql.= " WHERE rowid = ".$id;
|
||||
|
||||
dol_syslog(get_class($this)."::updateObjectField sql=".$sql, LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::setValueFrom sql=".$sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class GenericObject extends CommonObject
|
|||
*
|
||||
* @param DoliDB $DB Database handler
|
||||
*/
|
||||
function GenericObject($db)
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db=$db;
|
||||
}
|
||||
|
|
|
|||
45
htdocs/core/tpl/ajaxeditinplace.tpl.php
Normal file
45
htdocs/core/tpl/ajaxeditinplace.tpl.php
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
/* Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE FOR JQUERY -->
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function() {
|
||||
$('.edit_area').editable('<?php echo DOL_URL_ROOT.'/core/ajax/saveinplace.php'; ?>', {
|
||||
type : 'textarea',
|
||||
rows : 4,
|
||||
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 : {
|
||||
table_element: "<?php echo $object->table_element; ?>",
|
||||
fk_element: "<?php echo $object->id; ?>"
|
||||
},
|
||||
submitdata : {
|
||||
table_element: "<?php echo $object->table_element; ?>",
|
||||
fk_element: "<?php echo $object->id; ?>"
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!-- END PHP TEMPLATE FOR JQUERY -->
|
||||
|
|
@ -917,19 +917,24 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
|
|||
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/tiptip/jquery.tipTip.min'.$ext.'"></script>'."\n";
|
||||
//print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/lightbox/js/jquery.lightbox-0.5.min'.$ext.'"></script>'."\n";
|
||||
// jQuery Layout
|
||||
if (!empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) || defined('REQUIRE_JQUERY_LAYOUT'))
|
||||
if (! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) || defined('REQUIRE_JQUERY_LAYOUT'))
|
||||
{
|
||||
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/layout/jquery.layout-latest'.$ext.'"></script>'."\n";
|
||||
}
|
||||
// jQuery jnotify
|
||||
if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY)) print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jnotify/jquery.jnotify.min.js"></script>'."\n";
|
||||
// Flot
|
||||
print '<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/excanvas.min.js"></script><![endif]-->'."\n";
|
||||
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.min.js"></script>'."\n";
|
||||
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.pie.min.js"></script>'."\n";
|
||||
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.stack.min.js"></script>'."\n";
|
||||
// jQuery jeditable
|
||||
if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.min'.$ext.'"></script>'."\n";
|
||||
// Flot
|
||||
if (empty($conf->global->MAIN_DISABLE_JQUERY_FLOT))
|
||||
{
|
||||
print '<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/excanvas.min.js"></script><![endif]-->'."\n";
|
||||
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.min.js"></script>'."\n";
|
||||
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.pie.min.js"></script>'."\n";
|
||||
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.stack.min.js"></script>'."\n";
|
||||
}
|
||||
// CKEditor
|
||||
if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_EDITORNAME) && $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor')
|
||||
if (! empty($conf->fckeditor->enabled) && ! empty($conf->global->FCKEDITOR_EDITORNAME) && $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor')
|
||||
{
|
||||
print '<!-- Includes JS for CKEditor -->'."\n";
|
||||
print '<script type="text/javascript">var CKEDITOR_BASEPATH = \''.DOL_URL_ROOT.'/includes/ckeditor/\';</script>'."\n";
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user