diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php
index 2788526de051245023f33a547b8e8ba353e0f418..861de271dabaccfd61a42941497aecc6f7ce15cb 100644
--- a/htdocs/accountancy/class/bookkeeping.class.php
+++ b/htdocs/accountancy/class/bookkeeping.class.php
@@ -30,6 +30,8 @@
 class BookKeeping
 {
 	var $db;
+	var $error;
+
 	var $id;
 	var $doc_date;
 	var $doc_type;
diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php
index 97d52124c0175cf78a476bb9bf41064707b115c6..d2f204c6b8cee469818b17834cd08ba6122c9d8f 100644
--- a/htdocs/accountancy/journal/purchasesjournal.php
+++ b/htdocs/accountancy/journal/purchasesjournal.php
@@ -58,8 +58,10 @@ if ($user->societe_id > 0)
 
 $action = GETPOST('action');
 
+
+
 /*
- * View
+ * Actions
  */
 
 $year_current = strftime("%Y", dol_now());
@@ -152,9 +154,6 @@ if ($result) {
 	dol_print_error($db);
 }
 
-/*
- * Actions
-*/
 // Bookkeeping Write
 if ($action == 'writebookkeeping') {
 	$now = dol_now();
@@ -237,9 +236,16 @@ if ($action == 'writebookkeeping') {
 	}
 }
 
-// export csv
 
-if ($action == 'export_csv') {
+/*
+ * View
+ */
+
+$companystatic = new Societe($db);
+
+// export csv
+if ($action == 'export_csv')
+{
 	$sep = $conf->global->ACCOUNTING_SEPARATORCSV;
 
 	header('Content-Type: text/csv');
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 3eeef6916eb21cb6adf2c5697d73d0691234759a..6d23d3a982d1f84818a6d23335a91142c22de524 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -2000,7 +2000,7 @@ if ($action == 'create')
 		{
 			$var = true;
 
-			// Add free products/services
+			// Add products/services form
 			$object->formAddObjectLine(1, $mysoc, $soc);
 
 			$parameters = array();
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 9b7eb8ea755e04ec891ec29c3038dc265ab30e1f..12fee9deb8be8c5689fc2cfcdb0c809d8f2b2e3f 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -611,6 +611,8 @@ abstract class CommonObject
 
 	    require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
 
+	require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
+
         $thirdparty = new Societe($this->db);
         $result=$thirdparty->fetch(isset($this->socid)?$this->socid:(isset($this->fk_soc)?$this->fk_soc:$this->fk_thirdparty));
         $this->client = $thirdparty;  // deprecated
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 8c460f1d93a51e1b82b55ef95bded45cbefb54c3..cc06786e6021896eabb5fb34630e3eb890998225 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -1100,7 +1100,11 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
 				$default_timezone=@date_default_timezone_get();
 			}
 		}
-		else $localtz = new DateTimeZone('UTC');
+		
+		if (empty($localtz)) {
+			$localtz = new DateTimeZone('UTC');
+		}
+		
 		$dt = new DateTime(null,$localtz);
 		$dt->setDate($year,$month,$day);
 		$dt->setTime((int) $hour, (int) $minute, (int) $second);
diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php
index 86ef648bf947965b932cd17854578f050ccec390..a69ab60c2547eb0086c8f3f0591141ff8b016b2c 100644
--- a/htdocs/core/tpl/objectline_create.tpl.php
+++ b/htdocs/core/tpl/objectline_create.tpl.php
@@ -271,7 +271,7 @@ else {
 </tr>
 
 <?php
-if (! empty($conf->service->enabled) && $dateSelector)
+if (! empty($conf->service->enabled) && $dateSelector && GETPOST('type') != '0')
 {
 	if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10;
 	else $colspan = 9;
diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
index e4fbcfbec9a073c3e79825968bc06f4ff3fb18ba..de02887abf833e55e366a1ad227808277378ff6f 100755
--- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
+++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
@@ -27,6 +27,11 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
 insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_REOPEN','Intervention opened','Executed when a intervention is re-opened','ficheinter',19);
 insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPAL_CLASSIFY_BILLED','Customer proposal set billed','Executed when a customer proposal is set to billed','propal',2);
 
+-- VPGSQL8.2 ALTER TABLE llx_contrat ALTER COLUMN fk_commercial_signature DROP NOT NULL;
+-- VPGSQL8.2 ALTER TABLE llx_contrat ALTER COLUMN fk_commercial_suivi DROP NOT NULL;
+ALTER TABLE llx_contrat MODIFY fk_commercial_signature integer NULL;
+ALTER TABLE llx_contrat MODIFY fk_commercial_suivi integer NULL;
+
 ALTER TABLE llx_notify ADD COLUMN fk_soc integer NULL after fk_action;
 ALTER TABLE llx_notify ADD COLUMN type varchar(16) DEFAULT 'email' after fk_soc;
 
diff --git a/htdocs/install/mysql/tables/llx_contrat.sql b/htdocs/install/mysql/tables/llx_contrat.sql
index 4631b660d46d176a2efab3d119c4ba0f0896c224..5efbcdfe1fa9a3dfbd71be4c5040ddad0de1e1db 100644
--- a/htdocs/install/mysql/tables/llx_contrat.sql
+++ b/htdocs/install/mysql/tables/llx_contrat.sql
@@ -33,8 +33,8 @@ create table llx_contrat
   date_cloture				datetime,
   fk_soc					integer NOT NULL,
   fk_projet					integer,
-  fk_commercial_signature	integer NOT NULL, -- obsolete
-  fk_commercial_suivi 		integer NOT NULL,	-- obsolete
+  fk_commercial_signature	integer, -- obsolete
+  fk_commercial_suivi 		integer, -- obsolete
   fk_user_author			integer NOT NULL default 0,
   fk_user_mise_en_service	integer,
   fk_user_cloture			integer,
diff --git a/htdocs/product/index.php b/htdocs/product/index.php
index 45f908237474aae81365516175bb4b0d1f5af639..4af7772f290826d6edeb225a54d5b0629413143e 100644
--- a/htdocs/product/index.php
+++ b/htdocs/product/index.php
@@ -167,7 +167,7 @@ print $total;
 print '</td></tr>';
 print '</table>';
 
-if (! empty($conf->categorie->enabled))
+if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHSTATS_ON_PRODUCTS))
 {
 	require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
 	print '<br>';
diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php
index 243b55f01cac4e6825b78973c28d4db90457ba18..b76d8a7b9f087048fa08b4c8810434f72229a999 100644
--- a/htdocs/societe/index.php
+++ b/htdocs/societe/index.php
@@ -176,7 +176,7 @@ print $total;
 print '</td></tr>';
 print '</table>';
 
-if (! empty($conf->categorie->enabled))
+if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES))
 {
 	require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
 	$elementtype = 'societe';
diff --git a/htdocs/user/card.php b/htdocs/user/card.php
index 9c2290cc6292d9b568a8e2ff073ee6be8c4a6ae7..429bcc9113027f14f790e5e73853978d9c955d09 100644
--- a/htdocs/user/card.php
+++ b/htdocs/user/card.php
@@ -37,7 +37,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
-//if (! empty($conf->agenda->enabled))require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
 if (! empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
 if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
 if (! empty($conf->multicompany->enabled)) dol_include_once('/multicompany/class/actions_multicompany.class.php');