Browse Source

Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into develop

Laurent Destailleur 1 năm trước cách đây
mục cha
commit
0c3e516e57
38 tập tin đã thay đổi với 282 bổ sung185 xóa
  1. 8 2
      htdocs/admin/stock.php
  2. 2 4
      htdocs/comm/mailing/class/mailing.class.php
  3. 1 1
      htdocs/comm/propal/class/propal.class.php
  4. 30 12
      htdocs/compta/bank/class/account.class.php
  5. 1 1
      htdocs/compta/facture/class/facture.class.php
  6. 1 1
      htdocs/contrat/class/contrat.class.php
  7. 1 1
      htdocs/core/lib/reception.lib.php
  8. 1 1
      htdocs/core/lib/sendings.lib.php
  9. 4 0
      htdocs/expedition/card.php
  10. 11 16
      htdocs/expedition/class/expedition.class.php
  11. 2 0
      htdocs/expedition/class/expeditionlinebatch.class.php
  12. 129 72
      htdocs/expedition/dispatch.php
  13. 7 6
      htdocs/expedition/js/lib_dispatch.js.php
  14. 1 1
      htdocs/expensereport/class/expensereport.class.php
  15. 11 6
      htdocs/expensereport/list.php
  16. 1 1
      htdocs/fourn/class/fournisseur.commande.class.php
  17. 1 1
      htdocs/fourn/class/fournisseur.facture.class.php
  18. 4 2
      htdocs/fourn/commande/dispatch.php
  19. 3 2
      htdocs/fourn/js/lib_dispatch.js.php
  20. 6 3
      htdocs/holiday/class/holiday.class.php
  21. 1 3
      htdocs/holiday/list.php
  22. 1 1
      htdocs/knowledgemanagement/class/knowledgerecord.class.php
  23. 1 0
      htdocs/langs/en_US/receptions.lang
  24. 1 0
      htdocs/langs/en_US/sendings.lang
  25. 2 4
      htdocs/opensurvey/class/opensurveysondage.class.php
  26. 1 1
      htdocs/product/stock/class/entrepot.class.php
  27. 2 4
      htdocs/product/stock/class/productlot.class.php
  28. 3 2
      htdocs/reception/card.php
  29. 3 1
      htdocs/reception/contact.php
  30. 24 17
      htdocs/reception/dispatch.php
  31. 5 9
      htdocs/reception/note.php
  32. 1 1
      htdocs/resource/class/dolresource.class.php
  33. 1 1
      htdocs/salaries/class/salary.class.php
  34. 1 1
      htdocs/supplier_proposal/class/supplier_proposal.class.php
  35. 1 1
      htdocs/theme/eldy/global.inc.php
  36. 6 1
      htdocs/theme/md/style.css.php
  37. 2 4
      htdocs/ticket/class/ticket.class.php
  38. 1 1
      htdocs/user/card.php

+ 8 - 2
htdocs/admin/stock.php

@@ -216,6 +216,7 @@ print '</tr>'."\n";
 
 $found = 0;
 
+print '<!-- STOCK_CALCULATE_ON_BILL -->';
 print '<tr class="oddeven">';
 print '<td>'.$langs->trans("DeStockOnBill").'</td>';
 print '<td class="right">';
@@ -237,6 +238,7 @@ print "</td>\n</tr>\n";
 $found++;
 
 
+print '<!-- STOCK_CALCULATE_ON_VALIDATE_ORDER -->';
 print '<tr class="oddeven">';
 print '<td>'.$langs->trans("DeStockOnValidateOrder").'</td>';
 print '<td class="right">';
@@ -260,6 +262,7 @@ $found++;
 //if (isModEnabled('expedition'))
 //{
 
+print '<!-- STOCK_CALCULATE_ON_SHIPMENT -->';
 print '<tr class="oddeven">';
 print '<td>'.$langs->trans("DeStockOnShipment").'</td>';
 print '<td class="right">';
@@ -276,7 +279,7 @@ if (isModEnabled("expedition")) {
 print "</td>\n</tr>\n";
 $found++;
 
-
+print '<!-- STOCK_CALCULATE_ON_SHIPMENT_CLOSE -->';
 print '<tr class="oddeven">';
 print '<td>'.$langs->trans("DeStockOnShipmentOnClosing").'</td>';
 print '<td class="right">';
@@ -309,6 +312,7 @@ print '</tr>'."\n";
 
 $found = 0;
 
+print '<!-- STOCK_CALCULATE_ON_SUPPLIER_BILL -->';
 print '<tr class="oddeven">';
 print '<td>'.$langs->trans("ReStockOnBill").'</td>';
 print '<td class="right">';
@@ -330,7 +334,7 @@ print "</td>\n</tr>\n";
 $found++;
 
 
-
+print '<!-- STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER -->';
 print '<tr class="oddeven">';
 print '<td>'.$langs->trans("ReStockOnValidateOrder").'</td>';
 print '<td class="right">';
@@ -352,6 +356,7 @@ print "</td>\n</tr>\n";
 $found++;
 
 if (isModEnabled("reception")) {
+	print '<!-- STOCK_CALCULATE_ON_RECEPTION_CLOSE -->';
 	print '<tr class="oddeven">';
 	print '<td>'.$langs->trans("StockOnReception").'</td>';
 	print '<td class="right">';
@@ -380,6 +385,7 @@ if (isModEnabled("reception")) {
 	print "</td>\n</tr>\n";
 	$found++;
 } else {
+	print '<!-- STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER -->';
 	print '<tr class="oddeven">';
 	print '<td>'.$langs->trans("ReStockOnDispatchOrder").'</td>';
 	print '<td class="right">';

+ 2 - 4
htdocs/comm/mailing/class/mailing.class.php

@@ -793,9 +793,7 @@ class Mailing extends CommonObject
 	 */
 	public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
 	{
-		global $db, $conf, $langs, $hookmanager;
-		global $dolibarr_main_authentication, $dolibarr_main_demo;
-		global $menumanager;
+		global $conf, $langs, $hookmanager;
 
 		if (!empty($conf->dol_no_mouse_hover)) {
 			$notooltip = 1; // Force disable tooltips
@@ -849,7 +847,7 @@ class Mailing extends CommonObject
 
 		$result .= $linkstart;
 		if ($withpicto) {
-			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
 		}
 		if ($withpicto != 2) {
 			$result .= $this->ref;

+ 1 - 1
htdocs/comm/propal/class/propal.class.php

@@ -3882,7 +3882,7 @@ class Propal extends CommonObject
 
 		$result .= $linkstart;
 		if ($withpicto) {
-			$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
 		}
 		if ($withpicto != 2) {
 			$result .= $this->ref;

+ 30 - 12
htdocs/compta/bank/class/account.class.php

@@ -1465,11 +1465,16 @@ class Account extends CommonObject
 	 *  @param  string  $option         			''=Show ref, 'reflabel'=Show ref+label
 	 *  @param  int     $save_lastsearch_value    	-1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
 	 *  @param	int  	$notooltip		 			1=Disable tooltip
+	 *  @param  string  $morecss                    Add more css on link
 	 *	@return	string								Chaine avec URL
 	 */
-	public function getNomUrl($withpicto = 0, $mode = '', $option = '', $save_lastsearch_value = -1, $notooltip = 0)
+	public function getNomUrl($withpicto = 0, $mode = '', $option = '', $save_lastsearch_value = -1, $notooltip = 0, $morecss = '')
 	{
-		global $conf, $langs, $user;
+		global $conf, $langs;
+
+		if (!empty($conf->dol_no_mouse_hover)) {
+			$notooltip = 1; // Force disable tooltips
+		}
 
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
 
@@ -1490,10 +1495,6 @@ class Account extends CommonObject
 			$label = implode($this->getTooltipContentArray($params));
 		}
 
-		$linkclose = '';
-		$linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' :  ' title="tocomplete"');
-		$linkclose .= $dataparams.' class="'.$classfortooltip.'">';
-
 		$url = DOL_URL_ROOT.'/compta/bank/card.php?id='.$this->id;
 		if ($mode == 'transactions') {
 			$url = DOL_URL_ROOT.'/compta/bank/bankentries_list.php?id='.$this->id;
@@ -1512,17 +1513,34 @@ class Account extends CommonObject
 			}
 		}
 
-		$linkstart = '<a href="'.$url.'"'.$linkclose;
-		$linkend = '</a>';
+		$linkclose = '';
+		if (empty($notooltip)) {
+			if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER')) {
+				$label = $langs->trans("BankAccount");
+				$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
+			}
+			$linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' :  ' title="tocomplete"');
+			$linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
+		} else {
+			$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+		}
 
-		if ($option == 'nolink') {
-			$linkstart = '';
-			$linkend = '';
+		if ($option == 'nolink' || empty($url)) {
+			$linkstart = '<span';
+		} else {
+			$linkstart = '<a href="'.$url.'"';
+		}
+		$linkstart .= $linkclose.'>';
+		if ($option == 'nolink' || empty($url)) {
+			$linkend = '</span>';
+		} else {
+			$linkend = '</a>';
 		}
 
 		$result .= $linkstart;
+
 		if ($withpicto) {
-			$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
 		}
 		if ($withpicto != 2) {
 			$result .= $this->ref.($option == 'reflabel' && $this->label ? ' - '.$this->label : '');

+ 1 - 1
htdocs/compta/facture/class/facture.class.php

@@ -2071,7 +2071,7 @@ class Facture extends CommonInvoice
 
 		$result .= $linkstart;
 		if ($withpicto) {
-			$result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
 		}
 		if ($withpicto != 2) {
 			$result .= ($max ?dol_trunc($this->ref, $max) : $this->ref);

+ 1 - 1
htdocs/contrat/class/contrat.class.php

@@ -2119,7 +2119,7 @@ class Contrat extends CommonObject
 
 		$result .= $linkstart;
 		if ($withpicto) {
-			$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
 		}
 		if ($withpicto != 2) {
 			$result .= ($this->ref ? $this->ref : $this->id);

+ 1 - 1
htdocs/core/lib/reception.lib.php

@@ -46,7 +46,7 @@ function reception_prepare_head(Reception $object)
 	$head[$h][2] = 'reception';
 	$h++;
 
-	if ($object->statut ==  Reception::STATUS_DRAFT) {
+	if ($object->statut ==  Reception::STATUS_DRAFT || ($object->statut == Reception::STATUS_VALIDATED && empty($conf->global->STOCK_CALCULATE_ON_RECEPTION))) {
 		$head[$h][0] = DOL_URL_ROOT."/reception/dispatch.php?id=".$object->id;
 		$head[$h][1] = $langs->trans("ReceptionDistribution");
 		$head[$h][2] = 'dispatch';

+ 1 - 1
htdocs/core/lib/sendings.lib.php

@@ -47,7 +47,7 @@ function shipping_prepare_head($object)
 	$head[$h][2] = 'shipping';
 	$h++;
 
-	if ($object->statut ==  Expedition::STATUS_DRAFT) {
+	if ($object->statut == Expedition::STATUS_DRAFT) {
 		$head[$h][0] = DOL_URL_ROOT."/expedition/dispatch.php?id=".$object->id;
 		$head[$h][1] = $langs->trans("ShipmentDistribution");
 		$head[$h][2] = 'dispatch';

+ 4 - 0
htdocs/expedition/card.php

@@ -2541,6 +2541,10 @@ if ($action == 'create') {
 
 	// TODO Show also lines ordered but not delivered
 
+	if (empty($num_prod)) {
+		print '<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans("NoLineGoOnTabToAddSome", $langs->transnoentitiesnoconv("ShipmentDistribution")).'</span></td></tr>';
+	}
+
 	print "</table>\n";
 	print '</tbody>';
 	print '</div>';

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

@@ -754,7 +754,7 @@ class Expedition extends CommonObject
 
 		// If stock increment is done on sending (recommanded choice)
 		if (!$error && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) {
-			$result = $this->manageStockMvtOnEvt($user);
+			$result = $this->manageStockMvtOnEvt($user, "ShipmentValidatedInDolibarr");
 			if ($result < 0) {
 				return -2;
 			}
@@ -1088,14 +1088,11 @@ class Expedition extends CommonObject
 			$this->model_pdf = trim($this->model_pdf);
 		}
 
-
-
 		// Check parameters
 		// Put here code to add control on parameters values
 
 		// Update request
 		$sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET";
-
 		$sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").",";
 		$sql .= " ref_ext=".(isset($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null").",";
 		$sql .= " ref_customer=".(isset($this->ref_customer) ? "'".$this->db->escape($this->ref_customer)."'" : "null").",";
@@ -1121,7 +1118,6 @@ class Expedition extends CommonObject
 		$sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").",";
 		$sql .= " model_pdf=".(isset($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null").",";
 		$sql .= " entity=".$conf->entity;
-
 		$sql .= " WHERE rowid=".((int) $this->id);
 
 		$this->db->begin();
@@ -1593,11 +1589,12 @@ class Expedition extends CommonObject
 			while ($i < $num) {
 				$obj = $this->db->fetch_object($resql);
 
+
 				if ($originline > 0 && $originline == $obj->fk_origin_line) {
 					$line->entrepot_id = 0; // entrepod_id in details_entrepot
 					$line->qty_shipped += $obj->qty_shipped;
 				} else {
-					$line = new ExpeditionLigne($this->db);
+					$line = new ExpeditionLigne($this->db);		// new group to start
 					$line->entrepot_id    	= $obj->fk_entrepot;	// this is a property of a shipment line
 					$line->qty_shipped    	= $obj->qty_shipped;	// this is a property of a shipment line
 				}
@@ -1855,7 +1852,7 @@ class Expedition extends CommonObject
 
 		$result .= $linkstart;
 		if ($withpicto) {
-			$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
 		}
 		if ($withpicto != 2) {
 			$result .= $this->ref;
@@ -2192,12 +2189,14 @@ class Expedition extends CommonObject
 
 	/**
 	 * Manage Stock MVt onb Close or valid Shipment
-	 * @param      User 	$user        		Object user that modify
-	 * @return     int     <0 if ko, >0 if ok
+	 *
+	 * @param      	User 	$user        		Object user that modify
+	 * @param		string	$labelmovement		Label of movement
+	 * @return     	int     					<0 if KO, >0 if OK
 	 * @throws Exception
 	 *
 	 */
-	private function manageStockMvtOnEvt($user)
+	private function manageStockMvtOnEvt($user, $labelmovement = 'ShipmentClassifyClosedInDolibarr')
 	{
 		global $langs;
 
@@ -2244,7 +2243,7 @@ class Expedition extends CommonObject
 					// line without batch detail
 
 					// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record
-					$result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr", $obj->ref));
+					$result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans($labelmovement, $obj->ref));
 					if ($result < 0) {
 						$this->error = $mouvS->error;
 						$this->errors = $mouvS->errors;
@@ -2255,7 +2254,7 @@ class Expedition extends CommonObject
 					// line with batch detail
 
 					// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record
-					$result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr", $obj->ref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock);
+					$result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans($labelmovement, $obj->ref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock);
 					if ($result < 0) {
 						$this->error = $mouvS->error;
 						$this->errors = $mouvS->errors;
@@ -2829,8 +2828,6 @@ class ExpeditionLigne extends CommonObjectLine
 	 */
 	public function delete($user = null, $notrigger = 0)
 	{
-		global $conf;
-
 		$error = 0;
 
 		$this->db->begin();
@@ -2894,8 +2891,6 @@ class ExpeditionLigne extends CommonObjectLine
 	 */
 	public function update($user = null, $notrigger = 0)
 	{
-		global $conf;
-
 		$error = 0;
 
 		dol_syslog(get_class($this)."::update id=$this->id, entrepot_id=$this->entrepot_id, product_id=$this->fk_product, qty=$this->qty");

+ 2 - 0
htdocs/expedition/class/expeditionlinebatch.class.php

@@ -45,6 +45,7 @@ class ExpeditionLineBatch extends CommonObject
 	public $dluo_qty; // deprecated, use qty
 	public $entrepot_id;
 	public $fk_origin_stock;		// rowid in llx_product_batch table
+	public $fk_warehouse;			// for future use in v19
 	public $fk_expeditiondet;
 
 
@@ -123,6 +124,7 @@ class ExpeditionLineBatch extends CommonObject
 		$sql .= ", batch";
 		$sql .= ", qty";
 		$sql .= ", fk_origin_stock";
+		// TODO Add fk_warehouse here
 		$sql .= ") VALUES (";
 		$sql .= $id_line_expdet.",";
 		$sql .= " ".(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : ("'".$this->db->idate($this->sellby))."'").",";

+ 129 - 72
htdocs/expedition/dispatch.php

@@ -25,9 +25,9 @@
  */
 
 /**
- * \file htdocs/expedition/dispatch.php
+ * \file 	htdocs/expedition/dispatch.php
  * \ingroup expedition
- * \brief Page to dispatch shipments
+ * \brief 	Page to dispatch shipments
  */
 
 // Load Dolibarr environment
@@ -60,6 +60,9 @@ $fk_default_warehouse = GETPOST('fk_default_warehouse', 'int');
 $cancel = GETPOST('cancel', 'alpha');
 $confirm = GETPOST('confirm', 'alpha');
 
+$error = 0;
+$errors = array();
+
 if ($user->socid) {
 	$socid = $user->socid;
 }
@@ -75,6 +78,7 @@ if (GETPOSTISSET("projectid")) {
 $object = new Expedition($db);
 $objectorder = new Commande($db);
 
+
 if ($id > 0 || !empty($ref)) {
 	$result = $object->fetch($id, $ref);
 	if ($result <= 0) {
@@ -96,7 +100,7 @@ if ($id > 0 || !empty($ref)) {
 $result = restrictedArea($user, 'expedition', $object, '');
 
 if (!isModEnabled('stock')) {
-	accessforbidden();
+	accessforbidden('Module stock disabled');
 }
 
 $usercancreate = $user->hasRight('expedition', 'creer');
@@ -148,46 +152,53 @@ if ($action == 'updatelines' && $usercancreate) {
 			$lot = '';
 			$dDLUO = '';
 			$dDLC = '';
-			if ($modebatch == "batch") { //TODO: Make impossible to input non existing batchcode
+			if ($modebatch == "batch") { //TODO: Make impossible to input non existing batch code
 				$lot = GETPOST('lot_number_'.$reg[1].'_'.$reg[2]);
 				$dDLUO = dol_mktime(12, 0, 0, GETPOST('dluo_'.$reg[1].'_'.$reg[2].'month', 'int'), GETPOST('dluo_'.$reg[1].'_'.$reg[2].'day', 'int'), GETPOST('dluo_'.$reg[1].'_'.$reg[2].'year', 'int'));
 				$dDLC = dol_mktime(12, 0, 0, GETPOST('dlc_'.$reg[1].'_'.$reg[2].'month', 'int'), GETPOST('dlc_'.$reg[1].'_'.$reg[2].'day', 'int'), GETPOST('dlc_'.$reg[1].'_'.$reg[2].'year', 'int'));
 			}
 
+			$newqty = price2num(GETPOST($qty, 'alpha'), 'MS');
+
 			// We ask to move a qty
-			if (($modebatch == "batch" && GETPOST($qty) > 0) || ($modebatch == "barcode" && GETPOST($qty) != 0)) {
-				if (!(GETPOST($ent, 'int') > 0)) {
-					dol_syslog('No dispatch for line '.$key.' as no warehouse was chosen.');
-					$text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' '.($numline);
-					setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
-					$error++;
-				}
-				if ($modebatch == "batch") {
-					$sql = "SELECT pb.rowid ";
-					$sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb";
-					$sql .= " JOIN ".MAIN_DB_PREFIX."product_stock as ps";
-					$sql .= " ON ps.rowid = pb.fk_product_stock";
-					$sql .= " WHERE pb.batch ='".$db->escape($lot)."'";
-					$sql .= " AND ps.fk_product =".((int) GETPOST($prod, 'int')) ;
-					$sql .= " AND ps.fk_entrepot =".((int) GETPOST($ent, 'int')) ;
-					$resql = $db->query($sql);
-					if ($resql) {
-						$num = $db->num_rows($resql);
-						if ($num > 1) {
-							dol_syslog('No dispatch for line '.$key.' as too many combination warehouse, product, batch code was found ('.$num.').');
-							setEventMessages($langs->trans('ErrorTooManyCombinationBatchcode', $numline, $num), null, 'errors');
-							$error++;
-						} elseif ($num < 1) {
-							dol_syslog('No dispatch for line '.$key.' as no combination warehouse, product, batch code was found.');
-							setEventMessages($langs->trans('ErrorNoCombinationBatchcode', $numline), null, 'errors');
-							$error++;
+			if (($modebatch == "batch" && $newqty >= 0) || ($modebatch == "barcode" && $newqty != 0)) {
+				if ($newqty > 0) {	// If we want a qty, we make test on input data
+					if (!(GETPOST($ent, 'int') > 0)) {
+						dol_syslog('No dispatch for line '.$key.' as no warehouse was chosen.');
+						$text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' '.($numline);
+						setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
+						$error++;
+					}
+					if (!$error && $modebatch == "batch") {
+						$sql = "SELECT pb.rowid ";
+						$sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb";
+						$sql .= " JOIN ".MAIN_DB_PREFIX."product_stock as ps";
+						$sql .= " ON ps.rowid = pb.fk_product_stock";
+						$sql .= " WHERE pb.batch = '".$db->escape($lot)."'";
+						$sql .= " AND ps.fk_product = ".((int) GETPOST($prod, 'int')) ;
+						$sql .= " AND ps.fk_entrepot = ".((int) GETPOST($ent, 'int')) ;
+
+						$resql = $db->query($sql);
+						if ($resql) {
+							$num = $db->num_rows($resql);
+							if ($num > 1) {
+								dol_syslog('No dispatch for line '.$key.' as too many combination warehouse, product, batch code was found ('.$num.').');
+								setEventMessages($langs->trans('ErrorTooManyCombinationBatchcode', $numline, $num), null, 'errors');
+								$error++;
+							} elseif ($num < 1) {
+								dol_syslog('No dispatch for line '.$key.' as no combination warehouse, product, batch code was found.');
+								setEventMessages($langs->trans('ErrorNoCombinationBatchcode', $numline), null, 'errors');
+								$error++;
+							}
+							$db->free($resql);
 						}
-						$db->free($resql);
 					}
 				}
+				//var_dump($key.' '.$newqty.' '.$idline.' '.$error);
 
 				if (!$error) {
 					$qtystart = 0;
+
 					if ($idline > 0) {
 						$result = $expeditiondispatch->fetch($idline);
 						if ($result < 0) {
@@ -195,22 +206,38 @@ if ($action == 'updatelines' && $usercancreate) {
 							$error++;
 						} else {
 							$qtystart = $expeditiondispatch->qty;
-							$expeditiondispatch->qty = GETPOST($qty);
+							$expeditiondispatch->qty = $newqty;
 							$expeditiondispatch->entrepot_id = GETPOST($ent, 'int');
 
-							$result = $expeditiondispatch->update($user);
+							if ($newqty > 0) {
+								$result = $expeditiondispatch->update($user);
+							} else {
+								$result = $expeditiondispatch->delete($user);
+							}
 							if ($result < 0) {
 								setEventMessages($expeditiondispatch->error, $expeditiondispatch->errors, 'errors');
 								$error++;
 							}
 
 							if (!$error && $modebatch == "batch") {
-								$sql = "UPDATE ".MAIN_DB_PREFIX.$expeditionlinebatch->table_element." SET";
-								$sql .= " eatby = ".($eatby ? "'".$db->idate($eatby)."'" : "null");
-								$sql .= " , sellby = ".($sellby ? "'".$db->idate($sellby)."'" : "null");
-								$sql .= " , qty = ".((float) price2num(GETPOST($qty, 'int'), 'MS'));
-								$sql .= " WHERE fk_expeditiondet = ".((int) $idline);
-								$sql .= " AND batch = ".((int) $idline);
+								if ($newqty > 0) {
+									$suffixkeyfordate = preg_replace('/^product_batch/', '', $key);
+									$sellby = dol_mktime(0, 0, 0, GETPOST('dlc'.$suffixkeyfordate.'month'), GETPOST('dlc'.$suffixkeyfordate.'day'), GETPOST('dlc'.$suffixkeyfordate.'year'), '');
+									$eatby = dol_mktime(0, 0, 0, GETPOST('dluo'.$suffixkeyfordate.'month'), GETPOST('dluo'.$suffixkeyfordate.'day'), GETPOST('dluo'.$suffixkeyfordate.'year'));
+
+									$sql = "UPDATE ".MAIN_DB_PREFIX.$expeditionlinebatch->table_element." SET";
+									$sql .= " eatby = ".($eatby ? "'".$db->idate($eatby)."'" : "null");
+									$sql .= " , sellby = ".($sellby ? "'".$db->idate($sellby)."'" : "null");
+									$sql .= " , qty = ".((float) $newqty);
+									// TODO Add a column fk_warehouse
+									$sql .= " WHERE fk_expeditiondet = ".((int) $idline);
+									$sql .= " AND batch = '".$db->escape($lot)."'";
+								} else {
+									$sql = " DELETE FROM ".MAIN_DB_PREFIX.$expeditionlinebatch->table_element;
+									$sql .= " WHERE fk_expeditiondet = ".((int) $idline);
+									$sql .= " AND batch = '".$db->escape($lot)."'";
+								}
+
 								$resql = $db->query($sql);
 								if (!$db->query($sql)) {
 									dol_print_error($db);
@@ -222,34 +249,40 @@ if ($action == 'updatelines' && $usercancreate) {
 						$expeditiondispatch->fk_expedition = $object->id;
 						$expeditiondispatch->entrepot_id = GETPOST($ent, 'int');
 						$expeditiondispatch->fk_origin_line = GETPOST($fk_commandedet, 'int');
-						$expeditiondispatch->qty = GETPOST($qty, 'int');
-						$idline = $expeditiondispatch->insert($user);
-						if ($idline < 0) {
-							setEventMessages($expeditiondispatch->error, $expeditiondispatch->errors, 'errors');
-							$error++;
-						}
+						$expeditiondispatch->qty = $newqty;
 
-						if ($modebatch == "batch" && !$error) {
-							$expeditionlinebatch->sellby = $dDLUO;
-							$expeditionlinebatch->eatby = $dDLC;
-							$expeditionlinebatch->batch = $lot;
-							$expeditionlinebatch->qty = GETPOST($qty, 'int');
-							$expeditionlinebatch->fk_origin_stock = 0;
-							$result = $expeditionlinebatch->create($idline);
-							if ($result < 0) {
-								setEventMessages($expeditionlinebatch->error, $expeditionlinebatch->errors, 'errors');
+						if ($newqty > 0) {
+							$idline = $expeditiondispatch->insert($user);
+							if ($idline < 0) {
+								setEventMessages($expeditiondispatch->error, $expeditiondispatch->errors, 'errors');
 								$error++;
 							}
+
+							if ($modebatch == "batch" && !$error) {
+								$expeditionlinebatch->sellby = $dDLUO;
+								$expeditionlinebatch->eatby = $dDLC;
+								$expeditionlinebatch->batch = $lot;
+								$expeditionlinebatch->qty = $newqty;
+								$expeditionlinebatch->fk_origin_stock = 0;
+								$expeditionlinebatch->fk_warehouse = GETPOST($ent, 'int');
+
+								$result = $expeditionlinebatch->create($idline);
+								if ($result < 0) {
+									setEventMessages($expeditionlinebatch->error, $expeditionlinebatch->errors, 'errors');
+									$error++;
+								}
+							}
 						}
 					}
 
-					// If module stock is enabled and the stock increase is done on purchase order dispatching
-					if (!$error && GETPOST($ent, 'int') > 0 && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) {
+					// If module stock is enabled and the stock decrease is done on edtion of this page
+					/*
+					if (!$error && GETPOST($ent, 'int') > 0 && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_DISPATCH_ORDER)) {
 						$mouv = new MouvementStock($db);
 						$product = GETPOST($prod, 'int');
 						$entrepot = GETPOST($ent, 'int');
-						$qtymouv = GETPOST($qty) - $qtystart;
-						$price = GETPOST($pu);
+						$qtymouv = price2num(GETPOST($qty, 'alpha'), 'MS') - $qtystart;
+						$price = price2num(GETPOST($pu), 'MU');
 						$comment = GETPOST('comment');
 						$inventorycode = dol_print_date(dol_now(), 'dayhourlog');
 						$now = dol_now();
@@ -279,6 +312,7 @@ if ($action == 'updatelines' && $usercancreate) {
 							}
 						}
 					}
+					*/
 				}
 			}
 		}
@@ -289,6 +323,9 @@ if ($action == 'updatelines' && $usercancreate) {
 	} else {
 		$db->commit();
 		setEventMessages($langs->trans("ReceptionUpdated"), null);
+
+		header("Location: ".DOL_URL_ROOT.'/expedition/dispatch.php?id='.$object->id);
+		exit;
 	}
 } elseif ($action == 'setdate_livraison' && $usercancreate) {
 	$datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int'));
@@ -318,7 +355,8 @@ $morejs = array('/expedition/js/lib_dispatch.js.php');
 llxHeader('', $title, $help_url, '', 0, 0, $morejs);
 
 if ($object->id > 0 || !empty($object->ref)) {
-	$lines = $object->lines;
+	$lines = $object->lines;	// This is an array of detail of line, on line per source order line found intolines[]->fk_origin_line, then each line may have sub data
+	//var_dump($lines[0]->fk_origin_line); exit;
 
 	$num_prod = count($lines);
 
@@ -465,7 +503,7 @@ if ($object->id > 0 || !empty($object->ref)) {
 	print '<br>';
 	$disabled = 0;	// This is used to disable or not the bulk selection of target warehouse. No reason to have it disabled so forced to 0.
 
-	if ($object->statut == Reception::STATUS_DRAFT) {
+	if ($object->statut == Expedition::STATUS_DRAFT) {
 		require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
 		$formproduct = new FormProduct($db);
 		$formproduct->loadWarehouses();
@@ -482,7 +520,7 @@ if ($object->id > 0 || !empty($object->ref)) {
 		print '<div class="div-table-responsive-no-min">';
 		print '<table class="noborder centpercent">';
 
-		// Get list of lines from the shipments $products_dispatched with qty dispatched for each product id
+		// Get list of lines of the shipment $products_dispatched, with qty dispatched for each product id
 		$products_dispatched = array();
 		$sql = "SELECT ed.fk_origin_line as rowid, sum(ed.qty) as qty";
 		$sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed";
@@ -503,6 +541,7 @@ if ($object->id > 0 || !empty($object->ref)) {
 			}
 			$db->free($resql);
 		}
+
 		//$sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, SUM(l.qty) as qty,";
 		$sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, '' AS sref, l.qty as qty,";
 		$sql .= " p.ref, p.label, p.tobatch, p.fk_default_warehouse";
@@ -565,8 +604,12 @@ if ($object->id > 0 || !empty($object->ref)) {
 					print '<td></td>';
 				}
 				print '<td class="right">'.$langs->trans("QtyOrdered").'</td>';
-				print '<td class="right">'.$langs->trans("QtyDispatchedShort").'</td>';
-				print ' <td class="right">'.$langs->trans("QtyToDispatchShort");
+				if ($object->status == Expedition::STATUS_DRAFT) {
+					print '<td class="right">'.$langs->trans("QtyToDispatchShort");	// Qty to dispatch (sum for all lines of batch detail if there is)
+				} else {
+					print '<td class="right">'.$langs->trans("QtyDispatchedShort").'</td>';
+				}
+				print '<td class="right">'.$langs->trans("QtyToDispatchShort");
 				print '<td width="32"></td>';
 
 				if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
@@ -610,6 +653,7 @@ if ($object->id > 0 || !empty($object->ref)) {
 
 			$conf->cache['product'] = array();
 
+			// Loop on each line of origin order
 			while ($i < $num) {
 				$objp = $db->fetch_object($resql);
 
@@ -754,8 +798,8 @@ if ($object->id > 0 || !empty($object->ref)) {
 									print '</td>';
 
 									print '<td>';
-									print '<input disabled="" type="text" class="inputlotnumber quatrevingtquinzepercent" id="lot_number'.$suffix.'" name="lot_number'.$suffix.'" value="'.$objd->batch.'">';
-									//print '<input type="hidden" class="inputlotnumber quatrevingtquinzepercent" id="lot_number'.$suffix.'" name="lot_number'.$suffix.'" value="'.$objd->batch.'">';
+									print '<input type="text" class="inputlotnumber quatrevingtquinzepercent" id="lot_number'.$suffix.'" name="lot_number'.$suffix.'" value="'.$objd->batch.'">';
+									//print '<input type="hidden" id="lot_number'.$suffix.'" name="lot_number'.$suffix.'" value="'.$objd->batch.'">';
 									print '</td>';
 									if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
 										print '<td class="nowraponall">';
@@ -809,8 +853,10 @@ if ($object->id > 0 || !empty($object->ref)) {
 								}
 								// Qty to dispatch
 								print '<td class="right">';
-								print '<a href="#" id="reset'.$suffix.'" class="resetline">'.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').'</a>';
-								print '<input id="qty'.$suffix.'" onchange="onChangeDispatchLineQty($(this))" name="qty'.$suffix.'" data-type="'.$type.'" data-index="'.$i.'" class="width50 right qtydispatchinput" value="'.(GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : $objd->qty).'" data-expected="'.$objd->qty.'">';
+								print '<a href="" id="reset'.$suffix.'" class="resetline">'.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').'</a>';
+								$suggestedvalue = (GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : $objd->qty);
+								//var_dump($suggestedvalue);exit;
+								print '<input id="qty'.$suffix.'" onchange="onChangeDispatchLineQty($(this))" name="qty'.$suffix.'" data-type="'.$type.'" data-index="'.$i.'" class="width50 right qtydispatchinput" value="'.$suggestedvalue.'" data-expected="'.$objd->qty.'">';
 								print '</td>';
 								print '<td>';
 								if (isModEnabled('productbatch') && $objp->tobatch > 0) {
@@ -953,8 +999,14 @@ if ($object->id > 0 || !empty($object->ref)) {
 							}
 							// Qty to dispatch
 							print '<td class="right">';
-							print '<a href="#" id="reset'.$suffix.'" class="resetline">'.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').'</a>';
-							print '<input id="qty'.$suffix.'" onchange="onChangeDispatchLineQty($(this))" name="qty'.$suffix.'" data-index="'.$i.'" data-type="text" class="width50 right qtydispatchinput" value="'.(GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : (empty($conf->global->SUPPLIER_ORDER_DISPATCH_FORCE_QTY_INPUT_TO_ZERO) ? $remaintodispatch : 0)).'" data-expected="'.$remaintodispatch.'">';
+							print '<a href="" id="reset'.$suffix.'" class="resetline">'.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').'</a>';
+							$amounttosuggest = (GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : (empty($conf->global->SUPPLIER_ORDER_DISPATCH_FORCE_QTY_INPUT_TO_ZERO) ? $remaintodispatch : 0));
+							if (count($products_dispatched)) {
+								// There is already existing lines into llx_expeditiondet, this means a plan for the shipment has already been started.
+								// In such a case, we do not suggest new values, we suggest the value known.
+								$amounttosuggest = (GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : (isset($products_dispatched[$objp->rowid]) ? $products_dispatched[$objp->rowid] : ''));
+							}
+							print '<input id="qty'.$suffix.'" onchange="onChangeDispatchLineQty($(this))" name="qty'.$suffix.'" data-index="'.$i.'" data-type="text" class="width50 right qtydispatchinput" value="'.$amounttosuggest.'" data-expected="'.$amounttosuggest.'">';
 							print '</td>';
 							print '<td>';
 							if (isModEnabled('productbatch') && $objp->tobatch > 0) {
@@ -1011,14 +1063,14 @@ if ($object->id > 0 || !empty($object->ref)) {
 		print '</div>';
 
 		if ($nbproduct) {
-			$checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll'));
+			//$checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll'));
 
 			print '<div class="center">';
 			$parameters = array();
 			$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
 			// modified by hook
 			if (empty($reshook)) {
-				if (empty($conf->reception->enabled)) {
+				/*if (empty($conf->reception->enabled)) {
 					print $langs->trans("Comment").' : ';
 					print '<input type="text" class="minwidth400" maxlength="128" name="comment" value="';
 					print GETPOSTISSET("comment") ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $object->ref);
@@ -1031,6 +1083,8 @@ if ($object->id > 0 || !empty($object->ref)) {
 				$dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive") : $langs->trans("CreateReception");
 
 				print '<br>';
+				*/
+
 				print '<input type="submit" id="submitform" class="button" name="dispatch" value="'.$langs->trans("Save").'"';
 				$disabled = 0;
 				if (!$usercancreate) {
@@ -1067,11 +1121,13 @@ if ($object->id > 0 || !empty($object->ref)) {
 	print '<script type="text/javascript">
 		$(document).ready(function () {
 			$("select[name=fk_default_warehouse]").change(function() {
+				console.log("warehouse is modified");
 				var fk_default_warehouse = $("option:selected", this).val();
 				$("select[name^=entrepot_]").val(fk_default_warehouse).change();
 			});
 
 			$("#autoreset").click(function() {
+				console.log("we click on autoreset");
 				$(".autoresettr").each(function(){
 					id = $(this).attr("name");
 					idtab = id.split("_");
@@ -1102,7 +1158,8 @@ if ($object->id > 0 || !empty($object->ref)) {
 				return false;
 			});
 
-			$(".resetline").click(function(){
+			$(".resetline").on("click", function(event) {
+				event.preventDefault();
 				id = $(this).attr("id");
 				id = id.split("reset_");
 				console.log("Reset trigger for id = qty_"+id[1]);

+ 7 - 6
htdocs/expedition/js/lib_dispatch.js.php

@@ -68,7 +68,7 @@ if (empty($dolibarr_nocache)) {
 function addDispatchLine(index, type, mode) {
 	mode = mode || 'qtymissing'
 
-	console.log("fourn/js/lib_dispatch.js.php addDispatchLine Split line type="+type+" index="+index+" mode="+mode);
+	console.log("expedition/js/lib_dispatch.js.php addDispatchLine Split line type="+type+" index="+index+" mode="+mode);
 
 	var $row0 = $("tr[name='"+type+'_0_'+index+"']");
 	var $dpopt = $row0.find('.hasDatepicker').first().datepicker('option', 'all'); // get current datepicker options to apply the same to the cloned datepickers
@@ -81,7 +81,7 @@ function addDispatchLine(index, type, mode) {
 		qty = '';
 	}
 
-	console.log("fourn/js/lib_dispatch.js.php addDispatchLine Split line nbrTrs="+nbrTrs+" qtyOrdered="+qtyOrdered+" qty="+qty);
+	console.log("expedition/js/lib_dispatch.js.php addDispatchLine Split line nbrTrs="+nbrTrs+" qtyOrdered="+qtyOrdered+" qty="+qty);
 
 	var	qtyDispatched;
 
@@ -96,7 +96,7 @@ function addDispatchLine(index, type, mode) {
 			mode = 'lessone';
 		}
 	}
-	console.log("qtyDispatched=" + qtyDispatched + " qtyOrdered=" + qtyOrdered+ " qty=" + qty);
+	console.log("expedition/js/lib_dispatch.js.php qtyDispatched=" + qtyDispatched + " qtyOrdered=" + qtyOrdered+ " qty=" + qty);
 
 	if (qty <= 1) {
 		window.alert("Remain quantity to dispatch is too low to be split");
@@ -146,17 +146,18 @@ function addDispatchLine(index, type, mode) {
 		$("tr[name^='" + type + "_'][name$='_" + index + "'] .splitbutton").hide();
 		$("tr[name^='" + type + "_'][name$='_" + index + "']:last .splitbutton").show();
 
-		$("#reset_" + (nbrTrs) + "_" + index).click(function () {
+		$("#reset_" + (nbrTrs) + "_" + index).click(function (event) {
+			event.preventDefault();
 			id = $(this).attr("id");
 			id = id.split("reset_");
 			idrow = id[1];
 			idlast = $("tr[name^='" + type + "_'][name$='_" + index + "']:last .qtydispatchinput").attr("id");
 			if (idlast == $("#qty_" + idrow).attr("id")) {
-				console.log("Remove trigger for tr name = " + type + "_" + idrow);
+				console.log("expedition/js/lib_dispatch.js.php Remove trigger for tr name = " + type + "_" + idrow);
 				$('tr[name="' + type + '_' + idrow + '"').remove();
 				$("tr[name^='" + type + "_'][name$='_" + index + "']:last .splitbutton").show();
 			} else {
-				console.log("fourn/js/lib_dispatch.js.php Reset trigger for id = #qty_" + idrow);
+				console.log("expedition/js/lib_dispatch.js.php Reset trigger for id = qty_" + idrow);
 				$("#qty_" + idrow).val("");
 			}
 		});

+ 1 - 1
htdocs/expensereport/class/expensereport.class.php

@@ -1807,7 +1807,7 @@ class ExpenseReport extends CommonObject
 
 		$result .= $linkstart;
 		if ($withpicto) {
-			$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
 		}
 		if ($withpicto != 2) {
 			$result .= ($max ? dol_trunc($ref, $max) : $ref);

+ 11 - 6
htdocs/expensereport/list.php

@@ -798,6 +798,9 @@ if ($resql) {
 						print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
 					}
 					print '</td>';
+					if (!$i) {
+						$totalarray['nbfield']++;
+					}
 				}
 				// Ref
 				if (!empty($arrayfields['d.ref']['checked'])) {
@@ -953,16 +956,18 @@ if ($resql) {
 						print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
 					}
 					print '</td>';
-				}
-				if (!$i) {
-					$totalarray['nbfield']++;
+					if (!$i) {
+						$totalarray['nbfield']++;
+					}
 				}
 
 				print "</tr>\n";
 			}
-				$total_total_ht = $total_total_ht + $obj->total_ht;
-				$total_total_tva = $total_total_tva + $obj->total_tva;
-				$total_total_ttc = $total_total_ttc + $obj->total_ttc;
+
+			$total_total_ht = $total_total_ht + $obj->total_ht;
+			$total_total_tva = $total_total_tva + $obj->total_tva;
+			$total_total_ttc = $total_total_ttc + $obj->total_ttc;
+
 			$i++;
 		}
 	} else {

+ 1 - 1
htdocs/fourn/class/fournisseur.commande.class.php

@@ -963,7 +963,7 @@ class CommandeFournisseur extends CommonOrder
 
 		$result .= $linkstart;
 		if ($withpicto) {
-			$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
 		}
 		if ($withpicto != 2) {
 			$result .= $this->ref;

+ 1 - 1
htdocs/fourn/class/fournisseur.facture.class.php

@@ -2888,7 +2888,7 @@ class FactureFournisseur extends CommonInvoice
 
 		$result .= $linkstart;
 		if ($withpicto) {
-			$result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
 		}
 		if ($withpicto != 2) {
 			$result .= ($max ?dol_trunc($ref, $max) : $ref);

+ 4 - 2
htdocs/fourn/commande/dispatch.php

@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2004-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2016 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2004-2023 Laurent Destailleur  <eldy@users.sourceforge.net>
  * Copyright (C) 2005      Eric Seigne          <eric.seigne@ryxeo.com>
  * Copyright (C) 2005-2009 Regis Houssin        <regis.houssin@inodbox.com>
  * Copyright (C) 2010-2021 Juanjo Menent        <jmenent@2byte.es>
@@ -51,7 +51,7 @@ if (isModEnabled('productbatch')) {
 	$langs->load('productbatch');
 }
 
-	// Security check
+// Security check
 $id = GETPOST("id", 'int');
 $ref = GETPOST('ref');
 $lineid = GETPOST('lineid', 'int');
@@ -381,6 +381,8 @@ if ($action == 'dispatch' && $permissiontoreceive) {
 	if ($result >= 0 && !$error) {
 		$db->commit();
 
+		setEventMessages($langs->trans("ReceptionsRecorded"), null, 'mesgs');
+
 		header("Location: dispatch.php?id=".$id);
 		exit();
 	} else {

+ 3 - 2
htdocs/fourn/js/lib_dispatch.js.php

@@ -146,7 +146,8 @@ function addDispatchLine(index, type, mode) {
 		$("tr[name^='" + type + "_'][name$='_" + index + "'] .splitbutton").hide();
 		$("tr[name^='" + type + "_'][name$='_" + index + "']:last .splitbutton").show();
 
-		$("#reset_" + (nbrTrs) + "_" + index).click(function () {
+		$("#reset_" + (nbrTrs) + "_" + index).click(function (event) {
+			event.preventDefault();
 			id = $(this).attr("id");
 			id = id.split("reset_");
 			idrow = id[1];
@@ -156,7 +157,7 @@ function addDispatchLine(index, type, mode) {
 				$('tr[name="' + type + '_' + idrow + '"').remove();
 				$("tr[name^='" + type + "_'][name$='_" + index + "']:last .splitbutton").show();
 			} else {
-				console.log("Reset trigger for id = #qty_" + idrow);
+				console.log("fourn/js/lib_dispatch.js.php Reset trigger for id = qty_" + idrow);
 				$("#qty_" + idrow).val("");
 			}
 		});

+ 6 - 3
htdocs/holiday/class/holiday.class.php

@@ -2471,15 +2471,18 @@ class Holiday extends CommonObject
 		if (property_exists($this, 'fk_type')) {
 			$return .= '<br>';
 			//$return .= '<span class="opacitymedium">'.$langs->trans("Type").'</span> : ';
-			$return .= '<span class="info_box-label maxwidth100">'.$arraydata['labeltype'].'</span>';
+			$return .= '<div class="info_box-label tdoverflowmax100" title="'.dol_escape_htmltag($arraydata['labeltype']).'">'.dol_escape_htmltag($arraydata['labeltype']).'</div>';
 		}
 		if (property_exists($this, 'date_debut') && property_exists($this, 'date_fin')) {
-			$return .= '<br><span class="info-box-label small">'.dol_print_date($this->date_debut, 'day').'</span>';
+			$return .= '<span class="info-box-label small">'.dol_print_date($this->date_debut, 'day').'</span>';
 			$return .= ' <span class="opacitymedium small">'.$langs->trans("To").'</span> ';
 			$return .= '<span class="info-box-label small">'.dol_print_date($this->date_fin, 'day').'</span>';
+			if (!empty($arraydata['nbopenedday'])) {
+				$return .= ' ('.$arraydata['nbopenedday'].')';
+			}
 		}
 		if (method_exists($this, 'getLibStatut')) {
-			$return .= '<br><div class="info-box-status margintoponly">'.$this->getLibStatut(3).'</div>';
+			$return .= '<div class="info-box-status margintoponly">'.$this->getLibStatut(3).'</div>';
 		}
 		$return .= '</div>';
 		$return .= '</div>';

+ 1 - 3
htdocs/holiday/list.php

@@ -895,7 +895,7 @@ if ($id && empty($user->rights->holiday->readall) && !in_array($id, $childids))
 					$labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code']) != $typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']);
 				}
 
-				$arraydata = array('user'=>$userstatic, 'labeltype'=>$labeltypeleavetoshow, 'selected'=>$selected);
+				$arraydata = array('user'=>$userstatic, 'labeltype'=>$labeltypeleavetoshow, 'selected'=>$selected, 'nbopenedday'=>$nbopenedday);
 			}
 			print $holidaystatic->getKanbanView('', $arraydata);
 			if ($i == ($imaxinloop - 1)) {
@@ -957,8 +957,6 @@ if ($id && empty($user->rights->holiday->readall) && !in_array($id, $childids))
 			}
 			if (!empty($arrayfields['duration']['checked'])) {
 				print '<td class="right">';
-				$nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday);	// user jdate(..., 1) because num_open_day need UTC dates
-				$totalduration += $nbopenedday;
 				print $nbopenedday;
 				//print ' '.$langs->trans('DurationDays');
 				print '</td>';

+ 1 - 1
htdocs/knowledgemanagement/class/knowledgerecord.class.php

@@ -847,7 +847,7 @@ class KnowledgeRecord extends CommonObject
 
 					$result .= '</div>';
 				} else {
-					$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+					$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
 				}
 			}
 		}

+ 1 - 0
htdocs/langs/en_US/receptions.lang

@@ -53,5 +53,6 @@ ReceptionBackToDraftInDolibarr=Reception %s back to draft
 ReceptionClassifyClosedInDolibarr=Reception %s classified Closed
 ReceptionUnClassifyCloseddInDolibarr=Reception %s re-open
 RestoreWithCurrentQtySaved=Fill quantities with latest saved values
+ReceptionsRecorded=Receptions recorded
 ReceptionUpdated=Reception sucessfully updated
 ReceptionDistribution=Reception distribution

+ 1 - 0
htdocs/langs/en_US/sendings.lang

@@ -62,6 +62,7 @@ ProductQtyInSuppliersShipmentAlreadyRecevied=Product quantity from open purchase
 NoProductToShipFoundIntoStock=No product to ship found in warehouse <b>%s</b>. Correct stock or go back to choose another warehouse.
 WeightVolShort=Weight/Vol.
 ValidateOrderFirstBeforeShipment=You must first validate the order before being able to make shipments.
+NoLineGoOnTabToAddSome=No line, go on tab "%s" to add
 
 # Sending methods
 # ModelDocument

+ 2 - 4
htdocs/opensurvey/class/opensurveysondage.class.php

@@ -457,9 +457,7 @@ class Opensurveysondage extends CommonObject
 	 */
 	public function getNomUrl($withpicto = 0, $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
 	{
-		global $db, $conf, $langs;
-		global $dolibarr_main_authentication, $dolibarr_main_demo;
-		global $menumanager;
+		global $conf, $langs;
 
 		if (!empty($conf->dol_no_mouse_hover)) {
 			$notooltip = 1; // Force disable tooltips
@@ -509,7 +507,7 @@ class Opensurveysondage extends CommonObject
 
 		$result .= $linkstart;
 		if ($withpicto) {
-			$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
 		}
 		if ($withpicto != 2) {
 			$result .= $this->ref;

+ 1 - 1
htdocs/product/stock/class/entrepot.class.php

@@ -815,7 +815,7 @@ class Entrepot extends CommonObject
 
 		$result .= $linkstart;
 		if ($withpicto) {
-			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
 		}
 		if ($withpicto != 2) {
 			$result .= (($showfullpath || !empty($conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO)) ? $this->get_full_arbo() : $this->label);

+ 2 - 4
htdocs/product/stock/class/productlot.class.php

@@ -987,9 +987,7 @@ class Productlot extends CommonObject
 	 */
 	public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '', $save_lastsearch_value = -1)
 	{
-		global $langs, $conf, $hookmanager, $db;
-		global $dolibarr_main_authentication, $dolibarr_main_demo;
-		global $menumanager;
+		global $langs, $conf, $hookmanager;
 
 		$result = '';
 		$params = [
@@ -1046,7 +1044,7 @@ class Productlot extends CommonObject
 
 		$result .= $linkstart;
 		if ($withpicto) {
-			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
 		}
 		if ($withpicto != 2) {
 			$result .= $this->batch;

+ 3 - 2
htdocs/reception/card.php

@@ -143,13 +143,14 @@ if ($user->socid) {
 	$socid = $user->socid;
 }
 
+// TODO Test on reception module on only
 if (isModEnabled("reception") || $origin == 'reception' || empty($origin)) {
-	$result = restrictedArea($user, 'reception', $id);
+	$result = restrictedArea($user, 'reception', $object->id);
 } else {
 	// We do not use the reception module, so we test permission on the supplier orders
 	if ($origin == 'supplierorder' || $origin == 'order_supplier') {
 		$result = restrictedArea($user, 'fournisseur', $origin_id, 'commande_fournisseur', 'commande');
-	} elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) {
+	} elseif (!$user->hasRight($origin, 'lire') && !$user->hasRight($origin, 'read')) {
 		accessforbidden();
 	}
 }

+ 3 - 1
htdocs/reception/contact.php

@@ -67,12 +67,14 @@ if ($id > 0 || !empty($ref)) {
 if ($user->socid > 0) {
 	$socid = $user->socid;
 }
+
+// TODO Test on reception module on only
 if ($origin == 'reception') {
 	$result = restrictedArea($user, $origin, $object->id);
 } else {
 	if ($origin == 'supplierorder' || $origin == 'order_supplier') {
 		$result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande');
-	} elseif (!$user->hasRight($origin, "lire") && !$user->hasRight($origin, "read")) {
+	} elseif (!$user->hasRight($origin, 'lire') && !$user->hasRight($origin, 'read')) {
 		accessforbidden();
 	}
 }

+ 24 - 17
htdocs/reception/dispatch.php

@@ -25,9 +25,9 @@
  */
 
 /**
- * \file htdocs/fourn/commande/dispatch.php
+ * \file 	htdocs/reception/dispatch.php
  * \ingroup commande
- * \brief Page to dispatch receiving
+ * \brief 	Page to dispatch receptions.
  */
 
 // Load Dolibarr environment
@@ -40,11 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class
 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php';
-
-
-if (isModEnabled('project')) {
-	require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
-}
+require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
 
 // Load translation files required by the page
 $langs->loadLangs(array("bills", "orders", "sendings", "companies", "deliveries", "products", "stocks", "receptions"));
@@ -62,6 +58,9 @@ $fk_default_warehouse = GETPOST('fk_default_warehouse', 'int');
 $cancel = GETPOST('cancel', 'alpha');
 $confirm = GETPOST('confirm', 'alpha');
 
+$error = 0;
+$errors = array();
+
 if ($user->socid) {
 	$socid = $user->socid;
 }
@@ -106,11 +105,11 @@ if (empty($conf->reception->enabled)) {
 	$permissiontocontrol = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate)));
 }
 
-// $id is id of a purchase order.
-$result = restrictedArea($user, 'fournisseur', $object, 'reception');
+// $id is id of a reception
+$result = restrictedArea($user, 'reception', $object->id);
 
 if (!isModEnabled('stock')) {
-	accessforbidden();
+	accessforbidden('Module stock disabled');
 }
 
 $usercancreate = $user->hasRight('reception', 'creer');
@@ -206,7 +205,8 @@ if ($action == 'updatelines' && $permissiontoreceive) {
 								$error++;
 							}
 
-							// If module stock is enabled and the stock increase is done on purchase order dispatching
+							// If module stock is enabled and the stock decrease is done on edtion of this page
+							/*
 							if (!$error && GETPOST($ent, 'int') > 0 && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) {
 								$mouv = new MouvementStock($db);
 								$product = GETPOST($prod, 'int');
@@ -242,6 +242,7 @@ if ($action == 'updatelines' && $permissiontoreceive) {
 									}
 								}
 							}
+							*/
 						}
 					} else {
 						$result = $objectsrc->dispatchProduct($user, GETPOST($prod, 'int'), GETPOST($qty), GETPOST($ent, 'int'), GETPOST($pu), GETPOST('comment'), $dDLUO, $dDLC, $lot, GETPOST($fk_commandefourndet, 'int'), 0, $object->id);
@@ -282,6 +283,9 @@ if ($action == 'updatelines' && $permissiontoreceive) {
 	} else {
 		$db->commit();
 		setEventMessages($langs->trans("ReceptionUpdated"), null);
+
+		header("Location: ".DOL_URL_ROOT.'/reception/dispatch.php?id='.$object->id);
+		exit;
 	}
 }
 
@@ -427,7 +431,7 @@ if ($id > 0 || !empty($ref)) {
 	print '</tr>';
 	print '</table>';
 
-	print '<br><center>';
+	print '<br><br><center>';
 	print '<a href="#" id="resetalltoexpected" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto("", 'autofill', 'class="pictofixedwidth"').$langs->trans("RestoreWithCurrentQtySaved").'</a></td>';
 	// Link to clear qty
 	print '<a href="#" id="autoreset" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto("", 'eraser', 'class="pictofixedwidth"').$langs->trans("ClearQtys").'</a></td>';
@@ -436,14 +440,13 @@ if ($id > 0 || !empty($ref)) {
 	print '<br>';
 	$disabled = 0;	// This is used to disable or not the bulk selection of target warehouse. No reason to have it disabled so forced to 0.
 
-	if ($object->statut == Reception::STATUS_DRAFT) {
+	if ($object->statut == Reception::STATUS_DRAFT || ($object->statut == Reception::STATUS_VALIDATED && empty($conf->global->STOCK_CALCULATE_ON_RECEPTION))) {
 		require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
 		$formproduct = new FormProduct($db);
 		$formproduct->loadWarehouses();
 		$entrepot = new Entrepot($db);
 		$listwarehouses = $entrepot->list_array(1);
 
-
 		print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
 
 		print '<input type="hidden" name="token" value="'.newToken().'">';
@@ -1046,13 +1049,13 @@ if ($id > 0 || !empty($ref)) {
 		print '</div>';
 
 		if ($nbproduct) {
-			$checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll'));
-
 			print '<div class="center">';
 			$parameters = array();
 			$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
 			// modified by hook
 			if (empty($reshook)) {
+				/*$checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll'));
+
 				if (empty($conf->reception->enabled)) {
 					print $langs->trans("Comment").' : ';
 					print '<input type="text" class="minwidth400" maxlength="128" name="comment" value="';
@@ -1066,6 +1069,8 @@ if ($id > 0 || !empty($ref)) {
 				$dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive") : $langs->trans("CreateReception");
 
 				print '<br>';
+				*/
+
 				print '<input type="submit" id="submitform" class="button" name="dispatch" value="'.$langs->trans("Save").'"';
 				$disabled = 0;
 				if (!$permissiontoreceive) {
@@ -1137,11 +1142,13 @@ if ($id > 0 || !empty($ref)) {
 				return false;
 			});
 
-			$(".resetline").click(function(){
+			$(".resetline").click(function(e){
+				e.preventDefault();
 				id = $(this).attr("id");
 				id = id.split("reset_");
 				console.log("Reset trigger for id = qty_"+id[1]);
 				$("#qty_"+id[1]).val("");
+				return false;
 			});
 		});
 	</script>';

+ 5 - 9
htdocs/reception/note.php

@@ -83,22 +83,18 @@ if (isModEnabled("reception")) {
 }
 $permissionnote = $user->rights->reception->creer; // Used by the include of actions_setnotes.inc.php
 
+// TODO Test on reception module on only
 if ($origin == 'reception') {
 	$result = restrictedArea($user, $origin, $object->id);
 } else {
-	if ($origin == 'reception') {
-		$result = restrictedArea($user, $origin, $object->id);
-	} else {
-		if ($origin == 'supplierorder' || $origin == 'order_supplier') {
-			$result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande');
-		} elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) {
-			accessforbidden();
-		}
+	if ($origin == 'supplierorder' || $origin == 'order_supplier') {
+		$result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande');
+	} elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) {
+		accessforbidden();
 	}
 }
 
 
-
 /*
  * Actions
  */

+ 1 - 1
htdocs/resource/class/dolresource.class.php

@@ -854,7 +854,7 @@ class Dolresource extends CommonObject
 
 		$result .= $linkstart;
 		if ($withpicto) {
-			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
 		}
 		if ($withpicto != 2) {
 			$result .= $this->ref;

+ 1 - 1
htdocs/salaries/class/salary.class.php

@@ -552,7 +552,7 @@ class Salary extends CommonObject
 
 		$result .= $linkstart;
 		if ($withpicto) {
-			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright pictofixedwidth"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.' pictofixedwidth"'), 0, 0, $notooltip ? 0 : 1);
+			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
 		}
 		if ($withpicto != 2) {
 			$result .= $this->ref;

+ 1 - 1
htdocs/supplier_proposal/class/supplier_proposal.class.php

@@ -2573,7 +2573,7 @@ class SupplierProposal extends CommonObject
 
 		$result .= $linkstart;
 		if ($withpicto) {
-			$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
 		}
 		if ($withpicto != 2) {
 			$result .= $this->ref;

+ 1 - 1
htdocs/theme/eldy/global.inc.php

@@ -191,7 +191,7 @@ th.wrapcolumntitle dl dt a span.fas.fa-list {
 .liste_titre input[name=search_day_date_when], .liste_titre input[name=search_month_date_when], .liste_titre input[name=search_year_date_when],
 .liste_titre input[name=search_dtstartday], .liste_titre input[name=search_dtendday], .liste_titre input[name=search_dtstartmonth], .liste_titre input[name=search_dtendmonth],
 */
-.liste_titre input[name=search_month] {
+.liste_titre input[name=search_month], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end] {
 	margin-right: 4px;
 }
 

+ 6 - 1
htdocs/theme/md/style.css.php

@@ -495,7 +495,7 @@ th.wrapcolumntitle dl dt a span.fas.fa-list {
 	vertical-align: bottom;
 }
 
-.liste_titre input[name=month_date_when], .liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth],
+/*.liste_titre input[name=month_date_when], .liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth],
 .liste_titre input[name=search_smonth], .liste_titre input[name=search_month], .liste_titre input[name=search_emonth], .liste_titre input[name=smonth], .liste_titre input[name=month],
 .liste_titre input[name=month_lim], .liste_titre input[name=month_start], .liste_titre input[name=month_end], .liste_titre input[name=month_create],
 .liste_titre input[name=search_month_lim], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end], .liste_titre input[name=search_month_create],
@@ -507,10 +507,15 @@ th.wrapcolumntitle dl dt a span.fas.fa-list {
 .liste_titre input[name=search_day_create], .liste_titre input[name=search_day_start], .liste_titre input[name=search_day_end],
 .liste_titre input[name=search_day_date_when], .liste_titre input[name=search_month_date_when], .liste_titre input[name=search_year_date_when],
 .liste_titre input[name=search_dtstartday], .liste_titre input[name=search_dtendday], .liste_titre input[name=search_dtstartmonth], .liste_titre input[name=search_dtendmonth],
+*/
+.liste_titre input[name=search_month], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end] {
+	margin-right: 4px;
+}
 select#date_startday, select#date_startmonth, select#date_endday, select#date_endmonth, select#reday, select#remonth
 {
 	margin-right: 4px;
 }
+
 input, input.flat, textarea, textarea.flat, form.flat select, select, select.flat, .dataTables_length label select {
 	color: var(--colortext);
 	border: none;

+ 2 - 4
htdocs/ticket/class/ticket.class.php

@@ -1522,9 +1522,7 @@ class Ticket extends CommonObject
 	 */
 	public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
 	{
-		global $db, $conf, $langs;
-		global $dolibarr_main_authentication, $dolibarr_main_demo;
-		global $menumanager;
+		global $conf, $langs;
 
 		if (!empty($conf->dol_no_mouse_hover)) {
 			$notooltip = 1; // Force disable tooltips
@@ -1579,7 +1577,7 @@ class Ticket extends CommonObject
 
 		$result .= $linkstart;
 		if ($withpicto) {
-			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
+			$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
 		}
 		if ($withpicto != 2) {
 			$result .= $this->ref;

+ 1 - 1
htdocs/user/card.php

@@ -74,7 +74,7 @@ $group = GETPOST("group", "int", 3);
 $cancel		= GETPOST('cancel', 'alpha');
 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'useracard'; // To manage different context of search
 
-if (empty($id)) {
+if (empty($id) && $action != 'create') {
 	$id = $user->id;
 }