diff --git a/ChangeLog b/ChangeLog
index 40ef96fb5c1f7fc8f613322c00c43bd8c11ad97f..d264a72cd74d4e7f3c01b1455f18d831dfb93d77 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -114,6 +114,7 @@ Fix: [ bug #1240 ] traduction.
 Fix: [ bug #1238 ] When creating accompte with a %, free product are used for calculation.
 Fix: [ bug #1280 ] service with not end of date was tagged as expired.
 Fix: [ bug #1295 ] Error when creating an agenda extrafield with a number as reference
+New: Added es_CL language
 
 ***** ChangeLog for 3.5 compared to 3.4.* *****
 For users:
diff --git a/build/debian/changelog b/build/debian/changelog
index c4e31ec51c8715e37af9e5e5750650fcfe4ba349..eb2100922f4967e6503be3bac5f885e9d3a95572 100644
--- a/build/debian/changelog
+++ b/build/debian/changelog
@@ -5,6 +5,13 @@ dolibarr (3.6.0-1) unstable; urgency=low
     
  -- Laurent Destailleur (eldy) <eldy@users.sourceforge.net>  Sat, 8 Feb 2014 12:00:00 +0100      
 
+dolibarr (3.5.2-3) unstable; urgency=low
+
+  [ Laurent Destailleur (eldy) ]
+  * New upstream release.
+    
+ -- Laurent Destailleur (eldy) <eldy@users.sourceforge.net>  Fri, 14 March 2014 12:00:00 +0100     
+
 dolibarr (3.5.1-3) unstable; urgency=low
 
   [ Laurent Destailleur (eldy) ]
diff --git a/build/perl/virtualmin/dolibarr.pl b/build/perl/virtualmin/dolibarr.pl
index 31abc0138ee64ffe8cd85a007b21bcdc15f07648..c44481db736f576b46702e954a714be2d0a34334 100644
--- a/build/perl/virtualmin/dolibarr.pl
+++ b/build/perl/virtualmin/dolibarr.pl
@@ -30,7 +30,7 @@ return "Regis Houssin";
 # script_dolibarr_versions()
 sub script_dolibarr_versions
 {
-return ( "3.6.0", "3.5.1", "3.5.0", "3.4.1", "3.4.0", "3.3.3", "3.3.2", "3.3.1", "3.3.0", "3.2.1", "3.1.1" );
+return ( "3.6.0", "3.5.2", "3.5.1", "3.5.0", "3.4.1", "3.4.0", "3.3.3", "3.3.2", "3.3.1", "3.3.0", "3.2.1", "3.1.1" );
 }
 
 sub script_dolibarr_category
diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec
index 4cbf9c11171e4013136c5e04a7d13fc75a5ef377..94b2bb2ef7577ba7fe0e6e5ab14c205c0a27e166 100755
--- a/build/rpm/dolibarr_fedora.spec
+++ b/build/rpm/dolibarr_fedora.spec
@@ -334,5 +334,11 @@ fi
 * Fri Feb 7 2014 Laurent Destailleur 3.6.0-0.2.b
 - Upstream release
 
+* Fri Feb 14 2014 Laurent Destailleur 3.5.2-0.3
+- Upstream release
+
+* Fri Feb 7 2014 Laurent Destailleur 3.5.1-0.3
+- Upstream release
+
 * Mon Dec 30 2013 Laurent Destailleur 3.5.0-0.3
 - Initial version (#723326)
diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec
index d37a41390f07a8d5cf46b05c44e0e18ecaa0ec17..64efb3ffe92cdfaba59a85fdf845f6a547891a64 100755
--- a/build/rpm/dolibarr_generic.spec
+++ b/build/rpm/dolibarr_generic.spec
@@ -562,5 +562,11 @@ fi
 * Mon Feb 7 2014 Laurent Destailleur 3.6.0-0.2.b
 - Upstream release
 
+* Fri Feb 14 2014 Laurent Destailleur 3.5.2-0.3
+- Upstream release
+
+* Fri Feb 7 2014 Laurent Destailleur 3.5.1-0.3
+- Upstream release
+
 * Mon Dec 30 2013 Laurent Destailleur 3.5.0-0.3
 - Initial version (#723326)
diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec
index 0645eb55f4edf338116e6c5c75f57a4413e0f4a6..e000403715794b8ceac5a3208494ee47040cc378 100755
--- a/build/rpm/dolibarr_mandriva.spec
+++ b/build/rpm/dolibarr_mandriva.spec
@@ -339,5 +339,11 @@ fi
 * Mon Feb 7 2014 Laurent Destailleur 3.6.0-0.2.b
 - Upstream release
 
+* Fri Feb 14 2014 Laurent Destailleur 3.5.2-0.3
+- Upstream release
+
+* Fri Feb 7 2014 Laurent Destailleur 3.5.1-0.3
+- Upstream release
+
 * Mon Dec 30 2013 Laurent Destailleur 3.5.0-0.3
 - Initial version (#723326)
diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec
index 06feacf42c2fae933e09ebc52eb0f19359e9336a..d42c0bf8bc3d2f12c84df7f3edca3572dab6ec33 100755
--- a/build/rpm/dolibarr_opensuse.spec
+++ b/build/rpm/dolibarr_opensuse.spec
@@ -349,5 +349,11 @@ fi
 * Mon Feb 7 2014 Laurent Destailleur 3.6.0-0.2.b
 - Upstream release
 
+* Fri Feb 14 2014 Laurent Destailleur 3.5.2-0.3
+- Upstream release
+
+* Fri Feb 7 2014 Laurent Destailleur 3.5.1-0.3
+- Upstream release
+
 * Mon Dec 30 2013 Laurent Destailleur 3.5.0-0.3
 - Initial version (#723326)
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index a338f588073ee21e14435fc547de55fe39a37a60..25d032982a9c75dc16a391314054f089a755350d 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -484,14 +484,15 @@ else if ($action == 'confirm_canceled' && $confirm == 'yes') {
 }
 
 // Convertir en reduc
-else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->facture->creer) {
+else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->facture->creer)
+{
 	$db->begin();
 
 	$object->fetch($id);
 	$object->fetch_thirdparty();
 	$object->fetch_lines();
 
-	if (! $object->paye) 	// protection against multiple submit
+	if (empty($object->paye))	// protection against multiple submit
 	{
 		// Boucle sur chaque taux de tva
 		$i = 0;
@@ -509,8 +510,7 @@ else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->righ
 		elseif ($object->type == Facture::TYPE_DEPOSIT)
 			$discount->description = '(DEPOSIT)';
 		else {
-			$this->error = "CantConvertToReducAnInvoiceOfThisType";
-			return - 1;
+			setEventMessage($langs->trans('CantConvertToReducAnInvoiceOfThisType'),'errors');
 		}
 		$discount->tva_tx = abs($object->total_ttc);
 		$discount->fk_soc = $object->socid;
@@ -524,24 +524,31 @@ else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->righ
 			$discount->tva_tx = abs($tva_tx);
 
 			$result = $discount->create($user);
-			if ($result < 0) {
-				$error ++;
+			if ($result < 0)
+			{
+				$error++;
 				break;
 			}
 		}
 
-		if (! $error) {
+		if (empty($error))
+		{
 			// Classe facture
 			$result = $object->set_paid($user);
-			if ($result > 0) {
-				// $mesgs[]='OK'.$discount->id;
+			if ($result >= 0)
+			{
+				//$mesgs[]='OK'.$discount->id;
 				$db->commit();
-			} else {
-				$mesgs [] = '<div class="error">' . $object->error . '</div>';
+			}
+			else
+			{
+				setEventMessage($object->error,'errors');
 				$db->rollback();
 			}
-		} else {
-			$mesgs [] = '<div class="error">' . $discount->error . '</div>';
+		}
+		else
+		{
+			setEventMessage($discount->error,'errors');
 			$db->rollback();
 		}
 	}
@@ -644,14 +651,14 @@ else if ($action == 'add' && $user->rights->facture->creer) {
 			$id = $object->create($user);
 
 			if(GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) {
-			    
+
                 $facture_source = new Facture($db); // fetch origin object
                 if($facture_source->fetch($object->fk_facture_source)>0) {
-                
+
                     foreach($facture_source->lines as $line) {
-                      
-                        $line->fk_facture = $object->id;  
-                        
+
+                        $line->fk_facture = $object->id;
+
                         $line->subprice =-$line->subprice; // invert price for object
                         $line->pa_ht = -$line->pa_ht;
                         $line->total_ht=-$line->total_ht;
@@ -659,33 +666,33 @@ else if ($action == 'add' && $user->rights->facture->creer) {
                         $line->total_ttc=-$line->total_ttc;
                         $line->total_localtax1=-$line->total_localtax1;
                         $line->total_localtax2=-$line->total_localtax2;
-                        
+
                         $line->insert();
-                        
+
                         $object->lines[] = $line; // insert new line in current object
                     }
-                 
-                    $object->update_price(1);   
+
+                    $object->update_price(1);
                 }
-                 
+
 			}
-            
+
             if(GETPOST('invoiceAvoirWithPaymentRestAmount', 'int')==1 && $id>0) {
-                    
+
                 $facture_source = new Facture($db); // fetch origin object if not previously defined
                 if($facture_source->fetch($object->fk_facture_source)>0) {
                     $totalpaye = $facture_source->getSommePaiement();
                     $totalcreditnotes = $facture_source->getSumCreditNotesUsed();
                     $totaldeposits = $facture_source->getSumDepositsUsed();
                     $remain_to_pay = abs($facture_source->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits);
-                    
-                    $object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'),$remain_to_pay,1,0,0,0,0,0,'','','TTC');      
+
+                    $object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'),$remain_to_pay,1,0,0,0,0,0,'','','TTC');
                 }
             }
-            
+
 			// Add predefined lines
 			/*
-             TODO delete 
+             TODO delete
              for($i = 1; $i <= $NBLINES; $i ++) {
 				if ($_POST ['idprod' . $i]) {
 					$product = new Product($db);
@@ -2070,10 +2077,10 @@ if ($action == 'create')
 		$text .= '</select>';
 		$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1);
 		print $desc;
-        
+
         print '&nbsp;&nbsp;&nbsp; <input type="checkbox" name="invoiceAvoirWithLines" id="invoiceAvoirWithLines" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').attr(\'checked\',\'checked\'); $(\'#invoiceAvoirWithPaymentRestAmount\').removeAttr(\'checked\');   }" '.(GETPOST('invoiceAvoirWithLines','int')>0 ? 'checked="checked"':'').' /> <label for="invoiceAvoirWithLines">'.$langs->trans('invoiceAvoirWithLines')."</label>";
         print '<br />&nbsp;&nbsp;&nbsp; <input type="checkbox" name="invoiceAvoirWithPaymentRestAmount" id="invoiceAvoirWithPaymentRestAmount" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').attr(\'checked\',\'checked\');  $(\'#invoiceAvoirWithLines\').removeAttr(\'checked\');   }" '.(GETPOST('invoiceAvoirWithPaymentRestAmount','int')>0 ? 'checked="checked"':'').' /> <label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans('invoiceAvoirWithPaymentRestAmount')."</label>";
-        
+
 		print '</td></tr>' . "\n";
 	}
 
@@ -3340,7 +3347,7 @@ if ($action == 'create')
 					print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER ["PHP_SELF"] . '?facid=' . $object->id . '&amp;action=converttoreduc">' . $langs->trans('ConvertToReduc') . '</a></div>';
 				}
 				// For deposit invoice
-				if ($object->type == Facture::TYPE_DEPOSIT && $object->statut == 1 && $resteapayer == 0 && $user->rights->facture->creer) {
+				if ($object->type == Facture::TYPE_DEPOSIT && $object->statut == 2 && $resteapayer == 0 && $user->rights->facture->creer && empty($discount->id)) {
 					print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER ["PHP_SELF"] . '?facid=' . $object->id . '&amp;action=converttoreduc">' . $langs->trans('ConvertToReduc') . '</a></div>';
 				}
 			}
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 81794f24c552815229d4367c4e7e0f9bcf6e2467..babf0257d7c6db6eb8a654fb48c96e6e28854208 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -1472,7 +1472,8 @@ class Facture extends CommonInvoice
 	}
 
 	/**
-	 *  Tag la facture comme paye completement (close_code non renseigne) ou partiellement (close_code renseigne) + appel trigger BILL_PAYED
+	 *  Tag la facture comme paye completement (si close_code non renseigne) => this->fk_statut=2, this->paye=1
+	 *  ou partiellement (si close_code renseigne) + appel trigger BILL_PAYED => this->fk_statut=2, this->paye stay 0
 	 *
 	 *  @param	User	$user      	Objet utilisateur qui modifie
 	 *	@param  string	$close_code	Code renseigne si on classe a payee completement alors que paiement incomplet (cas escompte par exemple)
@@ -1496,6 +1497,7 @@ class Facture extends CommonInvoice
 			if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'";
 			$sql.= ' WHERE rowid = '.$this->id;
 
+			dol_syslog(get_class($this)."::set_paid sql=".$sql, LOG_DEBUG);
 			$resql = $this->db->query($sql);
 			if ($resql)
 			{
@@ -1511,8 +1513,7 @@ class Facture extends CommonInvoice
 			else
 			{
 				$error++;
-				$this->error=$this->db->error();
-				dol_print_error($this->db);
+				$this->error=$this->db->lasterror();
 			}
 
 			if (! $error)
@@ -2075,7 +2076,7 @@ class Facture extends CommonInvoice
 				$product=new Product($this->db);
 				$result=$product->fetch($fk_product);
 				$product_type=$product->type;
-				
+
 				if($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE && $product_type == 0 && $product->stock_reel < $qty) {
 					$this->error=$langs->trans('ErrorStockIsNotEnough');
 					$this->db->rollback();
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index 1319ad766d0f67e5b4d726289444629550ad9d3d..5317d49c23cad8c84900a0be4e44b6315fb315e4 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -764,8 +764,9 @@ class FormFile
 					if (empty($relativepath))
 					{
 						$relativepath=(! empty($object->ref)?dol_sanitizeFileName($object->ref):'').'/';
-						if ($object->element == 'invoice_supplier') $relativepath=get_exdir($object->id,2).$relativepath;
-						if ($object->element == 'member') $relativepath=get_exdir($object->id,2).$relativepath;
+						if ($object->element == 'invoice_supplier') $relativepath=get_exdir($object->id,2).$relativepath;	// TODO Call using a defined value for $relativepath
+						if ($object->element == 'member') $relativepath=get_exdir($object->id,2).$relativepath;				// TODO Call using a defined value for $relativepath
+						if ($object->element == 'project_task') $relativepath='Call_not_supported_._Call_function_using_a_defined_relative_path_.';
 					}
 
 					$var=!$var;
@@ -1052,9 +1053,10 @@ class FormFile
      * @param 	int			$permtodelete	Deletion is allowed
      * @param 	string		$action			Action
      * @param 	string		$selected		???
+     * @param	string		$param			More param to add into URL
      * @return 	int							Number of links
      */
-    public function listOfLinks($object, $permtodelete=1, $action=null, $selected=null)
+    public function listOfLinks($object, $permtodelete=1, $action=null, $selected=null, $param='')
     {
         global $user, $conf, $langs, $user;
         global $bc;
@@ -1071,17 +1073,17 @@ class FormFile
             $sortfield = null;
         }
         $res = $link->fetchAll($links, $object->element, $object->id, $sortfield, $sortorder);
-        $param = (isset($object->id)?'&id=' . $object->id : '');
+        $param .= (isset($object->id)?'&id=' . $object->id : '');
 
         // Show list of associated links
         print_titre($langs->trans("LinkedFiles"));
 
-        print '<form action="' . $_SERVER['PHP_SELF'] . '" method="POST">';
+        print '<form action="' . $_SERVER['PHP_SELF'] . ($param?'?'.$param:'') . '" method="POST">';
 
         print '<table width="100%" class="liste">';
         print '<tr class="liste_titre">';
         print_liste_field_titre(
-            $langs->trans("Documents2"),
+            $langs->trans("Links"),
             $_SERVER['PHP_SELF'],
             "name",
             "",
@@ -1135,34 +1137,34 @@ class FormFile
                 print '<input type="hidden" name="action" value="confirm_updateline">';
                 print $langs->trans('Link') . ': <input type="text" name="link" size="50" value="' . $link->url . '">';
                 print '</td>';
-                print '<td align="right">';
+                print '<td>';
                 print $langs->trans('Label') . ': <input type="text" name="label" value="' . $link->label . '">';
                 print '</td>';
                 print '<td align="center">' . dol_print_date(dol_now(), "dayhour", "tzuser") . '</td>';
                 print '<td align="right"></td>';
-                print '<td align="right" colspan="2"><input type="submit" name="save" class="button" value="' . $langs->trans('Save') . '">';
-                print '<input type="submit" name="cancel" class="button" value="' . $langs->trans('Cancel') . '">';
+                print '<td align="right" colspan="2">';
+                print '<input type="submit" name="save" class="button" value="' . dol_escape_htmltag($langs->trans('Save')) . '">';
+                print '<input type="submit" name="cancel" class="button" value="' . dol_escape_htmltag($langs->trans('Cancel')) . '">';
                 print '</td>';
             }
-            else {
+            else
+			{
                 print '<td>';
-                print '<a data-ajax="false" href="'. $link->url . '" target="_blank">';
+                print '<a data-ajax="false" href="' . $link->url . '" target="_blank">';
                 print $link->label;
                 print '</a>';
-                print "</td>\n";
+                print '</td>'."\n";
                 print '<td align="right"></td>';
                 print '<td align="center">' . dol_print_date($link->datea, "dayhour", "tzuser") . '</td>';
                 print '<td align="center"></td>';
                 print '<td align="right" colspan="2">';
-                print '<a href="' . $_SERVER['PHP_SELF'] . '?action=update&linkid=' . $link->id
-                        . '&id=' . $object->id . '" class="editfilelink" >' . img_edit().'</a>';
+                print '<a href="' . $_SERVER['PHP_SELF'] . '?action=update&linkid=' . $link->id . $param . '" class="editfilelink" >' . img_edit() . '</a>';	// id= is included into $param
                 if ($permtodelete) {
-                    print ' &nbsp; <a href="'. $_SERVER['PHP_SELF'] .'?action=delete&linkid=' . $link->id
-                            . '&id=' . $object->id . '" class="deletefilelink" >' . img_delete() . '</a>';
+                    print ' &nbsp; <a href="'. $_SERVER['PHP_SELF'] .'?action=delete&linkid=' . $link->id . $param . '" class="deletefilelink">' . img_delete() . '</a>';	// id= is included into $param
                 } else {
                     print '&nbsp;';
                 }
-                print "</td>";
+                print '</td>';
             }
             print "</tr>\n";
         }
diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
index af0cb03b68f069320de6c6befe6a9cf9a7425873..a1b8852860fc31cad5a5692e203f96095b93fb7d 100644
--- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
@@ -1,5 +1,5 @@
 <?php
-/* Copyright (C) 2004-2013	Laurent Destailleur	<eldy@users.sourceforge.net>
+/* Copyright (C) 2004-2014	Laurent Destailleur	<eldy@users.sourceforge.net>
  * Copyright (C) 2005-2012	Regis Houssin		<regis.houssin@capnetworks.com>
  * Copyright (C) 2008		Raphael Bertrand	<raphael.bertrand@resultic.fr>
  * Copyright (C) 2010-2013	Juanjo Menent		<jmenent@2byte.es>
@@ -109,7 +109,7 @@ class pdf_einstein extends ModelePDFCommandes
 		$this->posxdiscount=162;
 		$this->postotalht=174;
 		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
-		$this->posxpicture=$this->posxtva - 16;	// width of images
+		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?16:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
 		if ($this->page_largeur < 210) // To work with US executive format
 		{
 			$this->posxpicture-=20;
@@ -153,7 +153,7 @@ class pdf_einstein extends ModelePDFCommandes
 		$outputlangs->load("products");
 		$outputlangs->load("orders");
 		$outputlangs->load("deliveries");
-		
+
 		if ($conf->commande->dir_output)
 		{
             $object->fetch_thirdparty();
@@ -228,6 +228,15 @@ class pdf_einstein extends ModelePDFCommandes
 						$this->atleastonediscount++;
 					}
 				}
+				if (empty($this->atleastonediscount))
+				{
+					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
+					$this->posxtva+=($this->postotalht - $this->posxdiscount);
+					$this->posxup+=($this->postotalht - $this->posxdiscount);
+					$this->posxqty+=($this->postotalht - $this->posxdiscount);
+					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
+					//$this->postotalht;
+				}
 
 				// New page
 				$pdf->AddPage();
@@ -316,7 +325,7 @@ class pdf_einstein extends ModelePDFCommandes
 								$pdf->AddPage('','',true);
 								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-								$pdf->setPage($pagenb+1);
+								$pdf->setPage($pageposafter+1);
 							}
 						}
 						else
@@ -412,6 +421,7 @@ class pdf_einstein extends ModelePDFCommandes
 					// Add line
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
 					{
+						$pdf->setPage($pageposafter);
 						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
 						//$pdf->SetDrawColor(190,190,200);
 						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
@@ -601,7 +611,7 @@ class pdf_einstein extends ModelePDFCommandes
             $pdf->SetFont('','B', $default_font_size - 2);
             $text=$outputlangs->transnoentities("DeliveryDate").':';
             $pdf->MultiCell(80, 3, $text, 0, 'L', 0);
-            
+
 			$pdf->SetFont('','', $default_font_size - 2);
 			$pdf->SetXY($posxval, $posy);
             $text=dol_print_date($object->date_livraison,'day','',$outputlangs);
diff --git a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php
index 9733b30ded67d7a6035d41fa5bdca2cdd6cf6767..7ea8ebb2e557b49fd9f2c1a8f512f5abca6e26ce 100644
--- a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php
@@ -1,5 +1,5 @@
 <?php
-/* Copyright (C) 2004-2013	Laurent Destailleur	<eldy@users.sourceforge.net>
+/* Copyright (C) 2004-2014	Laurent Destailleur	<eldy@users.sourceforge.net>
  * Copyright (C) 2005-2012	Regis Houssin		<regis.houssin@capnetworks.com>
  * Copyright (C) 2008		Raphael Bertrand	<raphael.bertrand@resultic.fr>
  * Copyright (C) 2010-2013	Juanjo Menent		<jmenent@2byte.es>
@@ -109,7 +109,7 @@ class pdf_proforma extends ModelePDFCommandes
 		$this->posxdiscount=162;
 		$this->postotalht=174;
 		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
-		$this->posxpicture=$this->posxtva - 16;	// width of images
+		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?16:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
 		if ($this->page_largeur < 210) // To work with US executive format
 		{
 			$this->posxpicture-=20;
@@ -227,6 +227,15 @@ class pdf_proforma extends ModelePDFCommandes
 						$this->atleastonediscount++;
 					}
 				}
+				if (empty($this->atleastonediscount))
+				{
+					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
+					$this->posxtva+=($this->postotalht - $this->posxdiscount);
+					$this->posxup+=($this->postotalht - $this->posxdiscount);
+					$this->posxqty+=($this->postotalht - $this->posxdiscount);
+					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
+					//$this->postotalht;
+				}
 
 				// New page
 				$pdf->AddPage();
@@ -315,7 +324,7 @@ class pdf_proforma extends ModelePDFCommandes
 								$pdf->AddPage('','',true);
 								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-								$pdf->setPage($pagenb+1);
+								$pdf->setPage($pageposafter+1);
 							}
 						}
 						else
@@ -411,6 +420,7 @@ class pdf_proforma extends ModelePDFCommandes
 					// Add line
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
 					{
+						$pdf->setPage($pageposafter);
 						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
 						//$pdf->SetDrawColor(190,190,200);
 						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php
index 6976754285a10f67f02c406db81b2bc098d9ad09..353b77ffaf791a21263ee3e015709b7e1daf815a 100644
--- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php
+++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php
@@ -116,15 +116,24 @@ class pdf_strato extends ModelePDFContract
 		$outputlangs->load("dict");
 		$outputlangs->load("companies");
 		$outputlangs->load("contracts");
+		$outputlangs->load("interventions");
 
 		if ($conf->contrat->dir_output)
 		{
             $object->fetch_thirdparty();
 
-			$objectref = dol_sanitizeFileName($object->ref);
-			$dir = $conf->contrat->dir_output;
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
-			$file = $dir . "/" . $objectref . ".pdf";
+			// Definition of $dir and $file
+			if ($object->specimen)
+			{
+				$dir = $conf->contrat->dir_output;
+				$file = $dir . "/SPECIMEN.pdf";
+			}
+			else
+			{
+				$objectref = dol_sanitizeFileName($object->ref);
+				$dir = $conf->contrat->dir_output . "/" . $objectref;
+				$file = $dir . "/" . $objectref . ".pdf";
+			}
 
 			if (! file_exists($dir))
 			{
diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php
index c5662089e9e2b4c3f5f7625361aba55eecec62e0..dafff8b81ea0bc7f0ff52b465db7d9f08fef528b 100644
--- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php
@@ -267,6 +267,7 @@ class pdf_merou extends ModelePdfExpedition
 					// Add line
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
 					{
+						$pdf->setPage($pageposafter);
 						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
 						//$pdf->SetDrawColor(190,190,200);
 						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
@@ -474,7 +475,7 @@ class pdf_merou extends ModelePdfExpedition
 		else
 		{
 			$text=$this->emetteur->name;
-			$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($text), 0, 'L');
+			$pdf->MultiCell(70, 3, $outputlangs->convToOutputCharset($text), 0, 'L');
 		}
 
 		//*********************Entete****************************
diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
index 4394c3200f5a9e46f80830c3674e9cb97cb042a5..d924da16785b70c523d5bf1cec6fae5ecc8c0e6d 100644
--- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
@@ -240,7 +240,7 @@ class pdf_rouget extends ModelePdfExpedition
 					$pageposbefore=$pdf->getPage();
 
 					// Description de la ligne produit
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,150,3,$this->posxdesc,$curY,0,1);
+					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxqtyordered-10,3,$this->posxdesc,$curY,0,1);
 
 					$nexY = $pdf->GetY();
 					$pageposafter=$pdf->getPage();
@@ -264,6 +264,7 @@ class pdf_rouget extends ModelePdfExpedition
 					// Add line
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
 					{
+						$pdf->setPage($pageposafter);
 						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
 						//$pdf->SetDrawColor(190,190,200);
 						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index ebbe4727cfeea00dc6100317dd2309ddbc729673..eecf69eed8dc6181f0297d435e57ad35bb99c45d 100644
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -1,5 +1,5 @@
 <?php
-/* Copyright (C) 2004-2013	Laurent Destailleur	<eldy@users.sourceforge.net>
+/* Copyright (C) 2004-2014	Laurent Destailleur	<eldy@users.sourceforge.net>
  * Copyright (C) 2005-2012	Regis Houssin		<regis.houssin@capnetworks.com>
  * Copyright (C) 2008		Raphael Bertrand	<raphael.bertrand@resultic.fr>
  * Copyright (C) 2010-2013	Juanjo Menent		<jmenent@2byte.es>
@@ -109,7 +109,7 @@ class pdf_crabe extends ModelePDFFactures
 		$this->posxdiscount=162;
 		$this->postotalht=174;
 		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
-		$this->posxpicture=$this->posxtva - 16;	// width of images
+		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?16:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
 		if ($this->page_largeur < 210) // To work with US executive format
 		{
 			$this->posxpicture-=20;
@@ -228,6 +228,15 @@ class pdf_crabe extends ModelePDFFactures
 						$this->atleastonediscount++;
 					}
 				}
+				if (empty($this->atleastonediscount))
+				{
+					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
+					$this->posxtva+=($this->postotalht - $this->posxdiscount);
+					$this->posxup+=($this->postotalht - $this->posxdiscount);
+					$this->posxqty+=($this->postotalht - $this->posxdiscount);
+					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
+					//$this->postotalht;
+				}
 
 				// New page
 				$pdf->AddPage();
@@ -318,7 +327,7 @@ class pdf_crabe extends ModelePDFFactures
 								$pdf->AddPage('','',true);
 								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-								$pdf->setPage($pagenb+1);
+								$pdf->setPage($pageposafter+1);
 							}
 						}
 						else
@@ -413,6 +422,7 @@ class pdf_crabe extends ModelePDFFactures
 					// Add line
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
 					{
+						$pdf->setPage($pageposafter);
 						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
 						//$pdf->SetDrawColor(190,190,200);
 						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php
index 0162792974c4ce4f9451de79adb0c086380fb78d..23357f7491b0e28c19011289e969eab598d49995 100644
--- a/htdocs/core/modules/import/import_csv.modules.php
+++ b/htdocs/core/modules/import/import_csv.modules.php
@@ -250,7 +250,7 @@ class ImportCsv extends ModeleImports
 	/**
 	 * 	Return array of next record in input file.
 	 *
-	 * 	@return		Array		Array of field values. Data are UTF8 encoded. [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string)
+	 * 	@return		Array		Array of field values. Data are UTF8 encoded. [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=not empty string)
 	 */
 	function import_read_record()
 	{
@@ -403,7 +403,7 @@ class ImportCsv extends ModeleImports
 					{
 						// Set $newval with value to insert and set $listvalues with sql request part for insert
 						$newval='';
-						if ($arrayrecord[($key-1)]['type'] > 0) $newval=$arrayrecord[($key-1)]['val'];    // If type of field is not null or '' but string
+						if ($arrayrecord[($key-1)]['type'] > 0) $newval=$arrayrecord[($key-1)]['val'];    // If type of field into input file is not empty string (so defined into input file), we get value
 
 						// Make some tests on $newval
 
@@ -463,37 +463,41 @@ class ImportCsv extends ModeleImports
                                 }
                                 elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomercodeifnull')
                                 {
-                                    if (empty($newval) || $newval=='auto')
+                                    if (empty($newval) || strtolower($newval) == 'auto')
                                     {
                                         $this->thirpartyobject->get_codeclient(0,0);
                                         $newval=$this->thirpartyobject->code_client;
+                                        if (empty($newval)) $arrayrecord[($key-1)]['type']=-1;	// If we get empty value, we will use "null"
                                         //print 'code_client='.$newval;
                                     }
                                 }
                                 elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsuppliercodeifnull')
                                 {
-                                    if (empty($newval) || $newval=='auto')
+                                    if (empty($newval) || strtolower($newval) == 'auto')
                                     {
                                         $newval=$this->thirpartyobject->get_codefournisseur(0,1);
                                         $newval=$this->thirpartyobject->code_fournisseur;
+                                        if (empty($newval)) $arrayrecord[($key-1)]['type']=-1;	// If we get empty value, we will use "null"
                                         //print 'code_fournisseur='.$newval;
                                     }
                                 }
                                 elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomeraccountancycodeifnull')
                                 {
-                                    if (empty($newval) || $newval=='auto')
+                                    if (empty($newval) || strtolower($newval) == 'auto')
                                     {
                                         $this->thirpartyobject->get_codecompta('customer');
                                         $newval=$this->thirpartyobject->code_compta;
+                                        if (empty($newval)) $arrayrecord[($key-1)]['type']=-1;	// If we get empty value, we will use "null"
                                         //print 'code_compta='.$newval;
                                     }
                                 }
                                 elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsupplieraccountancycodeifnull')
                                 {
-                                    if (empty($newval) || $newval=='auto')
+                                    if (empty($newval) || strtolower($newval) == 'auto')
                                     {
                                         $this->thirpartyobject->get_codecompta('supplier');
                                         $newval=$this->thirpartyobject->code_compta_fournisseur;
+                                        if (empty($newval)) $arrayrecord[($key-1)]['type']=-1;	// If we get empty value, we will use "null"
                                         //print 'code_compta_fournisseur='.$newval;
                                     }
                                 }
@@ -560,6 +564,7 @@ class ImportCsv extends ModeleImports
 						if ($listfields) { $listfields.=', '; $listvalues.=', '; }
 						$listfields.=$fieldname;
 
+						// Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert
 						if (empty($newval) && $arrayrecord[($key-1)]['type'] < 0)       $listvalues.=($newval=='0'?$newval:"null");
 						elseif (empty($newval) && $arrayrecord[($key-1)]['type'] == 0) $listvalues.="''";
 						else															 $listvalues.="'".$this->db->escape($newval)."'";
@@ -664,4 +669,5 @@ function cleansep($value)
 	return str_replace(array(',',';'),'/',$value);
 };
 
-?>
+
+?>
\ No newline at end of file
diff --git a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php
index bdb35d67fbe7649a0d329972db4acad5dcfa1b90..b9d61ec10490a915c5be9414fb3368423a5e040b 100644
--- a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php
+++ b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php
@@ -1,5 +1,5 @@
 <?php
-/* Copyright (C) 2004-2008 Laurent Destailleur   <eldy@users.sourceforge.net>
+/* Copyright (C) 2004-2014 Laurent Destailleur   <eldy@users.sourceforge.net>
  * Copyright (C) 2005-2009 Regis Houssin         <regis.houssin@capnetworks.com>
  * Copyright (C) 2007      Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
  * Copyright (C) 2008      Chiptronik
@@ -223,15 +223,24 @@ class pdf_typhon extends ModelePDFDeliveryOrder
 				$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 < $nblines ; $i++)
-				 {
-				 if ($object->lines[$i]->remise_percent)
-				 {
-				 $this->atleastonediscount++;
-				 }
-				 }
-				 */
+				// Positionne $this->atleastonediscount si on a au moins une remise
+				for ($i = 0 ; $i < $nblines ; $i++)
+				{
+				 	if ($object->lines[$i]->remise_percent)
+				 	{
+				 		$this->atleastonediscount++;
+				 	}
+				}
+ 				if (empty($this->atleastonediscount))
+				{
+					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
+					$this->posxtva+=($this->postotalht - $this->posxdiscount);
+					$this->posxup+=($this->postotalht - $this->posxdiscount);
+					$this->posxqty+=($this->postotalht - $this->posxdiscount);
+					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
+					//$this->postotalht;
+				}
+				*/
 
 				// New page
 				$pdf->AddPage();
@@ -307,7 +316,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
                     			$pdf->AddPage('','',true);
                     			if (! empty($tplidx)) $pdf->useTemplate($tplidx);
                     			if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-                    			$pdf->setPage($pagenb+1);
+                    			$pdf->setPage($pageposafter+1);
                     		}
                     	}
                     	else
@@ -370,6 +379,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
 					// Add line
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
 					{
+						$pdf->setPage($pageposafter);
 						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
 						//$pdf->SetDrawColor(190,190,200);
 						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
diff --git a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php
index cca049cba920c0d88e9d6d9f8d2767eb36ec8088..881b112688ecb9e2ab3e403a5d779a6c1f2b2714 100644
--- a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php
+++ b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php
@@ -222,12 +222,15 @@ class pdf_baleine extends ModelePDFProjects
 					$pdf->MultiCell(20, 3, $dateend, 0, 'L');
 
 
+					$pageposafter=$pdf->getPage();
+
 					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
 					$nexY = $pdf->GetY();
 
 					// Add line
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
 					{
+						$pdf->setPage($pageposafter);
 						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
 						//$pdf->SetDrawColor(190,190,200);
 						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
index 700e558668eccd98af9eb12334dafaf04c34eee7..af073ddc1ca37cc72b4dd82299739ab486364ba0 100644
--- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
@@ -254,6 +254,15 @@ class pdf_azur extends ModelePDFPropales
 						$this->atleastonediscount++;
 					}
 				}
+				if (empty($this->atleastonediscount))
+				{
+					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
+					$this->posxtva+=($this->postotalht - $this->posxdiscount);
+					$this->posxup+=($this->postotalht - $this->posxdiscount);
+					$this->posxqty+=($this->postotalht - $this->posxdiscount);
+					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
+					//$this->postotalht;
+				}
 
 				// New page
 				$pdf->AddPage();
@@ -332,7 +341,7 @@ class pdf_azur extends ModelePDFPropales
 						$pdf->AddPage('','',true);
 						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-						$pdf->setPage($pagenb+1);
+						$pdf->setPage($pageposbefore+1);
 
 						$curY = $tab_top_newpage;
 						$showpricebeforepagebreak=0;
@@ -370,7 +379,7 @@ class pdf_azur extends ModelePDFPropales
 								$pdf->AddPage('','',true);
 								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-								$pdf->setPage($pagenb+1);
+								$pdf->setPage($pageposafter+1);
 							}
 						}
 						else
@@ -387,6 +396,7 @@ class pdf_azur extends ModelePDFPropales
 
 					$nexY = $pdf->GetY();
 					$pageposafter=$pdf->getPage();
+
 					$pdf->setPage($pageposbefore);
 					$pdf->setTopMargin($this->marge_haute);
 					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
@@ -468,6 +478,7 @@ class pdf_azur extends ModelePDFPropales
 					// Add line
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
 					{
+						$pdf->setPage($pageposafter);
 						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
 						//$pdf->SetDrawColor(190,190,200);
 						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
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 34c031734f1a7fc777489a993c38caef61bf166f..b6ed22e3c37c17a419ab3583796630ec8255766d 100644
--- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
+++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2010-2011      Juanjo Menent        <jmenent@2byte.es>
- * Copyright (C) 2010-2012 		Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2010-2014 		Laurent Destailleur  <eldy@users.sourceforge.net>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -58,7 +58,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 	 *	Constructor
 	 *
 	 *  @param	DoliDB		$db     	Database handler
-	 *  @param	Societe		$object		Supplier invoice
+	 *  @param	Object		$object		Supplier invoice
 	 */
 	function __construct($db,$object)
 	{
@@ -105,7 +105,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 		$this->posxdiscount=162;
 		$this->postotalht=174;
 		//if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
-		$this->posxpicture=$this->posxtva - 16;	// width of images
+		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?16:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
 		if ($this->page_largeur < 210) // To work with US executive format
 		{
 			$this->posxpicture-=20;
@@ -227,6 +227,15 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
                         $this->atleastonediscount++;
                     }
                 }
+				if (empty($this->atleastonediscount))
+				{
+					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
+					$this->posxtva+=($this->postotalht - $this->posxdiscount);
+					$this->posxup+=($this->postotalht - $this->posxdiscount);
+					$this->posxqty+=($this->postotalht - $this->posxdiscount);
+					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
+					//$this->postotalht;
+				}
 
                 // New page
 				$pdf->AddPage();
@@ -281,7 +290,39 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 
 					// Description of product line
 					$curX = $this->posxdesc-1;
-                    pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1);
+					$showpricebeforepagebreak=1;
+
+					$pdf->startTransaction();
+					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1);
+					$pageposafter=$pdf->getPage();
+					if ($pageposafter > $pageposbefore)	// There is a pagebreak
+					{
+						$pdf->rollbackTransaction(true);
+						$pageposafter=$pageposbefore;
+						//print $pageposafter.'-'.$pageposbefore;exit;
+						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
+						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc);
+						$posyafter=$pdf->GetY();
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
+						{
+							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
+							{
+								$pdf->AddPage('','',true);
+								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+								$pdf->setPage($pageposafter+1);
+							}
+						}
+						else
+						{
+							// We found a page break
+							$showpricebeforepagebreak=0;
+						}
+					}
+					else	// No pagebreak
+					{
+						$pdf->commitTransaction();
+					}
 
 					$nexY = $pdf->GetY();
                     $pageposafter=$pdf->getPage();
@@ -290,7 +331,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
 
 					// We suppose that a too long description is moved completely on next page
-					if ($pageposafter > $pageposbefore) {
+					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
 					}
 
@@ -301,7 +342,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
                     {
     					$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
                         $pdf->SetXY($this->posxtva, $curY);
-	       				$pdf->MultiCell($this->posxup-$this->posxtva-0.8, 3, $vat_rate, 0, 'R');
+	       				$pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R');
                     }
 
 					// Unit price before discount
@@ -322,7 +363,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 					// Total HT line
                     $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs);
                     $pdf->SetXY($this->postotalht, $curY);
-                    $pdf->MultiCell(26, 3, $total_excl_tax, 0, 'R', 0);
+                    $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
 
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
 					$tvaligne=$object->lines[$i]->total_tva;
@@ -344,6 +385,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 					// Add line
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
 					{
+						$pdf->setPage($pageposafter);
 						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
 						//$pdf->SetDrawColor(190,190,200);
 						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
@@ -368,6 +410,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 						$pagenb++;
 						$pdf->setPage($pagenb);
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
 					}
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
 					{
@@ -384,6 +427,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 						$pdf->AddPage();
 						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
 						$pagenb++;
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
 					}
 				}
 
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 0b580a41de87d10d7ec453abc36914aec3134dad..3933e21e0e021e344f107757ae62a400749fbf5c 100644
--- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
+++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
@@ -1,5 +1,5 @@
 <?php
-/* Copyright (C) 2004-2013 Laurent Destailleur   <eldy@users.sourceforge.net>
+/* Copyright (C) 2004-2014 Laurent Destailleur   <eldy@users.sourceforge.net>
  * Copyright (C) 2005-2011 Regis Houssin         <regis.houssin@capnetworks.com>
  * Copyright (C) 2007      Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
  * Copyright (C) 2010-2013 Juanjo Menent         <jmenent@2byte.es>
@@ -110,7 +110,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 		$this->posxdiscount=162;
 		$this->postotalht=174;
 		//if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
-		$this->posxpicture=$this->posxtva - 16;	// width of images
+		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?16:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
 		if ($this->page_largeur < 210) // To work with US executive format
 		{
 			$this->posxpicture-=20;
@@ -235,6 +235,15 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 						$this->atleastonediscount++;
 					}
 				}
+				if (empty($this->atleastonediscount))
+				{
+					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
+					$this->posxtva+=($this->postotalht - $this->posxdiscount);
+					$this->posxup+=($this->postotalht - $this->posxdiscount);
+					$this->posxqty+=($this->postotalht - $this->posxdiscount);
+					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
+					//$this->postotalht;
+				}
 
 				// New page
 				$pdf->AddPage();
@@ -309,7 +318,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 								$pdf->AddPage('','',true);
 								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-								$pdf->setPage($pagenb+1);
+								$pdf->setPage($pageposafter+1);
 							}
 						}
 						else
@@ -403,6 +412,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 					// Add line
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
 					{
+						$pdf->setPage($pageposafter);
 						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
 						//$pdf->SetDrawColor(190,190,200);
 						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
diff --git a/htdocs/core/tpl/document_actions_post_headers.tpl.php b/htdocs/core/tpl/document_actions_post_headers.tpl.php
index 2ae7b9ad595cfa0c82bd2eaf150455b618def14f..a662bd5be3defdc607aba6aab6f1b8cfecefca2e 100644
--- a/htdocs/core/tpl/document_actions_post_headers.tpl.php
+++ b/htdocs/core/tpl/document_actions_post_headers.tpl.php
@@ -1,6 +1,6 @@
 <?php
-/* Copyright (C)    2013    Cédric Salvador     <csalvador@gpcsolutions.fr>
- * Copyright (C)    2013    Laurent Destailleur	<eldy@users.sourceforge.net>
+/* Copyright (C)    2013      Cédric Salvador     <csalvador@gpcsolutions.fr>
+ * Copyright (C)    2013-2014 Laurent Destailleur <eldy@users.sourceforge.net>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -18,16 +18,17 @@
  */
 
 $langs->load("link");
+if (empty($relativepathwithnofile)) $relativepathwithnofile='';
 
 /*
- * Confirm suppression
+ * Confirm form to delete
  */
 
 if ($action == 'delete')
 {
 	$langs->load("companies");	// Need for string DeleteFile+ConfirmDeleteFiles
 	$ret = $form->form_confirm(
-			$_SERVER["PHP_SELF"] . '?id=' . $object->id . '&urlfile=' . urlencode(GETPOST("urlfile")) . '&linkid=' . GETPOST('linkid', 'int'),
+			$_SERVER["PHP_SELF"] . '?id=' . $object->id . '&urlfile=' . urlencode(GETPOST("urlfile")) . '&linkid=' . GETPOST('linkid', 'int') . (empty($param)?'':$param),
 			$langs->trans('DeleteFile'),
 			$langs->trans('ConfirmDeleteFile'),
 			'confirm_deletefile',
@@ -58,11 +59,11 @@ $formfile->list_of_documents(
     $modulepart,
     $param,
     0,
-    '',
+    $relativepathwithnofile,		// relative path with no file. For example "moduledir/0/1"
     $permission
 );
 
 print "<br>";
 //List of links
-$formfile->listOfLinks($object, $permission, $action, GETPOST('linkid', 'int'));
+$formfile->listOfLinks($object, $permission, $action, GETPOST('linkid', 'int'), $param);
 print "<br>";
diff --git a/htdocs/core/tpl/document_actions_pre_headers.tpl.php b/htdocs/core/tpl/document_actions_pre_headers.tpl.php
index 989a3bcaf73d689b44e74d3f56a7b14aed06e3a9..ca6929331eccc8898ad35daa0cb019abca7560b2 100644
--- a/htdocs/core/tpl/document_actions_pre_headers.tpl.php
+++ b/htdocs/core/tpl/document_actions_pre_headers.tpl.php
@@ -74,7 +74,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
                 setEventMessage($langs->trans("ErrorFailedToDeleteLink", $link->label), 'errors');
             }
         }
-        header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id);
+        header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id.($withproject?'&withproject=1':''));
         exit;
     }
 }
diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index 743988b3195cd3bef7aa0f5bad7a7b05caf2a763..4d30aca90fa8bbead281a77956648c8631bbbe1d 100644
--- a/htdocs/fourn/commande/fiche.php
+++ b/htdocs/fourn/commande/fiche.php
@@ -212,8 +212,9 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
         setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors');
         $error++;
     }
-    if (! GETPOST('addline_predefined') && (! GETPOST('pu') || GETPOST('pu')=='')) // Unit price can be 0 but not ''
+    if (! GETPOST('addline_predefined') && ( GETPOST('pu')==='')) // Unit price can be 0 but not ''
     {
+    	
         setEventMessage($langs->trans($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice'))), 'errors');
         $error++;
     }
@@ -232,7 +233,7 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
     // Ecrase $pu par celui	du produit
     // Ecrase $desc	par	celui du produit
     // Ecrase $txtva  par celui du produit
-    if (GETPOST('addline_predefined') || GETPOST('idprodfournprice'))	// With combolist idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or ''
+    if ((GETPOST('addline_predefined') || GETPOST('idprodfournprice'))  && ( GETPOST('pu')!==''))	// With combolist idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or ''
     {
     	$idprod=0;
     	$productsupplier = new ProductFournisseur($db);
@@ -292,7 +293,7 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
     		setEventMessage($langs->trans("ErrorQtyTooLowForThisSupplier"), 'errors');
     	}
     }
-    else
+    else if( GETPOST('pu')!=='' || GETPOST('amountttc')!=='' )
 	{
     	$type=$_POST["type"];
     	$desc=$_POST['dp_desc'];
@@ -319,7 +320,7 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
     			$ttc = price2num($_POST['amountttc']);
     			$ht = $ttc / (1 + ($tauxtva / 100));
     			$price_base_type = 'HT';
-    			$result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type);
+			$result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type);
     		}
     	}
     }
diff --git a/htdocs/holiday/fiche.php b/htdocs/holiday/fiche.php
index e921237583a255934efbea66894c3b1060ca7e3f..b77a93ab6336d9595dc5f62fbf5d01a971e904e4 100644
--- a/htdocs/holiday/fiche.php
+++ b/htdocs/holiday/fiche.php
@@ -1043,7 +1043,7 @@ else
                     $idGroupValid = $cp->getConfCP('userGroup');
 
                     $validator = new UserGroup($db,$idGroupValid);
-                    $valideur = $validator->listUsersForGroup();
+                    $valideur = $validator->listUsersForGroup('',1);
 
                     print '<td>';
                     $form->select_users($cp->fk_validator,"valideur",1,"",0,$valideur,'');
diff --git a/htdocs/langs/en_US/languages.lang b/htdocs/langs/en_US/languages.lang
index 754a7a7154483c739bd7f97d1da60ea7bd160df2..fd67a42c2374780458206b778787c48d67fa6ce8 100644
--- a/htdocs/langs/en_US/languages.lang
+++ b/htdocs/langs/en_US/languages.lang
@@ -20,6 +20,7 @@ Language_en_US=English (United States)
 Language_en_ZA=English (South Africa)
 Language_es_ES=Spanish
 Language_es_AR=Spanish (Argentina)
+Language_es_CL=Spanish (Chile)
 Language_es_HN=Spanish (Honduras)
 Language_es_MX=Spanish (Mexico)
 Language_es_PY=Spanish (Paraguay)
diff --git a/htdocs/langs/es_CL/admin.lang b/htdocs/langs/es_CL/admin.lang
new file mode 100644
index 0000000000000000000000000000000000000000..20f6fdfea33bbac57e0a9de338785067012deb3c
--- /dev/null
+++ b/htdocs/langs/es_CL/admin.lang
@@ -0,0 +1,23 @@
+Module20Name=Cotizaciones
+Module20Desc=Gestión de cotizaciones/propuestas comerciales
+Permission21=Consultar cotizaciones
+Permission22=Crear/modificar cotizaciones
+Permission24=Validar cotizaciones
+Permission25=Enviar las cotizaciones
+Permission26=Cerrar cotizaciones
+Permission27=Eliminar cotizaciones
+Permission28=Exportar las cotizaciones
+DictionnarySource=Orígenes de cotizaciones/pedidos
+VATIsUsedDesc=El tipo de IVA propuesto por defecto en las creaciones de cotizaciones, facturas, pedidos, etc. Responde a la siguiente regla:<br>Si el vendedor no está sujeto a IVA, IVA por defecto=0. Final de regla.<br>Si el país del vendedor= país del comprador entonces IVA por defecto=IVA del producto vendido. Final de regla.<br>Si vendedor y comprador residen en la Comunidad Europea y el bien vendido= nuevo medio de transportes (auto, barco, avión), IVA por defecto=0 (el IVA debe ser pagado por comprador a la hacienda pública de su país y no al vendedor). Final de regla<br>Si vendedor y comprador residen en la Comunidad Europea y comprador= particular o empresa sin NIF intracomunitario entonces IVA por defecto=IVA del producto vendido. Final de regla.<br>Si vendedor y comprador residen en la Comunidad Europea y comprador= empresa con NIF intracomunitario entonces IVA por defecto=0. Final de regla.<br>Si no, IVA propuesto por defecto=0. Final de regla.<br>
+VATIsNotUsedDesc=El tipo de IVA propuesto por defecto es 0. Este es el caso de asociaciones, particulares o algunas pequeñas sociedades.
+VATIsUsedExampleFR=En Francia, se trata de las sociedades u organismos que eligen un régimen fiscal general (General simplificado o General normal), régimen en el cual se declara el IVA.
+Delays_MAIN_DELAY_PROPALS_TO_CLOSE=Tolerancia de retraso antes de la alerta (en días) sobre cotizaciones a cerrar
+Delays_MAIN_DELAY_PROPALS_TO_BILL=Tolerancia de retraso antes de la alerta (en días) sobre cotizaciones no facturadas
+WebCalAddEventOnStatusPropal=Añadir evento en el calendario en el cambio de estado de las cotizaciones
+PropalSetup=Configuración del módulo Cotizaciones
+ProposalsNumberingModules=Módulos de numeración de cotizaciones
+ProposalsPDFModules=Modelos de documentos de cotizaciones
+HideTreadedPropal=Ocultar las cotizaciones procesados del listado
+FreeLegalTextOnProposal=Texto libre en cotizaciones
+WatermarkOnDraftProposal=Marca de agua en cotizaciones borrador (en caso de estar vacío)
+FCKeditorForProductDetails=Creación/edición WYSIWIG de las líneas de detalle de los productos (en pedidos, cotizaciones, facturas, etc.)
\ No newline at end of file
diff --git a/htdocs/langs/es_CL/agenda.lang b/htdocs/langs/es_CL/agenda.lang
new file mode 100644
index 0000000000000000000000000000000000000000..deefdc2275c6e54b48703d8b272389ed9ed424a9
--- /dev/null
+++ b/htdocs/langs/es_CL/agenda.lang
@@ -0,0 +1,2 @@
+PropalValidatedInDolibarr=Cotización %s validada
+ProposalSentByEMail=Cotización %s enviada por e-mail
\ No newline at end of file
diff --git a/htdocs/langs/es_CL/bills.lang b/htdocs/langs/es_CL/bills.lang
new file mode 100644
index 0000000000000000000000000000000000000000..63a78444437fe6307a13c57bd1e5be88a0b9ce66
--- /dev/null
+++ b/htdocs/langs/es_CL/bills.lang
@@ -0,0 +1 @@
+RelatedCommercialProposals=Cotizaciones asociadas
\ No newline at end of file
diff --git a/htdocs/langs/es_CL/boxes.lang b/htdocs/langs/es_CL/boxes.lang
new file mode 100644
index 0000000000000000000000000000000000000000..970c91a8fe5204f50e5b1c5d585c92bd524c8712
--- /dev/null
+++ b/htdocs/langs/es_CL/boxes.lang
@@ -0,0 +1,5 @@
+BoxLastProposals=Últimas cotizaciones
+BoxTitleLastPropals=Las %s últimas cotizaciones registradas
+NoRecordedProposals=Sin cotizaciones registradas
+BoxProposalsPerMonth=Cotizaciones por mes
+ForProposals=Cotizaciones
\ No newline at end of file
diff --git a/htdocs/langs/es_CL/commercial.lang b/htdocs/langs/es_CL/commercial.lang
new file mode 100644
index 0000000000000000000000000000000000000000..d468d7d5f19ce01edbf572b011f0f818785bfba1
--- /dev/null
+++ b/htdocs/langs/es_CL/commercial.lang
@@ -0,0 +1,4 @@
+SendPropalRef=Envío de la cotización %s
+ActionAC_PROP=Envío cotización por correo
+DraftPropals=Cotizaciones borrador
+SearchPropal=Buscar una cotización
\ No newline at end of file
diff --git a/htdocs/langs/es_CL/companies.lang b/htdocs/langs/es_CL/companies.lang
new file mode 100644
index 0000000000000000000000000000000000000000..daef89c75cf547605a1e1a0b21f1db2d407c5798
--- /dev/null
+++ b/htdocs/langs/es_CL/companies.lang
@@ -0,0 +1,2 @@
+ContactForProposals=Contacto de cotizaciones
+NoContactForAnyProposal=Este contacto no es contacto de ninguna cotización
\ No newline at end of file
diff --git a/htdocs/langs/es_CL/compta.lang b/htdocs/langs/es_CL/compta.lang
new file mode 100644
index 0000000000000000000000000000000000000000..bf18ae78c5fcbe66646002d820f698024d01c124
--- /dev/null
+++ b/htdocs/langs/es_CL/compta.lang
@@ -0,0 +1 @@
+ProposalStats=Estadísticas de cotizaciones
\ No newline at end of file
diff --git a/htdocs/langs/es_CL/ecm.lang b/htdocs/langs/es_CL/ecm.lang
new file mode 100644
index 0000000000000000000000000000000000000000..3e20b3e66282f82e4efdcc7bfe540f6f745f9ace
--- /dev/null
+++ b/htdocs/langs/es_CL/ecm.lang
@@ -0,0 +1,2 @@
+DocsProposals=Documentos cotizaciones
+ECMDocsByProposals=Documentos asociados a cotizaciones
\ No newline at end of file
diff --git a/htdocs/langs/es_CL/install.lang b/htdocs/langs/es_CL/install.lang
new file mode 100644
index 0000000000000000000000000000000000000000..40d447b8653f84f395f4e8fe63cbbf1fcdb66a39
--- /dev/null
+++ b/htdocs/langs/es_CL/install.lang
@@ -0,0 +1 @@
+MigrationProposal=Migración de datos de cotizaciones
\ No newline at end of file
diff --git a/htdocs/langs/es_CL/main.lang b/htdocs/langs/es_CL/main.lang
new file mode 100644
index 0000000000000000000000000000000000000000..90e98cca31d645f9a5b1585a228d2033be73fb65
--- /dev/null
+++ b/htdocs/langs/es_CL/main.lang
@@ -0,0 +1 @@
+CommercialProposalsShort=Cotizaciones
\ No newline at end of file
diff --git a/htdocs/langs/es_CL/members.lang b/htdocs/langs/es_CL/members.lang
new file mode 100644
index 0000000000000000000000000000000000000000..59fd53dd9937e6ea34ae57ea55d2d32f29f70db6
--- /dev/null
+++ b/htdocs/langs/es_CL/members.lang
@@ -0,0 +1 @@
+TurnoverOrBudget=Volumen de ventas (empresa) o Cotización (asociación o colectivo)
\ No newline at end of file
diff --git a/htdocs/langs/es_CL/orders.lang b/htdocs/langs/es_CL/orders.lang
new file mode 100644
index 0000000000000000000000000000000000000000..8810a19bcf8dee46dd83b8430759d0c3f165d709
--- /dev/null
+++ b/htdocs/langs/es_CL/orders.lang
@@ -0,0 +1 @@
+OrderSource0=Cotización
\ No newline at end of file
diff --git a/htdocs/langs/es_CL/other.lang b/htdocs/langs/es_CL/other.lang
new file mode 100644
index 0000000000000000000000000000000000000000..f2b10a1a2d2e64db2c27dd102ba014534684cde1
--- /dev/null
+++ b/htdocs/langs/es_CL/other.lang
@@ -0,0 +1,9 @@
+Notify_PROPAL_VALIDATE=Validación cotización cliente
+Notify_PROPAL_SENTBYMAIL=Envío cotización por e-mail
+PredefinedMailContentSendProposal=Buenos días, __CONTACTCIVNAME__ \n\n Nos ponemos en contacto con usted para facilitarle la cotización __PROPREF__\n\n Ante cualquier duda, consúltenos y será atendido a la mayor brevedad posible.\n\n __PERSONALIZED__Cordialmente\n\n__SIGNATURE__
+NumberOfProposals=Número de cotizaciones en los últimos 12 meses
+NumberOfUnitsProposals=Número de unidades en las cotizaciones en los últimos 12 meses
+EMailTextProposalValidated=La cotización %s que le concierne ha sido validado.
+PropalClosedSignedInDolibarr=Cotización %s firmada en Dolibarr
+PropalClosedRefusedInDolibarr=Cotización %s rechazada en Dolibarr
+PropalValidatedInDolibarr=Cotización %s validada en Dolibarr
\ No newline at end of file
diff --git a/htdocs/langs/es_CL/products.lang b/htdocs/langs/es_CL/products.lang
new file mode 100644
index 0000000000000000000000000000000000000000..cf82ea19c2b6f55537e661184f4431f3eab761cb
--- /dev/null
+++ b/htdocs/langs/es_CL/products.lang
@@ -0,0 +1,3 @@
+AddToMyProposals=Añadir a mis cotizaciones
+AddToOtherProposals=Añadir a otras cotizaciones
+NoteNotVisibleOnBill=Nota (no visible en las facturas, cotizaciones, etc.)
\ No newline at end of file
diff --git a/htdocs/langs/es_CL/projects.lang b/htdocs/langs/es_CL/projects.lang
new file mode 100644
index 0000000000000000000000000000000000000000..a5ee33a39a41ad0c3ef8391f3b74e1053dcf3e2e
--- /dev/null
+++ b/htdocs/langs/es_CL/projects.lang
@@ -0,0 +1 @@
+ListProposalsAssociatedProject=Listado de cotizaciones asociadas al proyecto
\ No newline at end of file
diff --git a/htdocs/langs/es_CL/propal.lang b/htdocs/langs/es_CL/propal.lang
new file mode 100644
index 0000000000000000000000000000000000000000..8242c7d90a463e0d68c10690ce519a9bbab4c6c5
--- /dev/null
+++ b/htdocs/langs/es_CL/propal.lang
@@ -0,0 +1,62 @@
+Proposals=Cotizaciones
+Proposal=Cotización
+ProposalShort=Cotización
+ProposalsDraft=Cotizaciones borrador
+ProposalDraft=Cotización borrador
+ProposalsOpened=Cotizaciones abiertas
+Prop=Cotizaciones
+CommercialProposal=Cotización
+CommercialProposals=Cotizaciones
+ProposalCard=Ficha cotización
+NewProp=Nueva cotización
+NewProposal=Nueva cotización
+NewPropal=Nueva cotización
+DeletePop=Eliminar cotización
+ValidateProp=Validar cotización
+AddProp=Crear cotización
+ConfirmDeleteProp=¿Está seguro de querer eliminar esta cotización?
+ConfirmValidateProp=¿Está seguro de querer validar esta cotización bajo la referencia <b>%s</b> ?
+LastClosedProposals=Las %s últimas cotizaciones cerradas
+LastModifiedProposals=Las %s últimas cotizaciones modificadas
+AllPropals=Todas las cotizacioness
+LastProposals=Últimas cotizaciones
+SearchAProposal=Buscar una cotización
+ProposalsStatistics=Estadísticas de cotizaciones
+NumberOfUnitsProposals=Número de unidades en las cotizaciones en los últimos 12 meses
+NbOfProposals=Número cotizaciones
+ShowPropal=Ver cotización
+PropalStatusValidated=Validado (cotización abierta)
+PropalStatusOpened=Validado (cotización abierta)
+PropalsToClose=Cotizaciones a cerrar
+PropalsToBill=Cotizaciones firmadas a facturar
+ListOfProposals=Listado de cotizaciones
+ActionsOnPropal=Eventos sobre la cotización
+NoOpenedPropals=Sin cotizaciones abiertos
+NoOtherOpenedPropals=Ninguna otra cotización abierta
+RefProposal=Ref. cotización
+SendPropalByMail=Enviar cotización por e-mail
+AssociatedDocuments=Documentos asociados a la cotizacion
+DatePropal=Fecha cotización
+ErrorPropalNotFound=Presupuesto %s inexistente
+Estimate=Cotización:
+EstimateShort=Cotización
+OtherPropals=Otras cotizaciones
+AddToDraftProposals=Añadir a cotización borrador
+NoDraftProposals=Sin cotizaciones borrador
+CopyPropalFrom=Crear cotización por copia de una existente
+CreateEmptyPropal=Crear cotización vacía
+UseCustomerContactAsPropalRecipientIfExist=Utilizar dirección contacto de seguimiento de cliente definido en vez de la dirección del tercero como destinatario de las cotizaciones
+ClonePropal=Clonar cotización
+ConfirmClonePropal=¿Está seguro de querer clonar la cotización <b>%s</b>?
+ConfirmReOpenProp=¿Está seguro de querer reabrir la cotización <b>%s</b> ?
+ProposalsAndProposalsLines=Cotizaciones a clientes y líneas de cotizaciones
+ProposalLine=Línea de cotización
+##### Types de contacts #####
+TypeContact_propal_internal_SALESREPFOLL=Comercial seguimiento cotización
+TypeContact_propal_external_BILLING=Contacto cliente de facturación cotización
+TypeContact_propal_external_CUSTOMER=Contacto cliente seguimiento cotización
+# Document models
+DocModelAzurDescription=Modelo de cotización completa (logo...)
+DocModelJauneDescription=Modelo de cotización Jaune
+DefaultModelPropalToBill=Modelo por defecto al cerrar una cotización (a facturar)
+DefaultModelPropalClosed=Modelo por defecto al cerrar una cotización (no facturado)
\ No newline at end of file
diff --git a/htdocs/langs/es_CL/workflow.lang b/htdocs/langs/es_CL/workflow.lang
new file mode 100644
index 0000000000000000000000000000000000000000..17b2915fc39c7c68d2b33f835d5b3a2eb8635b22
--- /dev/null
+++ b/htdocs/langs/es_CL/workflow.lang
@@ -0,0 +1,3 @@
+descWORKFLOW_PROPAL_AUTOCREATE_ORDER=Crear un pedido de cliente automáticamente a la firma de una cotización
+descWORKFLOW_PROPAL_AUTOCREATE_INVOICE=Crear una factura a cliente automáticamente a la firma de una cotización
+descWORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL=Clasificar como facturada la cotización cuando el pedido de cliente relacionado se clasifique como pagado
\ No newline at end of file
diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php
index 89fc9549156c545e703386d54c7420f609eab227..8d545bf1e6aa6752c75b992d175aa3484974fea0 100644
--- a/htdocs/projet/document.php
+++ b/htdocs/projet/document.php
@@ -144,9 +144,8 @@ if ($object->id > 0)
 	print "</table>\n";
 	print "</div>\n";
 
-	$modulepart = 'projet';
+	$modulepart = 'project';
 	$permission = ($userWrite > 0);
-	$param = '&id=' . $object->id;
 	include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
 
 }
diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php
index 8dd80223e6c29e8569c06cd8ed6e9893019929b8..0b876d0490a328efdf6cb840f8f0be066c0bf4f0 100644
--- a/htdocs/projet/tasks/document.php
+++ b/htdocs/projet/tasks/document.php
@@ -110,6 +110,7 @@ if ($id > 0 || ! empty($ref))
 
 include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
 
+
 /*
  * View
  */
@@ -229,9 +230,11 @@ if ($object->id > 0)
 
 	print '<br>';
 
-	$modulepart = 'projet';
+	$param='';
+	if ($withproject) $param .= '&withproject=1';
+	$modulepart = 'project_task';
 	$permission = $user->rights->projet->creer;
-	$param = '&id=' . $object->id;
+	$relativepathwithnofile=dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($object->ref).'/';
 	include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
 }
 else