diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index c8706d1b22e..302cf3b47b7 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -55,7 +55,7 @@ if (!empty($conf->variants->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php';
}
-$langs->loadLangs(array('admin', 'orders', 'sendings', 'companies', 'bills', 'propal', 'supplier_proposal', 'deliveries', 'products', 'stocks', 'productbatch'));
+$langs->loadLangs(array('admin', 'orders', 'sendings', 'companies', 'bills', 'propal', 'receptions', 'supplier_proposal', 'deliveries', 'products', 'stocks', 'productbatch'));
if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
$id = GETPOST('id', 'int');
@@ -2483,11 +2483,14 @@ elseif (!empty($object->id))
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)))
{
+ $labelofbutton = $langs->trans('ReceiveProducts');
+ if ($conf->reception->enabled) $labelofbutton = $langs->trans("CreateReception");
+
if (in_array($object->statut, array(3, 4, 5))) {
if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->receptionner) {
- print '
';
+ print '';
} else {
- print '';
+ print '';
}
}
}
diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php
index dd55bb36ffb..014b7f20ced 100644
--- a/htdocs/fourn/commande/dispatch.php
+++ b/htdocs/fourn/commande/dispatch.php
@@ -379,7 +379,7 @@ $warehouse_static = new Entrepot($db);
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
$help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
-llxHeader('', $langs->trans("Order"), $help_url, '', 0, 0, array('/fourn/js/lib_dispatch.js'));
+llxHeader('', $langs->trans("Order"), $help_url, '', 0, 0, array('/fourn/js/lib_dispatch.js.php'));
if ($id > 0 || !empty($ref)) {
$soc = new Societe($db);
@@ -808,12 +808,12 @@ if ($id > 0 || !empty($ref)) {
if (! empty($conf->productbatch->enabled) && $objp->tobatch == 1) {
$type = 'batch';
//print img_picto($langs->trans('AddDispatchBatchLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
- print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
+ print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine('.$i.', \''.$type.'\')"');
}
else
{
$type = 'dispatch';
- print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
+ print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine('.$i.', \''.$type.'\')"');
}
print '';
@@ -894,7 +894,8 @@ if ($id > 0 || !empty($ref)) {
print ' '.$checkboxlabel;
}
- empty($conf->reception->enabled) ? $dispatchBt = $langs->trans("DispatchVerb") : $dispatchBt = $langs->trans("Receive");
+
+ $dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive") : $langs->trans("CreateReception");
print '
// Copyright (C) 2017 Francis Appels
//
@@ -15,14 +16,33 @@
// along with this program. If not, see .
// or see https://www.gnu.org/
-//
-// \file htdocs/core/js/lib_dispatch.js
-// \brief File that include javascript functions used dispatch.php
-//
+/**
+ * \file htdocs/core/js/lib_dispatch.js.php
+ * \brief File that include javascript functions used for dispatching qty/stock/lot
+ */
+if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
+if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1);
+if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1);
+if (! defined('NOLOGIN')) define('NOLOGIN', 1);
+if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1);
+if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1);
+if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
+
+session_cache_limiter('public');
+
+require_once '../../main.inc.php';
+
+// Define javascript type
+top_httphead('text/javascript; charset=UTF-8');
+// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
+if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate');
+else header('Cache-Control: no-cache');
+
+?>
/**
* addDispatchLine
- * Adds new table row for dispatching to multiple stock locations
+ * Adds new table row for dispatching to multiple stock locations or multiple lot/serial
*
* @param index int index of product line. 0 = first product line
* @param type string type of dispatch (batch = batch dispatch, dispatch = non batch dispatch)
@@ -32,7 +52,7 @@ function addDispatchLine(index, type, mode)
{
mode = mode || 'qtymissing'
- console.log("fourn/js/lib_dispatch.js Split line type="+type+" index="+index+" mode="+mode);
+ console.log("fourn/js/lib_dispatch.js.php Split line type="+type+" index="+index+" mode="+mode);
var $row = $("tr[name='"+type+'_0_'+index+"']").clone(true), // clone first batch line to jQuery object
nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length, // position of line for batch
qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()), // Qty ordered is same for all rows
@@ -46,8 +66,17 @@ function addDispatchLine(index, type, mode)
else
{
qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()) + qty;
+ // If user did not reduced the qty to dispatch on old line, we keep only 1 on old line and the rest on new line
+ if (qtyDispatched == qtyOrdered && qtyDispatched > 1) {
+ qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()) + 1;
+ mode = 'lessone';
+ }
}
+ console.log("qtyDispatched="+qtyDispatched+" qtyOrdered="+qtyOrdered);
+ if (qtyOrdered <= 1) {
+ window.alert("Quantity can't be split");
+ }
if (qtyDispatched < qtyOrdered)
{
//replace tr suffix nbr
diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php
index a065cc922fe..c8c7ec0e624 100644
--- a/htdocs/mrp/mo_production.php
+++ b/htdocs/mrp/mo_production.php
@@ -57,7 +57,7 @@ dol_include_once('/mrp/class/mo.class.php');
dol_include_once('/mrp/lib/mrp_mo.lib.php');
// Load translation files required by the page
-$langs->loadLangs(array("mrp", "stocks", "other"));
+$langs->loadLangs(array("mrp", "stocks", "other", "productbatch"));
// Get parameters
$id = GETPOST('id', 'int');
@@ -621,11 +621,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if (in_array($action, array('consumeorproduce', 'consumeandproduceall', 'addconsumeline')))
{
- print '