function destockProduct($qty_to_destock) { global $conf; $sens = $qty_to_destock > 0 ? -1 : 1; $qty_to_destock_rest = abs($qty_to_destock); $labelMvt = 'Utilisation via Ordre de Fabrication'; if ($this->type == 'TO_MAKE') { $sens == 1 ? $labelMvt = 'Création via Ordre de Fabrication' : ($labelMvt = 'Suppression via Ordre de Fabrication'); } if ($this->type == 'TO_MAKE') { $fk_entrepot = !empty($conf->global->ASSET_MANUAL_WAREHOUSE) ? $this->fk_entrepot : $conf->global->ASSET_DEFAULT_WAREHOUSE_ID_TO_MAKE; } else { $fk_entrepot = !empty($conf->global->ASSET_MANUAL_WAREHOUSE) ? $this->fk_entrepot : $conf->global->ASSET_DEFAULT_WAREHOUSE_ID_NEEDED; } /*$asset=new TAsset; //TODO if asset not implemented $asset->addStockMouvementDolibarr($this->fk_product, $sens * $qty_to_destock_rest,$labelMvt.' n°'.$this->of_numero, false, 0, $fk_entrepot); */ $price = 0; if ($this->type == 'TO_MAKE') { $price = $this->current_cost_for_to_make; $this->pmp = $this->current_cost_for_to_make; } TAssetOF::addStockMouvementDolibarr($this->fk_product, $sens * $qty_to_destock_rest, $labelMvt, $fk_entrepot, $price); $this->update_qty_stock($sens * $qty_to_destock_rest); }