diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e4f04bde0a2..155cbdddca1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3420,7 +3420,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'group', 'help', 'holiday', 'intervention', 'label', 'language', 'link', 'list', 'listlight', 'loan', 'lot', - 'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'mrp', 'note', 'next', + 'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'movement', 'mrp', 'note', 'next', 'object_accounting', 'object_account', 'object_accountline', 'object_action', 'object_barcode', 'object_bill', 'object_billa', 'object_billd', 'object_bom', 'object_category', 'object_conversation', 'object_bookmark', 'object_bug', 'object_clock', 'object_dolly', 'object_dollyrevert', 'object_folder', 'object_folder-open','object_generic', diff --git a/htdocs/fourn/js/lib_dispatch.js.php b/htdocs/fourn/js/lib_dispatch.js.php index 254fac29f28..fd15894b4ec 100644 --- a/htdocs/fourn/js/lib_dispatch.js.php +++ b/htdocs/fourn/js/lib_dispatch.js.php @@ -93,9 +93,7 @@ function addDispatchLine(index, type, mode) if (qtyOrdered <= 1) { window.alert("Quantity can't be split"); - } - if (qtyDispatched < qtyOrdered) - { + } else if (qtyDispatched < qtyOrdered) { //replace tr suffix nbr $row.html($row.html().replace(/_0_/g,"_"+nbrTrs+"_")); //create new select2 to avoid duplicate id of cloned one diff --git a/htdocs/mrp/js/lib_dispatch.js.php b/htdocs/mrp/js/lib_dispatch.js.php index 179c7a15129..8a5eef60211 100644 --- a/htdocs/mrp/js/lib_dispatch.js.php +++ b/htdocs/mrp/js/lib_dispatch.js.php @@ -94,9 +94,9 @@ function addDispatchLine(index, type, mode) if (qtyOrdered <= 1) { window.alert("Quantity can't be split"); - } - if (qtyDispatched < qtyOrdered) - { + } else if (qtyDispatched >= qtyOrdered) { + window.alert("No remain qty to dispatch"); + } else if (qtyDispatched < qtyOrdered) { //replace tr suffix nbr var re1 = new RegExp('_'+index+'_1', 'g'); var re2 = new RegExp('-'+index+'-1', 'g'); diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 0b50bcf8e9a..5b01aff6207 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -259,32 +259,33 @@ if (empty($reshook)) { $qtytoprocess = price2num(GETPOST('qtytoproduce-'.$line->id.'-'.$i)); $pricetoprocess = GETPOST('pricetoproduce-'.$line->id.'-'.$i) ? price2num(GETPOST('pricetoproduce-'.$line->id.'-'.$i)) : 0; - // Check warehouse is set if we should have to - if (GETPOSTISSET('idwarehousetoproduce-'.$line->id.'-'.$i)) { // If there is a warehouse to set - if (!(GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0)) { // If there is no warehouse set. - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors'); - $error++; - } - if (!empty($conf->productbatch->enabled) && $tmpproduct->status_batch && (!GETPOST('batchtoproduce-'.$line->id.'-'.$i))) { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors'); - $error++; - } - } - - $idstockmove = 0; - if (!$error && GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0) { - // Record stock movement - $id_product_batch = 0; - $stockmove->origin = $object; - $idstockmove = $stockmove->reception($user, $line->fk_product, GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i), $qtytoprocess, $pricetoprocess, $labelmovement, '', '', GETPOST('batchtoproduce-'.$line->id.'-'.$i), dol_now(), $id_product_batch, $codemovement); - if ($idstockmove < 0) { - $error++; - setEventMessages($stockmove->error, $stockmove->errors, 'errors'); - } - } if ($qtytoprocess != 0) { + // Check warehouse is set if we should have to + if (GETPOSTISSET('idwarehousetoproduce-'.$line->id.'-'.$i)) { // If there is a warehouse to set + if (!(GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0)) { // If there is no warehouse set. + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors'); + $error++; + } + if (!empty($conf->productbatch->enabled) && $tmpproduct->status_batch && (!GETPOST('batchtoproduce-'.$line->id.'-'.$i))) { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors'); + $error++; + } + } + + $idstockmove = 0; + if (!$error && GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0) { + // Record stock movement + $id_product_batch = 0; + $stockmove->origin = $object; + $idstockmove = $stockmove->reception($user, $line->fk_product, GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i), $qtytoprocess, $pricetoprocess, $labelmovement, '', '', GETPOST('batchtoproduce-'.$line->id.'-'.$i), dol_now(), $id_product_batch, $codemovement); + if ($idstockmove < 0) { + $error++; + setEventMessages($stockmove->error, $stockmove->errors, 'errors'); + } + } + if (!$error) { // Record production $moline = new MoLine($db); @@ -414,6 +415,7 @@ $formproject = new FormProjets($db); $formproduct = new FormProduct($db); $tmpwarehouse = new Entrepot($db); $tmpbatch = new Productlot($db); +$tmpstockmovement = new MouvementStock($db); $help_url = 'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication'; llxHeader('', $langs->trans('Mo'), $help_url, '', 0, 0, array('/mrp/js/lib_dispatch.js.php')); @@ -654,8 +656,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $defaultstockmovementcode = GETPOST('inventorycode', 'alphanohtml') ? GETPOST('inventorycode', 'alphanohtml') : $langs->trans("ProductionForRef", $object->ref); print '
'; - print ''.$langs->trans("ConfirmProductionDesc", $langs->transnoentitiesnoconv("Confirm")).'
'; - print ''.$langs->trans("InventoryCode").':   '; + print '
'.$langs->trans("ConfirmProductionDesc", $langs->transnoentitiesnoconv("Confirm")).'
'; + print ''.$langs->trans("InventoryCode").':   '; print ''; print $langs->trans("MovementLabel").':

'; print '
'; @@ -688,7 +690,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } - // consumtion + // Lines to consume print '
'; print '
'; @@ -706,7 +708,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''.$langs->trans("Product").''; print ''.$langs->trans("Qty").''; - if ($permissiontoupdatecost) { + if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) { print ''.$langs->trans("UnitCost").''; } print ''.$langs->trans("QtyAlreadyConsumed").''; @@ -731,7 +733,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $form->select_produits('', 'productidtoadd', '', 0, 0, -1, 2, '', 0, array(), 0, '1', 0, 'maxwidth300'); print ''; print ''; - if ($permissiontoupdatecost) { + if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) { print ''; } print ''; @@ -809,7 +811,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $line->qty; } print ''; - if ($permissiontoupdatecost) { + if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) { print ''; print price($linecost); print ''; @@ -853,11 +855,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea foreach ($arrayoflines as $line2) { print ''; print ''; - print dol_print_date($line2['date'], 'dayhour'); + $tmpstockmovement->id = $line2['fk_stock_movement']; + print ''.img_picto($langs->trans("StockMovement"), 'movement', 'class="paddingright"').''; + print dol_print_date($line2['date'], 'dayhour', 'tzuserrel'); print ''; print ''; print ''.$line2['qty'].''; - if ($permissiontoupdatecost) { + if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) { print ''; } print ''; @@ -888,7 +892,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $preselected = 0; } print ''; - if ($permissiontoupdatecost) { + if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) { print ''; } print ''; @@ -922,6 +926,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print '
'; + // Lines to produce print '
'; @@ -1039,13 +1044,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea foreach ($arrayoflines as $line2) { print ''; print ''; - print dol_print_date($line2['date'], 'dayhour'); + $tmpstockmovement->id = $line2['fk_stock_movement']; + print ''.img_picto($langs->trans("StockMovement"), 'movement', 'class="paddingright"').''; + print dol_print_date($line2['date'], 'dayhour', 'tzuserrel'); print ''; + // Qty print ''; - print ''.$line2['qty'].''; + // Cost price if ($permissiontoupdatecost) { print ''; } + // Qty already produced + print ''.$line2['qty'].''; print ''; if ($line2['fk_warehouse'] > 0) { $result = $tmpwarehouse->fetch($line2['fk_warehouse']); @@ -1076,10 +1086,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } print ''; if ($permissiontoupdatecost) { - $preselected = (GETPOSTISSET('pricetoproduce-'.$line->id.'-'.$i) ? GETPOST('pricetoproduce-'.$line->id.'-'.$i) : price($bomcost)); - print ''; - } else { - print ''; + if ($tmpproduct->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $preselected = (GETPOSTISSET('pricetoproduce-'.$line->id.'-'.$i) ? GETPOST('pricetoproduce-'.$line->id.'-'.$i) : price($bomcost)); + print ''; + } else { + print ''; + } } print ''; print ''; @@ -1097,6 +1109,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; } print ''; + // Batch number in same column than the stock movement picto print ''; if ($tmpproduct->status_batch) { $type = 'batch'; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index bea9e1173a7..548afb3037a 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4580,6 +4580,9 @@ class Product extends CommonObject $label .= "
".$labelsurfacevolume; } } + if (!empty($this->pmp) && $this->pmp) { + $label .= "
".$langs->trans("PMPValue").': '.price($this->pmp, 0, '', 1, -1, -1, $conf->currency); + } if (!empty($conf->accounting->enabled) && $this->status) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';