瀏覽代碼

NEW debut rename stock conf

atm-quentin 6 年之前
父節點
當前提交
52717dbb65
共有 30 個文件被更改,包括 667 次插入64 次删除
  1. 1 1
      htdocs/admin/dict.php
  2. 1 0
      htdocs/admin/mails_templates.php
  3. 127 0
      htdocs/admin/reception_extrafields.php
  4. 1 1
      htdocs/admin/reception_setup.php
  5. 127 0
      htdocs/admin/receptiondet_extrafields.php
  6. 68 12
      htdocs/admin/stock.php
  7. 5 1
      htdocs/core/class/conf.class.php
  8. 1 1
      htdocs/core/lib/fourn.lib.php
  9. 3 1
      htdocs/fourn/commande/card.php
  10. 1 0
      htdocs/install/mysql/tables/llx_commande_fournisseur_dispatch.sql
  11. 9 9
      htdocs/install/mysql/tables/llx_reception.key.sql
  12. 3 4
      htdocs/install/mysql/tables/llx_reception.sql
  13. 1 1
      htdocs/install/mysql/tables/llx_reception_extrafields.key.sql
  14. 1 1
      htdocs/install/mysql/tables/llx_reception_extrafields.sql
  15. 2 2
      htdocs/install/mysql/tables/llx_receptiondet.key.sql
  16. 2 2
      htdocs/install/mysql/tables/llx_receptiondet.sql
  17. 2 2
      htdocs/install/mysql/tables/llx_receptiondet_batch.key.sql
  18. 2 2
      htdocs/install/mysql/tables/llx_receptiondet_batch.sql
  19. 1 1
      htdocs/install/mysql/tables/llx_receptiondet_extrafields.key.sql
  20. 1 1
      htdocs/install/mysql/tables/llx_receptiondet_extrafields.sql
  21. 1 3
      htdocs/langs/fr_FR/admin.lang
  22. 6 3
      htdocs/langs/fr_FR/stocks.lang
  23. 3 0
      htdocs/product/class/product.class.php
  24. 1 1
      htdocs/product/list.php
  25. 1 1
      htdocs/product/reassort.php
  26. 2 0
      htdocs/product/stock/product.php
  27. 3 1
      htdocs/product/stock/replenish.php
  28. 1 1
      htdocs/product/stock/replenishorders.php
  29. 12 12
      htdocs/reception/class/reception.class.php
  30. 278 0
      scripts/reception/create-table.php

+ 1 - 1
htdocs/admin/dict.php

@@ -407,7 +407,7 @@ $tabcond[14]= (! empty($conf->product->enabled) && ! empty($conf->ecotax->enable
 $tabcond[15]= true;
 $tabcond[16]= (! empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS));
 $tabcond[17]= (! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled));
-$tabcond[18]= ! empty($conf->expedition->enabled);
+$tabcond[18]= ! empty($conf->expedition->enabled) || ! empty($conf->reception->enabled);
 $tabcond[19]= ! empty($conf->societe->enabled);
 $tabcond[20]= ! empty($conf->fournisseur->enabled);
 $tabcond[21]= ! empty($conf->propal->enabled);

+ 1 - 0
htdocs/admin/mails_templates.php

@@ -148,6 +148,7 @@ if ($conf->propal->enabled) $elementList['propal_send']=$langs->trans('MailToSen
 if ($conf->commande->enabled) $elementList['order_send']=$langs->trans('MailToSendOrder');
 if ($conf->facture->enabled) $elementList['facture_send']=$langs->trans('MailToSendInvoice');
 if ($conf->expedition->enabled) $elementList['shipping_send']=$langs->trans('MailToSendShipment');
+if ($conf->reception->enabled) $elementList['reception_send']=$langs->trans('MailToSendReception');
 if ($conf->ficheinter->enabled) $elementList['fichinter_send']=$langs->trans('MailToSendIntervention');
 if ($conf->supplier_proposal->enabled) $elementList['supplier_proposal_send']=$langs->trans('MailToSendSupplierRequestForQuotation');
 if ($conf->fournisseur->enabled) $elementList['order_supplier_send']=$langs->trans('MailToSendSupplierOrder');

+ 127 - 0
htdocs/admin/reception_extrafields.php

@@ -0,0 +1,127 @@
+<?php
+/* Copyright (C) 2001-2002	Rodolphe Quiedeville	<rodolphe@quiedeville.org>
+ * Copyright (C) 2003		Jean-Louis Bergamo		<jlb@j1b.org>
+ * Copyright (C) 2004-2013	Laurent Destailleur		<eldy@users.sourceforge.net>
+ * Copyright (C) 2012		Regis Houssin			<regis.houssin@capnetworks.com>
+ * Copyright (C) 2012		Florian Henry			<florian.henry@open-concept.pro>
+ * Copyright (C) 2013		Philippe Grand			<philippe.grand@atoo-net.com>
+ * Copyright (C) 2015		Claudio Aschieri		<c.aschieri@19.coop>
+ * Copyright (C) 2018	   Quentin Vial-Gouteyron   <quentin.vial-gouteyron@atm-consulting.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *      \file       htdocs/admin/reception_extrafields.php
+ *		\ingroup    reception
+ *		\brief      Page to setup extra fields of reception
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
+
+
+if (!$user->admin)
+	accessforbidden();
+
+$langs->load("admin");
+$langs->load("other");
+$langs->load("receptions");
+$langs->load("deliveries");
+
+
+$extrafields = new ExtraFields($db);
+$form = new Form($db);
+
+// List of supported format
+$tmptype2label=ExtraFields::$type2label;
+$type2label=array('');
+foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
+
+$action=GETPOST('action', 'alpha');
+$attrname=GETPOST('attrname', 'alpha');
+$elementtype='reception'; //Must be the $table_element of the class that manage extrafield
+
+if (!$user->admin) accessforbidden();
+
+
+/*
+ * Actions
+ */
+
+require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
+
+
+
+/*
+ * View
+ */
+
+$textobject=$langs->transnoentitiesnoconv("Receptions");
+
+llxHeader('',$langs->trans("ReceptionsSetup"));
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print load_fiche_titre($langs->trans("ReceptionsSetup"),$linkback,'title_setup');
+print "<br>\n";
+
+$head = reception_admin_prepare_head();
+
+dol_fiche_head($head, 'attributes_reception', $langs->trans("Receptions"), -1, 'sending');
+
+require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
+
+dol_fiche_end();
+
+
+// Buttons
+if ($action != 'create' && $action != 'edit')
+{
+    print '<div class="tabsAction">';
+    print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>";
+    print "</div>";
+}
+
+
+/* ************************************************************************** */
+/*                                                                            */
+/* Creation of an optional field											  */
+/*                                                                            */
+/* ************************************************************************** */
+
+if ($action == 'create')
+{
+    print "<br>";
+    print load_fiche_titre($langs->trans('NewAttribute'));
+
+    require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
+}
+
+/* ************************************************************************** */
+/*                                                                            */
+/* Edition of an optional field                                                */
+/*                                                                            */
+/* ************************************************************************** */
+if ($action == 'edit' && ! empty($attrname))
+{
+    print "<br>";
+    print load_fiche_titre($langs->trans("FieldEdition", $attrname));
+
+    require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
+}
+
+llxFooter();
+
+$db->close();

+ 1 - 1
htdocs/admin/reception_setup.php

@@ -205,7 +205,7 @@ print load_fiche_titre($langs->trans("ReceptionsSetup"),$linkback,'title_setup')
 print '<br>';
 $head = reception_admin_prepare_head();
 
-dol_fiche_head($head, 'reception', $langs->trans("Receptions"), -1, 'reception');
+dol_fiche_head($head, 'reception', $langs->trans("Receptions"), -1, 'sending');
 
 // Reception numbering model
 

+ 127 - 0
htdocs/admin/receptiondet_extrafields.php

@@ -0,0 +1,127 @@
+<?php
+/* Copyright (C) 2001-2002	Rodolphe Quiedeville	<rodolphe@quiedeville.org>
+ * Copyright (C) 2003		Jean-Louis Bergamo		<jlb@j1b.org>
+ * Copyright (C) 2004-2013	Laurent Destailleur		<eldy@users.sourceforge.net>
+ * Copyright (C) 2012		Regis Houssin			<regis.houssin@capnetworks.com>
+ * Copyright (C) 2012		Florian Henry			<florian.henry@open-concept.pro>
+ * Copyright (C) 2013		Philippe Grand			<philippe.grand@atoo-net.com>
+ * Copyright (C) 2013		Florian Henry			<florian.henry@open-concept.pro>
+ * Copyright (C) 2015		Claudio Aschieri		<c.aschieri@19.coop>
+ * Copyright (C) 2018	   Quentin Vial-Gouteyron   <quentin.vial-gouteyron@atm-consulting.fr>
+ * 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *      \file       htdocs/admin/receptiondet_extrafields.php
+ *		\ingroup    reception
+ *		\brief      Page to setup extra fields of reception
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
+
+
+if (!$user->admin)
+	accessforbidden();
+
+$langs->load("admin");
+$langs->load("other");
+$langs->load("receptions");
+
+$extrafields = new ExtraFields($db);
+$form = new Form($db);
+
+// List of supported format
+$tmptype2label=ExtraFields::$type2label;
+$type2label=array('');
+foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
+
+$action=GETPOST('action', 'alpha');
+$attrname=GETPOST('attrname', 'alpha');
+$elementtype='receptiondet'; //Must be the $table_element of the class that manage extrafield
+
+if (!$user->admin) accessforbidden();
+
+
+/*
+ * Actions
+ */
+
+require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
+
+
+
+/*
+ * View
+ */
+
+$textobject=$langs->transnoentitiesnoconv("Receptions");
+
+llxHeader('',$langs->trans("ReceptionsSetup"));
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print load_fiche_titre($langs->trans("ReceptionsSetup"),$linkback,'title_setup');
+print "<br>\n";
+
+$head = reception_admin_prepare_head();
+
+dol_fiche_head($head, 'attributeslines_reception', $langs->trans("Receptions"), -1, 'sending');
+
+require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
+
+dol_fiche_end();
+
+
+// Buttons
+if ($action != 'create' && $action != 'edit')
+{
+    print '<div class="tabsAction">';
+    print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>";
+    print "</div>";
+}
+
+
+/* ************************************************************************** */
+/*                                                                            */
+/* Creation of an optional field											  */
+/*                                                                            */
+/* ************************************************************************** */
+
+if ($action == 'create')
+{
+    print "<br>";
+    print load_fiche_titre($langs->trans('NewAttribute'));
+
+    require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
+}
+
+/* ************************************************************************** */
+/*                                                                            */
+/* Edition of an optional field                                               */
+/*                                                                            */
+/* ************************************************************************** */
+if ($action == 'edit' && ! empty($attrname))
+{
+    print "<br>";
+    print load_fiche_titre($langs->trans("FieldEdition", $attrname));
+
+    require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
+}
+
+llxFooter();
+
+$db->close();

+ 68 - 12
htdocs/admin/stock.php

@@ -74,16 +74,22 @@ if($action)
 	// Mode of stock increase
 	if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL'
 	|| $action == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER'
-	|| $action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER')
+	|| $action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER'
+	|| $action == 'STOCK_CALCULATE_ON_RECEPTION'
+	|| $action == 'STOCK_CALCULATE_ON_RECEPTION_CLOSE')
 	{
 		//Use variable cause empty(GETPOST()) do not work with php version < 5.4
 		$valdispatch=GETPOST('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER','alpha');
 
 		$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", '','chaine',0,'',$conf->entity);
 		$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", '','chaine',0,'',$conf->entity);
+		$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_RECEPTION", '','chaine',0,'',$conf->entity);
+		$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_RECEPTION_CLOSE", '','chaine',0,'',$conf->entity);
 		$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", '','chaine',0,'',$conf->entity);
 		if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL')           $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_BILL','alpha'),'chaine',0,'',$conf->entity);
 		if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER','alpha'),'chaine',0,'',$conf->entity);
+		if ($action == 'STOCK_CALCULATE_ON_RECEPTION') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_RECEPTION", GETPOST('STOCK_CALCULATE_ON_RECEPTION','alpha'),'chaine',0,'',$conf->entity);
+		if ($action == 'STOCK_CALCULATE_ON_RECEPTION_CLOSE') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_RECEPTION_CLOSE", GETPOST('STOCK_CALCULATE_ON_RECEPTION_CLOSE','alpha'),'chaine',0,'',$conf->entity);
 		if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $valdispatch,'chaine',0,'',$conf->entity);
 		if (empty($valdispatch)) {
 			$res=dolibarr_set_const($db, "SUPPLIER_ORDER_USE_DISPATCH_STATUS", '','chaine',0,'',$conf->entity);
@@ -107,6 +113,9 @@ if($action)
 	if($action == 'STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT') {
 	    $res = dolibarr_set_const($db, "STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT", GETPOST('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT','alpha'),'chaine',0,'',$conf->entity);
 	}
+	if($action == 'STOCK_MUST_BE_ENOUGH_FOR_RECEPTION') {
+	    $res = dolibarr_set_const($db, "STOCK_MUST_BE_ENOUGH_FOR_RECEPTION", GETPOST('STOCK_MUST_BE_ENOUGH_FOR_RECEPTION','alpha'),'chaine',0,'',$conf->entity);
+	}
 	if($action == 'INDEPENDANT_SUBPRODUCT_STOCK') {
 	    $res = dolibarr_set_const($db, "INDEPENDANT_SUBPRODUCT_STOCK", GETPOST('INDEPENDANT_SUBPRODUCT_STOCK','alpha'),'chaine',0,'',$conf->entity);
 	}
@@ -307,25 +316,58 @@ else
 print "</td>\n</tr>\n";
 $found++;
 
-
-print '<tr class="oddeven">';
-print '<td width="60%">'.$langs->trans("ReStockOnDispatchOrder").'</td>';
-print '<td width="160" align="right">';
-if (! empty($conf->fournisseur->enabled))
+if (!empty($conf->reception->enabled))
 {
-    print "<form method=\"post\" action=\"stock.php\">";
+	print '<tr class="oddeven">';
+	print '<td width="60%">'.$langs->trans("StockOnReception").'</td>';
+	print '<td width="160" align="right">';
+
+	print "<form method=\"post\" action=\"stock.php\">";
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+	print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_RECEPTION\">";
+	print $form->selectyesno("STOCK_CALCULATE_ON_RECEPTION", $conf->global->STOCK_CALCULATE_ON_RECEPTION, 1, $disabled);
+	print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"'.$disabled.'>';
+	print "</form>\n";
+
+	print "</td>\n</tr>\n";
+	$found++;
+
+
+	print '<tr class="oddeven">';
+	print '<td width="60%">'.$langs->trans("StockOnReceptionOnClosing").'</td>';
+	print '<td width="160" align="right">';
+
+	print "<form method=\"post\" action=\"stock.php\">";
 	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-	print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER\">";
-	print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER,1,$disabled);
+	print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_RECEPTION_CLOSE\">";
+	print $form->selectyesno("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE, 1, $disabled);
 	print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"'.$disabled.'>';
 	print "</form>\n";
+
+	print "</td>\n</tr>\n";
+	$found++;
 }
 else
 {
-    print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
+	print '<tr class="oddeven">';
+	print '<td width="60%">'.$langs->trans("ReStockOnDispatchOrder").'</td>';
+	print '<td width="160" align="right">';
+	if (!empty($conf->fournisseur->enabled))
+	{
+		print "<form method=\"post\" action=\"stock.php\">";
+		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+		print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER\">";
+		print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER, 1, $disabled);
+		print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"'.$disabled.'>';
+		print "</form>\n";
+	}
+	else
+	{
+		print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
+	}
+	print "</td>\n</tr>\n";
+	$found++;
 }
-print "</td>\n</tr>\n";
-$found++;
 
 /*if (! $found)
 {
@@ -402,6 +444,20 @@ if($conf->expedition->enabled) {
 	print "</td>\n";
 	print "</tr>\n";
 }
+if($conf->reception->enabled) {
+	$var = !$var;
+	print '<tr class="oddeven">';
+	print '<td width="60%">'.$langs->trans("StockMustBeEnoughForReception").'</td>';
+	print '<td width="160" align="right">';
+	print "<form method=\"post\" action=\"stock.php\">";
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+	print "<input type=\"hidden\" name=\"action\" value=\"STOCK_MUST_BE_ENOUGH_FOR_RECEPTION\">";
+	print $form->selectyesno("STOCK_MUST_BE_ENOUGH_FOR_RECEPTION",$conf->global->STOCK_MUST_BE_ENOUGH_FOR_RECEPTION,1);
+	print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
+	print '</form>';
+	print "</td>\n";
+	print "</tr>\n";
+}
 print '</table>';
 
 $virtualdiffersfromphysical=0;

+ 5 - 1
htdocs/core/class/conf.class.php

@@ -415,7 +415,11 @@ class Conf
 			$this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE=0;
 			$this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL=0;
 			$this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER=0;
-			$this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER=1;
+			if(empty($this->reception->enabled))$this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER=1;
+			else {
+				$this->global->STOCK_CALCULATE_ON_RECEPTION=1;
+				$this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE=0;
+			}
 		}
 
 		// conf->currency

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

@@ -111,7 +111,7 @@ function ordersupplier_prepare_head($object)
 	$head[$h][2] = 'card';
 	$h++;
 
-	if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
+	if (! empty($conf->stock->enabled) && (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)))
 	{
 		$langs->load("stocks");
 		$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id;

+ 3 - 1
htdocs/fourn/commande/card.php

@@ -2623,8 +2623,10 @@ elseif (! empty($object->id))
 				}
 
 				// Ship
-				if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
+				
+				if (! empty($conf->stock->enabled) && (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)))
 				{
+					
 					if (in_array($object->statut, array(3,4))) {
 						if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->receptionner) {
 							print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/fourn/commande/dispatch.php?id=' . $object->id . '">' . $langs->trans('OrderDispatch') . '</a></div>';

+ 1 - 0
htdocs/install/mysql/tables/llx_commande_fournisseur_dispatch.sql

@@ -25,6 +25,7 @@ create table llx_commande_fournisseur_dispatch
   fk_commande    integer,
   fk_product     integer,
   fk_commandefourndet integer,
+  fk_projet  	 integer  DEFAULT NULL,
   qty            float,              -- qty
   fk_entrepot    integer,
   fk_user        integer,

+ 9 - 9
htdocs/install/mysql/tables/llx_reception.key.sql

@@ -18,14 +18,14 @@
 -- ===================================================================
 
 
-ALTER TABLE llx_expedition ADD UNIQUE INDEX idx_expedition_uk_ref (ref, entity);
+ALTER TABLE llx_reception ADD UNIQUE INDEX idx_reception_uk_ref (ref, entity);
 
-ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_soc (fk_soc);
-ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_user_author (fk_user_author);
-ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_user_valid (fk_user_valid);
-ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_shipping_method (fk_shipping_method);
+ALTER TABLE llx_reception ADD INDEX idx_reception_fk_soc (fk_soc);
+ALTER TABLE llx_reception ADD INDEX idx_reception_fk_user_author (fk_user_author);
+ALTER TABLE llx_reception ADD INDEX idx_reception_fk_user_valid (fk_user_valid);
+ALTER TABLE llx_reception ADD INDEX idx_reception_fk_shipping_method (fk_shipping_method);
 
-ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_soc				FOREIGN KEY (fk_soc)			 REFERENCES llx_societe (rowid);
-ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_user_author		FOREIGN KEY (fk_user_author)	 REFERENCES llx_user (rowid);
-ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_user_valid 		FOREIGN KEY (fk_user_valid)		 REFERENCES llx_user (rowid);
-ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_shipping_method 	FOREIGN KEY (fk_shipping_method) REFERENCES llx_c_shipment_mode (rowid);
+ALTER TABLE llx_reception ADD CONSTRAINT fk_reception_fk_soc				FOREIGN KEY (fk_soc)			 REFERENCES llx_societe (rowid);
+ALTER TABLE llx_reception ADD CONSTRAINT fk_reception_fk_user_author		FOREIGN KEY (fk_user_author)	 REFERENCES llx_user (rowid);
+ALTER TABLE llx_reception ADD CONSTRAINT fk_reception_fk_user_valid 		FOREIGN KEY (fk_user_valid)		 REFERENCES llx_user (rowid);
+ALTER TABLE llx_reception ADD CONSTRAINT fk_reception_fk_shipping_method 	FOREIGN KEY (fk_shipping_method) REFERENCES llx_c_shipment_mode (rowid);

+ 3 - 4
htdocs/install/mysql/tables/llx_reception.sql

@@ -19,7 +19,7 @@
 --
 -- ===================================================================
 
-create table llx_expedition
+create table llx_reception
 (
   rowid                 integer AUTO_INCREMENT PRIMARY KEY,
   tms                   timestamp,
@@ -30,7 +30,7 @@ create table llx_expedition
   
   ref_ext               varchar(30),					-- reference into an external system (not used by dolibarr)
   ref_int				varchar(30),					-- reference into an internal system (used by dolibarr to store extern id like paypal info)
-  ref_customer          varchar(30),					-- customer number
+  ref_supplier          varchar(30),					-- customer number
   
   date_creation         datetime,						-- date de creation
   fk_user_author        integer,						-- author of creation
@@ -38,8 +38,7 @@ create table llx_expedition
   date_valid            datetime,						-- date de validation
   fk_user_valid         integer,						-- valideur
   date_delivery			datetime	DEFAULT NULL,		-- date planned of delivery
-  date_expedition       datetime,						-- not used (deprecated)
-  fk_address  			integer		DEFAULT NULL, 		-- delivery address (deprecated)
+  date_reception       datetime,						
   fk_shipping_method    integer,
   tracking_number       varchar(50),
   fk_statut             smallint	DEFAULT 0,			-- 0 = draft, 1 = validated, 2 = billed or closed depending on WORKFLOW_BILL_ON_SHIPMENT option

+ 1 - 1
htdocs/install/mysql/tables/llx_reception_extrafields.key.sql

@@ -17,4 +17,4 @@
 -- ===================================================================
 
 
-ALTER TABLE llx_expedition_extrafields ADD INDEX idx_expedition_extrafields (fk_object);
+ALTER TABLE llx_reception_extrafields ADD INDEX idx_reception_extrafields (fk_object);

+ 1 - 1
htdocs/install/mysql/tables/llx_reception_extrafields.sql

@@ -16,7 +16,7 @@
 --
 -- ========================================================================
 
-create table llx_expedition_extrafields
+create table llx_reception_extrafields
 (
   rowid                     integer AUTO_INCREMENT PRIMARY KEY,
   tms                       timestamp,

+ 2 - 2
htdocs/install/mysql/tables/llx_receptiondet.key.sql

@@ -18,5 +18,5 @@
 -- ===================================================================
 
 
-ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_expedition (fk_expedition);
-ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_expedition FOREIGN KEY (fk_expedition) REFERENCES llx_expedition (rowid);
+ALTER TABLE llx_receptiondet ADD INDEX idx_receptiondet_fk_reception (fk_reception);
+ALTER TABLE llx_receptiondet ADD CONSTRAINT fk_receptiondet_fk_reception FOREIGN KEY (fk_reception) REFERENCES llx_reception (rowid);

+ 2 - 2
htdocs/install/mysql/tables/llx_receptiondet.sql

@@ -18,10 +18,10 @@
 --
 -- ===================================================================
 
-create table llx_expeditiondet
+create table llx_receptiondet
 (
   rowid             integer AUTO_INCREMENT PRIMARY KEY,
-  fk_expedition     integer NOT NULL,
+  fk_reception     integer NOT NULL,
   fk_origin_line    integer,           -- Correspondance de la ligne avec le document d'origine (propal, commande)
   fk_entrepot       integer,           -- Entrepot de depart du produit
   qty               real,              -- Quantity

+ 2 - 2
htdocs/install/mysql/tables/llx_receptiondet_batch.key.sql

@@ -16,5 +16,5 @@
 --
 -- ============================================================================
 
-ALTER TABLE llx_expeditiondet_batch ADD INDEX idx_fk_expeditiondet (fk_expeditiondet);
-ALTER TABLE llx_expeditiondet_batch ADD CONSTRAINT fk_expeditiondet_batch_fk_expeditiondet FOREIGN KEY (fk_expeditiondet) REFERENCES llx_expeditiondet(rowid);
+ALTER TABLE llx_receptiondet_batch ADD INDEX idx_fk_receptiondet (fk_receptiondet);
+ALTER TABLE llx_receptiondet_batch ADD CONSTRAINT fk_receptiondet_batch_fk_receptiondet FOREIGN KEY (fk_receptiondet) REFERENCES llx_receptiondet(rowid);

+ 2 - 2
htdocs/install/mysql/tables/llx_receptiondet_batch.sql

@@ -15,9 +15,9 @@
 -- along with this program. If not, see <http://www.gnu.org/licenses/>.
 --
 -- ============================================================================
-CREATE TABLE llx_expeditiondet_batch (
+CREATE TABLE llx_receptiondet_batch (
   rowid integer AUTO_INCREMENT PRIMARY KEY,
-  fk_expeditiondet int NOT NULL,
+  fk_receptiondet int NOT NULL,
   eatby date DEFAULT NULL,
   sellby date DEFAULT NULL,
   batch varchar(30) DEFAULT NULL,

+ 1 - 1
htdocs/install/mysql/tables/llx_receptiondet_extrafields.key.sql

@@ -17,4 +17,4 @@
 -- ===================================================================
 
 
-ALTER TABLE llx_expeditiondet_extrafields ADD INDEX idx_expeditiondet_extrafields (fk_object);
+ALTER TABLE llx_receptiondet_extrafields ADD INDEX idx_receptiondet_extrafields (fk_object);

+ 1 - 1
htdocs/install/mysql/tables/llx_receptiondet_extrafields.sql

@@ -16,7 +16,7 @@
 --
 -- ===================================================================
 
-create table llx_expeditiondet_extrafields
+create table llx_receptiondet_extrafields
 (
   rowid            integer AUTO_INCREMENT PRIMARY KEY,
   tms              timestamp,

+ 1 - 3
htdocs/langs/fr_FR/admin.lang

@@ -1439,11 +1439,9 @@ SendingsAbility=Prise en charge des bons d'expédition pour les livraisons clien
 NoNeedForDeliveryReceipts=Dans le plupart des cas, la fiche expédition est utilisée en tant que bon d'expédition (liste des produits expédiés) et bon de livraison (signée par le client). Le bon de réception est un doublon de fonctionnalité et est rarement utilisé.
 FreeLegalTextOnShippings=Mention complémentaire sur les expéditions
 ##### Reception #####
-ReceptionsSetup=Configuration du module Réception/Livraison
+ReceptionsSetup=Configuration du module Réception
 ReceptionsReceiptModel=Modèles de bordereau de réception
 ReceptionsNumberingModules=Modèles de numérotation des réceptions
-ReceptionsAbility=Prise en charge des bons d'réception pour les livraisons clients
-NoNeedForDeliveryReceipts=Dans le plupart des cas, la fiche réception est utilisée en tant que bon d'réception (liste des produits expédiés) et bon de livraison (signée par le client). Le bon de réception est un doublon de fonctionnalité et est rarement utilisé.
 FreeLegalTextOnShippings=Mention complémentaire sur les réceptions
 ##### Deliveries #####
 DeliveryOrderNumberingModules=Modèle de numérotation des bons de réception client

+ 6 - 3
htdocs/langs/fr_FR/stocks.lang

@@ -60,6 +60,8 @@ DeStockOnBill=Décrémente les stocks physiques sur validation des factures/avoi
 DeStockOnValidateOrder=Décrémente les stocks physiques sur validation des commandes clients
 DeStockOnShipment=Décrémenter les stocks physiques sur validation des expéditions
 DeStockOnShipmentOnClosing=Décrémenter les stocks réels au classement "clôturée" de l'expédition
+StockOnReception=Incrémenter les stocks physiques sur validation des réceptions
+StockOnReceptionOnClosing=Incrémenter les stocks réels au classement "clôturée" de la réception
 ReStockOnBill=Incrémente les stocks physiques sur validation des factures/avoirs fournisseurs
 ReStockOnValidateOrder=Incrémente les stocks physiques sur approbation des commandes fournisseurs
 ReStockOnDispatchOrder=Incrémente les stocks réels sur ventilation manuelle dans les entrepôts, après réception de la marchandise
@@ -123,9 +125,10 @@ RecordMovement=Enregistrer transfert
 ReceivingForSameOrder=Réceptions pour cette commande
 StockMovementRecorded=Mouvement de stocks enregistré
 RuleForStockAvailability=Règles d'exigence sur les stocks
-StockMustBeEnoughForInvoice=Le niveau de stock doit être suffisant pour ajouter ce produit/service à la facture (la vérification est faite sur le stock réel lors de l'ajout de la ligne de facture, quelquesoit la règle de modification automatique de stock)
-StockMustBeEnoughForOrder=Le niveau de stock doit être suffisant pour ajouter ce produit/service à la commande (la vérification est faite sur le stock réel lors de l'ajout de la ligne de commande, quelquesoit la règle de modification automatique de stock)
-StockMustBeEnoughForShipment= Le niveau de stock doit être suffisant pour ajouter ce produit/service à l'expédition (la vérification est faite sur le stock réel lors de l'ajout de la ligne à l'expédition, quelquesoit la règle de modification automatique de stock)
+StockMustBeEnoughForInvoice=Le niveau de stock doit être suffisant pour ajouter ce produit/service à la facture (la vérification est faite sur le stock réel lors de l'ajout de la ligne de facture, quel que soit la règle de modification automatique de stock)
+StockMustBeEnoughForOrder=Le niveau de stock doit être suffisant pour ajouter ce produit/service à la commande (la vérification est faite sur le stock réel lors de l'ajout de la ligne de commande, quel que soit la règle de modification automatique de stock)
+StockMustBeEnoughForShipment= Le niveau de stock doit être suffisant pour ajouter ce produit/service à l'expédition (la vérification est faite sur le stock réel lors de l'ajout de la ligne à l'expédition, quel que soit la règle de modification automatique de stock)
+StockMustBeEnoughForReception= Le niveau de stock doit être suffisant pour ajouter ce produit/service à la réception (la vérification est faite sur le stock réel lors de l'ajout de la ligne à la récepetion, quel que soit la règle de modification automatique de stock)
 MovementLabel=Libellé du mouvement
 InventoryCode=Code mouvement ou inventaire
 IsInPackage=Inclus dans un package

+ 3 - 0
htdocs/product/class/product.class.php

@@ -3839,6 +3839,9 @@ class Product extends CommonObject
             $this->stock_theorique=$this->stock_reel-$stock_commande_client;
         }
         // Stock Increase mode
+		 if (! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) {
+            $this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur;
+        }
         if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) {
             $this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur;
         }

+ 1 - 1
htdocs/product/list.php

@@ -121,7 +121,7 @@ else $result=restrictedArea($user,'produit|service','','','','','',$objcanvas);
 
 // Define virtualdiffersfromphysical
 $virtualdiffersfromphysical=0;
-if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
+if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) )
 {
     $virtualdiffersfromphysical=1;		// According to increase/decrease stock options, virtual and physical stock may differs.
 }

+ 1 - 1
htdocs/product/reassort.php

@@ -75,7 +75,7 @@ if (! empty($canvas))
 
 // Define virtualdiffersfromphysical
 $virtualdiffersfromphysical=0;
-if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
+if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)|| ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION))
 {
     $virtualdiffersfromphysical=1;		// According to increase/decrease stock options, virtual and physical stock may differs.
 }

+ 2 - 0
htdocs/product/stock/product.php

@@ -638,6 +638,8 @@ if ($id > 0 || $ref)
         $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)?$langs->trans("ReStockOnBill").'<br>':'');
         $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)?$langs->trans("ReStockOnValidateOrder").'<br>':'');
         $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)?$langs->trans("ReStockOnDispatchOrder").'<br>':'');
+        $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)?$langs->trans("StockOnReception").'<br>':'');
+
         print '<tr><td>';
         print $form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1);
         print '</td>';

+ 3 - 1
htdocs/product/stock/replenish.php

@@ -80,7 +80,9 @@ if (!$sortorder) {
 $virtualdiffersfromphysical=0;
 if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
 || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)
-|| ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE))
+|| ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)
+|| !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) 
+|| !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))
 {
     $virtualdiffersfromphysical=1;		// According to increase/decrease stock options, virtual and physical stock may differs.
 }

+ 1 - 1
htdocs/product/stock/replenishorders.php

@@ -113,7 +113,7 @@ $sql.= ' WHERE cf.fk_soc = s.rowid ';
 $sql.= ' AND cf.entity = ' . $conf->entity;
 if ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) {
     $sql .= ' AND cf.fk_statut < 3';
-} elseif ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) {
+} elseif ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER|| !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) {
     $sql .= ' AND cf.fk_statut < 6';	// We want also status 5, we will keep them visible if dispatching is not yet finished (tested with function dolDispatchToDo).
 } else {
     $sql .= ' AND cf.fk_statut < 5';

+ 12 - 12
htdocs/reception/class/reception.class.php

@@ -51,7 +51,7 @@ class Reception extends CommonObject
     public $picto = 'reception';
 
 	var $socid;
-	var $ref_customer;
+	var $ref_supplier;
 	var $ref_int;
 	var $brouillon;
 	var $entrepot_id;
@@ -201,7 +201,7 @@ class Reception extends CommonObject
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."reception (";
 		$sql.= "ref";
 		$sql.= ", entity";
-		$sql.= ", ref_customer";
+		$sql.= ", ref_supplier";
 		$sql.= ", ref_int";
 		$sql.= ", date_creation";
 		$sql.= ", fk_user_author";
@@ -210,7 +210,7 @@ class Reception extends CommonObject
 		$sql.= ", fk_soc";
 		$sql.= ", fk_projet";
 		$sql.= ", fk_address";
-		$sql.= ", fk_reception_method";
+		$sql.= ", fk_shipping_method";
 		$sql.= ", tracking_number";
 		$sql.= ", weight";
 		$sql.= ", size";
@@ -225,7 +225,7 @@ class Reception extends CommonObject
 		$sql.= ") VALUES (";
 		$sql.= "'(PROV)'";
 		$sql.= ", ".$conf->entity;
-		$sql.= ", ".($this->ref_customer?"'".$this->db->escape($this->ref_customer)."'":"null");
+		$sql.= ", ".($this->ref_supplier?"'".$this->db->escape($this->ref_supplier)."'":"null");
 		$sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null");
 		$sql.= ", '".$this->db->idate($now)."'";
 		$sql.= ", ".$user->id;
@@ -477,10 +477,10 @@ class Reception extends CommonObject
 		// Check parameters
 		if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1;
 
-		$sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut";
+		$sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_supplier, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut";
 		$sql.= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height";
 		$sql.= ", e.date_reception as date_reception, e.model_pdf, e.fk_address, e.date_delivery";
-		$sql.= ", e.fk_reception_method, e.tracking_number";
+		$sql.= ", e.fk_shipping_method, e.tracking_number";
 		$sql.= ", el.fk_source as origin_id, el.sourcetype as origin";
 		$sql.= ", e.note_private, e.note_public";
         $sql.= ', e.fk_incoterms, e.location_incoterms';
@@ -505,7 +505,7 @@ class Reception extends CommonObject
 				$this->id                   = $obj->rowid;
 				$this->ref                  = $obj->ref;
 				$this->socid                = $obj->socid;
-				$this->ref_customer			= $obj->ref_customer;
+				$this->ref_supplier			= $obj->ref_supplier;
 				$this->ref_ext				= $obj->ref_ext;
 				$this->ref_int				= $obj->ref_int;
 				$this->statut               = $obj->fk_statut;
@@ -517,7 +517,7 @@ class Reception extends CommonObject
 				$this->date_delivery        = $this->db->jdate($obj->date_delivery);	// Date planed
 				$this->fk_delivery_address  = $obj->fk_address;
 				$this->modelpdf             = $obj->model_pdf;
-				$this->reception_method_id	= $obj->fk_reception_method;
+				$this->shipping_method_id	= $obj->fk_shipping_method;
 				$this->tracking_number      = $obj->tracking_number;
 				$this->origin               = ($obj->origin?$obj->origin:'commande'); // For compatibility
 				$this->origin_id            = $obj->origin_id;
@@ -1007,7 +1007,7 @@ class Reception extends CommonObject
 
 		if (isset($this->ref)) $this->ref=trim($this->ref);
 		if (isset($this->entity)) $this->entity=trim($this->entity);
-		if (isset($this->ref_customer)) $this->ref_customer=trim($this->ref_customer);
+		if (isset($this->ref_supplier)) $this->ref_supplier=trim($this->ref_supplier);
 		if (isset($this->socid)) $this->socid=trim($this->socid);
 		if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author);
 		if (isset($this->fk_user_valid)) $this->fk_user_valid=trim($this->fk_user_valid);
@@ -1035,7 +1035,7 @@ class Reception extends CommonObject
 
 		$sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
 		$sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").",";
-		$sql.= " ref_customer=".(isset($this->ref_customer)?"'".$this->db->escape($this->ref_customer)."'":"null").",";
+		$sql.= " ref_supplier=".(isset($this->ref_supplier)?"'".$this->db->escape($this->ref_supplier)."'":"null").",";
 		$sql.= " fk_soc=".(isset($this->socid)?$this->socid:"null").",";
 		$sql.= " date_creation=".(dol_strlen($this->date_creation)!=0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').",";
 		$sql.= " fk_user_author=".(isset($this->fk_user_author)?$this->fk_user_author:"null").",";
@@ -1044,7 +1044,7 @@ class Reception extends CommonObject
 		$sql.= " date_reception=".(dol_strlen($this->date_reception)!=0 ? "'".$this->db->idate($this->date_reception)."'" : 'null').",";
 		$sql.= " date_delivery=".(dol_strlen($this->date_delivery)!=0 ? "'".$this->db->idate($this->date_delivery)."'" : 'null').",";
 		$sql.= " fk_address=".(isset($this->fk_delivery_address)?$this->fk_delivery_address:"null").",";
-		$sql.= " fk_reception_method=".((isset($this->reception_method_id) && $this->reception_method_id > 0)?$this->reception_method_id:"null").",";
+		$sql.= " fk_shipping_method=".((isset($this->reception_method_id) && $this->reception_method_id > 0)?$this->reception_method_id:"null").",";
 		$sql.= " tracking_number=".(isset($this->tracking_number)?"'".$this->db->escape($this->tracking_number)."'":"null").",";
 		$sql.= " fk_statut=".(isset($this->statut)?$this->statut:"null").",";
 		$sql.= " height=".(($this->trueHeight != '')?$this->trueHeight:"null").",";
@@ -1498,7 +1498,7 @@ class Reception extends CommonObject
 		$result='';
         $label = '<u>' . $langs->trans("ShowReception") . '</u>';
         $label .= '<br><b>' . $langs->trans('Ref') . ':</b> '.$this->ref;
-        $label .= '<br><b>'.$langs->trans('RefCustomer').':</b> '.($this->ref_customer ? $this->ref_customer : $this->ref_client);
+        $label .= '<br><b>'.$langs->trans('RefCustomer').':</b> '.($this->ref_supplier ? $this->ref_supplier : $this->ref_client);
 
 		$url = DOL_URL_ROOT.'/reception/card.php?id='.$this->id;
 

+ 278 - 0
scripts/reception/create-table.php

@@ -0,0 +1,278 @@
+<?php
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+$sapi_type = php_sapi_name();
+$script_file = basename(__FILE__);
+$path = dirname(__FILE__).'/';
+
+// Test if batch mode
+if (substr($sapi_type, 0, 3) == 'cgi')
+{
+	echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
+	exit(-1);
+}
+
+
+
+require_once($path."../../htdocs/master.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php");
+require_once(DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php");
+
+// Global variables
+$version = DOL_VERSION;
+$error = 0;
+
+
+/*
+ * Main
+ */
+
+@set_time_limit(0);
+
+// We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
+$dir = DOL_DOCUMENT_ROOT."/install/mysql/tables/";
+
+$ok = 0;
+$handle = opendir($dir);
+$tablefound = 0;
+$tabledata = array();
+if (is_resource($handle))
+{
+	while (($file = readdir($handle)) !== false)
+	{
+		if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && !preg_match('/\.key\.sql$/i', $file))
+		{
+			if (strpos($file, 'reception') !== false){
+				$tablefound++;
+				$tabledata[] = $file;
+			}
+		}
+	}
+
+	closedir($handle);
+}
+
+
+
+// Sort list of sql files on alphabetical order (load order is important)
+sort($tabledata);
+foreach ($tabledata as $file)
+{
+	$name = substr($file, 0, dol_strlen($file) - 4);
+	$buffer = '';
+	$fp = fopen($dir.$file, "r");
+	if ($fp)
+	{
+		while (!feof($fp))
+		{
+			$buf = fgets($fp, 4096);
+			if (substr($buf, 0, 2) <> '--')
+			{
+				$buf = preg_replace('/--(.+)*/', '', $buf);
+				$buffer .= $buf;
+			}
+		}
+		fclose($fp);
+
+		$buffer = trim($buffer);
+		if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') // For Mysql 5.5+, we must replace type=innodb with ENGINE=innodb
+		{
+			$buffer = preg_replace('/type=innodb/i', 'ENGINE=innodb', $buffer);
+		}
+		else if ($conf->db->type == 'mssql')
+		{
+			$buffer = preg_replace('/type=innodb/i', '', $buffer);
+			$buffer = preg_replace('/ENGINE=innodb/i', '', $buffer);
+		}
+
+		// Replace the prefix tables
+		if ($dolibarr_main_db_prefix != 'llx_')
+		{
+			$buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer);
+		}
+
+		//print "<tr><td>Creation de la table $name/td>";
+		$requestnb++;
+
+		$resql = $db->query($buffer, 0, 'dml');
+		if ($resql)
+		{
+			// print "<td>OK requete ==== $buffer</td></tr>";
+			$db->free($resql);
+		}
+		else
+		{
+			if ($db->errno() == 'DB_ERROR_TABLE_ALREADY_EXISTS' ||
+				$db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS')
+			{
+				//print "<td>Deja existante</td></tr>";
+			}
+			else
+			{
+				print "<tr><td>".$langs->trans("CreateTableAndPrimaryKey", $name);
+				print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$buffer.' <br>Executed query : '.$db->lastquery;
+				print "\n</td>";
+				print '<td><font class="error">'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'</font></td></tr>';
+				$error++;
+			}
+		}
+	}
+	else
+	{
+		print "<tr><td>".$langs->trans("CreateTableAndPrimaryKey", $name);
+		print "</td>";
+		print '<td><font class="error">'.$langs->trans("Error").' Failed to open file '.$dir.$file.'</td></tr>';
+		$error++;
+	}
+}
+
+if ($tablefound)
+{
+	if ($error == 0)
+	{
+		print '<tr><td>';
+		print $langs->trans("TablesAndPrimaryKeysCreation").'</td><td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
+		$ok = 1;
+	}
+}
+else
+{
+	print '<tr><td>'.$langs->trans("ErrorFailedToFindSomeFiles", $dir).'</td><td><img src="../theme/eldy/img/error.png" alt="Error"></td></tr>';
+}
+
+
+
+// We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
+
+
+$okkeys = 0;
+$handle = opendir($dir);
+$tablefound = 0;
+$tabledata = array();
+if (is_resource($handle))
+{
+	while (($file = readdir($handle)) !== false)
+	{
+		if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && preg_match('/\.key\.sql$/i', $file))
+		{
+			if (strpos($file, 'reception') !== false){
+				$tablefound++;
+				$tabledata[] = $file;
+			}
+		}
+	}
+	closedir($handle);
+}
+
+// Sort list of sql files on alphabetical order (load order is important)
+sort($tabledata);
+foreach ($tabledata as $file)
+{
+	$name = substr($file, 0, dol_strlen($file) - 4);
+	//print "<tr><td>Creation de la table $name</td>";
+	$buffer = '';
+	$fp = fopen($dir.$file, "r");
+	if ($fp)
+	{
+		while (!feof($fp))
+		{
+			$buf = fgets($fp, 4096);
+
+			// Cas special de lignes autorisees pour certaines versions uniquement
+			if ($choix == 1 && preg_match('/^--\sV([0-9\.]+)/i', $buf, $reg))
+			{
+				$versioncommande = explode('.', $reg[1]);
+				//print var_dump($versioncommande);
+				//print var_dump($versionarray);
+				if (count($versioncommande) && count($versionarray) && versioncompare($versioncommande, $versionarray) <= 0)
+				{
+					// Version qualified, delete SQL comments
+					$buf = preg_replace('/^--\sV([0-9\.]+)/i', '', $buf);
+					//print "Ligne $i qualifiee par version: ".$buf.'<br>';
+				}
+			}
+			if ($choix == 2 && preg_match('/^--\sPOSTGRESQL\sV([0-9\.]+)/i', $buf, $reg))
+			{
+				$versioncommande = explode('.', $reg[1]);
+				//print var_dump($versioncommande);
+				//print var_dump($versionarray);
+				if (count($versioncommande) && count($versionarray) && versioncompare($versioncommande, $versionarray) <= 0)
+				{
+					// Version qualified, delete SQL comments
+					$buf = preg_replace('/^--\sPOSTGRESQL\sV([0-9\.]+)/i', '', $buf);
+					//print "Ligne $i qualifiee par version: ".$buf.'<br>';
+				}
+			}
+
+			// Ajout ligne si non commentaire
+			if (!preg_match('/^--/i', $buf))
+				$buffer .= $buf;
+		}
+		fclose($fp);
+
+		// Si plusieurs requetes, on boucle sur chaque
+		$listesql = explode(';', $buffer);
+		foreach ($listesql as $req)
+		{
+			$buffer = trim($req);
+			if ($buffer)
+			{
+				// Replace the prefix tables
+				if ($dolibarr_main_db_prefix != 'llx_')
+				{
+					$buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer);
+				}
+
+				//print "<tr><td>Creation des cles et index de la table $name: '$buffer'</td>";
+				$requestnb++;
+
+				$resql = $db->query($buffer, 0, 'dml');
+				if ($resql)
+				{
+					//print "<td>OK requete ==== $buffer</td></tr>";
+					$db->free($resql);
+				}
+				else
+				{
+					if ($db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS' ||
+						$db->errno() == 'DB_ERROR_CANNOT_CREATE' ||
+						$db->errno() == 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS' ||
+						$db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS' ||
+						preg_match('/duplicate key name/i', $db->error()))
+					{
+						//print "<td>Deja existante</td></tr>";
+						$key_exists = 1;
+					}
+					else
+					{
+						print "<tr><td>".$langs->trans("CreateOtherKeysForTable", $name);
+						print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$db->lastqueryerror();
+						print "\n</td>";
+						print '<td><font class="error">'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'</font></td></tr>';
+						$error++;
+					}
+				}
+			}
+		}
+	}
+	else
+	{
+		print "<tr><td>".$langs->trans("CreateOtherKeysForTable", $name);
+		print "</td>";
+		print '<td><font class="error">'.$langs->trans("Error")." Failed to open file ".$dir.$file."</font></td></tr>";
+		$error++;
+	}
+}
+
+if ($tablefound && $error == 0)
+{
+	print '<tr><td>';
+	print $langs->trans("OtherKeysCreation").'</td><td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
+	$okkeys = 1;
+}
+