This commit is contained in:
Laurent Destailleur 2020-01-02 22:05:35 +01:00
parent d95e37aa72
commit 68d7195964
6 changed files with 160 additions and 133 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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?
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

View File

@ -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 '<div class="tabsAction">';
$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 '<div class="tabsAction">';
if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) {
if ($permissiontoproduce) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=consume">'.$langs->trans('Consume').'</a>';
$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 '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=consume">'.$langs->trans('Consume').'</a>';
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('Consume').'</a>';
}
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('Consume').'</a>';
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateBefore").'">'.$langs->trans('Consume').'</a>';
}
// Produce
if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) {
if ($permissiontoproduce) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=produce">'.$langs->trans('Produce').'</a>';
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('Produce').'</a>';
}
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateBefore").'">'.$langs->trans('Produce').'</a>';
}
// ConsumeAndProduceAll
if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) {
if ($permissiontoproduce) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=consumeandproduceall">'.$langs->trans('ConsumeAndProduceAll').'</a>';
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('ConsumeAndProduceAll').'</a>';
}
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateBefore").'">'.$langs->trans('ConsumeAndProduceAll').'</a>';
}
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateFirst").'">'.$langs->trans('Consume').'</a>';
}
// Produce
if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) {
if ($permissiontoproduce) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=produce">'.$langs->trans('Produce').'</a>';
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('Produce').'</a>';
}
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateFirst").'">'.$langs->trans('Produce').'</a>';
}
// ConsumeAndProduceAll
if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) {
if ($permissiontoproduce) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=consumeandproduceall">'.$langs->trans('ConsumeAndProduceAll').'</a>';
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('ConsumeAndProduceAll').'</a>';
}
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateFirst").'">'.$langs->trans('ConsumeAndProduceAll').'</a>';
}
print '</div>';
}
print '</div>';
if (in_array($action, array('consume', 'produce', 'consumeandproduceall')))
{
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input type="hidden" name="id" value="'.$id.'">';
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 '<div class="center">';
print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ConfirmProductionDesc", $langs->transnoentitiesnoconv("Confirm")).'<br><br></span>';
print $langs->trans("MovementLabel").': <input type="text" class="minwidth300" name="label" value="'.$defaultstockmovementlabel.'"> &nbsp; ';
print $langs->trans("InventoryCode").': <input type="text" class="maxwidth150" name="inventorycode" value="'.$defaultstockmovementcode.'"> &nbsp; ';
print '<input class="button" type="submit" value="'.$langs->trans("Confirm").'" name="confirm">';
print ' &nbsp; ';
print '<input class="button" type="submit" value="'.$langs->trans("Cancel").'" name="cancel">';
print '</div>';
print '<br>';
}
}
/*
@ -360,17 +397,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
//$result = $object->getLinesArray();
$object->fetchLines();
print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
<input type="hidden" name="token" value="' . $_SESSION ['newtoken'].'">
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
<input type="hidden" name="mode" value="">
<input type="hidden" name="id" value="' . $object->id.'">
';
if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
}
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="clearboth"></div>';
@ -384,27 +410,54 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td>'.$langs->trans("Product").'</td>';
print '<td>'.$langs->trans("Qty").'</td>';
print '<td>'.$langs->trans("QtyAlreadyConsumed").'</td>';
/*print '<td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("Batch").'</td>';*/
print '<td></td>';
if ($conf->productbatch->enabled) {
print '<td>';
if ($action == 'consumeandproduceall') print $langs->trans("Batch");
print '</td>';
}
print '</tr>';
if (!empty($object->lines))
{
foreach($object->lines as $line) {
if ($line->role == 'toconsume') {
print '<tr>';
$tmpproduct = new Product($db);
$tmpproduct->fetch($line->fk_product);
print '<tr>';
print '<td>'.$tmpproduct->getNomUrl(1).'</td>';
print '<td>'.$line->qty.'</td>';
$alreadyconsumed = 0;
print '<td>'.$alreadyconsumed.'</td>';
/*print '<td>'.'</td>';
print '<td>'.'</td>';*/
print '<td></td>'; // Warehouse
if ($conf->productbatch->enabled) {
print '<td></td>'; // Lot
}
print '</tr>';
// Show detailed of already consumed
// Show detailed of already consumed with js code to collapse
//$arrayoflines = $line->fetchLinesLinked('consumed');
if ($action == 'consumeandproduceall') {
print '<tr>';
print '<td>'.$langs->trans("ToConsume").'</td>';
print '<td><input type="text" class="width50" name="qty-'.$line->id.'" value="'.max(0, $line->qty - $alreadyconsumed).'"></td>';
print '<td></td>';
print '<td>';
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 '</td>';
if ($conf->productbatch->enabled) {
print '<td>';
if ($tmpproduct->status_batch) {
print '<input type="text" class="width50" name="batch-'.$line->id.'" value="">';
}
print '</td>';
}
print '</tr>';
}
}
}
}
@ -443,8 +496,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td>'.$langs->trans("Product").'</td>';
print '<td>'.$langs->trans("Qty").'</td>';
print '<td>'.$langs->trans("QtyAlreadyProduced").'</td>';
/*print '<td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("Batch").'</td>';*/
print '<td></td>';
if ($conf->productbatch->enabled) {
print '<td>';
if ($action == 'consumeandproduceall') print $langs->trans("Batch");
print '</td>';
}
print '</tr>';
if (!empty($object->lines))
@ -456,14 +513,36 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$tmpproduct->fetch($line->fk_product);
print '<td>'.$tmpproduct->getNomUrl(1).'</td>';
print '<td>'.$line->qty.'</td>';
$alreadyconsumed = 0;
print '<td>'.$alreadyconsumed.'</td>';
/*print '<td>'.'</td>';
print '<td>'.'</td>';*/
$alreadyproduced = 0;
print '<td>'.$alreadyproduced.'</td>';
print '<td></td>'; // Warehouse
if ($conf->productbatch->enabled) {
print '<td></td>'; // Lot
}
print '</tr>';
// Show detailed of already consumed
//$arrayoflines = $line->fetchLinesLinked('consumed');
// Show detailed of already produced
//$arrayoflines = $line->fetchLinesLinked('produced');
if ($action == 'consumeandproduceall') {
print '<tr>';
print '<td>'.$langs->trans("ToProduce").'</td>';
print '<td><input type="text" class="width50" name="qty-'.$line->id.'" value="'.max(0, $line->qty - $alreadyproduced).'"></td>';
print '<td></td>';
print '<td>';
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 '</td>';
if ($conf->productbatch->enabled) {
print '<td>';
if ($tmpproduct->status_batch) {
print '<input type="text" class="width50" name="batch-'.$line->id.'" value="">';
}
print '</td>';
}
print '</tr>';
}
}
}
}
@ -473,66 +552,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</div>';
print '</div>';
print "</form>\n";
}
// Buttons for actions
/*
if ($action != 'presend' && $action != 'editline') {
print '<div class="tabsAction">'."\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 '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'."\n";
// Modify
if (! empty($user->rights->mrp->write))
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'."\n";
}
else
{
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
}
// Clone
if (! empty($user->rights->mrp->write))
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;socid=' . $object->socid . '&amp;action=clone&amp;object=order">' . $langs->trans("ToClone") . '</a></div>';
}
// 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 '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'."\n";
}
else
{
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
}
}
print '</div>'."\n";
}*/
if ($action != 'presend')
if (in_array($action, array('consume', 'produce', 'consumeandproduceall')))
{
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
print '</div></div></div>';
print "</form>\n";
}
}