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_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_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 ('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 ('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 ('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_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 ('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 ('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_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_...) -- 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_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); 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_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 ('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); DELETE FROM llx_c_action_trigger where code LIKE 'MO_%';
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 ('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 ('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_PRODUCED','MO produced','Executed when a MO is produced','bom',661);
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_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; 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_CLOSEInDolibarr=BOM disabled
BOM_REOPENInDolibarr=BOM reopen BOM_REOPENInDolibarr=BOM reopen
BOM_DELETEInDolibarr=BOM deleted BOM_DELETEInDolibarr=BOM deleted
MO_VALIDATEInDolibarr=MO validated MRP_MO_VALIDATEInDolibarr=MO validated
MO_PRODUCEDInDolibarr=MO produced MRP_MO_PRODUCEDInDolibarr=MO produced
MO_DELETEInDolibarr=MO deleted MRP_MO_DELETEInDolibarr=MO deleted
##### End agenda events ##### ##### End agenda events #####
AgendaModelModule=Document templates for event AgendaModelModule=Document templates for event
DateActionStart=Start date DateActionStart=Start date

View File

@ -741,7 +741,7 @@ NotSupported=Not supported
RequiredField=Required field RequiredField=Required field
Result=Result Result=Result
ToTest=Test ToTest=Test
ValidateBefore=Card must be validated before using this feature ValidateBefore=Item must be validated before using this feature
Visibility=Visibility Visibility=Visibility
Totalizable=Totalizable Totalizable=Totalizable
TotalizableDesc=This field is totalizable in list TotalizableDesc=This field is totalizable in list

View File

@ -59,3 +59,5 @@ Manufactured=Manufactured
TheProductXIsAlreadyTheProductToProduce=The product to add is already the product to produce. TheProductXIsAlreadyTheProductToProduce=The product to add is already the product to produce.
ForAQuantityOf1=For a quantity to produce of 1 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.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.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.'/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/class/mo.class.php');
dol_include_once('/mrp/lib/mrp_mo.lib.php'); dol_include_once('/mrp/lib/mrp_mo.lib.php');
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("mrp", "other")); $langs->loadLangs(array("mrp", "stocks", "other"));
// Get parameters // Get parameters
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
@ -103,8 +104,6 @@ $permissiontoproduce = $permissiontoadd;
/* /*
* Actions * Actions
*
* Put here all code to do according to value of "action" parameter
*/ */
$parameters = array(); $parameters = array();
@ -120,7 +119,7 @@ if (empty($reshook))
if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && empty($id))) {
//var_dump($backurlforlist);exit; //var_dump($backurlforlist);exit;
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; 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 $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); $form = new Form($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
$formproject = new FormProjets($db); $formproject = new FormProjets($db);
$formproduct = new FormProduct($db);
llxHeader('', $langs->trans('Mo'), ''); llxHeader('', $langs->trans('Mo'), '');
@ -306,6 +306,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
dol_fiche_end(); dol_fiche_end();
if (! in_array($action, array('consume', 'produce', 'consumeandproduceall')))
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
$parameters = array(); $parameters = array();
@ -321,7 +324,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('Consume').'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('Consume').'</a>';
} }
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateFirst").'">'.$langs->trans('Consume').'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateBefore").'">'.$langs->trans('Consume').'</a>';
} }
// Produce // Produce
@ -332,7 +335,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('Produce').'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('Produce').'</a>';
} }
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateFirst").'">'.$langs->trans('Produce').'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateBefore").'">'.$langs->trans('Produce').'</a>';
} }
// ConsumeAndProduceAll // ConsumeAndProduceAll
@ -343,11 +346,45 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('ConsumeAndProduceAll').'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('ConsumeAndProduceAll').'</a>';
} }
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateFirst").'">'.$langs->trans('ConsumeAndProduceAll').'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateBefore").'">'.$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(); //$result = $object->getLinesArray();
$object->fetchLines(); $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="fichecenter">';
print '<div class="fichehalfleft">'; print '<div class="fichehalfleft">';
print '<div class="clearboth"></div>'; 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("Product").'</td>';
print '<td>'.$langs->trans("Qty").'</td>'; print '<td>'.$langs->trans("Qty").'</td>';
print '<td>'.$langs->trans("QtyAlreadyConsumed").'</td>'; print '<td>'.$langs->trans("QtyAlreadyConsumed").'</td>';
/*print '<td>'.$langs->trans("Date").'</td>'; print '<td></td>';
print '<td>'.$langs->trans("Batch").'</td>';*/ if ($conf->productbatch->enabled) {
print '<td>';
if ($action == 'consumeandproduceall') print $langs->trans("Batch");
print '</td>';
}
print '</tr>'; print '</tr>';
if (!empty($object->lines)) if (!empty($object->lines))
{ {
foreach($object->lines as $line) { foreach($object->lines as $line) {
if ($line->role == 'toconsume') { if ($line->role == 'toconsume') {
print '<tr>';
$tmpproduct = new Product($db); $tmpproduct = new Product($db);
$tmpproduct->fetch($line->fk_product); $tmpproduct->fetch($line->fk_product);
print '<tr>';
print '<td>'.$tmpproduct->getNomUrl(1).'</td>'; print '<td>'.$tmpproduct->getNomUrl(1).'</td>';
print '<td>'.$line->qty.'</td>'; print '<td>'.$line->qty.'</td>';
$alreadyconsumed = 0; $alreadyconsumed = 0;
print '<td>'.$alreadyconsumed.'</td>'; print '<td>'.$alreadyconsumed.'</td>';
/*print '<td>'.'</td>'; print '<td></td>'; // Warehouse
print '<td>'.'</td>';*/ if ($conf->productbatch->enabled) {
print '<td></td>'; // Lot
}
print '</tr>'; print '</tr>';
// Show detailed of already consumed // Show detailed of already consumed with js code to collapse
//$arrayoflines = $line->fetchLinesLinked('consumed'); //$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("Product").'</td>';
print '<td>'.$langs->trans("Qty").'</td>'; print '<td>'.$langs->trans("Qty").'</td>';
print '<td>'.$langs->trans("QtyAlreadyProduced").'</td>'; print '<td>'.$langs->trans("QtyAlreadyProduced").'</td>';
/*print '<td>'.$langs->trans("Date").'</td>'; print '<td></td>';
print '<td>'.$langs->trans("Batch").'</td>';*/ if ($conf->productbatch->enabled) {
print '<td>';
if ($action == 'consumeandproduceall') print $langs->trans("Batch");
print '</td>';
}
print '</tr>'; print '</tr>';
if (!empty($object->lines)) if (!empty($object->lines))
@ -456,14 +513,36 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$tmpproduct->fetch($line->fk_product); $tmpproduct->fetch($line->fk_product);
print '<td>'.$tmpproduct->getNomUrl(1).'</td>'; print '<td>'.$tmpproduct->getNomUrl(1).'</td>';
print '<td>'.$line->qty.'</td>'; print '<td>'.$line->qty.'</td>';
$alreadyconsumed = 0; $alreadyproduced = 0;
print '<td>'.$alreadyconsumed.'</td>'; print '<td>'.$alreadyproduced.'</td>';
/*print '<td>'.'</td>'; print '<td></td>'; // Warehouse
print '<td>'.'</td>';*/ if ($conf->productbatch->enabled) {
print '<td></td>'; // Lot
}
print '</tr>'; print '</tr>';
// Show detailed of already consumed // Show detailed of already produced
//$arrayoflines = $line->fetchLinesLinked('consumed'); //$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,67 +552,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</div>'; print '</div>';
print '</div>'; print '</div>';
}
if (in_array($action, array('consume', 'produce', 'consumeandproduceall')))
{
print "</form>\n"; 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')
{
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>';
}
} }
// End of page // End of page