Merge pull request #18624 from Hystepik/develop#1
Close #18584 : Code enhancement of MO
This commit is contained in:
commit
caf0559985
@ -74,6 +74,7 @@ NoStockChangeOnServices=No stock change on services
|
||||
ProductQtyToConsumeByMO=Product quantity still to consume by open MO
|
||||
ProductQtyToProduceByMO=Product quantity still to produce by open MO
|
||||
AddNewConsumeLines=Add new line to consume
|
||||
AddNewProduceLines=Add new line to produce
|
||||
ProductsToConsume=Products to consume
|
||||
ProductsToProduce=Products to produce
|
||||
UnitCost=Unit cost
|
||||
|
||||
@ -72,6 +72,7 @@ NoStockChangeOnServices=Aucune variation de stock sur les services
|
||||
ProductQtyToConsumeByMO=Quantité de produit restant à consommer par OF ouvert
|
||||
ProductQtyToProduceByMO=Quantités restant à produire avec les OF ouverts
|
||||
AddNewConsumeLines=Ajouter une nouvelle ligne à consommer
|
||||
AddNewProduceLines=Ajouter une nouvelle ligne à produire
|
||||
ProductsToConsume=Produits à consommer
|
||||
ProductsToProduce=Produits à produire
|
||||
UnitCost=Coût unitaire
|
||||
|
||||
@ -659,6 +659,12 @@ class Mo extends CommonObject
|
||||
$role = 'toconsume';
|
||||
$moline->role = 'toproduce';
|
||||
}
|
||||
} else {
|
||||
if ($this->mrptype == 1) {
|
||||
$moline->role = 'toconsume';
|
||||
} else {
|
||||
$moline->role = 'toproduce';
|
||||
}
|
||||
}
|
||||
|
||||
$resultline = $moline->create($user, false); // Never use triggers here
|
||||
|
||||
@ -149,14 +149,19 @@ if (empty($reshook)) {
|
||||
$result = $object->setStatut($object::STATUS_INPROGRESS, 0, '', 'MRP_REOPEN');
|
||||
}
|
||||
|
||||
if ($action == 'confirm_addconsumeline' && GETPOST('addconsumelinebutton') && $permissiontoadd) {
|
||||
if (($action == 'confirm_addconsumeline' && GETPOST('addconsumelinebutton') && $permissiontoadd)
|
||||
|| ($action == 'confirm_addproduceline' && GETPOST('addproducelinebutton') && $permissiontoadd)) {
|
||||
$moline = new MoLine($db);
|
||||
|
||||
// Line to produce
|
||||
$moline->fk_mo = $object->id;
|
||||
$moline->qty = GETPOST('qtytoadd', 'int'); ;
|
||||
$moline->fk_product = GETPOST('productidtoadd', 'int');
|
||||
$moline->role = 'toconsume';
|
||||
if (GETPOST('addconsumelinebutton')) {
|
||||
$moline->role = 'toconsume';
|
||||
} else {
|
||||
$moline->role = 'toproduce';
|
||||
}
|
||||
$moline->origin_type = 'free'; // free consume line
|
||||
$moline->position = 0;
|
||||
|
||||
@ -642,7 +647,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
if (in_array($action, array('consumeorproduce', 'consumeandproduceall', 'addconsumeline'))) {
|
||||
if (in_array($action, array('consumeorproduce', 'consumeandproduceall', 'addconsumeline', 'addproduceline'))) {
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="confirm_'.$action.'">';
|
||||
@ -962,7 +967,19 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '<div class="fichehalfright">';
|
||||
print '<div class="clearboth"></div>';
|
||||
|
||||
print load_fiche_titre($langs->trans('Production'), '', '');
|
||||
$nblinetoproduce = 0;
|
||||
foreach ($object->lines as $line) {
|
||||
if ($line->role == 'toproduce') {
|
||||
$nblinetoproduce++;
|
||||
}
|
||||
}
|
||||
$newlinetext = '';
|
||||
if ($object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED && $action != 'consumeorproduce' && $action != 'consumeandproduceall') {
|
||||
if ($nblinetoproduce == 0 || $object->mrptype == 1) {
|
||||
$newlinetext = '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addproduceline">'.$langs->trans("AddNewProduceLines").'</a>';
|
||||
}
|
||||
}
|
||||
print load_fiche_titre($langs->trans('Production'), '', '', 0, '', '', $newlinetext);
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table id="tablelinestoproduce" class="noborder noshadow nobottom centpercent">';
|
||||
@ -993,6 +1010,34 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
if ($action == 'addproduceline') {
|
||||
print '<!-- Add line to produce -->'."\n";
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>';
|
||||
print $form->select_produits('', 'productidtoadd', '', 0, 0, -1, 2, '', 0, array(), 0, '1', 0, 'maxwidth300');
|
||||
print '</td>';
|
||||
// Qty
|
||||
print '<td class="right"><input type="text" name="qtytoadd" value="1" class="width50 right"></td>';
|
||||
// Cost price
|
||||
print '<td></td>';
|
||||
|
||||
// Qty already produced
|
||||
print '<td></td>';
|
||||
// Warehouse
|
||||
print '<td>';
|
||||
print '<input type="submit" class="button buttongen" name="addproducelinebutton" value="'.$langs->trans("Add").'">';
|
||||
print '</td>';
|
||||
// Lot - serial
|
||||
if ($conf->productbatch->enabled) {
|
||||
print '<td></td>';
|
||||
}
|
||||
// Action
|
||||
if ($permissiontodelete) {
|
||||
print '<td></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
if (!empty($object->lines)) {
|
||||
$nblinetoproduce = 0;
|
||||
foreach ($object->lines as $line) {
|
||||
@ -1065,7 +1110,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '</td>';
|
||||
if ($conf->productbatch->enabled) {
|
||||
print '<td></td>'; // Lot
|
||||
print '<td></td>';
|
||||
}
|
||||
|
||||
if ($permissiontodelete && $line->origin_type == 'free') {
|
||||
$href = $_SERVER["PHP_SELF"];
|
||||
$href .= '?id='.$object->id;
|
||||
$href .= '&action=deleteline';
|
||||
$href .= '&lineid='.$line->id;
|
||||
print '<td class="center">';
|
||||
print '<a href="'.$href.'">';
|
||||
print img_picto('', "delete");
|
||||
print '</a>';
|
||||
print '</td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user