diff --git a/ChangeLog b/ChangeLog
index 960bc09756beace10f666ec89986daa65b410c88..1763325fd3e712537590e079698f587eb2753f9e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -224,7 +224,7 @@ Dolibarr better:
   hook afterLogin or afterLoginFailed instead.
 - The trigger USER_CREATE_FROM_CONTACT has been replace with USER_CREATE and property context is now filled
   to make difference between creation from contact or not.
-
+- Function get_exdir require now 6 parameters. This is to prepare a future feature.
 
 ***** ChangeLog for 3.7.2 compared to 3.7.1 *****
 FIX [ bug #2855 ] Wrong translation key in localtax report page
diff --git a/build/debian/README.howto b/build/debian/README.howto
index 6140412b831874f046b1164517db29546fb33c90..3c111f0a0ecf128db092f3585d29eea67d0eec64 100644
--- a/build/debian/README.howto
+++ b/build/debian/README.howto
@@ -117,7 +117,7 @@ http://bugs.debian.org/package
 severity 123 xxx
 
 
-##### Update but tracker system
+##### Update bug tracker system
 
 To set status of a bug to "pending"
 > bts --smtp-host=yoursmtpserver tag 999999 +pending
@@ -249,7 +249,7 @@ from git clone dir and make link to git.
 * If local branch upstream and pristine-tar does not exists, create it
 from origin/upstream and origin/pristine.
 
-* If new upstream is available onto sourceforge, launch:
+* When new upstream is available onto sourceforge, launch:
 > debian/get-orig-source.sh
 If script fails with error Bad certificate, you can set "export PERL_LWP_SSL_VERIFY_HOSTNAME=0" to solve this.
 
@@ -273,8 +273,8 @@ Note: If there was errors solved manually after get-orig-sources.sh, you may nee
 * Fix debian/* files used to build package.
 Add an entry into debian/changelog
 > dch -v x.y.z+dfsgw-v "My comment" will add entry.
-For example: dch -v x.y.z+dfsgw-1 "New upstream release." for a new version (x.y.z = version, w start from 1 and increaed for each new import)
-Then modify changelog to replace "version" or "unstable" with "UNRELEASED".
+For example: dch -v x.y.z+dfsgw-1 "New upstream release." for a new version (x.y.z = version, w start from 1 and increased for each new import)
+Then check/modify changelog to replace "version" or "unstable" with "UNRELEASED".
 Then check/modify also the user/date signature:
 - Date must have format reported by "date -R"
 - Name and email must match value into debian/control file (Entry added here is used by next step).
@@ -299,7 +299,7 @@ Note: Package is built into directory ../build-area
 
 * If package .deb is ok:
 Note: If there was errors managed manually, you may need to make a git commit but do not use option "amend" previous commit
-> git push --all ou git push origin --all
+> git push --all
 
 * If ok, you can tag.
 > Edit debian/changelog to replace "UNRELEASED" into "unstable", then push
diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php
index 6d553f1b236d6109793c95243251bf679de4b565..204ac36ea0356f9b52f0ed9e55d8b5a5711b502d 100644
--- a/htdocs/admin/tools/listevents.php
+++ b/htdocs/admin/tools/listevents.php
@@ -182,7 +182,8 @@ if ($result)
 		$formquestion=array();
 		print $form->formconfirm($_SERVER["PHP_SELF"].'?noparam=noparam', $langs->trans('PurgeAuditEvents'), $langs->trans('ConfirmPurgeAuditEvents'),'confirm_purge',$formquestion,'no',1);
 	}
-
+	
+	print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
 	print '<table class="liste" width="100%">';
 	print '<tr class="liste_titre">';
 	print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"e.dateevent","","",'align="left"',$sortfield,$sortorder);
@@ -195,7 +196,6 @@ if ($result)
 
 
 	// Lignes des champs de filtres
-	print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
 	print '<tr class="liste_titre">';
 
 	print '<td class="liste_titre" width="15%">'.$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).$form->select_date($date_end,'date_end',0,0,0,'',1,0,1).'</td>';
@@ -222,7 +222,6 @@ if ($result)
 	print '</td>';
 
 	print "</tr>\n";
-	print '</form>';
 
 	$var=True;
 
@@ -283,7 +282,7 @@ if ($result)
 		if ($usefilter) print '<tr><td colspan="6">'.$langs->trans("NoEventFoundWithCriteria").'</td></tr>';
 		else print '<tr><td colspan="6">'.$langs->trans("NoEventOrNoAuditSetup").'</td></tr>';
 	}
-	print "</table>";
+	print "</table></form>";
 	$db->free($result);
 
 	if ($num)
diff --git a/htdocs/comm/askpricesupplier/index.php b/htdocs/comm/askpricesupplier/index.php
index 4eddadf38038b6d7ae7874a04a26361d12a6ede2..681a889ed25709a931ca54d6abe147674612f5e9 100644
--- a/htdocs/comm/askpricesupplier/index.php
+++ b/htdocs/comm/askpricesupplier/index.php
@@ -61,15 +61,15 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
  * Search form
  */
 $var=false;
-print '<table class="noborder nohover" width="100%">';
 print '<form method="post" action="'.DOL_URL_ROOT.'/comm/askpricesupplier/list.php">';
 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<table class="noborder nohover" width="100%">';
 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchRequest").'</td></tr>';
 print '<tr '.$bc[$var].'><td>';
 print $langs->trans("Ref").':</td><td><input type="text" class="flat" name="sref" size=18></td><td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
 print '<tr '.$bc[$var].'><td class="nowrap">'.$langs->trans("Other").':</td><td><input type="text" class="flat" name="sall" size="18"></td>';
 print '</tr>';
-print "</form></table><br>\n";
+print "</table></form><br>\n";
 
 
 /*
diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php
index ef2e2c48bf84e3b9e59d65213095945174310a60..43441306e34e741c46b8b72d33188ebde1f2c93a 100644
--- a/htdocs/comm/mailing/list.php
+++ b/htdocs/comm/mailing/list.php
@@ -96,7 +96,8 @@ if ($result)
 
 	$param = "&amp;sall=".$sall;
 	if ($filteremail) $param.='&amp;filteremail='.urlencode($filteremail);
-
+	
+	print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
 	print '<table class="liste">';
 	print '<tr class="liste_titre">';
 	print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"m.rowid",$param,"","",$sortfield,$sortorder);
@@ -108,7 +109,6 @@ if ($result)
 	print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],($filteremail?"mc.statut":"m.statut"),$param,"",'align="right"',$sortfield,$sortorder);
 	print "</tr>\n";
 
-	print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
 	print '<tr class="liste_titre">';
 	print '<td class="liste_titre">';
 	print '<input type="text" class="flat" name="sref" value="'.$sref.'" size="6">';
@@ -123,7 +123,6 @@ if ($result)
 	print '<td class="liste_titre" align="right"><input class="liste_titre" type="image" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
 	print "</td>";
 	print "</tr>\n";
-	print '</form>';
 
 	$var=True;
 
@@ -177,7 +176,7 @@ if ($result)
 		print "</tr>\n";
 		$i++;
 	}
-	print "</table>";
+	print '</table></form>';
 	$db->free($result);
 }
 else
diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php
index 428e561f4fecba152dd3f78ae5f51af6ff693b47..8fc50f853c60e39d1f0c9da46f46572e8c15c3bc 100644
--- a/htdocs/comm/propal/index.php
+++ b/htdocs/comm/propal/index.php
@@ -63,15 +63,15 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
  * Search form
  */
 $var=false;
-print '<table class="noborder nohover" width="100%">';
 print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal/list.php">';
 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<table class="noborder nohover" width="100%">';
 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchPropal").'</td></tr>';
 print '<tr '.$bc[$var].'><td>';
 print $langs->trans("Ref").':</td><td><input type="text" class="flat" name="sref" size=18></td><td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
 print '<tr '.$bc[$var].'><td class="nowrap">'.$langs->trans("Other").':</td><td><input type="text" class="flat" name="sall" size="18"></td>';
 print '</tr>';
-print "</form></table><br>\n";
+print "</table></form><br>\n";
 
 
 /*
diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php
index 0d72eac46e3df829449940c0ce1476574b76fb16..f5f600ddd08dfd9ca7b0a18c8ce3fcc202ad226f 100644
--- a/htdocs/comm/prospect/index.php
+++ b/htdocs/comm/prospect/index.php
@@ -54,15 +54,15 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
 if (! empty($conf->propal->enabled))
 {
 	$var=false;
-	print '<table class="noborder nohover" width="100%">';
 	print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal.php">';
 	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+	print '<table class="noborder nohover" width="100%">';
 	print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAProposal").'</td></tr>';
 	print '<tr '.$bc[$var].'><td>';
 	print $langs->trans("Ref").':</td><td><input type="text" class="flat" name="sf_ref" size="18"></td><td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
 	print '<tr '.$bc[$var].'><td class="nowrap">'.$langs->trans("Other").':</td><td><input type="text" class="flat" name="sall" size="18"></td>';
 	print '</tr>';
-	print "</form></table><br>\n";
+	print "</table></form><br>\n";
 }
 
 /*
diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php
index 7957803a5d5a15216a031e94c82d1e4dc65e0e66..5baa7b7c30fcc696681feb31481f35097bcc994b 100644
--- a/htdocs/commande/index.php
+++ b/htdocs/commande/index.php
@@ -62,15 +62,15 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
 
 // Search customer orders
 $var=false;
-print '<table class="noborder nohover" width="100%">';
 print '<form method="post" action="'.DOL_URL_ROOT.'/commande/list.php">';
 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<table class="noborder nohover" width="100%">';
 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchOrder").'</td></tr>';
 print '<tr '.$bc[$var].'><td>';
 print $langs->trans("Ref").':</td><td><input type="text" class="flat" name="sref" size=18></td><td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
 print '<tr '.$bc[$var].'><td class="nowrap">'.$langs->trans("Other").':</td><td><input type="text" class="flat" name="sall" size="18"></td>';
 print '</tr>';
-print "</form></table><br>\n";
+print "</table></form><br>\n";
 
 
 /*
diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php
index b854503f0844701d0a05bed8dd97402c30fe29ac..00755959ab924131540be11a01f07f44eb01a818 100644
--- a/htdocs/compta/bank/categ.php
+++ b/htdocs/compta/bank/categ.php
@@ -158,7 +158,6 @@ if ($result)
 	$db->free($result);
 }
 
-print "</form>";
 
 /*
  * Line to add category
@@ -172,9 +171,7 @@ if ($action != 'edit')
 	print '</tr>';
 }
 
-print "</table>";
-
-print "</form>";
+print '</table></form>';
 
 llxFooter();
 
diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php
index e69e2dce2e7cc23c6959a3d22c7ef167f63e406f..4186dae55616a59d5fd44976c89fafadd84ffd37 100644
--- a/htdocs/compta/bank/ligne.php
+++ b/htdocs/compta/bank/ligne.php
@@ -596,8 +596,7 @@ if ($result)
             }
             print '</tr>';
 
-            print "</table>";
-            print '</form>';
+            print '</table></form>';
         }
 
     }
@@ -610,22 +609,21 @@ print '</div>';
 
 
 // List of bank categories
-
 print '<br>';
-print '<table class="noborder" width="100%">';
 
 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?rowid='.$rowid.'&amp;id='.$id.'">';
 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 print '<input type="hidden" name="action" value="class">';
 print '<input type="hidden" name="orig_account" value="'.$orig_account.'">';
+
+print '<table class="noborder" width="100%">';
 print '<tr class="liste_titre"><td>'.$langs->trans("Rubriques").'</td><td colspan="2">';
 if ($user->rights->banque->modifier)
 {
     print '<select class="flat" name="cat1">'.$options.'</select>&nbsp;';
     print '<input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
 }
-print "</tr>";
-print "</form>";
+print '</tr>';
 
 $sql = "SELECT c.label, c.rowid";
 $sql.= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c";
@@ -650,13 +648,13 @@ if ($result)
         {
             print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=delete_categ&amp;rowid='.$rowid.'&amp;fk_categ='.$objp->rowid.'">'.img_delete($langs->trans("Remove")).'</a></td>';
         }
-        print "</tr>";
+        print '</tr>';
 
         $i++;
     }
     $db->free($result);
 }
-print "</table>";
+print '</table></form>';
 
 llxFooter();
 
diff --git a/htdocs/compta/facture/mergepdftool.php b/htdocs/compta/facture/mergepdftool.php
index d29f237c331d728fa2db4621346df8ae75f26ffb..27741077f6d1d54595002de8e73db978e724c930 100644
--- a/htdocs/compta/facture/mergepdftool.php
+++ b/htdocs/compta/facture/mergepdftool.php
@@ -56,7 +56,7 @@ if (GETPOST('button_search'))
 }
 if ($option == 'late') $filter = 'paye:0';
 if ($option == 'unpaidall') $filter = 'paye:0';
-if ($mode == 'sendremind' && $filter == '') $filter = 'paye:0';
+if ($mode == 'sendmassremind' && $filter == '') $filter = 'paye:0';
 if ($filter == '') $filter = 'paye:0';
 
 $search_user = GETPOST('search_user','int');
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index 85fdbc2870f589bcdeff5e9729c43ea9334b5b7e..cf65c1c54561c28f504cc62721f70900f3be26f7 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -269,7 +269,7 @@ if ($result)
 
     print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
     print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-    print '<input type="hidden" name="view" value="'.htmlspecialchars($view).'">';
+    print '<input type="hidden" name="view" value="'.dol_escape_htmltag($view).'">';
     print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
     print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
 
diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php
index eedb01837599421908f6f6a213c0fffc4a35ba94..cd07db385aa80b27bd5b1bd9c09e801d0bf1a1e7 100644
--- a/htdocs/contrat/services.php
+++ b/htdocs/contrat/services.php
@@ -153,7 +153,9 @@ if ($resql)
 	if ($mode == "4" && $filter == "expired") $title=$langs->trans("ListOfExpiredServices");
 	if ($mode == "5") $title=$langs->trans("ListOfClosedServices");
 	print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num,$totalnboflines,'title_commercial.png');
-
+	
+	print '<form method="POST" action="'. $_SERVER["PHP_SELF"] .'">';
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 	print '<table class="liste" width="100%">';
 
 	print '<tr class="liste_titre">';
@@ -169,9 +171,6 @@ if ($resql)
 	print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"], "cd.statut,c.statut",$param,"","align=\"right\"",$sortfield,$sortorder);
 	print "</tr>\n";
 
-	print '<form method="POST" action="'. $_SERVER["PHP_SELF"] .'">';
-	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-
 	print '<tr class="liste_titre">';
 	print '<td class="liste_titre">';
 	print '<input type="hidden" name="filter" value="'.$filter.'">';
@@ -203,7 +202,6 @@ if ($resql)
     print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
 	print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
     print "</td></tr>\n";
-	print '</form>';
 
 	$contractstatic=new Contrat($db);
 	$productstatic=new Product($db);
@@ -278,7 +276,7 @@ if ($resql)
 	}
 	$db->free($resql);
 
-	print "</table>";
+	print '</table></form>';
 
 }
 else
diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php
index 4695be5eaa00bc813e02524e9be65d1bffac4a40..dde2a559cd3fc082d63de90b6ce61a73b164e0f3 100644
--- a/htdocs/core/boxes/box_contacts.php
+++ b/htdocs/core/boxes/box_contacts.php
@@ -105,7 +105,7 @@ class box_contacts extends ModeleBoxes
 
                     $this->info_box_contents[$line][] = array(
                         'td' => 'align="left"',
-                        'text' => $societestatic->getNomUrl(1),
+                        'text' => ($objp->fk_soc > 0 ? $societestatic->getNomUrl(1) : ''),
                         'asis' => 1,
                     );
 
diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php
index 8e9ca33b2a0e3889ca963dcfa99021f233431f7e..437637c3bdf966e9ff2a345a076da8a2a9606f8b 100644
--- a/htdocs/core/class/html.formother.class.php
+++ b/htdocs/core/class/html.formother.class.php
@@ -303,13 +303,14 @@ class FormOther
      * Return select list for categories (to use in form search selectors)
      *
      * @param	int		$type			Type of categories (0=product, 1=suppliers, 2=customers, 3=members)
-     * @param  integer	$selected     	Preselected value
-     * @param  string	$htmlname      	Name of combo list
+     * @param   integer	$selected     	Preselected value
+     * @param   string	$htmlname      	Name of combo list
      * @param	int		$nocateg		Show also an entry "Not categorized"
+     * @param   int     $showempty      Add also an empty line
      * @return string		        	Html combo list code
      * @see	select_all_categories
      */
-    function select_categories($type,$selected=0,$htmlname='search_categ',$nocateg=0)
+    function select_categories($type,$selected=0,$htmlname='search_categ',$nocateg=0,$showempty=1)
     {
         global $conf, $langs;
         require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
@@ -331,7 +332,7 @@ class FormOther
 
         // Print a select with each of them
         $moreforfilter.='<select class="flat minwidth100" id="select_categ_'.$htmlname.'" name="'.$htmlname.'"'.$nodatarole.'>';
-        $moreforfilter.='<option value="">&nbsp;</option>';	// Should use -1 to say nothing
+        if ($showempty) $moreforfilter.='<option value="0">&nbsp;</option>';	// Should use -1 to say nothing
 
         if (is_array($tab_categs))
         {
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index e0a7ec1b9f2894b38f13d345ed66ce0bf344a454..cc718334f13ce43f69a0c404bee9357102c00891 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -3743,7 +3743,7 @@ function yn($yesno, $case=1, $color=0)
  *
  *	@param	string	$num            Id of object
  *	@param  int		$level		    Level of subdirs to return (1, 2 or 3 levels)
- * 	@param	int		$alpha		    Use alpha ref
+ * 	@param	int		$alpha		    0=Keep number only to forge path, 1=Use alpha part afer the - (By default, use 0).
  *  @param  int		$withoutslash   0=With slash at end, 1=without slash at end (except if '/', we return '')
  *  @param	Object	$object			Object
  *  @param	string	$modulepart		Type of object ('invoice_supplier, 'donation', 'invoice', ...')
diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php
index f924922cb87ce90825458f4a6a7046cfa47e893f..89d658fa01a085841ed9eae505824ca367270472 100644
--- a/htdocs/core/lib/project.lib.php
+++ b/htdocs/core/lib/project.lib.php
@@ -1023,14 +1023,13 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
 	if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE))
 	{
 		//Add the year filter input
+		print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">';
 		print '<table width="100%">';
 		print '<tr>';
 		print '<td>'.$langs->trans("Year").'</td>';
-		print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">';
 		print '<td style="text-align:right"><input type="text" size="4" class="flat" name="project_year_filter" value="'.$project_year_filter.'"/>';
-		print '</form>';
 		print "</tr>\n";
-		print '</table>';
+		print '</table></form>';
 	}
 }
 
diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php
index fcac8bd2646b06064d0cd0e23f9e28f45fc9a046..0471fad1877865437bec4645937eb09e2dcf57b6 100644
--- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php
+++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php
@@ -154,6 +154,11 @@ class pdf_baleine extends ModelePDFProjects
 				$task = new Task($this->db);
 				$tasksarray = $task->getTasksArray(0,0,$object->id);
 
+                if (! $object->id > 0)  // Special case when used with object = specimen, we may return all lines 
+                {
+                    $tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray)));
+                }
+                
 				$object->lines=$tasksarray;
 				$nblignes=count($object->lines);
 
@@ -230,12 +235,12 @@ class pdf_baleine extends ModelePDFProjects
 					$pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $planned_workload, 0, 'R');
 					$pdf->SetXY($this->posxprogress, $curY);
 					$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R');
+
 					$pdf->SetXY($this->posxdatestart, $curY);
 					$pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C');
 					$pdf->SetXY($this->posxdateend, $curY);
 					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C');
 
-
 					$pageposafter=$pdf->getPage();
 
 					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php
index 7bca394d16135a59bdac58abf000d6318d7946ea..4a8839ef865a1b8f4f4f47e3aa2315d97eac21ae 100644
--- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php
+++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php
@@ -111,7 +111,7 @@ class pdf_beluga extends ModelePDFProjects
 	{
 		global $user,$langs,$conf;
 
-$formproject=new FormProjets($this->db);
+        $formproject=new FormProjets($this->db);
 
 		if (! is_object($outputlangs)) $outputlangs=$langs;
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@@ -223,233 +223,216 @@ $formproject=new FormProjets($this->db);
 				$iniY = $tab_top + 7;
 				$curY = $tab_top + 7;
 				$nexY = $tab_top + 7;
-
-$listofreferent=array(
-'propal'=>array(
-	'name'=>"Proposals",
-	'title'=>"ListProposalsAssociatedProject",
-	'class'=>'Propal',
-	'table'=>'propal',
-    'datefieldname'=>'datep',
-	'test'=>$conf->propal->enabled && $user->rights->propale->lire),
-'order'=>array(
-	'name'=>"CustomersOrders",
-	'title'=>"ListOrdersAssociatedProject",
-	'class'=>'Commande',
-	'table'=>'commande',
-	'datefieldname'=>'date_commande',
-	'test'=>$conf->commande->enabled && $user->rights->commande->lire),
-'invoice'=>array(
-	'name'=>"CustomersInvoices",
-	'title'=>"ListInvoicesAssociatedProject",
-	'class'=>'Facture',
-	'margin'=>'add',
-	'table'=>'facture',
-	'datefieldname'=>'datef',
-	'test'=>$conf->facture->enabled && $user->rights->facture->lire),
-'invoice_predefined'=>array(
-	'name'=>"PredefinedInvoices",
-	'title'=>"ListPredefinedInvoicesAssociatedProject",
-	'class'=>'FactureRec',
-	'table'=>'facture_rec',
-	'datefieldname'=>'datec',
-	'test'=>$conf->facture->enabled && $user->rights->facture->lire),
-'order_supplier'=>array(
-	'name'=>"SuppliersOrders",
-	'title'=>"ListSupplierOrdersAssociatedProject",
-	'class'=>'CommandeFournisseur',
-	'table'=>'commande_fournisseur',
-	'datefieldname'=>'date_commande',
-	'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire),
-'invoice_supplier'=>array(
-	'name'=>"BillsSuppliers",
-	'title'=>"ListSupplierInvoicesAssociatedProject",
-	'class'=>'FactureFournisseur',
-	'margin'=>'minus',
-	'table'=>'facture_fourn',
-	'datefieldname'=>'datef',
-	'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire),
-'contract'=>array(
-	'name'=>"Contracts",
-	'title'=>"ListContractAssociatedProject",
-	'class'=>'Contrat',
-	'table'=>'contrat',
-	'datefieldname'=>'date_contrat',
-	'test'=>$conf->contrat->enabled && $user->rights->contrat->lire),
-'intervention'=>array(
-	'name'=>"Interventions",
-	'title'=>"ListFichinterAssociatedProject",
-	'class'=>'Fichinter',
-	'table'=>'fichinter',
-	'datefieldname'=>'date_valid',
-	'disableamount'=>1,
-	'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire),
-'trip'=>array(
-	'name'=>"TripsAndExpenses",
-	'title'=>"ListTripAssociatedProject",
-	'class'=>'Deplacement',
-	'table'=>'deplacement',
-	'datefieldname'=>'dated',
-	'margin'=>'minus',
-	'disableamount'=>1,
-	'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire),
-'agenda'=>array(
-	'name'=>"Agenda",
-	'title'=>"ListActionsAssociatedProject",
-	'class'=>'ActionComm',
-	'table'=>'actioncomm',
-	'datefieldname'=>'datep',
-	'disableamount'=>1,
-	'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->lire)
-);
-
-
-foreach ($listofreferent as $key => $value)
-{
-	$title=$value['title'];
-	$classname=$value['class'];
-	$tablename=$value['table'];
-	$datefieldname=$value['datefieldname'];
-	$qualified=$value['test'];
-
-	if ($qualified)
-	{
-		$elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee);
-		$num=count($elementarray);
-if ($num> 0)
-{
-		$nexY = $pdf->GetY()+5;
-		$curY = $nexY;
-		$pdf->SetXY($this->posxref, $curY);
-		$pdf->MultiCell($this->posxstatut-$this->posxref, 3, $outputlangs->transnoentities($title), 0, 'L');
-
-		
-		$selectList=$formproject->select_element($tablename,$project->thirdparty->id);
-		$nexY = $pdf->GetY()+1;
-		$curY = $nexY;
-		$pdf->SetXY($this->posxref, $curY);
-		$pdf->MultiCell($this->posxdate-$this->posxref, 3, $outputlangs->transnoentities("Ref"), 1, 'L');
-		$pdf->SetXY($this->posxdate, $curY);
-		$pdf->MultiCell($this->posxsociety-$this->posxdate, 3, $outputlangs->transnoentities("Date"), 1, 'C');
-		$pdf->SetXY($this->posxsociety, $curY);
-		$pdf->MultiCell($this->posxamountht-$this->posxsociety, 3, $outputlangs->transnoentities("ThirdParty"), 1, 'L');
-		if (empty($value['disableamount'])) 
-		{
-			$pdf->SetXY($this->posxamountht, $curY);
-			$pdf->MultiCell($this->posxamountttc-$this->posxamountht, 3, $outputlangs->transnoentities("AmountHT"), 1, 'R');
-			$pdf->SetXY($this->posxamountttc, $curY);
-			$pdf->MultiCell($this->posxstatut-$this->posxamountttc, 3, $outputlangs->transnoentities("AmountTTC"), 1, 'R');
-		}
-		else
-		{
-			$pdf->SetXY($this->posxamountht, $curY);
-			$pdf->MultiCell($this->posxstatut-$this->posxamountht, 3, "", 1, 'R');
-		}
-		$pdf->SetXY($this->posxstatut, $curY);
-		$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxstatut, 3, $outputlangs->transnoentities("Statut"), 1, 'R');
-
-		
-		if (is_array($elementarray) && count($elementarray)>0)
-		{
-			$nexY = $pdf->GetY();
-			$curY = $nexY;
-			
-			$total_ht = 0;
-			$total_ttc = 0;
-			$num=count($elementarray);
-			for ($i = 0; $i < $num; $i++)
-			{
-				$element = new $classname($this->db);
-				$element->fetch($elementarray[$i]);
-				$element->fetch_thirdparty();
-				//print $classname;
-
-				$qualifiedfortotal=true;
-				if ($key == 'invoice')
-				{
-					if ($element->close_code == 'replaced') $qualifiedfortotal=false;	// Replacement invoice
-				}
-
-				$pdf->SetXY($this->posxref, $curY);
-				$pdf->MultiCell($this->posxdate-$this->posxref, 3, $element->ref, 1, 'L');
-
-
-				// Date
-				if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') $date=$element->date_commande;
-				else
-				{
-					$date=$element->date;
-					if (empty($date)) $date=$element->datep;
-					if (empty($date)) $date=$element->date_contrat;
-					if (empty($date)) $date=$element->datev; //Fiche inter
-				}
-				
-				$pdf->SetXY($this->posxdate, $curY);
-				$pdf->MultiCell($this->posxsociety-$this->posxdate, 3, dol_print_date($date,'day'), 1, 'C');
-		
-				$pdf->SetXY($this->posxsociety, $curY);
-				if (is_object($element->thirdparty))
-					$pdf->MultiCell($this->posxamountht-$this->posxsociety, 3, $element->thirdparty->name, 1, 'L');
-
-
-                // Amount without tax
-				if (empty($value['disableamount']))
-				{
-					$pdf->SetXY($this->posxamountht, $curY);
-					$pdf->MultiCell($this->posxamountttc-$this->posxamountht, 3, 
-						(isset($element->total_ht)?price($element->total_ht):'&nbsp;'), 1, 'R');
-					$pdf->SetXY($this->posxamountttc, $curY);
-					$pdf->MultiCell($this->posxstatut-$this->posxamountttc, 3, 
-						(isset($element->total_ttc)?price($element->total_ttc):'&nbsp;'), 1, 'R');
-				}
-				else
-				{
-					$pdf->SetXY($this->posxamountht, $curY);
-					$pdf->MultiCell($this->posxstatut-$this->posxamountht, 3, "", 1, 'R');
-				}
-
-				// Status
-				if ($element instanceof CommonInvoice) {
-					//This applies for Facture and FactureFournisseur
-					$outputstatut= $element->getLibStatut(1, $element->getSommePaiement());
-				} else {
-					$outputstatut = $element->getLibStatut(1);
-				}
-				$pdf->SetXY($this->posxstatut, $curY);
-				$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxstatut, 3, 
-					$outputstatut, 1, 'R',false, 1, '', '', true, 0, true);
-
-				if ($qualifiedfortotal)
-				{
-					$total_ht = $total_ht + $element->total_ht;
-					$total_ttc = $total_ttc + $element->total_ttc;
-				}
-$nexY = $pdf->GetY();
-				$curY = $nexY;
-			}
-
-
-			if (empty($value['disableamount']))
-			{
-				$curY = $nexY;
-				$pdf->SetXY($this->posxref, $curY);
-				$pdf->MultiCell($this->posxamountttc-$this->posxref, 3, "TOTAL", 1, 'L');
-				$pdf->SetXY($this->posxamountht, $curY);
-				$pdf->MultiCell($this->posxamountttc-$this->posxamountht, 3, 
-					(isset($element->total_ht)?price($total_ht):'&nbsp;'), 1, 'R');
-				$pdf->SetXY($this->posxamountttc, $curY);
-				$pdf->MultiCell($this->posxstatut-$this->posxamountttc, 3, 
-					(isset($element->total_ttc)?price($total_ttc):'&nbsp;'), 1, 'R');
-				$pdf->SetXY($this->posxstatut, $curY);
-				$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxstatut, 3, 
-					$outputlangs->transnoentities("Nb")." ".$num, 1, 'L');
-			}
-			$nexY = $pdf->GetY()+5;
-			$curY = $nexY;
-		}
-	}
-}
-}
+                                    
+                $listofreferent=array(
+                    'propal'=>array(
+                    	'name'=>"Proposals",
+                    	'title'=>"ListProposalsAssociatedProject",
+                    	'class'=>'Propal',
+                    	'table'=>'propal',
+                        'datefieldname'=>'datep',
+                    	'test'=>$conf->propal->enabled && $user->rights->propale->lire),
+                    'order'=>array(
+                    	'name'=>"CustomersOrders",
+                    	'title'=>"ListOrdersAssociatedProject",
+                    	'class'=>'Commande',
+                    	'table'=>'commande',
+                    	'datefieldname'=>'date_commande',
+                    	'test'=>$conf->commande->enabled && $user->rights->commande->lire),
+                    'invoice'=>array(
+                    	'name'=>"CustomersInvoices",
+                    	'title'=>"ListInvoicesAssociatedProject",
+                    	'class'=>'Facture',
+                    	'margin'=>'add',
+                    	'table'=>'facture',
+                    	'datefieldname'=>'datef',
+                    	'test'=>$conf->facture->enabled && $user->rights->facture->lire),
+                    'invoice_predefined'=>array(
+                    	'name'=>"PredefinedInvoices",
+                    	'title'=>"ListPredefinedInvoicesAssociatedProject",
+                    	'class'=>'FactureRec',
+                    	'table'=>'facture_rec',
+                    	'datefieldname'=>'datec',
+                    	'test'=>$conf->facture->enabled && $user->rights->facture->lire),
+                    'order_supplier'=>array(
+                    	'name'=>"SuppliersOrders",
+                    	'title'=>"ListSupplierOrdersAssociatedProject",
+                    	'class'=>'CommandeFournisseur',
+                    	'table'=>'commande_fournisseur',
+                    	'datefieldname'=>'date_commande',
+                    	'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire),
+                    'invoice_supplier'=>array(
+                    	'name'=>"BillsSuppliers",
+                    	'title'=>"ListSupplierInvoicesAssociatedProject",
+                    	'class'=>'FactureFournisseur',
+                    	'margin'=>'minus',
+                    	'table'=>'facture_fourn',
+                    	'datefieldname'=>'datef',
+                    	'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire),
+                    'contract'=>array(
+                    	'name'=>"Contracts",
+                    	'title'=>"ListContractAssociatedProject",
+                    	'class'=>'Contrat',
+                    	'table'=>'contrat',
+                    	'datefieldname'=>'date_contrat',
+                    	'test'=>$conf->contrat->enabled && $user->rights->contrat->lire),
+                    'intervention'=>array(
+                    	'name'=>"Interventions",
+                    	'title'=>"ListFichinterAssociatedProject",
+                    	'class'=>'Fichinter',
+                    	'table'=>'fichinter',
+                    	'datefieldname'=>'date_valid',
+                    	'disableamount'=>1,
+                    	'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire),
+                    'trip'=>array(
+                    	'name'=>"TripsAndExpenses",
+                    	'title'=>"ListTripAssociatedProject",
+                    	'class'=>'Deplacement',
+                    	'table'=>'deplacement',
+                    	'datefieldname'=>'dated',
+                    	'margin'=>'minus',
+                    	'disableamount'=>1,
+                    	'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire),
+                    'agenda'=>array(
+                    	'name'=>"Agenda",
+                    	'title'=>"ListActionsAssociatedProject",
+                    	'class'=>'ActionComm',
+                    	'table'=>'actioncomm',
+                    	'datefieldname'=>'datep',
+                    	'disableamount'=>1,
+                    	'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->lire)
+                );
+                
+                
+                foreach ($listofreferent as $key => $value)
+                {
+                	$title=$value['title'];
+                	$classname=$value['class'];
+                	$tablename=$value['table'];
+                	$datefieldname=$value['datefieldname'];
+                	$qualified=$value['test'];
+                	
+                    if ($qualified)
+                    {
+                        $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee);
+                        $num = count($elementarray);
+                        if ($num > 0)
+                        {
+                            $nexY = $pdf->GetY() + 5;
+                            $curY = $nexY;
+                            $pdf->SetXY($this->posxref, $curY);
+                            $pdf->MultiCell($this->posxstatut - $this->posxref, 3, $outputlangs->transnoentities($title), 0, 'L');
+                            
+                            $selectList = $formproject->select_element($tablename, $project->thirdparty->id);
+                            $nexY = $pdf->GetY() + 1;
+                            $curY = $nexY;
+                            $pdf->SetXY($this->posxref, $curY);
+                            $pdf->MultiCell($this->posxdate - $this->posxref, 3, $outputlangs->transnoentities("Ref"), 1, 'L');
+                            $pdf->SetXY($this->posxdate, $curY);
+                            $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, $outputlangs->transnoentities("Date"), 1, 'C');
+                            $pdf->SetXY($this->posxsociety, $curY);
+                            $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $outputlangs->transnoentities("ThirdParty"), 1, 'L');
+                            if (empty($value['disableamount'])) {
+                                $pdf->SetXY($this->posxamountht, $curY);
+                                $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, $outputlangs->transnoentities("AmountHT"), 1, 'R');
+                                $pdf->SetXY($this->posxamountttc, $curY);
+                                $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, $outputlangs->transnoentities("AmountTTC"), 1, 'R');
+                            } else {
+                                $pdf->SetXY($this->posxamountht, $curY);
+                                $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R');
+                            }
+                            $pdf->SetXY($this->posxstatut, $curY);
+                            $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Statut"), 1, 'R');
+                            
+                            if (is_array($elementarray) && count($elementarray) > 0)
+                            {
+                                $nexY = $pdf->GetY();
+                                $curY = $nexY;
+                                
+                                $total_ht = 0;
+                                $total_ttc = 0;
+                                $num = count($elementarray);
+                                for ($i = 0; $i < $num; $i ++) {
+                                    $element = new $classname($this->db);
+                                    $element->fetch($elementarray[$i]);
+                                    $element->fetch_thirdparty();
+                                    // print $classname;
+                                    
+                                    $qualifiedfortotal = true;
+                                    if ($key == 'invoice') {
+                                        if ($element->close_code == 'replaced')
+                                            $qualifiedfortotal = false; // Replacement invoice
+                                    }
+                                    
+                                    $pdf->SetXY($this->posxref, $curY);
+                                    $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
+                                    
+                                    // Date
+                                    if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order')
+                                        $date = $element->date_commande;
+                                    else {
+                                        $date = $element->date;
+                                        if (empty($date))
+                                            $date = $element->datep;
+                                        if (empty($date))
+                                            $date = $element->date_contrat;
+                                        if (empty($date))
+                                            $date = $element->datev; // Fiche inter
+                                    }
+                                    
+                                    $pdf->SetXY($this->posxdate, $curY);
+                                    $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, dol_print_date($date, 'day'), 1, 'C');
+                                    
+                                    $pdf->SetXY($this->posxsociety, $curY);
+                                    if (is_object($element->thirdparty))
+                                        $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $element->thirdparty->name, 1, 'L');
+                                        
+                                        // Amount without tax
+                                    if (empty($value['disableamount'])) {
+                                        $pdf->SetXY($this->posxamountht, $curY);
+                                        $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, (isset($element->total_ht) ? price($element->total_ht) : '&nbsp;'), 1, 'R');
+                                        $pdf->SetXY($this->posxamountttc, $curY);
+                                        $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($element->total_ttc) : '&nbsp;'), 1, 'R');
+                                    } else {
+                                        $pdf->SetXY($this->posxamountht, $curY);
+                                        $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R');
+                                    }
+                                    
+                                    // Status
+                                    if ($element instanceof CommonInvoice) {
+                                        // This applies for Facture and FactureFournisseur
+                                        $outputstatut = $element->getLibStatut(1, $element->getSommePaiement());
+                                    } else {
+                                        $outputstatut = $element->getLibStatut(1);
+                                    }
+                                    $pdf->SetXY($this->posxstatut, $curY);
+                                    $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputstatut, 1, 'R', false, 1, '', '', true, 0, true);
+                                    
+                                    if ($qualifiedfortotal) {
+                                        $total_ht = $total_ht + $element->total_ht;
+                                        $total_ttc = $total_ttc + $element->total_ttc;
+                                    }
+                                    $nexY = $pdf->GetY();
+                                    $curY = $nexY;
+                                }
+                                
+                                if (empty($value['disableamount'])) {
+                                    $curY = $nexY;
+                                    $pdf->SetXY($this->posxref, $curY);
+                                    $pdf->MultiCell($this->posxamountttc - $this->posxref, 3, "TOTAL", 1, 'L');
+                                    $pdf->SetXY($this->posxamountht, $curY);
+                                    $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, (isset($element->total_ht) ? price($total_ht) : '&nbsp;'), 1, 'R');
+                                    $pdf->SetXY($this->posxamountttc, $curY);
+                                    $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($total_ttc) : '&nbsp;'), 1, 'R');
+                                    $pdf->SetXY($this->posxstatut, $curY);
+                                    $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Nb") . " " . $num, 1, 'L');
+                                }
+                                $nexY = $pdf->GetY() + 5;
+                                $curY = $nexY;
+                            }
+                        }
+                    }
+                }
 
 
 
diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php
index e38b8f873bdb3466980685257afb2de6cbab1805..ec427addef9b7b94f9a9fd70a977e9b9f3951243 100644
--- a/htdocs/core/tpl/objectline_edit.tpl.php
+++ b/htdocs/core/tpl/objectline_edit.tpl.php
@@ -322,7 +322,7 @@ if (! empty($conf->margin->enabled))
 		var remise = $("input[name='remise_percent']:first");
 
 		var rate = $("input[name='"+npRate+"']:first");
-		if (rate.val() == '') return true;
+		if (rate.val() == '' || (typeof rate.val()) == 'undefined' ) return true;
 
 		if (! $.isNumeric(rate.val().replace(',','.')))
 		{
@@ -331,7 +331,7 @@ if (! empty($conf->margin->enabled))
 			setTimeout(function () { rate.focus() }, 50);
 			return false;
 		}
-		if (npRate == "markRate" && rate.val() >= 100)
+		if (npRate == "np_markRate" && rate.val() >= 100)
 		{
 			alert('<?php echo $langs->trans("markRateShouldBeLesserThan100"); ?>');
 			e.stopPropagation();
@@ -347,9 +347,11 @@ if (! empty($conf->margin->enabled))
 			bpjs=price2numjs(buying_price.val());
 			ratejs=price2numjs(rate.val());
 
-			if (npRate == "marginRate")
+			/* console.log(npRate+" - "+bpjs+" - "+ratejs); */
+
+			if (npRate == "np_marginRate")
 				price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
-			else if (npRate == "markRate")
+			else if (npRate == "np_markRate")
 				price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
 		}
 		$("input[name='price_ht']:first").val(price);	// TODO Must use a function like php price to have here a formated value
diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php
index ffc453d395c6c2b5d28ad1c923d37c1e3f0b8f7a..e72af4de60105c384b8bd804394d4ffd55153165 100644
--- a/htdocs/expedition/card.php
+++ b/htdocs/expedition/card.php
@@ -888,11 +888,11 @@ if ($action == 'create')
 					}
 					else
 					{
-						print '<tr><td colspan="3" ></td><td align="center">';
+						print '<tr><td colspan="3" ></td><td align="center">';
 						print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="0" disabled="disabled"> ';
-						print '</td>';
-						
-						print '<td align="left">';
+						print '</td>';
+						
+						print '<td align="left">';
 						print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $staticwarehouse->libelle);
 					}
 				}
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index a599a4a7b4b70f8b1d1f94d4d05610b2987dee66..3dc1d555d2805593641fd095c4ec85c73df0d7ec 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -658,7 +658,7 @@ class Expedition extends CommonObject
 						$result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref));
 						if ($result < 0) {
 							$error++; break;
-							}
+						}
 					}
 					else
 					{
@@ -860,8 +860,8 @@ class Expedition extends CommonObject
 					// $value['q']=qty to move
 					// $value['id_batch']=id into llx_product_batch of record to move
 					//var_dump($value);
-					
-					$linebatch = new ExpeditionLineBatch($this->db);
+
+				    $linebatch = new ExpeditionLineBatch($this->db);
 					$ret=$linebatch->fetchFromStock($value['id_batch']);	// load serial, sellby, eatby
 					if ($ret<0)
 					{
diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php
index 2d5d0e207c676c75b28e0b6c46e56f55067e6d2e..dbfece1838162267df80d58460b53b2267132b98 100644
--- a/htdocs/expedition/index.php
+++ b/htdocs/expedition/index.php
@@ -48,13 +48,13 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
 
 
 $var=false;
-print '<table class="noborder nohover" width="100%">';
 print '<form method="post" action="list.php">';
 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<table class="noborder nohover" width="100%">';
 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchASending").'</td></tr>';
 print '<tr '.$bc[$var].'><td>';
 print $langs->trans("Ref").':</td><td><input type="text" class="flat" name="sf_ref" size="18"></td><td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
-print "</form></table><br>\n";
+print "</table></form><br>\n";
 
 /*
  * Shipments to validate
diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php
index 1bf286ff5aa49d38cd972693661dcdf80def0dd4..5e24417f61851ebb9e115190221129c04e715072 100644
--- a/htdocs/fourn/class/fournisseur.facture.class.php
+++ b/htdocs/fourn/class/fournisseur.facture.class.php
@@ -1151,7 +1151,7 @@ class FactureFournisseur extends CommonInvoice
         if (empty($txtva)) $txtva=0;
         if (empty($txlocaltax1)) $txlocaltax1=0;
         if (empty($txlocaltax2)) $txlocaltax2=0;
-
+        
         $remise_percent=price2num($remise_percent);
         $qty=price2num($qty);
         $pu=price2num($pu);
@@ -1197,7 +1197,7 @@ class FactureFournisseur extends CommonInvoice
             }
             else
             {
-                dol_syslog("Error error=".$this->error, LOG_ERR);
+                dol_syslog("Error after updateline error=".$this->error, LOG_ERR);
                 $this->db->rollback();
                 return -1;
             }
@@ -2096,16 +2096,17 @@ class SupplierInvoiceLine extends CommonObjectLine
 
 		$this->db->begin();
 
-		if ($this->fk_product) {
+		if (empty($this->fk_product))
+		{
 			$fk_product = "null";
 		} else {
 			$fk_product = $this->fk_product;
 		}
 
-		if ($this->fk_unit) {
-			$fk_unit = "'".$this->db->escape($this->fk_unit)."'";
-		} else {
+		if (empty($this->fk_unit)) {
 			$fk_unit = "null";
+		} else {
+		    $fk_unit = "'".$this->db->escape($this->fk_unit)."'";
 		}
 
 		$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET";
diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php
index 60b9b65e8e8927cf7b9f574fdfb0f9cec74c8d90..c877589851de79f7cf9c751a9c5a40916253e008 100644
--- a/htdocs/fourn/commande/index.php
+++ b/htdocs/fourn/commande/index.php
@@ -58,15 +58,15 @@ print '<tr valign="top"><td class="notopnoleft" width="30%">';
  * Search form
  */
 $var=false;
-print '<table class="noborder nohover" width="100%">';
 print '<form method="post" action="list.php">';
 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<table class="noborder nohover" width="100%">';
 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchOrder").'</td></tr>';
 print '<tr '.$bc[$var].'><td>';
 print $langs->trans("Ref").':</td><td><input type="text" class="flat" name="search_ref" size=18></td><td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
 print '<tr '.$bc[$var].'><td class="nowrap">'.$langs->trans("Other").':</td><td><input type="text" class="flat" name="search_all" size="18"></td>';
 print '</tr>';
-print "</form></table><br>\n";
+print "</table></form><br>\n";
 
 
 /*
diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php
index 49c16d38bc8866edbde79dfa9a57b5668ef437bc..a1fa57f97f478df9715ee2ee42e2044877a168d1 100644
--- a/htdocs/fourn/commande/orderstoinvoice.php
+++ b/htdocs/fourn/commande/orderstoinvoice.php
@@ -453,7 +453,9 @@ if (($action != 'create' && $action != 'add') && !$error) {
 			$companystatic->nom = $soc->nom;
 			print '<h3>' . $companystatic->getNomUrl(1, 'customer') . '</h3>';
 		}
-
+		
+		print '<form method="get" action="orderstoinvoice.php">';
+		print '<input type="hidden" name="socid" value="' . $socid . '">';
 		print '<table class="noborder" width="100%">';
 		print '<tr class="liste_titre">';
 		print_liste_field_titre($langs->trans('Ref'), 'orderstoinvoice.php', 'c.ref', '', '&amp;socid=' . $socid, '', $sortfield, $sortorder);
@@ -465,8 +467,6 @@ if (($action != 'create' && $action != 'add') && !$error) {
 		print "</tr>\n";
 
 		// Lignes des champs de filtre
-		print '<form method="get" action="orderstoinvoice.php">';
-		print '<input type="hidden" name="socid" value="' . $socid . '">';
 		print '<tr class="liste_titre">';
 		print '<td class="liste_titre">';
 		// REF
@@ -497,7 +497,6 @@ if (($action != 'create' && $action != 'add') && !$error) {
 		print '</td>';
 
 		print '</td></tr>';
-		print '</form>';
 
 		print '<form name="orders2invoice" action="orderstoinvoice.php" method="GET">';
 		$var = True;
diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang
index dc6cece9c3bc12a5be448becdf8dc612b1cfa8de..c15f99996d42e5f2d0a0faa79212ef24bd6fc447 100644
--- a/htdocs/langs/en_US/projects.lang
+++ b/htdocs/langs/en_US/projects.lang
@@ -143,7 +143,8 @@ SelectElement=Select element
 AddElement=Link to element
 UnlinkElement=Unlink element
 # Documents models
-DocumentModelBaleine=A complete project's report model (logo...)
+DocumentModelBeluga=Project template for linked objects overview
+DocumentModelBaleine=Project report template for tasks
 PlannedWorkload=Planned workload
 PlannedWorkloadShort=Workload
 WorkloadOccupation=Workload assignation
diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php
index e018bc4744651f7056b24b1027b364da1ceb021d..f8e106a7e7e88e746b9e3c81ff6b24500b6c2295 100644
--- a/htdocs/projet/activity/perday.php
+++ b/htdocs/projet/activity/perday.php
@@ -258,6 +258,7 @@ llxHeader("",$title,"");
 
 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project');
 
+$param=($mode?'&amp;mode='.$mode:'');
 
 // Show navigation bar
 $nav ="<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\">".img_previous($langs->trans("Previous"))."</a>\n";
diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php
index 6ffc38cfbe9699f1cbdc365b6066631caebfcc6e..619803ecbc372f66c1cfdbc9cce191b73350543c 100644
--- a/htdocs/projet/activity/perweek.php
+++ b/htdocs/projet/activity/perweek.php
@@ -236,6 +236,7 @@ llxHeader("",$title,"",'','','',array('/core/js/timesheet.js'));
 
 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project');
 
+$param=($mode?'&amp;mode='.$mode:'');
 
 // Show navigation bar
 $nav ="<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\">".img_previous($langs->trans("Previous"))."</a>\n";