diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 30031103156..6186e809543 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -125,9 +125,11 @@ if (empty($reshook)) $error = 0; // Set if we used free entry or predefined product - $idprod=GETPOST('idprod', 'int'); - $qty=GETPOST('qty', 'int'); - $efficiency=GETPOST('efficiency', 'int'); + $idprod = GETPOST('idprod', 'int'); + $qty = GETPOST('qty', 'int'); + $qty_frozen = GETPOST('qty_frozen', 'int'); + $disable_stock_change = GETPOST('disable_stock_change', 'int'); + $efficiency = GETPOST('efficiency', 'int'); if ($qty == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); @@ -138,17 +140,27 @@ if (empty($reshook)) $error++; } - $bomline = new BOMLine($db); - $bomline->fk_bom = $id; - $bomline->fk_product = $idprod; - $bomline->qty = $qty; - $bomline->efficiency = $efficiency; - - $result = $bomline->create($user); - if ($result <= 0) + if (! $error) { - setEventMessages($bomline->error, $bomline->errors, 'errors'); - $action = ''; + $bomline = new BOMLine($db); + $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 $qty=GETPOST('qty', 'int'); + $qty_frozen = GETPOST('qty_frozen', 'int'); + $disable_stock_change = GETPOST('disable_stock_change', 'int'); $efficiency=GETPOST('efficiency', 'int'); if ($qty == '') { @@ -170,6 +184,8 @@ if (empty($reshook)) $bomline = new BOMLine($db); $bomline->fetch($lineid); $bomline->qty = $qty; + $bomline->qty_frozen = $qty_frozen; + $bomline->disable_stock_change = $disable_stock_change; $bomline->efficiency = $efficiency; $result = $bomline->update($user); @@ -178,6 +194,11 @@ if (empty($reshook)) setEventMessages($bomline->error, $bomline->errors, 'errors'); $action = ''; } + else + { + unset($_POST['qty_frozen']); + unset($_POST['disable_stock_change']); + } } } diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 90e23dad802..0d59946216b 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -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,), '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',), - '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,), '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 $description; public $qty; + public $qty_frozen; + public $disable_stock_change; public $efficiency; public $position; public $import_key; @@ -1316,47 +1320,7 @@ class BOMLine extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - if (empty($this->labelstatus)) - { - 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'); - } + return ''; } /** diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index cd654c7a596..9f6bfee98f2 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -63,11 +63,13 @@ if ($nolinesbefore) { print '