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/adherents/admin/adherent.php b/htdocs/adherents/admin/adherent.php
index f86e19050e465273efd2978382c09351c934f860..1e445911b24a5e7f89071534c98a2f86279db8e0 100644
--- a/htdocs/adherents/admin/adherent.php
+++ b/htdocs/adherents/admin/adherent.php
@@ -219,7 +219,7 @@ if ($conf->facture->enabled)
 		print '<input type="hidden" name="constname" value="ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS">';
 		print '<tr '.$bc[$var].'><td>'.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").'</td>';
 		print '<td>';
-		print $form->select_produits($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS, 'constvalue_ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS');
+		$form->select_produits($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS, 'constvalue_ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS');
 		print '</td><td align="center" width="80">';
 		print '<input type="submit" class="button" value="'.$langs->trans("Update").'" name="Button">';
 		print '</td>';
diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php
index cf89e1f526ca7be5f3b295677984ed5899e64ff8..9987f9bc530ab2d2daf614a6172a58fccfd5f2ca 100644
--- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php
+++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php
@@ -27,6 +27,10 @@
  */
 abstract class ActionsAdherentCardCommon
 {
+    /**
+     * Database handler
+     * @var DoliDB
+     */
     var $db;
     var $dirmodule;
     var $targetmodule;
diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php
index 3363bf34f656cf40bd8fbad98ebaffc0862faaa0..d8a1a85debf0ff0aa07b1e6602a4949a5c988990 100644
--- a/htdocs/adherents/card.php
+++ b/htdocs/adherents/card.php
@@ -1159,7 +1159,7 @@ else
 		print '<tr><td>'.$langs->trans("LinkedToDolibarrUser").'</td><td colspan="2" class="valeur">';
 		if ($object->user_id)
 		{
-			print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none');
+			$form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none');
 		}
 		else print $langs->trans("NoDolibarrAccess");
 		print '</td></tr>';
@@ -1516,13 +1516,13 @@ else
 		print '</td><td colspan="2" class="valeur">';
 		if ($action == 'editlogin')
 		{
-			print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'userid','');
+			$form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'userid','');
 		}
 		else
 		{
 			if ($object->user_id)
 			{
-				print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none');
+				$form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none');
 			}
 			else print $langs->trans("NoDolibarrAccess");
 		}
diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php
index 7b710ba9aca9fca27fa70086ef3f3993dcc4dd66..17567f5ca842c10c8e240274f2550b8295c5cf93 100644
--- a/htdocs/adherents/card_subscriptions.php
+++ b/htdocs/adherents/card_subscriptions.php
@@ -674,13 +674,13 @@ if ($rowid)
          {
          $include=array($object->user_id,$user->id);
          }*/
-        print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'userid','');
+        $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'userid','');
     }
     else
     {
         if ($object->user_id)
         {
-            print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none');
+            $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none');
         }
         else print $langs->trans("NoDolibarrAccess");
     }
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index 8b1a456ee797bae3164435f8aed9208d027d0cb6..214476299e5e724eb30ad94653892326df97194a 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -641,10 +641,6 @@ class Adherent extends CommonObject
      */
     function update_end_date($user)
     {
-        global $conf, $langs;
-
-        $error=0;
-
         $this->db->begin();
 
         // Search for last subscription id and end date
diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php
index 5c340de1fdfd50d3379ac0268b3cbfd643a6983e..11c194526b216c06b98e3ed9b13b386805694173 100644
--- a/htdocs/adherents/class/adherent_type.class.php
+++ b/htdocs/adherents/class/adherent_type.class.php
@@ -36,6 +36,13 @@ class AdherentType extends CommonObject
     public $element = 'adherent_type';
 
     var $id;
+
+    /**
+     * @var int
+     * @deprecated Use rowid
+     */
+    public $ref;
+
     var $libelle;
     var $statut;
     var $cotisation;  // Soumis a la cotisation
diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php
index b70e212d2d2bc60bdadb863e4df29635278b02c0..7764b4d144e7d4cf7420912ace573500159ac2a6 100644
--- a/htdocs/adherents/list.php
+++ b/htdocs/adherents/list.php
@@ -152,7 +152,7 @@ $nbtotalofrecords = 0;
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
 	$resql = $db->query($sql);
-	if ($resql) $nbtotalofrecords = $db->num_rows($result);
+	if ($resql) $nbtotalofrecords = $db->num_rows($resql);
 	else dol_print_error($db);
 }
 // Add order and limit
diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php
index 0ffdc8b7e7f6e55952298d2b1cebf3121b5eb621..96e1356182538911bf5ac7484ff22909e4ca83f3 100644
--- a/htdocs/adherents/type.php
+++ b/htdocs/adherents/type.php
@@ -92,7 +92,7 @@ if ($action == 'add' && $user->rights->adherent->configurer)
 
 		if ($adht->libelle)
 		{
-			$id=$adht->create($user->id);
+			$id=$adht->create($user);
 			if ($id > 0)
 			{
 				header("Location: ".$_SERVER["PHP_SELF"]);
@@ -127,7 +127,7 @@ if ($action == 'update' && $user->rights->adherent->configurer)
 		// Fill array 'array_options' with data from add form
 		$ret = $extrafields->setOptionalsFromPost($extralabels,$adht);
 
-		$adht->update($user->id);
+		$adht->update($user);
 
 		header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$_POST["rowid"]);
 		exit;
diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php
index a069a0718c9cbd2e8189a14da9a60fcdcb1f4fe8..eed8cf2c344be9bfbaf4c422675e46a06aa4caed 100644
--- a/htdocs/admin/agenda_other.php
+++ b/htdocs/admin/agenda_other.php
@@ -133,7 +133,7 @@ print '<tr '.$bc[$var].'>'."\n";
 print '<td>'.$langs->trans("AGENDA_DEFAULT_FILTER_TYPE").'</td>'."\n";
 print '<td align="center">&nbsp;</td>'."\n";
 print '<td align="right" class="nowrap">'."\n";
-print $formactions->select_type_actions($conf->global->AGENDA_DEFAULT_FILTER_TYPE, "AGENDA_DEFAULT_FILTER_TYPE", '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), 1);
+$formactions->select_type_actions($conf->global->AGENDA_DEFAULT_FILTER_TYPE, "AGENDA_DEFAULT_FILTER_TYPE", '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), 1);
 print '</td></tr>'."\n";
 
 // AGENDA_DEFAULT_FILTER_STATUS
diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php
index 725d53dd1c31505e6e06c6954faad1cddf868fec..48d150ad7f18ac56b4e3d98c931e81a7d84f2eb2 100644
--- a/htdocs/admin/barcode.php
+++ b/htdocs/admin/barcode.php
@@ -328,7 +328,7 @@ if (! empty($conf->product->enabled))
 	print "<tr ".$bc[$var].">";
 	print '<td>'.$langs->trans("SetDefaultBarcodeTypeProducts").'</td>';
 	print '<td width="60" align="right">';
-	print $formbarcode->select_barcode_type($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE,"PRODUIT_DEFAULT_BARCODE_TYPE",1);
+	$formbarcode->select_barcode_type($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE,"PRODUIT_DEFAULT_BARCODE_TYPE",1);
 	print '</td><td align="right">';
 	print '<input type="submit" class="button" name="submit_PRODUIT_DEFAULT_BARCODE_TYPE" value="'.$langs->trans("Modify").'">';
 	print "</td>";
diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php
index db0f9de94bba06e7a9a79c5f6577e4ec94fa4fa7..1477ef5577b134dde86dd75b6135d242131a8650 100644
--- a/htdocs/admin/ihm.php
+++ b/htdocs/admin/ihm.php
@@ -117,7 +117,8 @@ if ($action == 'edit')	// Edit
     clearstatcache();
     $var=true;
 
-    print_fiche_titre($langs->trans("Language"),'','').'<br>';
+    print_fiche_titre($langs->trans("Language"),'','');
+    print '<br>';
     print '<table summary="edit" class="noborder" width="100%">';
     print '<tr class="liste_titre"><td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
 	print '<td width="20">&nbsp;</td>';
@@ -299,7 +300,8 @@ else	// Show
     $var=true;
 
     // Language
-    print_fiche_titre($langs->trans("Language"),'','').'<br>';
+    print_fiche_titre($langs->trans("Language"),'','');
+    print '<br>';
     print '<table class="noborder" width="100%">';
     print '<tr class="liste_titre"><td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td><td>&nbsp;</td></tr>';
 
diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php
index 438c99adc9722a609ef67b0a5aa4b457339ffacb..d12cd517fa7188489b6889923d7442c3bd2a2318 100644
--- a/htdocs/admin/menus.php
+++ b/htdocs/admin/menus.php
@@ -183,10 +183,10 @@ if ($action == 'edit')
 	$var=!$var;
 	print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuManager").'</td>';
 	print '<td>';
-	print $formadmin->select_menu(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED, 'MAIN_MENU_STANDARD', $dirstandard, empty($conf->global->MAIN_MENU_STANDARD_FORCED)?'':' disabled="disabled"');
+	$formadmin->select_menu(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED, 'MAIN_MENU_STANDARD', $dirstandard, empty($conf->global->MAIN_MENU_STANDARD_FORCED)?'':' disabled="disabled"');
 	print '</td>';
 	print '<td>';
-	print $formadmin->select_menu(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?$conf->global->MAIN_MENUFRONT_STANDARD:$conf->global->MAIN_MENUFRONT_STANDARD_FORCED, 'MAIN_MENUFRONT_STANDARD', $dirstandard, empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?'':' disabled="disabled"');
+	$formadmin->select_menu(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?$conf->global->MAIN_MENUFRONT_STANDARD:$conf->global->MAIN_MENUFRONT_STANDARD_FORCED, 'MAIN_MENUFRONT_STANDARD', $dirstandard, empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?'':' disabled="disabled"');
 	print '</td>';
 	print '</tr>';
 
@@ -194,10 +194,10 @@ if ($action == 'edit')
 	$var=!$var;
 	print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuSmartphoneManager").'</td>';
 	print '<td>';
-	print $formadmin->select_menu(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED, 'MAIN_MENU_SMARTPHONE', array_merge($dirstandard,$dirsmartphone), empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?'':' disabled="disabled"');
+	$formadmin->select_menu(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED, 'MAIN_MENU_SMARTPHONE', array_merge($dirstandard,$dirsmartphone), empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?'':' disabled="disabled"');
 	print '</td>';
 	print '<td>';
-	print $formadmin->select_menu(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$conf->global->MAIN_MENUFRONT_SMARTPHONE:$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED, 'MAIN_MENUFRONT_SMARTPHONE', array_merge($dirstandard,$dirsmartphone), empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?'':' disabled="disabled"');
+	$formadmin->select_menu(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$conf->global->MAIN_MENUFRONT_SMARTPHONE:$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED, 'MAIN_MENUFRONT_SMARTPHONE', array_merge($dirstandard,$dirsmartphone), empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?'':' disabled="disabled"');
 	print '</td>';
 	print '</tr>';
 
diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php
index ff015884bbc0bc90c6a054d45c47198d6c0e0aa6..f962592d5a5e3d2737fdd024de6596eb56124c4c 100644
--- a/htdocs/admin/menus/edit.php
+++ b/htdocs/admin/menus/edit.php
@@ -299,7 +299,7 @@ if ($action == 'create')
     // Handler
     print '<tr><td class="fieldrequired">'.$langs->trans('MenuHandler').'</td>';
     print '<td>';
-    print $formadmin->select_menu_families($menu_handler,'menu_handler',$dirmenu);
+    $formadmin->select_menu_families($menu_handler,'menu_handler',$dirmenu);
     print '</td>';
     print '<td>'.$langs->trans('DetailMenuHandler').'</td></tr>';
 
diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php
index 3bff5c29118bc218ed7820d6efd964b7cab31629..fe7a9f73a200315434fc36f00b16f1d977bd953d 100644
--- a/htdocs/admin/prelevement.php
+++ b/htdocs/admin/prelevement.php
@@ -149,7 +149,7 @@ print '</tr>';
 // Bank account (from Banks module)
 print '<tr class="impair"><td>'.$langs->trans("BankToReceiveWithdraw").'</td>';
 print '<td align="left">';
-print $form->select_comptes($conf->global->PRELEVEMENT_ID_BANKACCOUNT,'PRELEVEMENT_ID_BANKACCOUNT',0,"courant=1",1);
+$form->select_comptes($conf->global->PRELEVEMENT_ID_BANKACCOUNT,'PRELEVEMENT_ID_BANKACCOUNT',0,"courant=1",1);
 print '</td></tr>';
 
 // ICS
diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php
index 9d5317fdd88efb5ee6bf9366d39e13c0f02d5192..aec78f8aaace2956849d26ca6e13f83052845518 100644
--- a/htdocs/admin/tools/dolibarr_export.php
+++ b/htdocs/admin/tools/dolibarr_export.php
@@ -97,7 +97,7 @@ jQuery(document).ready(function() {
 		if (jQuery("#select_sql_compat").val() == 'POSTGRESQL')
 		{
 			jQuery("#checkbox_dump_disable-add-locks").attr('checked',true);
-		};
+		}
 	});
 
 	<?php
diff --git a/htdocs/admin/tools/eaccelerator.php b/htdocs/admin/tools/eaccelerator.php
index 8f82f33d03949b33c7090045025b5bfe6b7a0fa4..d457be07b8e853c932141c0620057ae86af70839 100644
--- a/htdocs/admin/tools/eaccelerator.php
+++ b/htdocs/admin/tools/eaccelerator.php
@@ -91,7 +91,7 @@ function compare($x, $y)
  */
 function revcompare($x, $y)
 {
-	global $sortby, $langs;
+	global $sortby;
 
 	if ( $x[$sortby] == $y[$sortby] )
 	return 0;
diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php
index 721692145a184a508580524d3a217af3f682b525..1668e4f4c672c45b1c0666336dffd950590b3765 100644
--- a/htdocs/admin/tools/export.php
+++ b/htdocs/admin/tools/export.php
@@ -469,7 +469,6 @@ function backup_tables($outputfile, $tables='*')
 
 	        $sql='SELECT * FROM '.$table;
 	        $result = $db->query($sql);
-	        $num_fields = $db->num_rows($result);
 	        while($row = $db->fetch_row($result))
 	        {
 	            // For each row of data we print a line of INSERT
diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php
index fe577419eaf3f8fe7011a39da4113290c8d8b67e..309bf1d935ee5ff5a2a8fdfd14bcf1581f4e7603 100644
--- a/htdocs/admin/tools/listevents.php
+++ b/htdocs/admin/tools/listevents.php
@@ -102,7 +102,7 @@ if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin)
 	{
 		$error++;
 		dol_syslog($securityevent->error, LOG_ERR);
-		$db->rolback();
+		$db->rollback();
 	}
 }
 
diff --git a/htdocs/asterisk/wrapper.php b/htdocs/asterisk/wrapper.php
index d0e3ec633a58199e27d4bef61ba575f504f29887..e0f115e31c51119a75ae4ab39e2cecd16b076c13 100644
--- a/htdocs/asterisk/wrapper.php
+++ b/htdocs/asterisk/wrapper.php
@@ -41,7 +41,7 @@ if (! defined('NOREQUIREAJAX'))   define('NOREQUIREAJAX','1');
 /**
  * Empty header
  *
- * @return	none
+ * @return	void
  */
 function llxHeader()
 {
@@ -53,7 +53,7 @@ function llxHeader()
 /**
  * Empty footer
  *
- * @return	none
+ * @return	void
  */
 function llxFooter()
 {
diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php
index a2e2468501743a476c72114846a9d764e75bb119..071d1f32bdaa8f31fe1a489a8775880b483eea23 100644
--- a/htdocs/barcode/codeinit.php
+++ b/htdocs/barcode/codeinit.php
@@ -211,7 +211,8 @@ if ($conf->societe->enabled)
 {
 	$nbno=$nbtotal=0;
 
-	print_fiche_titre($langs->trans("BarcodeInitForThirdparties"),'','').'<br>'."\n";
+	print_fiche_titre($langs->trans("BarcodeInitForThirdparties"),'','');
+	print '<br>'."\n";
 	$sql="SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."societe where barcode IS NULL or barcode = ''";
 	$resql=$db->query($sql);
 	if ($resql)
@@ -251,7 +252,9 @@ if ($conf->product->enabled || $conf->product->service)
 
 	$nbno=$nbtotal=0;
 
-	print_fiche_titre($langs->trans("BarcodeInitForProductsOrServices"),'','').'<br>'."\n";
+	print_fiche_titre($langs->trans("BarcodeInitForProductsOrServices"),'','');
+	print '<br>'."\n";
+
 	$sql ="SELECT count(rowid) as nb, fk_product_type, datec";
 	$sql.=" FROM ".MAIN_DB_PREFIX."product";
 	$sql.=" WHERE barcode IS NULL OR barcode = ''";
diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php
index 0ce692674b17235e5a1e715aba87518dbb4d48d2..fd89390f3db7c374d9ce1e19811c93073d1917d3 100644
--- a/htdocs/barcode/printsheet.php
+++ b/htdocs/barcode/printsheet.php
@@ -360,7 +360,7 @@ print '<br>';
 print '<input id="fillfromproduct" type="radio" '.((GETPOST("selectorforbarcode")=='fillfromproduct')?'checked="checked" ':'').'name="selectorforbarcode" value="fillfromproduct" class="radiobarcodeselect"> '.$langs->trans("FillBarCodeTypeAndValueFromProduct").' &nbsp; ';
 print '<br>';
 print '<div class="showforproductselector">';
-print $form->select_produits(GETPOST('productid'), 'productid', '');
+$form->select_produits(GETPOST('productid'), 'productid', '');
 print ' &nbsp; <input type="submit" id="submitproduct" name="submitproduct" class="button" value="'.(dol_escape_htmltag($langs->trans("GetBarCode"))).'">';
 print '</div>';
 
diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php
index a9d2d7eb6c065627182fac58c4eb96cec06cb12e..ee6003d0119712c9c86ff4a55c7b18a7d6c4cdcb 100644
--- a/htdocs/bookmarks/bookmarks.lib.php
+++ b/htdocs/bookmarks/bookmarks.lib.php
@@ -38,8 +38,6 @@ function printBookmarksList($aDb, $aLangs)
 	require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php';
 	if (! isset($conf->global->BOOKMARKS_SHOW_IN_MENU)) $conf->global->BOOKMARKS_SHOW_IN_MENU=5;
 
-	$bookm = new Bookmark($db);
-
 	$langs->load("bookmarks");
 
 	$url= $_SERVER["PHP_SELF"].(! empty($_SERVER["QUERY_STRING"])?'?'.$_SERVER["QUERY_STRING"]:'');
diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php
index 748a4d9b7fa4d7e9c757e0b07c2189d7cafe4202..e00772a0af561a256c046bce4d92ab3a9b1fb222 100644
--- a/htdocs/bookmarks/list.php
+++ b/htdocs/bookmarks/list.php
@@ -94,9 +94,12 @@ if ($resql)
     print "<tr class=\"liste_titre\">";
     //print "<td>&nbsp;</td>";
     print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"bid","","",'align="left"',$sortfield,$sortorder);
-    print_liste_field_titre($langs->trans("Title"),'','')."</td>";
-    print_liste_field_titre($langs->trans("Link"),'','')."</td>";
-    print_liste_field_titre($langs->trans("Target"),'','','','','align="center"')."</td>";
+    print_liste_field_titre($langs->trans("Title"),'','');
+    print "</td>";
+    print_liste_field_titre($langs->trans("Link"),'','');
+    print "</td>";
+    print_liste_field_titre($langs->trans("Target"),'','','','','align="center"');
+    print "</td>";
     print_liste_field_titre($langs->trans("Owner"),$_SERVER["PHP_SELF"],"u.lastname","","",'align="center"',$sortfield,$sortorder);
     print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"b.dateb","","",'align="center"',$sortfield,$sortorder);
     print_liste_field_titre($langs->trans("Position"),$_SERVER["PHP_SELF"],"b.position","","",'align="right"',$sortfield,$sortorder);
diff --git a/htdocs/cashdesk/tpl/validation2.tpl.php b/htdocs/cashdesk/tpl/validation2.tpl.php
index b00268d7b0aafa7f64cf2ddbc5d3fca11696716c..7bc7999d377ca1d60834448a2cb16639f196b725 100644
--- a/htdocs/cashdesk/tpl/validation2.tpl.php
+++ b/htdocs/cashdesk/tpl/validation2.tpl.php
@@ -31,7 +31,7 @@ $langs->load("bills");
 	function popupTicket()
 	{
 		largeur = 600;
-		hauteur = 500
+		hauteur = 500;
 		opt = 'width='+largeur+', height='+hauteur+', left='+(screen.width - largeur)/2+', top='+(screen.height-hauteur)/2+'';
 		window.open('validation_ticket.php?facid=<?php echo $_GET['facid']; ?>', '<?php echo $langs->trans('PrintTicket') ?>', opt);
 	}
diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php
index 61ab169029f0e7a31e714243cc65619168917bc7..0746475ecece0a0fd90514372c2d24ec04540a04 100644
--- a/htdocs/categories/categorie.php
+++ b/htdocs/categories/categorie.php
@@ -278,7 +278,7 @@ if ($socid)
 
 	// Address
 	print '<tr><td valign="top">'.$langs->trans('Address').'</td><td colspan="3">';
-    print dol_print_address($soc->address,'gmap','thirdparty',$soc->id);
+    dol_print_address($soc->address,'gmap','thirdparty',$soc->id);
     print '</td></tr>';
 
 	// Zip / Town
@@ -609,7 +609,7 @@ else if ($id || $ref)
  * 	@param		Object		$object				Object we want to see categories it can be classified into
  * 	@param		int			$typeid				Type of category (0, 1, 2, 3)
  *  @param		int			$socid				Id thirdparty
- *  @param		string		$showclassifyform	1=Add form to 'Classify', 0=Do not show form to 'Classify'
+ *  @param		int		$showclassifyform	1=Add form to 'Classify', 0=Do not show form to 'Classify'
  *  @return		int			0
  */
 function formCategory($db,$object,$typeid,$socid=0,$showclassifyform=1)
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index de8d494f9fcc1abf7a51ab048399fed5964b459f..f5828ecdea70306f36d4bd5c7c06561624640ce9 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -297,7 +297,6 @@ class Categorie extends CommonObject
 			// FIXME le hook fait double emploi avec le trigger !!
 			$hookmanager->initHooks(array('HookCategorydao'));
 			$parameters=array();
-			$action='update';
 			$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
 			if (empty($reshook))
 			{
@@ -334,7 +333,7 @@ class Categorie extends CommonObject
 	 * 	Delete a category from database
 	 *
 	 * 	@param	User	$user		Object user that ask to delete
-	 *	@return	void
+	 *	@return	int <0 KO >0 OK
 	 */
 	function delete($user)
 	{
@@ -689,7 +688,9 @@ class Categorie extends CommonObject
 	 */
 	function containsObject($type, $object_id)
 	{
-		$field = ''; $classname = ''; $category_table = ''; $object_table = '';
+		$field = '';
+		$category_table = '';
+
 		if ($type == 'product') {
 			$field = 'product';
 		}
@@ -726,7 +727,7 @@ class Categorie extends CommonObject
 	/**
 	 * Return childs of a category
 	 *
-	 * @return	void
+	 * @return	array|int   <0 KO, array ok
 	 */
 	function get_filles()
 	{
@@ -1045,7 +1046,7 @@ class Categorie extends CommonObject
 	 *	Retourne les categories de premier niveau (qui ne sont pas filles)
 	 *
 	 *	@param		int		$type		Type of category
-	 *	@return		void
+	 *	@return		array
 	 */
 	function get_main_categories($type=null)
 	{
@@ -1058,7 +1059,7 @@ class Categorie extends CommonObject
 	 *
 	 * @param	string	$sep	Separator
 	 * @param	string	$url	Url
-	 * @return	void
+	 * @return	array
 	 */
 	function print_all_ways($sep = " &gt;&gt; ", $url='')
 	{
@@ -1088,7 +1089,7 @@ class Categorie extends CommonObject
 	/**
 	 *	Retourne un tableau contenant la liste des categories meres
 	 *
-	 *	@return		void
+	 *	@return	int|array <0 KO, array OK
 	 */
 	function get_meres()
 	{
@@ -1123,7 +1124,7 @@ class Categorie extends CommonObject
 	 * 	Retourne dans un tableau tous les chemins possibles pour arriver a la categorie
 	 * 	en partant des categories principales, representes par des tableaux de categories
 	 *
-	 *	@return		void
+	 *	@return	array
 	 */
 	function get_all_ways()
 	{
@@ -1315,7 +1316,7 @@ class Categorie extends CommonObject
 			$originImage = $dir . $file['name'];
 
 			// Cree fichier en taille origine
-			$result=dol_move_uploaded_file($file['tmp_name'], $originImage, 1, 0, 0);
+			dol_move_uploaded_file($file['tmp_name'], $originImage, 1, 0, 0);
 
 			if (file_exists($originImage))
 			{
@@ -1560,8 +1561,6 @@ class Categorie extends CommonObject
      */
     function initAsSpecimen()
     {
-        global $user,$langs,$conf;
-
         dol_syslog(get_class($this)."::initAsSpecimen");
 
         // Initialise parametres
diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php
index c54d7d889b2b8bb49320e18f6b53ede6fc713e3d..36a44f4bdda5a7c86dc4ed18018f5ea7a165993d 100644
--- a/htdocs/categories/photos.php
+++ b/htdocs/categories/photos.php
@@ -66,7 +66,9 @@ if ($id > 0)
 
 if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
 {
-    if ($object->id) $result = $object->add_photo($upload_dir, $_FILES['userfile']);
+    if ($object->id) {
+	    $object->add_photo($upload_dir, $_FILES['userfile']);
+    }
 }
 
 if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && $user->rights->categorie->creer)
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index 223c00afc6e509ac90068c8a1986287793cba4e6..94ce48161f53438941f575ce8e993c6ba508ee97 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -37,27 +37,67 @@ class ActionComm extends CommonObject
     public $table_rowid = 'id';
     protected $ismultientitymanaged = 1;	// 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
 
+    /**
+     * Id of the event
+     * @var int
+     */
     var $id;
 
+    /**
+     * Id of the event. Use $id as possible
+     * @var int
+     */
+    public $ref;
+
     var $type_id;		// Id into parent table llx_c_actioncomm (used only if option to use type is set)
     var $type_code;		// Code into parent table llx_c_actioncomm (used only if option to use type is set). With default setup, should be AC_OTH_AUTO or AC_OTH.
     var $type;			// Label into parent table llx_c_actioncomm (used only if option to use type is set)
     var $type_color;	// Color into parent table llx_c_actioncomm (used only if option to use type is set)
     var $code;			// Free code to identify action. Ie: Agenda trigger add here AC_TRIGGERNAME ('AC_COMPANY_CREATE', 'AC_PROPAL_VALIDATE', ...)
+
     var $label;
 
+    /**
+     * @var string
+     * @deprecated Use $label
+     */
+    public $libelle;
+
     var $datec;			// Date creation record (datec)
     var $datem;			// Date modification record (tms)
-    var $author;		// Object user that create action 	//deprecated
-    var $usermod;		// Object user that modified action	// deprecated
+
+    /**
+     * Object user that create action
+     * @var User
+     * @deprecated
+     */
+    var $author;
+
+    /**
+     * Object user that modified action
+     * @var User
+     * @deprecated
+     */
+    var $usermod;
     var $authorid;		// Id user that create action
     var $usermodid;		// Id user that modified action
 
     var $datep;			// Date action start (datep)
     var $datef;			// Date action end (datep2)
-    var $durationp = -1;      // -1=Unkown duration			// deprecated
+
+    /**
+     * @var int -1=Unkown duration
+     * @deprecated
+     */
+    var $durationp = -1;
     var $fulldayevent = 0;    // 1=Event on full day
-    var $punctual = 1;        // Milestone					// deprecated. Milestone is already event with end date = start date
+
+    /**
+     * Milestone
+     * @var int
+     * @deprecated Milestone is already event with end date = start date
+     */
+    var $punctual = 1;
     var $percentage;    // Percentage
     var $location;      // Location
 
@@ -68,14 +108,41 @@ class ActionComm extends CommonObject
 	var $userassigned = array();	// Array of user ids
     var $userownerid;		// Id of user owner
     var $userdoneid;	// Id of user done
-    var $usertodo;		// Object user of owner				// deprecated
-    var $userdone;	 	// Object user that did action		// deprecated
+
+    /**
+     * Object user of owner
+     * @var User
+     * @deprecated
+     */
+    var $usertodo;
+
+    /**
+     * Object user that did action
+     * @var User
+     * @deprecated
+     */
+    var $userdone;
 
     var $socid;
     var $contactid;
-    var $societe;		// Company linked to action (optional)
-    var $contact;		// Contact linked to action (optional)
-    var $fk_project;	// Id of project (optional)
+
+    /**
+     * Company linked to action (optional)
+     * @var Societe|null
+     */
+    var $societe;
+
+    /**
+     * Contact linked to action (optional)
+     * @var Contact|null
+     */
+    var $contact;
+
+    /**
+     * Id of project (optional)
+     * @var int
+     */
+    var $fk_project;
 
     // Properties for links to other objects
     var $fk_element;    // Id of record
@@ -95,8 +162,6 @@ class ActionComm extends CommonObject
      */
     function __construct($db)
     {
-    	global $langs;
-
         $this->db = $db;
 
         $this->societe = new stdClass();	// deprecated
@@ -239,7 +304,6 @@ class ActionComm extends CommonObject
 				{
 			        if (! is_array($val))	// For backward compatibility when val=id
 			        {
-			        	$tmpid=$val;
 			        	$val=array('id'=>$val);
 			        }
 					
@@ -421,9 +485,7 @@ class ActionComm extends CommonObject
      */
     function fetch_userassigned()
     {
-        global $langs;
-
-        $sql.="SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency";
+        $sql ="SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency";
 		$sql.=" FROM ".MAIN_DB_PREFIX."actioncomm_resources";
 		$sql.=" WHERE element_type = 'user' AND fk_actioncomm = ".$this->id;
 		$resql2=$this->db->query($sql);
@@ -885,7 +947,7 @@ class ActionComm extends CommonObject
      * 		@param	int		$overwritepicto		1=Overwrite picto
      *		@return	string						Chaine avec URL
      */
-    function getNomUrl($withpicto=0,$maxlength=0,$classname='',$option='',$overwritepicto='')
+    function getNomUrl($withpicto=0,$maxlength=0,$classname='',$option='',$overwritepicto=0)
     {
         global $conf,$langs;
 
@@ -1145,7 +1207,7 @@ class ActionComm extends CommonObject
      */
     function initAsSpecimen()
     {
-        global $user,$langs,$conf,$user;
+        global $user;
 
         $now=dol_now();
 
diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php
index 77dfea739e123dd6560efe8dd750a70760399320..56465d45fdb63525821646e09d210926f397a374 100644
--- a/htdocs/comm/action/class/cactioncomm.class.php
+++ b/htdocs/comm/action/class/cactioncomm.class.php
@@ -99,10 +99,10 @@ class CActionComm
     /**
      *  Return list of event types: array(id=>label) or array(code=>label)
      *
-     *  @param	int			$active     	1 or 0 to filter on event state active or not ('' by default = no filter)
+     *  @param	string|int			$active     	1 or 0 to filter on event state active or not ('' by default = no filter)
      *  @param	string		$idorcode		'id' or 'code'
      *  @param	string		$excludetype	Type to exclude
-     *  @param	string		$onlyautoornot	Group list by auto events or not
+     *  @param	int		$onlyautoornot	Group list by auto events or not
      *  @return mixed      					Array of all event types if OK, <0 if KO
      */
     function liste_array($active='',$idorcode='id',$excludetype='',$onlyautoornot=0)
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/comm/action/index.php b/htdocs/comm/action/index.php
index 91e5dd9f1d21691f415b709ec2fa1a5abede7961..d9d17a0ea712e645327376a9386b9af3856f47c6 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -1144,7 +1144,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
                 	$ponct=($event->date_start_in_calendar == $event->date_end_in_calendar);
 
                     // Define $color (Hex string like '0088FF') and $cssclass of event
-                    $color=-1; $cssclass=''; $colorindex=-1;
+                    $color=-1; $colorindex=-1;
        				if (in_array($user->id, $keysofuserassigned))
 					{
 						$nummytasks++; $cssclass='family_mytasks';
diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php
index b8c913df271f1f436bbc7e4689f881aee690cef1..8fd26b52b7f82ec6b6c8aaf4fb5a0c8ad5186a4a 100644
--- a/htdocs/comm/action/listactions.php
+++ b/htdocs/comm/action/listactions.php
@@ -313,7 +313,7 @@ if ($resql)
 		$actionstatic->id=$obj->id;
 		$actionstatic->type_code=$obj->type_code;
 		$actionstatic->type_label=$obj->type_label;
-		$actionstatic->libelle=$obj->label;
+		$actionstatic->label=$obj->label;
 		print $actionstatic->getNomUrl(1,28);
 		print '</td>';
 
diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php
index 831a019d04ef45e1b3838ddefa72707ae503810b..3df775496098d2e2271d50c4eecbeb30e388b90e 100644
--- a/htdocs/comm/action/peruser.php
+++ b/htdocs/comm/action/peruser.php
@@ -804,7 +804,7 @@ $db->close();
  * @param   int		$minheight      Minimum height for each event. 60px by default.
  * @param	boolean	$showheader		Show header
  * @param	array	$colorsbytype	Array with colors by type
- * @param	string	$var			true or false for alternat style on tr/td
+ * @param	bool	$var			true or false for alternat style on tr/td
  * @return	void
  */
 function show_day_events2($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60, $showheader=false, $colorsbytype=array(), $var=false)
diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index 74e29fcd3b21ab495222488a16ada50cb4e52021..450a462c751e27136665522af6d6105c894a6d70 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -909,7 +909,7 @@ if ($id > 0)
 	// Addresses list
 	if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) && ! empty($conf->global->MAIN_REPEATADDRESSONEACHTAB))
 	{
-		$result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
+		show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
 	}
 
     if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php
index 4129b561ed1abfd82afac9d520c4d18f754fabd2..427b2201d521a2da5934c67fe6b28ea9ec785bf7 100644
--- a/htdocs/comm/index.php
+++ b/htdocs/comm/index.php
@@ -434,7 +434,7 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TO
 			while ($i < $num)
 			{
 				$obj = $db->fetch_object($resql);
-				print "<tr ".$bc[$var]."><td><a href=\"../contrat/card.php?id=".$obj->contratid."\">".img_object($langs->trans("ShowContract","contract"))." ".$obj->ref."</a></td>";
+				print "<tr ".$bc[$var]."><td><a href=\"../contrat/card.php?id=".$obj->contratid."\">".img_object($langs->trans("ShowContract","contract"), 'contract')." ".$obj->ref."</a></td>";
 				print '<td>';
                 $companystatic->id=$objp->rowid;
                 $companystatic->name=$objp->name;
diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php
index 75f2399017bb0b3a4b099c66c531320095840ed3..ff129a557e88f60dde91c7ad3061ba87427697e9 100644
--- a/htdocs/comm/mailing/cibles.php
+++ b/htdocs/comm/mailing/cibles.php
@@ -118,8 +118,7 @@ if ($action == 'add')
 if (GETPOST('clearlist'))
 {
 	// Chargement de la classe
-	$classname = "MailingTargets";
-	$obj = new $classname($db);
+	$obj = new MailingTargets($db);
 	$obj->clear_target($id);
 
 	header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
@@ -135,8 +134,7 @@ if ($action == 'delete')
 	{
 		if (!empty($id))
 		{
-			$classname = "MailingTargets";
-			$obj = new $classname($db);
+			$obj = new MailingTargets($db);
 			$obj->update_nb($id);
 
 			header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 15ce2ccd33022473c0cc4be0519b65c16c421204..ca4c51c3f4c44386ee45828a8b24cf1b891beee7 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -296,15 +296,15 @@ class Propal extends CommonObject
      *		et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
      *
      * 		@param    	string		$desc				Description de la ligne
-     * 		@param    	double		$pu_ht				Prix unitaire
-     * 		@param    	double		$qty             	Quantite
-     * 		@param    	double		$txtva           	Taux de tva
-     * 		@param		double		$txlocaltax1		Local tax 1 rate
-     *  	@param		double		$txlocaltax2		Local tax 2 rate
+     * 		@param    	float		$pu_ht				Prix unitaire
+     * 		@param    	float		$qty             	Quantite
+     * 		@param    	float		$txtva           	Taux de tva
+     * 		@param		float		$txlocaltax1		Local tax 1 rate
+     *  	@param		float		$txlocaltax2		Local tax 2 rate
      *		@param    	int			$fk_product      	Id du produit/service predefini
-     * 		@param    	double		$remise_percent  	Pourcentage de remise de la ligne
+     * 		@param    	float		$remise_percent  	Pourcentage de remise de la ligne
      * 		@param    	string		$price_base_type	HT or TTC
-     * 		@param    	double		$pu_ttc             Prix unitaire TTC
+     * 		@param    	float		$pu_ttc             Prix unitaire TTC
      * 		@param    	int			$info_bits			Bits de type de lignes
      *      @param      int			$type               Type of line (product, service)
      *      @param      int			$rang               Position of line
@@ -320,7 +320,7 @@ class Propal extends CommonObject
      *
      *    	@see       	add_product
      */
-	function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_option=0)
+	function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_option=0)
     {
     	global $mysoc;
 
@@ -477,14 +477,14 @@ class Propal extends CommonObject
      *  Update a proposal line
      *
      *  @param      int			$rowid           	Id de la ligne
-     *  @param      double		$pu		     	  	Prix unitaire (HT ou TTC selon price_base_type)
-     *  @param      double		$qty            	Quantity
-     *  @param      double		$remise_percent  	Remise effectuee sur le produit
-     *  @param      double		$txtva	          	Taux de TVA
-     * 	@param	  	double		$txlocaltax1		Local tax 1 rate
-     *  @param	  	double		$txlocaltax2		Local tax 2 rate
+     *  @param      float		$pu		     	  	Prix unitaire (HT ou TTC selon price_base_type)
+     *  @param      float		$qty            	Quantity
+     *  @param      float		$remise_percent  	Remise effectuee sur le produit
+     *  @param      float		$txtva	          	Taux de TVA
+     * 	@param	  	float		$txlocaltax1		Local tax 1 rate
+     *  @param	  	float		$txlocaltax2		Local tax 2 rate
      *  @param      string		$desc            	Description
-     *	@param	  	double		$price_base_type	HT ou TTC
+     *	@param	  	string		$price_base_type	HT ou TTC
      *	@param      int			$info_bits        	Miscellaneous informations
      *	@param		int			$special_code		Special code (also used by externals modules!)
      * 	@param		int			$fk_parent_line		Id of parent line (0 in most cases, used by modules adding sublevels into lines).
@@ -498,9 +498,9 @@ class Propal extends CommonObject
 	 *  @param		array		$array_option		extrafields array
      *  @return     int     		        		0 if OK, <0 if KO
      */
-	function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='', $array_option=0)
+	function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='', $array_option=0)
     {
-        global $conf,$user,$langs, $mysoc;
+        global $mysoc;
 
         dol_syslog(get_class($this)."::updateLine $rowid, $pu, $qty, $remise_percent, $txtva, $desc, $price_base_type, $info_bits");
         include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
@@ -1866,8 +1866,6 @@ class Propal extends CommonObject
      */
     function set_draft($user)
     {
-        global $conf,$langs;
-
         $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 0";
         $sql.= " WHERE rowid = ".$this->id;
 
diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php
index dc8501c37baa379f3b979d18ca5dfea559e852ff..97256c840b147c6139ec177ff0009f59d1086c04 100644
--- a/htdocs/comm/propal/class/propalestats.class.php
+++ b/htdocs/comm/propal/class/propalestats.class.php
@@ -193,8 +193,6 @@ class PropaleStats extends Stats
 	 */
 	function getAllByProduct($year)
 	{
-		global $user;
-
 		$sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg";
 		$sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product";
 		//if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
diff --git a/htdocs/comm/prospect/class/prospect.class.php b/htdocs/comm/prospect/class/prospect.class.php
index 19e56fe2cffb54b6701fa9cf9fd7d086270c219b..59f284408b84d9a9e839e43cef94f02f9f2139f6 100644
--- a/htdocs/comm/prospect/class/prospect.class.php
+++ b/htdocs/comm/prospect/class/prospect.class.php
@@ -41,8 +41,6 @@ class Prospect extends Societe
      */
     function __construct($db)
     {
-        global $config;
-
         $this->db = $db;
 
         return 0;
@@ -56,7 +54,7 @@ class Prospect extends Societe
      */
     function load_state_board()
     {
-        global $conf, $user;
+        global $user;
 
         $this->nb=array("customers" => 0,"prospects" => 0);
         $clause = "WHERE";
diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php
index 79f952fe7fdec7f31a3322655a8978b51c598a33..99bfcb3a072e7f125d55098d8021c5653e9151c9 100644
--- a/htdocs/comm/remx.php
+++ b/htdocs/comm/remx.php
@@ -534,7 +534,7 @@ if ($socid > 0)
 	}
 	else
 	{
-		print dol_print_error($db);
+		dol_print_error($db);
 	}
 
 }
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 6c5b6c020c77665df2e69495dd1c268e76fbadd4..35834419a74b239456eb63214328129c3609ed2d 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -162,7 +162,6 @@ class Commande extends CommonOrder
             }
 
             $obj = new $classname();
-            $numref = "";
             $numref = $obj->getNextValue($soc,$this);
 
             if ($numref != "")
@@ -1079,19 +1078,19 @@ class Commande extends CommonOrder
      *	Add an order line into database (linked to product/service or not)
      *
      *	@param      string			$desc            	Description of line
-     *	@param      double			$pu_ht    	        Unit price (without tax)
-     *	@param      double			$qty             	Quantite
-     *	@param      double			$txtva           	Taux de tva force, sinon -1
-     *	@param      double			$txlocaltax1		Local tax 1 rate
-     *	@param      double			$txlocaltax2		Local tax 2 rate
+     *	@param      float			$pu_ht    	        Unit price (without tax)
+     *	@param      float			$qty             	Quantite
+     *	@param      float			$txtva           	Taux de tva force, sinon -1
+     *	@param      float			$txlocaltax1		Local tax 1 rate
+     *	@param      float			$txlocaltax2		Local tax 2 rate
      *	@param      int				$fk_product      	Id du produit/service predefini
-     *	@param      double			$remise_percent  	Pourcentage de remise de la ligne
+     *	@param      float			$remise_percent  	Pourcentage de remise de la ligne
      *	@param      int				$info_bits			Bits de type de lignes
      *	@param      int				$fk_remise_except	Id remise
      *	@param      string			$price_base_type	HT or TTC
-     *	@param      double			$pu_ttc    		    Prix unitaire TTC
-     *	@param      timestamp		$date_start       	Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
-     *	@param      timestamp		$date_end         	End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
+     *	@param      float			$pu_ttc    		    Prix unitaire TTC
+     *	@param      int		$date_start       	Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
+     *	@param      int		$date_end         	End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
      *	@param      int				$type				Type of line (0=product, 1=service)
      *	@param      int				$rang             	Position of line
      *	@param		int				$special_code		Special code (also used by externals modules!)
@@ -1285,16 +1284,16 @@ class Commande extends CommonOrder
      *	$this->client must be loaded
      *
      *	@param		int				$idproduct			Product Id
-     *	@param		double			$qty				Quantity
-     *	@param		double			$remise_percent		Product discount relative
-     * 	@param    	timestamp		$date_start         Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
-     * 	@param    	timestamp		$date_end           End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
+     *	@param		float			$qty				Quantity
+     *	@param		float			$remise_percent		Product discount relative
+     * 	@param    	int		$date_start         Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
+     * 	@param    	int		$date_end           End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
      * 	@return    	void
      *
      *	TODO	Remplacer les appels a cette fonction par generation objet Ligne
      *			insere dans tableau $this->products
      */
-    function add_product($idproduct, $qty, $remise_percent=0, $date_start='', $date_end='')
+    function add_product($idproduct, $qty, $remise_percent=0.0, $date_start='', $date_end='')
     {
         global $conf, $mysoc;
 
@@ -1692,7 +1691,6 @@ class Commande extends CommonOrder
      */
     function loadExpeditions($filtre_statut=-1)
     {
-        $num=0;
         $this->expeditions = array();
 
         $sql = 'SELECT cd.rowid, cd.fk_product,';
@@ -1961,7 +1959,7 @@ class Commande extends CommonOrder
      *	Set the order date
      *
      *	@param      User		$user       Object user making change
-     *	@param      timestamp	$date		Date
+     *	@param      int	$date		Date
      *	@return     int         			<0 if KO, >0 if OK
      */
     function set_date($user, $date)
@@ -1995,7 +1993,7 @@ class Commande extends CommonOrder
      *	Set the planned delivery date
      *
      *	@param      User			$user        		Objet utilisateur qui modifie
-     *	@param      timestamp		$date_livraison     Date de livraison
+     *	@param      int		$date_livraison     Date de livraison
      *	@return     int         						<0 si ko, >0 si ok
      */
     function set_date_livraison($user, $date_livraison)
@@ -2324,16 +2322,16 @@ class Commande extends CommonOrder
      *
      *  @param    	int				$rowid            	Id of line to update
      *  @param    	string			$desc             	Description de la ligne
-     *  @param    	double			$pu               	Prix unitaire
-     *  @param    	double			$qty              	Quantity
-     *  @param    	double			$remise_percent   	Pourcentage de remise de la ligne
-     *  @param    	double			$txtva           	Taux TVA
-     * 	@param		double			$txlocaltax1		Local tax 1 rate
-     *  @param		double			$txlocaltax2		Local tax 2 rate
+     *  @param    	float			$pu               	Prix unitaire
+     *  @param    	float			$qty              	Quantity
+     *  @param    	float			$remise_percent   	Pourcentage de remise de la ligne
+     *  @param    	float			$txtva           	Taux TVA
+     * 	@param		float			$txlocaltax1		Local tax 1 rate
+     *  @param		float			$txlocaltax2		Local tax 2 rate
      *  @param    	string			$price_base_type	HT or TTC
      *  @param    	int				$info_bits        	Miscellaneous informations on line
-     *  @param    	timestamp		$date_start        	Start date of the line
-     *  @param    	timestamp		$date_end          	End date of the line
+     *  @param    	int		$date_start        	Start date of the line
+     *  @param    	int		$date_end          	End date of the line
      * 	@param		int				$type				Type of line (0=product, 1=service)
      * 	@param		int				$fk_parent_line		Id of parent line (0 in most cases, used by modules adding sublevels into lines).
      * 	@param		int				$skip_update_total	Keep fields total_xxx to 0 (used for special lines by some modules)
@@ -2344,7 +2342,7 @@ class Commande extends CommonOrder
 	 *  @param		array			$array_option		extrafields array
      *  @return   	int              					< 0 if KO, > 0 if OK
      */
-	function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0,$txlocaltax2=0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_option=0)
+	function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_option=0)
     {
         global $conf, $mysoc;
 
@@ -2578,6 +2576,8 @@ class Commande extends CommonOrder
      */
     function update_extrafields($user)
     {
+        global $hookmanager, $conf;
+
     	$action='create';
 
     	// Actions on extra fields (by external module or standard code)
@@ -3167,7 +3167,7 @@ class Commande extends CommonOrder
 	 */
 	public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
 	{
-		global $conf,$user,$langs,$hookmanager;
+		global $conf,$langs;
 
 		$langs->load("orders");
 
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index f42920850c244c777ecf4ffcca377bb8e97f141b..0de3c54e1bad81a9cd036592d5c68caf0092c36b 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -500,7 +500,7 @@ if ($resql)
 }
 else
 {
-	print dol_print_error($db);
+	dol_print_error($db);
 }
 
 llxFooter();
diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php
index 1009b0302107c4288b0321507c04d32cabf185ef..930fee833fac8785ba1840886a16242d6e14562c 100644
--- a/htdocs/commande/orderstoinvoice.php
+++ b/htdocs/commande/orderstoinvoice.php
@@ -696,7 +696,7 @@ if (($action != 'create' && $action != 'add') || !$error)
 	}
 	else
 	{
-		print dol_print_error($db);
+		dol_print_error($db);
 	}
 
 }
diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php
index 87b7d3e62c54a9ab8b97bff42dadc4e54de6c528..024e21510e1e1a92adadd7cc9553ac56a021cbea 100644
--- a/htdocs/compta/bank/account.php
+++ b/htdocs/compta/bank/account.php
@@ -432,7 +432,7 @@ if ($id > 0 || ! empty($ref))
 	print '<td>';
 	//$filtertype=array('TIP'=>'TIP','PRE'=>'PRE',...)
 	$filtertype='';
-	print $form->select_types_paiements($paiementtype,'paiementtype',$filtertype,2,1,1,8);
+	$form->select_types_paiements($paiementtype,'paiementtype',$filtertype,2,1,1,8);
 	print '</td>';
 	print '<td><input type="text" class="flat" name="req_nb" value="'.$req_nb.'" size="2"></td>';
 	print '<td><input type="text" class="flat" name="req_desc" value="'.$req_desc.'" size="24"></td>';
diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php
index b18527854666116a6ba6bf49ffcac9c923072c6d..98c302f73202e3b4690d4f139056e2eeb95b9e2e 100644
--- a/htdocs/compta/bank/card.php
+++ b/htdocs/compta/bank/card.php
@@ -250,7 +250,7 @@ if ($action == 'create')
 	// Type
 	print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("AccountType").'</td>';
 	print '<td colspan="3">';
-	print $formbank->select_type_comptes_financiers(isset($_POST["type"])?$_POST["type"]:1,"type");
+	$formbank->select_type_comptes_financiers(isset($_POST["type"])?$_POST["type"]:1,"type");
 	print '</td></tr>';
 
 	// Currency
@@ -547,7 +547,7 @@ else
         // Type
         print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("AccountType").'</td>';
         print '<td colspan="3">';
-		print $formbank->select_type_comptes_financiers((isset($_POST["type"])?$_POST["type"]:$account->type),"type");
+		$formbank->select_type_comptes_financiers((isset($_POST["type"])?$_POST["type"]:$account->type),"type");
         print '</td></tr>';
 
 		// Currency
diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index 4343e2cb921b71f89c4252c9e5d69e22954a5218..c3bf23bdf66612b8ce94b0603dbf3e6945c3262d 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -36,7 +36,12 @@ class Account extends CommonObject
     public $element='bank_account';
     public $table_element='bank_account';
 
-    var $rowid;	 	// deprecated
+    /**
+     * //TODO: Discuss this. $rowid is preferred over $id
+     * @var
+     * @deprecated
+     */
+    var $rowid;
     var $id;
     var $ref;
     var $label;
@@ -220,7 +225,7 @@ class Account extends CommonObject
     /**
      *  Add an entry into table ".MAIN_DB_PREFIX."bank
      *
-     *  @param	timestamp	$date			Date operation
+     *  @param	int	$date			Date operation
      *  @param	string		$oper			1,2,3,4... (deprecated) or TYP,VIR,PRE,LIQ,VAD,CB,CHQ...
      *  @param	string		$label			Descripton
      *  @param	float		$amount			Amount
@@ -1288,7 +1293,7 @@ class AccountLine extends CommonObject
                 $sql.= ")";
 
                 dol_syslog(get_class($this)."::update_conciliation", LOG_DEBUG);
-                $resql = $this->db->query($sql);
+                $this->db->query($sql);
 
                 // No error check. Can fail if category already affected
             }
diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php
index b9850a7f98fbfac9a9a2298024c7779f853824f2..ac9fa10ff12bbb116281f48358aefced0ccec3fb 100644
--- a/htdocs/compta/bank/ligne.php
+++ b/htdocs/compta/bank/ligne.php
@@ -384,7 +384,7 @@ if ($result)
         if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
         {
             print '<td colspan="3">';
-            print $form->select_types_paiements($objp->fk_type,"value",'',2);
+            $form->select_types_paiements($objp->fk_type,"value",'',2);
             print '<input type="text" class="flat" name="num_chq" value="'.(empty($objp->num_chq) ? '' : $objp->num_chq).'">';
             if ($objp->receiptid)
             {
diff --git a/htdocs/compta/bank/virement.php b/htdocs/compta/bank/virement.php
index 601db34c964a16db3b22f264d64fdfd61339d7e1..3881efd5c9bcb24fd0839ecec5ab92cb2fc14880 100644
--- a/htdocs/compta/bank/virement.php
+++ b/htdocs/compta/bank/virement.php
@@ -167,11 +167,11 @@ print '</tr>';
 
 $var=false;
 print '<tr '.$bc[$var].'><td>';
-print $form->select_comptes($account_from,'account_from',0,'',1);
+$form->select_comptes($account_from,'account_from',0,'',1);
 print "</td>";
 
 print "<td>\n";
-print $form->select_comptes($account_to,'account_to',0,'',1);
+$form->select_comptes($account_to,'account_to',0,'',1);
 print "</td>\n";
 
 print "<td>";
diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php
index 20433118bbf2c842e961dfb5386c2e7218e0fbf2..407edf6332efb0feac58aa66f5ccfd7b57308c2e 100644
--- a/htdocs/compta/deplacement/card.php
+++ b/htdocs/compta/deplacement/card.php
@@ -252,7 +252,7 @@ if ($action == 'create')
 
     print "<tr>";
     print '<td width="25%" class="fieldrequired">'.$langs->trans("Type").'</td><td>';
-    print $form->select_type_fees(GETPOST('type','int'),'type',1);
+    $form->select_type_fees(GETPOST('type','int'),'type',1);
     print '</td></tr>';
 
     print "<tr>";
@@ -344,7 +344,7 @@ else if ($id)
             // Type
             print "<tr>";
             print '<td class="fieldrequired">'.$langs->trans("Type").'</td><td>';
-            print $form->select_type_fees(GETPOST('type','int')?GETPOST('type','int'):$object->type,'type',0);
+            $form->select_type_fees(GETPOST('type','int')?GETPOST('type','int'):$object->type,'type',0);
             print '</td></tr>';
 
             // Who
diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php
index 4eab354577aefffc329f46b8bac4295b824a45dc..36eb49f4ed8015acd186d7f13a669311a97f244e 100644
--- a/htdocs/compta/deplacement/class/deplacement.class.php
+++ b/htdocs/compta/deplacement/class/deplacement.class.php
@@ -376,11 +376,11 @@ class Deplacement extends CommonObject
 	 * List of types
 	 *
 	 * @param	int		$active		Active or not
-	 * @return	void
+	 * @return	array
 	 */
 	function listOfTypes($active=1)
 	{
-	   global $conf,$langs;
+	   global $langs;
 
 	   $ret=array();
 
diff --git a/htdocs/compta/dons/card.php b/htdocs/compta/dons/card.php
index 5a4170e74fee516c1d345792b7b0482eb931db4e..7bf909378b4bc55be2ac94f011db70872592c7dd 100644
--- a/htdocs/compta/dons/card.php
+++ b/htdocs/compta/dons/card.php
@@ -500,7 +500,7 @@ if (! empty($id) && $action != 'edit')
 
 	// Payment mode
 	print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
-	print $form->form_modes_reglement(null, $don->modepaiementid,'none');
+	$form->form_modes_reglement(null, $don->modepaiementid,'none');
 	print "</td></tr>\n";
 
 	print "<tr>".'<td>'.$langs->trans("Status").'</td><td>'.$don->getLibStatut(4).'</td></tr>';
diff --git a/htdocs/compta/dons/class/don.class.php b/htdocs/compta/dons/class/don.class.php
index 61e1b9cd9264931210c328bde9add39079225c1c..a8f7c11d92b6694dc337f98855dd25326c3b2311 100644
--- a/htdocs/compta/dons/class/don.class.php
+++ b/htdocs/compta/dons/class/don.class.php
@@ -450,7 +450,7 @@ class Don extends CommonObject
     function delete($rowid)
     {
 
-        $this->db-begin();
+        $this->db->begin();
 
         $sql = "DELETE FROM ".MAIN_DB_PREFIX."don WHERE rowid = $rowid AND fk_statut = 0;";
 
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 67ba28b4e476256c232b3eeb5c96a86fc0eaafa4..5f1f3998b5d24ecd2e9c1824453dfad37f3704c7 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -2736,7 +2736,7 @@ if ($action == 'create')
 	} else {
 		if ($absolute_creditnote > 0) 		// If not, link will be added later
 		{
-			if ($object->statut == 0 && $object->type != TYPE_CREDIT_NOTE && $object->type != TYPE_DEPOSIT)
+			if ($object->statut == 0 && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT)
 				print ' (' . $addabsolutediscount . ')<br>';
 			else
 				print '. ';
diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index f6c0ab1a48146c2cc3309fb8512a33fa714c4947..3c0bcf4319f19a9dedcfbbffaa23491671540acc 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -591,8 +591,7 @@ class FactureRec extends Facture
 
 		parent::initAsSpecimen($option);
 
-		$this->usenewprice = 1;		
-		
+		$this->usenewprice = 1;
 	}
 		
 }
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 42f0afc0bbbb04e619b32d74160f45638de37870..d50079f78c882de505cf4b72724e9d601b30865a 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -59,6 +59,11 @@ class Facture extends CommonInvoice
 	//! Id client
 	var $socid;
 	//! Objet societe client (to load with fetch_client method)
+
+	/**
+	 * Customer
+	 * @var Societe
+	 */
 	var $client;
 	var $author;
 	var $fk_user_author;
@@ -82,7 +87,10 @@ class Facture extends CommonInvoice
 	var $total_tva=0;
 	var $total_ttc=0;
 	var $revenuestamp;
-	var $note;			// deprecated
+	/**
+	 * @deprecated
+	 */
+	var $note;
 	var $note_private;
 	var $note_public;
 	//! 0=draft,
@@ -111,7 +119,10 @@ class Facture extends CommonInvoice
     var $fk_account;                // Id of bank account
 	var $fk_bank;					// Field to store bank id to use when payment mode is withdraw
 	var $modelpdf;
-	var $products=array();	// deprecated
+	/**
+	 * @deprecated
+	 */
+	var $products=array();
 	var $lines=array();
 	var $line;
 	var $extraparams=array();
@@ -1930,8 +1941,8 @@ class Facture extends CommonInvoice
 	 *  	@param		double		$txlocaltax2		Local tax 2 rate
 	 *		@param    	int			$fk_product      	Id of predefined product/service
 	 * 		@param    	double		$remise_percent  	Percent of discount on line
-	 * 		@param    	timestamp	$date_start      	Date start of service
-	 * 		@param    	timestamp	$date_end        	Date end of service
+	 * 		@param    	int	$date_start      	Date start of service
+	 * 		@param    	int	$date_end        	Date end of service
 	 * 		@param    	int			$ventil          	Code of dispatching into accountancy
 	 * 		@param    	int			$info_bits			Bits de type de lignes
 	 *		@param    	int			$fk_remise_except	Id discount used
@@ -2106,8 +2117,8 @@ class Facture extends CommonInvoice
 	 *  @param     	double		$pu              	Prix unitaire (HT ou TTC selon price_base_type) (> 0 even for credit note lines)
 	 *  @param     	double		$qty             	Quantity
 	 *  @param     	double		$remise_percent  	Pourcentage de remise de la ligne
-	 *  @param     	date		$date_start      	Date de debut de validite du service
-	 *  @param     	date		$date_end        	Date de fin de validite du service
+	 *  @param     	int		$date_start      	Date de debut de validite du service
+	 *  @param     	int		$date_end        	Date de fin de validite du service
 	 *  @param     	double		$txtva          	VAT Rate
 	 * 	@param		double		$txlocaltax1		Local tax 1 rate
 	 *  @param		double		$txlocaltax2		Local tax 2 rate
@@ -2946,7 +2957,7 @@ class Facture extends CommonInvoice
 	/**
 	 *  Supprime une demande de prelevement
 	 *
-	 *  @param  Use		$user       utilisateur creant la demande
+	 *  @param  User		$user       utilisateur creant la demande
 	 *  @param  int		$did        id de la demande a supprimer
 	 *  @return	int					<0 if OK, >0 if KO
 	 */
diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php
index f4d6d7670918de4ae496924f9e57be65dad914f2..d0ce1609b2a2eb72b4464a6a475dd2bc64cf5539 100644
--- a/htdocs/compta/facture/impayees.php
+++ b/htdocs/compta/facture/impayees.php
@@ -324,7 +324,7 @@ if ($action == 'remove_file')
 	$langs->load("other");
 	$upload_dir = $diroutputpdf;
 	$file = $upload_dir . '/' . GETPOST('file');
-	$ret=dol_delete_file($file,0,0,0,'');
+	$ret=dol_delete_file($file);
 	if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
 	else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
 	$action='';
@@ -482,7 +482,8 @@ if ($resql)
 		$formmail = new FormMail($db);
 
 		print '<br>';
-		print_fiche_titre($langs->trans("SendRemind"),'','').'<br>';
+		print_fiche_titre($langs->trans("SendRemind"),'','');
+		print '<br>';
 
 		$topicmail="MailTopicSendRemindUnpaidInvoices";
 		$modelmail="facture_relance";
diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php
index e2c9c94595a10b01ed82849e6911be52adfd52cc..d6260d1b34d3161580306f3eebbb3343abb67d50 100644
--- a/htdocs/compta/localtax/class/localtax.class.php
+++ b/htdocs/compta/localtax/class/localtax.class.php
@@ -249,10 +249,6 @@ class Localtax extends CommonObject
  	 */
 	function delete($user)
 	{
-		global $conf, $langs;
-
-		$error=0;
-
 		// Call trigger
 		$result=$this->call_trigger('LOCALTAX_DELETE',$user);
 		if ($result < 0) return -1;
@@ -270,7 +266,6 @@ class Localtax extends CommonObject
 			return -1;
 		}
 
-
 		return 1;
 	}
 
diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php
index 7c34cec1ed45bbd295ad52afac52a3dbd9db3161..90d6cbe8599cda83449fcee00e6adb6d9bd11cfe 100644
--- a/htdocs/compta/localtax/clients.php
+++ b/htdocs/compta/localtax/clients.php
@@ -104,7 +104,7 @@ $fsearch.='  <input type="hidden" name="modetax" value="'.$modetax.'">';
 $fsearch.='  '.$langs->trans("SalesTurnoverMinimum").': ';
 $fsearch.='  <input type="text" name="min" id="min" value="'.$min.'" size="6">';
 
-$calc=MAIN_INFO_LOCALTAX_CALC.$local;
+$calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local;
 // Affiche en-tete du rapport
 if ($conf->global->$calc==0 || $conf->global->$calc==1)	// Calculate on invoice for goods and services
 {
diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php
index b1b4aad7722eb3c4c40c5e93e3906ae21c798182..612014ac74133086f848a55d59a091de7717a273 100644
--- a/htdocs/compta/localtax/quadri_detail.php
+++ b/htdocs/compta/localtax/quadri_detail.php
@@ -124,7 +124,7 @@ $fsearch.='  <input type="hidden" name="modetax" value="'.$modetax.'">';
 //$fsearch.='  '.$langs->trans("SalesTurnoverMinimum").': ';
 //$fsearch.='  <input type="text" name="min" value="'.$min.'">';
 
-$calc=MAIN_INFO_LOCALTAX_CALC.$local;
+$calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local;
 // Affiche en-tete du rapport
 if ($conf->global->$calc==0 || $conf->global->$calc==1)	// Calculate on invoice for goods and services
 {
diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php
index c922099cd0e55d9bc5b41550f6d555fed69fa55e..13414a5b915c9c86361a03891b4b6f75403c0eb4 100644
--- a/htdocs/compta/paiement.php
+++ b/htdocs/compta/paiement.php
@@ -315,7 +315,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
             					$(\'.fieldrequireddyn\').addClass(\'fieldrequired\');
             					if ($(\'#fieldchqemetteur\').val() == \'\')
             					{
-            						var emetteur = ('.$facture->type.' == 2) ? \''.dol_escape_htmltag(MAIN_INFO_SOCIETE_NOM).'\' : jQuery(\'#thirdpartylabel\').val();
+            						var emetteur = ('.$facture->type.' == 2) ? \''.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_NOM).'\' : jQuery(\'#thirdpartylabel\').val();
             						$(\'#fieldchqemetteur\').val(emetteur);
             					}
             				}
diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php
index 0c5eeca3689418be72af93caee18ff5fd68fcc07..f87689bd2026aa563b85e208c67a580af5afb77d 100644
--- a/htdocs/compta/paiement/cheque/card.php
+++ b/htdocs/compta/paiement/cheque/card.php
@@ -355,7 +355,7 @@ if ($action == 'new')
 	print $form->select_date($filterdate,'fd',0,0,1,'',1,1);
 	print '</td></tr>';
     print '<tr><td>'.$langs->trans("BankAccount").'</td><td>';
-    print $form->select_comptes($filteraccountid,'accountid',0,'courant <> 2',1);
+    $form->select_comptes($filteraccountid,'accountid',0,'courant <> 2',1);
     print '</td></tr>';
 	print '</table>';
     print '<center>';
diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php
index 922ab54ac7c5eede970eedbca95217f8d3acf9d1..36ef0e2a1e9d66a56ba7f5c0fbd5a3eb6cf5990e 100644
--- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php
+++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php
@@ -41,6 +41,8 @@ class RemiseCheque extends CommonObject
 	//! Numero d'erreur Plage 1024-1279
 	var $errno;
 
+	public $statut;
+
 	/**
 	 *	Constructor
 	 *
@@ -274,7 +276,7 @@ class RemiseCheque extends CommonObject
 	 *	Supprime la remise en base
 	 *
 	 *	@param  User	$user 		Utilisateur qui effectue l'operation
-	 *	@return	void
+	 *	@return	int
 	 */
 	function delete($user='')
 	{
@@ -292,25 +294,23 @@ class RemiseCheque extends CommonObject
 		{
 			$num = $this->db->affected_rows($resql);
 
-			if ($num <> 1)
-	  {
-	  	$this->errno = -2;
-	  	dol_syslog("Remisecheque::Delete Erreur Lecture ID ($this->errno)");
-	  }
+			if ($num <> 1) {
+				$this->errno = -2;
+				dol_syslog("Remisecheque::Delete Erreur Lecture ID ($this->errno)");
+			}
 
-	  if ( $this->errno === 0)
-	  {
-	  	$sql = "UPDATE ".MAIN_DB_PREFIX."bank";
-	  	$sql.= " SET fk_bordereau = 0";
-	  	$sql.= " WHERE fk_bordereau = '".$this->id."'";
-
-	  	$resql = $this->db->query($sql);
-	  	if (!$resql)
-	  	{
-	  		$this->errno = -1028;
-	  		dol_syslog("RemiseCheque::Delete ERREUR UPDATE ($this->errno)");
-	  	}
-	  }
+			if ( $this->errno === 0) {
+			    $sql = "UPDATE ".MAIN_DB_PREFIX."bank";
+			    $sql.= " SET fk_bordereau = 0";
+			    $sql.= " WHERE fk_bordereau = '".$this->id."'";
+
+			    $resql = $this->db->query($sql);
+			    if (!$resql)
+			    {
+			        $this->errno = -1028;
+				    dol_syslog("RemiseCheque::Delete ERREUR UPDATE ($this->errno)");
+				}
+			}
 		}
 
 		if ($this->errno === 0)
@@ -476,7 +476,7 @@ class RemiseCheque extends CommonObject
 	 *	Build document
 	 *
 	 *	@param	string		$model 			Model name
-	 *	@param 	Tranlsate	$outputlangs	Object langs
+	 *	@param 	Translate	$outputlangs	Object langs
 	 * 	@return int        					<0 if KO, >0 if OK
 	 */
 	function generatePdf($model, $outputlangs)
@@ -693,7 +693,7 @@ class RemiseCheque extends CommonObject
      *      Set the creation date
      *
      *      @param	User		$user           Object user
-     *      @param  timestamp   $date           Date creation
+     *      @param  int   $date           Date creation
      *      @return int                 		<0 if KO, >0 if OK
      */
     function set_date($user, $date)
@@ -727,7 +727,7 @@ class RemiseCheque extends CommonObject
 	 *      Set the number of bordereau
 	 *
 	 *      @param	User		$user           Object user
-	 *      @param  timestamp   $number         number of bordereau
+	 *      @param  int   $number         number of bordereau
 	 *      @return int                 		<0 if KO, >0 if OK
 	 */
 	function set_number($user, $number)
diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php
index 2fce476af78262bd5b2f0127bac2dace1d0ff4c5..e3fb7a3c824a073a47103a9d46b11472ccb72ff9 100644
--- a/htdocs/compta/paiement/class/paiement.class.php
+++ b/htdocs/compta/paiement/class/paiement.class.php
@@ -573,7 +573,7 @@ class Paiement extends CommonObject
     /**
      *	Updates the payment date
      *
-     *  @param	timestamp	$date   New date
+     *  @param	int	$date   New date
      *  @return int					<0 if KO, 0 if OK
      */
     function update_date($date)
diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index 21417483b80f2ea0046d5157b0105458f483ddd0..3738abac4c7b40b17d04063a96cb575f9a26b94e 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -403,7 +403,7 @@ class BonPrelevement extends CommonObject
      *	Set withdrawal to credited status
      *
      *	@param	User		$user		id of user
-     *	@param 	timestamp	$date		date of action
+     *	@param 	int	$date		date of action
      *	@return	int						>0 if OK, <0 if KO
      */
     function set_infocredit($user, $date)
@@ -525,7 +525,7 @@ class BonPrelevement extends CommonObject
      *	Set withdrawal to transmited status
      *
      *	@param	User		$user		id of user
-     *	@param 	timestamp	$date		date of action
+     *	@param 	int	$date		date of action
      *	@param	string		$method		method of transmision to bank
      *	@return	int						>0 if OK, <0 if KO
      */
@@ -667,9 +667,9 @@ class BonPrelevement extends CommonObject
         {
             $obj = $this->db->fetch_object($resql);
 
-            return $obj->nb;
-
             $this->db->free($resql);
+
+            return $obj->nb;
         }
         else
         {
@@ -1167,7 +1167,7 @@ class BonPrelevement extends CommonObject
     /**
      *	Delete a notification
      *
-     *	@param	User	$user		notification user
+     *	@param	int	$user		notification user
      *	@param	string	$action		notification action
      *	@return	int					>0 if OK, <0 if KO
      */
@@ -1192,7 +1192,7 @@ class BonPrelevement extends CommonObject
      *	Add a notification
      *
      *	@param	DoliDB	$db			database handler
-     *	@param	User	$user		notification user
+     *	@param	int	$user		notification user
      *	@param	string	$action		notification action
      *	@return	int					0 if OK, <0 if KO
      */
@@ -1631,7 +1631,7 @@ class BonPrelevement extends CommonObject
      *  Note: The tag PmtInf is opened here but closed into caller
      *
      *	@param	string	$configuration	conf
-     *	@param	date	$ladate			Date
+     *	@param	int	$ladate			Date
      *	@param	int		$nombre			0 or 1
      *	@param	float	$total			Total
      *	@param	string	$CrLf			End of line character
diff --git a/htdocs/compta/prelevement/class/ligneprelevement.class.php b/htdocs/compta/prelevement/class/ligneprelevement.class.php
index 581fb3152afc1abce62ed731d0c0ee18e0a92e59..2b71c5c80040026cc57aebc4003b074a86f8e125 100644
--- a/htdocs/compta/prelevement/class/ligneprelevement.class.php
+++ b/htdocs/compta/prelevement/class/ligneprelevement.class.php
@@ -61,7 +61,7 @@ class LignePrelevement
 	 *  Recupere l'objet prelevement
 	 *
 	 *  @param	int		$rowid       id de la facture a recuperer
-	 *  @return	void
+	 *  @return	void|int
 	 */
 	function fetch($rowid)
 	{
diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php
index d0b467f294ba287b3b85c9bf75f1b3b8b49e7ce7..176a561378b0c28ad34da8b0531984d63a57f93a 100644
--- a/htdocs/compta/prelevement/class/rejetprelevement.class.php
+++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php
@@ -71,7 +71,7 @@ class RejetPrelevement
 	 * @param 	User		$user				User object
 	 * @param 	int			$id					Id
 	 * @param 	string		$motif				Motif
-	 * @param 	timestamp	$date_rejet			Date rejet
+	 * @param 	int	$date_rejet			Date rejet
 	 * @param 	int			$bonid				Bon id
 	 * @param 	int			$facturation		Facturation
 	 * @return	void
@@ -272,7 +272,7 @@ class RejetPrelevement
 	/**
 	 *    Retrieve the list of invoices
 	 *
-	 *    @return	void
+	 *    @return	array
 	 */
 	private function getListInvoices()
 	{
@@ -318,7 +318,7 @@ class RejetPrelevement
 	 *    Retrieve withdrawal object
 	 *
 	 *    @param    int		$rowid       id of invoice to retrieve
-	 *    @return	void
+	 *    @return	int
 	 */
 	function fetch($rowid)
 	{
diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php
index 1d684c655523fc7ec2075171b0c5e4d98bc153e0..805558b4267e49dcc1b18ab365e7dc7fb2f918f9 100644
--- a/htdocs/compta/sociales/class/chargesociales.class.php
+++ b/htdocs/compta/sociales/class/chargesociales.class.php
@@ -69,7 +69,7 @@ class ChargeSociales extends CommonObject
      *
      *  @param	int     $id		Id
      *  @param	string  $ref	Ref
-     *  @return	void
+     *  @return	int <0 KO >0 OK
      */
     function fetch($id, $ref='')
     {
@@ -99,13 +99,14 @@ class ChargeSociales extends CommonObject
                 $this->paye           = $obj->paye;
                 $this->periode        = $this->db->jdate($obj->periode);
 
+                $this->db->free($resql);
+
                 return 1;
             }
             else
             {
                 return 0;
             }
-            $this->db->free($resql);
         }
         else
         {
@@ -308,6 +309,7 @@ class ChargeSociales extends CommonObject
             if ($this->db->num_rows($result))
             {
                 $obj = $this->db->fetch_object($result);
+                $this->db->free($result);
                 return $obj->amount;
             }
             else
@@ -315,8 +317,6 @@ class ChargeSociales extends CommonObject
                 return 0;
             }
 
-            $this->db->free($result);
-
         }
         else
         {
@@ -520,8 +520,6 @@ class ChargeSociales extends CommonObject
      */
     function initAsSpecimen()
     {
-        global $user,$langs,$conf;
-
         // Initialize parameters
         $this->id=0;
         $this->ref = 'SPECIMEN';
diff --git a/htdocs/compta/tva/quadri.php b/htdocs/compta/tva/quadri.php
index f5d0065e7f34c5baa812301491f5b1ac1e44b55b..4b399d65248307c67b012ae903be9944da1827ca 100644
--- a/htdocs/compta/tva/quadri.php
+++ b/htdocs/compta/tva/quadri.php
@@ -54,7 +54,7 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
  * @param	DoliDB	$db		Database handler
  * @param	int		$y		Year
  * @param	int		$q		Year quarter (1-4)
- * @return	void
+ * @return	array
  */
 function tva_coll($db,$y,$q)
 {
@@ -122,7 +122,7 @@ function tva_coll($db,$y,$q)
  * @param	DoliDB	$db			Database handler object
  * @param	int		$y			Year
  * @param	int		$q			Year quarter (1-4)
- * @return	void
+ * @return	array
  */
 function tva_paye($db, $y,$q)
 {
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index bd37c15519676f8933e60ed96354c60e39d82e3d..e2118a9dbaa175b7c9ce7887713297446ccadb68 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -1001,8 +1001,6 @@ class Contact extends CommonObject
 	 */
 	function initAsSpecimen()
 	{
-		global $user,$langs;
-
 		// Get first id of existing company and save it into $socid
 		$socid = 0;
 		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe ORDER BY rowid LIMIT 1";
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index b2b99a9dde36aab055e904a61252b5f067e7a427..fdd0acfec74fa922dc618bba7ea270284b668ec9 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -659,7 +659,7 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->contr
 // Close all lines
 else if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contrat->creer)
 {
-    $result = $object->cloture($user);
+    $object->cloture($user);
 }
 
 else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer)
diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index 37be98fa2c40a279b36054e84b36337d9de6f066..d2bbe28726a8ac6b4846829de0a04a77800615ce 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -236,7 +236,6 @@ class Contrat extends CommonObject
 			}
 
 			$obj = new $classname();
-			$numref = "";
 			$numref = $obj->getNextValue($soc,$this);
 
 			if ( $numref != "")
@@ -1589,11 +1588,11 @@ class Contrat extends CommonObject
 		// Load $this->lines array
 		//		$this->fetch_lines();
 
-		$newstatut=1;
-		foreach($this->lines as $key => $contractline)
-		{
-			//			if ($contractline)         // Loop on each service
-		}
+//		$newstatut=1;
+//		foreach($this->lines as $key => $contractline)
+//		{
+//			//			if ($contractline)         // Loop on each service
+//		}
 
 		return 1;
 	}
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 3e58e7b5c7dd908cf2961bc4c4ec1a78ccfcc3b4..8a8258ca641ff82176e18d0af0f9bfc315ccd3d8 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -821,7 +821,7 @@ abstract class CommonObject
      *	Update a specific field into database
      *
      *	@param	string	$field		Field to update
-     *	@param	mixte	$value		New value
+     *	@param	mixed	$value		New value
      *	@param	string	$table		To force other table element or element line (should not be used)
      *	@param	int		$id			To force other object id (should not be used)
      *	@param	string	$format		Data format ('text', 'date'). 'text' is used if not defined
@@ -2412,7 +2412,7 @@ abstract class CommonObject
      *  TODO Move this into html.class.php
      *  But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
      *
-     *  @return	void
+     *  @return	int
      */
     function showLinkedObjectBlock()
     {
diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php
index 6dc726b084e082ef73ca0f24adeeb5143eca171d..d6e23beac70b8fa3e5defcaf4655e822fb8e62c6 100644
--- a/htdocs/core/class/doleditor.class.php
+++ b/htdocs/core/class/doleditor.class.php
@@ -142,7 +142,7 @@ class DolEditor
      *
      *  @param	int		$noprint    1=Return HTML string instead of printing it to output
      *  @param	string	$morejs		Add more js. For example: ".on( \'saveSnapshot\', function(e) { alert(\'ee\'); });"
-     *  @return	void
+     *  @return	void|string
      */
     function Create($noprint=0,$morejs='')
     {
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index 1c7c3ffb634ebbe6b365c090944565aea5de4bc5..544619892b5f2ca1b12ff93313eae74788f1fae8 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -590,7 +590,7 @@ class ExtraFields
 	 * @param	string	$value          Value to show (for date type it must be in timestamp format)
 	 * @param	string	$moreparam      To add more parametes on html input tag
 	 * @param	string	$keyprefix		Prefix string to add into name and id of field (can be used to avoid duplicate names)
-	 * @return	void
+	 * @return	string
 	 */
 	function showInputField($key,$value,$moreparam='',$keyprefix='')
 	{
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 8f35a486dbe77e099ed879bbc9c4658f6dd54bf5..6d83561e2a95b0558b7a28b29d28693ac4438d86 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -2794,7 +2794,7 @@ class Form
      *    @param    string	$htmlname			HTML field name
      *    @param    int		$maxlength      	Maximum length for labels
      *    @param    int		$excludeafterid 	Exclude all categories after this leaf in category tree.
-     *    @return	void
+     *    @return	string
      *    @see select_categories
      */
     function select_all_categories($type, $selected='', $htmlname="parent", $maxlength=64, $excludeafterid=0)
@@ -3568,7 +3568,7 @@ class Form
      *
      *  @param	string	$selected    preselected currency code
      *  @param  string	$htmlname    name of HTML select list
-     * 	@return	void
+     * 	@return	string
      */
     function selectCurrency($selected='',$htmlname='currency_id')
     {
@@ -3667,7 +3667,7 @@ class Form
 	 *                                      Si vendeur et acheteur dans Communauté européenne et acheteur= entreprise alors TVA par défaut=0. Fin de règle.
      *                  					Sinon la TVA proposee par defaut=0. Fin de regle.
      *  @param	bool	$options_only		Return options only (for ajax treatment)
-     *  @return	void
+     *  @return	string
      */
     function load_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $idprod=0, $info_bits=0, $type='', $options_only=false)
     {
@@ -4452,7 +4452,7 @@ class Form
      *    	Return HTML code to output a photo
      *
      *    	@param	string		$modulepart		Key to define module concerned ('societe', 'userphoto', 'memberphoto')
-     *     	@param  Object		$object			Object containing data to retrieve file name
+     *     	@param  object		$object			Object containing data to retrieve file name
      * 		@param	int			$width			Width of photo
      * 	  	@return string    					HTML code to output photo
      */
diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php
index 87723c535f332a19642bc972f5ff05a698668da1..297d772b06c8e8102c332f9659059e9e0cea8560 100644
--- a/htdocs/core/class/html.formcompany.class.php
+++ b/htdocs/core/class/html.formcompany.class.php
@@ -709,7 +709,7 @@ class FormCompany
 	 *    @param    string		$fields					Fields
 	 *    @param    int			$fieldsize				Field size
 	 *    @param    int			$disableautocomplete    1 To disable autocomplete features
-	 *    @return	void
+	 *    @return	string
 	 */
 	function select_ziptown($selected='', $htmlname='zipcode', $fields='', $fieldsize=0, $disableautocomplete=0)
 	{
diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php
index 4f0439d7b3cd7e9d4dc52edd1ca2710c0ac1f36a..b7971d52c53ab273a381faa3ac9b981e2d6ce604 100644
--- a/htdocs/core/class/html.formother.class.php
+++ b/htdocs/core/class/html.formother.class.php
@@ -590,7 +590,7 @@ class FormOther
      * 		@param	int			$showcolorbox	1=Show color code and color box, 0=Show only color code
      * 		@param 	array		$arrayofcolors	Array of colors. Example: array('29527A','5229A3','A32929','7A367A','B1365F','0D7813')
      * 		@param	string		$morecss		Add css style into input field
-     * 		@return	void
+     * 		@return	string
      */
     function selectColor($set_color='', $prefix='f_color', $form_name='', $showcolorbox=1, $arrayofcolors='', $morecss='')
     {
@@ -720,7 +720,7 @@ class FormOther
      *    	@param	string		$selected          Preselected value
      *    	@param  string		$htmlname          Nom de la zone select
      *    	@param  int			$useempty          Affiche valeur vide dans liste
-     *    	@return	void
+     *    	@return	string
      */
     function select_dayofweek($selected='',$htmlname='weekid',$useempty=0)
     {
@@ -761,7 +761,7 @@ class FormOther
      *    	@param	string		$selected          Preselected value
      *    	@param  string		$htmlname          Nom de la zone select
      *    	@param  int			$useempty          Affiche valeur vide dans liste
-     *    	@return	void
+     *    	@return	string
      */
     function select_month($selected='',$htmlname='monthid',$useempty=0)
     {
@@ -803,7 +803,7 @@ class FormOther
      *  @param	int			$offset			Offset
      *  @param	int			$invert			Invert
      *  @param	string		$option			Option
-     *  @return	void
+     *  @return	string
      */
     function select_year($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='')
     {
diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php
index dc844ee3f0233be239e8f22e98bafec076e8c113..ca0cbab39258817c329f1c73191cc69f7b0383ce 100644
--- a/htdocs/core/class/ldap.class.php
+++ b/htdocs/core/class/ldap.class.php
@@ -801,7 +801,7 @@ class Ldap
 	 *
 	 *	@param	string	$dn			DN entry key
 	 *	@param	string	$filter		Filter
-	 *	@return	int					<0 if KO, >0 if OK
+	 *	@return	int|false|array					<0 or false if KO, array if OK
 	 */
 	function getAttribute($dn,$filter)
 	{
diff --git a/htdocs/core/class/vcard.class.php b/htdocs/core/class/vcard.class.php
index 512aa011d986c208990689f2ce7aacef0f1ac915..bc9f9081a4946cec007be64ad99497995d9f1328 100644
--- a/htdocs/core/class/vcard.class.php
+++ b/htdocs/core/class/vcard.class.php
@@ -306,7 +306,7 @@ class vCard
     /**
      *  permet d'obtenir une vcard
      *
-     *  @return	void
+     *  @return	string
      */
     function getVCard()
     {
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/ajax.lib.php b/htdocs/core/lib/ajax.lib.php
index 74e715f7b4a1fcee470e36d15f136d375b0d4507..c891ee60a261445f37eb6dce3460aeb5ad8610d0 100644
--- a/htdocs/core/lib/ajax.lib.php
+++ b/htdocs/core/lib/ajax.lib.php
@@ -403,7 +403,7 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0)
  * 	@param	int		$entity			Entity to set
  *  @param	int		$revertonoff	Revert on/off
  *  @param	bool	$strict			Use only "disabled" with delConstant and "enabled" with setConstant
- * 	@return	void
+ * 	@return	string
  */
 function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0)
 {
diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php
index 488a4c3a530ee3201c80abeefb4e08bc040eac62..fdb7d0e76ecfca4552db6a0bfa22a77bda64dafc 100644
--- a/htdocs/core/lib/bank.lib.php
+++ b/htdocs/core/lib/bank.lib.php
@@ -27,10 +27,10 @@
 /**
  * Prepare array with list of tabs
  *
- * @param   Object	$object		Object related to tabs
+ * @param   Account	$object		Object related to tabs
  * @return  array				Array of tabs to show
  */
-function bank_prepare_head($object)
+function bank_prepare_head(Account $object)
 {
     global $langs, $conf, $user;
     $h = 0;
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 2d0ecc4ebf72fb0c381d510d3702c40a11b3604a..9e4c72d829972ddfc16369cb4a2bfa2eb2cd8a0c 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -32,10 +32,10 @@
 /**
  * Return array of tabs to used on pages for third parties cards.
  *
- * @param 	Object	$object		Object company shown
+ * @param 	Societe	$object		Object company shown
  * @return 	array				Array of tabs
  */
-function societe_prepare_head($object)
+function societe_prepare_head(Societe $object)
 {
     global $db, $langs, $conf, $user;
     $h = 0;
@@ -545,7 +545,7 @@ function show_projects($conf,$langs,$db,$object,$backtopage='')
  *		@param	Conf		$conf		Object conf
  * 		@param	Translate	$langs		Object langs
  * 		@param	DoliDB		$db			Database handler
- * 		@param	Object		$object		Third party object
+ * 		@param	Societe		$object		Third party object
  *      @param  string		$backtopage	Url to go once contact is created
  *      @return	void
  */
@@ -809,7 +809,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
  *		@param	Conf		$conf		Object conf
  * 		@param	Translate	$langs		Object langs
  * 		@param	DoliDB		$db			Database handler
- * 		@param	Object		$object		Third party object
+ * 		@param	Societe		$object		Third party object
  *      @param  string		$backtopage	Url to go once address is created
  *      @return	void
  */
@@ -904,7 +904,7 @@ function show_addresses($conf,$langs,$db,$object,$backtopage='')
  * 		@param	Conf		$conf		Object conf
  * 		@param	Translate	$langs		Object langs
  * 		@param	DoliDB		$db			Object db
- * 		@param	Object		$object		Object third party or member
+ * 		@param	Adherent|Societe		$object		Object third party or member
  * 		@param	Contact		$objcon		Object contact
  *      @param  int			$noprint	Return string but does not output it
  *      @return	mixed					Return html part or void if noprint is 1
@@ -1067,7 +1067,7 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0)
  * 		@param	Conf		$conf		Object conf
  * 		@param	Translate	$langs		Object langs
  * 		@param	DoliDB		$db			Object db
- * 		@param	Object		$object		Object third party or member
+ * 		@param	Adherent|Societe		$object		Object third party or member
  * 		@param	Contact		$objcon		Object contact
  *      @param  int			$noprint    Return string but does not output it
  *      @return	mixed					Return html part or void if noprint is 1
diff --git a/htdocs/core/lib/contact.lib.php b/htdocs/core/lib/contact.lib.php
index 8d9ba9296a46e1f72c955239623ff00f3f03b287..3eeca82c9936d8cf5ff1cfb84b1bcccdbed113f8 100644
--- a/htdocs/core/lib/contact.lib.php
+++ b/htdocs/core/lib/contact.lib.php
@@ -25,10 +25,10 @@
 /**
  * Prepare array with list of tabs
  *
- * @param   Object	$object		Object related to tabs
+ * @param   Contact	$object		Object related to tabs
  * @return  array				Array of tabs to show
  */
-function contact_prepare_head($object)
+function contact_prepare_head(Contact $object)
 {
 	global $langs, $conf, $user;
 
diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php
index b7e82c6dbf21d19628aa9a5dc603aa2b8d5fb71d..fff83e4c4bc9833ccd33f27adf94ca28961dec86 100644
--- a/htdocs/core/lib/contract.lib.php
+++ b/htdocs/core/lib/contract.lib.php
@@ -25,10 +25,10 @@
 /**
  * Prepare array with list of tabs
  *
- * @param   Object	$object		Object related to tabs
+ * @param   Contrat	$object		Object related to tabs
  * @return  array				Array of tabs to show
  */
-function contract_prepare_head($object)
+function contract_prepare_head(Contrat $object)
 {
 	global $langs, $conf;
 	$h = 0;
diff --git a/htdocs/core/lib/cron.lib.php b/htdocs/core/lib/cron.lib.php
index 79e23e90089431f99a1920fd36d0bbe9e9abc876..c3867839e846e93253e205d5ca05cbe8acf4864d 100644
--- a/htdocs/core/lib/cron.lib.php
+++ b/htdocs/core/lib/cron.lib.php
@@ -50,10 +50,10 @@ function cronadmin_prepare_head()
 /**
  * Return array of tabs to used on a cron job
  *
- * @param 	Object	$object		Object cron
+ * @param 	Cronjob	$object		Object cron
  * @return 	array				Array of tabs
  */
-function cron_prepare_head($object)
+function cron_prepare_head(Cronjob $object)
 {
 	global $langs, $conf, $user;
 	$h = 0;
diff --git a/htdocs/core/lib/emailing.lib.php b/htdocs/core/lib/emailing.lib.php
index 239f36721ee0a808f4dda2e8d2859e3bf421518e..7ca2aba9db2702248d41ac4e70308ce9741f0668 100644
--- a/htdocs/core/lib/emailing.lib.php
+++ b/htdocs/core/lib/emailing.lib.php
@@ -24,10 +24,10 @@
 /**
  * Prepare array with list of tabs
  *
- * @param   Object	$object		Object related to tabs
+ * @param   Mailing	$object		Object related to tabs
  * @return  array				Array of tabs to show
  */
-function emailing_prepare_head($object)
+function emailing_prepare_head(Mailing $object)
 {
 	global $user, $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;
 
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index c3446eb7b153b6e1fee8072b39ee090a5c92c434..6c3de5641979e9c66ea0cfc64c5576cb7b45ba66 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -657,7 +657,7 @@ function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto
  *	@param  int		$notab				0=Add tab header, 1=no tab header. If you set this to 1, using dol_fiche_end() to close tab is not required.
  * 	@param	string	$picto				Add a picto on tab title
  *	@param	int		$pictoisfullpath	If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto.
- * 	@return	void
+ * 	@return	string
  */
 function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0)
 {
@@ -739,7 +739,7 @@ function dol_fiche_end($notab=0)
  *	Return tab footer of a card
  *
  *	@param  int		$notab		0=Add tab footer, 1=no tab footer
- *  @return	void
+ *  @return	string
  */
 function dol_get_fiche_end($notab=0)
 {
@@ -2542,7 +2542,7 @@ function print_liste_field_titre($name, $file="", $field="", $begin="", $morepar
  *	@param  string	$moreattrib  Add more attributes on th ("" by defaut)
  *	@param  string	$sortfield   Current field used to sort
  *	@param  string	$sortorder   Current sort order
- *	@return	void
+ *	@return	string
  */
 function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="")
 {
@@ -2647,7 +2647,7 @@ function print_fiche_titre($title, $mesg='', $picto='title.png', $pictoisfullpat
  *	@param	string	$picto				Icon to use before title (should be a 32x32 transparent png file)
  *	@param	int		$pictoisfullpath	1=Icon name is a full absolute url of image
  * 	@param	int		$id					To force an id on html objects
- * 	@return	void
+ * 	@return	string
  */
 function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='')
 {
@@ -3188,11 +3188,11 @@ function get_localtax_by_third($local)
  *  Instead this function must be called when adding a line to get (array of localtax and type) and
  *  provide it to the function calcul_price_total.
  *
- *  @param		float	$vatrate			VAT Rate
- *  @param		int		$local              Number of localtax (1 or 2, or 0 to return 1 & 2)
- *  @param		int		$buyer         		Company object
- *  @param		int		$seller        		Company object
- *  @return		array    	  				array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...)
+ *  @param	float	$vatrate			VAT Rate
+ *  @param	int		$local              Number of localtax (1 or 2, or 0 to return 1 & 2)
+ *  @param	Societe	$buyer         		Company object
+ *  @param	Societe	$seller        		Company object
+ *  @return	array    	  				array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...)
  */
 function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller)
 {
@@ -4639,7 +4639,7 @@ function picto_from_langcode($codelang)
  *
  *  @param	Conf			$conf           Object conf
  *  @param  Translate		$langs          Object langs
- *  @param  Object|null		$object         Object object
+ *  @param  object|null		$object         Object object
  *  @param  array			$head          	Object head
  *  @param  int				$h				New position to fill
  *  @param  string			$type           Value for object where objectvalue can be
diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php
index 879478daf8d5d8fd14923c8596a0cf62fdf85e29..19e9f08e94d6b8367132885daaca6c66d357760b 100644
--- a/htdocs/core/lib/member.lib.php
+++ b/htdocs/core/lib/member.lib.php
@@ -24,10 +24,10 @@
 /**
  *  Return array head with list of tabs to view object informations
  *
- *  @param	Object	$object         Member
+ *  @param	Adherent	$object         Member
  *  @return array           		head
  */
-function member_prepare_head($object)
+function member_prepare_head(Adherent $object)
 {
 	global $langs, $conf, $user;
 
@@ -155,7 +155,7 @@ function member_admin_prepare_head()
 /**
  *  Return array head with list of tabs to view object stats informations
  *
- *  @param	Object	$object         Member or null
+ *  @param	Adherent	$object         Member or null
  *  @return	array           		head
  */
 function member_stats_prepare_head($object)
diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php
index 24e2e05693a2bf432bba67d1d81fcc2bd5ae28a0..a6fae1c7b1f30d6373f619957c4a3ad0ecbbd6fd 100644
--- a/htdocs/core/lib/memory.lib.php
+++ b/htdocs/core/lib/memory.lib.php
@@ -169,7 +169,7 @@ function dol_getshmopaddress($memoryid)
 /**
  * 	Return list of contents of all memory area shared
  *
- * 	@return	int						0=Nothing is done, <0 if KO, >0 if OK
+ * 	@return	array
  */
 function dol_listshmop()
 {
diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php
index 1e0f2f50139f9112b4efd6bfe3f2dfc07844fd06..de7e9a935183f457e230d957a37342bf0885e9ad 100644
--- a/htdocs/core/lib/order.lib.php
+++ b/htdocs/core/lib/order.lib.php
@@ -28,10 +28,10 @@
 /**
  * Prepare array with list of tabs
  *
- * @param   Object	$object		Object related to tabs
+ * @param   Commande	$object		Object related to tabs
  * @return  array				Array of tabs to show
  */
-function commande_prepare_head($object)
+function commande_prepare_head(Commande $object)
 {
 	global $langs, $conf, $user;
 	if (! empty($conf->expedition->enabled)) $langs->load("sendings");
diff --git a/htdocs/core/lib/prelevement.lib.php b/htdocs/core/lib/prelevement.lib.php
index 53f54d66f70f04d84d047509ae223ee657ff40c2..18608a55a04756225b6303a5f5733df4b6c58fe2 100644
--- a/htdocs/core/lib/prelevement.lib.php
+++ b/htdocs/core/lib/prelevement.lib.php
@@ -28,10 +28,10 @@
 /**
  * Prepare array with list of tabs
  *
- * @param   Object	$object		Object related to tabs
+ * @param   BonPrelevement	$object		Object related to tabs
  * @return  array				Array of tabs to show
  */
-function prelevement_prepare_head($object)
+function prelevement_prepare_head(BonPrelevement $object)
 {
 	global $langs, $conf, $user;
 	$langs->load("withdrawals");
diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php
index 6b750bf2f96b7b8a03f58625babf84f57a28c4a6..011f3d26de08855e51411157f2ba6b0bdb86caa0 100644
--- a/htdocs/core/lib/tax.lib.php
+++ b/htdocs/core/lib/tax.lib.php
@@ -29,10 +29,10 @@
 /**
  * Prepare array with list of tabs
  *
- * @param   Object	$object		Object related to tabs
+ * @param   ChargeSociales	$object		Object related to tabs
  * @return  array				Array of tabs to show
  */
-function tax_prepare_head($object)
+function tax_prepare_head(ChargeSociales $object)
 {
     global $langs, $conf;
 
diff --git a/htdocs/core/lib/trip.lib.php b/htdocs/core/lib/trip.lib.php
index 45619b10d6fee3c43626422cc4aff10e01a375ba..33f977bcf3482dc160e033e8ffc4729b3390c96d 100644
--- a/htdocs/core/lib/trip.lib.php
+++ b/htdocs/core/lib/trip.lib.php
@@ -24,10 +24,10 @@
 /**
  * Prepare array with list of tabs
  *
- * @param   Object	$object		Object related to tabs
+ * @param   Deplacement	$object		Object related to tabs
  * @return  array				Array of tabs to show
  */
-function trip_prepare_head($object)
+function trip_prepare_head(Deplacement $object)
 {
 	global $langs, $conf;
 
diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php
index aaa69ec7f42d09cc232324dfd962daa15669c705..723660f1d9ce2e6d2ad2cb224881893b14c46181 100644
--- a/htdocs/cron/class/cronjob.class.php
+++ b/htdocs/cron/class/cronjob.class.php
@@ -273,7 +273,6 @@ class Cronjob extends CommonObject
      */
     function fetch($id)
     {
-    	global $langs;
         $sql = "SELECT";
 		$sql.= " t.rowid,";
 
@@ -655,15 +654,14 @@ class Cronjob extends CommonObject
 	 */
 	function delete($user, $notrigger=0)
 	{
-		global $conf, $langs;
 		$error=0;
 
 		$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.
 
@@ -673,18 +671,18 @@ class Cronjob extends CommonObject
 		        //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
 		        //if ($result < 0) { $error++; $this->errors=$interface->errors; }
 		        //// End call triggers
-			}
-		}
+//			}
+//		}
 
-		if (! $error)
-		{
+//		if (! $error)
+//		{
     		$sql = "DELETE FROM ".MAIN_DB_PREFIX."cronjob";
     		$sql.= " WHERE rowid=".$this->id;
 
     		dol_syslog(get_class($this)."::delete", LOG_DEBUG);
     		$resql = $this->db->query($sql);
         	if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
-		}
+//		}
 
         // Commit or rollback
 		if ($error)
@@ -803,12 +801,10 @@ class Cronjob extends CommonObject
 	/**
 	 *	Load object information
 	 *
-	 *	@return	void
+	 *	@return	int
 	 */
 	function info()
 	{
-		global $langs;
-
 		$sql = "SELECT";
 		$sql.= " f.rowid, f.datec, f.tms, f.fk_user_mod, f.fk_user_author";
 		$sql.= " FROM ".MAIN_DB_PREFIX."cronjob as f";
@@ -849,7 +845,6 @@ class Cronjob extends CommonObject
 	{
 		global $langs, $conf;
 
-		$error=0;
 		$now=dol_now();
 
 		$langs->load('cron');
@@ -935,7 +930,6 @@ class Cronjob extends CommonObject
 			// Create Object for the call module
 			$object = new $this->objectname($this->db);
 
-			$params_arr = array();
 			$params_arr = explode(", ",$this->params);
 			if (!is_array($params_arr))
 			{
@@ -978,7 +972,6 @@ class Cronjob extends CommonObject
 				return -1;
 			}
 			dol_syslog(get_class($this) . "::run_jobs " . $this->libname . "::" . $this->methodename."(" . $this->params . ");", LOG_DEBUG);
-			$params_arr = array();
 			$params_arr = explode(", ", $this->params);
 			if (!is_array($params_arr))
 			{
@@ -1074,8 +1067,6 @@ class Cronjob extends CommonObject
 	 */
 	function reprogram_jobs($userlogin)
 	{
-		global $langs, $conf;
-
 		dol_syslog(get_class($this)."::reprogram_jobs userlogin:$userlogin", LOG_DEBUG);
 
 		require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php
index 6c0de13d15bd3331faa05a953de0f36794cd21f9..d099d017ecd2b540e96bff930205513ba59ef38e 100644
--- a/htdocs/ecm/class/ecmdirectory.class.php
+++ b/htdocs/ecm/class/ecmdirectory.class.php
@@ -244,8 +244,6 @@ class EcmDirectory // extends CommonObject
 	 */
 	function changeNbOfFiles($sign)
 	{
-		global $conf, $langs;
-
 		// Update request
 		$sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
 		$sql.= " cachenbofdoc = cachenbofdoc ".$sign." 1";
@@ -320,7 +318,7 @@ class EcmDirectory // extends CommonObject
 	 * 	Delete object on database and/or on disk
 	 *
 	 *	@param	User	$user		User that delete
-	 *  @param	int		$mode		'all'=delete all, 'databaseonly'=only database entry, 'fileonly' (not implemented)
+	 *  @param	string		$mode		'all'=delete all, 'databaseonly'=only database entry, 'fileonly' (not implemented)
 	 *	@return	int					<0 if KO, >0 if OK
 	 */
 	function delete($user, $mode='all')
@@ -329,7 +327,6 @@ class EcmDirectory // extends CommonObject
         require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 
 		$error=0;
-		$result=0;
 
 		if ($mode != 'databaseonly') $relativepath=$this->getRelativePath(1);	// Ex: dir1/dir2/dir3
 
diff --git a/htdocs/ecm/class/htmlecm.form.class.php b/htdocs/ecm/class/htmlecm.form.class.php
index 58286371941ac5cd2ee998c841a4645892a8edab..87b4af190aeace97f3c8e3a5bbb0f95943a9b8e3 100644
--- a/htdocs/ecm/class/htmlecm.form.class.php
+++ b/htdocs/ecm/class/htmlecm.form.class.php
@@ -51,7 +51,7 @@ class FormEcm
 	 *  @param  string	$select_name		Nom formulaire HTML
 	 *  @return	string						String with HTML select
 	 */
-	function select_all_sections($selected='',$select_name='')
+	function select_all_sections($selected=0,$select_name='')
 	{
 		global $langs;
 		$langs->load("ecm");
diff --git a/htdocs/mailmanspip/class/mailmanspip.class.php b/htdocs/mailmanspip/class/mailmanspip.class.php
index 6e772b09c0367b93a10aab55a30d808bc633e17a..d874e539164a876222cb9d9dc57bae50e249245f 100644
--- a/htdocs/mailmanspip/class/mailmanspip.class.php
+++ b/htdocs/mailmanspip/class/mailmanspip.class.php
@@ -166,7 +166,7 @@ class MailmanSpip
     /**
      *  Fonction qui donne les droits redacteurs dans spip
      *
-     *	@param	Object	$object		Object with data (->firstname, ->lastname, ->email and ->login)
+     *	@param	object	$object		Object with data (->firstname, ->lastname, ->email and ->login)
      *  @return	int					=0 if KO, >0 if OK
      */
     function add_to_spip($object)
@@ -208,7 +208,7 @@ class MailmanSpip
     /**
      *  Fonction qui enleve les droits redacteurs dans spip
      *
-     *	@param	Object	$object		Object with data (->login)
+     *	@param	object	$object		Object with data (->login)
      *  @return	int					=0 if KO, >0 if OK
      */
     function del_to_spip($object)
@@ -247,7 +247,7 @@ class MailmanSpip
     /**
      *  Fonction qui dit si cet utilisateur est un redacteur existant dans spip
      *
-     *	@param	Object	$object		Object with data (->login)
+     *	@param	object	$object		Object with data (->login)
      *  @return int     			1=exists, 0=does not exists, -1=error
      */
     function is_in_spip($object)
@@ -297,7 +297,7 @@ class MailmanSpip
     /**
      *  Subscribe an email to all mailing-lists
      *
-     *	@param	Object	$object		Object with data (->email, ->pass, ->element, ->type)
+     *	@param	object	$object		Object with data (->email, ->pass, ->element, ->type)
      *  @param	array	$listes    	To force mailing-list (string separated with ,)
      *  @return	int		  			<0 if KO, >=0 if OK
      */
@@ -369,7 +369,7 @@ class MailmanSpip
      *  Unsubscribe an email from all mailing-lists
      *  Used when a user is resiliated
      *
-     *	@param	Object	$object		Object with data (->email, ->pass, ->element, ->type)
+     *	@param	object	$object		Object with data (->email, ->pass, ->element, ->type)
      *  @param	array	$listes     To force mailing-list (string separated with ,)
      *  @return int         		<0 if KO, >=0 if OK
      */
diff --git a/htdocs/societe/class/address.class.php b/htdocs/societe/class/address.class.php
index 7b36423cb6116da68f07c60bf4dfb881ca212472..632e4aea5b6bb125c3a1fbe6e9c40ce54dbf2526 100644
--- a/htdocs/societe/class/address.class.php
+++ b/htdocs/societe/class/address.class.php
@@ -47,6 +47,11 @@ class Address
 	var $fax;
 	var $note;
 
+	/**
+	 * Adresses liees a la societe
+	 * @var array
+	 */
+	public $lines;
 
 	/**
 	 *  Constructor
@@ -391,7 +396,7 @@ class Address
 	 *
 	 *  @param	int		$id      id de la societe a supprimer
 	 *  @param	int		$socid	id third party
-	 *  @return	void
+	 *  @return	<0 KO >0 OK
 	 */
 	function delete($id,$socid)
 	{
@@ -403,10 +408,11 @@ class Address
 
 		$result = $this->db->query($sql);
 
-		if (!$result)
-		{
-			print $this->db->error() . '<br>' . $sql;
+		if (!$result) {
+			return -1;
 		}
+
+		return 1;
 	}
 
 	/**