diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index 85360478500..dee1200389c 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -124,10 +124,10 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_CLOSE','BOM disabled','Executed when a BOM is disabled','bom',652); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_REOPEN','BOM reopen','Executed when a BOM is re-open','bom',653); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_DELETE','BOM deleted','Executed when a BOM deleted','bom',654); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_VALIDATE','MO validated','Executed when a MO is validated','bom',660); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_PRODUCED','MO produced','Executed when a MO is produced','bom',661); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_DELETE','MO deleted','Executed when a MO is deleted','bom',662); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_CANCEL','MO canceled','Executed when a MO is canceled','bom',663); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_VALIDATE','MO validated','Executed when a MO is validated','bom',660); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_PRODUCED','MO produced','Executed when a MO is produced','bom',661); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_DELETE','MO deleted','Executed when a MO is deleted','bom',662); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_CANCEL','MO canceled','Executed when a MO is canceled','bom',663); -- actions not enabled by default : they are excluded when we enable the module Agenda (except TASK_...) insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_CREATE','Task created','Executed when a project task is created','project',150); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_MODIFY','Task modified','Executed when a project task is modified','project',151); 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 e5d996be713..50014e2da05 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 @@ -522,10 +522,11 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_REOPEN','BOM reopen','Executed when a BOM is re-open','bom',653); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_DELETE','BOM deleted','Executed when a BOM deleted','bom',654); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_VALIDATE','MO validated','Executed when a MO is validated','bom',660); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_PRODUCED','MO produced','Executed when a MO is produced','bom',661); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_DELETE','MO deleted','Executed when a MO is deleted','bom',662); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_CANCEL','MO canceled','Executed when a MO is canceled','bom',663); +DELETE FROM llx_c_action_trigger where code LIKE 'MO_%'; +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_VALIDATE','MO validated','Executed when a MO is validated','bom',660); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_PRODUCED','MO produced','Executed when a MO is produced','bom',661); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_DELETE','MO deleted','Executed when a MO is deleted','bom',662); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_CANCEL','MO canceled','Executed when a MO is canceled','bom',663); ALTER TABLE llx_comment ADD COLUMN fk_user_modif integer DEFAULT NULL; diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 9f141d15220..6e5415067f1 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -110,9 +110,9 @@ BOM_UNVALIDATEInDolibarr=BOM unvalidated BOM_CLOSEInDolibarr=BOM disabled BOM_REOPENInDolibarr=BOM reopen BOM_DELETEInDolibarr=BOM deleted -MO_VALIDATEInDolibarr=MO validated -MO_PRODUCEDInDolibarr=MO produced -MO_DELETEInDolibarr=MO deleted +MRP_MO_VALIDATEInDolibarr=MO validated +MRP_MO_PRODUCEDInDolibarr=MO produced +MRP_MO_DELETEInDolibarr=MO deleted ##### End agenda events ##### AgendaModelModule=Document templates for event DateActionStart=Start date diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index fa9f48ee4c4..bc9abb9753d 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -741,7 +741,7 @@ NotSupported=Not supported RequiredField=Required field Result=Result ToTest=Test -ValidateBefore=Card must be validated before using this feature +ValidateBefore=Item must be validated before using this feature Visibility=Visibility Totalizable=Totalizable TotalizableDesc=This field is totalizable in list diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index e5bcb1e5318..a414920ff83 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -58,4 +58,6 @@ ConsumeAndProduceAll=Consume and Produce All Manufactured=Manufactured TheProductXIsAlreadyTheProductToProduce=The product to add is already the product to produce. ForAQuantityOf1=For a quantity to produce of 1 -ConfirmValidateMo=Are you sure you want to validate this Manufacturing Order? \ No newline at end of file +ConfirmValidateMo=Are you sure you want to validate this Manufacturing Order? +ConfirmProductionDesc=By clicking on '%s', you will validate the consumption and/or production for the quantities set. This will also update the stock and record stock movements. +ProductionForRefAndDate=Production %s - %s diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 17f2cd44069..cc08486e27d 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -47,11 +47,12 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; 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/html.formproduct.class.php'; 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", "other")); +$langs->loadLangs(array("mrp", "stocks", "other")); // Get parameters $id = GETPOST('id', 'int'); @@ -103,8 +104,6 @@ $permissiontoproduce = $permissiontoadd; /* * Actions - * - * Put here all code to do according to value of "action" parameter */ $parameters = array(); @@ -120,7 +119,7 @@ if (empty($reshook)) if (empty($backtopage) || ($cancel && empty($id))) { //var_dump($backurlforlist);exit; if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; - else $backtopage = DOL_URL_ROOT.'/mrp/mo_card.php?id='.($id > 0 ? $id : '__ID__'); + else $backtopage = DOL_URL_ROOT.'/mrp/mo_production.php?id='.($id > 0 ? $id : '__ID__'); } $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record @@ -162,6 +161,7 @@ if (empty($reshook)) $form = new Form($db); $formfile = new FormFile($db); $formproject = new FormProjets($db); +$formproduct = new FormProduct($db); llxHeader('', $langs->trans('Mo'), ''); @@ -306,48 +306,85 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea dol_fiche_end(); - print '
'; - $parameters = array(); - // Note that $action and $object may be modified by hook - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); - if (empty($reshook)) { - // Consume + if (! in_array($action, array('consume', 'produce', 'consumeandproduceall'))) + { + print '
'; - if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) { - if ($permissiontoproduce) { - print ''.$langs->trans('Consume').''; + $parameters = array(); + // Note that $action and $object may be modified by hook + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); + if (empty($reshook)) { + // Consume + + if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) { + if ($permissiontoproduce) { + print ''.$langs->trans('Consume').''; + } else { + print ''.$langs->trans('Consume').''; + } } else { - print ''.$langs->trans('Consume').''; + print ''.$langs->trans('Consume').''; + } + + // Produce + if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) { + if ($permissiontoproduce) { + print ''.$langs->trans('Produce').''; + } else { + print ''.$langs->trans('Produce').''; + } + } else { + print ''.$langs->trans('Produce').''; + } + + // ConsumeAndProduceAll + if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) { + if ($permissiontoproduce) { + print ''.$langs->trans('ConsumeAndProduceAll').''; + } else { + print ''.$langs->trans('ConsumeAndProduceAll').''; + } + } else { + print ''.$langs->trans('ConsumeAndProduceAll').''; } - } else { - print ''.$langs->trans('Consume').''; } - // Produce - if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) { - if ($permissiontoproduce) { - print ''.$langs->trans('Produce').''; - } else { - print ''.$langs->trans('Produce').''; - } - } else { - print ''.$langs->trans('Produce').''; - } - - // ConsumeAndProduceAll - if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) { - if ($permissiontoproduce) { - print ''.$langs->trans('ConsumeAndProduceAll').''; - } else { - print ''.$langs->trans('ConsumeAndProduceAll').''; - } - } else { - print ''.$langs->trans('ConsumeAndProduceAll').''; - } + print '
'; } - print '
'; + if (in_array($action, array('consume', 'produce', 'consumeandproduceall'))) + { + print '
'; + print ''; + print ''; + print ''; + print ''; + + if ($action == 'consume') + { + print $langs->trans("FeatureNotYetAvailable"); + } + if ($action == 'produce') + { + print $langs->trans("FeatureNotYetAvailable"); + } + if ($action == 'consumeandproduceall') + { + $defaultstockmovementlabel = $langs->trans("ProductionForRefAndDate", $object->ref, dol_print_date(dol_now(), 'standard')); + $defaultstockmovementcode = $object->ref.'_'.dol_print_date(dol_now(), 'dayhourlog'); + + print '
'; + print ''.$langs->trans("ConfirmProductionDesc", $langs->transnoentitiesnoconv("Confirm")).'

'; + print $langs->trans("MovementLabel").':   '; + print $langs->trans("InventoryCode").':   '; + print ''; + print '   '; + print ''; + print '
'; + print '
'; + } + } /* @@ -360,17 +397,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea //$result = $object->getLinesArray(); $object->fetchLines(); - print ' - - - - - '; - - if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } - print '
'; print '
'; print '
'; @@ -384,27 +410,54 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$langs->trans("Product").''; print ''.$langs->trans("Qty").''; print ''.$langs->trans("QtyAlreadyConsumed").''; - /*print ''.$langs->trans("Date").''; - print ''.$langs->trans("Batch").'';*/ + print ''; + if ($conf->productbatch->enabled) { + print ''; + if ($action == 'consumeandproduceall') print $langs->trans("Batch"); + print ''; + } print ''; if (!empty($object->lines)) { foreach($object->lines as $line) { if ($line->role == 'toconsume') { - print ''; $tmpproduct = new Product($db); $tmpproduct->fetch($line->fk_product); + + print ''; print ''.$tmpproduct->getNomUrl(1).''; print ''.$line->qty.''; $alreadyconsumed = 0; print ''.$alreadyconsumed.''; - /*print ''.''; - print ''.'';*/ + print ''; // Warehouse + if ($conf->productbatch->enabled) { + print ''; // Lot + } print ''; - // Show detailed of already consumed + // Show detailed of already consumed with js code to collapse //$arrayoflines = $line->fetchLinesLinked('consumed'); + + if ($action == 'consumeandproduceall') { + print ''; + print ''.$langs->trans("ToConsume").''; + print ''; + print ''; + print ''; + if ($tmpproduct->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + print $formproduct->selectWarehouses('ifone', 'idwarehouse-'.$line->id, '', 1, 0, $line->fk_product, '', 1); + } + print ''; + if ($conf->productbatch->enabled) { + print ''; + if ($tmpproduct->status_batch) { + print ''; + } + print ''; + } + print ''; + } } } } @@ -443,8 +496,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$langs->trans("Product").''; print ''.$langs->trans("Qty").''; print ''.$langs->trans("QtyAlreadyProduced").''; - /*print ''.$langs->trans("Date").''; - print ''.$langs->trans("Batch").'';*/ + print ''; + if ($conf->productbatch->enabled) { + print ''; + if ($action == 'consumeandproduceall') print $langs->trans("Batch"); + print ''; + } print ''; if (!empty($object->lines)) @@ -456,14 +513,36 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $tmpproduct->fetch($line->fk_product); print ''.$tmpproduct->getNomUrl(1).''; print ''.$line->qty.''; - $alreadyconsumed = 0; - print ''.$alreadyconsumed.''; - /*print ''.''; - print ''.'';*/ + $alreadyproduced = 0; + print ''.$alreadyproduced.''; + print ''; // Warehouse + if ($conf->productbatch->enabled) { + print ''; // Lot + } print ''; - // Show detailed of already consumed - //$arrayoflines = $line->fetchLinesLinked('consumed'); + // Show detailed of already produced + //$arrayoflines = $line->fetchLinesLinked('produced'); + + if ($action == 'consumeandproduceall') { + print ''; + print ''.$langs->trans("ToProduce").''; + print ''; + print ''; + print ''; + if ($tmpproduct->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + print $formproduct->selectWarehouses('ifone', 'idwarehouse-'.$line->id, '', 1, 0, $line->fk_product, '', 1); + } + print ''; + if ($conf->productbatch->enabled) { + print ''; + if ($tmpproduct->status_batch) { + print ''; + } + print ''; + } + print ''; + } } } } @@ -473,66 +552,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print '
'; - - print "
\n"; } - - // Buttons for actions - /* - if ($action != 'presend' && $action != 'editline') { - print '
'."\n"; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - - if (empty($reshook)) - { - // Send - print '' . $langs->trans('SendMail') . ''."\n"; - - // Modify - if (! empty($user->rights->mrp->write)) - { - print ''.$langs->trans("Modify").''."\n"; - } - else - { - print ''.$langs->trans('Modify').''."\n"; - } - - // Clone - if (! empty($user->rights->mrp->write)) - { - print '
' . $langs->trans("ToClone") . '
'; - } - - // Delete (need delete permission, or if draft, just need create/modify permission) - if (! empty($user->rights->mrp->delete) || (! empty($object->fields['status']) && $object->status == $object::STATUS_DRAFT && ! empty($user->rights->mrp->write))) - { - print ''.$langs->trans('Delete').''."\n"; - } - else - { - print ''.$langs->trans('Delete').''."\n"; - } - } - print '
'."\n"; - }*/ - - - if ($action != 'presend') + if (in_array($action, array('consume', 'produce', 'consumeandproduceall'))) { - print '
'; - print ''; // ancre - - - - print '
'; - - - - print '
'; + print "\n"; } }