Skip to content
Snippets Groups Projects
Commit dea1210c authored by Regis Houssin's avatar Regis Houssin
Browse files

Fix: edit in place datepicker more stable

parent 75340e4b
Branches
No related tags found
No related merge requests found
Showing
with 30 additions and 83 deletions
index.php
*.htaccess
*.settings
*.buildpath
*.project
*.cache
*.log
*.DS_Store
document
documents
DEBIAN
install.lock
*.patch
default.properties
dolibarr-*.exe
dolibarr-*.tgz
dolibarr-*.zip
dolibarr-*.rpm
dolibarr-*.deb
makepack-google.conf
module_google-*.tgz
module_pibarcode-1.0.tgz
*.exe
*.tgz
*.torrent
*.zip
version-phpsane.txt
makepack-phpsane.conf
html
*.deb
*.dsc
*.tar.gz
*.changes
*.db
ca_dolibarr.key
doliwamptest.iss
spec
Thumbs.db
out.*
socpeople*
example*.pdf
Thumbs.db
*.db
google
.htaccess
.DS_Store
.documents
dolibarr_mail
demo_pwc
phpsane
test.php
custom
custom2
google.php
......@@ -356,8 +356,7 @@ else if ($id)
// Date
print '<tr><td>'.$langs->trans("Date").'</td><td>';
print $form->editInPlace($object->date, 'date', $user->rights->deplacement->creer, 'datepicker');
//print dol_print_date($object->date,'day');
print $form->editInPlace($object->date, 'dated', $user->rights->deplacement->creer, 'datepicker');
print '</td></tr>';
// Km/Price
......
conf.php*.sav
*.php
conf.php.mysql
conf.php.postgres
......@@ -37,7 +37,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php");
top_httphead();
//print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
print_r($_POST);
//print_r($_POST);
// Load original field value
if((isset($_POST['field']) && ! empty($_POST['field']))
......@@ -51,7 +51,9 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
$fk_element = GETPOST('fk_element');
$value = GETPOST('value');
$type = GETPOST('type');
$timestamp = GETPOST('timestamp');
$format='text';
$return=array();
$error=0;
......@@ -62,26 +64,31 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
$object = new GenericObject($db);
// Clean parameters
$value = trim($value);
$newvalue = trim($value);
if ($type == 'numeric')
{
$value = price2num($value);
$newvalue = price2num($newvalue);
// Check parameters
if (! is_numeric($value))
if (! is_numeric($newvalue))
{
$error++;
$return['error'] = $langs->trans('ErrorBadValue');
}
}
else if ($type == 'datepicker')
{
$format = 'date';
$newvalue = ($timestamp / 1000);
}
if (! $error)
{
$ret=$object->setValueFrom($table_element, $fk_element, $field, $value);
$ret=$object->setValueFrom($table_element, $fk_element, $field, $newvalue, $format);
if ($ret > 0)
{
if ($type == 'numeric') $value = price($value);
else if ($type == 'textarea') $value = dol_nl2br($value);
if ($type == 'numeric') $value = price($newvalue);
else if ($type == 'textarea') $value = dol_nl2br($newvalue);
$return['value'] = $value;
}
......
......@@ -622,16 +622,18 @@ abstract class CommonObject
* @param int $id Object id
* @param string $field Field to update
* @param mixte $value New value
* @param string $format Data format
* @return int <0 if KO, >0 if OK
*/
function setValueFrom($table, $id, $field, $value)
function setValueFrom($table, $id, $field, $value, $format='text')
{
global $conf;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET ";
$sql.= $field." = '".$this->db->escape($value)."'";
if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'";
else if ($format == 'date') $sql.= $field." = '".$this->db->idate($value)."'";
$sql.= " WHERE rowid = ".$id;
dol_syslog(get_class($this)."::setValueFrom sql=".$sql, LOG_DEBUG);
......
......@@ -164,6 +164,9 @@ class Form
if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && $condition)
{
// Use for timestamp format
if ($type == 'datepicker') $out.= '<input id="timeStamp" type="hidden"/>';
$out.= '<div class="edit_'.$type.'" id="'.$htmlname.'">';
$out.= $value;
$out.= '</div>';
......
......@@ -105,11 +105,14 @@ $(document).ready(function() {
cancel : cancelInPlace,
submit : submitInPlace,
indicator : indicatorInPlace,
submitdata : {
submitdata : function(value, settings) {
return {
type: 'datepicker',
element: element,
table_element: table_element,
fk_element: fk_element
fk_element: fk_element,
timestamp: $('#timeStamp').val()
};
},
callback : function(result, settings) {
var obj = $.parseJSON(result);
......
modGoogle.class.php
modPHPSane.class.php
mailinglist_chatsderace.modules.php
mailinglist_chiensderace.modules.php
jpgraph2
phpsane
php_excelreader
.DS_Store
ckfinder
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment