diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php
index 4dd005fca85a09516f8db920fb9c415b29cb47d2..e269bafae6cc5f743f10573d3c47bc102982fd62 100644
--- a/htdocs/accountancy/admin/fiscalyear.php
+++ b/htdocs/accountancy/admin/fiscalyear.php
@@ -94,7 +94,6 @@ if ($result)
 		while ($i < $num && $i < $max)
         {
             $obj = $db->fetch_object($result);
-            $fiscalyearstatic->ref=$obj->rowid;
             $fiscalyearstatic->id=$obj->rowid;
             print '<tr '.$bc[$var].'>';
 			print '<td><a href="fiscalyear_card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowFiscalYear"),"technic").' '.$obj->rowid.'</a></td>';
diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php
index 423ac88b490cf5dbeac2c495af910ec15972e9f0..30cd7ae877742ed083fd60a045a9ca26931f3d60 100644
--- a/htdocs/accountancy/admin/fiscalyear_card.php
+++ b/htdocs/accountancy/admin/fiscalyear_card.php
@@ -226,7 +226,7 @@ else if ($id)
             // Ref
             print "<tr>";
             print '<td width="20%">'.$langs->trans("Ref").'</td><td>';
-            print $object->ref;
+            print $object->rowid;
             print '</td></tr>';
 
             // Label
@@ -278,7 +278,7 @@ else if ($id)
 
             // Ref
             print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td width="50%">';
-            print $object->ref;
+            print $object->rowid;
 			print '</td><td width="25%">';
 			print $linkback;
             print '</td></tr>';
diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php
index 7ce2134d0d2ac45a88f765d01efcdb4084e8569f..ab0765ff1155328cb6bc616b4574108d4e7e7e9a 100644
--- a/htdocs/accountancy/class/accountancysystem.class.php
+++ b/htdocs/accountancy/class/accountancysystem.class.php
@@ -66,8 +66,8 @@ class AccountancySystem
 			$id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_system");
 
 			if ($id > 0) {
-				$this->id = $id;
-				$result = $this->id;
+				$this->rowid = $id;
+				$result = $this->rowid;
 			} else {
 				$result = - 2;
 				$this->error = "AccountancySystem::Create Erreur $result";
diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php
index 24031b683b4f6f12d1f9195cba533b8fe80aaf83..293338c3b73815146eba091e5dc293b20b86ec3b 100644
--- a/htdocs/accountancy/class/accountingaccount.class.php
+++ b/htdocs/accountancy/class/accountingaccount.class.php
@@ -123,7 +123,7 @@ class AccountingAccount
 	 */
 	function create($user, $notrigger = 0)
 	{
-		global $conf, $langs;
+		global $conf;
 		$error = 0;
 
 		$now=dol_now();
@@ -190,7 +190,7 @@ class AccountingAccount
 		if (! $error) {
 			$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accountingaccount");
 
-			if (! $notrigger) {
+//			if (! $notrigger) {
 				// Uncomment this and change MYOBJECT to your own tag if you
 				// want this action calls a trigger.
 
@@ -200,7 +200,7 @@ class AccountingAccount
 				// $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
 				// if ($result < 0) { $error++; $this->errors=$interface->errors; }
 				// // End call triggers
-			}
+//			}
 		}
 
 		// Commit or rollback
@@ -225,8 +225,6 @@ class AccountingAccount
 	 */
 	function update($user)
 	{
-		global $langs;
-
 		$this->db->begin();
 
 		$sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount ";
@@ -294,7 +292,6 @@ class AccountingAccount
 	 */
 	function delete($user, $notrigger = 0)
 	{
-		global $conf, $langs;
 		$error = 0;
 
 		$result = $this->checkUsage();
@@ -303,8 +300,8 @@ class AccountingAccount
 
 			$this->db->begin();
 
-			if (! $error) {
-				if (! $notrigger) {
+//			if (! $error) {
+//				if (! $notrigger) {
 					// Uncomment this and change MYOBJECT to your own tag if you
 					// want this action calls a trigger.
 
@@ -314,8 +311,8 @@ class AccountingAccount
 					// $result=$interface->run_triggers('ACCOUNTANCY_ACCOUNT_DELETE',$this,$user,$langs,$conf);
 					// if ($result < 0) { $error++; $this->errors=$interface->errors; }
 					// // End call triggers
-				}
-			}
+//				}
+//			}
 
 			if (! $error) {
 				$sql = "DELETE FROM " . MAIN_DB_PREFIX . "accountingaccount";
@@ -392,8 +389,6 @@ class AccountingAccount
 	 */
 	function account_desactivate($id)
 	{
-		global $langs;
-
 		$result = $this->checkUsage();
 
 		if ($result > 0) {
@@ -427,8 +422,6 @@ class AccountingAccount
 	 */
 	function account_activate($id)
 	{
-		global $langs;
-
 		$this->db->begin();
 
 		$sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount ";
diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php
index a3a760b05705aa6d7e375883fdba352726daeabc..9dcba514ae19d5868207c600dbc3b06d066694fb 100644
--- a/htdocs/accountancy/class/bookkeeping.class.php
+++ b/htdocs/accountancy/class/bookkeeping.class.php
@@ -225,8 +225,6 @@ class BookKeeping
 	 */
 	function create($user='')
 	{
-		global $conf, $user, $langs;
-
 		$this->piece_num = 0;
 
 		// first check if line not yet in bookkeeping
@@ -355,7 +353,6 @@ class BookKeeping
 	 */
 	function create_std($user, $notrigger = 0)
 	{
-		global $conf, $langs;
 		$error = 0;
 
 		// Clean parameters
@@ -445,7 +442,7 @@ class BookKeeping
 		if (! $error) {
 			$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_bookkeeping");
 
-			if (! $notrigger) {
+//			if (! $notrigger) {
 				// Uncomment this and change MYOBJECT to your own tag if you
 				// want this action calls a trigger.
 
@@ -455,7 +452,7 @@ class BookKeeping
 				// $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
 				// if ($result < 0) { $error++; $this->errors=$interface->errors; }
 				// // End call triggers
-			}
+//			}
 		}
 
 		// Commit or rollback
@@ -481,7 +478,6 @@ class BookKeeping
 	 */
 	function update($user = 0, $notrigger = 0)
 	{
-		global $conf, $langs;
 		$error = 0;
 
 		// Clean parameters
@@ -550,8 +546,8 @@ class BookKeeping
 			$this->errors[] = "Error " . $this->db->lasterror();
 		}
 
-		if (! $error) {
-			if (! $notrigger) {
+//		if (! $error) {
+//			if (! $notrigger) {
 				// Uncomment this and change MYOBJECT to your own tag if you
 				// want this action calls a trigger.
 
@@ -561,8 +557,8 @@ class BookKeeping
 				// $result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
 				// if ($result < 0) { $error++; $this->errors=$interface->errors; }
 				// // End call triggers
-			}
-		}
+//			}
+//		}
 
 		// Commit or rollback
 		if ($error) {
@@ -587,7 +583,6 @@ class BookKeeping
 	 */
 	function delete($user, $notrigger = 0)
 	{
-		global $conf, $langs;
 		$error = 0;
 
 		$this->db->begin();
@@ -642,10 +637,10 @@ class BookKeeping
 		$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
 		$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
 
-		$resql = $this->db->query($sql);
+		dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG);
 
-		dol_syslog(get_class($this) . "::export_bookkeping sql=" . $sql, LOG_DEBUG);
 		$resql = $this->db->query($sql);
+
 		if ($resql) {
 			$this->linesexport = array ();
 
diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php
index 4e833862bd81fe94c66af7a320225dee171da96b..f2b6ba6346cdafa48fb93f961cb904f05f5f8c74 100644
--- a/htdocs/accountancy/class/html.formventilation.class.php
+++ b/htdocs/accountancy/class/html.formventilation.class.php
@@ -50,10 +50,6 @@ class FormVentilation extends Form
 	 */
 	function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey='')
 	{
-		global $langs;
-
-		$date_array = array ();
-
 		$sql  = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping';
 		$sql .= ' ORDER BY import_key DESC';
 
@@ -100,7 +96,7 @@ class FormVentilation extends Form
 	 */
 	function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array())
 	{
-		global $conf, $user, $langs;
+		global $conf;
 
 		$out = '';
 
@@ -161,7 +157,7 @@ class FormVentilation extends Form
 	 */
 	function select_pcgtype($selectid, $htmlname = 'pcg_type', $showempty = 0, $event = array())
 	{
-		global $conf, $user, $langs;
+		global $conf;
 
 		$out = '';
 
@@ -217,7 +213,7 @@ class FormVentilation extends Form
 	 */
 	function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array())
 	{
-		global $conf, $user, $langs;
+		global $conf;
 
 		$out = '';
 
diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php
index 5fc986909332f54b458120aa3fe7f7a153ed26eb..b9d3b9209f9746bef4c9d5bf7c361f7f4f45dbd9 100644
--- a/htdocs/accountancy/journal/bankjournal.php
+++ b/htdocs/accountancy/journal/bankjournal.php
@@ -553,17 +553,15 @@ else
 
 		// Bank
 		foreach ( $tabbq[$key] as $k => $mt ) {
-			if (1) {
-				print "<tr " . $bc[$var] . ">";
-				print "<td>" . $date . "</td>";
-				print "<td>" . $reflabel . "</td>";
-				print "<td>" . length_accountg($k) . "</td>";
-				print "<td>" . $langs->trans('Bank') . "</td>";
-				print "<td>" . $val["type_payment"] . "</td>";
-				print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
-				print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
-				print "</tr>";
-			}
+			print "<tr " . $bc[$var] . ">";
+			print "<td>" . $date . "</td>";
+			print "<td>" . $reflabel . "</td>";
+			print "<td>" . length_accountg($k) . "</td>";
+			print "<td>" . $langs->trans('Bank') . "</td>";
+			print "<td>" . $val["type_payment"] . "</td>";
+			print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
+			print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
+			print "</tr>";
 		}
 
 		// Third party
diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php
index 4c260f9fa991dc61d423cf82fec5841d57e21290..d80e8f3656289b8a9670a509fc369988b979c9bc 100644
--- a/htdocs/accountancy/journal/sellsjournal.php
+++ b/htdocs/accountancy/journal/sellsjournal.php
@@ -230,7 +230,6 @@ if ($action == 'writebookkeeping') {
 				$bookkeeping->doc_type = 'customer_invoice';
 				$bookkeeping->fk_doc = $key;
 				$bookkeeping->fk_docdet = $val["fk_facturedet"];
-				$bookkeeping->fk_compte = $compte->id;
 				$bookkeeping->code_tiers = '';
 				$bookkeeping->numero_compte = $k;
 				$bookkeeping->label_compte = $langs->trans("VAT");
@@ -420,7 +419,6 @@ if ($action == 'export_csv') {
 		$invoicestatic->id = $key;
 		$invoicestatic->ref = $val["ref"];
 		$invoicestatic->type = $val["type"];
-		$invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
 
 		$date = dol_print_date($db->jdate($val["date"]), 'day');
 
diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php
index 2dd6ea2b1253ef61077da478422adfcf7a626656..da062176d1381375a850b34bb5422c7ad0510cd9 100644
--- a/htdocs/comm/action/class/ical.class.php
+++ b/htdocs/comm/action/class/ical.class.php
@@ -261,7 +261,7 @@ class ICal
      */
     function ical_rrule($value)
     {
-    	$result=aray();
+    	$result=array();
         $rrule = explode(';',$value);
         foreach ($rrule as $line)
         {
diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php
index ea098ba10bb087111ba93b45c44dbc6128e78401..6896912ae7ddd6ea71012872e09ca90a6117e977 100644
--- a/htdocs/core/lib/accounting.lib.php
+++ b/htdocs/core/lib/accounting.lib.php
@@ -26,10 +26,10 @@
 /**
  *	Prepare array with list of admin tabs
  *
- *	@param	Object	$object		Object instance we show card
+ *	@param	AccountingAccount	$object		Object instance we show card
  *	@return	array				Array of tabs to show
  */
-function admin_accounting_prepare_head($object=null)
+function admin_accounting_prepare_head(AccountingAccount $object=null)
 {
 	global $langs, $conf;
 
@@ -65,10 +65,10 @@ function admin_accounting_prepare_head($object=null)
 /**
  *	Prepare array with list of tabs
  *
- *	@param	Object	$object		Accounting account
+ *	@param	AccountingAccount	$object		Accounting account
  *	@return	array				Array of tabs to show
  */
-function accounting_prepare_head($object)
+function accounting_prepare_head(AccountingAccount $object)
 {
 	global $langs, $conf;
 
diff --git a/htdocs/core/lib/fiscalyear.lib.php b/htdocs/core/lib/fiscalyear.lib.php
index 5d27760b41f9e5a41374e233b2ba9f995c0bebf1..37266b5149518c1ab01765d07f971d5276baaead 100644
--- a/htdocs/core/lib/fiscalyear.lib.php
+++ b/htdocs/core/lib/fiscalyear.lib.php
@@ -24,10 +24,10 @@
 /**
  * Prepare array with list of tabs
  *
- * @param   Object	$object		Object related to tabs
+ * @param   Fiscalyear	$object		Object related to tabs
  * @return  array				Array of tabs to show
  */
-function fiscalyear_prepare_head($object)
+function fiscalyear_prepare_head(Fiscalyear $object)
 {
 	global $langs, $conf;