Browse Source

Fix: edit in place datepicker more stable

Regis Houssin 14 years ago
parent
commit
dea1210c2d
63 changed files with 32 additions and 141 deletions
  1. 0 14
      .cvsignore
  2. 0 19
      build/.cvsignore
  3. 0 3
      build/exe/doliwamp/.cvsignore
  4. 0 1
      dev/.cvsignore
  5. 0 1
      dev/phpunit/.cvsignore
  6. 0 2
      dev/skeletons/.cvsignore
  7. 0 1
      dev/test/.cvsignore
  8. 0 1
      dev/xdebug/.cvsignore
  9. 0 1
      doc/images/.cvsignore
  10. 0 10
      htdocs/.cvsignore
  11. 0 1
      htdocs/admin/.cvsignore
  12. 1 2
      htdocs/compta/deplacement/fiche.php
  13. 0 4
      htdocs/conf/.cvsignore
  14. 14 7
      htdocs/core/ajax/saveinplace.php
  15. 4 2
      htdocs/core/class/commonobject.class.php
  16. 3 0
      htdocs/core/class/html.form.class.php
  17. 8 5
      htdocs/core/js/editinplace.js
  18. 0 2
      htdocs/core/modules/.cvsignore
  19. 0 2
      htdocs/core/modules/mailings/.cvsignore
  20. 0 5
      htdocs/includes/.cvsignore
  21. 0 1
      htdocs/includes/jquery/plugins/flot/.cvsignore
  22. 0 2
      htdocs/includes/jquery/plugins/jcrop/.cvsignore
  23. 0 1
      htdocs/includes/nusoap/.cvsignore
  24. 0 1
      htdocs/install/.cvsignore
  25. 0 1
      htdocs/langs/ca_ES/.cvsignore
  26. 0 1
      htdocs/langs/en_AU/.cvsignore
  27. 0 1
      htdocs/langs/en_IN/.cvsignore
  28. 0 1
      htdocs/langs/en_NZ/.cvsignore
  29. 0 1
      htdocs/langs/en_US/.cvsignore
  30. 0 1
      htdocs/langs/es_ES/.cvsignore
  31. 0 1
      htdocs/langs/es_PR/.cvsignore
  32. 0 1
      htdocs/langs/fr_BE/.cvsignore
  33. 0 1
      htdocs/langs/fr_FR/.cvsignore
  34. 2 0
      htdocs/langs/fr_FR/js/jquery.ui.datepicker-fr_FR.js
  35. 0 1
      htdocs/langs/it_IT/.cvsignore
  36. 0 1
      htdocs/langs/nl_BE/.cvsignore
  37. 0 1
      htdocs/langs/pl_PL/.cvsignore
  38. 0 1
      htdocs/langs/pt_PT/.cvsignore
  39. 0 1
      htdocs/paypal/img/.cvsignore
  40. 0 9
      htdocs/public/donations/.cvsignore
  41. 0 1
      htdocs/support/.cvsignore
  42. 0 3
      htdocs/theme/.cvsignore
  43. 0 1
      htdocs/theme/auguria/.cvsignore
  44. 0 1
      htdocs/theme/auguria/fckeditor/.cvsignore
  45. 0 2
      htdocs/theme/auguria/fckeditor/images/.cvsignore
  46. 0 1
      htdocs/theme/auguria/img/.cvsignore
  47. 0 1
      htdocs/theme/auguria/img/menus/.cvsignore
  48. 0 2
      htdocs/theme/bureau2crea/.cvsignore
  49. 0 1
      htdocs/theme/bureau2crea/fckeditor/.cvsignore
  50. 0 2
      htdocs/theme/bureau2crea/fckeditor/images/.cvsignore
  51. 0 1
      htdocs/theme/bureau2crea/img/.cvsignore
  52. 0 1
      htdocs/theme/bureau2crea/img/menus/.cvsignore
  53. 0 1
      htdocs/theme/common/.cvsignore
  54. 0 1
      htdocs/theme/common/flags/.cvsignore
  55. 0 1
      htdocs/theme/common/mime/.cvsignore
  56. 0 2
      htdocs/theme/common/treemenu/.cvsignore
  57. 0 1
      htdocs/theme/eldy/.cvsignore
  58. 0 1
      htdocs/theme/eldy/fckeditor/.cvsignore
  59. 0 2
      htdocs/theme/eldy/fckeditor/images/.cvsignore
  60. 0 1
      htdocs/theme/eldy/img/.cvsignore
  61. 0 1
      htdocs/theme/eldy/img/menus/.cvsignore
  62. 0 1
      test/.cvsignore
  63. 0 1
      test/phpunit/.cvsignore

+ 0 - 14
.cvsignore

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

+ 0 - 19
build/.cvsignore

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

+ 0 - 3
build/exe/doliwamp/.cvsignore

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

+ 0 - 1
dev/.cvsignore

@@ -1 +0,0 @@
-spec

+ 0 - 1
dev/phpunit/.cvsignore

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

+ 0 - 2
dev/skeletons/.cvsignore

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

+ 0 - 1
dev/test/.cvsignore

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

+ 0 - 1
dev/xdebug/.cvsignore

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

+ 0 - 1
doc/images/.cvsignore

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

+ 0 - 10
htdocs/.cvsignore

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

+ 0 - 1
htdocs/admin/.cvsignore

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

+ 1 - 2
htdocs/compta/deplacement/fiche.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

+ 0 - 4
htdocs/conf/.cvsignore

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

+ 14 - 7
htdocs/core/ajax/saveinplace.php

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

+ 4 - 2
htdocs/core/class/commonobject.class.php

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

+ 3 - 0
htdocs/core/class/html.form.class.php

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

+ 8 - 5
htdocs/core/js/editinplace.js

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

+ 0 - 2
htdocs/core/modules/.cvsignore

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

+ 0 - 2
htdocs/core/modules/mailings/.cvsignore

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

+ 0 - 5
htdocs/includes/.cvsignore

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

+ 0 - 1
htdocs/includes/jquery/plugins/flot/.cvsignore

@@ -1 +0,0 @@
-examples

+ 0 - 2
htdocs/includes/jquery/plugins/jcrop/.cvsignore

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

+ 0 - 1
htdocs/includes/nusoap/.cvsignore

@@ -1 +0,0 @@
-samples

+ 0 - 1
htdocs/install/.cvsignore

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

+ 0 - 1
htdocs/langs/ca_ES/.cvsignore

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

+ 0 - 1
htdocs/langs/en_AU/.cvsignore

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

+ 0 - 1
htdocs/langs/en_IN/.cvsignore

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

+ 0 - 1
htdocs/langs/en_NZ/.cvsignore

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

+ 0 - 1
htdocs/langs/en_US/.cvsignore

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

+ 0 - 1
htdocs/langs/es_ES/.cvsignore

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

+ 0 - 1
htdocs/langs/es_PR/.cvsignore

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

+ 0 - 1
htdocs/langs/fr_BE/.cvsignore

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

+ 0 - 1
htdocs/langs/fr_FR/.cvsignore

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

+ 2 - 0
htdocs/langs/fr_FR/js/jquery.ui.datepicker-fr_FR.js

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

+ 0 - 1
htdocs/langs/it_IT/.cvsignore

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

+ 0 - 1
htdocs/langs/nl_BE/.cvsignore

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

+ 0 - 1
htdocs/langs/pl_PL/.cvsignore

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

+ 0 - 1
htdocs/langs/pt_PT/.cvsignore

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

+ 0 - 1
htdocs/paypal/img/.cvsignore

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

+ 0 - 9
htdocs/public/donations/.cvsignore

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

+ 0 - 1
htdocs/support/.cvsignore

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

+ 0 - 3
htdocs/theme/.cvsignore

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

+ 0 - 1
htdocs/theme/auguria/.cvsignore

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

+ 0 - 1
htdocs/theme/auguria/fckeditor/.cvsignore

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

+ 0 - 2
htdocs/theme/auguria/fckeditor/images/.cvsignore

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

+ 0 - 1
htdocs/theme/auguria/img/.cvsignore

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

+ 0 - 1
htdocs/theme/auguria/img/menus/.cvsignore

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

+ 0 - 2
htdocs/theme/bureau2crea/.cvsignore

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

+ 0 - 1
htdocs/theme/bureau2crea/fckeditor/.cvsignore

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

+ 0 - 2
htdocs/theme/bureau2crea/fckeditor/images/.cvsignore

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

+ 0 - 1
htdocs/theme/bureau2crea/img/.cvsignore

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

+ 0 - 1
htdocs/theme/bureau2crea/img/menus/.cvsignore

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

+ 0 - 1
htdocs/theme/common/.cvsignore

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

+ 0 - 1
htdocs/theme/common/flags/.cvsignore

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

+ 0 - 1
htdocs/theme/common/mime/.cvsignore

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

+ 0 - 2
htdocs/theme/common/treemenu/.cvsignore

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

+ 0 - 1
htdocs/theme/eldy/.cvsignore

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

+ 0 - 1
htdocs/theme/eldy/fckeditor/.cvsignore

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

+ 0 - 2
htdocs/theme/eldy/fckeditor/images/.cvsignore

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

+ 0 - 1
htdocs/theme/eldy/img/.cvsignore

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

+ 0 - 1
htdocs/theme/eldy/img/menus/.cvsignore

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

+ 0 - 1
test/.cvsignore

@@ -1 +0,0 @@
-report

+ 0 - 1
test/phpunit/.cvsignore

@@ -1 +0,0 @@
-report