Browse Source

Fix: Use correct syntax of date into sql requests (with quotes)

Laurent Destailleur 11 years ago
parent
commit
cafa61ef7d
30 changed files with 70 additions and 58 deletions
  1. 1 1
      htdocs/accountancy/class/accountancyaccount.class.php
  2. 1 1
      htdocs/accountancy/class/accountancysystem.class.php
  3. 2 2
      htdocs/adherents/index.php
  4. 2 2
      htdocs/adherents/type.php
  5. 1 1
      htdocs/bookmarks/class/bookmark.class.php
  6. 2 2
      htdocs/comm/mailing/class/mailing.class.php
  7. 3 3
      htdocs/compta/localtax/class/localtax.class.php
  8. 2 2
      htdocs/compta/paiement/cheque/class/remisecheque.class.php
  9. 1 1
      htdocs/compta/paiement/class/paiement.class.php
  10. 1 1
      htdocs/compta/prelevement/class/bonprelevement.class.php
  11. 1 1
      htdocs/compta/prelevement/class/rejetprelevement.class.php
  12. 6 6
      htdocs/compta/salaries/class/paymentsalary.class.php
  13. 3 3
      htdocs/compta/tva/class/tva.class.php
  14. 1 1
      htdocs/contrat/class/contrat.class.php
  15. 3 3
      htdocs/contrat/liste.php
  16. 2 2
      htdocs/contrat/services.php
  17. 1 1
      htdocs/core/class/discount.class.php
  18. 1 1
      htdocs/core/class/events.class.php
  19. 1 1
      htdocs/core/class/notify.class.php
  20. 13 8
      htdocs/core/db/pgsql.class.php
  21. 1 1
      htdocs/core/lib/tax.lib.php
  22. 3 1
      htdocs/cron/class/cronjob.class.php
  23. 1 1
      htdocs/fichinter/class/fichinter.class.php
  24. 1 1
      htdocs/fourn/class/fournisseur.commande.class.php
  25. 2 2
      htdocs/fourn/class/paiementfourn.class.php
  26. 2 2
      htdocs/install/upgrade2.php
  27. 2 2
      htdocs/livraison/class/livraison.class.php
  28. 6 1
      htdocs/projet/tasks/task.php
  29. 1 1
      htdocs/societe/class/address.class.php
  30. 3 3
      htdocs/societe/class/societe.class.php

+ 1 - 1
htdocs/accountancy/class/accountancyaccount.class.php

@@ -63,7 +63,7 @@ class AccountancyAccount
     	
         $sql = "INSERT INTO ".MAIN_DB_PREFIX."accountingaccount";
         $sql.= " (date_creation, fk_user_author, numero,intitule)";
-        $sql.= " VALUES (".$this->db->idate($now).",".$user->id.",'".$this->numero."','".$this->intitule."')";
+        $sql.= " VALUES ('".$this->db->idate($now)."',".$user->id.",'".$this->numero."','".$this->intitule."')";
 
         $resql = $this->db->query($sql);
         if ($resql)

+ 1 - 1
htdocs/accountancy/class/accountancysystem.class.php

@@ -62,7 +62,7 @@ class AccountancySystem
 
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_system";
 		$sql.= " (date_creation, fk_user_author, numero,intitule)";
-		$sql.= " VALUES (".$this->db->idate($now).",".$user->id.",'".$this->numero."','".$this->intitule."')";
+		$sql.= " VALUES ('".$this->db->idate($now)."',".$user->id.",'".$this->numero."','".$this->intitule."')";
 
 		$resql = $this->db->query($sql);
 		if ($resql)

+ 2 - 2
htdocs/adherents/index.php

@@ -101,8 +101,8 @@ $now=dol_now();
 $sql = "SELECT count(*) as somme , d.fk_adherent_type";
 $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
 $sql.= " WHERE d.entity IN (".getEntity().")";
-//$sql.= " AND d.statut = 1 AND ((t.cotisation = 0 AND d.datefin IS NULL) OR d.datefin >= ".$db->idate($now).')';
-$sql.= " AND d.statut = 1 AND d.datefin >= ".$db->idate($now);
+//$sql.= " AND d.statut = 1 AND ((t.cotisation = 0 AND d.datefin IS NULL) OR d.datefin >= '".$db->idate($now)."')";
+$sql.= " AND d.statut = 1 AND d.datefin >= '".$db->idate($now)."'";
 $sql.= " AND t.rowid = d.fk_adherent_type";
 $sql.= " GROUP BY d.fk_adherent_type";
 

+ 2 - 2
htdocs/adherents/type.php

@@ -411,11 +411,11 @@ if ($rowid > 0)
 		}
 		if ($filter == 'uptodate')
 		{
-		    $sql.=" AND datefin >= ".$db->idate($now);
+		    $sql.=" AND datefin >= '".$db->idate($now)."'";
 		}
 		if ($filter == 'outofdate')
 		{
-		    $sql.=" AND datefin < ".$db->idate($now);
+		    $sql.=" AND datefin < '".$db->idate($now)."'";
 		}
 		// Count total nb of records
 		$nbtotalofrecords = 0;

+ 1 - 1
htdocs/bookmarks/class/bookmark.class.php

@@ -116,7 +116,7 @@ class Bookmark
         if ($this->fk_soc) $sql.=",fk_soc";
         $sql.= ") VALUES (";
         $sql.= ($this->fk_user > 0?"'".$this->fk_user."'":"0").",";
-        $sql.= " ".$this->db->idate($now).",";
+        $sql.= " '".$this->db->idate($now)."',";
         $sql.= " '".$this->url."', '".$this->target."',";
         $sql.= " '".$this->db->escape($this->title)."', '".$this->favicon."', '".$this->position."'";
         $sql.= ", '".$conf->entity."'";

+ 2 - 2
htdocs/comm/mailing/class/mailing.class.php

@@ -102,7 +102,7 @@ class Mailing extends CommonObject
 
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing";
 		$sql .= " (date_creat, fk_user_creat, entity)";
-		$sql .= " VALUES (".$this->db->idate($now).", ".$user->id.", ".$conf->entity.")";
+		$sql .= " VALUES ('".$this->db->idate($now)."', ".$user->id.", ".$conf->entity.")";
 
 		if (! $this->titre)
 		{
@@ -334,7 +334,7 @@ class Mailing extends CommonObject
 		$now=dol_now();
 
 		$sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
-		$sql .= " SET statut = 1, date_valid = ".$this->db->idate($now).", fk_user_valid=".$user->id;
+		$sql .= " SET statut = 1, date_valid = '".$this->db->idate($now)."', fk_user_valid=".$user->id;
 		$sql .= " WHERE rowid = ".$this->id;
 
 		dol_syslog("Mailing::valid sql=".$sql, LOG_DEBUG);

+ 3 - 3
htdocs/compta/localtax/class/localtax.class.php

@@ -84,9 +84,9 @@ class Localtax extends CommonObject
 		$sql.= "fk_user_creat,";
 		$sql.= "fk_user_modif";
         $sql.= ") VALUES (";
-		$sql.= " ".$this->db->idate($this->tms).",";
-		$sql.= " ".$this->db->idate($this->datep).",";
-		$sql.= " ".$this->db->idate($this->datev).",";
+		$sql.= " '".$this->db->idate($this->tms)."',";
+		$sql.= " '".$this->db->idate($this->datep)."',";
+		$sql.= " '".$this->db->idate($this->datev)."',";
 		$sql.= " '".$this->amount."',";
 		$sql.= " '".$this->label."',";
 		$sql.= " '".$this->note."',";

+ 2 - 2
htdocs/compta/paiement/cheque/class/remisecheque.class.php

@@ -143,8 +143,8 @@ class RemiseCheque extends CommonObject
 		$sql.= ", nbcheque";
 		$sql.= ", ref_ext";
 		$sql.= ") VALUES (";
-		$sql.= $this->db->idate($now);
-		$sql.= ", ".$this->db->idate($now);
+		$sql.= "'".$this->db->idate($now)."'";
+		$sql.= ", '".$this->db->idate($now)."'";
 		$sql.= ", ".$user->id;
 		$sql.= ", ".$account_id;
 		$sql.= ", 0";

+ 1 - 1
htdocs/compta/paiement/class/paiement.class.php

@@ -578,7 +578,7 @@ class Paiement extends CommonObject
         if (!empty($date) && $this->statut!=1)
         {
             $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
-            $sql.= " SET datep = ".$this->db->idate($date);
+            $sql.= " SET datep = '".$this->db->idate($date)."'";
             $sql.= " WHERE rowid = ".$this->id;
 
             dol_syslog(get_class($this)."::update_date sql=".$sql);

+ 1 - 1
htdocs/compta/prelevement/class/bonprelevement.class.php

@@ -967,7 +967,7 @@ class BonPrelevement extends CommonObject
                          */
                         $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_facture_demande";
                         $sql.= " SET traite = 1";
-                        $sql.= ", date_traite = ".$this->db->idate($now);
+                        $sql.= ", date_traite = '".$this->db->idate($now)."'";
                         $sql.= ", fk_prelevement_bons = ".$prev_id;
                         $sql.= " WHERE rowid = ".$fac[1];
 

+ 1 - 1
htdocs/compta/prelevement/class/rejetprelevement.class.php

@@ -104,7 +104,7 @@ class RejetPrelevement
 		$sql.= ", '".$this->db->idate($date_rejet)."'";
 		$sql.= ", ".$motif;
 		$sql.= ", ".$user->id;
-		$sql.= ", ".$this->db->idate($now);
+		$sql.= ", '".$this->db->idate($now)."'";
 		$sql.= ", ".$facturation;
 		$sql.= ")";
 

+ 6 - 6
htdocs/compta/salaries/class/paymentsalary.class.php

@@ -106,15 +106,15 @@ class PaymentSalary extends CommonObject
   
           $sql.= ") VALUES (";
   
-  		$sql.= " ".$this->db->idate($this->tms).",";
+  		$sql.= " '".$this->db->idate($this->tms).",";
   		$sql.= " '".$this->fk_user."',";
-		  $sql.= " ".$this->db->idate($this->datep).",";
-  		$sql.= " ".$this->db->idate($this->datev).",";
+		$sql.= " '".$this->db->idate($this->datep)."',";
+  		$sql.= " '".$this->db->idate($this->datev)."',";
   		$sql.= " '".$this->amount."',";
   		$sql.= " '".$this->label."',";
-  		$sql.= " ".$this->db->idate($this->datesp).",";
-  		$sql.= " ".$this->db->idate($this->dateep).",";
-  	  $sql.= " '".$this->note."',";
+  		$sql.= " '".$this->db->idate($this->datesp)."',";
+  		$sql.= " '".$this->db->idate($this->dateep)."',";
+		$sql.= " '".$this->note."',";
   		$sql.= " ".($this->fk_bank <= 0 ? "NULL" : "'".$this->fk_bank."'").",";
   		$sql.= " '".$this->fk_user_creat."',";
   		$sql.= " '".$this->fk_user_modif."'";

+ 3 - 3
htdocs/compta/tva/class/tva.class.php

@@ -100,9 +100,9 @@ class Tva extends CommonObject
 
         $sql.= ") VALUES (";
 
-		$sql.= " ".$this->db->idate($this->tms).",";
-		$sql.= " ".$this->db->idate($this->datep).",";
-		$sql.= " ".$this->db->idate($this->datev).",";
+		$sql.= " '".$this->db->idate($this->tms)."',";
+		$sql.= " '".$this->db->idate($this->datep)."',";
+		$sql.= " '".$this->db->idate($this->datev)."',";
 		$sql.= " '".$this->amount."',";
 		$sql.= " '".$this->label."',";
 		$sql.= " '".$this->note."',";

+ 1 - 1
htdocs/contrat/class/contrat.class.php

@@ -718,7 +718,7 @@ class Contrat extends CommonObject
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."contrat (datec, fk_soc, fk_user_author, date_contrat,";
 		$sql.= " fk_commercial_signature, fk_commercial_suivi, fk_projet,";
 		$sql.= " ref, entity, note_private, note_public)";
-		$sql.= " VALUES (".$this->db->idate($now).",".$this->socid.",".$user->id;
+		$sql.= " VALUES ('".$this->db->idate($now)."',".$this->socid.",".$user->id;
 		$sql.= ",".$this->db->idate($this->date_contrat);
 		$sql.= ",".($this->commercial_signature_id>0?$this->commercial_signature_id:"NULL");
 		$sql.= ",".($this->commercial_suivi_id>0?$this->commercial_suivi_id:"NULL");

+ 3 - 3
htdocs/contrat/liste.php

@@ -66,9 +66,9 @@ llxHeader();
 
 $sql = 'SELECT';
 $sql.= ' SUM('.$db->ifsql("cd.statut=0",1,0).') as nb_initial,';
-$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= ".$db->idate($now).")",1,0).') as nb_running,';
-$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < ".$db->idate($now).")",1,0).') as nb_expired,';
-$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < ".$db->idate($now - $conf->contrat->services->expires->warning_delay).")",1,0).') as nb_late,';
+$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now)."')",1,0).') as nb_running,';
+$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')",1,0).') as nb_expired,';
+$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now - $conf->contrat->services->expires->warning_delay)."')",1,0).') as nb_late,';
 $sql.= ' SUM('.$db->ifsql("cd.statut=5",1,0).') as nb_closed,';
 $sql.= " c.rowid as cid, c.ref, c.datec, c.date_contrat, c.statut,";
 $sql.= " s.nom, s.rowid as socid";

+ 2 - 2
htdocs/contrat/services.php

@@ -107,8 +107,8 @@ if ($search_service)  $sql.= " AND (p.ref LIKE '%".$db->escape($search_service).
 if ($socid > 0)       $sql.= " AND s.rowid = ".$socid;
 $filter_date1=dol_mktime(0,0,0,$op1month,$op1day,$op1year);
 $filter_date2=dol_mktime(0,0,0,$op2month,$op2day,$op2year);
-if (! empty($filter_op1) && $filter_op1 != -1 && $filter_date1 != '') $sql.= " AND date_ouverture_prevue ".$filter_op1." ".$db->idate($filter_date1);
-if (! empty($filter_op2) && $filter_op2 != -1 && $filter_date2 != '') $sql.= " AND date_fin_validite ".$filter_op2." ".$db->idate($filter_date2);
+if (! empty($filter_op1) && $filter_op1 != -1 && $filter_date1 != '') $sql.= " AND date_ouverture_prevue ".$filter_op1." '".$db->idate($filter_date1)."'";
+if (! empty($filter_op2) && $filter_op2 != -1 && $filter_date2 != '') $sql.= " AND date_fin_validite ".$filter_op2." '".$db->idate($filter_date2)."'";
 $sql .= $db->order($sortfield,$sortorder);
 $sql .= $db->plimit($limit + 1, $offset);
 

+ 1 - 1
htdocs/core/class/discount.class.php

@@ -154,7 +154,7 @@ class DiscountAbsolute
         $sql.= " amount_ht, amount_tva, amount_ttc, tva_tx,";
         $sql.= " fk_facture_source";
         $sql.= ")";
-        $sql.= " VALUES (".$this->db->idate($this->datec!=''?$this->datec:dol_now()).", ".$this->fk_soc.", ".$user->id.", '".$this->db->escape($this->description)."',";
+        $sql.= " VALUES ('".$this->db->idate($this->datec!=''?$this->datec:dol_now())."', ".$this->fk_soc.", ".$user->id.", '".$this->db->escape($this->description)."',";
         $sql.= " ".$this->amount_ht.", ".$this->amount_tva.", ".$this->amount_ttc.", ".$this->tva_tx.",";
         $sql.= " ".($this->fk_facture_source?"'".$this->fk_facture_source."'":"null");
         $sql.= ")";

+ 1 - 1
htdocs/core/class/events.class.php

@@ -127,7 +127,7 @@ class Events // extends CommonObject
 		$sql.= " ".$conf->entity.",";
 		$sql.= " '".$_SERVER['REMOTE_ADDR']."',";
 		$sql.= " ".($_SERVER['HTTP_USER_AGENT']?"'".dol_trunc($_SERVER['HTTP_USER_AGENT'],250)."'":'NULL').",";
-		$sql.= " ".$this->db->idate($this->dateevent).",";
+		$sql.= " '".$this->db->idate($this->dateevent)."',";
 		$sql.= " ".($user->id?"'".$user->id."'":'NULL').",";
 		$sql.= " '".$this->db->escape($this->description)."'";
 		$sql.= ")";

+ 1 - 1
htdocs/core/class/notify.class.php

@@ -225,7 +225,7 @@ class Notify
                         $sendto = htmlentities($sendto);
 
                         $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_contact, objet_type, objet_id, email)";
-                        $sql.= " VALUES (".$this->db->idate($now).", ".$actiondefid.", ".$obj->cid.", '".$objet_type."', ".$objet_id.", '".$this->db->escape($obj->email)."')";
+                        $sql.= " VALUES ('".$this->db->idate($now)."', ".$actiondefid.", ".$obj->cid.", '".$objet_type."', ".$objet_id.", '".$this->db->escape($obj->email)."')";
                         dol_syslog("Notify::send sql=".$sql);
                         if (! $this->db->query($sql) )
                         {

+ 13 - 8
htdocs/core/db/pgsql.class.php

@@ -534,24 +534,29 @@ class DoliDBPgsql extends DoliDB
 	 */
 	function query($query,$usesavepoint=0,$type='auto')
 	{
+		global $conf;
+		
 		$query = trim($query);
 
 		// Convert MySQL syntax to PostgresSQL syntax
 		$query=$this->convertSQLFromMysql($query,$type,($this->unescapeslashquot && $this->standard_conforming_strings));
 		//print "After convertSQLFromMysql:\n".$query."<br>\n";
 
-		// Fix bad formed requests. If request contains a date without quotes, we fix this but this should not occurs.
-/*		$loop=true;
-		while ($loop)
+		if (! empty($conf->global->MAIN_DB_AUTOFIX_BAD_SQL_REQUEST))
 		{
-			if (preg_match('/([^\'])([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9])/',$query))
+			// Fix bad formed requests. If request contains a date without quotes, we fix this but this should not occurs.
+			$loop=true;
+			while ($loop)
 			{
-				$query=preg_replace('/([^\'])([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9])/','\\1\'\\2\'',$query);
-				dol_syslog("Warning: Bad formed request converted into ".$query,LOG_WARNING);
+				if (preg_match('/([^\'])([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9])/',$query))
+				{
+					$query=preg_replace('/([^\'])([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9])/','\\1\'\\2\'',$query);
+					dol_syslog("Warning: Bad formed request converted into ".$query,LOG_WARNING);
+				}
+				else $loop=false;
 			}
-			else $loop=false;
 		}
-*/
+		
 		if ($usesavepoint && $this->transaction_opened)
 		{
 			@pg_query($this->db, 'SAVEPOINT mysavepoint');

+ 1 - 1
htdocs/core/lib/tax.lib.php

@@ -516,7 +516,7 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
                 $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'";
             }
             if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
-            if ($date_start && $date_end) $sql.= " AND pa.datep >= ".$db->idate($date_start)." AND pa.datep <= ".$db->idate($date_end);
+            if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
             $sql.= " AND (d.product_type = 1";                              // Limit to services
             $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)";       // enhance detection of service
             $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";

+ 3 - 1
htdocs/cron/class/cronjob.class.php

@@ -95,6 +95,8 @@ class Cronjob extends CommonObject
     	global $conf, $langs;
 		$error=0;
 
+		$now=dol_now();
+		
 		// Clean parameters
 
 		if (isset($this->label)) $this->label=trim($this->label);
@@ -189,7 +191,7 @@ class Cronjob extends CommonObject
 
 		$sql.= ") VALUES (";
 
-		$sql.= " ".$this->db->idate(dol_now()).",";
+		$sql.= " '".$this->db->idate($now)."',";
 		$sql.= " ".(! isset($this->jobtype)?'NULL':"'".$this->db->escape($this->jobtype)."'").",";
 		$sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").",";
 		$sql.= " ".(! isset($this->command)?'NULL':"'".$this->db->escape($this->command)."'").",";

+ 1 - 1
htdocs/fichinter/class/fichinter.class.php

@@ -812,7 +812,7 @@ class Fichinter extends CommonObject
 		if ($user->rights->ficheinter->creer)
 		{
 			$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
-			$sql.= " SET datei = ".$this->db->idate($date_delivery);
+			$sql.= " SET datei = '".$this->db->idate($date_delivery)."'";
 			$sql.= " WHERE rowid = ".$this->id;
 			$sql.= " AND entity = ".$conf->entity;
 			$sql.= " AND fk_statut = 0";

+ 1 - 1
htdocs/fourn/class/fournisseur.commande.class.php

@@ -877,7 +877,7 @@ class CommandeFournisseur extends CommonOrder
         $sql.= ", ".$conf->entity;
         $sql.= ", ".$this->socid;
         $sql.= ", '".$this->db->idate($now)."'";
-		//$sql.= ", ".$this->db->idate($now);
+		//$sql.= ", '".$this->db->idate($now)."'";
         $sql.= ", ".$user->id;
         $sql.= ", 0";
         $sql.= ", " . $this->source;

+ 2 - 2
htdocs/fourn/class/paiementfourn.class.php

@@ -146,8 +146,8 @@ class PaiementFourn extends Paiement
 
 			$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn (';
 			$sql.= 'datec, datep, amount, fk_paiement, num_paiement, note, fk_user_author, fk_bank)';
-			$sql.= ' VALUES ('.$this->db->idate($now).',';
-			$sql.= " ".$this->db->idate($this->datepaye).", '".$this->total."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($this->note)."', ".$user->id.", 0)";
+			$sql.= " VALUES ('".$this->db->idate($now).',';
+			$sql.= " '".$this->db->idate($this->datepaye)."', '".$this->total."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($this->note)."', ".$user->id.", 0)";
 
 			dol_syslog("PaiementFourn::create sql=".$sql);
 			$resql = $this->db->query($sql);

+ 2 - 2
htdocs/install/upgrade2.php

@@ -2569,7 +2569,7 @@ function migrate_project_user_resp($db,$langs,$conf)
                     $sql2.= ", fk_c_type_contact";
                     $sql2.= ", fk_socpeople";
                     $sql2.= ") VALUES (";
-                    $sql2.= $db->idate(dol_now());
+                    $sql2.= "'".$db->idate(dol_now())."'";
                     $sql2.= ", '4'";
                     $sql2.= ", ".$obj->rowid;
                     $sql2.= ", '160'";
@@ -2664,7 +2664,7 @@ function migrate_project_task_actors($db,$langs,$conf)
                     $sql2.= ", fk_c_type_contact";
                     $sql2.= ", fk_socpeople";
                     $sql2.= ") VALUES (";
-                    $sql2.= $db->idate(dol_now());
+                    $sql2.= "'".$db->idate(dol_now())."'";
                     $sql2.= ", '4'";
                     $sql2.= ", ".$obj->fk_projet_task;
                     $sql2.= ", '180'";

+ 2 - 2
htdocs/livraison/class/livraison.class.php

@@ -121,7 +121,7 @@ class Livraison extends CommonObject
 		$sql.= ", ".$conf->entity;
 		$sql.= ", ".$this->socid;
 		$sql.= ", '".$this->db->escape($this->ref_customer)."'";
-		$sql.= ", ".$this->db->idate($now);
+		$sql.= ", '".$this->db->idate($now)."'";
 		$sql.= ", ".$user->id;
 		$sql.= ", ".($this->date_delivery?"'".$this->db->idate($this->date_delivery)."'":"null");
 		$sql.= ", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address : "null");
@@ -392,7 +392,7 @@ class Livraison extends CommonObject
 					$sql = "UPDATE ".MAIN_DB_PREFIX."livraison SET";
 					$sql.= " ref='".$this->db->escape($numref)."'";
 					$sql.= ", fk_statut = 1";
-					$sql.= ", date_valid = ".$this->db->idate($now);
+					$sql.= ", date_valid = '".$this->db->idate($now)."'";
 					$sql.= ", fk_user_valid = ".$user->id;
 					$sql.= " WHERE rowid = ".$this->id;
 					$sql.= " AND fk_statut = 0";

+ 6 - 1
htdocs/projet/tasks/task.php

@@ -429,7 +429,12 @@ if ($id > 0 || ! empty($ref))
 			print '</td></tr>';
 
 			// Progress
-			print '<tr><td>'.$langs->trans("Progress").'</td><td colspan="3">';
+			print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td colspan="3">';
+			print $object->progress.' %';
+			print '</td></tr>';
+
+			// Progress
+			print '<tr><td>'.$langs->trans("ProgressCalculated").'</td><td colspan="3">';
 			print $object->progress.' %';
 			print '</td></tr>';
 

+ 1 - 1
htdocs/societe/class/address.class.php

@@ -83,7 +83,7 @@ class Address
 			$now=dol_now();
 
 			$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_address (label, fk_soc, name, datec, fk_user_creat) ";
-			$sql .= " VALUES ('".$this->db->escape($this->label)."', '".$socid."', '".$this->db->escape($this->name)."', ".$this->db->idate($now).", '".$user->id."')";
+			$sql .= " VALUES ('".$this->db->escape($this->label)."', '".$socid."', '".$this->db->escape($this->name)."', '".$this->db->idate($now)."', '".$user->id."')";
 
 			$result=$this->db->query($sql);
 			if ($result)

+ 3 - 3
htdocs/societe/class/societe.class.php

@@ -1230,9 +1230,9 @@ class Societe extends CommonObject
             }
 
             // Ecrit trace dans historique des remises
-            $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise ";
+            $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise";
             $sql.= " (datec, fk_soc, remise_client, note, fk_user_author)";
-            $sql.= " VALUES (".$this->db->idate($now).", ".$this->id.", '".$remise."',";
+            $sql.= " VALUES ('".$this->db->idate($now)."', ".$this->id.", '".$remise."',";
             $sql.= " '".$this->db->escape($note)."',";
             $sql.= " ".$user->id;
             $sql.= ")";
@@ -1241,7 +1241,7 @@ class Societe extends CommonObject
             if (! $resql)
             {
                 $this->db->rollback();
-                $this->error=$this->db->error();
+                $this->error=$this->db->lasterror();
                 return -1;
             }