Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/3.5' into develop

Conflicts:
	htdocs/comm/propal.php
	htdocs/commande/fiche.php
	htdocs/compta/facture.php
	htdocs/core/lib/pdf.lib.php
	htdocs/core/modules/expedition/doc/pdf_merou.modules.php
	htdocs/core/modules/modProduct.class.php
	htdocs/fourn/commande/fiche.php
	htdocs/projet/fiche.php
Laurent Destailleur 11 gadi atpakaļ
vecāks
revīzija
8d1fdec8cf

+ 23 - 0
ChangeLog

@@ -107,12 +107,35 @@ removed. You must now use the 6 parameters way. See file modMyModule.class.php f
 
 
 ***** ChangeLog for 3.5.4 compared to 3.5.3 *****
+Fix: [ bug #1431 ] Reception and Send supplier order box has a weird top margin.
+Fix: [ bug #1428 ] "Nothing" is shown in the middle of the screen in a supplier order.
+Fix: The object deliverycompany was not used anymore and output of
+     details for delivery reports was lost during 3.5. Rewrite code to
+     restore feature.
+Fix: [ bug #1445 ] html fix : missing </tr>
 Fix: [ bug #1415 ] Intervention document model name and suppliers model names is not shown
      properly in module configuration
 Fix: [ bug #1416 ] Supplier order does not list document models in the select box of the 
      supplier order card
 Fix: [ bug #1443 ] Payment conditions is erased after editing supplier invoice label or 
      limit date for payment
+Fix: Filter on status was not visible when selected from url.
+Fix: Filtering on status was last when asking to sort.
+Fix: [ bug #1432 ] Trigger SHIPPING_CREATE ignores interception on error.
+Fix: [ bug #1449 ] Trigger ORDER_CREATE, LINEORDER_DELETE, LINEORDER_UPDATE and LINEORDER_INSERT ignore interception on error.
+Fix: [ bug #1450 ] Several Customer order's triggers do not report the error from the trigger handler.
+Fix: [ bug #1451 ] Interrupted order clone through trigger, loads nonexistent order.
+Fix: [ bug #1454 ] Mention de bas de page erroné
+Fix: Do not display dictionnay for non activated module 
+Fix: Link element from element project pages
+Fix: [ bug #1509 ] Expedition admin free text & watermark submit error
+Fix: [ bug #1349 ] AJAX contact selector does not work fine in Project card
+Fix: [ bug #1452 ] variable used but not defined
+Fix: If multiprice level is used the VAT on addline is not correct
+Fix: [ bug #1254 ] Error when using "Enter" on qty input box of a product (on supplier order part)
+Fix: [ bug #1462, 1468, 1480, 1483, 1490, 1497] $this instead of $object
+Fix: [ bug #1455 ] outstanding amount
+Fix: [ bug #1425 ]
 
 ***** ChangeLog for 3.5.3 compared to 3.5.2 *****
 Fix: Error on field accountancy code for export profile of invoices.

+ 2 - 2
htdocs/admin/expedition.php

@@ -76,7 +76,7 @@ else if ($action == 'set_SHIPPING_FREE_TEXT')
 	$freetext=GETPOST('SHIPPING_FREE_TEXT','alpha');
 	$res = dolibarr_set_const($db, "SHIPPING_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
 
-	if ($res < 0)
+	if ($res > 0)
 		setEventMessage($langs->trans("SetupSaved"));
 	else
 		setEventMessage($langs->trans("Error"), 'errors');
@@ -87,7 +87,7 @@ else if ($action == 'set_SHIPPING_DRAFT_WATERMARK')
 	$draft=GETPOST('SHIPPING_DRAFT_WATERMARK','alpha');
 	$res = dolibarr_set_const($db, "SHIPPING_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
 
-	if ($res < 0)
+	if ($res > 0)
 		setEventMessage($langs->trans("SetupSaved"));
 	else
 		setEventMessage($langs->trans("Error"), 'errors');

+ 13 - 5
htdocs/comm/propal.php

@@ -178,7 +178,8 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->pr
 		}
 	} else {
 		$langs->load("errors");
-		setEventMessage($langs->trans($object->error), 'errors');
+		if (count($object->errors) > 0) setEventMessage($object->errors, 'errors');
+		else setEventMessage($langs->trans($object->error), 'errors');
 	}
 }
 
@@ -472,7 +473,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
 					$interface = new Interfaces($db);
 					$result = $interface->run_triggers('PROPAL_SENTBYMAIL', $object, $user, $langs, $conf);
 					if ($result < 0) {
-						$error ++;
+						$error++;
 						$object->errors = $interface->errors;
 					}
 					// Fin appel triggers
@@ -609,12 +610,17 @@ else if ($action == 'addline' && $user->rights->propal->creer) {
 				$tva_npr = get_default_npr($mysoc, $object->client, $prod->id);
 
 				// On defini prix unitaire
-				if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->client->price_level) {
+				if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->client->price_level)
+				{
 					$pu_ht = $prod->multiprices [$object->client->price_level];
 					$pu_ttc = $prod->multiprices_ttc [$object->client->price_level];
 					$price_min = $prod->multiprices_min [$object->client->price_level];
 					$price_base_type = $prod->multiprices_base_type [$object->client->price_level];
-				} elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
+					$tva_tx=$prod->multiprices_tva_tx[$object->client->price_level];
+					$tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level];
+				}
+				elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
+				{
 					require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
 
 					$prodcustprice = new Productcustomerprice($db);
@@ -631,7 +637,9 @@ else if ($action == 'addline' && $user->rights->propal->creer) {
 							$prod->tva_tx = $prodcustprice->lines [0]->tva_tx;
 						}
 					}
-				} else {
+				}
+				else
+				{
 					$pu_ht = $prod->price;
 					$pu_ttc = $prod->price_ttc;
 					$price_min = $prod->price_min;

+ 84 - 21
htdocs/commande/class/commande.class.php

@@ -453,8 +453,13 @@ class Commande extends CommonOrder
         }
         else
         {
-            $this->db->rollback();
-            return -1;
+	        foreach($this->errors as $errmsg)
+	        {
+		        dol_syslog(get_class($this)."::set_reopen ".$errmsg, LOG_ERR);
+		        $this->error.=($this->error?', '.$errmsg:$errmsg);
+	        }
+	        $this->db->rollback();
+	        return -1*$error;
         }
     }
 
@@ -580,8 +585,14 @@ class Commande extends CommonOrder
 			else
 			{
 				$this->error=$mouvP->error;
+
+				foreach($this->errors as $errmsg)
+				{
+					dol_syslog(get_class($this)."::cancel ".$errmsg, LOG_ERR);
+					$this->error.=($this->error?', '.$errmsg:$errmsg);
+				}
 				$this->db->rollback();
-				return -1;
+				return -1*$error;
 			}
 		}
 		else
@@ -808,8 +819,19 @@ class Commande extends CommonOrder
                         // Fin appel triggers
                     }
 
-                    $this->db->commit();
-                    return $this->id;
+	                if (!$error) {
+		                $this->db->commit();
+		                return $this->id;
+	                }
+
+	                foreach($this->errors as $errmsg)
+	                {
+		                dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
+		                $this->error.=($this->error?', '.$errmsg:$errmsg);
+	                }
+	                $this->db->rollback();
+	                return -1*$error;
+
                 }
                 else
                 {
@@ -1795,7 +1817,7 @@ class Commande extends CommonOrder
                     else
                     {
                         $this->db->rollback();
-                        $this->error=$this->db->lasterror();
+                        $this->error=$line->error;
                         return -1;
                     }
                 }
@@ -2229,9 +2251,14 @@ class Commande extends CommonOrder
 			else
 			{
 				$this->error=$this->db->error();
-				dol_syslog(get_class($this)."::classifyBilled ".$this->error, LOG_ERR);
+
+				foreach($this->errors as $errmsg)
+				{
+					dol_syslog(get_class($this)."::classifyBilled ".$errmsg, LOG_ERR);
+					$this->error.=($this->error?', '.$errmsg:$errmsg);
+				}
 				$this->db->rollback();
-				return -2;
+				return -1*$error;
 			}
 		}
 		else
@@ -2397,11 +2424,10 @@ class Commande extends CommonOrder
             }
             else
             {
-                $this->error=$this->db->lasterror();
-        		$this->errors=array($this->db->lasterror());
-                $this->db->rollback();
-                dol_syslog(get_class($this)."::updateline Error=".$this->error, LOG_ERR);
-                return -1;
+	            $this->error=$this->line->error;
+
+	            $this->db->rollback();
+	            return -1;
             }
         }
         else
@@ -2519,9 +2545,13 @@ class Commande extends CommonOrder
         else
         {
             $this->error=$this->db->lasterror();
-            dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
-            $this->db->rollback();
-            return -1;
+	        foreach($this->errors as $errmsg)
+	        {
+		        dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
+		        $this->error.=($this->error?', '.$errmsg:$errmsg);
+	        }
+	        $this->db->rollback();
+	        return -1*$error;
         }
     }
 
@@ -3154,6 +3184,8 @@ class OrderLine extends CommonOrderLine
 
 		$error=0;
 
+	    $this->db->begin();
+
         $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid='".$this->rowid."';";
 
         dol_syslog("OrderLine::delete sql=".$sql);
@@ -3179,7 +3211,18 @@ class OrderLine extends CommonOrderLine
             if ($result < 0) { $error++; $this->errors=$interface->errors; }
             // Fin appel triggers
 
-            return 1;
+	        if (!$error) {
+		        $this->db->commit();
+		        return 1;
+	        }
+
+	        foreach($this->errors as $errmsg)
+	        {
+		        dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
+		        $this->error.=($this->error?', '.$errmsg:$errmsg);
+	        }
+	        $this->db->rollback();
+	        return -1*$error;
         }
         else
         {
@@ -3295,8 +3338,18 @@ class OrderLine extends CommonOrderLine
                 // Fin appel triggers
             }
 
-            $this->db->commit();
-            return 1;
+	        if (!$error) {
+		        $this->db->commit();
+		        return 1;
+	        }
+
+	        foreach($this->errors as $errmsg)
+	        {
+		        dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
+		        $this->error.=($this->error?', '.$errmsg:$errmsg);
+	        }
+	        $this->db->rollback();
+	        return -1*$error;
         }
         else
         {
@@ -3403,8 +3456,18 @@ class OrderLine extends CommonOrderLine
 				// Fin appel triggers
 			}
 
-			$this->db->commit();
-			return 1;
+			if (!$error) {
+				$this->db->commit();
+				return 1;
+			}
+
+			foreach($this->errors as $errmsg)
+			{
+				dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
+				$this->error.=($this->error?', '.$errmsg:$errmsg);
+			}
+			$this->db->rollback();
+			return -1*$error;
 		}
 		else
 		{

+ 66 - 31
htdocs/commande/fiche.php

@@ -104,18 +104,30 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action
 include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once
 
 // Action clone object
-if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande->creer) {
-	if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) {
-		$mesg = '<div class="error">' . $langs->trans("NoCloneOptionsSpecified") . '</div>';
-	} else {
-		if ($object->id > 0) {
-			$result = $object->createFromClone($socid);
-			if ($result > 0) {
-				header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result);
-				exit();
-			} else {
-				$mesg = '<div class="error">' . $object->error . '</div>';
-				$action = '';
+if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande->creer)
+{
+	if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
+	{
+		$mesg='<div class="error">'.$langs->trans("NoCloneOptionsSpecified").'</div>';
+	}
+	else
+	{
+		if ($object->id > 0)
+		{
+			// Because createFromClone modifies the object, we must clone it so that we can restore it later
+			$orig = dol_clone($object);
+
+			$result=$object->createFromClone($socid);
+			if ($result > 0)
+			{
+				header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
+				exit;
+			}
+			else
+			{
+				setEventMessage($object->error, 'errors');
+				$object = $orig;
+				$action='';
 			}
 		}
 	}
@@ -125,11 +137,14 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande->
 else if ($action == 'reopen' && $user->rights->commande->creer) {
 	if ($object->statut == 3) {
 		$result = $object->set_reopen($user);
-		if ($result > 0) {
-			header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id);
-			exit();
-		} else {
-			$mesg = '<div class="error">' . $object->error . '</div>';
+		if ($result > 0)
+		{
+			header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
+			exit;
+		}
+		else
+		{
+			setEventMessage($object->error, 'errors');
 		}
 	}
 }
@@ -139,9 +154,10 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->comm
 	$result = $object->delete($user);
 	if ($result > 0) {
 		header('Location: index.php');
-		exit();
-	} else {
-		$mesg = '<div class="error">' . $object->error . '</div>';
+		exit;
+	}
+	else {
+		setEventMessage($object->error, 'errors');
 	}
 }
 
@@ -165,10 +181,12 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
 			commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
 		}
 
-		header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id);
-		exit();
-	} else {
-		$mesg = '<div class="error">' . $object->error . '</div>';
+		header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
+		exit;
+	}
+	else
+	{
+		setEventMessage($object->error, 'errors');
 	}
 }
 
@@ -382,8 +400,13 @@ else if ($action == 'add' && $user->rights->commande->creer) {
 	}
 }
 
-else if ($action == 'classifybilled' && $user->rights->commande->creer) {
-	$ret = $object->classifyBilled();
+else if ($action == 'classifybilled' && $user->rights->commande->creer)
+{
+	$ret=$object->classifyBilled();
+
+	if ($ret < 0) {
+		setEventMessage($object->error, 'errors');
+	}
 }
 
 // Positionne ref commande client
@@ -552,12 +575,17 @@ else if ($action == 'addline' && $user->rights->commande->creer) {
 				$tva_npr = get_default_npr($mysoc, $object->client, $prod->id);
 
 				// multiprix
-				if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) {
+				if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level))
+				{
 					$pu_ht = $prod->multiprices [$object->client->price_level];
 					$pu_ttc = $prod->multiprices_ttc [$object->client->price_level];
 					$price_min = $prod->multiprices_min [$object->client->price_level];
 					$price_base_type = $prod->multiprices_base_type [$object->client->price_level];
-				} elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
+					$tva_tx=$prod->multiprices_tva_tx[$object->client->price_level];
+					$tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level];
+				}
+				elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
+				{
 					require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
 
 					$prodcustprice = new Productcustomerprice($db);
@@ -574,7 +602,9 @@ else if ($action == 'addline' && $user->rights->commande->creer) {
 							$prod->tva_tx = $prodcustprice->lines [0]->tva_tx;
 						}
 					}
-				} else {
+				}
+				else
+				{
 					$pu_ht = $prod->price;
 					$pu_ttc = $prod->price_ttc;
 					$price_min = $prod->price_min;
@@ -898,8 +928,9 @@ else if ($action == 'confirm_modif' && $user->rights->commande->creer) {
 
 else if ($action == 'confirm_shipped' && $confirm == 'yes' && $user->rights->commande->cloturer) {
 	$result = $object->cloture($user);
-	if ($result < 0)
-		$mesgs = $object->errors;
+	if ($result < 0) {
+		setEventMessage($object->error, 'errors');
+	}
 }
 
 else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande->valider) {
@@ -916,6 +947,10 @@ else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->comm
 
 	if (! $error) {
 		$result = $object->cancel($idwarehouse);
+
+		if ($result < 0) {
+			setEventMessage($object->error, 'errors');
+		}
 	}
 }
 

+ 11 - 4
htdocs/compta/facture.php

@@ -1137,12 +1137,17 @@ else if ($action == 'addline' && $user->rights->facture->creer)
 				$tva_npr = get_default_npr($mysoc, $object->client, $prod->id);
 
 				// We define price for product
-				if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) {
+				if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level))
+				{
 					$pu_ht = $prod->multiprices [$object->client->price_level];
 					$pu_ttc = $prod->multiprices_ttc [$object->client->price_level];
 					$price_min = $prod->multiprices_min [$object->client->price_level];
 					$price_base_type = $prod->multiprices_base_type [$object->client->price_level];
-				} elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
+					$tva_tx=$prod->multiprices_tva_tx[$object->client->price_level];
+					$tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level];
+				}
+				elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
+				{
 					require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
 
 					$prodcustprice = new Productcustomerprice($db);
@@ -1159,7 +1164,9 @@ else if ($action == 'addline' && $user->rights->facture->creer)
 							$prod->tva_tx = $prodcustprice->lines [0]->tva_tx;
 						}
 					}
-				} else {
+				}
+				else
+				{
 					$pu_ht = $prod->price;
 					$pu_ttc = $prod->price_ttc;
 					$price_min = $prod->price_min;
@@ -1606,7 +1613,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
 					$interface = new Interfaces($db);
 					$result = $interface->run_triggers('BILL_SENTBYMAIL', $object, $user, $langs, $conf);
 					if ($result < 0) {
-						$error ++;
+						$error++;
 						$object->errors = $interface->errors;
 					}
 					// Fin appel triggers

+ 1 - 1
htdocs/core/class/html.formfile.class.php

@@ -616,7 +616,7 @@ class FormFile
               		}
 				}
 
-			 	if (count($file_list) == 0)
+			 	if (count($file_list) == 0 && $headershown)
 	            {
     	        	$out.='<tr><td colspan="3">'.$langs->trans("None").'</td></tr>';
         	    }

+ 10 - 4
htdocs/core/class/html.formprojet.class.php

@@ -77,7 +77,7 @@ class FormProjets
 		$sql.= " WHERE p.entity = ".$conf->entity;
 		if ($projectsListId !== false) $sql.= " AND p.rowid IN (".$projectsListId.")";
 		if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
-		$sql.= " ORDER BY p.title ASC";
+		$sql.= " ORDER BY p.ref ASC";
 
 		dol_syslog(get_class($this)."::select_projects sql=".$sql,LOG_DEBUG);
 		$resql=$this->db->query($sql);
@@ -113,6 +113,7 @@ class FormProjets
 						else
 						{
 							$disabled=0;
+							$labeltoshow.=' '.dol_trunc($obj->title,$maxlength);
 							if (! $obj->fk_statut > 0)
 							{
 								$disabled=1;
@@ -134,8 +135,8 @@ class FormProjets
 								if ($disabled) $resultat.=' disabled="disabled"';
 								//if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
 								//else $labeltoshow.=' ('.$langs->trans("Private").')';
-								$resultat.='>'.$labeltoshow;
-								if (! $disabled) $resultat.=' - '.dol_trunc($obj->title,$maxlength);
+								$resultat.='>';
+								$resultat.=$labeltoshow;
 								$resultat.='</option>';
 							}
 							$out.= $resultat;
@@ -167,6 +168,7 @@ class FormProjets
 	 */
 	function select_element($table_element)
 	{
+		global $conf;
 
 		$projectkey="fk_projet";
 		switch ($table_element)
@@ -194,7 +196,7 @@ class FormProjets
 		if (!empty($this->societe->id)) {
 			$sql.= " AND fk_soc=".$this->societe->id;
 		}
-		$sql.= ' AND entity='.$conf->entity;
+		$sql.= ' AND entity='.getEntity('project');
 		$sql.= " ORDER BY ref DESC";
 
 		dol_syslog(get_class($this).'::select_element sql='.$sql,LOG_DEBUG);
@@ -218,6 +220,10 @@ class FormProjets
 			return $sellist ;
 
 			$this->db->free($resql);
+		}else {
+			$this->error=$this->db->lasterror();
+			dol_syslog(get_class($this) . "::select_element " . $this->error, LOG_ERR);
+			return -1;
 		}
 	}
 

+ 1 - 0
htdocs/core/js/lib_head.js

@@ -810,6 +810,7 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton,
             var input = this.input = $( "<input>" )
                 .insertAfter( select )
                 .val( value )
+                .attr('id', 'inputautocomplete'+select.attr('id'))
                 .autocomplete({
                     delay: 0,
                     minLength: this.options.minLengthToAutocomplete,

+ 2 - 0
htdocs/core/lib/admin.lib.php

@@ -937,6 +937,8 @@ function complete_dictionary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsql
                         $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod)));
                         if ($objMod->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2 && ! $conf->global->$const_name) $modulequalified=0;
                         if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && ! $conf->global->$const_name) $modulequalified=0;
+                        //If module is not activated disqualified
+                        if (empty($conf->global->$const_name)) $modulequalified=0;
 
                         if ($modulequalified)
                         {

+ 7 - 0
htdocs/core/lib/ajax.lib.php

@@ -368,6 +368,13 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0)
 							}
 						});
 						$("select#" + htmlname).html(response.value);
+						if (response.num) {
+							var selecthtml_str = response.value;
+							var selecthtml_dom=$.parseHTML(selecthtml_str);
+							$("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
+						} else {
+							$("#inputautocomplete"+htmlname).val("");
+						}
 					});
 		}
 

+ 2 - 2
htdocs/core/lib/pdf.lib.php

@@ -348,7 +348,7 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target
 				// Phone
 				if (! empty($targetcontact->phone_pro) || ! empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ";
 				if (! empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
-				if (! empty($targetcontact->phone_pro) || ! empty($targetcontact->phone_mobile)) $stringaddress .= " / ";
+				if (! empty($targetcontact->phone_pro) && ! empty($targetcontact->phone_mobile)) $stringaddress .= " / ";
 				if (! empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
 				// Fax
 				if ($targetcontact->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax);
@@ -369,7 +369,7 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target
 				// Phone
 				if (! empty($targetcompany->phone) || ! empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ";
 				if (! empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
-				if (! empty($targetcompany->phone) || ! empty($targetcompany->phone_mobile)) $stringaddress .= " / ";
+				if (! empty($targetcompany->phone) && ! empty($targetcompany->phone_mobile)) $stringaddress .= " / ";
 				if (! empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile);
 				// Fax
 				if ($targetcompany->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax);

+ 0 - 1
htdocs/core/modules/expedition/doc/pdf_merou.modules.php

@@ -604,7 +604,6 @@ class pdf_merou extends ModelePdfExpedition
 
 		$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,((!empty($object->contact))?$object->contact:null),$usecontact,'targetwithdetails');
 
-
 		$blDestX=$blExpX+55;
 		$blW=50;
 		$Yoff = $Ydef +1;

+ 1 - 1
htdocs/core/modules/propale/doc/pdf_azur.modules.php

@@ -630,7 +630,7 @@ class pdf_azur extends ModelePDFPropales
 		$posxval=52;
 
         // Show shipping date
-        if ($object->date_livraison)
+        if (! empty($object->date_livraison))
 		{
             $outputlangs->load("sendings");
 			$pdf->SetFont('','B', $default_font_size - 2);

+ 6 - 3
htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php

@@ -911,6 +911,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 		$outputlangs->load("bills");
 		$outputlangs->load("orders");
 		$outputlangs->load("companies");
+		$outputlangs->load("sendings");
 
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
@@ -981,11 +982,10 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 
         $posy+=5;
 		$pdf->SetXY($posx,$posy);
-		if ($object->date_commande)
+		if (! empty($object->date_commande))
 		{
 			$pdf->SetTextColor(0,0,60);
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date_commande,"day",false,$outputlangs,true), '', 'R');
-			$pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_livraison,"day",false,$outputlangs,true), '', 'R');
 		}
 		else
 		{
@@ -993,6 +993,9 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderToProcess"), '', 'R');
 		}
 
+		$pdf->SetTextColor(0,0,60);
+		if (! empty($object->date_livraison)) $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_livraison,"day",false,$outputlangs,true), '', 'R');
+
 		$posy+=5;
 		$pdf->SetTextColor(0,0,60);
 
@@ -1094,7 +1097,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 	 */
 	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
 	{
-		return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_INVOICE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,0,$hidefreetext);
+		return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,0,$hidefreetext);
 	}
 
 }

+ 16 - 2
htdocs/expedition/class/expedition.class.php

@@ -282,8 +282,22 @@ class Expedition extends CommonObject
 					if ($result < 0) { $error++; $this->errors=$interface->errors; }
 					// Fin appel triggers
 
-					$this->db->commit();
-					return $this->id;
+					if (! $error)
+					{
+						$this->db->commit();
+						return $this->id;
+					}
+					else
+					{
+						foreach($this->errors as $errmsg)
+						{
+							dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
+							$this->error.=($this->error?', '.$errmsg:$errmsg);
+						}
+						$this->db->rollback();
+						return -1*$error;
+					}
+
 				}
 				else
 				{

+ 0 - 7
htdocs/fourn/commande/fiche.php

@@ -1860,8 +1860,6 @@ elseif (! empty($object->id))
 
 
 		print '<div class="fichecenter"><div class="fichehalfleft">';
-		//print '<table width="100%"><tr><td width="50%" valign="top">';
-		//print '<a name="builddoc"></a>'; // ancre
 
 		/*
 		 * Documents generes
@@ -1890,10 +1888,6 @@ elseif (! empty($object->id))
         $formactions=new FormActions($db);
         $somethingshown=$formactions->showactions($object,'order_supplier',$socid);
 
-		print '</div></div></div>';
-
-		//print '</td><td valign="top" width="50%">';
-		print '</div><div class="fichehalfright"><div class="ficheaddleft">';
 
 		if ($user->rights->fournisseur->commande->commander && $object->statut == 2)
 		{
@@ -1962,7 +1956,6 @@ elseif (! empty($object->id))
 		*/
 
 		print '</div></div></div>';
-		//print '</td></tr></table>';
 	}
 
 	/*

+ 3 - 3
htdocs/fourn/facture/fiche.php

@@ -1197,10 +1197,10 @@ if ($action == 'create')
     {
         print $form->select_company((empty($_GET['socid'])?'':$_GET['socid']),'socid','s.fournisseur = 1',1);
     }
-    print '</td>';
+    print '</td></tr>';
 
     // Ref supplier
-    print '<tr><td class="fieldrequired">'.$langs->trans('RefSupplier').'</td><td><input name="ref_supplier" value="'.(isset($_POST['ref_supplier'])?$_POST['ref_supplier']:$fac_ori->ref).'" type="text"></td>';
+    print '<tr><td class="fieldrequired">'.$langs->trans('RefSupplier').'</td><td><input name="ref_supplier" value="'.(isset($_POST['ref_supplier'])?$_POST['ref_supplier']:'').'" type="text"></td>';
     print '</tr>';
 
     print '<tr><td valign="top" class="fieldrequired">'.$langs->trans('Type').'</td><td colspan="2">';
@@ -1287,7 +1287,7 @@ if ($action == 'create')
     print '</td></tr>';
 
     // Label
-    print '<tr><td>'.$langs->trans('Label').'</td><td><input size="30" name="libelle" value="'.(isset($_POST['libelle'])?$_POST['libelle']:$fac_ori->libelle).'" type="text"></td></tr>';
+    print '<tr><td>'.$langs->trans('Label').'</td><td><input size="30" name="libelle" value="'.(isset($_POST['libelle'])?$_POST['libelle']:'').'" type="text"></td></tr>';
 
     // Date invoice
     print '<tr><td class="fieldrequired">'.$langs->trans('DateInvoice').'</td><td>';

+ 14 - 11
htdocs/fourn/facture/list.php

@@ -119,7 +119,7 @@ if ($socid)
 {
 	$sql .= " AND s.rowid = ".$socid;
 }
-if (GETPOST('filtre'))
+if (GETPOST('filtre') && GETPOST('filtre') != -1)		// GETPOST('filtre') may be a string
 {
 	$filtrearr = explode(",", GETPOST('filtre'));
 	foreach ($filtrearr as $fil)
@@ -191,15 +191,16 @@ if ($resql)
 		$soc->fetch($socid);
 	}
 
-	$param='&amp;socid='.$socid;
-	if ($month) $param.='&amp;month='.urlencode($month);
-	if ($year)  $param.='&amp;year=' .urlencode($year);
-	if (GETPOST("search_ref"))          $param.='&amp;search_ref='.urlencode(GETPOST("search_ref"));
-	if (GETPOST("search_ref_supplier")) $param.='&amp;search_ref_supplier'.urlencode(GETPOST("search_ref_supplier"));
-	if (GETPOST("search_libelle"))      $param.='&amp;search_libelle='.urlencode(GETPOST("search_libelle"));
-	if (GETPOST("search_societe"))      $param.='&amp;search_societe='.urlencode(GETPOST("search_societe"));
-	if (GETPOST("search_montant_ht"))   $param.='&amp;search_montant_ht='.urlencode(GETPOST("search_montant_ht"));
-	if (GETPOST("search_montant_ttc"))  $param.='&amp;search_montant_ttc='.urlencode(GETPOST("search_montant_ttc"));
+	$param='&socid='.$socid;
+	if ($month) $param.='&month='.urlencode($month);
+	if ($year)  $param.='&year=' .urlencode($year);
+	if (GETPOST("search_ref"))          $param.='&search_ref='.urlencode(GETPOST("search_ref"));
+	if (GETPOST("search_ref_supplier")) $param.='&search_ref_supplier'.urlencode(GETPOST("search_ref_supplier"));
+	if (GETPOST("search_libelle"))      $param.='&search_libelle='.urlencode(GETPOST("search_libelle"));
+	if (GETPOST("search_societe"))      $param.='&search_societe='.urlencode(GETPOST("search_societe"));
+	if (GETPOST("search_montant_ht"))   $param.='&search_montant_ht='.urlencode(GETPOST("search_montant_ht"));
+	if (GETPOST("search_montant_ttc"))  $param.='&search_montant_ttc='.urlencode(GETPOST("search_montant_ttc"));
+	if (GETPOST("filtre") && GETPOST('filtre') != -1) $param.='&filtre='.urlencode(GETPOST("filtre"));
 
 	print_barre_liste($langs->trans("BillsSuppliers").($socid?" $soc->nom":""),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
 	print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
@@ -242,7 +243,9 @@ if ($resql)
 	print '<input class="flat" type="text" size="8" name="search_montant_ht" value="'.GETPOST("search_montant_ht").'">';
 	print '</td><td class="liste_titre" align="right">';
 	print '<input class="flat" type="text" size="8" name="search_montant_ttc" value="'.GETPOST("search_montant_ttc").'">';
-	print '</td><td class="liste_titre" colspan="2" align="center">';
+	print '</td><td class="liste_titre" align="center">';
+	$liststatus=array('paye:0'=>$langs->trans("Unpayed"), 'paye:1'=>$langs->trans("Payed"));
+	print $form->selectarray('filtre', $liststatus, GETPOST('filtre'), 1);
 	print '<input type="image" class="liste_titre" align="right" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
 	print '</td>';
 	print "</tr>\n";

+ 1 - 1
htdocs/projet/class/task.class.php

@@ -852,7 +852,7 @@ class Task extends CommonObject
                 $this->id					= $obj->fk_task;
                 $this->timespent_date		= $obj->task_date;
                 $this->timespent_duration	= $obj->task_duration;
-                $this->timespent_user		= $obj->fk_user;
+                $this->timespent_fk_user	= $obj->fk_user;
                 $this->timespent_note		= $obj->note;
             }
 

+ 6 - 1
htdocs/projet/element.php

@@ -222,13 +222,18 @@ foreach ($listofreferent as $key => $value)
 	$classname=$value['class'];
 	$tablename=$value['table'];
 	$qualified=$value['test'];
+	
 	if ($qualified)
 	{
 		print '<br>';
 
 		print_titre($langs->trans($title));
-
+		
 		$selectList=$formproject->select_element($tablename);
+		if ($selectList<0) {
+			setEventMessage($formproject->error,'errors');
+		}
+		
 		if ($selectList)
 		{
 			print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$projectid.'" method="post">';

+ 26 - 6
htdocs/projet/fiche.php

@@ -56,7 +56,7 @@ if ($object->id > 0)
 }
 
 // Security check
-$socid=0;
+$socid=GETPOST('socid');
 if ($user->societe_id > 0) $socid=$user->societe_id;
 $result = restrictedArea($user, 'projet', $object->id);
 
@@ -384,6 +384,10 @@ if ($action == 'create' && $user->rights->projet->creer)
     /*
      * Create
      */
+
+	$thirdparty=new Societe($db);
+	if ($socid > 0) $thirdparty->fetch($socid);
+
     print_fiche_titre($langs->trans("NewProject"));
 
     dol_htmloutput_mesg($mesg);
@@ -396,12 +400,28 @@ if ($action == 'create' && $user->rights->projet->creer)
     print '<table class="border" width="100%">';
 
     $defaultref='';
-    $obj = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON;
-    if (! empty($conf->global->PROJECT_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/".$conf->global->PROJECT_ADDON.".php"))
+    $modele = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON;
+
+    // Search template files
+    $file=''; $classname=''; $filefound=0;
+    $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
+    foreach($dirmodels as $reldir)
     {
-        require_once DOL_DOCUMENT_ROOT ."/core/modules/project/".$conf->global->PROJECT_ADDON.'.php';
-        $modProject = new $obj;
-        $defaultref = $modProject->getNextValue($soc,$object);
+    	$file=dol_buildpath($reldir."core/modules/project/".$modele.'.php',0);
+    	if (file_exists($file))
+    	{
+    		$filefound=1;
+    		$classname = $modele;
+    		break;
+    	}
+    }
+
+    if ($filefound)
+    {
+	    $result=dol_include_once($reldir."core/modules/project/".$modele.'.php');
+	    $modProject = new $classname;
+
+	    $defaultref = $modProject->getNextValue($thirdparty,$object);
     }
 
     if (is_numeric($defaultref) && $defaultref <= 0) $defaultref='';