diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 24c62c040e4..18972bc6b8f 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -554,6 +554,7 @@ ALTER TABLE llx_mrp_production MODIFY COLUMN qty real NOT NULL DEFAULT 1; ALTER TABLE llx_mrp_production ADD COLUMN qty_frozen smallint DEFAULT 0; ALTER TABLE llx_mrp_production ADD COLUMN disable_stock_change smallint DEFAULT 0; + ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_mo FOREIGN KEY (fk_mo) REFERENCES llx_mrp_mo (rowid); ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid); ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_stock_movement FOREIGN KEY (fk_stock_movement) REFERENCES llx_stock_mouvement (rowid); diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 832335bdbae..4660eaf9246 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -469,7 +469,10 @@ update llx_facturedet set product_type = 1 where product_type = 0 AND fk_product update llx_facture_fourn_det set product_type = 0 where product_type = 1 AND fk_product > 0 AND fk_product IN (SELECT rowid FROM llx_product WHERE fk_product_type = 0); update llx_facture_fourn_det set product_type = 1 where product_type = 0 AND fk_product > 0 AND fk_product IN (SELECT rowid FROM llx_product WHERE fk_product_type = 1); - + +DELETE FROM llx_mrp_production where qty = 0; + + UPDATE llx_accounting_bookkeeping set date_creation = tms where date_creation IS NULL; diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index be784dbf5ad..df7ad6ea94f 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -496,6 +496,7 @@ class Mo extends CommonObject if ($obj) { $resarray[] = array( 'rowid'=> $obj->rowid, + 'date'=> $this->db->jdate($obj->date_creation), 'qty' => $obj->qty, 'role' => $obj->role, 'fk_product' => $obj->fk_product, diff --git a/htdocs/mrp/lib/mrp_mo.lib.php b/htdocs/mrp/lib/mrp_mo.lib.php index 2e47c7bf621..c3f8e7825d4 100644 --- a/htdocs/mrp/lib/mrp_mo.lib.php +++ b/htdocs/mrp/lib/mrp_mo.lib.php @@ -43,6 +43,12 @@ function moPrepareHead($object) $head[$h][0] = DOL_URL_ROOT.'/mrp/mo_production.php?id='.$object->id; $head[$h][1] = $langs->trans("Production"); + $arrayproduced = $object->fetchLinesLinked('produced', 0); + $nbProduced = 0; + foreach($arrayproduced as $lineproduced) { + $nbProduced += $lineproduced['qty']; + } + $head[$h][1].= ''.$nbProduced.' / '.$object->qty.''; $head[$h][2] = 'production'; $h++; diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 6a2b0e88dc4..148caa30ed7 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -49,6 +49,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; dol_include_once('/mrp/class/mo.class.php'); dol_include_once('/mrp/lib/mrp_mo.lib.php'); @@ -66,6 +67,8 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'moc $backtopage = GETPOST('backtopage', 'alpha'); //$lineid = GETPOST('lineid', 'int'); +$collapse = GETPOST('collapse', 'aZ09comma'); + // Initialize technical objects $object = new Mo($db); $extrafields = new ExtraFields($db); @@ -371,6 +374,7 @@ $form = new Form($db); $formfile = new FormFile($db); $formproject = new FormProjets($db); $formproduct = new FormProduct($db); +$tmpwarehouse = new Entrepot($db); llxHeader('', $langs->trans('Mo'), ''); @@ -587,6 +591,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea /* * Lines */ + $collapse = 1; if (!empty($object->table_element_line)) { @@ -601,26 +606,36 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print load_fiche_titre($langs->trans('Consumption'), '', ''); print '
'; - print ''; + print '
'; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; if ($conf->productbatch->enabled) { print ''; } print ''; if (!empty($object->lines)) { - foreach($object->lines as $line) { + $nblinetoconsume = 0; + foreach($object->lines as $line) { + if ($line->role == 'toconsume') { + $nblinetoconsume++; + } + } + + $nblinetoconsumecursor = 0; + foreach($object->lines as $line) { if ($line->role == 'toconsume') { + $nblinetoconsumecursor++; + $tmpproduct = new Product($db); $tmpproduct->fetch($line->fk_product); @@ -632,31 +647,37 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; - print ''; - print ''; - print ''; + print ''; if ($conf->productbatch->enabled) { print ''; // Lot @@ -664,7 +685,22 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; // Show detailed of already consumed with js code to collapse - //$arrayoflines = $object->fetchLinesLinked('consumed', $line->id); + foreach($arrayoflines as $line2) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { $i = 1; @@ -672,7 +708,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; $preselected = (GETPOSTISSET('qty-'.$line->id.'-'.$i) ? GETPOST('qty-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyconsumed)); if ($action == 'consumeorproduce' && ! GETPOSTISSET('qty-'.$line->id.'-'.$i)) $preselected = 0; - print ''; + print ''; print ''; print '
'.$langs->trans("Product").''.$langs->trans("Qty").''.$langs->trans("QtyAlreadyConsumed").''.$langs->trans("Qty").''.$langs->trans("QtyAlreadyConsumed").''; - if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) print $langs->trans("Warehouse"); + if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) print $langs->trans("Warehouse"); print ''; - if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) print $langs->trans("Batch"); + if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) print $langs->trans("Batch"); print '
'.$tmpproduct->getNomUrl(1).''; + print ''; $help = ''; if ($line->qty_frozen) $help.=($help ? '
' : '').''.$langs->trans("QuantityFrozen").': '.yn(1).' ('.$langs->trans("QuantityConsumedInvariable").')'; if ($line->disable_stock_change) $help.=($help ? '
' : '').''.$langs->trans("DisableStockChange").': '.yn(1).' ('.(($tmpproduct->type == Product::TYPE_SERVICE && empty($conf->global->STOCK_SUPPORTS_SERVICES)) ? $langs->trans("NoStockChangeOnServices") : $langs->trans("DisableStockChangeHelp")).')'; if ($help) { - print $form->textwithpicto($line->qty, $help); + print $form->textwithpicto($line->qty, $help, -1); } else { print $line->qty; } print '
'.$alreadyconsumed.''; // Warehouse + print ''; if ($alreadyconsumed) { - print ''; - if (empty($conf->use_javascript_ajax)) print 'id.'">'; - print img_picto($langs->trans("ShowDetails"), "chevron-down", 'id="expandtoproduce'.$line->id.'"'); - if (empty($conf->use_javascript_ajax)) print ''; + print ''; + if (empty($conf->use_javascript_ajax)) print 'id.'">'; + print img_picto($langs->trans("ShowDetails"), "chevron-down", 'id="expandtoproduce'.$line->id.'"'); + if (empty($conf->use_javascript_ajax)) print ''; } + print ' '.$alreadyconsumed; + print ''; // Warehouse print '
'; + print dol_print_date($line2['date'], 'dayhour'); + print ''.$line2['qty'].''; + if ($line2['fk_warehouse'] > 0) { + $tmpwarehouse->fetch($line2['fk_warehouse']); + print $tmpwarehouse->getNomUrl(); + } + print ''.$line2['batch'].'
'.$langs->trans("ToConsume").''; if ($tmpproduct->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { @@ -700,24 +736,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } - /*if (!empty($object->lines)) - { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/mrp/tpl'); - } - - // Form to add new line - if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') - { - if ($action != 'editline') - { - // Add products/services form - $object->formAddObjectLine(1, $mysoc, $soc, '/mrp/tpl'); - - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - } - }*/ - print '
'; print '
'; @@ -728,26 +746,36 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print load_fiche_titre($langs->trans('Production'), '', ''); print '
'; - print ''; + print '
'; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; if ($conf->productbatch->enabled) { print ''; } print ''; if (!empty($object->lines)) { + $nblinetoproduce = 0; foreach($object->lines as $line) { if ($line->role == 'toproduce') { + $nblinetoproduce++; + } + } + + $nblinetoproducecursor = 0; + foreach($object->lines as $line) { + if ($line->role == 'toproduce') { + $nblinetoproducecursor++; + $tmpproduct = new Product($db); $tmpproduct->fetch($line->fk_product); @@ -759,34 +787,58 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; if ($conf->productbatch->enabled) { print ''; // Lot } print ''; + // Show detailed of already consumed with js code to collapse + foreach($arrayoflines as $line2) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { print ''; print ''; $preselected = (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i) ? GETPOST('qtytoproduce-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyproduced)); if ($action == 'consumeorproduce' && ! GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) $preselected = 0; - print ''; + print ''; print ''; print '
'.$langs->trans("Product").''.$langs->trans("Qty").''.$langs->trans("QtyAlreadyProduced").''.$langs->trans("Qty").''.$langs->trans("QtyAlreadyProduced").''; - if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) print $langs->trans("Warehouse"); + if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) print $langs->trans("Warehouse"); print ''; - if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) print $langs->trans("Batch"); + if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) print $langs->trans("Batch"); print '
'.$tmpproduct->getNomUrl(1).''.$line->qty.''.$alreadyproduced.''; // Warehouse + print ''.$line->qty.''; if ($alreadyproduced) { print ''; if (empty($conf->use_javascript_ajax)) print 'id.'">'; - print img_picto($langs->trans("ShowDetails"), "chevron-down", 'id="expand'.$line->id.'"'); + print img_picto($langs->trans("ShowDetails"), "chevron-down", 'id="expandtoproduce'.$line->id.'"'); if (empty($conf->use_javascript_ajax)) print ''; } + print ' '.$alreadyproduced; + print ''; // Warehouse print '
'; + print dol_print_date($line2['date'], 'dayhour'); + print ''.$line2['qty'].''; + if ($line2['fk_warehouse'] > 0) { + $tmpwarehouse->fetch($line2['fk_warehouse']); + print $tmpwarehouse->getNomUrl(); + } + print ''.$line2['batch'].'
'.$langs->trans("ToProduce").''; if ($tmpproduct->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index c8c535a9038..a8e2339a7b9 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -244,6 +244,9 @@ select.flat, form.flat select { .opacitymediumbycolor { color: rgba(0, 0, 0, 0.4); } +.opacitylow { + opacity: 0.6; +} .opacityhigh { opacity: 0.2; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 50c637be3c9..e396b5f7a42 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -462,6 +462,9 @@ select.flat, form.flat select { .opacitymediumbycolor { color: rgba(0, 0, 0, 0.4); } +.opacitylow { + opacity: 0.6; +} .opacityhigh { opacity: 0.2; }