diff --git a/ChangeLog b/ChangeLog
index 639529576521b11fc0ad98d44fb8297e3068367c..bddd25d5dd11a18674c195665e83387c1ab86dc5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,9 @@ English Dolibarr ChangeLog
 
 ***** ChangeLog for 3.3 compared to 3.2 *****
 For users:
+- New: If field "signature" is filled into user table, text is added 
+  at end of predefined email texts. If option MAIL_DO_NOT_USE_SIGN is on, this
+  feautre is disabled.
 - New: Add link "Back to list" on all cards.
 - New: After first install, warning are visible onto mandatory setup not
   configured. Show also total number of activated modules.
@@ -42,7 +45,8 @@ For developers:
 - New: Can add a link on title field of added dictionnary.
 - New: Uniformize code.
 - New: Add option WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER and 
-       WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER
+       WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER.
+- New: A module can add several css and js.
 - New: removed deprecated methods
        ldap::connect, formadmin::select_lang,
        html::select_tva
diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl
index 6951bc28bb4bfebb9a0ddccfebe84307d87ef188..bff952cd317f5b09fa84bce4e474327acddb49da 100755
--- a/build/makepack-dolibarr.pl
+++ b/build/makepack-dolibarr.pl
@@ -324,7 +324,6 @@ if ($nboftargetok) {
 	    $ret=`rm -f  $BUILDROOT/$PROJECT/.gitignore $BUILDROOT/$PROJECT/*/.gitignore $BUILDROOT/$PROJECT/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/*/*/*/.gitignore`;
         $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/theme/amarok`;
    	    $ret=`rm -f  $BUILDROOT/$PROJECT/htdocs/includes/geoip/sample*.*`;
-	    $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/lightbox`;
         $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/lib/Mail`;
         $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/license.txt`;
         $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/PHPExcel/Shared/PDF`;
diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php
index 98e50bc813a682c8f0b51c0f9e552ea7685c5356..71401511e7a8b1d5ba25de4057700481fd83b1b0 100644
--- a/dev/skeletons/modMyModule.class.php
+++ b/dev/skeletons/modMyModule.class.php
@@ -73,16 +73,17 @@ class modMyModule extends DolibarrModules
 		// for specific path of parts (eg: /mymodule/core/modules/barcode)
 		// for specific css file (eg: /mymodule/css/mymodule.css.php)
 		//$this->module_parts = array(
-		//                        	'triggers' => 0,                                 // Set this to 1 if module has its own trigger directory (core/triggers)
-		//							'login' => 0,                                    // Set this to 1 if module has its own login method directory (core/login)
-		//							'substitutions' => 0,                            // Set this to 1 if module has its own substitution function file (core/substitutions)
-		//							'menus' => 0,                                    // Set this to 1 if module has its own menus handler directory (core/menus)
-		//							'theme' => 0,                                    // Set this to 1 if module has its own theme directory (core/theme)
-		//                        	'tpl' => 0,                                      // Set this to 1 if module overwrite template dir (core/tpl)
-		//							'barcode' => 0,                                  // Set this to 1 if module has its own barcode directory (core/modules/barcode)
-		//							'models' => 0,                                   // Set this to 1 if module has its own models directory (core/modules/xxx)
-		//							'css' => '/mymodule/css/mymodule.css.php',       // Set this to relative path of css if module has its own css file
-		//							'hooks' => array('hookcontext1','hookcontext2')  // Set here all hooks context managed by module
+		//                        	'triggers' => 0,                                 	// Set this to 1 if module has its own trigger directory (core/triggers)
+		//							'login' => 0,                                    	// Set this to 1 if module has its own login method directory (core/login)
+		//							'substitutions' => 0,                            	// Set this to 1 if module has its own substitution function file (core/substitutions)
+		//							'menus' => 0,                                    	// Set this to 1 if module has its own menus handler directory (core/menus)
+		//							'theme' => 0,                                    	// Set this to 1 if module has its own theme directory (core/theme)
+		//                        	'tpl' => 0,                                      	// Set this to 1 if module overwrite template dir (core/tpl)
+		//							'barcode' => 0,                                  	// Set this to 1 if module has its own barcode directory (core/modules/barcode)
+		//							'models' => 0,                                   	// Set this to 1 if module has its own models directory (core/modules/xxx)
+		//							'css' => array('/mymodule/css/mymodule.css.php'),	// Set this to relative path of css file if module has its own css file
+	 	//							'js' => array('/mymodule/js/mymodule.js'),          // Set this to relative path of js file if module must load a js on all pages
+		//							'hooks' => array('hookcontext1','hookcontext2')  	// Set here all hooks context managed by module
 		//							'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@mymodule')) // Set here all workflow context managed by module
 		//                        );
 		$this->module_parts = array();
diff --git a/htdocs/admin/fournisseur.php b/htdocs/admin/fournisseur.php
index efc3b826b2a57f0160bef1aa09d1ec824d01e36f..4c6c3fa533d56893c19d788eed835eddbb9713dd 100644
--- a/htdocs/admin/fournisseur.php
+++ b/htdocs/admin/fournisseur.php
@@ -55,7 +55,7 @@ if ($action == 'updateMask')
 {
     $maskconstorder=GETPOST('maskconstorder','alpha');
     $maskorder=GETPOST('maskorder','alpha');
-    
+
     if ($maskconstorder)  $res = dolibarr_set_const($db,$maskconstorder,$maskorder,'chaine',0,'',$conf->entity);
 
     if (! $res > 0) $error++;
@@ -77,7 +77,7 @@ if ($action == 'specimen')  // For orders
     $commande = new CommandeFournisseur($db);
     $commande->initAsSpecimen();
     $commande->thirdparty=$specimenthirdparty;
-    
+
     // Search template files
     $file=''; $classname=''; $filefound=0;
     $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
@@ -91,13 +91,13 @@ if ($action == 'specimen')  // For orders
     		break;
     	}
     }
-    
+
     if ($filefound)
     {
     	require_once($file);
-    
-    	$module = new $classname($db);
-    
+
+    	$module = new $classname($db,$commande);
+
     	if ($module->write_file($commande,$langs) > 0)
     	{
     		header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf");
@@ -123,7 +123,7 @@ if ($action == 'specimenfacture')   // For invoices
     $facture = new FactureFournisseur($db);
     $facture->initAsSpecimen();
     $facture->thirdparty=$specimenthirdparty;    // Define who should has build the invoice (so the supplier)
-    
+
 	// Search template files
     $file=''; $classname=''; $filefound=0;
     $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
@@ -137,13 +137,13 @@ if ($action == 'specimenfacture')   // For invoices
     		break;
     	}
     }
-    
+
     if ($filefound)
     {
     	require_once($file);
-    
-    	$module = new $classname($db);
-    
+
+    	$module = new $classname($db,$facture);
+
     	if ($module->write_file($facture,$langs) > 0)
     	{
     		header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf");
@@ -166,7 +166,7 @@ if ($action == 'set')
 {
 	$label = GETPOST('label','alpha');
 	$scandir = GETPOST('scandir','alpha');
-	
+
     $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
     $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
     $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
@@ -198,7 +198,7 @@ if ($action == 'setdoc')
 {
 	$label = GETPOST('label','alpha');
 	$scandir = GETPOST('scandir','alpha');
-	
+
     $db->begin();
 
     if ($type == 'order_supplier' && dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
diff --git a/htdocs/admin/project.php b/htdocs/admin/project.php
index ad67ba3a317da420fe18009e5c8a76da04ca6f38..80be64c815355137fea6ed0696bd1076379cf2e2 100644
--- a/htdocs/admin/project.php
+++ b/htdocs/admin/project.php
@@ -51,7 +51,7 @@ if ($action == 'updateMask')
 {
 	$maskconstproject=GETPOST('maskconstproject','alpha');
 	$maskproject=GETPOST('maskproject','alpha');
-	
+
 	if ($maskconstproject)  $res = dolibarr_set_const($db,$maskconstproject,$maskproject,'chaine',0,'',$conf->entity);
 
 	if (! $res > 0) $error++;
@@ -86,7 +86,7 @@ if ($action == 'specimen')
 			break;
 		}
 	}
-	
+
 	if ($filefound)
 	{
 		require_once($file);
@@ -207,7 +207,7 @@ foreach ($dirmodels as $reldir)
 					if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
 
 					if ($module->isEnabled())
-					{						
+					{
 						$var=!$var;
 						print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
 						print $module->info();
@@ -339,10 +339,10 @@ foreach ($dirmodels as $reldir)
 					// Active
 					if (in_array($name, $def))
 					{
-						print "<td align=\"center\">\n";						
+						print "<td align=\"center\">\n";
 						print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
 						print img_picto($langs->trans("Enabled"),'switch_on');
-						print '</a>';						
+						print '</a>';
 						print "</td>";
 					}
 					else
@@ -371,7 +371,7 @@ foreach ($dirmodels as $reldir)
 					$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
 					$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
 					print '<td align="center">';
-					$link='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&amp;module='.$name.'">'.img_object($langs->trans("Preview"),'order').'</a>';
+					$link='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&amp;module='.$name.'">'.img_object($langs->trans("Preview"),'project').'</a>';
 					print $form->textwithpicto(' &nbsp; &nbsp; '.$link,$htmltooltip,-1,0);
 					print '</td>';
 
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 76cdd822ce509637e3d3caae7a1f5d1bcf80d2ff..11ce0f53b4bef6649d2ec8d14e962c2d68a13e4e 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -280,7 +280,7 @@ class Commande extends CommonOrder
 
                         dol_syslog("Rename ok");
                         // Suppression ancien fichier PDF dans nouveau rep
-                        dol_delete_file($conf->commande->dir_output.'/'.$snum.'/'.$comref.'.*');
+                        dol_delete_file($conf->commande->dir_output.'/'.$snum.'/'.$comref.'*.*');
                     }
                 }
             }
diff --git a/htdocs/commande/liste.php b/htdocs/commande/liste.php
index 5efeaad7b04b1e6666d70089779e3c64b2d4dbac..9416732af77d81e3bd6f1474151df18afc5b24c3 100644
--- a/htdocs/commande/liste.php
+++ b/htdocs/commande/liste.php
@@ -98,7 +98,8 @@ $formother = new FormOther($db);
 $formfile = new FormFile($db);
 $companystatic = new Societe($db);
 
-llxHeader();
+$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
+llxHeader('',$langs->trans("Orders"),$help_url);
 
 $sql = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,';
 $sql.= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as facturee';
diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php
index cae2461a78007645f79f966c4688ffa5c7de671c..b99b92391a99fd10c91643e9f0e16e127d864c3b 100755
--- a/htdocs/commande/orderstoinvoice.php
+++ b/htdocs/commande/orderstoinvoice.php
@@ -29,10 +29,12 @@
 
 require("../main.inc.php");
 require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
-require_once(DOL_DOCUMENT_ROOT ."/commande/class/commande.class.php");
+require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
+require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
 require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
 require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
 require_once(DOL_DOCUMENT_ROOT."/core/lib/report.lib.php");
+if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/core/lib/project.lib.php");
 
 $langs->load('orders');
 $langs->load('deliveries');
@@ -73,10 +75,9 @@ if ($action == 'create')
 	}
 }
 $now=dol_now();
-$html = new Form($db);
-$formfile = new FormFile($db);
-$companystatic = new Societe($db);
-$htmlother = new FormOther($db);
+
+$viewstatut=GETPOST('viewstatut');
+
 
 /*
  * Actions
@@ -267,30 +268,30 @@ if (($action == 'create' || $action == 'add') && empty($mesgs))
 										{
 											$fk_parent_line = 0;
 										}
-                                        $result = $object->addline(
-                                            $id,
-                                            $desc,
-                                            $lines[$i]->subprice,
-                                            $lines[$i]->qty,
-                                            $lines[$i]->tva_tx,
-                                            $lines[$i]->localtax1_tx,
-                                            $lines[$i]->localtax2_tx,
-                                            $lines[$i]->fk_product,
-                                            $lines[$i]->remise_percent,
-                                            $date_start,
-                                            $date_end,
-                                            0,
-                                            $lines[$i]->info_bits,
-                                            $lines[$i]->fk_remise_except,
-                                            'HT',
-                                            0,
-                                            $product_type,
-                                            $lines[$i]->rang,
-                                            $lines[$i]->special_code,
-                                            $object->origin,
-                                            $lines[$i]->rowid,
-                                            $fk_parent_line
-                                        );
+										$result = $object->addline(
+												$id,
+												$desc,
+												$lines[$i]->subprice,
+												$lines[$i]->qty,
+												$lines[$i]->tva_tx,
+												$lines[$i]->localtax1_tx,
+												$lines[$i]->localtax2_tx,
+												$lines[$i]->fk_product,
+												$lines[$i]->remise_percent,
+												$date_start,
+												$date_end,
+												0,
+												$lines[$i]->info_bits,
+												$lines[$i]->fk_remise_except,
+												'HT',
+												0,
+												$product_type,
+												$lines[$i]->rang,
+												$lines[$i]->special_code,
+												$object->origin,
+												$lines[$i]->rowid,
+												$fk_parent_line
+										);
 										if ($result > 0)
 										{
 											$lineid=$result;
@@ -342,146 +343,149 @@ if (($action == 'create' || $action == 'add') && empty($mesgs))
 			$mesgs[]='<div class="error">'.$object->error.'</div>';
 		}
 	}
+}
 
-	/*
-	* View
-	*/
-	$html = new Form($db);
-	$htmlother = new FormOther($db);
-	$formfile = new FormFile($db);
-	$now=dol_now();
 
-	// Mode creation
-	if ($action == 'create')
-	{
-		$facturestatic=new Facture($db);
+/*
+ * View
+ */
 
-		llxHeader();
-		print_fiche_titre($langs->trans('NewBill'));
+$html = new Form($db);
+$htmlother = new FormOther($db);
+$formfile = new FormFile($db);
+$companystatic = new Societe($db);
 
-		$soc = new Societe($db);
-		if ($socid) $res=$soc->fetch($socid);
-		if ($res)
-		{
-			$cond_reglement_id 	= $soc->cond_reglement_id;
-			$mode_reglement_id 	= $soc->mode_reglement_id;
-			$remise_percent 	= $soc->remise_percent;
-		}
-		$remise_absolue 	= 0;
-		$dateinvoice		= empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
-
-		$absolute_discount=$soc->getAvailableDiscounts();
-		print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
-		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-		print '<input type="hidden" name="action" value="add">';
-		print '<input type="hidden" name="socid" value="'.$soc->id.'">' ."\n";
-		print '<input name="facnumber" type="hidden" value="provisoire">';
-		print '<input name="ref_client" type="hidden" value="'.$ref_client.'">';
-		print '<input name="ref_int" type="hidden" value="'.$ref_int.'">';
-		print '<input type="hidden" name="origin" value="'.GETPOST('origin').'">';
-		print '<input type="hidden" name="originid" value="'.GETPOST('originid').'">';
-		print '<table class="border" width="100%">';
-		// Ref
-		print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans('Draft').'</td></tr>';
-		// Tiers
-		print '<tr><td class="fieldrequired">'.$langs->trans('Customer').'</td><td colspan="2">';
-		print $soc->getNomUrl(1);
-		print '<input type="hidden" name="socid" value="'.$soc->id.'">';
-		print '</td>';
-		print '</tr>'."\n";
-		print '<tr><td valign="top" class="fieldrequired">'.$langs->trans('Type').'</td><td colspan="2">';
-		print '<table class="nobordernopadding">'."\n";
-		// Standard invoice
-		print '<tr height="18"><td width="16px" valign="middle">';
-		print '<input type="radio" name="type" value="0"'.(GETPOST('type')==0?' checked="true"':'').'>';
-		print '</td><td valign="middle">';
-		$desc=$html->textwithpicto($langs->trans("InvoiceStandardAsk"),$langs->transnoentities("InvoiceStandardDesc"),1);
-		print $desc;
-		print '</td></tr>'."\n";
-		print '</table>';
-		// Date invoice
-		print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td colspan="2">';
-		$html->select_date(0,'','','','',"add",1,1);
-		print '</td></tr>';
-		// Payment term
-		print '<tr><td nowrap>'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">';
-		$html->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id,'cond_reglement_id');
-		print '</td></tr>';
-		// Payment mode
-		print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">';
-		$html->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id');
+// Mode creation
+if ($action == 'create')
+{
+	$facturestatic=new Facture($db);
+
+	llxHeader();
+	print_fiche_titre($langs->trans('NewBill'));
+
+	$soc = new Societe($db);
+	if ($socid) $res=$soc->fetch($socid);
+	if ($res)
+	{
+		$cond_reglement_id 	= $soc->cond_reglement_id;
+		$mode_reglement_id 	= $soc->mode_reglement_id;
+		$remise_percent 	= $soc->remise_percent;
+	}
+	$remise_absolue 	= 0;
+	$dateinvoice		= empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
+
+	$absolute_discount=$soc->getAvailableDiscounts();
+	print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+	print '<input type="hidden" name="action" value="add">';
+	print '<input type="hidden" name="socid" value="'.$soc->id.'">' ."\n";
+	print '<input name="facnumber" type="hidden" value="provisoire">';
+	print '<input name="ref_client" type="hidden" value="'.$ref_client.'">';
+	print '<input name="ref_int" type="hidden" value="'.$ref_int.'">';
+	print '<input type="hidden" name="origin" value="'.GETPOST('origin').'">';
+	print '<input type="hidden" name="originid" value="'.GETPOST('originid').'">';
+	print '<table class="border" width="100%">';
+	// Ref
+	print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans('Draft').'</td></tr>';
+	// Tiers
+	print '<tr><td class="fieldrequired">'.$langs->trans('Customer').'</td><td colspan="2">';
+	print $soc->getNomUrl(1);
+	print '<input type="hidden" name="socid" value="'.$soc->id.'">';
+	print '</td>';
+	print '</tr>'."\n";
+	print '<tr><td valign="top" class="fieldrequired">'.$langs->trans('Type').'</td><td colspan="2">';
+	print '<table class="nobordernopadding">'."\n";
+	// Standard invoice
+	print '<tr height="18"><td width="16px" valign="middle">';
+	print '<input type="radio" name="type" value="0"'.(GETPOST('type')==0?' checked="true"':'').'>';
+	print '</td><td valign="middle">';
+	$desc=$html->textwithpicto($langs->trans("InvoiceStandardAsk"),$langs->transnoentities("InvoiceStandardDesc"),1);
+	print $desc;
+	print '</td></tr>'."\n";
+	print '</table>';
+	// Date invoice
+	print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td colspan="2">';
+	$html->select_date(0,'','','','',"add",1,1);
+	print '</td></tr>';
+	// Payment term
+	print '<tr><td nowrap>'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">';
+	$html->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id,'cond_reglement_id');
+	print '</td></tr>';
+	// Payment mode
+	print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">';
+	$html->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id');
+	print '</td></tr>';
+	// Project
+	if ($conf->projet->enabled)
+	{
+		$langs->load('projects');
+		print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">';
+		select_projects($soc->id, $projectid, 'projectid');
 		print '</td></tr>';
-		// Project
-		if ($conf->projet->enabled)
+	}
+	// Modele PDF
+	print '<tr><td>'.$langs->trans('Model').'</td>';
+	print '<td>';
+	include_once(DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php');
+	$liste=ModelePDFFactures::liste_modeles($db);
+	print $html->selectarray('model',$liste,$conf->global->FACTURE_ADDON_PDF);
+	print "</td></tr>";
+
+	// Public note
+	print '<tr>';
+	print '<td class="border" valign="top">'.$langs->trans('NotePublic').'</td>';
+	print '<td valign="top" colspan="2">';
+	print '<textarea name="note_public" wrap="soft" cols="70" rows="'.ROWS_3.'">';
+
+	dol_include_once('/commande/class/commande.class.php');
+	$srcobject = new Commande($db);
+	$commandes = $langs->trans("Orders").": ";
+	foreach ($selected as $sel)
+	{
+		$result=$srcobject->fetch($sel);
+		if ($result > 0)
 		{
-			$langs->load('projects');
-			print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">';
-			select_projects($soc->id, $projectid, 'projectid');
-			print '</td></tr>';
+			$commandes.= $srcobject->ref." ";
 		}
-		// Modele PDF
-		print '<tr><td>'.$langs->trans('Model').'</td>';
-		print '<td>';
-		include_once(DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php');
-    	$liste=ModelePDFFactures::liste_modeles($db);
-		print $html->selectarray('model',$liste,$conf->global->FACTURE_ADDON_PDF);
-		print "</td></tr>";
-
-		// Public note
+	}
+	print $commandes;
+
+	print '</textarea></td></tr>';
+	// Private note
+	if (! $user->societe_id)
+	{
 		print '<tr>';
-		print '<td class="border" valign="top">'.$langs->trans('NotePublic').'</td>';
+		print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>';
 		print '<td valign="top" colspan="2">';
-		print '<textarea name="note_public" wrap="soft" cols="70" rows="'.ROWS_3.'">';
-
-		dol_include_once('/commande/class/commande.class.php');
-		$srcobject = new Commande($db);
-		$commandes = $langs->trans("Orders").": ";
-		foreach ($selected as $sel)
-		{
-			$result=$srcobject->fetch($sel);
-			if ($result > 0)
-			{
-				$commandes.= $srcobject->ref." ";
-			}
-		}
-		print $commandes;
+		print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_3.'">';
 
 		print '</textarea></td></tr>';
-		// Private note
-		if (! $user->societe_id)
-		{
-			print '<tr>';
-			print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>';
-			print '<td valign="top" colspan="2">';
-			print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_3.'">';
-
-			print '</textarea></td></tr>';
-		}
+	}
 
-		print '</table>';
-		print '</td></tr>';
+	print '</table>';
+	print '</td></tr>';
 
-	}
 
 	while ($i < $n)
 	{
 		print '<input type="hidden" name="orders_to_invoice[]" value="'.$orders_id[$i].'">';
-
+	
 		$i++;
 	}
-
+	
 	print "</table>\n";
 	// Button "Create Draft"
 	print '<br><center><input type="submit" class="button" name="bouton" value="'.$langs->trans('CreateDraft').'"></center>';
 	print "</form>\n";
 }
 
+
 //Mode liste
-else
+if (($action != 'create' && $action != 'add') || ! empty($mesgs))
 {
 	llxHeader();
 	?>
-	<script language="javascript" type="text/javascript">
+	<script type="text/javascript">
 		jQuery(document).ready(function() {
 		jQuery("#checkall").click(function() {
 			jQuery(".checkformerge").attr('checked', true);
@@ -492,14 +496,34 @@ else
 	});
 	</script>
 	<?php
-
+	
 	$sql = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,';
 	$sql.= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as facturee';
 	$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s';
 	$sql.= ', '.MAIN_DB_PREFIX.'commande as c';
 	if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
 	$sql.= ' WHERE c.fk_soc = s.rowid';
-	$sql.= ' AND c.fk_statut in (1, 2) AND c.facture = 0';
+	// Which invoice to show
+	if ($viewstatut <> '')
+	{
+		if ($viewstatut < 4 && $viewstatut > -2)
+		{
+			$sql.= ' AND c.fk_statut ='.$viewstatut; // brouillon, validee, en cours, annulee
+			if ($viewstatut == 3)
+			{
+				$sql.= ' AND c.facture = 0'; // need to create invoice
+			}
+		}
+		if ($viewstatut == 4)
+		{
+			$sql.= ' AND c.facture = 1'; // invoice created
+		}
+		if ($viewstatut == -2)	// To process
+		{
+			//$sql.= ' AND c.fk_statut IN (1,2,3) AND c.facture = 0';
+			$sql.= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";    // If status is 2 and facture=1, it must be selected
+		}
+	}
 	$sql.= ' AND s.entity = '.$conf->entity;
 	if ($socid)	$sql.= ' AND s.rowid = '.$socid;
 	if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
@@ -511,18 +535,18 @@ else
 	{
 		$sql.= " AND (c.ref LIKE '%".$db->escape($sall)."%' OR c.note LIKE '%".$db->escape($sall)."%')";
 	}
-
+	
 	//Date filter
 	if ($date_start && $date_end) $sql.= " AND c.date_commande >= '".$db->idate($date_start)."' AND c.date_commande <= '".$db->idate($date_end)."'";
 	if ($date_starty && $date_endy) $sql.= " AND c.date_livraison >= '".$db->idate($date_starty)."' AND c.date_livraison <= '".$db->idate($date_endy)."'";
-
+	
 	if (!empty($sref_client))
 	{
 		$sql.= ' AND c.ref_client LIKE \'%'.$db->escape($sref_client).'%\'';
 	}
 	$sql.= ' ORDER BY '.$sortfield.' '.$sortorder;
 	$resql = $db->query($sql);
-
+	
 	if ($resql)
 	{
 		if ($socid)
@@ -545,7 +569,7 @@ else
 		print '<h3>';
 		$companystatic->id=$socid;
 		$companystatic->nom=$soc->nom;
-
+	
 		print $companystatic->getNomUrl(1,'customer');
 		print '</h3>';
 		print '<table class="noborder" width="100%">';
@@ -557,7 +581,7 @@ else
 		print_liste_field_titre($langs->trans('Status'),'','','','','align="right"');
 		print_liste_field_titre($langs->trans('GenerateBill'),'','','','','align="center"');
 		print '</tr>';
-
+	
 		// Lignes des champs de filtre
 		print '<form method="get" action="orderstoinvoice.php">';
 		print '<input type="hidden" name="socid" value="'.$socid.'">';
@@ -569,52 +593,52 @@ else
 		//print '<td class="liste_titre">';
 		print '<td class="liste_titre" align="left">';
 		print '<input class="flat" type="text" size="10" name="sref_client" value="'.$sref_client.'">';
-
+	
 		//DATE ORDER
 		print '<td class="liste_titre" align="center">';
 		print $period;
-    	print '</td>';
-
+		print '</td>';
+	
 		//DATE DELIVERY
 		print '<td class="liste_titre" align="center">';
 		print $periodely;
 		print '</td>';
-
-    	//SEARCH BUTTON
+	
+		//SEARCH BUTTON
 		print '</td><td align="right" class="liste_titre">';
 		print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png"  value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
-
+	
 		//ALL/NONE
 		print '<td class="liste_titre" align="center">';
 		if ($conf->use_javascript_ajax) print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a>';
 		print '</td>';
-
+	
 		print '</td></tr>';
 		print '</form>';
-
+	
 		print '<form name="orders2invoice" action="orderstoinvoice.php" method="GET">';
 		$var=True;
 		$generic_commande = new Commande($db);
-
+	
 		while ($i < $num)
 		{
 			$objp = $db->fetch_object($resql);
 			$var=!$var;
 			print '<tr '.$bc[$var].'>';
 			print '<td nowrap="nowrap">';
-
+	
 			$generic_commande->id=$objp->rowid;
 			$generic_commande->ref=$objp->ref;
-
+	
 			print '<table class="nobordernopadding"><tr class="nocellnopadd">';
 			print '<td class="nobordernopadding" nowrap="nowrap">';
 			print $generic_commande->getNomUrl(1,$objp->fk_statut);
 			print '</td>';
-
+	
 			print '<td width="20" class="nobordernopadding" nowrap="nowrap">';
 			if (($objp->fk_statut > 0) && ($objp->fk_statut < 3) && $db->jdate($objp->date_valid) < ($now - $conf->commande->client->warning_delay)) print img_picto($langs->trans("Late"),"warning");
 			print '</td>';
-
+	
 			print '<td width="16" align="right" class="nobordernopadding">';
 			$filename=dol_sanitizeFileName($objp->ref);
 			$filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($objp->ref);
@@ -622,37 +646,37 @@ else
 			$formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','',1,'',1);
 			print '</td></tr></table>';
 			print '</td>';
-
+	
 			print '<td>'.$objp->ref_client.'</td>';
-
+	
 			// Order date
 			print '<td align="center" nowrap>';
 			print dol_print_date($db->jdate($objp->date_commande),'day');
 			print '</td>';
-
+	
 			//Delivery date
 			print '<td align="center" nowrap>';
 			print dol_print_date($db->jdate($objp->date_livraison),'day');
 			print '</td>';
-
+	
 			// Statut
 			print '<td align="right" nowrap="nowrap">'.$generic_commande->LibStatut($objp->fk_statut,$objp->facturee,5).'</td>';
-
+	
 			// Checkbox
 			print '<td align="center">';
 			print '<input class="flat checkformerge" type="checkbox" name="orders_to_invoice[]" value="'.$objp->rowid.'">';
 			print '</td>' ;
-
+	
 			print '</tr>';
-
+	
 			$total = $total + $objp->price;
 			$subtotal = $subtotal + $objp->price;
 			$i++;
 		}
 		print '</table>';
-
+	
 		/*
-	 	* Boutons actions
+		 * Boutons actions
 		*/
 		print '<div align="right">';
 		print '<input type="hidden" name="socid" value="'.$socid.'">';
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index a8e10747977524d06a9efab920d4735d26984308..87405b5e0bec21bec326ebaf8197d9513c318cfd 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -1724,7 +1724,7 @@ class Facture extends CommonInvoice
 
                             dol_syslog("Rename ok");
                             // Suppression ancien fichier PDF dans nouveau rep
-                            dol_delete_file($conf->facture->dir_output.'/'.$snumfa.'/'.$facref.'.*');
+                            dol_delete_file($conf->facture->dir_output.'/'.$snumfa.'/'.$facref.'*.*');
                         }
                     }
                 }
diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php
index 494867ec94f57dc15989122e626ab0c5799911e2..cd474a141bf619678f1bade7deee2bd29aa511e0 100755
--- a/htdocs/core/class/commondocgenerator.class.php
+++ b/htdocs/core/class/commondocgenerator.class.php
@@ -165,6 +165,24 @@ abstract class CommonDocGenerator
         );
     }
 
+	/**
+	 * Rect pdf
+	 *
+	 * @param unknown_type $pdf
+	 * @param unknown_type $x
+	 * @param unknown_type $y
+	 * @param unknown_type $l
+	 * @param unknown_type $h
+	 * @param	int		$hidetop		Hide top
+	 * @param	int		$hidebottom		Hide bottom
+	 */
+    function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
+    {
+	    if (empty($hidetop)) $pdf->line($x, $y, $x+$l, $y);
+	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
+	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
+	    $pdf->line($x, $y+$h, $x, $y);
+    }
 }
 
 ?>
diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php
index 78255aa90842dc75ae7ec972f83d497ed038cc75..c3c6475822539280c368415393e53d0e1b844d6a 100644
--- a/htdocs/core/class/conf.class.php
+++ b/htdocs/core/class/conf.class.php
@@ -52,7 +52,7 @@ class Conf
 	public $smart_menu;
 
 	public $modules					= array();	// List of activated modules
-	public $modules_parts			= array('js'=>array(),'triggers'=>array(),'login'=>array(),'substitutions'=>array(),'menus'=>array(),'theme'=>array(),'tpl'=>array(),'barcode'=>array(),'models'=>array(),'hooks'=>array());	// List of modules parts
+	public $modules_parts			= array('css'=>array(), 'js'=>array(),'triggers'=>array(),'login'=>array(),'substitutions'=>array(),'menus'=>array(),'theme'=>array(),'tpl'=>array(),'barcode'=>array(),'models'=>array(),'hooks'=>array());	// List of modules parts
 
 	// TODO Remove thoose arrays with generic module_parts
 	public $tabs_modules			= array();
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 29433cfb63b9c5a9b04e329af66572a81d2ab62c..19f5e7de09b71d4982ce11468c26971fc8554d9c 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1424,7 +1424,7 @@ class Form
                 $outval='';
 
                 $opt = '<option value="'.$objp->idprodfournprice.'"';
-                if ($selected == $objp->idprodfournprice) $opt.= ' selected="selected"';
+                if ($selected && $selected == $objp->idprodfournprice) $opt.= ' selected="selected"';
                 if ($objp->fprice == '') $opt.=' disabled="disabled"';
                 $opt.= '>';
 
@@ -3709,30 +3709,6 @@ class Form
         }
         else dol_print_error('','Call of showphoto with wrong parameters');
 
-        /* Disabled. lightbox seems to not work. I don't know why.
-         $ret.="\n<script type=\"text/javascript\">
-        jQuery(function() {
-        jQuery('.photologo').lightBox();
-        });
-        </script>\n";
-
-        $ret.="\n<script type=\"text/javascript\">
-        jQuery(function() {
-        jQuery('.photologo').lightBox({
-        overlayBgColor: '#FFF',
-        overlayOpacity: 0.6,
-        imageLoading: '".DOL_URL_ROOT."/includes/jquery/plugins/lightbox/images/lightbox-ico-loading.gif',
-        imageBtnClose: '".DOL_URL_ROOT."/includes/jquery/plugins/lightbox/images/lightbox-btn-close.gif',
-        imageBtnPrev: '".DOL_URL_ROOT."/includes/jquery/plugins/lightbox/images/lightbox-btn-prev.gif',
-        imageBtnNext: '".DOL_URL_ROOT."/includes/jquery/plugins/lightbox/images/lightbox-btn-next.gif',
-        containerResizeSpeed: 350,
-        txtImage: 'Imagem',
-        txtOf: 'de'
-        });
-        });
-        </script>\n";
-        */
-
         return $ret;
     }
 
diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index 8347725fd32eec81b59314465e14cdbb12e85247..597d143f6eaaf3bc9cedfaa2c95b28aa3e6fa7ea 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -601,12 +601,13 @@ class FormMail
             {
             	if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes';
 
-                if(! empty($conf->global->MAIL_USE_SIGN) && $this->fromid > 0)
+                if (empty($conf->global->MAIL_DO_NOT_USE_SIGN) && $this->fromid > 0)
                 {
                     $fuser=new User($this->db);
                     $fuser->fetch($this->fromid);
 
-                    if(!empty($fuser->signature)) {
+                    if(! empty($fuser->signature)) 
+                    {
                         $defaultmessage.=dol_htmlentitiesbr_decode($fuser->signature);
                     }
                 }
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 140361265f28d7a5fc6c1f9c67e26faecca605fe..220a3c65bc06183b2bcd5686c03be9228768c7dc 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -222,12 +222,18 @@ function getCountry($id,$withcode='',$dbtouse=0,$outputlangs='',$entconv=1)
 {
     global $db,$langs;
 
+    // Check parameters
+    if (empty($id))
+    {
+    	if ($withcode === 'all') return array('id'=>'','code'=>'','label'=>'');
+    	else return '';
+    }
     if (! is_object($dbtouse)) $dbtouse=$db;
     if (! is_object($outputlangs)) $outputlangs=$langs;
 
     $sql = "SELECT rowid, code, libelle FROM ".MAIN_DB_PREFIX."c_pays";
     if (is_numeric($id)) $sql.= " WHERE rowid=".$id;
-    else $sql.= " WHERE code='".$id."'";
+    else $sql.= " WHERE code='".$db->escape($id)."'";
 
     dol_syslog("Company.lib::getCountry sql=".$sql);
     $resql=$dbtouse->query($sql);
@@ -251,10 +257,11 @@ function getCountry($id,$withcode='',$dbtouse=0,$outputlangs='',$entconv=1)
         }
         else
         {
-            return "NotDefined";
+            return 'NotDefined';
         }
     }
     else dol_print_error($dbtouse,'');
+    return 'Error';
 }
 
 /**
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index 99cac8eb60bc8c78763a81860a2c402fe250053e..2a7b004c7c3205709d70c5b9a7380115a4a1cdfa 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -524,12 +524,12 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default
  *  @param  Translate	$outputlangs	Object lang for output
  * 	@param	string		$paramfreetext	Constant name of free text
  * 	@param	Societe		$fromcompany	Object company
- * 	@param	int			$marge_basse	Margin bottom
- * 	@param	int			$marge_gauche	Margin left
- * 	@param	int			$page_hauteur	Page height
+ * 	@param	int			$marge_basse	Margin bottom we use for the autobreak
+ * 	@param	int			$marge_gauche	Margin left (no more used)
+ * 	@param	int			$page_hauteur	Page height (no more used)
  * 	@param	Object		$object			Object shown in PDF
- * 	@param	int			$showdetails	Show company details
- * 	@return	void
+ * 	@param	int			$showdetails	Show company details into footer. This param seems to not be used by standard version.
+ * 	@return	int							Return height of bottom margin including footer text
  */
 function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_basse,$marge_gauche,$page_hauteur,$object,$showdetails=0)
 {
@@ -538,6 +538,8 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
 	$outputlangs->load("dict");
 	$line='';
 
+	$dims=$pdf->getPageDimensions();
+
 	// Line of free text
 	if (! empty($conf->global->$paramfreetext))
 	{
@@ -659,11 +661,12 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
 	$nbofline=dol_nboflines_bis($line,0,$outputlangs->charset_output);
 	//print 'nbofline='.$nbofline; exit;
 	//print 'e'.$line.'t'.dol_nboflines($line);exit;
-	$posy=$marge_basse + ($nbofline*3) + (! empty($line1)?3:0) + (! empty($line2)?3:0) + (! empty($line3)?3:0) + (! empty($line4)?3:0);
+	$marginwithfooter=$marge_basse + ($nbofline*3) + (! empty($line1)?3:0) + (! empty($line2)?3:0) + (! empty($line3)?3:0) + (! empty($line4)?3:0);
+	$posy=$marginwithfooter+0;
 
 	if ($line)	// Free text
 	{
-		$pdf->SetXY($marge_gauche,-$posy);
+		$pdf->SetXY($dims['lm'],-$posy);
 		$width=20000; $align='L';	// By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text.
 		if ($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT) { $width=200; $align='C'; }
 		$pdf->MultiCell($width, 3, $line, 0, $align, 0);
@@ -671,13 +674,13 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
 	}
 
 	$pdf->SetY(-$posy);
-	$pdf->line($marge_gauche, $page_hauteur-$posy, 200, $page_hauteur-$posy);
+	$pdf->line($dims['lm'], $dims['hk']-$posy, $dims['wk']-$dims['rm'], $dims['hk']-$posy);
 	$posy--;
 
 	if (! empty($line1))
 	{
 		$pdf->SetFont('','B',7);
-		$pdf->SetXY($marge_gauche,-$posy);
+		$pdf->SetXY($dims['lm'],-$posy);
 		$pdf->MultiCell(200, 2, $line1, 0, 'C', 0);
 		$posy-=3;
 		$pdf->SetFont('','',7);
@@ -686,7 +689,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
 	if (! empty($line2))
 	{
 		$pdf->SetFont('','B',7);
-		$pdf->SetXY($marge_gauche,-$posy);
+		$pdf->SetXY($dims['lm'],-$posy);
 		$pdf->MultiCell(200, 2, $line2, 0, 'C', 0);
 		$posy-=3;
 		$pdf->SetFont('','',7);
@@ -694,14 +697,14 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
 
 	if (! empty($line3))
 	{
-		$pdf->SetXY($marge_gauche,-$posy);
+		$pdf->SetXY($dims['lm'],-$posy);
 		$pdf->MultiCell(200, 2, $line3, 0, 'C', 0);
 	}
 
 	if (! empty($line4))
 	{
 		$posy-=3;
-		$pdf->SetXY($marge_gauche,-$posy);
+		$pdf->SetXY($dims['lm'],-$posy);
 		$pdf->MultiCell(200, 2, $line4, 0, 'C', 0);
 	}
 
@@ -712,6 +715,8 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
 		$pdf->MultiCell(11, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
 		//print 'xxx'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit;
 	}
+
+	return $marginwithfooter;
 }
 
 /**
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index 9a51e08ea37cfd88d15d17db10ca89207581a507..3aae851a2d6e3e00d9e76daf8804f7a3ce36ac53 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -744,12 +744,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
                     $newmenu->add("/societe/soc.php?action=create", $langs->trans("MenuNewThirdParty"),1);
                     if (! $conf->use_javascript_ajax) $newmenu->add("/societe/soc.php?action=create&amp;private=1",$langs->trans("MenuNewPrivateIndividual"),1);
                 }
-
-                // TODO Avoid doing dir scan
-                if(is_dir("societe/groupe"))
-                {
-                    $newmenu->add("/societe/groupe/index.php", $langs->trans("MenuSocGroup"),1);
-                }
             }
 
             // Prospects
@@ -858,8 +852,8 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
                 $newmenu->add("/commande/liste.php?leftmenu=orders", $langs->trans("List"), 1, $user->rights->commande->lire);
                 if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=0", $langs->trans("StatusOrderDraftShort"), 2, $user->rights->commande->lire);
                 if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=1", $langs->trans("StatusOrderValidated"), 2, $user->rights->commande->lire);
-                if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=2", $langs->trans("StatusOrderOnProcessShort"), 2, $user->rights->commande->lire);
-                if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=3", $langs->trans("StatusOrderToBill"), 2, $user->rights->commande->lire);
+                if ($leftmenu=="orders" && $conf->expedition->enabled) $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=2", $langs->trans("StatusOrderOnProcessShort"), 2, $user->rights->commande->lire);
+                if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=".($conf->expedition->enabled?"3":"-2"), $langs->trans("StatusOrderToBill"), 2, $user->rights->commande->lire);
                 if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=4", $langs->trans("StatusOrderProcessed"), 2, $user->rights->commande->lire);
                 if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=-1", $langs->trans("StatusOrderCanceledShort"), 2, $user->rights->commande->lire);
                 $newmenu->add("/commande/stats/index.php?leftmenu=orders", $langs->trans("Statistics"), 1, $user->rights->commande->lire);
diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php
index c98aff33804905086ff3f2de011d1272af4f17c8..5653c8977cd19aa8c93d96c29db3e3d03b7ec9de 100644
--- a/htdocs/core/modules/DolibarrModules.class.php
+++ b/htdocs/core/modules/DolibarrModules.class.php
@@ -1286,6 +1286,20 @@ abstract class DolibarrModules
 
     /**
      * Insert activation of generic parts from modules in llx_const
+	 * Input entry use $this->module_parts = array(
+	 *                        	'triggers' => 0,                                 // Set this to 1 if module has its own trigger directory (core/triggers)
+	 *							'login' => 0,                                    // Set this to 1 if module has its own login method directory (core/login)
+	 *							'substitutions' => 0,                            // Set this to 1 if module has its own substitution function file (core/substitutions)
+	 *							'menus' => 0,                                    // Set this to 1 if module has its own menus handler directory (core/menus)
+	 *							'theme' => 0,                                    // Set this to 1 if module has its own theme directory (core/theme)
+	 *                        	'tpl' => 0,                                      // Set this to 1 if module overwrite template dir (core/tpl)
+	 *							'barcode' => 0,                                  // Set this to 1 if module has its own barcode directory (core/modules/barcode)
+	 *							'models' => 0,                                   // Set this to 1 if module has its own models directory (core/modules/xxx)
+	 *							'css' => '/mymodule/css/mymodule.css.php',       // Set this to relative path of css file if module has its own css file
+	 *							'js' => '/mymodule/js/mymodule.js',              // Set this to relative path of js file if module must load a js on all pages
+	 *							'hooks' => array('hookcontext1','hookcontext2')  // Set here all hooks context managed by module
+	 *							'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@mymodule') // Set here all workflow context managed by module
+	 * )
      *
      * @return     int     Nb of errors (0 if OK)
      */
diff --git a/htdocs/core/modules/action/rapport.pdf.php b/htdocs/core/modules/action/rapport.pdf.php
index e2a92b187537eeea9df937f3a7ce644dfb4a393e..5a9d14382619702567dd6a285d82e792a08d6643 100644
--- a/htdocs/core/modules/action/rapport.pdf.php
+++ b/htdocs/core/modules/action/rapport.pdf.php
@@ -112,6 +112,9 @@ class CommActionRapport
 		if (file_exists($dir))
 		{
             $pdf=pdf_getInstance($this->format);
+            $heightforinfotot = 80;	// Height reserved to output the info and total part (value include bottom margin)
+            $heightforfooter = 25;	// Height reserved to output the footer (value include bottom margin)
+            $pdf->SetAutoPageBreak(1,0);
 
             if (class_exists('TCPDF'))
             {
@@ -132,7 +135,6 @@ class CommActionRapport
 			$pdf->SetKeywords($outputlangs->convToOutputCharset($this->title." ".$this->subject));
 
 			$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
-			$pdf->SetAutoPageBreak(1,0);
 
 			$nbpage = $this->_pages($pdf, $outputlangs);
 
diff --git a/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php b/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php
index 923ee55baf0328d6dea12ff75811a92ebeb00739..98bea5676f8a2674657ab66a3ce7e39b23dc8e15 100644
--- a/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php
+++ b/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php
@@ -117,6 +117,9 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 
 		// Create PDF instance
         $pdf=pdf_getInstance($this->format);
+        $heightforinfotot = 80;	// Height reserved to output the info and total part (value include bottom margin)
+        $heightforfooter = 25;	// Height reserved to output the footer (value include bottom margin)
+        $pdf->SetAutoPageBreak(1,0);
 
         if (class_exists('TCPDF'))
         {
@@ -137,7 +140,6 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 		if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
 
 		$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
-		$pdf->SetAutoPageBreak(1,0);
 
 		$nboflines=count($this->lines);
 		// Define nb of page
diff --git a/htdocs/core/modules/commande/doc/pdf_edison.modules.php b/htdocs/core/modules/commande/doc/pdf_edison.modules.php
index 0ec5df0960dd28e1eb81b24198bfadb16ce9df40..c8d707b51cec76cde32ffcef5a1d3aa1e66b0a89 100644
--- a/htdocs/core/modules/commande/doc/pdf_edison.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_edison.modules.php
@@ -141,6 +141,9 @@ class pdf_edison extends ModelePDFCommandes
 				$nblignes = count($object->lines);
 
 				$pdf=pdf_getInstance($this->format);
+				$heightforinfotot = 80;	// Height reserved to output the info and total part (value include bottom margin)
+				$heightforfooter = 25;	// Height reserved to output the footer (value include bottom margin)
+				$pdf->SetAutoPageBreak(1,0);
 
                 if (class_exists('TCPDF'))
                 {
@@ -167,7 +170,6 @@ class pdf_edison extends ModelePDFCommandes
 				if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
 
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
-				$pdf->SetAutoPageBreak(1,0);
 
 				// New page
 				$pdf->AddPage();
@@ -200,9 +202,16 @@ class pdf_edison extends ModelePDFCommandes
 
 					$pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
 
+					$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
+					$pageposbefore=$pdf->getPage();
+
 					// Description of product line
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,100,3,30,$curY,1,$hidedesc,0,$hookmanager);
 
+					$pageposafter=$pdf->getPage();
+					$pdf->setPage($pageposbefore);
+					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+
 					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
 					$nexY = $pdf->GetY();
 
@@ -228,39 +237,51 @@ class pdf_edison extends ModelePDFCommandes
 
 					$nexY+=2;    // Passe espace entre les lignes
 
-					// cherche nombre de lignes a venir pour savoir si place suffisante
-					if ($i < ($nblignes - 1) && empty($hidedesc))	// If it's not last line
-					{
-						//on recupere la description du produit suivant
-						$follow_descproduitservice = $object->lines[$i+1]->desc;
-						//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
-						$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4);
-					}
-					else	// If it's last line
+					// Detect if some page were added automatically and output _tableau for past pages
+					while ($pagenb < $pageposafter)
 					{
-						$nblineFollowDesc = 0;
+						if ($pagenb == 1)
+						{
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+						}
+						else
+						{
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
+						$pagenb++;
+						$pdf->setPage($pagenb);
+						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
 					}
-
-					if ((($nexY+$nblineFollowDesc) > ($tab_top+$tab_height) && $i < ($nblignes - 1)) || (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak))
+					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
 					{
-						$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
-
+						if ($pagenb == 1)
+						{
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+						}
+						else
+						{
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
 						// New page
 						$pdf->AddPage();
-				        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
 						$pagenb++;
-						$this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
-						$pdf->SetFont('','', $default_font_size - 1);
-						$pdf->MultiCell(0, 3, '');		// Set interline to 3
-						$pdf->SetTextColor(0,0,0);
-
-						$nexY = $tab_top + 8;
 					}
 				}
 
-				$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
-
-				$bottomlasttab=$tab_top + $tab_height + 1;
+				// Show square
+				if ($pagenb == 1)
+				{
+					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
+				}
+				else
+				{
+					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
+				}
 
 				// Affiche zone infos
 				$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
@@ -467,9 +488,11 @@ class pdf_edison extends ModelePDFCommandes
 	 *   @param		string		$tab_height		Height of table (rectangle)
 	 *   @param		int			$nexY			Y
 	 *   @param		Translate	$outputlangs	Langs object
+	 *   @param		int			$hidetop		Hide top bar of array
+	 *   @param		int			$hidebottom		Hide bottom bar of array
 	 *   @return	void
 	 */
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
 	{
 		global $langs,$conf;
 		$langs->load("main");
diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
index 899ea1c69b4a41061f998aeb76a99f6006eec906..76ac2268b0f8fbc8f286720eb1c0c11002216f3a 100644
--- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
@@ -177,6 +177,9 @@ class pdf_einstein extends ModelePDFCommandes
 				$nblignes = count($object->lines);
 
                 $pdf=pdf_getInstance($this->format);
+                $heightforinfotot = 80;	// Height reserved to output the info and total part (value include bottom margin)
+                $heightforfooter = 25;	// Height reserved to output the footer (value include bottom margin)
+                $pdf->SetAutoPageBreak(1,0);
 
                 if (class_exists('TCPDF'))
                 {
@@ -203,7 +206,6 @@ class pdf_einstein extends ModelePDFCommandes
 				if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
 
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
-				$pdf->SetAutoPageBreak(1,0);
 
 				// Positionne $this->atleastonediscount si on a au moins une remise
 				for ($i = 0 ; $i < $nblignes ; $i++)
@@ -262,10 +264,17 @@ class pdf_einstein extends ModelePDFCommandes
 
                     $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
 
+					$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
+					$pageposbefore=$pdf->getPage();
+
 					// Description of product line
 					$curX = $this->posxdesc-1;
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
 
+					$pageposafter=$pdf->getPage();
+					$pdf->setPage($pageposbefore);
+					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+
 					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
 					$nexY = $pdf->GetY();
 
@@ -321,71 +330,50 @@ class pdf_einstein extends ModelePDFCommandes
 
 					$nexY+=2;    // Passe espace entre les lignes
 
-					// Cherche nombre de lignes a venir pour savoir si place suffisante
-					if ($i < ($nblignes - 1) && empty($hidedesc))	// If it's not last line
+					// Detect if some page were added automatically and output _tableau for past pages
+					while ($pagenb < $pageposafter)
 					{
-						//on recupere la description du produit suivant
-						$follow_descproduitservice = $object->lines[$i+1]->desc;
-						//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
-						$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4);
-						// Et si on affiche dates de validite, on ajoute encore une ligne
-						if ($object->lines[$i]->date_start && $object->lines[$i]->date_end)
+						if ($pagenb == 1)
 						{
-							$nblineFollowDesc += 4;
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
 						}
+						else
+						{
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
+						$pagenb++;
+						$pdf->setPage($pagenb);
+						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
 					}
-					else	// If it's last line
-					{
-						$nblineFollowDesc = 0;
-					}
-
-					// Test if a new page is required
-					if ($pagenb == 1)
-					{
-						$tab_top_in_current_page=$tab_top;
-						$tab_height_in_current_page=$tab_height;
-					}
-					else
-					{
-						$tab_top_in_current_page=$tab_top_newpage;
-						$tab_height_in_current_page=$tab_height_newpage;
-					}
-					if ((($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblignes - 1)) || (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak))
+					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
 					{
 						if ($pagenb == 1)
 						{
-							$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs);
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
 						}
 						else
 						{
-							$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
 						}
-
 						$this->_pagefoot($pdf,$object,$outputlangs);
-
 						// New page
 						$pdf->AddPage();
-				        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
 						$pagenb++;
-						$this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
-						$pdf->SetFont('','', $default_font_size - 1);
-						$pdf->MultiCell(0, 3, '');		// Set interline to 3
-						$pdf->SetTextColor(0,0,0);
-
-						$nexY = $tab_top_newpage + 7;
 					}
 				}
 
 				// Show square
 				if ($pagenb == 1)
 				{
-					$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
-					$bottomlasttab=$tab_top + $tab_height + 1;
+					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
 				}
 				else
 				{
-					$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
-					$bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1;
+					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
 				}
 
 				// Affiche zone infos
@@ -797,9 +785,11 @@ class pdf_einstein extends ModelePDFCommandes
 	 *   @param		string		$tab_height		Height of table (rectangle)
 	 *   @param		int			$nexY			Y
 	 *   @param		Translate	$outputlangs	Langs object
+	 *   @param		int			$hidetop		Hide top bar of array
+	 *   @param		int			$hidebottom		Hide bottom bar of array
 	 *   @return	void
 	 */
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
 	{
 		global $conf;
 
diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php
index 3b657f5967b9a2e61ced471c37e9d91472484406..01575734d973a9388bd0dea338b90c89ee45e811 100644
--- a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php
@@ -147,6 +147,9 @@ class pdf_expedition_merou extends ModelePdfExpedition
 			if (file_exists($dir))
 			{
                 $pdf=pdf_getInstance($this->format,'mm','l');
+                $heightforinfotot = 80;	// Height reserved to output the info and total part (value include bottom margin)
+                $heightforfooter = 25;	// Height reserved to output the footer (value include bottom margin)
+                $pdf->SetAutoPageBreak(1,0);
 
 			    if (class_exists('TCPDF'))
                 {
@@ -174,7 +177,6 @@ class pdf_expedition_merou extends ModelePdfExpedition
 				if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
 
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
-				$pdf->SetAutoPageBreak(1,0);
 
 				$pdf->SetFont('','', $default_font_size - 3);
 
@@ -284,9 +286,11 @@ class pdf_expedition_merou extends ModelePdfExpedition
 	 *   @param		string		$tab_height		Height of table (rectangle)
 	 *   @param		int			$nexY			Y
 	 *   @param		Translate	$outputlangs	Langs object
+	 *   @param		int			$hidetop		Hide top bar of array
+	 *   @param		int			$hidebottom		Hide bottom bar of array
 	 *   @return	void
 	 */
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
 	{
 		global $langs;
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php
index 16d757aaafc26cf6e7b601d8071c1c39563837fc..e0a9f5211a8e634fd62be5b5bbaa1214795fa5ed 100644
--- a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php
@@ -126,6 +126,9 @@ class pdf_expedition_rouget extends ModelePdfExpedition
 			if (file_exists($dir))
 			{
                 $pdf=pdf_getInstance($this->format);
+                $heightforinfotot = 80;	// Height reserved to output the info and total part (value include bottom margin)
+                $heightforfooter = 25;	// Height reserved to output the footer (value include bottom margin)
+                $pdf->SetAutoPageBreak(1,0);
 
                 if (class_exists('TCPDF'))
                 {
@@ -154,7 +157,6 @@ class pdf_expedition_rouget extends ModelePdfExpedition
 				if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
 
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
-				$pdf->SetAutoPageBreak(1,0);
 
 				// New page
 				$pdf->AddPage();
@@ -223,9 +225,16 @@ class pdf_expedition_rouget extends ModelePdfExpedition
 
 					$pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
 
+					$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
+					$pageposbefore=$pdf->getPage();
+
 					// Description de la ligne produit
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,150,3,$this->posxdesc,$curY,0,1);
 
+					$pageposafter=$pdf->getPage();
+					$pdf->setPage($pageposbefore);
+					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+
 					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
 					$nexY = $pdf->GetY();
 
@@ -274,9 +283,11 @@ class pdf_expedition_rouget extends ModelePdfExpedition
 	 *   @param		string		$tab_height		Height of table (rectangle)
 	 *   @param		int			$nexY			Y
 	 *   @param		Translate	$outputlangs	Langs object
+	 *   @param		int			$hidetop		Hide top bar of array
+	 *   @param		int			$hidebottom		Hide bottom bar of array
 	 *   @return	void
 	 */
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
 	{
 		global $conf;
 
@@ -385,7 +396,7 @@ class pdf_expedition_rouget extends ModelePdfExpedition
 		}
 
 
-		$posx=100;
+		$posx=$this->page_largeur - 100 - $this->marge_droite;
 		$posy=$this->marge_haute;
 
 		$pdf->SetFont('','B', $default_font_size + 2);
@@ -467,7 +478,7 @@ class pdf_expedition_rouget extends ModelePdfExpedition
 			$posx=$this->marge_gauche;
 			$posy=42;
 			$hautcadre=40;
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118;
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur - 80 - $this->marge_droite;
 
 			// Show sender frame
 			$pdf->SetTextColor(0,0,0);
@@ -516,7 +527,7 @@ class pdf_expedition_rouget extends ModelePdfExpedition
 
 			// Show recipient
 			$posy=42;
-			$posx=100;
+			$posx=$this->page_largeur - 100 - $this->marge_droite;
 			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
 
 			// Show recipient frame
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index 1ab1f99dbbcf7f644aed7155e678b67b41ba3dc3..327ad5e8b19135ad07737efc57a712326f7633d3 100755
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -178,6 +178,9 @@ class pdf_crabe extends ModelePDFFactures
 				$nblignes = count($object->lines);
 
                 $pdf=pdf_getInstance($this->format);
+				$heightforinfotot = 80;	// Height reserved to output the info and total part (value include bottom margin)
+				$heightforfooter = 25;	// Height reserved to output the footer (value include bottom margin)
+                $pdf->SetAutoPageBreak(1,0);
 
                 if (class_exists('TCPDF'))
                 {
@@ -204,7 +207,6 @@ class pdf_crabe extends ModelePDFFactures
 				if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
 
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
-				$pdf->SetAutoPageBreak(1,0);
 
 				// Positionne $this->atleastonediscount si on a au moins une remise
 				for ($i = 0 ; $i < $nblignes ; $i++)
@@ -225,7 +227,7 @@ class pdf_crabe extends ModelePDFFactures
 				$pdf->SetTextColor(0,0,0);
 
 				$tab_top = 90;
-				$tab_top_newpage = 50;
+				$tab_top_newpage = 10;
 				$tab_height = 130;
 				$tab_height_newpage = 150;
 
@@ -262,8 +264,9 @@ class pdf_crabe extends ModelePDFFactures
 				{
 					$curY = $nexY;
 
+					$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
 					$pageposbefore=$pdf->getPage();
-						
+
 					// Description of product line
 					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
 					$curX = $this->posxdesc-1;
@@ -271,7 +274,8 @@ class pdf_crabe extends ModelePDFFactures
 
 					$pageposafter=$pdf->getPage();
 					$pdf->setPage($pageposbefore);
-					
+					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+
 					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
 					$nexY = $pdf->GetY();
 
@@ -332,84 +336,47 @@ class pdf_crabe extends ModelePDFFactures
 					// Detect if some page were added automatically and output _tableau for past pages
 					while ($pagenb < $pageposafter)
 					{
-					    if ($pagenb == 1)
+						if ($pagenb == 1)
 						{
-							$this->_tableau($pdf, $tab_top, $tab_height + 40, 0, $outputlangs);
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
 						}
 						else
 						{
-							$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, 0, $outputlangs);
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
 						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
 						$pagenb++;
 						$pdf->setPage($pagenb);
+						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
 					}
-					
-					// Cherche nombre de lignes a venir pour savoir si place suffisante
-					if ($i < ($nblignes - 1) && empty($hidedesc))	// If it's not last line
+					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
 					{
-						//on recupere la description du produit suivant
-						$follow_descproduitservice = $object->lines[$i+1]->desc;
-						//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
-						$nblineFollowDesc = dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4;
-						// Et si on affiche dates de validite, on ajoute encore une ligne
-						if ($object->lines[$i]->date_start && $object->lines[$i]->date_end)
-						{
-							$nblineFollowDesc += 4;
+						if ($pagenb == 1)
+						{
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+						}
+						else
+						{
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
 						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
+						// New page
+						$pdf->AddPage();
+						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+						$pagenb++;
 					}
-					else	// If it's last line
-					{
-						$nblineFollowDesc = 0;
-					}
-
-					// Test if a new page is required
-					if ($pagenb == 1)
-					{
-						$tab_top_in_current_page=$tab_top;
-						$tab_height_in_current_page=$tab_height;
-					}
-					else
-					{
-						$tab_top_in_current_page=$tab_top_newpage;
-						$tab_height_in_current_page=$tab_height_newpage;
-					}
-					if ((($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblignes - 1)) || (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak))
-					{
-					    if ($pagenb == 1)
-						{
-							$this->_tableau($pdf, $tab_top, $tab_height + 40, $nexY, $outputlangs);
-						}
-						else
-						{
-							$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
-						}
-
-						$this->_pagefoot($pdf,$object,$outputlangs);
-
-						// New page
-						$pdf->AddPage();
-				        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
-						$pagenb++;
-						$this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
-						$pdf->SetFont('','', $default_font_size - 1);
-						$pdf->MultiCell(0, 3, '');		// Set interline to 3
-						$pdf->SetTextColor(0,0,0);
-
-						$nexY = $tab_top_newpage + 7;
-					}
-
 				}
 
 				// Show square
 				if ($pagenb == 1)
 				{
-					$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
-					$bottomlasttab=$tab_top + $tab_height + 1;
+					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
 				}
 				else
 				{
-					$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
-					$bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1;
+					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
 				}
 
 				// Affiche zone infos
@@ -960,11 +927,13 @@ class pdf_crabe extends ModelePDFFactures
 	 *   @param		PDF			&$pdf     		Object PDF
 	 *   @param		string		$tab_top		Top position of table
 	 *   @param		string		$tab_height		Height of table (rectangle)
-	 *   @param		int			$nexY			Y
+	 *   @param		int			$nexY			Y (not used)
 	 *   @param		Translate	$outputlangs	Langs object
+	 *   @param		int			$hidetop		Hide top bar of array
+	 *   @param		int			$hidebottom		Hide bottom bar of array
 	 *   @return	void
 	 */
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
 	{
 		global $conf;
 
@@ -973,51 +942,70 @@ class pdf_crabe extends ModelePDFFactures
 		// Amount in (at tab_top - 1)
 		$pdf->SetTextColor(0,0,0);
 		$pdf->SetFont('','', $default_font_size - 2);
-		$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
-		$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
-		$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
+
+		if (empty($hidetop))
+		{
+			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
+			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
+			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
+		}
 
 		$pdf->SetDrawColor(128,128,128);
+		$pdf->SetFont('','', $default_font_size - 1);
 
-		// Rect prend une longueur en 3eme param et 4eme param
-		$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
-		// line prend une position y en 2eme param et 4eme param
-		$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);
+		// Output Rect
+		$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
 
-		$pdf->SetFont('','', $default_font_size - 1);
+		if (empty($hidetop))
+		{
+			$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line prend une position y en 2eme param et 4eme param
 
-		$pdf->SetXY($this->posxdesc-1, $tab_top+1);
-		$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
+			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
+			$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
+		}
 
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
 		{
 			$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
-			$pdf->SetXY($this->posxtva-3, $tab_top+1);
-			$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
+			if (empty($hidetop))
+			{
+				$pdf->SetXY($this->posxtva-3, $tab_top+1);
+				$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
+			}
 		}
 
 		$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
-		$pdf->SetXY($this->posxup-1, $tab_top+1);
-		$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
+		if (empty($hidetop))
+		{
+			$pdf->SetXY($this->posxup-1, $tab_top+1);
+			$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
+		}
 
 		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
-		$pdf->SetXY($this->posxqty-1, $tab_top+1);
-		$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
+		if (empty($hidetop))
+		{
+			$pdf->SetXY($this->posxqty-1, $tab_top+1);
+			$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
+		}
 
 		$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
-		if ($this->atleastonediscount)
+		if (empty($hidetop))
 		{
-			$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
-			$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
+			if ($this->atleastonediscount)
+			{
+				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
+				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
+			}
 		}
-
 		if ($this->atleastonediscount)
 		{
 			$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
 		}
-		$pdf->SetXY($this->postotalht-1, $tab_top+1);
-		$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
-
+		if (empty($hidetop))
+		{
+			$pdf->SetXY($this->postotalht-1, $tab_top+1);
+			$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
+		}
 	}
 
 	/**
@@ -1244,7 +1232,7 @@ class pdf_crabe extends ModelePDFFactures
 	 *   	@param	PDF			&$pdf     			PDF
 	 * 		@param	Object		$object				Object to show
 	 *      @param	Translate	$outputlangs		Object lang for output
-	 *      @return	void
+	 *      @return	int								Return height of bottom margin including footer text
 	 */
 	function _pagefoot(&$pdf,$object,$outputlangs)
 	{
diff --git a/htdocs/core/modules/facture/doc/pdf_oursin.modules.php b/htdocs/core/modules/facture/doc/pdf_oursin.modules.php
index d6c8102f2b7b3699994abce85af23e17efb97055..57a7c7a3abd8a7a489fd24335c7d1c64a3db4c96 100755
--- a/htdocs/core/modules/facture/doc/pdf_oursin.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_oursin.modules.php
@@ -166,6 +166,9 @@ class pdf_oursin extends ModelePDFFactures
 			if (file_exists($dir))
 			{
                 $pdf=pdf_getInstance($this->format);
+                $heightforinfotot = 80;	// Height reserved to output the info and total part (value include bottom margin)
+                $heightforfooter = 25;	// Height reserved to output the footer (value include bottom margin)
+                $pdf->SetAutoPageBreak(1,0);
 
                 if (class_exists('TCPDF'))
                 {
@@ -191,8 +194,16 @@ class pdf_oursin extends ModelePDFFactures
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Invoice"));
 				if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
 
-				$pdf->SetMargins(10, 10, 10);
-				$pdf->SetAutoPageBreak(1,0);
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
+
+				// Positionne $this->atleastonediscount si on a au moins une remise
+				for ($i = 0 ; $i < $nblignes ; $i++)
+				{
+					if ($object->lines[$i]->remise_percent)
+					{
+						$this->atleastonediscount++;
+					}
+				}
 
 				// New page
 				$pdf->AddPage();
@@ -204,7 +215,9 @@ class pdf_oursin extends ModelePDFFactures
 				$pdf->SetTextColor(0,0,0);
 
 				$tab_top = $this->marges['h']+90;
+				$tab_top_newpage = $this->marges['h'];
 				$tab_height = 110;
+				$tab_height_newpage = 150;
 
 				$pdf->SetFillColor(220,220,220);
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -220,20 +233,24 @@ class pdf_oursin extends ModelePDFFactures
 				{
 					$curY = $nexY;
 
+					$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
+					$pageposbefore=$pdf->getPage();
+
 					// Description of product line
                     pdf_writelinedesc($pdf,$object,$i,$outputlangs,108,3,$this->posxdesc-1,$curY+1,$hideref,$hidedesc,0,$hookmanager);
 
+					$pageposafter=$pdf->getPage();
+					$pdf->setPage($pageposbefore);
+					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+
 					$nexY = $pdf->GetY();
 
 					// TVA
 					if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
 					{
-						if ($this->franchise!=1)
-						{
-							$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager);
-							$pdf->SetXY($this->marges['g']+118, $curY);
-							$pdf->MultiCell(12, 3, $vat_rate, 0, 'R');
-						}
+						$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager);
+						$pdf->SetXY($this->marges['g']+118, $curY);
+						$pdf->MultiCell(12, 3, $vat_rate, 0, 'R');
 					}
 
 					// Prix unitaire HT avant remise
@@ -258,25 +275,64 @@ class pdf_oursin extends ModelePDFFactures
 					$pdf->SetXY($this->marges['g']+168, $curY);
 					$pdf->MultiCell(21, 3, $total_excl_tax, 0, 'R', 0);
 
-
-					if (($nexY > 200 && $i < $nblignes - 1) || (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak))
-					{
-						$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $object, $outputlangs);
-						$nexY = $iniY;
-
-						// New page
-						$pdf->AddPage();
-				        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
-						$pagenb++;
-						$this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
-						$pdf->SetFont('','', $default_font_size - 1);
-						$pdf->MultiCell(0, 3, '');		// Set interline to 3
-						$pdf->SetTextColor(0,0,0);
+					// Detect if some page were added automatically and output _tableau for past pages
+					while ($pagenb < $pageposafter)
+					{
+						if ($pagenb == 1)
+						{
+							$this->_tableau($pdf, $tab_top, $tab_height + 40, 0, $outputlangs, 0, 1);
+						}
+						else
+						{
+							$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, 0, $outputlangs, 1, 1);
+						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
+						$pagenb++;
+						$pdf->setPage($pagenb);
 					}
+					/*if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
+					{
+						if ($pagenb == 1)
+						{
+							$this->_tableau($pdf, $tab_top, $tab_height + 40, 0, $outputlangs, 0, 1);
+						}
+						else
+						{
+							$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, 0, $outputlangs, 1, 1);
+						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
+						// New page
+						$pdf->AddPage();
+						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+						$pagenb++;
+					}*/
+					if (($nexY > 200 && $i < $nblignes - 1) || (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak))
+					{
+						$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $object, $outputlangs);
+						$nexY = $iniY;
+
+						// New page
+						$pdf->AddPage();
+						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+						$pagenb++;
+						$this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
+						$pdf->SetFont('','', $default_font_size - 1);
+						$pdf->MultiCell(0, 3, '');		// Set interline to 3
+						$pdf->SetTextColor(0,0,0);
+					}
+				}
 
+				// Show square
+				if ($pagenb == 1)
+				{
+					$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
+					$bottomlasttab=$tab_top + $tab_height + 1;
+				}
+				else
+				{
+					$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs, 1, 0);
+					$bottomlasttab=$tab_top + $tab_height + 1;
 				}
-				$posy=$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $object, $outputlangs);
-				$bottomlasttab=$tab_top + $tab_height + 1;
 
 				// Affiche zone infos
 				$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
@@ -744,11 +800,12 @@ class pdf_oursin extends ModelePDFFactures
 	 *   @param		string		$tab_top		Top position of table
 	 *   @param		string		$tab_height		Height of table (rectangle)
 	 *   @param		int			$nexY			Y
-	 *   @param		Object		$object			Object
 	 *   @param		Translate	$outputlangs	Langs object
+	 *   @param		int			$hidetop		Hide top bar of array
+	 *   @param		int			$hidebottom		Hide bottom bar of array
 	 *   @return	void
 	 */
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $object, $outputlangs)
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
 	{
 		global $conf,$langs;
 		$langs->load("main");
@@ -775,16 +832,7 @@ class pdf_oursin extends ModelePDFFactures
         $pdf->SetXY($this->marges['g']+153,$tab_top + 1);
         $pdf->MultiCell(0, 4, $outputlangs->transnoentities("Qty"), 0, 'L');
 
-		$nblignes = count($object->lines);
-		$rem=0;
-		for ($i = 0 ; $i < $nblignes ; $i++)
-		{
-    		if ($object->lines[$i]->remise_percent)
-    		{
-    			$rem=1;
-    		}
-		}
-		if ($rem==1)
+		if ($this->atleastonediscount)
 		{
             $pdf->SetXY($this->marges['g']+165,$tab_top + 1);
             $pdf->MultiCell(0, 4, $outputlangs->transnoentities("%"), 0, 'L');
@@ -1018,7 +1066,7 @@ class pdf_oursin extends ModelePDFFactures
 	 *   	@param	PDF			&$pdf     			PDF
 	 * 		@param	Object		$object				Object to show
 	 *      @param	Translate	$outputlangs		Object lang for output
-	 *      @return	void
+	 *      @return	int								Return height of bottom margin including footer text
 	 */
 	function _pagefoot(&$pdf, $object, $outputlangs)
 	{
diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
index 91f4b18c1729c30ecf90790e59ec6d236897dae5..eee3a6ebf9dc8682236f7fc226c5dfd5b5c28d01 100644
--- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
+++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
@@ -134,6 +134,9 @@ class pdf_soleil extends ModelePDFFicheinter
 			if (file_exists($dir))
 			{
                 $pdf=pdf_getInstance($this->format);
+                $heightforinfotot = 80;	// Height reserved to output the info and total part (value include bottom margin)
+                $heightforfooter = 25;	// Height reserved to output the footer (value include bottom margin)
+                $pdf->SetAutoPageBreak(1,0);
 
                 if (class_exists('TCPDF'))
                 {
@@ -160,7 +163,6 @@ class pdf_soleil extends ModelePDFFicheinter
 				if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
 
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
-				$pdf->SetAutoPageBreak(1,0);
 
 				// New page
 				$pdf->AddPage();
@@ -268,67 +270,51 @@ class pdf_soleil extends ModelePDFFicheinter
 
 						$nexY+=2;    // Passe espace entre les lignes
 
-						// Cherche nombre de lignes a venir pour savoir si place suffisante
-						if ($i < ($nblines - 1) && empty($hidedesc))	// If it's not last line
-						{
-							//on recupere la description du produit suivant
-							$follow_descproduitservice = $objectligne->desc;
-							//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
-							$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*3);
-						}
-						else	// If it's last line
-						{
-							$nblineFollowDesc = 0;
-						}
-
-						// Test if a new page is required
-						if ($pagenb == 1)
-						{
-							$tab_top_in_current_page=$tab_top;
-							$tab_height_in_current_page=$tab_height;
-						}
-						else
-						{
-							$tab_top_in_current_page=$tab_top_newpage;
-							$tab_height_in_current_page=$tab_height_middlepage;
-						}
-						if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblines - 1))
-						{
-							if ($pagenb == 1)
-							{
-								$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs);
-							}
-							else
-							{
-								$this->_tableau($pdf, $tab_top_newpage, $tab_height_middlepage, $nexY, $outputlangs);
-							}
-
-							$this->_pagefoot($pdf,$object,$outputlangs);
-
-							// New page
-							$pdf->AddPage();
-				            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
-							$pagenb++;
-							$this->_pagehead($pdf, $object, 0, $outputlangs);
-							$pdf->SetFont('','', $default_font_size - 1);
-							$pdf->MultiCell(0, 3, '');		// Set interline to 3
-							$pdf->SetTextColor(0,0,0);
-
-							$nexY = $tab_top_newpage + 7;
-						}
+						// Detect if some page were added automatically and output _tableau for past pages
+						while ($pagenb < $pageposafter)
+						{
+							if ($pagenb == 1)
+							{
+								$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+							}
+							else
+							{
+								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+							}
+							$this->_pagefoot($pdf,$object,$outputlangs);
+							$pagenb++;
+							$pdf->setPage($pagenb);
+							$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+						}
+						if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
+						{
+							if ($pagenb == 1)
+							{
+								$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+							}
+							else
+							{
+								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+							}
+							$this->_pagefoot($pdf,$object,$outputlangs);
+							// New page
+							$pdf->AddPage();
+							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+							$pagenb++;
+						}
 					}
 				}
 
 				// Show square
 				if ($pagenb == 1)
 				{
-					$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
-					$bottomlasttab=$tab_top + $tab_height + 1;
+					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
 				}
 				else
 				{
-					$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
-					$bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1;
+					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
 				}
 
 				$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
@@ -367,9 +353,11 @@ class pdf_soleil extends ModelePDFFicheinter
 	 *   @param		string		$tab_height		Height of table (rectangle)
 	 *   @param		int			$nexY			Y
 	 *   @param		Translate	$outputlangs	Langs object
+	 *   @param		int			$hidetop		Hide top bar of array
+	 *   @param		int			$hidebottom		Hide bottom bar of array
 	 *   @return	void
 	 */
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
 	{
 		global $conf;
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -406,13 +394,13 @@ class pdf_soleil extends ModelePDFFicheinter
 		$pdf->MultiCell(66,5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"),0,'L',0);
 
 		$pdf->SetXY(20,235);
-		$pdf->MultiCell(80,30, '', 1);
+		$pdf->MultiCell(80,25, '', 1);
 
 		$pdf->SetXY(110,230);
 		$pdf->MultiCell(80,5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"),0,'L',0);
 
 		$pdf->SetXY(110,235);
-		$pdf->MultiCell(80,30, '', 1);
+		$pdf->MultiCell(80,25, '', 1);
 	}
 
 	/**
diff --git a/htdocs/core/modules/livraison/pdf/pdf_sirocco.modules.php b/htdocs/core/modules/livraison/pdf/pdf_sirocco.modules.php
index d32f1370ef0d9b4e0a09caab10d886ebbb30cdb4..5ae3b4133e06dfe8eae0d075447f117b7da0d7e3 100644
--- a/htdocs/core/modules/livraison/pdf/pdf_sirocco.modules.php
+++ b/htdocs/core/modules/livraison/pdf/pdf_sirocco.modules.php
@@ -120,6 +120,9 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
 			if (file_exists($dir))
 			{
                 $pdf=pdf_getInstance($this->format);
+                $heightforinfotot = 80;	// Height reserved to output the info and total part (value include bottom margin)
+                $heightforfooter = 25;	// Height reserved to output the footer (value include bottom margin)
+                $pdf->SetAutoPageBreak(1,0);
 
                 if (class_exists('TCPDF'))
                 {
@@ -158,7 +161,6 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
 				if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
 
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
-				$pdf->SetAutoPageBreak(1,0);
 
 				// New page
 				$pdf->AddPage();
@@ -184,10 +186,15 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
 
 					$pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
 
-                    // Description de la ligne produit
-					//$libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs);
+					$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
+					$pageposbefore=$pdf->getPage();
+
+					// Description de la ligne produit
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,100,3,30,$curY,1);
-					//$pdf->writeHTMLCell(100, 3, 30, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1);
+
+					$pageposafter=$pdf->getPage();
+					$pdf->setPage($pageposbefore);
+					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
 
 					$pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
 					$nexY = $pdf->GetY();
@@ -217,66 +224,50 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
 
 					$nexY+=2;    // Passe espace entre les lignes
 
-					// Cherche nombre de lignes a venir pour savoir si place suffisante
-					if ($i < ($nblines - 1) && empty($hidedesc))	// If it's not last line
-					{
-						//on recupere la description du produit suivant
-						$follow_descproduitservice = $object->lines[$i+1]->desc;
-						//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
-						$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4);
-					}
-					else	// If it's last line
-					{
-						$nblineFollowDesc = 0;
-					}
-
-					// Test if a new page is required
-					if ($pagenb == 1)
+					// Detect if some page were added automatically and output _tableau for past pages
+					while ($pagenb < $pageposafter)
 					{
-						$tab_top_in_current_page=$tab_top;
-						$tab_height_in_current_page=$tab_height;
-					}
-					else
-					{
-						$tab_top_in_current_page=$tab_top_newpage;
-						$tab_height_in_current_page=$tab_height_newpage;
+						if ($pagenb == 1)
+						{
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+						}
+						else
+						{
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
+						$pagenb++;
+						$pdf->setPage($pagenb);
+						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
 					}
-
-					if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblines - 1))
+					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
 					{
 						if ($pagenb == 1)
 						{
-							$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs);
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
 						}
 						else
 						{
-							$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
 						}
-
-						$this->_pagefoot($pdf, $object, $outputlangs);
-
+						$this->_pagefoot($pdf,$object,$outputlangs);
 						// New page
 						$pdf->AddPage();
+						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
 						$pagenb++;
-						$this->_pagehead($pdf, $object, 0, $outputlangs);
-						$pdf->SetFont('','', $default_font_size - 1);
-						$pdf->MultiCell(0, 3, '');		// Set interline to 3
-						$pdf->SetTextColor(0,0,0);
-
-						$nexY = $tab_top_newpage + 7;
 					}
 				}
 
 				// Show square
 				if ($pagenb == 1)
 				{
-					$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
-					$bottomlasttab=$tab_top + $tab_height + 1;
+					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
 				}
 				else
 				{
-					$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
-					$bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1;
+					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
 				}
 
 				/*
@@ -309,9 +300,11 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
 	 *   @param		string		$tab_height		Height of table (rectangle)
 	 *   @param		int			$nexY			Y
 	 *   @param		Translate	$outputlangs	Langs object
+	 *   @param		int			$hidetop		Hide top bar of array
+	 *   @param		int			$hidebottom		Hide bottom bar of array
 	 *   @return	void
 	 */
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
 	{
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
 		$pdf->SetFont('','', $default_font_size - 1);
diff --git a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php
index 05da0f4bed4bd4b04c332556bb45bc569995c772..098a59323dae7b8f3fe6eccfa248d70c590b3671 100644
--- a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php
+++ b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php
@@ -142,6 +142,9 @@ class pdf_typhon extends ModelePDFDeliveryOrder
 			if (file_exists($dir))
 			{
                 $pdf=pdf_getInstance($this->format);
+                $heightforinfotot = 80;	// Height reserved to output the info and total part (value include bottom margin)
+                $heightforfooter = 25;	// Height reserved to output the footer (value include bottom margin)
+                $pdf->SetAutoPageBreak(1,0);
 
                 if (class_exists('TCPDF'))
                 {
@@ -180,7 +183,6 @@ class pdf_typhon extends ModelePDFDeliveryOrder
 				if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
 
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
-				$pdf->SetAutoPageBreak(1,0);
 
 				/*
 				 // Positionne $this->atleastonediscount si on a au moins une remise
@@ -240,10 +242,15 @@ class pdf_typhon extends ModelePDFDeliveryOrder
 
                     $pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
 
-                    // Description de la ligne produit
-					//$libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs);
+					$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
+					$pageposbefore=$pdf->getPage();
+
+					// Description de la ligne produit
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,108,3,$this->posxdesc-1,$curY);
-					//$pdf->writeHTMLCell(108, 3, $this->posxdesc-1, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1);
+
+					$pageposafter=$pdf->getPage();
+					$pdf->setPage($pageposbefore);
+					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
 
 					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
 					$nexY = $pdf->GetY();
@@ -281,68 +288,52 @@ class pdf_typhon extends ModelePDFDeliveryOrder
 					 */
 					$nexY+=2;    // Passe espace entre les lignes
 
-					// Cherche nombre de lignes a venir pour savoir si place suffisante
-					if ($i < ($nblines - 1) && empty($hidedesc))	// If it's not last line
-					{
-						//on recupere la description du produit suivant
-						$follow_descproduitservice = $object->lines[$i+1]->desc;
-						//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
-						$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4);
-					}
-					else	// If it's last line
-					{
-						$nblineFollowDesc = 0;
-					}
-
-					// Test if a new page is required
-					if ($pagenb == 1)
-					{
-						$tab_top_in_current_page=$tab_top;
-						$tab_height_in_current_page=$tab_height;
-					}
-					else
-					{
-						$tab_top_in_current_page=$tab_top_newpage;
-						$tab_height_in_current_page=$tab_height_newpage;
-					}
-					if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblines - 1))
-					{
-						if ($pagenb == 1)
-						{
-							$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs);
-						}
-						else
-						{
-							$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
-						}
-
-						$this->_pagefoot($pdf, $object, $outputlangs);
-
-						// New page
-						$pdf->AddPage();
-						$pagenb++;
-						$this->_pagehead($pdf, $object, 0, $outputlangs);
-						$pdf->SetFont('','', $default_font_size - 1);
-						$pdf->MultiCell(0, 3, '');		// Set interline to 3
-						$pdf->SetTextColor(0,0,0);
-
-						$nexY = $tab_top_newpage + 7;
-					}
+					// Detect if some page were added automatically and output _tableau for past pages
+					while ($pagenb < $pageposafter)
+					{
+						if ($pagenb == 1)
+						{
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+						}
+						else
+						{
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
+						$pagenb++;
+						$pdf->setPage($pagenb);
+						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+					}
+					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
+					{
+						if ($pagenb == 1)
+						{
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+						}
+						else
+						{
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
+						// New page
+						$pdf->AddPage();
+						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+						$pagenb++;
+					}
 				}
 
 				// Show square
 				if ($pagenb == 1)
 				{
-					$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
-					$bottomlasttab=$tab_top + $tab_height + 1;
+					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
 				}
 				else
 				{
-					$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
-					$bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1;
+					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
 				}
 
-
 				/*
 				 * Pied de page
 				 */
@@ -437,9 +428,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder
 	 *   @param		string		$tab_height		Height of table (rectangle)
 	 *   @param		int			$nexY			Y
 	 *   @param		Translate	$outputlangs	Langs object
+	 *   @param		int			$hidetop		Hide top bar of array
+	 *   @param		int			$hidebottom		Hide bottom bar of array
 	 *   @return	void
 	 */
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
 	{
 		global $conf,$mysoc;
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
diff --git a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php
index b34d3b9a6fc872ca5afb15b9032f5a6f6b331e7c..8f6fe597449c6fd7cffbaf4cbcabeb46885d97a0 100644
--- a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php
+++ b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php
@@ -127,6 +127,9 @@ class pdf_baleine extends ModelePDFProjects
 			if (file_exists($dir))
 			{
                 $pdf=pdf_getInstance($this->format);
+                $heightforinfotot = 80;	// Height reserved to output the info and total part (value include bottom margin)
+                $heightforfooter = 25;	// Height reserved to output the footer (value include bottom margin)
+                $pdf->SetAutoPageBreak(1,0);
 
                 if (class_exists('TCPDF'))
                 {
@@ -154,7 +157,6 @@ class pdf_baleine extends ModelePDFProjects
 				if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
 
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
-				$pdf->SetAutoPageBreak(1,0);
 
 				// New page
 				$pdf->AddPage();
@@ -225,43 +227,51 @@ class pdf_baleine extends ModelePDFProjects
 
 					$nexY+=2;    // Passe espace entre les lignes
 
-					// Cherche nombre de lignes a venir pour savoir si place suffisante
-					if ($i < ($nblignes - 1) && empty($hidedesc))	// If it's not last line
-					{
-						//on recupere la description du produit suivant
-						$follow_descproduitservice = $object->lines[$i+1]->desc;
-						//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
-						$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4);
-					}
-					else	// If it's last line
-					{
-						$nblineFollowDesc = 0;
-					}
-
-					if (($nexY+$nblineFollowDesc) > ($tab_top+$tab_height) && $i < ($nblignes - 1))
-					{
-						$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs);
-
-						$this->_pagefoot($pdf, $object, $outputlangs);
-
-						// New page
-						$pdf->AddPage();
-						$pagenb++;
-						$this->_pagehead($pdf, $object, 0, $outputlangs);
-						$pdf->SetFont('','', $default_font_size - 1);
-						$pdf->MultiCell(0, 3, '');		// Set interline to 3
-						$pdf->SetTextColor(0,0,0);
-
-						$tab_top=$tab_top_newpage;
-						$tab_height=$tab_height_newpage;
-
-						$nexY = $tab_top + 7;
-					}
+					// Detect if some page were added automatically and output _tableau for past pages
+					while ($pagenb < $pageposafter)
+					{
+						if ($pagenb == 1)
+						{
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+						}
+						else
+						{
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
+						$pagenb++;
+						$pdf->setPage($pagenb);
+						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+					}
+					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
+					{
+						if ($pagenb == 1)
+						{
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+						}
+						else
+						{
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
+						// New page
+						$pdf->AddPage();
+						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+						$pagenb++;
+					}
 				}
 
 				// Show square
-				$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
-				$bottomlasttab=$tab_top + $tab_height + 1;
+				if ($pagenb == 1)
+				{
+					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
+				}
+				else
+				{
+					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 1, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
+				}
 
 				/*
 				 * Pied de page
@@ -297,9 +307,11 @@ class pdf_baleine extends ModelePDFProjects
 	 *   @param		string		$tab_height		Height of table (rectangle)
 	 *   @param		int			$nexY			Y
 	 *   @param		Translate	$outputlangs	Langs object
+	 *   @param		int			$hidetop		Hide top bar of array
+	 *   @param		int			$hidebottom		Hide bottom bar of array
 	 *   @return	void
 	 */
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
 	{
 		global $conf,$mysoc;
 
diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
index dd55cf728f9d3d5c05ad7787adfae32b491532b3..a9d6e5d1fdb7ca32b1ddcfc4dada0fe7e1e90685 100644
--- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
@@ -163,6 +163,9 @@ class pdf_azur extends ModelePDFPropales
 
 				// Create pdf instance
                 $pdf=pdf_getInstance($this->format);
+                $heightforinfotot = 80;	// Height reserved to output the info and total part (value include bottom margin)
+                $heightforfooter = 25;	// Height reserved to output the footer (value include bottom margin)
+                $pdf->SetAutoPageBreak(1,0);
 
                 if (class_exists('TCPDF'))
                 {
@@ -189,7 +192,6 @@ class pdf_azur extends ModelePDFPropales
 				if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
 
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
-				$pdf->SetAutoPageBreak(1,0);
 
 				// Positionne $this->atleastonediscount si on a au moins une remise
 				for ($i = 0 ; $i < $nblignes ; $i++)
@@ -249,10 +251,17 @@ class pdf_azur extends ModelePDFPropales
 
 					$pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
 
+					$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
+					$pageposbefore=$pdf->getPage();
+
 					// Description de la ligne produit
 					$curX = $this->posxdesc-1;
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
 
+					$pageposafter=$pdf->getPage();
+					$pdf->setPage($pageposbefore);
+					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+
 					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
 					$nexY = $pdf->GetY();
 
@@ -308,67 +317,50 @@ class pdf_azur extends ModelePDFPropales
 
 					$nexY+=2;    // Passe espace entre les lignes
 
-					// Cherche nombre de lignes a venir pour savoir si place suffisante
-					if ($i < ($nblignes - 1) && empty($hidedesc))	// If it's not last line
-					{
-						//on recupere la description du produit suivant
-						$follow_descproduitservice = $object->lines[$i+1]->desc;
-						//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
-						$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4);
-					}
-					else	// If it's last line
-					{
-						$nblineFollowDesc = 0;
-					}
-
-					// Test if a new page is required
-					if ($pagenb == 1)
-					{
-						$tab_top_in_current_page=$tab_top;
-						$tab_height_in_current_page=$tab_height;
-					}
-					else
-					{
-						$tab_top_in_current_page=$tab_top_newpage;
-						$tab_height_in_current_page=$tab_height_middlepage;
-					}
-					if ((($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblignes - 1)) || (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak))
-					{
-						if ($pagenb == 1)
-						{
-							$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs);
-						}
-						else
-						{
-							$this->_tableau($pdf, $tab_top_newpage, $tab_height_middlepage, $nexY, $outputlangs);
-						}
-
-						$this->_pagefoot($pdf,$object,$outputlangs);
-
-						// New page
-						$pdf->AddPage();
-				        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
-						$pagenb++;
-						$this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
-						$pdf->SetFont('','', $default_font_size - 1);
-						$pdf->MultiCell(0, 3, '');		// Set interline to 3
-						$pdf->SetTextColor(0,0,0);
-
-						$nexY = $tab_top_newpage + 7;
-					}
-
+					// Detect if some page were added automatically and output _tableau for past pages
+					while ($pagenb < $pageposafter)
+					{
+						if ($pagenb == 1)
+						{
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+						}
+						else
+						{
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
+						$pagenb++;
+						$pdf->setPage($pagenb);
+						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+					}
+					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
+					{
+						if ($pagenb == 1)
+						{
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+						}
+						else
+						{
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
+						// New page
+						$pdf->AddPage();
+						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+						$pagenb++;
+					}
 				}
 
 				// Show square
 				if ($pagenb == 1)
 				{
-					$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
-					$bottomlasttab=$tab_top + $tab_height + 1;
+					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
 				}
 				else
 				{
-					$this->_tableau($pdf, $tab_top_newpage, $tab_height_endpage, $nexY, $outputlangs);
-					$bottomlasttab=$tab_top_newpage + $tab_height_endpage + 1;
+					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
 				}
 
 				// Affiche zone infos
@@ -828,9 +820,11 @@ class pdf_azur extends ModelePDFPropales
 	 *   @param		string		$tab_height		Height of table (rectangle)
 	 *   @param		int			$nexY			Y
 	 *   @param		Translate	$outputlangs	Langs object
+	 *   @param		int			$hidetop		Hide top bar of array
+	 *   @param		int			$hidebottom		Hide bottom bar of array
 	 *   @return	void
 	 */
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
 	{
 		global $conf;
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
diff --git a/htdocs/core/modules/propale/doc/pdf_jaune.modules.php b/htdocs/core/modules/propale/doc/pdf_jaune.modules.php
index 400da56bb7594231e3388f9ae6c8b9e2fbe3588c..1160bdbf3c8fddd4049282fe2117a1881e16494c 100644
--- a/htdocs/core/modules/propale/doc/pdf_jaune.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_jaune.modules.php
@@ -163,6 +163,9 @@ class pdf_jaune extends ModelePDFPropales
 
 				// Create pdf instance
                 $pdf=pdf_getInstance($this->format);
+                $heightforinfotot = 80;	// Height reserved to output the info and total part (value include bottom margin)
+                $heightforfooter = 25;	// Height reserved to output the footer (value include bottom margin)
+                $pdf->SetAutoPageBreak(1,0);
 
                 if (class_exists('TCPDF'))
                 {
@@ -189,7 +192,6 @@ class pdf_jaune extends ModelePDFPropales
 				if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
 
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
-				$pdf->SetAutoPageBreak(1,0);
 
 				// Positionne $this->atleastonediscount si on a au moins une remise
 				for ($i = 0 ; $i < $nblignes ; $i++)
@@ -249,10 +251,17 @@ class pdf_jaune extends ModelePDFPropales
 
 					$pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
 
+					$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
+					$pageposbefore=$pdf->getPage();
+
 					// Description de la ligne produit
 					$curX = $this->posxdesc-1;
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
 
+					$pageposafter=$pdf->getPage();
+					$pdf->setPage($pageposbefore);
+					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+
 					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
 					$nexY = $pdf->GetY();
 
@@ -308,67 +317,50 @@ class pdf_jaune extends ModelePDFPropales
 
 					$nexY+=2;    // Passe espace entre les lignes
 
-					// Cherche nombre de lignes a venir pour savoir si place suffisante
-					if ($i < ($nblignes - 1) && empty($hidedesc))	// If it's not last line
-					{
-						//on recupere la description du produit suivant
-						$follow_descproduitservice = $object->lines[$i+1]->desc;
-						//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
-						$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4);
-					}
-					else	// If it's last line
-					{
-						$nblineFollowDesc = 0;
-					}
-
-					// Test if a new page is required
-					if ($pagenb == 1)
-					{
-						$tab_top_in_current_page=$tab_top;
-						$tab_height_in_current_page=$tab_height;
-					}
-					else
-					{
-						$tab_top_in_current_page=$tab_top_newpage;
-						$tab_height_in_current_page=$tab_height_middlepage;
-					}
-					if ((($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblignes - 1)) || (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak))
-					{
-						if ($pagenb == 1)
-						{
-							$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs);
-						}
-						else
-						{
-							$this->_tableau($pdf, $tab_top_newpage, $tab_height_middlepage, $nexY, $outputlangs);
-						}
-
-						$this->_pagefoot($pdf,$object,$outputlangs);
-
-						// New page
-						$pdf->AddPage();
-				        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
-						$pagenb++;
-						$this->_pagehead($pdf, $object, 0, $outputlangs);
-						$pdf->SetFont('','', $default_font_size - 1);
-						$pdf->MultiCell(0, 3, '');		// Set interline to 3
-						$pdf->SetTextColor(0,0,0);
-
-						$nexY = $tab_top_newpage + 7;
-					}
-
+					// Detect if some page were added automatically and output _tableau for past pages
+					while ($pagenb < $pageposafter)
+					{
+						if ($pagenb == 1)
+						{
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+						}
+						else
+						{
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
+						$pagenb++;
+						$pdf->setPage($pagenb);
+						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+					}
+					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
+					{
+						if ($pagenb == 1)
+						{
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+						}
+						else
+						{
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
+						// New page
+						$pdf->AddPage();
+						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+						$pagenb++;
+					}
 				}
 
 				// Show square
 				if ($pagenb == 1)
 				{
-					$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
-					$bottomlasttab=$tab_top + $tab_height + 1;
+					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
 				}
 				else
 				{
-					$this->_tableau($pdf, $tab_top_newpage, $tab_height_endpage, $nexY, $outputlangs);
-					$bottomlasttab=$tab_top_newpage + $tab_height_endpage + 1;
+					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
 				}
 
 				// Affiche zone infos
@@ -809,9 +801,11 @@ class pdf_jaune extends ModelePDFPropales
 	 *   @param		string		$tab_height		Height of table (rectangle)
 	 *   @param		int			$nexY			Y
 	 *   @param		Translate	$outputlangs	Langs object
+	 *   @param		int			$hidetop		Hide top bar of array
+	 *   @param		int			$hidebottom		Hide bottom bar of array
 	 *   @return	void
 	 */
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
 	{
 		global $conf;
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
index 3fc64061d0be2bbcab2fc3525a8dd030c0b67264..70728e8ea4d70411c6600879bdbb5e793b554ad3 100755
--- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
+++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
@@ -171,6 +171,9 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 				$nblignes = count($object->lines);
 
                 $pdf=pdf_getInstance($this->format);
+                $heightforinfotot = 80;	// Height reserved to output the info and total part (value include bottom margin)
+                $heightforfooter = 25;	// Height reserved to output the footer (value include bottom margin)
+                $pdf->SetAutoPageBreak(1,0);
 
                 if (class_exists('TCPDF'))
                 {
@@ -197,7 +200,6 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 				if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
 
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
-				$pdf->SetAutoPageBreak(1,0);
 
 			    // Positionne $this->atleastonediscount si on a au moins une remise
                 for ($i = 0 ; $i < $nblignes ; $i++)
@@ -253,13 +255,19 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 				{
 					$curY = $nexY;
 
-                    $pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
-
-                    // Description of product line
                     $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
+
+					$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
+					$pageposbefore=$pdf->getPage();
+
+					// Description of product line
                     $curX = $this->posxdesc-1;
                     pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,0,0,1);
 
+					$pageposafter=$pdf->getPage();
+					$pdf->setPage($pageposbefore);
+					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+
 					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
 					$nexY = $pdf->GetY();
 
@@ -310,72 +318,50 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 
 					$nexY+=2;    // Passe espace entre les lignes
 
-					// Cherche nombre de lignes a venir pour savoir si place suffisante
-					if ($i < ($nblignes - 1) && empty($hidedesc))	// If it's not last line
-					{
-						//on recupere la description du produit suivant
-						$follow_descproduitservice = $object->lines[$i+1]->desc;
-						//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
-						$nblineFollowDesc = dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4;
-						// Et si on affiche dates de validite, on ajoute encore une ligne
-						if ($object->lines[$i]->date_start && $object->lines[$i]->date_end)
-						{
-							$nblineFollowDesc += 4;
-						}
-					}
-					else	// If it's last line
-					{
-						$nblineFollowDesc = 0;
-					}
-
-					// Test if a new page is required
-					if ($pagenb == 1)
-					{
-						$tab_top_in_current_page=$tab_top;
-						$tab_height_in_current_page=$tab_height;
-					}
-					else
-					{
-						$tab_top_in_current_page=$tab_top_newpage;
-						$tab_height_in_current_page=$tab_height_newpage;
-					}
-					if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblignes - 1))
-					{
-						if ($pagenb == 1)
-						{
-							$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs);
-						}
-						else
-						{
-							$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
-						}
-
-						$this->_pagefoot($pdf, $object, $outputlangs);
-
-						// New page
-						$pdf->AddPage();
-				        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
-						$pagenb++;
-						$this->_pagehead($pdf, $object, 0, $outputlangs);
-						$pdf->SetFont('','', $default_font_size - 1);
-						$pdf->MultiCell(0, 3, '');		// Set interline to 3
-						$pdf->SetTextColor(0,0,0);
-
-						$nexY = $tab_top_newpage + 7;
-					}
-
+					// Detect if some page were added automatically and output _tableau for past pages
+					while ($pagenb < $pageposafter)
+					{
+						if ($pagenb == 1)
+						{
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+						}
+						else
+						{
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
+						$pagenb++;
+						$pdf->setPage($pagenb);
+						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+					}
+					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
+					{
+						if ($pagenb == 1)
+						{
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+						}
+						else
+						{
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
+						// New page
+						$pdf->AddPage();
+						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+						$pagenb++;
+					}
 				}
 
 				// Show square
 				if ($pagenb == 1)
 				{
-					$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
-					$bottomlasttab=$tab_top + $tab_height + 1;
+					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
 				}
 				else
 				{
-					$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
-					$bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1;
+					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
 				}
 
 				// Affiche zone totaux
@@ -627,9 +613,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 	 *   @param		string		$tab_height		Height of table (rectangle)
 	 *   @param		int			$nexY			Y
 	 *   @param		Translate	$outputlangs	Langs object
+	 *   @param		int			$hidetop		Hide top bar of array
+	 *   @param		int			$hidebottom		Hide bottom bar of array
 	 *   @return	void
 	 */
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
 	{
 		global $conf;
 
diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
index e8fba3d9b464aaa88a2129779517ab1197d25541..bc1904b20d6863608ac1ddcccb2864cb8f08a2f4 100644
--- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
+++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
@@ -188,6 +188,9 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 				$nblignes = count($object->lines);
 
                 $pdf=pdf_getInstance($this->format);
+                $heightforinfotot = 80;	// Height reserved to output the info and total part (value include bottom margin)
+                $heightforfooter = 25;	// Height reserved to output the footer (value include bottom margin)
+                $pdf->SetAutoPageBreak(1,0);
 
                 if (class_exists('TCPDF'))
                 {
@@ -214,7 +217,6 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 				if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
 
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
-				$pdf->SetAutoPageBreak(1,0);
 
 				// Positionne $this->atleastonediscount si on a au moins une remise
 				for ($i = 0 ; $i < $nblignes ; $i++)
@@ -272,10 +274,17 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 
                     $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
 
+					$pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
+					$pageposbefore=$pdf->getPage();
+
 					// Description of product line
                     $curX = $this->posxdesc-1;
                     pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,0,0,1,$hookmanager);
 
+					$pageposafter=$pdf->getPage();
+					$pdf->setPage($pageposbefore);
+					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+
 					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
 					$nexY = $pdf->GetY();
 
@@ -328,72 +337,50 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 
 					$nexY+=2;    // Passe espace entre les lignes
 
-					// Cherche nombre de lignes a venir pour savoir si place suffisante
-					if ($i < ($nblignes - 1) && empty($hidedesc))	// If it's not last line
-					{
-						//on recupere la description du produit suivant
-						$follow_descproduitservice = $object->lines[$i+1]->desc;
-						//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
-						$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4);
-						// Et si on affiche dates de validite, on ajoute encore une ligne
-						if ($object->lines[$i]->date_start && $object->lines[$i]->date_end)
-						{
-							$nblineFollowDesc += 4;
-						}
-					}
-					else	// If it's last line
-					{
-						$nblineFollowDesc = 0;
-					}
-
-					// Test if a new page is required
-					if ($pagenb == 1)
-					{
-						$tab_top_in_current_page=$tab_top;
-						$tab_height_in_current_page=$tab_height;
-					}
-					else
-					{
-						$tab_top_in_current_page=$tab_top_newpage;
-						$tab_height_in_current_page=$tab_height_newpage;
-					}
-					if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblignes - 1))
-					{
-						if ($pagenb == 1)
-						{
-							$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs);
-						}
-						else
-						{
-							$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
-						}
-
-						$this->_pagefoot($pdf, $object, $outputlangs);
-
-						// New page
-						$pdf->AddPage();
-				        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
-						$pagenb++;
-						$this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
-						$pdf->SetFont('','', $default_font_size - 1);
-						$pdf->MultiCell(0, 3, '');		// Set interline to 3
-						$pdf->SetTextColor(0,0,0);
-
-						$nexY = $tab_top_newpage + 7;
-					}
-
+					// Detect if some page were added automatically and output _tableau for past pages
+					while ($pagenb < $pageposafter)
+					{
+						if ($pagenb == 1)
+						{
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+						}
+						else
+						{
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
+						$pagenb++;
+						$pdf->setPage($pagenb);
+						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+					}
+					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
+					{
+						if ($pagenb == 1)
+						{
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+						}
+						else
+						{
+							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+						}
+						$this->_pagefoot($pdf,$object,$outputlangs);
+						// New page
+						$pdf->AddPage();
+						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+						$pagenb++;
+					}
 				}
 
 				// Show square
 				if ($pagenb == 1)
 				{
-					$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
-					$bottomlasttab=$tab_top + $tab_height + 1;
+					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
 				}
 				else
 				{
-					$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
-					$bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1;
+					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0);
+					$bottomlasttab=$this->page_hauteur - $heightforinfotot + 1;
 				}
 
 				// Affiche zone infos
@@ -808,9 +795,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 	 *   @param		string		$tab_height		Height of table (rectangle)
 	 *   @param		int			$nexY			Y
 	 *   @param		Translate	$outputlangs	Langs object
+	 *   @param		int			$hidetop		Hide top bar of array
+	 *   @param		int			$hidebottom		Hide bottom bar of array
 	 *   @return	void
-     */
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
+	 */
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
 	{
 		global $conf;
 
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index 46f469a2d42d2088acef233520a4baa592812753..a69c7a0487376b0f8c73fa4bca129e2043474313 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -560,7 +560,7 @@ class Expedition extends CommonObject
 
 						dol_syslog("Rename ok");
 						// Suppression ancien fichier PDF dans nouveau rep
-						dol_delete_file($dirdest.'/'.$oldref.'.*');
+						dol_delete_file($dirdest.'/'.$oldref.'*.*');
 					}
 				}
 			}
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 612bfb01ee049e4088abd98f217d591c61f5258a..af36be18a443caa72e23d98a572f73bc6a7b8bf9 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -367,7 +367,7 @@ class CommandeFournisseur extends CommonOrder
 
                             dol_syslog("Rename ok");
                             // Suppression ancien fichier PDF dans nouveau rep
-                            dol_delete_file($dirdest.'/'.$oldref.'.*');
+                            dol_delete_file($dirdest.'/'.$oldref.'*.*');
                         }
                     }
                 }
diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php
index d17b97393d06f534e3325e9a3b3c55f116c94c1c..c85e8e81dc8ae38420ce931162f1241c8e54ca84 100644
--- a/htdocs/fourn/class/fournisseur.facture.class.php
+++ b/htdocs/fourn/class/fournisseur.facture.class.php
@@ -1282,6 +1282,7 @@ class FactureFournisseur extends CommonInvoice
     function initAsSpecimen()
     {
         global $langs,$conf;
+		include_once(DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php');
 
         $now = dol_now();
 
diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php
index 99638d7c1cee1f10ca0a6cc4a9f2b871c415624f..d238bf1eb41b5321b9ad4950e4416a7e8e089a65 100644
--- a/htdocs/fourn/commande/dispatch.php
+++ b/htdocs/fourn/commande/dispatch.php
@@ -217,13 +217,13 @@ if ($id > 0 || ! empty($ref))
 				$db->free($resql);
 			}
 
-			$sql = "SELECT l.rowid, l.ref, l.fk_product, l.description, l.subprice, sum(l.qty) as qty";
-			$sql.= ", p.label";
+			$sql = "SELECT l.fk_product, l.subprice, SUM(l.qty) as qty,";
+			$sql.= " p.ref, p.label";
 			$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
 			$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product=p.rowid";
 			$sql.= " WHERE l.fk_commande = ".$commande->id;
-			$sql.= " GROUP BY l.fk_product";
-			$sql.= " ORDER BY l.rowid";
+			$sql.= " GROUP BY p.ref, p.label, l.fk_product, l.subprice";	// Calculation of amount dispatched is done per fk_product so we must group by fk_product
+			$sql.= " ORDER BY p.ref, p.label";
 
 			$resql = $db->query($sql);
 			if ($resql)
@@ -260,7 +260,7 @@ if ($id > 0 || ! empty($ref))
 					{
 						$nbproduct++;
 
-						$remaintodispatch=($objp->qty - $products_dispatched[$objp->fk_product]);
+						$remaintodispatch=($objp->qty - $products_dispatched[$objp->fk_product]);	// Calculation of dispatched
 						if ($remaintodispatch < 0) $remaintodispatch=0;
 
 						$var=!$var;
@@ -268,7 +268,9 @@ if ($id > 0 || ! empty($ref))
 						print '<td>';
 						print '<a href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowProduct"),'product').' '.$objp->ref.'</a>';
 						print ' - '.$objp->label;
-						if ($objp->description) print '<br>'.nl2br($objp->description);
+						// To show detail cref and description value, we must make calculation by cref
+						//print ($objp->cref?' ('.$objp->cref.')':'');  
+						//if ($objp->description) print '<br>'.nl2br($objp->description);
 						print '<input name="product_'.$i.'" type="hidden" value="'.$objp->fk_product.'">';
 						print '<input name="pu_'.$i.'" type="hidden" value="'.$objp->subprice.'">';
 						print "</td>\n";
diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index 55fc63df8d06e7138208481af3215772c8664e43..0f88a16d7f26ff3e140965de279eaf0fdf714682 100644
--- a/htdocs/fourn/facture/fiche.php
+++ b/htdocs/fourn/facture/fiche.php
@@ -473,6 +473,8 @@ elseif ($action == 'addline')
             // cas special pour lequel on a les meme reference que le fournisseur
             // $label = '['.$product->ref.'] - '. $product->libelle;
             $label = $product->description;
+            $label.= $product->description && $_POST['np_desc'] ? "\n" : "";
+            $label.= $_POST['np_desc'];
 
             $tvatx=get_default_tva($object->thirdparty, $mysoc, $product->id, $_POST['idprodfournprice']);
 
@@ -1784,12 +1786,19 @@ else
                 print '<td colspan="4">';
                 $form->select_produits_fournisseurs($object->socid,'','idprodfournprice');
 
+                if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) print '<br>';
+                
                 if (is_object($hookmanager))
 				{
 			        $parameters=array('htmlname'=>'idprodfournprice');
 				    echo $hookmanager->executeHooks('formCreateProductSupplierOptions',$parameters,$object,$action);
 				}
 
+				$nbrows=ROWS_2;
+				if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
+				$doleditor = new DolEditor('np_desc', GETPOST('np_desc'), '', 100, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, $nbrows, 70);
+				$doleditor->Create();
+								
                 print '</td>';
                 print '<td align="right"><input type="text" name="qty" value="1" size="1"></td>';
                 print '<td>&nbsp;</td>';
diff --git a/htdocs/includes/jquery/plugins/lightbox/css/jquery.lightbox-0.5.css b/htdocs/includes/jquery/plugins/lightbox/css/jquery.lightbox-0.5.css
deleted file mode 100644
index c7c3d1cb1c2ead42d4f3d29c0c5ec223457504b8..0000000000000000000000000000000000000000
--- a/htdocs/includes/jquery/plugins/lightbox/css/jquery.lightbox-0.5.css
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * jQuery lightBox plugin
- * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
- * and adapted to me for use like a plugin from jQuery.
- * @name jquery-lightbox-0.5.css
- * @author Leandro Vieira Pinho - http://leandrovieira.com
- * @version 0.5
- * @date April 11, 2008
- * @category jQuery plugin
- * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
- * @license CCAttribution-ShareAlike 2.5 Brazil - http://creativecommons.org/licenses/by-sa/2.5/br/deed.en_US
- * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
- */
-#jquery-overlay {
-	position: absolute;
-	top: 0;
-	left: 0;
-	z-index: 90;
-	width: 100%;
-	height: 500px;
-}
-#jquery-lightbox {
-	position: absolute;
-	top: 0;
-	left: 0;
-	width: 100%;
-	z-index: 100;
-	text-align: center;
-	line-height: 0;
-}
-#jquery-lightbox a img { border: none; }
-#lightbox-container-image-box {
-	position: relative;
-	background-color: #fff;
-	width: 250px;
-	height: 250px;
-	margin: 0 auto;
-}
-#lightbox-container-image { padding: 10px; }
-#lightbox-loading {
-	position: absolute;
-	top: 40%;
-	left: 0%;
-	height: 25%;
-	width: 100%;
-	text-align: center;
-	line-height: 0;
-}
-#lightbox-nav {
-	position: absolute;
-	top: 0;
-	left: 0;
-	height: 100%;
-	width: 100%;
-	z-index: 10;
-}
-#lightbox-container-image-box > #lightbox-nav { left: 0; }
-#lightbox-nav a { outline: none;}
-#lightbox-nav-btnPrev, #lightbox-nav-btnNext {
-	width: 49%;
-	height: 100%;
-	zoom: 1;
-	display: block;
-}
-#lightbox-nav-btnPrev { 
-	left: 0; 
-	float: left;
-}
-#lightbox-nav-btnNext { 
-	right: 0; 
-	float: right;
-}
-#lightbox-container-image-data-box {
-	font: 10px Verdana, Helvetica, sans-serif;
-	background-color: #fff;
-	margin: 0 auto;
-	line-height: 1.4em;
-	overflow: auto;
-	width: 100%;
-	padding: 0 10px 0;
-}
-#lightbox-container-image-data {
-	padding: 0 10px; 
-	color: #666; 
-}
-#lightbox-container-image-data #lightbox-image-details { 
-	width: 70%; 
-	float: left; 
-	text-align: left; 
-}	
-#lightbox-image-details-caption { font-weight: bold; }
-#lightbox-image-details-currentNumber {
-	display: block; 
-	clear: left; 
-	padding-bottom: 1.0em;	
-}			
-#lightbox-secNav-btnClose {
-	width: 66px; 
-	float: right;
-	padding-bottom: 0.7em;	
-}
\ No newline at end of file
diff --git a/htdocs/includes/jquery/plugins/lightbox/images/lightbox-blank.gif b/htdocs/includes/jquery/plugins/lightbox/images/lightbox-blank.gif
deleted file mode 100644
index 1d11fa9ada9e93505b3d736acb204083f45d5fbf..0000000000000000000000000000000000000000
Binary files a/htdocs/includes/jquery/plugins/lightbox/images/lightbox-blank.gif and /dev/null differ
diff --git a/htdocs/includes/jquery/plugins/lightbox/images/lightbox-btn-close.gif b/htdocs/includes/jquery/plugins/lightbox/images/lightbox-btn-close.gif
deleted file mode 100644
index 33bcf517a35b72135b6a5b97bac72425762b8343..0000000000000000000000000000000000000000
Binary files a/htdocs/includes/jquery/plugins/lightbox/images/lightbox-btn-close.gif and /dev/null differ
diff --git a/htdocs/includes/jquery/plugins/lightbox/images/lightbox-btn-next.gif b/htdocs/includes/jquery/plugins/lightbox/images/lightbox-btn-next.gif
deleted file mode 100644
index a0d4fcf84a784f2cf44c33084145dde5df294ccf..0000000000000000000000000000000000000000
Binary files a/htdocs/includes/jquery/plugins/lightbox/images/lightbox-btn-next.gif and /dev/null differ
diff --git a/htdocs/includes/jquery/plugins/lightbox/images/lightbox-btn-prev.gif b/htdocs/includes/jquery/plugins/lightbox/images/lightbox-btn-prev.gif
deleted file mode 100644
index 040ee5992f7fdb9b51907cb4ba1c5570b1b5482a..0000000000000000000000000000000000000000
Binary files a/htdocs/includes/jquery/plugins/lightbox/images/lightbox-btn-prev.gif and /dev/null differ
diff --git a/htdocs/includes/jquery/plugins/lightbox/images/lightbox-ico-loading.gif b/htdocs/includes/jquery/plugins/lightbox/images/lightbox-ico-loading.gif
deleted file mode 100644
index 4f1429c06cb2ffd2910b038d06b01a4b3ee00a21..0000000000000000000000000000000000000000
Binary files a/htdocs/includes/jquery/plugins/lightbox/images/lightbox-ico-loading.gif and /dev/null differ
diff --git a/htdocs/includes/jquery/plugins/lightbox/js/jquery.lightbox-0.5.min.js b/htdocs/includes/jquery/plugins/lightbox/js/jquery.lightbox-0.5.min.js
deleted file mode 100644
index 429f0c557c8e2de483abfe39c9e0af34917ebf8e..0000000000000000000000000000000000000000
--- a/htdocs/includes/jquery/plugins/lightbox/js/jquery.lightbox-0.5.min.js
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * jQuery lightBox plugin
- * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
- * and adapted to me for use like a plugin from jQuery.
- * @name jquery-lightbox-0.5.js
- * @author Leandro Vieira Pinho - http://leandrovieira.com
- * @version 0.5
- * @date April 11, 2008
- * @category jQuery plugin
- * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
- * @license CCAttribution-ShareAlike 2.5 Brazil - http://creativecommons.org/licenses/by-sa/2.5/br/deed.en_US
- * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
- */
-(function($){$.fn.lightBox=function(settings){settings=jQuery.extend({overlayBgColor:'#000',overlayOpacity:0.8,fixedNavigation:false,imageLoading:'images/lightbox-ico-loading.gif',imageBtnPrev:'images/lightbox-btn-prev.gif',imageBtnNext:'images/lightbox-btn-next.gif',imageBtnClose:'images/lightbox-btn-close.gif',imageBlank:'images/lightbox-blank.gif',containerBorderSize:10,containerResizeSpeed:400,txtImage:'Image',txtOf:'of',keyToClose:'c',keyToPrev:'p',keyToNext:'n',imageArray:[],activeImage:0},settings);var jQueryMatchedObj=this;function _initialize(){_start(this,jQueryMatchedObj);return false;}
-function _start(objClicked,jQueryMatchedObj){$('embed, object, select').css({'visibility':'hidden'});_set_interface();settings.imageArray.length=0;settings.activeImage=0;if(jQueryMatchedObj.length==1){settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));}else{for(var i=0;i<jQueryMatchedObj.length;i++){settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));}}
-while(settings.imageArray[settings.activeImage][0]!=objClicked.getAttribute('href')){settings.activeImage++;}
-_set_image_to_view();}
-function _set_interface(){$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="'+settings.imageLoading+'"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="'+settings.imageBtnClose+'"></a></div></div></div></div>');var arrPageSizes=___getPageSize();$('#jquery-overlay').css({backgroundColor:settings.overlayBgColor,opacity:settings.overlayOpacity,width:arrPageSizes[0],height:arrPageSizes[1]}).fadeIn();var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]}).show();$('#jquery-overlay,#jquery-lightbox').click(function(){_finish();});$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function(){_finish();return false;});$(window).resize(function(){var arrPageSizes=___getPageSize();$('#jquery-overlay').css({width:arrPageSizes[0],height:arrPageSizes[1]});var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]});});}
-function _set_image_to_view(){$('#lightbox-loading').show();if(settings.fixedNavigation){$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}else{$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}
-var objImagePreloader=new Image();objImagePreloader.onload=function(){$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);objImagePreloader.onload=function(){};};objImagePreloader.src=settings.imageArray[settings.activeImage][0];};function _resize_container_image_box(intImageWidth,intImageHeight){var intCurrentWidth=$('#lightbox-container-image-box').width();var intCurrentHeight=$('#lightbox-container-image-box').height();var intWidth=(intImageWidth+(settings.containerBorderSize*2));var intHeight=(intImageHeight+(settings.containerBorderSize*2));var intDiffW=intCurrentWidth-intWidth;var intDiffH=intCurrentHeight-intHeight;$('#lightbox-container-image-box').animate({width:intWidth,height:intHeight},settings.containerResizeSpeed,function(){_show_image();});if((intDiffW==0)&&(intDiffH==0)){if($.browser.msie){___pause(250);}else{___pause(100);}}
-$('#lightbox-container-image-data-box').css({width:intImageWidth});$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({height:intImageHeight+(settings.containerBorderSize*2)});};function _show_image(){$('#lightbox-loading').hide();$('#lightbox-image').fadeIn(function(){_show_image_data();_set_navigation();});_preload_neighbor_images();};function _show_image_data(){$('#lightbox-container-image-data-box').slideDown('fast');$('#lightbox-image-details-caption').hide();if(settings.imageArray[settings.activeImage][1]){$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();}
-if(settings.imageArray.length>1){$('#lightbox-image-details-currentNumber').html(settings.txtImage+' '+(settings.activeImage+1)+' '+settings.txtOf+' '+settings.imageArray.length).show();}}
-function _set_navigation(){$('#lightbox-nav').show();$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({'background':'transparent url('+settings.imageBlank+') no-repeat'});if(settings.activeImage!=0){if(settings.fixedNavigation){$('#lightbox-nav-btnPrev').css({'background':'url('+settings.imageBtnPrev+') left 15% no-repeat'}).unbind().bind('click',function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnPrev').unbind().hover(function(){$(this).css({'background':'url('+settings.imageBtnPrev+') left 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageBlank+') no-repeat'});}).show().bind('click',function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}}
-if(settings.activeImage!=(settings.imageArray.length-1)){if(settings.fixedNavigation){$('#lightbox-nav-btnNext').css({'background':'url('+settings.imageBtnNext+') right 15% no-repeat'}).unbind().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnNext').unbind().hover(function(){$(this).css({'background':'url('+settings.imageBtnNext+') right 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageBlank+') no-repeat'});}).show().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}}
-_enable_keyboard_navigation();}
-function _enable_keyboard_navigation(){$(document).keydown(function(objEvent){_keyboard_action(objEvent);});}
-function _disable_keyboard_navigation(){$(document).unbind();}
-function _keyboard_action(objEvent){if(objEvent==null){keycode=event.keyCode;escapeKey=27;}else{keycode=objEvent.keyCode;escapeKey=objEvent.DOM_VK_ESCAPE;}
-key=String.fromCharCode(keycode).toLowerCase();if((key==settings.keyToClose)||(key=='x')||(keycode==escapeKey)){_finish();}
-if((key==settings.keyToPrev)||(keycode==37)){if(settings.activeImage!=0){settings.activeImage=settings.activeImage-1;_set_image_to_view();_disable_keyboard_navigation();}}
-if((key==settings.keyToNext)||(keycode==39)){if(settings.activeImage!=(settings.imageArray.length-1)){settings.activeImage=settings.activeImage+1;_set_image_to_view();_disable_keyboard_navigation();}}}
-function _preload_neighbor_images(){if((settings.imageArray.length-1)>settings.activeImage){objNext=new Image();objNext.src=settings.imageArray[settings.activeImage+1][0];}
-if(settings.activeImage>0){objPrev=new Image();objPrev.src=settings.imageArray[settings.activeImage-1][0];}}
-function _finish(){$('#jquery-lightbox').remove();$('#jquery-overlay').fadeOut(function(){$('#jquery-overlay').remove();});$('embed, object, select').css({'visibility':'visible'});}
-function ___getPageSize(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=window.innerWidth+window.scrollMaxX;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}
-var windowWidth,windowHeight;if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;}else{windowWidth=self.innerWidth;}
-windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}
-if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
-if(xScroll<windowWidth){pageWidth=xScroll;}else{pageWidth=windowWidth;}
-arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight);return arrayPageSize;};function ___getPageScroll(){var xScroll,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;xScroll=self.pageXOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;xScroll=document.documentElement.scrollLeft;}else if(document.body){yScroll=document.body.scrollTop;xScroll=document.body.scrollLeft;}
-arrayPageScroll=new Array(xScroll,yScroll);return arrayPageScroll;};function ___pause(ms){var date=new Date();curDate=null;do{var curDate=new Date();}
-while(curDate-date<ms);};return this.unbind('click').click(_initialize);};})(jQuery);
\ No newline at end of file
diff --git a/htdocs/includes/jquery/plugins/lightbox/js/jquery.lightbox-0.5.pack.js b/htdocs/includes/jquery/plugins/lightbox/js/jquery.lightbox-0.5.pack.js
deleted file mode 100644
index cb4b4ca94c757e36b2b7b50fd7c81a64b39a0e0b..0000000000000000000000000000000000000000
--- a/htdocs/includes/jquery/plugins/lightbox/js/jquery.lightbox-0.5.pack.js
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * jQuery lightBox plugin
- * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
- * and adapted to me for use like a plugin from jQuery.
- * @name jquery-lightbox-0.5.js
- * @author Leandro Vieira Pinho - http://leandrovieira.com
- * @version 0.5
- * @date April 11, 2008
- * @category jQuery plugin
- * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
- * @license CCAttribution-ShareAlike 2.5 Brazil - http://creativecommons.org/licenses/by-sa/2.5/br/deed.en_US
- * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
- */
-eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(6($){$.2N.3g=6(4){4=23.2H({2B:\'#34\',2g:0.8,1d:F,1M:\'18/5-33-Y.16\',1v:\'18/5-1u-2Q.16\',1E:\'18/5-1u-2L.16\',1W:\'18/5-1u-2I.16\',19:\'18/5-2F.16\',1f:10,2A:3d,2s:\'1j\',2o:\'32\',2j:\'c\',2f:\'p\',2d:\'n\',h:[],9:0},4);f I=N;6 20(){1X(N,I);u F}6 1X(1e,I){$(\'1U, 1S, 1R\').l({\'1Q\':\'2E\'});1O();4.h.B=0;4.9=0;7(I.B==1){4.h.1J(v 1m(1e.17(\'J\'),1e.17(\'2v\')))}j{36(f i=0;i<I.B;i++){4.h.1J(v 1m(I[i].17(\'J\'),I[i].17(\'2v\')))}}2n(4.h[4.9][0]!=1e.17(\'J\')){4.9++}D()}6 1O(){$(\'m\').31(\'<e g="q-13"></e><e g="q-5"><e g="5-s-b-w"><e g="5-s-b"><1w g="5-b"><e 2V="" g="5-k"><a J="#" g="5-k-V"></a><a J="#" g="5-k-X"></a></e><e g="5-Y"><a J="#" g="5-Y-29"><1w W="\'+4.1M+\'"></a></e></e></e><e g="5-s-b-T-w"><e g="5-s-b-T"><e g="5-b-A"><1i g="5-b-A-1t"></1i><1i g="5-b-A-1g"></1i></e><e g="5-1s"><a J="#" g="5-1s-22"><1w W="\'+4.1W+\'"></a></e></e></e></e>\');f z=1D();$(\'#q-13\').l({2K:4.2B,2J:4.2g,S:z[0],P:z[1]}).1V();f R=1p();$(\'#q-5\').l({1T:R[1]+(z[3]/10),1c:R[0]}).E();$(\'#q-13,#q-5\').C(6(){1a()});$(\'#5-Y-29,#5-1s-22\').C(6(){1a();u F});$(G).2G(6(){f z=1D();$(\'#q-13\').l({S:z[0],P:z[1]});f R=1p();$(\'#q-5\').l({1T:R[1]+(z[3]/10),1c:R[0]})})}6 D(){$(\'#5-Y\').E();7(4.1d){$(\'#5-b,#5-s-b-T-w,#5-b-A-1g\').1b()}j{$(\'#5-b,#5-k,#5-k-V,#5-k-X,#5-s-b-T-w,#5-b-A-1g\').1b()}f Q=v 1j();Q.1P=6(){$(\'#5-b\').2D(\'W\',4.h[4.9][0]);1N(Q.S,Q.P);Q.1P=6(){}};Q.W=4.h[4.9][0]};6 1N(1o,1r){f 1L=$(\'#5-s-b-w\').S();f 1K=$(\'#5-s-b-w\').P();f 1n=(1o+(4.1f*2));f 1y=(1r+(4.1f*2));f 1I=1L-1n;f 2z=1K-1y;$(\'#5-s-b-w\').3f({S:1n,P:1y},4.2A,6(){2y()});7((1I==0)&&(2z==0)){7($.3e.3c){1H(3b)}j{1H(3a)}}$(\'#5-s-b-T-w\').l({S:1o});$(\'#5-k-V,#5-k-X\').l({P:1r+(4.1f*2)})};6 2y(){$(\'#5-Y\').1b();$(\'#5-b\').1V(6(){2u();2t()});2r()};6 2u(){$(\'#5-s-b-T-w\').38(\'35\');$(\'#5-b-A-1t\').1b();7(4.h[4.9][1]){$(\'#5-b-A-1t\').2p(4.h[4.9][1]).E()}7(4.h.B>1){$(\'#5-b-A-1g\').2p(4.2s+\' \'+(4.9+1)+\' \'+4.2o+\' \'+4.h.B).E()}}6 2t(){$(\'#5-k\').E();$(\'#5-k-V,#5-k-X\').l({\'K\':\'1C M(\'+4.19+\') L-O\'});7(4.9!=0){7(4.1d){$(\'#5-k-V\').l({\'K\':\'M(\'+4.1v+\') 1c 15% L-O\'}).11().1k(\'C\',6(){4.9=4.9-1;D();u F})}j{$(\'#5-k-V\').11().2m(6(){$(N).l({\'K\':\'M(\'+4.1v+\') 1c 15% L-O\'})},6(){$(N).l({\'K\':\'1C M(\'+4.19+\') L-O\'})}).E().1k(\'C\',6(){4.9=4.9-1;D();u F})}}7(4.9!=(4.h.B-1)){7(4.1d){$(\'#5-k-X\').l({\'K\':\'M(\'+4.1E+\') 2l 15% L-O\'}).11().1k(\'C\',6(){4.9=4.9+1;D();u F})}j{$(\'#5-k-X\').11().2m(6(){$(N).l({\'K\':\'M(\'+4.1E+\') 2l 15% L-O\'})},6(){$(N).l({\'K\':\'1C M(\'+4.19+\') L-O\'})}).E().1k(\'C\',6(){4.9=4.9+1;D();u F})}}2k()}6 2k(){$(d).30(6(12){2i(12)})}6 1G(){$(d).11()}6 2i(12){7(12==2h){U=2Z.2e;1x=27}j{U=12.2e;1x=12.2Y}14=2X.2W(U).2U();7((14==4.2j)||(14==\'x\')||(U==1x)){1a()}7((14==4.2f)||(U==37)){7(4.9!=0){4.9=4.9-1;D();1G()}}7((14==4.2d)||(U==39)){7(4.9!=(4.h.B-1)){4.9=4.9+1;D();1G()}}}6 2r(){7((4.h.B-1)>4.9){2c=v 1j();2c.W=4.h[4.9+1][0]}7(4.9>0){2b=v 1j();2b.W=4.h[4.9-1][0]}}6 1a(){$(\'#q-5\').2a();$(\'#q-13\').2T(6(){$(\'#q-13\').2a()});$(\'1U, 1S, 1R\').l({\'1Q\':\'2S\'})}6 1D(){f o,r;7(G.1h&&G.28){o=G.26+G.2R;r=G.1h+G.28}j 7(d.m.25>d.m.24){o=d.m.2P;r=d.m.25}j{o=d.m.2O;r=d.m.24}f y,H;7(Z.1h){7(d.t.1l){y=d.t.1l}j{y=Z.26}H=Z.1h}j 7(d.t&&d.t.1A){y=d.t.1l;H=d.t.1A}j 7(d.m){y=d.m.1l;H=d.m.1A}7(r<H){1z=H}j{1z=r}7(o<y){1B=o}j{1B=y}21=v 1m(1B,1z,y,H);u 21};6 1p(){f o,r;7(Z.1Z){r=Z.1Z;o=Z.2M}j 7(d.t&&d.t.1F){r=d.t.1F;o=d.t.1Y}j 7(d.m){r=d.m.1F;o=d.m.1Y}2q=v 1m(o,r);u 2q};6 1H(2C){f 2x=v 2w();1q=2h;3h{f 1q=v 2w()}2n(1q-2x<2C)};u N.11(\'C\').C(20)}})(23);',62,204,'||||settings|lightbox|function|if||activeImage||image||document|div|var|id|imageArray||else|nav|css|body||xScroll||jquery|yScroll|container|documentElement|return|new|box||windowWidth|arrPageSizes|details|length|click|_set_image_to_view|show|false|window|windowHeight|jQueryMatchedObj|href|background|no|url|this|repeat|height|objImagePreloader|arrPageScroll|width|data|keycode|btnPrev|src|btnNext|loading|self||unbind|objEvent|overlay|key||gif|getAttribute|images|imageBlank|_finish|hide|left|fixedNavigation|objClicked|containerBorderSize|currentNumber|innerHeight|span|Image|bind|clientWidth|Array|intWidth|intImageWidth|___getPageScroll|curDate|intImageHeight|secNav|caption|btn|imageBtnPrev|img|escapeKey|intHeight|pageHeight|clientHeight|pageWidth|transparent|___getPageSize|imageBtnNext|scrollTop|_disable_keyboard_navigation|___pause|intDiffW|push|intCurrentHeight|intCurrentWidth|imageLoading|_resize_container_image_box|_set_interface|onload|visibility|select|object|top|embed|fadeIn|imageBtnClose|_start|scrollLeft|pageYOffset|_initialize|arrayPageSize|btnClose|jQuery|offsetHeight|scrollHeight|innerWidth||scrollMaxY|link|remove|objPrev|objNext|keyToNext|keyCode|keyToPrev|overlayOpacity|null|_keyboard_action|keyToClose|_enable_keyboard_navigation|right|hover|while|txtOf|html|arrayPageScroll|_preload_neighbor_images|txtImage|_set_navigation|_show_image_data|title|Date|date|_show_image|intDiffH|containerResizeSpeed|overlayBgColor|ms|attr|hidden|blank|resize|extend|close|opacity|backgroundColor|next|pageXOffset|fn|offsetWidth|scrollWidth|prev|scrollMaxX|visible|fadeOut|toLowerCase|style|fromCharCode|String|DOM_VK_ESCAPE|event|keydown|append|of|ico|000|fast|for||slideDown||100|250|msie|400|browser|animate|lightBox|do'.split('|'),0,{}))
\ No newline at end of file
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index 9a89653f89d118aaf3e2bef7d50922308f25ea81..acb4c6e192377a6a90a53244abf4e5a051b947b8 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -235,7 +235,7 @@ Discount=Discount
 Discounts=Discounts
 AddDiscount=Create discount
 AddRelativeDiscount=Create relative discount
-EditRelativelDiscount=Edit relatvie discount
+EditRelativeDiscount=Edit relative discount
 AddGlobalDiscount=Create absolute discount
 EditGlobalDiscounts=Edit absolute discounts
 AddCreditNote=Create credit note
diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang
index 570afcdabfbf832498102605dd09249c482ebc28..cc63582c5ab20b0e55658309172007e28752982f 100644
--- a/htdocs/langs/en_US/orders.lang
+++ b/htdocs/langs/en_US/orders.lang
@@ -21,7 +21,7 @@ CustomersOrders=Customer's orders
 CustomersOrdersRunning=Current customer's orders
 CustomersOrdersAndOrdersLines=Customer orders and order's lines
 OrdersToValid=Customer's orders to validate
-OrdersToBill=Customer's orders to bill
+OrdersToBill=Customer's orders delivered
 OrdersInProcess=Customer's orders in process
 OrdersToProcess=Customer's orders to process
 SuppliersOrdersToProcess=Supplier's orders to process
@@ -32,7 +32,7 @@ StatusOrderSentShort=In process
 StatusOrderSent=Shipment in process
 StatusOrderOnProcessShort=Reception
 StatusOrderProcessedShort=Processed
-StatusOrderToBillShort=To bill
+StatusOrderToBillShort=Delivered
 StatusOrderApprovedShort=Approved
 StatusOrderRefusedShort=Refused
 StatusOrderToProcessShort=To process
@@ -43,7 +43,7 @@ StatusOrderDraft=Draft (needs to be validated)
 StatusOrderValidated=Validated
 StatusOrderOnProcess=Waiting to receive
 StatusOrderProcessed=Processed
-StatusOrderToBill=To bill
+StatusOrderToBill=Delivered
 StatusOrderApproved=Approved
 StatusOrderRefused=Refused
 StatusOrderReceivedPartially=Partially received
@@ -51,7 +51,7 @@ StatusOrderReceivedAll=Everything received
 ShippingExist=A shipment exists
 DraftOrWaitingApproved=Draft or approved not yet ordered
 DraftOrWaitingShipped=Draft or validated not yet shipped
-MenuOrdersToBill=Orders to bill
+MenuOrdersToBill=Orders delivered
 SearchOrder=Search order
 Sending=Sending
 Sendings=Sendings
diff --git a/htdocs/langs/es_ES/commercial.lang b/htdocs/langs/es_ES/commercial.lang
index 8dbc91f6edbe59f976f8e83329e1cc946845d16f..acdac6fbba01f9473af9d071df2535d8c32a755c 100644
--- a/htdocs/langs/es_ES/commercial.lang
+++ b/htdocs/langs/es_ES/commercial.lang
@@ -24,6 +24,7 @@ TaskRDVWith=Cita con %s
 ShowTask=Ver tarea
 ShowAction=Ver evento
 ActionsReport=Informe de eventos
+ThirdPartiesOfSaleRepresentative=Terceros cuyo representante de ventas es
 SalesRepresentative=Comercial
 SalesRepresentatives=Comerciales
 SalesRepresentativeFollowUp=Comercial (seguimiento)
diff --git a/htdocs/langs/es_ES/members.lang b/htdocs/langs/es_ES/members.lang
index 8db3b80893cebaecd6a7f84929f4cc876cd548b9..6d98bc39f4a2508120ffb0eb0673130572eb0fe8 100644
--- a/htdocs/langs/es_ES/members.lang
+++ b/htdocs/langs/es_ES/members.lang
@@ -144,6 +144,7 @@ DescADHERENT_MAIL_RESIL_SUBJECT=Asunto de e-mail de baja
 DescADHERENT_MAIL_RESIL=E-mail de baja
 DescADHERENT_MAIL_FROM=E-mail emisor para los e-mails automáticos
 DescADHERENT_ETIQUETTE_TYPE=Formato páginas etiquetas
+DescADHERENT_ETIQUETTE_TEXT=Texto a imprimir en la dirección de las etiquetas de cada miembro
 DescADHERENT_CARD_TYPE=Formato páginas carné de miembro
 DescADHERENT_CARD_HEADER_TEXT=Texto a imprimir en la parte superior del carné de miembro
 DescADHERENT_CARD_TEXT=Texto a imprimir en el carné de miembro (Alineado a la izquierda)
diff --git a/htdocs/langs/fr_FR/orders.lang b/htdocs/langs/fr_FR/orders.lang
index cac2bcc278c7745f555a90dab2ecea2b6d93cc50..329afb01a8db7ecfc0b21a60993b3edf13da1dee 100644
--- a/htdocs/langs/fr_FR/orders.lang
+++ b/htdocs/langs/fr_FR/orders.lang
@@ -21,7 +21,7 @@ CustomersOrders=Commandes clients
 CustomersOrdersRunning=Commandes clients en cours
 CustomersOrdersAndOrdersLines=Commandes clients et lignes de commandes 
 OrdersToValid=Commandes clients à valider
-OrdersToBill=Commandes clients à facturer
+OrdersToBill=Commandes clients délivrées
 OrdersInProcess=Commandes clients en traitement
 OrdersToProcess=Commandes clients à traiter
 SuppliersOrdersToProcess=Commandes fournisseurs à traiter
@@ -32,7 +32,7 @@ StatusOrderOnProcessShort=Traitement en cours
 StatusOrderSentShort=Envoi en cours
 StatusOrderSent=Envoi en cours
 StatusOrderProcessedShort=Traitée
-StatusOrderToBillShort=À facturer
+StatusOrderToBillShort=Délivrée
 StatusOrderApprovedShort=Approuvée
 StatusOrderRefusedShort=Refusée
 StatusOrderToProcessShort=A traiter
@@ -43,7 +43,7 @@ StatusOrderDraft=Brouillon (à valider)
 StatusOrderValidated=Validée
 StatusOrderOnProcess=Attente réception
 StatusOrderProcessed=Traitée
-StatusOrderToBill=À facturer
+StatusOrderToBill=Délivrée
 StatusOrderApproved=Approuvée
 StatusOrderRefused=Refusée
 StatusOrderReceivedPartially=Reçu partiellement
@@ -52,7 +52,7 @@ ShippingExist=Une expédition existe
 DraftOrWaitingApproved=Brouillon ou approuvée pas encore commandée
 DraftOrWaitingShipped=Brouillon ou validée pas encore expédiée
 SearchOrder=Rechercher une commande
-MenuOrdersToBill=Commandes à facturer
+MenuOrdersToBill=Commandes délivrées
 Sending=Expédition
 Sendings=Expéditions
 ShipProduct=Expédier produit
diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php
index 0e219d07690096f01e92173c70eb04162e356507..9d56de642999fa0ae7d92e1d58f5a0d445f99596 100644
--- a/htdocs/livraison/class/livraison.class.php
+++ b/htdocs/livraison/class/livraison.class.php
@@ -408,7 +408,7 @@ class Livraison extends CommonObject
 
 									dol_syslog("Rename ok");
 									// Suppression ancien fichier PDF dans nouveau rep
-									dol_delete_file($dirdest.'/'.$oldref.'.*');
+									dol_delete_file($dirdest.'/'.$oldref.'*.*');
 								}
 							}
 						}
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index e45040779c4103cf9a97b1e148f7cad514e0cad8..19229f7a953851876caf8bcb7ed89155a167cb8e 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -876,7 +876,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
             else print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/css/'.$jquerytheme.'/jquery-ui-latest.custom.css" />'."\n";    // JQuery
             print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/tiptip/tipTip.css" />'."\n";                           // Tooltip
             print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/jnotify/jquery.jnotify-alt.min.css" />'."\n";          // JNotify
-            //print '<link rel="stylesheet" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/lightbox/css/jquery.lightbox-0.5.css" media="screen" />'."\n";       // Lightbox
             if (! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD))     // jQuery fileupload
             {
                 print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/css/jquery.fileupload-ui.css" />'."\n";
@@ -903,17 +902,22 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
         if (! empty($_SESSION['dol_resetcache'])) $themeparam.='&amp;dol_resetcache='.$_SESSION['dol_resetcache'];
         //print 'themepath='.$themepath.' themeparam='.$themeparam;exit;
         print '<link rel="stylesheet" type="text/css" title="default" href="'.$themepath.$themeparam.'">'."\n";
+
         // CSS forced by modules (relative url starting with /)
         if (isset($conf->modules_parts['css']))
         {
-        	$dircss=(array) $conf->modules_parts['css'];
-        	foreach($dircss as $key => $cssfile)
+        	$arraycss=(array) $conf->modules_parts['css'];
+        	foreach($arraycss as $modcss => $filescss)
         	{
-        		// cssfile is a relative path
-        		print '<link rel="stylesheet" type="text/css" title="default" href="'.dol_buildpath($cssfile,1);
-        		// We add params only if page is not static, because some web server setup does not return content type text/css if url has parameters, so browser cache is not used.
-        		if (!preg_match('/\.css$/i',$cssfile)) print $themeparam;
-        		print '"><!-- Added by module '.$key. '-->'."\n";
+        		$filescss=(array) $filescss;	// To be sure filecss is an array
+        		foreach($filescss as $cssfile)
+        		{
+	        		// cssfile is a relative path
+	        		print '<link rel="stylesheet" type="text/css" title="default" href="'.dol_buildpath($cssfile,1);
+	        		// We add params only if page is not static, because some web server setup does not return content type text/css if url has parameters, so browser cache is not used.
+	        		if (!preg_match('/\.css$/i',$cssfile)) print $themeparam;
+	        		print '"><!-- Added by module '.$modcss. '-->'."\n";
+        		}
         	}
         }
         // CSS forced by page in top_htmlhead call (relative url starting with /)
@@ -948,7 +952,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
             else print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-ui-latest.custom.min'.$ext.'"></script>'."\n";
             print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/tablednd/jquery.tablednd_0_5'.$ext.'"></script>'."\n";
             print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/tiptip/jquery.tipTip.min'.$ext.'"></script>'."\n";
-            //print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/lightbox/js/jquery.lightbox-0.5.min'.$ext.'"></script>'."\n";
             // jQuery Layout
             if (! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) || defined('REQUIRE_JQUERY_LAYOUT'))
             {
@@ -1044,12 +1047,19 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
             print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/datepicker.js.php?lang='.$langs->defaultlang.'"></script>'."\n";
 
             // JS forced by modules (relative url starting with /)
-            $dirjs=(array) $conf->modules_parts['js'];
-            foreach($dirjs as $key => $jsfile)
-            {
-            	// jsfile is a relative path
-            	print '<script type="text/javascript" src="'.dol_buildpath($jsfile,1).'"></script><!-- Added by module '.$key. '-->'."\n";
-            }
+            if (isset($conf->modules_parts['js']))		// $conf->modules_parts['js'] is array('module'=>array('file1','file2'))
+        	{
+        		$arrayjs=(array) $conf->modules_parts['js'];
+	            foreach($arrayjs as $modjs => $filesjs)
+	            {
+        			$filesjs=(array) $filesjs;	// To be sure filejs is an array
+		            foreach($filesjs as $jsfile)
+		            {
+	    	    		// jsfile is a relative path
+	        	    	print '<script type="text/javascript" src="'.dol_buildpath($jsfile,1).'"></script><!-- Added by module '.$modjs. '-->'."\n";
+		            }
+	            }
+        	}
             // JS forced by page in top_htmlhead (relative url starting with /)
             if (is_array($arrayofjs))
             {
diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php
index 617e477c0fde8bcd70c4eec09357c56c6566f5a2..37b48c7be00a61bc263730f4b2b846315fbc0d07 100755
--- a/htdocs/product/canvas/product/actions_card_product.class.php
+++ b/htdocs/product/canvas/product/actions_card_product.class.php
@@ -106,7 +106,7 @@ class ActionsCardProduct
 		$this->tpl['description'] = nl2br($this->description);
 
 		// Statut
-		$this->tpl['status'] = $this->getLibStatut(2);
+		$this->tpl['status'] = $this->object->getLibStatut(2);
 
 		// Note
 		$this->tpl['note'] = nl2br($this->note);
diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php
index d665e175c270a67e26ce0201a19793d36b2b2114..3e27cd968dc77c561e888478886c5dd9b38deee8 100755
--- a/htdocs/product/canvas/service/actions_card_service.class.php
+++ b/htdocs/product/canvas/service/actions_card_service.class.php
@@ -105,7 +105,7 @@ class ActionsCardService
 		$this->tpl['description'] = nl2br($this->description);
 
 		// Statut
-		$this->tpl['status'] = $this->getLibStatut(2);
+		$this->tpl['status'] = $this->object->getLibStatut(2);
 
 		// Note
 		$this->tpl['note'] = nl2br($this->note);
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index aff8a64e7fcd7fcd507f1b97ee854c459acee86a..cc671d254d0f4f7cc138c2c297ac3924892c90ae 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -2593,23 +2593,6 @@ class Product extends CommonObject
 		$pdirthumb = $pdir.'thumbs/';
 
 		$return ='<!-- Photo -->'."\n";
-        /*$return.="<script type=\"text/javascript\">
-        jQuery(function() {
-            jQuery('a.lightbox').lightBox({
-                overlayBgColor: '#888',
-                overlayOpacity: 0.6,
-                imageLoading: '".DOL_URL_ROOT."/theme/eldy/img/working.gif',
-                imageBtnClose: '".DOL_URL_ROOT."/theme/eldy/img/previous.png',
-                imageBtnPrev: '".DOL_URL_ROOT."/theme/eldy/img/1leftarrow.png',
-                imageBtnNext: '".DOL_URL_ROOT."/theme/eldy/img/1rightarrow.png',
-                containerResizeSpeed: 350,
-                txtImage: '".$langs->trans("Image")."',
-                txtOf: '".$langs->trans("on")."',
-                fixedNavigation:false
-            	});
-            });
-        </script>\n";
-        */
 		$nbphoto=0;
 
 		$dir_osencoded=dol_osencode($dir);
@@ -2647,7 +2630,7 @@ class Product extends CommonObject
     						if ($nbbyrow) $return.= '<td width="'.ceil(100/$nbbyrow).'%" class="photo">';
 
     						$return.= "\n";
-    						$return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="lightbox" target="_blank">';
+    						$return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">';
 
     						// Show image (width height=$maxHeight)
     						// Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine
diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php
index 2e0d8b6698429c3e34f2abd325212591c3aad3e2..68d2ced3d7e1334aaf4ba32c784c6aef7e416bbb 100644
--- a/htdocs/projet/tasks/time.php
+++ b/htdocs/projet/tasks/time.php
@@ -170,6 +170,7 @@ if (! empty($project_ref) && ! empty($withproject))
 llxHeader("",$langs->trans("Task"));
 
 $form = new Form($db);
+$userstatic = new User($db);
 
 if ($id > 0 || ! empty($ref))
 {
@@ -403,17 +404,17 @@ if ($id > 0 || ! empty($ref))
   		    print '</td>';
 
   		    // User
-			$user->id = $task_time->fk_user;
 			print '<td>';
 			if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid)
 			{
-				print $form->select_users($user->id,'userid_line');
+				print $form->select_users($task_time->fk_user,'userid_line');
 			}
 			else
 			{
-				$user->nom		= $task_time->name;
-				$user->prenom 	= $task_time->firstname;
-				print $user->getNomUrl(1);
+				$userstatic->id         = $task_time->fk_user;
+				$userstatic->nom		= $task_time->name;
+				$userstatic->prenom 	= $task_time->firstname;
+				print $userstatic->getNomUrl(1);
 			}
 		    print '</td>';