Fix: edit in place datepicker more stable

This commit is contained in:
Regis Houssin 2011-10-28 19:31:42 +02:00
parent 75340e4b74
commit dea1210c2d
63 changed files with 32 additions and 141 deletions

View File

@ -1,14 +0,0 @@
index.php
*.htaccess
*.settings
*.buildpath
*.project
*.cache
*.log
*.DS_Store
document
documents
DEBIAN
install.lock
*.patch
default.properties

View File

@ -1,19 +0,0 @@
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

View File

@ -1,3 +0,0 @@
*.db
ca_dolibarr.key
doliwamptest.iss

View File

@ -1 +0,0 @@
spec

View File

@ -1 +0,0 @@
Thumbs.db

View File

@ -1,2 +0,0 @@
out.*
socpeople*

View File

@ -1 +0,0 @@
example*.pdf

View File

@ -1 +0,0 @@
Thumbs.db

View File

@ -1 +0,0 @@
*.db

View File

@ -1,10 +0,0 @@
google
.htaccess
.DS_Store
.documents
dolibarr_mail
demo_pwc
phpsane
test.php
custom
custom2

View File

@ -1 +0,0 @@
google.php

View File

@ -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

View File

@ -1,4 +0,0 @@
conf.php*.sav
*.php
conf.php.mysql
conf.php.postgres

View File

@ -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;
}

View File

@ -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);

View File

@ -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>';

View File

@ -105,11 +105,14 @@ $(document).ready(function() {
cancel : cancelInPlace,
submit : submitInPlace,
indicator : indicatorInPlace,
submitdata : {
type: 'datepicker',
element: element,
table_element: table_element,
fk_element: fk_element
submitdata : function(value, settings) {
return {
type: 'datepicker',
element: element,
table_element: table_element,
fk_element: fk_element,
timestamp: $('#timeStamp').val()
};
},
callback : function(result, settings) {
var obj = $.parseJSON(result);

View File

@ -1,2 +0,0 @@
modGoogle.class.php
modPHPSane.class.php

View File

@ -1,2 +0,0 @@
mailinglist_chatsderace.modules.php
mailinglist_chiensderace.modules.php

View File

@ -1,5 +0,0 @@
jpgraph2
phpsane
php_excelreader
.DS_Store
ckfinder

View File

@ -1 +0,0 @@
examples

View File

@ -1,2 +0,0 @@
aaa.txt
demos

View File

@ -1 +0,0 @@
samples

View File

@ -1 +0,0 @@
install.forced.php

View File

@ -1 +0,0 @@
google.lang

View File

@ -1 +0,0 @@
google.lang

View File

@ -1 +0,0 @@
google.lang

View File

@ -1 +0,0 @@
google.lang

View File

@ -1 +0,0 @@
google.lang

View File

@ -1 +0,0 @@
google.lang

View File

@ -1 +0,0 @@
google.lang

View File

@ -1 +0,0 @@
google.lang

View File

@ -1 +0,0 @@
google.lang

View File

@ -16,6 +16,8 @@ jQuery(function($){
dayNamesShort: ['Dim.','Lun.','Mar.','Mer.','Jeu.','Ven.','Sam.'],
dayNamesMin: ['D','L','M','M','J','V','S'],
weekHeader: 'Sem.',
altField: '#timeStamp',
altFormat: '@', // Gives a timestamp dateformat
dateFormat: 'dd/mm/yy',
firstDay: 1,
isRTL: false,

View File

@ -1 +0,0 @@
google.lang

View File

@ -1 +0,0 @@
google.lang

View File

@ -1 +0,0 @@
google.lang

View File

@ -1 +0,0 @@
google.lang

View File

@ -1 +0,0 @@
Thumbs.db

View File

@ -1,9 +0,0 @@
don.php
merci.php
valid.php
erreur.php
navigation.fr.xsl
fsfe-fr.xsl
eucd.css
donateurs.php
graph.php

View File

@ -1 +0,0 @@
Thumbs.db

View File

@ -1,3 +0,0 @@
*.db
clear
bureau2crea?-?ancien

View File

@ -1 +0,0 @@
*.db

View File

@ -1 +0,0 @@
Thumbs.db

View File

@ -1,2 +0,0 @@
*.db
*.db

View File

@ -1 +0,0 @@
*.db

View File

@ -1 +0,0 @@
tango-icon-theme*

View File

@ -1,2 +0,0 @@
*.db
style.css?-?Copie.php

View File

@ -1 +0,0 @@
Thumbs.db

View File

@ -1,2 +0,0 @@
*.db
*.db

View File

@ -1 +0,0 @@
*.db

View File

@ -1 +0,0 @@
tango-icon-theme*

View File

@ -1 +0,0 @@
*.db

View File

@ -1 +0,0 @@
Thumbs.db

View File

@ -1 +0,0 @@
*.db

View File

@ -1,2 +0,0 @@
*.db
*.db

View File

@ -1 +0,0 @@
*.db

View File

@ -1 +0,0 @@
Thumbs.db

View File

@ -1,2 +0,0 @@
*.db
*.db

View File

@ -1 +0,0 @@
*.db

View File

@ -1 +0,0 @@
tango-icon-theme*

View File

@ -1 +0,0 @@
report

View File

@ -1 +0,0 @@
report