diff --git a/ChangeLog b/ChangeLog
index 5afacc88e5a6f1aa46dda579a948e77d5529f3ec..a8f276f9c81fa2e21a8b448c1f896bc64216d6e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -156,6 +156,9 @@ removed. You must now use the 6 parameters way. See file modMyModule.class.php f
 
 ***** ChangeLog for 3.5.7 compared to 3.5.6 *****
 Fix: Paypal link were broken dur to SSL v3 closed.
+Fix: [ bug #1769 ] Error when installing to a PostgreSQL DB that contains numbers
+Fix: [ bug #1752 ] Date filter of margins module, filters since 12H instead of 00H
+Fix: [ bug #1757 ] Sorting breaks product/service statistics
 
 ***** ChangeLog for 3.5.6 compared to 3.5.5 *****
 Fix: Avoid missing class error for fetch_thirdparty method #1973
diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php
index 0b0bc8c8a5cbc2e6c74f8bb227785b72395a5f6a..6f494cb6f487efd43337d3eef32299081c08d150 100644
--- a/htdocs/core/db/pgsql.class.php
+++ b/htdocs/core/db/pgsql.class.php
@@ -387,7 +387,7 @@ class DoliDBPgsql extends DoliDB
 		if ((! empty($host) && $host == "socket") && ! defined('NOLOCALSOCKETPGCONNECT'))
 		{
 			$con_string = "dbname='".$name."' user='".$login."' password='".$passwd."'";    // $name may be empty
-			$this->db = pg_connect($con_string);
+			$this->db = @pg_connect($con_string);
 		}
 
 		// if local connection failed or not requested, use TCP/IP
@@ -397,7 +397,7 @@ class DoliDBPgsql extends DoliDB
 			if (! $port) $port = 5432;
 
 			$con_string = "host='".$host."' port='".$port."' dbname='".$name."' user='".$login."' password='".$passwd."'";
-			$this->db = pg_connect($con_string);
+			$this->db = @pg_connect($con_string);
 		}
 
 		// now we test if at least one connect method was a success
@@ -832,7 +832,7 @@ class DoliDBPgsql extends DoliDB
 		// Test charset match LC_TYPE (pgsql error otherwise)
 		//print $charset.' '.setlocale(LC_CTYPE,'0'); exit;
 
-		$sql='CREATE DATABASE '.$database.' OWNER '.$owner.' ENCODING \''.$charset.'\'';
+		$sql='CREATE DATABASE "'.$database.'" OWNER "'.$owner.'" ENCODING \''.$charset.'\'';
 		dol_syslog($sql,LOG_DEBUG);
 		$ret=$this->query($sql);
 		return $ret;
diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php
index e5e6d70ba66d86468c80bd3d252aa36a0bb512d5..ab12b32716e892adcb7708e0a8f25d6c844a6dc3 100644
--- a/htdocs/margin/agentMargins.php
+++ b/htdocs/margin/agentMargins.php
@@ -57,9 +57,9 @@ $pagenext = $page + 1;
 $startdate=$enddate='';
 
 if (!empty($_POST['startdatemonth']))
-  $startdate  = dol_mktime(12, 0, 0, $_POST['startdatemonth'],  $_POST['startdateday'],  $_POST['startdateyear']);
+  $startdate  = dol_mktime(0, 0, 0, $_POST['startdatemonth'],  $_POST['startdateday'],  $_POST['startdateyear']);
 if (!empty($_POST['enddatemonth']))
-  $enddate  = dol_mktime(12, 0, 0, $_POST['enddatemonth'],  $_POST['enddateday'],  $_POST['enddateyear']);
+  $enddate  = dol_mktime(23, 59, 59, $_POST['enddatemonth'],  $_POST['enddateday'],  $_POST['enddateyear']);
 
 /*
  * View
diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php
index 7d1f4da5682f0fc91085ae75acec62a6f8805f8f..fe619531f48015e665f3eabea36b93012950ca5b 100644
--- a/htdocs/product/popuprop.php
+++ b/htdocs/product/popuprop.php
@@ -3,6 +3,7 @@
  * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
  * Copyright (C) 2004      Eric Seigne          <eric.seigne@ryxeo.com>
  * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
+ * Copyright (C) 2014      Marcos GarcĂ­a        <marcosgdf@gmail.com>
  *
  * 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
@@ -71,7 +72,9 @@ llxHeader('','',$helpurl);
 $sql = "SELECT count(*) as c";
 $sql.= " FROM ".MAIN_DB_PREFIX."product";
 $sql.= ' WHERE entity IN ('.getEntity('product', 1).')';
-if (isset($type)) $sql.= " AND fk_product_type = ".$type;
+if ($type !== '') {
+	$sql.= " AND fk_product_type = ".$type;
+}
 
 $result=$db->query($sql);
 if ($result)
@@ -82,11 +85,14 @@ if ($result)
 
 $param = '';
 $title = $langs->trans("ListProductServiceByPopularity");
-if (isset($type))
-{
+if ($type !== '') {
 	$param = '&amp;type='.$type;
-	$title = $langs->trans("ListProductByPopularity");
-	if ($type == 1) $title = $langs->trans("ListServiceByPopularity");
+
+	if ($type == 1) {
+		$title = $langs->trans("ListServiceByPopularity");
+	} else {
+		$title = $langs->trans("ListProductByPopularity");
+	}
 }
 
 print_barre_liste($title, $page, "popuprop.php",$param,"","","",$num);
@@ -106,7 +112,9 @@ $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pd";
 $sql.= ", ".MAIN_DB_PREFIX."product as p";
 $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')';
 $sql.= " AND p.rowid = pd.fk_product";
-if (isset($type)) $sql.= " AND fk_product_type = ".$type;
+if ($type !== '') {
+	$sql.= " AND fk_product_type = ".$type;
+}
 $sql.= " GROUP BY (p.rowid)";
 $sql.= $db->order($sortfield,$sortorder);
 $sql.= $db->plimit($limit, $offset);