Add qty frozen and disable stock change flag on BOM
This commit is contained in:
parent
5cb9434bb4
commit
eb112d4012
@ -125,9 +125,11 @@ if (empty($reshook))
|
|||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
// Set if we used free entry or predefined product
|
// Set if we used free entry or predefined product
|
||||||
$idprod=GETPOST('idprod', 'int');
|
$idprod = GETPOST('idprod', 'int');
|
||||||
$qty=GETPOST('qty', 'int');
|
$qty = GETPOST('qty', 'int');
|
||||||
$efficiency=GETPOST('efficiency', 'int');
|
$qty_frozen = GETPOST('qty_frozen', 'int');
|
||||||
|
$disable_stock_change = GETPOST('disable_stock_change', 'int');
|
||||||
|
$efficiency = GETPOST('efficiency', 'int');
|
||||||
|
|
||||||
if ($qty == '') {
|
if ($qty == '') {
|
||||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
|
||||||
@ -138,17 +140,27 @@ if (empty($reshook))
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$bomline = new BOMLine($db);
|
if (! $error)
|
||||||
$bomline->fk_bom = $id;
|
|
||||||
$bomline->fk_product = $idprod;
|
|
||||||
$bomline->qty = $qty;
|
|
||||||
$bomline->efficiency = $efficiency;
|
|
||||||
|
|
||||||
$result = $bomline->create($user);
|
|
||||||
if ($result <= 0)
|
|
||||||
{
|
{
|
||||||
setEventMessages($bomline->error, $bomline->errors, 'errors');
|
$bomline = new BOMLine($db);
|
||||||
$action = '';
|
$bomline->fk_bom = $id;
|
||||||
|
$bomline->fk_product = $idprod;
|
||||||
|
$bomline->qty = $qty;
|
||||||
|
$bomline->qty_frozen = $qty_frozen;
|
||||||
|
$bomline->disable_stock_change = $disable_stock_change;
|
||||||
|
$bomline->efficiency = $efficiency;
|
||||||
|
|
||||||
|
$result = $bomline->create($user);
|
||||||
|
if ($result <= 0)
|
||||||
|
{
|
||||||
|
setEventMessages($bomline->error, $bomline->errors, 'errors');
|
||||||
|
$action = '';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unset($_POST['qty_frozen']);
|
||||||
|
unset($_POST['disable_stock_change']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,6 +172,8 @@ if (empty($reshook))
|
|||||||
|
|
||||||
// Set if we used free entry or predefined product
|
// Set if we used free entry or predefined product
|
||||||
$qty=GETPOST('qty', 'int');
|
$qty=GETPOST('qty', 'int');
|
||||||
|
$qty_frozen = GETPOST('qty_frozen', 'int');
|
||||||
|
$disable_stock_change = GETPOST('disable_stock_change', 'int');
|
||||||
$efficiency=GETPOST('efficiency', 'int');
|
$efficiency=GETPOST('efficiency', 'int');
|
||||||
|
|
||||||
if ($qty == '') {
|
if ($qty == '') {
|
||||||
@ -170,6 +184,8 @@ if (empty($reshook))
|
|||||||
$bomline = new BOMLine($db);
|
$bomline = new BOMLine($db);
|
||||||
$bomline->fetch($lineid);
|
$bomline->fetch($lineid);
|
||||||
$bomline->qty = $qty;
|
$bomline->qty = $qty;
|
||||||
|
$bomline->qty_frozen = $qty_frozen;
|
||||||
|
$bomline->disable_stock_change = $disable_stock_change;
|
||||||
$bomline->efficiency = $efficiency;
|
$bomline->efficiency = $efficiency;
|
||||||
|
|
||||||
$result = $bomline->update($user);
|
$result = $bomline->update($user);
|
||||||
@ -178,6 +194,11 @@ if (empty($reshook))
|
|||||||
setEventMessages($bomline->error, $bomline->errors, 'errors');
|
setEventMessages($bomline->error, $bomline->errors, 'errors');
|
||||||
$action = '';
|
$action = '';
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unset($_POST['qty_frozen']);
|
||||||
|
unset($_POST['disable_stock_change']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1041,7 +1041,9 @@ class BOMLine extends CommonObject
|
|||||||
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,),
|
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,),
|
||||||
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,),
|
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,),
|
||||||
'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'position'=>100, 'notnull'=>1, 'isameasure'=>'1',),
|
'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'position'=>100, 'notnull'=>1, 'isameasure'=>'1',),
|
||||||
'efficiency' => array('type'=>'double(8,4)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'),
|
'qty_frozen' => array('type'=>'smallint', 'label'=>'QuantityFrozen', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>105, 'css'=>'maxwidth50imp', 'help'=>'QuantityConsumedInvariable'),
|
||||||
|
'disable_stock_change' => array('type'=>'smallint', 'label'=>'DisableStockChange', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>108, 'css'=>'maxwidth50imp', 'help'=>'DisableStockChangeHelp'),
|
||||||
|
'efficiency' => array('type'=>'double(8,4)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'),
|
||||||
'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'default'=>0, 'position'=>200, 'notnull'=>1,),
|
'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'default'=>0, 'position'=>200, 'notnull'=>1,),
|
||||||
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,),
|
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,),
|
||||||
);
|
);
|
||||||
@ -1050,6 +1052,8 @@ class BOMLine extends CommonObject
|
|||||||
public $fk_product;
|
public $fk_product;
|
||||||
public $description;
|
public $description;
|
||||||
public $qty;
|
public $qty;
|
||||||
|
public $qty_frozen;
|
||||||
|
public $disable_stock_change;
|
||||||
public $efficiency;
|
public $efficiency;
|
||||||
public $position;
|
public $position;
|
||||||
public $import_key;
|
public $import_key;
|
||||||
@ -1316,47 +1320,7 @@ class BOMLine extends CommonObject
|
|||||||
public function LibStatut($status, $mode = 0)
|
public function LibStatut($status, $mode = 0)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
if (empty($this->labelstatus))
|
return '';
|
||||||
{
|
|
||||||
global $langs;
|
|
||||||
//$langs->load("mrp");
|
|
||||||
$this->labelstatus[1] = $langs->trans('Enabled');
|
|
||||||
$this->labelstatus[0] = $langs->trans('Disabled');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($mode == 0)
|
|
||||||
{
|
|
||||||
return $this->labelstatus[$status];
|
|
||||||
}
|
|
||||||
elseif ($mode == 1)
|
|
||||||
{
|
|
||||||
return $this->labelstatus[$status];
|
|
||||||
}
|
|
||||||
elseif ($mode == 2)
|
|
||||||
{
|
|
||||||
if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status];
|
|
||||||
elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status];
|
|
||||||
}
|
|
||||||
elseif ($mode == 3)
|
|
||||||
{
|
|
||||||
if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle');
|
|
||||||
elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle');
|
|
||||||
}
|
|
||||||
elseif ($mode == 4)
|
|
||||||
{
|
|
||||||
if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status];
|
|
||||||
elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status];
|
|
||||||
}
|
|
||||||
elseif ($mode == 5)
|
|
||||||
{
|
|
||||||
if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle');
|
|
||||||
elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle');
|
|
||||||
}
|
|
||||||
elseif ($mode == 6)
|
|
||||||
{
|
|
||||||
if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle');
|
|
||||||
elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -63,11 +63,13 @@ if ($nolinesbefore) {
|
|||||||
print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
|
print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
|
||||||
if ($conf->global->PRODUCT_USE_UNITS)
|
if ($conf->global->PRODUCT_USE_UNITS)
|
||||||
{
|
{
|
||||||
print '<td class="linecoluseunit left">';
|
print '<td class="linecoluseunit left">';
|
||||||
print '<span id="title_units">';
|
print '<span id="title_units">';
|
||||||
print $langs->trans('Unit');
|
print $langs->trans('Unit');
|
||||||
print '</span></td>';
|
print '</span></td>';
|
||||||
}
|
}
|
||||||
|
print '<td class="linecolqtyfrozen right">'.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).'</td>';
|
||||||
|
print '<td class="linecoldisablestockchange right">'.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).'</td>';
|
||||||
print '<td class="linecollost right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).'</td>';
|
print '<td class="linecollost right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).'</td>';
|
||||||
print '<td class="linecoledit" colspan="'.$colspan.'"> </td>';
|
print '<td class="linecoledit" colspan="'.$colspan.'"> </td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
@ -109,6 +111,7 @@ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
|
|||||||
$coldisplay++;
|
$coldisplay++;
|
||||||
print '<td class="nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="'.(isset($_POST["qty"])?GETPOST("qty", 'alpha', 2):1).'">';
|
print '<td class="nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="'.(isset($_POST["qty"])?GETPOST("qty", 'alpha', 2):1).'">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
if($conf->global->PRODUCT_USE_UNITS)
|
if($conf->global->PRODUCT_USE_UNITS)
|
||||||
{
|
{
|
||||||
$coldisplay++;
|
$coldisplay++;
|
||||||
@ -118,7 +121,14 @@ if($conf->global->PRODUCT_USE_UNITS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$coldisplay++;
|
$coldisplay++;
|
||||||
|
print '<td class="nobottom linecolqtyfrozen right"><input type="checkbox" name="qty_frozen" id="qty_frozen" class="flat right" value="1"'.(GETPOST("qty_frozen", 'alpha')?' checked="checked"':'').'>';
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
$coldisplay++;
|
||||||
|
print '<td class="nobottom linecoldisablestockchange right"><input type="checkbox" name="disable_stock_change" id="disable_stock_change" class="flat right" value="1"'.(GETPOST("disable_stock_change", 'alpha')?' checked="checked"':'').'">';
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
$coldisplay++;
|
||||||
print '<td class="nobottom nowrap linecollost right">';
|
print '<td class="nobottom nowrap linecollost right">';
|
||||||
print '<input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="'.(GETPOSTISSET("efficiency")?GETPOST("efficiency", 'alpha'):1).'">';
|
print '<input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="'.(GETPOSTISSET("efficiency")?GETPOST("efficiency", 'alpha'):1).'">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|||||||
@ -116,6 +116,14 @@ if ($conf->global->PRODUCT_USE_UNITS)
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$coldisplay++;
|
||||||
|
print '<td class="nobottom linecolqtyfrozen right"><input type="checkbox" name="qty_frozen" id="qty_frozen" class="flat right" value="1"'.(GETPOSTISSET("qty_frozen")?(GETPOST('qty_frozen', 'int')?' checked="checked"':''):($line->qty_frozen?' checked="checked"':'')).'>';
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
$coldisplay++;
|
||||||
|
print '<td class="nobottom linecoldisablestockchange right"><input type="checkbox" name="disable_stock_change" id="disable_stock_change" class="flat right" value="1"'.(GETPOSTISSET('disablestockchange')?(GETPOST("disable_stock_change", 'int')?' checked="checked"':''):($line->disable_stock_change?' checked="checked"':'')).'">';
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
$coldisplay++;
|
$coldisplay++;
|
||||||
print '<td class="nobottom nowrap linecollost right">';
|
print '<td class="nobottom nowrap linecollost right">';
|
||||||
print '<input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="'.$line->efficiency.'"></td>';
|
print '<input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="'.$line->efficiency.'"></td>';
|
||||||
|
|||||||
@ -59,6 +59,13 @@ if ($conf->global->PRODUCT_USE_UNITS)
|
|||||||
print '<td class="linecoluseunit left">'.$langs->trans('Unit').'</td>';
|
print '<td class="linecoluseunit left">'.$langs->trans('Unit').'</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Qty frozen
|
||||||
|
print '<td class="linecolqty right">'.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).'</td>';
|
||||||
|
|
||||||
|
// Disable stock change
|
||||||
|
print '<td class="linecolqty right">'.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).'</td>';
|
||||||
|
|
||||||
|
// Efficiency
|
||||||
print '<td class="linecollost right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).'</td>';
|
print '<td class="linecollost right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).'</td>';
|
||||||
|
|
||||||
print '<td class="linecoledit"></td>'; // No width to allow autodim
|
print '<td class="linecoledit"></td>'; // No width to allow autodim
|
||||||
|
|||||||
@ -87,6 +87,16 @@ if($conf->global->PRODUCT_USE_UNITS)
|
|||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print '<td class="linecolqtyfrozen nowrap right">';
|
||||||
|
$coldisplay++;
|
||||||
|
echo $line->qty_frozen ? yn($line->qty_frozen) : '';
|
||||||
|
print '</td>';
|
||||||
|
print '<td class="linecoldisablestockchange nowrap right">';
|
||||||
|
$coldisplay++;
|
||||||
|
echo $line->disable_stock_change ? yn($line->disable_stock_change) : ''; // Yes, it is a quantity, not a price, but we just want the formating role of function price
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
print '<td class="linecolqty nowrap right">';
|
print '<td class="linecolqty nowrap right">';
|
||||||
$coldisplay++;
|
$coldisplay++;
|
||||||
echo $line->efficiency;
|
echo $line->efficiency;
|
||||||
|
|||||||
@ -58,6 +58,9 @@ UPDATE llx_rights_def SET subperms = 'write' WHERE perms = 'fiscalyear' AND modu
|
|||||||
|
|
||||||
ALTER TABLE llx_bom_bom ADD COLUMN duration double(8,4) DEFAULT NULL;
|
ALTER TABLE llx_bom_bom ADD COLUMN duration double(8,4) DEFAULT NULL;
|
||||||
ALTER TABLE llx_bom_bomline ADD COLUMN position integer NOT NULL DEFAULT 0;
|
ALTER TABLE llx_bom_bomline ADD COLUMN position integer NOT NULL DEFAULT 0;
|
||||||
|
ALTER TABLE llx_bom_bomline ADD COLUMN qty_frozen smallint DEFAULT 0;
|
||||||
|
ALTER TABLE llx_bom_bomline ADD COLUMN disable_stock_change smallint DEFAULT 0;
|
||||||
|
|
||||||
ALTER TABLE llx_bom_bomline DROP COLUMN rank;
|
ALTER TABLE llx_bom_bomline DROP COLUMN rank;
|
||||||
|
|
||||||
create table llx_categorie_warehouse
|
create table llx_categorie_warehouse
|
||||||
|
|||||||
@ -22,6 +22,8 @@ CREATE TABLE llx_bom_bomline(
|
|||||||
description text,
|
description text,
|
||||||
import_key varchar(14),
|
import_key varchar(14),
|
||||||
qty double(24,8) NOT NULL,
|
qty double(24,8) NOT NULL,
|
||||||
|
qty_frozen smallint DEFAULT 0,
|
||||||
|
disable_stock_change smallint DEFAULT 0,
|
||||||
efficiency double(8,4) NOT NULL DEFAULT 1,
|
efficiency double(8,4) NOT NULL DEFAULT 1,
|
||||||
position integer NOT NULL DEFAULT 0
|
position integer NOT NULL DEFAULT 0
|
||||||
-- END MODULEBUILDER FIELDS
|
-- END MODULEBUILDER FIELDS
|
||||||
|
|||||||
@ -32,4 +32,8 @@ EstimatedDurationDesc=Estimated duration to manufacture this product using this
|
|||||||
ConfirmValidateBom=Are you sure you want to validate the BOM with the reference <strong>%s</strong> (you will be able to use it to build new Manufacturing Orders)
|
ConfirmValidateBom=Are you sure you want to validate the BOM with the reference <strong>%s</strong> (you will be able to use it to build new Manufacturing Orders)
|
||||||
ConfirmCloseBom=Are you sure you want to cancel this BOM (you won't be able to use it to build new Manufacturing Orders anymore) ?
|
ConfirmCloseBom=Are you sure you want to cancel this BOM (you won't be able to use it to build new Manufacturing Orders anymore) ?
|
||||||
ConfirmReopenBom=Are you sure you want to re-open this BOM (you will be able to use it to build new Manufacturing Orders)
|
ConfirmReopenBom=Are you sure you want to re-open this BOM (you will be able to use it to build new Manufacturing Orders)
|
||||||
StatusMOProduced=Produced
|
StatusMOProduced=Produced
|
||||||
|
QtyFrozen=Frozen Qty
|
||||||
|
QuantityConsumedInvariable=When this flag is set, the quantity consumed is always the value defined and is not relative to the quantity produced.
|
||||||
|
DisableStockChange=Disable stock change
|
||||||
|
DisableStockChangeHelp=When this flag is set, there is no stock change on this product, whatever is the quantity produced
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user