diff --git a/ChangeLog b/ChangeLog
index 505c20d667a56a60dd15c920103396db58058bb7..4871c8ce58b5c4bd53f40576a2884759486b6ac4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,16 +5,18 @@ English Dolibarr ChangeLog
 ***** ChangeLog for 3.6.1 compared to 3.6.* *****
 For users:
 - Fix: Can upload files on services.
-- Fix: sql errors on updat fichinter
-- Fix: debian script syntax error
+- Fix: sql errors on updat fichinter.
+- Fix: debian script syntax error.
 - Fix: error "menu param is not inside list" into pos module.
-- Fix: Salary payments are not reflected on the reporting sheets
-- Fix: Unsubscribe emailing not working
-- Fix: Trigger on create category call failed because user is not passed on card
-- Fix: list event view lost type event filter
-- Fix: Save also code event
-- Fix: VAT payment - Add control on field date value
-- Fix: Salaries payment - Field date value is now required and add control on it
+- Fix: Salary payments are not reflected on the reporting sheets.
+- Fix: Unsubscribe emailing not working.
+- Fix: Trigger on create category call failed because user is not passed on card.
+- Fix: list event view lost type event filter.
+- Fix: Save also code event.
+- Fix: VAT payment - Add control on field date value.
+- Fix: Salaries payment - Field date value is now required and add control on it.
+- Fix: Iban was used instead of Bic into SEPA file.
+- Fix: Must unaccent strings into SEPA file.
 
 ***** ChangeLog for 3.6 compared to 3.5.* *****
 For users:
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 8f6df3135066fce4f602d37c4f2aea903ca708cd..25c8d068ae1af7dd5147fa6dc06081523640378e 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -269,10 +269,12 @@ else if ($action == 'add' && $user->rights->commande->creer) {
 			if ($ret < 0)
 				$error ++;
 
-			if (! $error) {
+			if (! $error)
+			{
 				$object_id = $object->create($user);
 
-				if ($object_id > 0) {
+				if ($object_id > 0)
+				{
 					dol_include_once('/' . $element . '/class/' . $subelement . '.class.php');
 
 					$classname = ucfirst($subelement);
@@ -280,15 +282,20 @@ else if ($action == 'add' && $user->rights->commande->creer) {
 
 					dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines");
 					$result = $srcobject->fetch($object->origin_id);
-					if ($result > 0) {
+					if ($result > 0)
+					{
 						$lines = $srcobject->lines;
 						if (empty($lines) && method_exists($srcobject, 'fetch_lines'))
-							$lines = $srcobject->fetch_lines();
+						{
+							$srcobject->fetch_lines();
+							$lines = $srcobject->lines;
+						}
 
 						$fk_parent_line = 0;
 						$num = count($lines);
 
-						for($i = 0; $i < $num; $i ++) {
+						for($i = 0; $i < $num; $i ++)
+						{
 							$label = (! empty($lines [$i]->label) ? $lines [$i]->label : '');
 							$desc = (! empty($lines [$i]->desc) ? $lines [$i]->desc : $lines [$i]->libelle);
 							$product_type = (! empty($lines [$i]->product_type) ? $lines [$i]->product_type : 0);
diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php
index bdb96718dfad6c9552885ef9adcffc8df6a27c0a..5332690e40b53a94b28c90e307c9f0623c10e217 100644
--- a/htdocs/commande/orderstoinvoice.php
+++ b/htdocs/commande/orderstoinvoice.php
@@ -97,7 +97,7 @@ if (($action == 'create' || $action == 'add') && empty($mesgs))
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
 	if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
-	
+
 	$langs->load('bills');
 	$langs->load('products');
 	$langs->load('main');
@@ -213,13 +213,17 @@ if (($action == 'create' || $action == 'add') && empty($mesgs))
 							$result=$objectsrc->fetch($orders_id[$ii]);
 							if ($result > 0)
 							{
-								if ($closeOrders) 
+								if ($closeOrders)
 								{
 									$objectsrc->classifyBilled();
 									$objectsrc->setStatut(3);
 								}
 								$lines = $objectsrc->lines;
-								if (empty($lines) && method_exists($objectsrc,'fetch_lines'))  $lines = $objectsrc->fetch_lines();
+								if (empty($lines) && method_exists($objectsrc, 'fetch_lines'))
+								{
+									$objectsrc->fetch_lines();
+									$lines = $objectsrc->lines;
+								}
 								$fk_parent_line=0;
 								$num=count($lines);
 								for ($i=0;$i<$num;$i++)
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 8138c56450eb11f717c8b008b46cfaf4161e3be8..0e237af632c6c00ad3dd76595ddfe2c51a6f6312 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -924,7 +924,11 @@ else if ($action == 'add' && $user->rights->facture->creer)
 						if ($result > 0)
 						{
 							$lines = $srcobject->lines;
-							if (empty($lines) && method_exists($srcobject, 'fetch_lines')) $lines = $srcobject->fetch_lines();
+							if (empty($lines) && method_exists($srcobject, 'fetch_lines'))
+							{
+								$srcobject->fetch_lines();
+								$lines = $srcobject->lines;
+							}
 
 							$fk_parent_line=0;
 							$num=count($lines);
diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php
index e579bc21640536ab94bc7ff4e3f56cab98ee09fd..81505af34ee8800cb484318d08ddd90811cf899d 100644
--- a/htdocs/compta/facture/prelevement.php
+++ b/htdocs/compta/facture/prelevement.php
@@ -1,7 +1,7 @@
 <?php
 /* Copyright (C) 2002-2005	Rodolphe Quiedeville	<rodolphe@quiedeville.org>
  * Copyright (C) 2004		Eric Seigne				<eric.seigne@ryxeo.com>
- * Copyright (C) 2004-2010	Laurent Destailleur		<eldy@users.sourceforge.net>
+ * Copyright (C) 2004-2014	Laurent Destailleur		<eldy@users.sourceforge.net>
  * Copyright (C) 2005-2012	Regis Houssin			<regis.houssin@capnetworks.com>
  * Copyright (C) 2010		Juanjo Menent			<jmenent@2byte.es>
  *
@@ -142,7 +142,7 @@ if ($object->id > 0)
 
 	/*
 	 *   Facture
-	*/
+	 */
 	print '<table class="border" width="100%">';
 
 	$linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
@@ -450,7 +450,7 @@ if ($object->id > 0)
 
 	/*
 	 * Buttons
-	*/
+	 */
 	print "\n<div class=\"tabsAction\">\n";
 
 	// Add a withdraw request
@@ -467,7 +467,11 @@ if ($object->id > 0)
 	}
 	else
 	{
-		if ($num == 0) print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("AlreadyPayed")).'">'.$langs->trans("MakeWithdrawRequest").'</a>';
+		if ($num == 0)
+		{
+			if ($object->statut > 0) print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("AlreadyPayed")).'">'.$langs->trans("MakeWithdrawRequest").'</a>';
+			else print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("Draft")).'">'.$langs->trans("MakeWithdrawRequest").'</a>';
+		}
 		else print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("RequestAlreadyDone")).'">'.$langs->trans("MakeWithdrawRequest").'</a>';
 	}
 
diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index 417f4362000917a7c8ec77c4f7fd0751e0fa194f..5c21c3c5fbfea7ab9195327253e3c1d2d4c769c2 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -1219,11 +1219,11 @@ class BonPrelevement extends CommonObject
 
 
     /**
-     *	Generate a withdrawal file. Generation Formats:
-     *   France: CFONB
-     *   Spain:  AEB19 (if external module EsAEB is enabled)
-     *   Others: Warning message
-     *	File is generated with name this->filename
+     * Generate a withdrawal file.
+     * Generation Formats:
+     * - Europe: SEPA (France: CFONB no more supported, Spain:  AEB19 if external module EsAEB is enabled)
+     * - Others countries: Warning message
+     * File is generated with name this->filename
      *
      *	@return		int			0 if OK, <0 if KO
      */
@@ -1410,7 +1410,7 @@ class BonPrelevement extends CommonObject
 			fputs($this->file, '		</PmtInf>'.$CrLf);
 			fputs($this->file, '	</CstmrDrctDbtInitn>'.$CrLf);
 			fputs($this->file, '</Document>'.$CrLf);
-			
+
 			$sql = "SELECT pl.amount";
 			$sql.= " FROM";
 			$sql.= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
@@ -1419,14 +1419,14 @@ class BonPrelevement extends CommonObject
 			$sql.= " WHERE pl.fk_prelevement_bons = ".$this->id;
 			$sql.= " AND pl.rowid = pf.fk_prelevement_lignes";
 			$sql.= " AND pf.fk_facture = f.rowid";
-			
+
 			//Lines
 			$i = 0;
 			$resql=$this->db->query($sql);
 			if ($resql)
 			{
 				$num = $this->db->num_rows($resql);
-			
+
 				while ($i < $num)
 				{
 					$obj = $this->db->fetch_object($resql);
@@ -1574,7 +1574,7 @@ class BonPrelevement extends CommonObject
      *	@param	string		$row_bic			rib.bic AS bic,
      *	@param	string		$row_datec			soc.datec,
      *	@param	string		$row_drum			soc.rowid AS drum
-     *	@return	void
+     *	@return	string							Return string with SEPA part DrctDbtTxInf
      */
     function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_facnumber, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum)
     {
@@ -1598,15 +1598,15 @@ class BonPrelevement extends CommonObject
 		$XML_DEBITOR .='				</DrctDbtTx>'.$CrLf;
 		$XML_DEBITOR .='				<DbtrAgt>'.$CrLf;
 		$XML_DEBITOR .='					<FinInstnId>'.$CrLf;
-		$XML_DEBITOR .='						<BIC>'.$row_iban.'</BIC>'.$CrLf;
+		$XML_DEBITOR .='						<BIC>'.$row_bic.'</BIC>'.$CrLf;
 		$XML_DEBITOR .='					</FinInstnId>'.$CrLf;
 		$XML_DEBITOR .='				</DbtrAgt>'.$CrLf;
 		$XML_DEBITOR .='				<Dbtr>'.$CrLf;
-		$XML_DEBITOR .='					<Nm>'.strtoupper($row_nom).'</Nm>'.$CrLf;
+		$XML_DEBITOR .='					<Nm>'.strtoupper(dol_string_unaccent($row_nom)).'</Nm>'.$CrLf;
 		$XML_DEBITOR .='					<PstlAdr>'.$CrLf;
 		$XML_DEBITOR .='						<Ctry>'.$row_country_code.'</Ctry>'.$CrLf;
 		$XML_DEBITOR .='						<AdrLine>'.strtr($row_adr, array(CHR(13) => ", ", CHR(10) => "")).'</AdrLine>'.$CrLf;
-		$XML_DEBITOR .='						<AdrLine>'.$row_zip.' '.$row_town.'</AdrLine>'.$CrLf;
+		$XML_DEBITOR .='						<AdrLine>'.dol_string_unaccent($row_zip.' '.$row_town).'</AdrLine>'.$CrLf;
 		$XML_DEBITOR .='					</PstlAdr>'.$CrLf;
 		$XML_DEBITOR .='				</Dbtr>'.$CrLf;
 		$XML_DEBITOR .='				<DbtrAcct>'.$CrLf;
@@ -1689,7 +1689,8 @@ class BonPrelevement extends CommonObject
     }
 
     /**
-     *	Write sender of request (me)
+     *	Write sender of request (me).
+     *  Note: The tag PmtInf is opened here but closed into caller
      *
      *	@param	string	$configuration	conf
      *	@param	date	$ladate			Date
diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php
index 7bcd7fcbc8d8d9d0abcbcb2bbb0670f3541ea840..38a2b3f1095939a0339711448474e9a77f8b8aa9 100644
--- a/htdocs/contrat/fiche.php
+++ b/htdocs/contrat/fiche.php
@@ -250,7 +250,11 @@ if ($action == 'add' && $user->rights->contrat->creer)
 	            {
 	                $srcobject->fetch_thirdparty();
 					$lines = $srcobject->lines;
-	                if (empty($lines) && method_exists($srcobject,'fetch_lines'))  $lines = $srcobject->fetch_lines();
+	                if (empty($lines) && method_exists($srcobject,'fetch_lines'))
+	                {
+	                	$srcobject->fetch_lines();
+	                	$lines = $srcobject->lines;
+	                }
 
 	                $fk_parent_line=0;
 	                $num=count($lines);
@@ -337,10 +341,10 @@ if ($action == 'add' && $user->rights->contrat->creer)
 	    }
 	    else
 	    {
-	    	
+
 	    	// Fill array 'array_options' with data from add form
 	    	$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
-	    	
+
 	        $result = $object->create($user);
 	        if ($result > 0)
 	        {
@@ -715,7 +719,7 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra
 		$error ++;
 
 	if (! $error) {
-		
+
 			$result = $object->insertExtraFields();
 			if ($result < 0) {
 				$error ++;
@@ -948,7 +952,7 @@ if ($action == 'create')
     // Other attributes
     $parameters=array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"');
     $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-    
+
     // Other attributes
     if (empty($reshook) && ! empty($extrafields->attribute_label)) {
     	print $object->showOptionals($extrafields, 'edit');
@@ -1112,7 +1116,7 @@ else
         // Other attributes
         $parameters=array('colspan' => ' colspan="3"');
         $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-        
+
         $res = $object->fetch_optionals($object->id, $extralabels);
         if (empty($reshook) && ! empty($extrafields->attribute_label)) {
         	foreach ($extrafields->attribute_label as $key => $label) {
@@ -1132,16 +1136,16 @@ else
         			if (in_array($extrafields->attribute_type [$key], array('date','datetime'))) {
         				$value = isset($_POST ["options_" . $key]) ? dol_mktime($_POST ["options_" . $key . "hour"], $_POST ["options_" . $key . "min"], 0, $_POST ["options_" . $key . "month"], $_POST ["options_" . $key . "day"], $_POST ["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]);
         			}
-        
+
         			if ($action == 'edit_extras' && $user->rights->commande->creer && GETPOST('attribute') == $key) {
         				print '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formcontract">';
         				print '<input type="hidden" name="action" value="update_extras">';
         				print '<input type="hidden" name="attribute" value="' . $key . '">';
         				print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
         				print '<input type="hidden" name="id" value="' . $object->id . '">';
-        
+
         				print $extrafields->showInputField($key, $value);
-        
+
         				print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
         				print '</form>';
         			} else {
@@ -1153,9 +1157,9 @@ else
         		}
         	}
         }
-        
-        
-        
+
+
+
 
         print "</table>";
 
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index 9299702a1bb0e517c6ca34ed799fded1b0c503a0..1cdf6fd194e321c9bf76e7442f4d24e6e7f6f9b8 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -1148,7 +1148,7 @@ class FormFile
                 print '</td>';
                 print '<td align="center">' . dol_print_date(dol_now(), "dayhour", "tzuser") . '</td>';
                 print '<td align="right"></td>';
-                print '<td align="right" colspan="2">';
+                print '<td align="right">';
                 print '<input type="submit" name="save" class="button" value="' . dol_escape_htmltag($langs->trans('Save')) . '">';
                 print '<input type="submit" name="cancel" class="button" value="' . dol_escape_htmltag($langs->trans('Cancel')) . '">';
                 print '</td>';
@@ -1163,7 +1163,7 @@ class FormFile
                 print '<td align="right"></td>';
                 print '<td align="center">' . dol_print_date($link->datea, "dayhour", "tzuser") . '</td>';
                 print '<td align="center"></td>';
-                print '<td align="right" colspan="2">';
+                print '<td align="right">';
                 print '<a href="' . $_SERVER['PHP_SELF'] . '?action=update&linkid=' . $link->id . $param . '" class="editfilelink" >' . img_edit() . '</a>';	// id= is included into $param
                 if ($permtodelete) {
                     print ' &nbsp; <a href="'. $_SERVER['PHP_SELF'] .'?action=delete&linkid=' . $link->id . $param . '" class="deletefilelink">' . img_delete() . '</a>';	// id= is included into $param
@@ -1176,7 +1176,7 @@ class FormFile
         }
         if ($nboflinks == 0)
         {
-            print '<tr ' . $bc[$var] . '><td colspan="4">';
+            print '<tr ' . $bc[$var] . '><td colspan="5">';
             print $langs->trans("NoLinkFound");
             print '</td></tr>';
         }
diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php
index 4201cde9e9dc544c1564585de825ef34f8141a6b..1d447430dfe2a894af0e72c2e119b2952b278345 100644
--- a/htdocs/core/lib/date.lib.php
+++ b/htdocs/core/lib/date.lib.php
@@ -505,7 +505,7 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
     $tmpday = date($tmparray[0])-$seconds;
 	$tmpday = date("d",$tmpday);
 
-	//Check first day of week is form this month or not
+	//Check first day of week is in same month than current day or not
 	if ($tmpday>$day)
     {
     	$prev_month = $month-1;
@@ -522,15 +522,17 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
     	$prev_month = $month;
 		$prev_year  = $year;
     }
-
+	$tmpmonth = $prev_month;
+	$tmpyear = $prev_year;
+    
     //Get first day of next week
 	$tmptime=dol_mktime(12,0,0,$month,$tmpday,$year,1,0);
 	$tmptime-=24*60*60*7;
 	$tmparray=dol_getdate($tmptime,true);
     $prev_day   = $tmparray['mday'];
 
-    //Check first day of week is form this month or not
-	if ($prev_day>$tmpday)
+    //Check prev day of week is in same month than first day or not
+    if ($prev_day>$tmpday)
     {
     	$prev_month = $month-1;
 		$prev_year  = $year;
@@ -544,7 +546,7 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
 
     $week = date("W",dol_mktime(0,0,0,$month,$tmpday,$year,$gm));
 
-	return array('year' => $year, 'month' => $month, 'week' => $week, 'first_day' => $tmpday, 'prev_year' => $prev_year, 'prev_month' => $prev_month, 'prev_day' => $prev_day);
+	return array('year' => $year, 'month' => $month, 'week' => $week, 'first_day' => $tmpday, 'first_month' => $tmpmonth, 'first_year' => $tmpyear, 'prev_year' => $prev_year, 'prev_month' => $prev_month, 'prev_day' => $prev_day);
 }
 
 /**
diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php
index 9a52ce477884128a1360fad331b658c68d5c88f3..c11c1d549a96b7751908c33fe4d064a8c6e54990 100644
--- a/htdocs/expedition/fiche.php
+++ b/htdocs/expedition/fiche.php
@@ -112,7 +112,6 @@ if ($action == 'add')
     $classname = ucfirst($object->origin);
     $objectsrc = new $classname($db);
     $objectsrc->fetch($object->origin_id);
-    //$object->fetch_lines();
 
     $object->socid					= $objectsrc->socid;
     $object->ref_customer			= $objectsrc->ref_client;
@@ -698,7 +697,7 @@ if ($action == 'create')
             print '<td colspan="3">';
             $expe->fetch_delivery_methods();
             print $form->selectarray("shipping_method_id",$expe->meths,GETPOST('shipping_method_id','int'),1,0,0,"",1);
-            if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
+            if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
             print "</td></tr>\n";
 
             // Tracking number
@@ -717,7 +716,6 @@ if ($action == 'create')
              * Lignes de commandes
              */
 
-            //$lines = $object->fetch_lines(1);
             $numAsked = count($object->lines);
 
             print '<script type="text/javascript" language="javascript">
@@ -1262,7 +1260,7 @@ else if ($id || $ref)
 			print '<input type="hidden" name="action" value="setshipping_method_id">';
 			$object->fetch_delivery_methods();
 			print $form->selectarray("shipping_method_id",$object->meths,$object->shipping_method_id,1,0,0,"",1);
-			if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
+			if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
 			print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
 			print '</form>';
 		}
diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php
index aa475c0417687b2d3882e2234faa179c5fbb4094..5c556ff23564b24fbafeb7e0e64467ba7f1e6767 100644
--- a/htdocs/fichinter/class/fichinter.class.php
+++ b/htdocs/fichinter/class/fichinter.class.php
@@ -973,9 +973,9 @@ class Fichinter extends CommonObject
 	}
 
 	/**
-	 *	Load array lines
+	 *	Load array lines ->lines
 	 *
-	 *	@return		int		<0 if Ko,	>0 if OK
+	 *	@return		int		<0 if KO, >0 if OK
 	 */
 	function fetch_lines()
 	{
diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php
index fcd037551363a141928b2f4df2313cb6b5542114..944dbae6b456ba1706583231fb4677c3c339711d 100644
--- a/htdocs/fichinter/fiche.php
+++ b/htdocs/fichinter/fiche.php
@@ -63,6 +63,7 @@ $confirm	= GETPOST('confirm','alpha');
 $mesg		= GETPOST('msg','alpha');
 $origin=GETPOST('origin','alpha');
 $originid=(GETPOST('originid','int')?GETPOST('originid','int'):GETPOST('origin_id','int')); // For backward compatibility
+$note_public = GETPOST('note_public');
 
 //PDF
 $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
@@ -211,7 +212,11 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
 				{
 					$srcobject->fetch_thirdparty();
 					$lines = $srcobject->lines;
-					if (empty($lines) && method_exists($srcobject,'fetch_lines'))  $lines = $srcobject->fetch_lines();
+					if (empty($lines) && method_exists($srcobject,'fetch_lines'))
+					{
+						$srcobject->fetch_lines();
+						$lines = $srcobject->lines;
+					}
 
 					$fk_parent_line=0;
 					$num=count($lines);
@@ -912,15 +917,19 @@ if ($action == 'create')
 			$classname = ucfirst($subelement);
 			$objectsrc = new $classname($db);
 			$objectsrc->fetch(GETPOST('originid'));
-			if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines'))  $objectsrc->fetch_lines();
+			if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines'))
+			{
+				$objectsrc->fetch_lines();
+				$lines = $objectsrc->lines;
+			}
 			$objectsrc->fetch_thirdparty();
 
 			$projectid          = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:'');
 
 			$soc = $objectsrc->client;
 
-			$note_private		= (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : ''));
-			$note_public		= (! empty($objectsrc->note_public) ? $objectsrc->note_public : '');
+			$note_private		= (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : GETPOST('note_private')));
+			$note_public		= (! empty($objectsrc->note_public) ? $objectsrc->note_public : GETPOST('note_public'));
 
 			// Object source contacts list
 			$srccontactslist = $objectsrc->liste_contact(-1,'external',1);
@@ -928,8 +937,6 @@ if ($action == 'create')
 	}
 	else {
 		$projectid = GETPOST('projectid','int');
-		$note_private = '';
-		$note_public = '';
 	}
 
 	if (! $conf->global->FICHEINTER_ADDON)
@@ -966,7 +973,7 @@ if ($action == 'create')
 		// Description (must be a textarea and not html must be allowed (used in list view)
 		print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
 		print '<td>';
-		print '<textarea name="description" cols="80" rows="'.ROWS_3.'"></textarea>';
+		print '<textarea name="description" cols="80" rows="'.ROWS_3.'">'.GETPOST('description').'</textarea>';
 		print '</td></tr>';
 
 		// Project
diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index f36ff37fc1a22ed2df7d0c80b4a758784a6057b7..d91c6ce37648c824c8392dc262719cbef24e0f0b 100644
--- a/htdocs/fourn/facture/fiche.php
+++ b/htdocs/fourn/facture/fiche.php
@@ -355,7 +355,11 @@ elseif ($action == 'add' && $user->rights->fournisseur->facture->creer)
                 if ($result > 0)
                 {
                     $lines = $srcobject->lines;
-                    if (empty($lines) && method_exists($srcobject,'fetch_lines'))  $lines = $srcobject->fetch_lines();
+                    if (empty($lines) && method_exists($srcobject,'fetch_lines'))
+                    {
+                    	$srcobject->fetch_lines();
+                    	$lines = $srcobject->lines;
+                    }
 
                     $num=count($lines);
                     for ($i = 0; $i < $num; $i++)
diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php
index 58ad4f1bc0d6872aedd26c6d01d7eb77e2381951..dd5ebf3857349b66ec003e8a37bc3cd85e3dfa83 100644
--- a/htdocs/livraison/class/livraison.class.php
+++ b/htdocs/livraison/class/livraison.class.php
@@ -148,7 +148,7 @@ class Livraison extends CommonObject
 				{
 					$commande = new Commande($this->db);
 					$commande->id = $this->commande_id;
-					$this->lines = $commande->fetch_lines();
+					$commande->fetch_lines();
 				}
 
 
diff --git a/htdocs/livraison/fiche.php b/htdocs/livraison/fiche.php
index c3b7e7da1c767e19ca989e881f90d0ef6bd09991..8b91b916e0bd11fb68414537075d42cca65b5567 100644
--- a/htdocs/livraison/fiche.php
+++ b/htdocs/livraison/fiche.php
@@ -185,7 +185,7 @@ if ($action == 'builddoc')	// En get ou en post
 	$object = new Livraison($db);
 	$object->fetch($id);
 	$object->fetch_thirdparty();
-	
+
 	// Save last template used to generate document
 	if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
 
@@ -317,7 +317,8 @@ if ($action == 'create')
 		 */
 		print '<br><table class="noborder" width="100%">';
 
-		$lines = $commande->fetch_lines(1);
+		$commande->fetch_lines(1);
+		$lines = $commande->lines;
 
 		// Lecture des livraisons deja effectuees
 		$commande->livraison_array();
@@ -515,7 +516,7 @@ else
 			if (($delivery->origin == 'shipment' || $delivery->origin == 'expedition') && $delivery->origin_id > 0)
 			{
 				$linkback = '<a href="'.DOL_URL_ROOT.'/expedition/liste.php">'.$langs->trans("BackToList").'</a>';
-				
+
 				// Ref
 				print '<tr><td width="20%">'.$langs->trans("RefSending").'</td>';
 				print '<td colspan="3">';
@@ -523,8 +524,8 @@ else
 				//print $form->showrefnav($expedition, 'refshipment', $linkback, 1, 'ref', 'ref');
 				print $form->showrefnav($expedition, 'refshipment', $linkback, 0, 'ref', 'ref');
 				print '</td></tr>';
-			}			
-				
+			}
+
 			// Ref
 			print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
 			print '<td colspan="3">'.$delivery->ref.'</td></tr>';
diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php
index c20c4ebca0d2a0496e0784b49aa3a519633a6309..4a01e125ba52b4c5a6116575c5e68ef4a02462ae 100644
--- a/htdocs/opensurvey/class/opensurveysondage.class.php
+++ b/htdocs/opensurvey/class/opensurveysondage.class.php
@@ -392,7 +392,7 @@ class Opensurveysondage extends CommonObject
 	/**
 	 * Return array of lines
 	 *
-	 * @return 	array	Array of lines
+	 * @return 	int		<0 if KO, >0 if OK
 	 */
 	function fetch_lines()
 	{
@@ -418,7 +418,7 @@ class Opensurveysondage extends CommonObject
 
 		$this->lines=$ret;
 
-		return $this->lines;
+		return count($this->lines);
 	}
 
 	/**
diff --git a/htdocs/opensurvey/public/studs.php b/htdocs/opensurvey/public/studs.php
index 01bb969df20aa1555fe50fd9b21b9deab9a6a52c..525f488b0cd7201a8e0ee8add61e9c3bb2f61fc6 100644
--- a/htdocs/opensurvey/public/studs.php
+++ b/htdocs/opensurvey/public/studs.php
@@ -43,7 +43,7 @@ $object=new Opensurveysondage($db);
 $result=$object->fetch(0,$numsondage);
 if ($result <= 0) dol_print_error('','Failed to get survey id '.$numsondage);
 
-$nblignes=count($object->fetch_lines());
+$nblignes=$object->fetch_lines();
 
 //If the survey has not yet finished, then it can be modified
 $canbemodified = ($object->date_fin > dol_now());
diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php
index 48c585c0f2e80ffe2589f6cf6e1a3532593f0e9c..00daab24b2771e942a1c8510d28d62c32ee2f8c9 100644
--- a/htdocs/opensurvey/results.php
+++ b/htdocs/opensurvey/results.php
@@ -42,7 +42,7 @@ $object=new Opensurveysondage($db);
 $result=$object->fetch(0,$numsondage);
 if ($result <= 0) dol_print_error('','Failed to get survey id '.$numsondage);
 
-$nblignes=count($object->fetch_lines());
+$nblignes=$object->fetch_lines();
 
 
 /*
diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php
index 797ab688e5c134f9a91782500036fe22857e774c..bedc41e244613abd47954fa3ddef87eed3741839 100644
--- a/htdocs/societe/consumption.php
+++ b/htdocs/societe/consumption.php
@@ -48,7 +48,7 @@ if ($page == -1) {
 }
 $offset = $conf->liste_limit * $page;
 if (! $sortorder) $sortorder='DESC';
-if (! $sortfield) $sortfield='datePrint';
+if (! $sortfield) $sortfield='dateprint';
 $limit = $conf->liste_limit;
 
 // Search fields
@@ -168,12 +168,12 @@ if ($type_element == 'invoice')
 { 	// Customer : show products from invoices
 	require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
 	$documentstatic=new Facture($db);
-	$sql_select = 'SELECT f.rowid as doc_id, f.facnumber as doc_number, f.type as doc_type, f.datef as datePrint, ';
+	$sql_select = 'SELECT f.rowid as doc_id, f.facnumber as doc_number, f.type as doc_type, f.datef as dateprint, ';
 	$tables_from = MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."facturedet as d";
 	$where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid;
 	$where.= " AND d.fk_facture = f.rowid";
 	$where.= " AND f.entity = ".$conf->entity;
-	$datePrint = 'f.datef';
+	$dateprint = 'f.datef';
 	$doc_number='f.facnumber';
 	$thirdTypeSelect='customer';
 }
@@ -181,12 +181,12 @@ if ($type_element == 'order')
 {
 	require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
 	$documentstatic=new Commande($db);
-	$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as datePrint, ';
+	$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as dateprint, ';
 	$tables_from = MAIN_DB_PREFIX."commande as c,".MAIN_DB_PREFIX."commandedet as d";
 	$where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid;
 	$where.= " AND d.fk_commande = c.rowid";
 	$where.= " AND c.entity = ".$conf->entity;
-	$datePrint = 'c.datef';
+	$dateprint = 'c.datef';
 	$doc_number='c.ref';
 	$thirdTypeSelect='customer';
 }
@@ -194,11 +194,11 @@ if ($type_element == 'supplier_invoice')
 { 	// Supplier : Show products from invoices.
 	require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
 	$documentstatic=new FactureFournisseur($db);
-	$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datef as datePrint, ';
+	$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datef as dateprint, ';
 	$tables_from = MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."facture_fourn_det as d";
 	$where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid;
 	$where.= " AND d.fk_facture_fourn = f.rowid";
-	$datePrint = 'f.datef';
+	$dateprint = 'f.datef';
 	$doc_number='f.ref';
 	$thirdTypeSelect='supplier';
 }
@@ -206,11 +206,11 @@ if ($type_element == 'supplier_order')
 { 	// Supplier : Show products from orders.
 	require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
 	$documentstatic=new CommandeFournisseur($db);
-	$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as datePrint, ';
+	$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, ';
 	$tables_from = MAIN_DB_PREFIX."commande_fournisseur as c,".MAIN_DB_PREFIX."commande_fournisseurdet as d";
 	$where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid;
 	$where.= " AND d.fk_commande = c.rowid";
-	$datePrint = 'c.date_valid';
+	$dateprint = 'c.date_valid';
 	$doc_number='c.ref';
 	$thirdTypeSelect='supplier';
 }
@@ -226,14 +226,14 @@ if ($month > 0) {
 	if ($year > 0) {
 		$start = dol_mktime(0, 0, 0, $month, 1, $year);
 		$end = dol_time_plus_duree($start,1,'m') - 1;
-		$sql.= " AND ".$datePrint." BETWEEN '".$db->idate($start)."' AND '".$db->idate($end)."'";
+		$sql.= " AND ".$dateprint." BETWEEN '".$db->idate($start)."' AND '".$db->idate($end)."'";
 	} else {
-		$sql.= " AND date_format(".$datePrint.", '%m') = '".sprintf('%02d',$month)."'";
+		$sql.= " AND date_format(".$dateprint.", '%m') = '".sprintf('%02d',$month)."'";
 	}
 } else if ($year > 0) {
 	$start = dol_mktime(0, 0, 0, 1, 1, $year);
 	$end = dol_time_plus_duree($start,1,'y') - 1;
-	$sql.= " AND ".$datePrint." BETWEEN '".$db->idate($start)."' AND '".$db->idate($end)."'";
+	$sql.= " AND ".$dateprint." BETWEEN '".$db->idate($start)."' AND '".$db->idate($end)."'";
 }
 if ($sref) $sql.= " AND ".$doc_number." LIKE '%".$sref."%'";
 if ($sprod_fulldescr) $sql.= " AND (d.description LIKE '%".$sprod_fulldescr."%' OR p.label LIKE '%".$sprod_fulldescr."%')";
@@ -259,7 +259,7 @@ print '<table class="liste" width="100%">'."\n";
 // Titles with sort buttons
 print '<tr class="liste_titre">';
 print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'doc_number','',$param,'align="left"',$sortfield,$sortorder);
-print_liste_field_titre($langs->trans('Date'),$_SERVER['PHP_SELF'],'datePrint','',$param,'align="center" width="150"',$sortfield,$sortorder);
+print_liste_field_titre($langs->trans('Date'),$_SERVER['PHP_SELF'],'dateprint','',$param,'align="center" width="150"',$sortfield,$sortorder);
 print_liste_field_titre($langs->trans('Product'),$_SERVER['PHP_SELF'],'','',$param,'align="left"',$sortfield,$sortorder);
 print_liste_field_titre($langs->trans('Quantity'),$_SERVER['PHP_SELF'],'prod_qty','',$param,'align="right"',$sortfield,$sortorder);
 // Filters
@@ -295,7 +295,7 @@ if ($sql_select)
 		$documentstatic->type=$objp->type;
 		print $documentstatic->getNomUrl(1);
 		print '</td>';
-		print '<td align="center" width="80">'.dol_print_date($db->jdate($objp->datePrint),'day').'</td>';
+		print '<td align="center" width="80">'.dol_print_date($db->jdate($objp->dateprint),'day').'</td>';
 
 		print '<td>';