diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index d68a320482e..ccc3a05c51f 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -14,7 +14,7 @@ * Copyright (C) 2014 Ion agorria * Copyright (C) 2016-2018 Ferran Marcet * Copyright (C) 2017 Gustavo Novaro - * Copyright (C) 2019-2021 Frédéric France + * Copyright (C) 2019-2022 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -255,6 +255,14 @@ class Product extends CommonObject */ public $status = 0; + /** + * Status indicates whether the product is on sale '1' or not '0' + * @var int + * @deprecated + * @see $status + */ + public $tosell; + /** * Status indicate whether the product is available for purchase '1' or not '0' * @@ -262,6 +270,14 @@ class Product extends CommonObject */ public $status_buy = 0; + /** + * Status indicate whether the product is available for purchase '1' or not '0' + * @var int + * @deprecated + * @see $status_buy + */ + public $tobuy; + /** * Status indicates whether the product is a finished product '1' or a raw material '0' * @@ -1977,11 +1993,11 @@ class Product extends CommonObject $this->remise_percent = $obj->remise_percent; // remise percent if present and not typed $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier $this->default_vat_code = $obj->default_vat_code; // Vat code supplier - $this->fourn_multicurrency_price = $obj->multicurrency_price; - $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; - $this->fourn_multicurrency_tx = $obj->multicurrency_tx; - $this->fourn_multicurrency_id = $obj->fk_multicurrency; - $this->fourn_multicurrency_code = $obj->multicurrency_code; + $this->fourn_multicurrency_price = $obj->multicurrency_price; + $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; + $this->fourn_multicurrency_tx = $obj->multicurrency_tx; + $this->fourn_multicurrency_id = $obj->fk_multicurrency; + $this->fourn_multicurrency_code = $obj->multicurrency_code; if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { $this->packaging = $obj->packaging; } @@ -2042,11 +2058,11 @@ class Product extends CommonObject $this->remise_percent = $obj->remise_percent; // remise percent if present and not typed $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier $this->default_vat_code = $obj->default_vat_code; // Vat code supplier - $this->fourn_multicurrency_price = $obj->multicurrency_price; - $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; - $this->fourn_multicurrency_tx = $obj->multicurrency_tx; - $this->fourn_multicurrency_id = $obj->fk_multicurrency; - $this->fourn_multicurrency_code = $obj->multicurrency_code; + $this->fourn_multicurrency_price = $obj->multicurrency_price; + $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; + $this->fourn_multicurrency_tx = $obj->multicurrency_tx; + $this->fourn_multicurrency_id = $obj->fk_multicurrency; + $this->fourn_multicurrency_code = $obj->multicurrency_code; if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { $this->packaging = $obj->packaging; } @@ -2383,57 +2399,57 @@ class Product extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; - $this->ref = $obj->ref; - $this->ref_ext = $obj->ref_ext; - $this->label = $obj->label; - $this->description = $obj->description; - $this->url = $obj->url; - $this->note_public = $obj->note_public; - $this->note_private = $obj->note_private; - $this->note = $obj->note_private; // deprecated + $this->ref = $obj->ref; + $this->ref_ext = $obj->ref_ext; + $this->label = $obj->label; + $this->description = $obj->description; + $this->url = $obj->url; + $this->note_public = $obj->note_public; + $this->note_private = $obj->note_private; + $this->note = $obj->note_private; // deprecated - $this->type = $obj->fk_product_type; - $this->status = $obj->tosell; - $this->status_buy = $obj->tobuy; - $this->status_batch = $obj->tobatch; - $this->batch_mask = $obj->batch_mask; + $this->type = $obj->fk_product_type; + $this->status = $obj->tosell; + $this->status_buy = $obj->tobuy; + $this->status_batch = $obj->tobatch; + $this->batch_mask = $obj->batch_mask; - $this->customcode = $obj->customcode; - $this->country_id = $obj->fk_country; + $this->customcode = $obj->customcode; + $this->country_id = $obj->fk_country; $this->country_code = getCountry($this->country_id, 2, $this->db); $this->state_id = $obj->fk_state; - $this->lifetime = $obj->lifetime; - $this->qc_frequency = $obj->qc_frequency; - $this->price = $obj->price; - $this->price_ttc = $obj->price_ttc; - $this->price_min = $obj->price_min; - $this->price_min_ttc = $obj->price_min_ttc; + $this->lifetime = $obj->lifetime; + $this->qc_frequency = $obj->qc_frequency; + $this->price = $obj->price; + $this->price_ttc = $obj->price_ttc; + $this->price_min = $obj->price_min; + $this->price_min_ttc = $obj->price_min_ttc; $this->price_base_type = $obj->price_base_type; - $this->cost_price = $obj->cost_price; + $this->cost_price = $obj->cost_price; $this->default_vat_code = $obj->default_vat_code; - $this->tva_tx = $obj->tva_tx; + $this->tva_tx = $obj->tva_tx; //! French VAT NPR - $this->tva_npr = $obj->tva_npr; - $this->recuperableonly = $obj->tva_npr; // For backward compatibility + $this->tva_npr = $obj->tva_npr; + $this->recuperableonly = $obj->tva_npr; // For backward compatibility //! Local taxes - $this->localtax1_tx = $obj->localtax1_tx; - $this->localtax2_tx = $obj->localtax2_tx; - $this->localtax1_type = $obj->localtax1_type; - $this->localtax2_type = $obj->localtax2_type; + $this->localtax1_tx = $obj->localtax1_tx; + $this->localtax2_tx = $obj->localtax2_tx; + $this->localtax1_type = $obj->localtax1_type; + $this->localtax2_type = $obj->localtax2_type; - $this->finished = $obj->finished; - $this->fk_default_bom = $obj->fk_default_bom; + $this->finished = $obj->finished; + $this->fk_default_bom = $obj->fk_default_bom; - $this->duration = $obj->duration; - $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1); + $this->duration = $obj->duration; + $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1); $this->duration_unit = substr($obj->duration, -1); - $this->canvas = $obj->canvas; + $this->canvas = $obj->canvas; $this->net_measure = $obj->net_measure; $this->net_measure_units = $obj->net_measure_units; - $this->weight = $obj->weight; - $this->weight_units = $obj->weight_units; - $this->length = $obj->length; - $this->length_units = $obj->length_units; + $this->weight = $obj->weight; + $this->weight_units = $obj->weight_units; + $this->length = $obj->length; + $this->length_units = $obj->length_units; $this->width = $obj->width; $this->width_units = $obj->width_units; $this->height = $obj->height; @@ -2442,32 +2458,32 @@ class Product extends CommonObject $this->surface = $obj->surface; $this->surface_units = $obj->surface_units; $this->volume = $obj->volume; - $this->volume_units = $obj->volume_units; + $this->volume_units = $obj->volume_units; $this->barcode = $obj->barcode; - $this->barcode_type = $obj->fk_barcode_type; + $this->barcode_type = $obj->fk_barcode_type; - $this->accountancy_code_buy = $obj->accountancy_code_buy; - $this->accountancy_code_buy_intra = $obj->accountancy_code_buy_intra; - $this->accountancy_code_buy_export = $obj->accountancy_code_buy_export; - $this->accountancy_code_sell = $obj->accountancy_code_sell; - $this->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; - $this->accountancy_code_sell_export = $obj->accountancy_code_sell_export; + $this->accountancy_code_buy = $obj->accountancy_code_buy; + $this->accountancy_code_buy_intra = $obj->accountancy_code_buy_intra; + $this->accountancy_code_buy_export = $obj->accountancy_code_buy_export; + $this->accountancy_code_sell = $obj->accountancy_code_sell; + $this->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; + $this->accountancy_code_sell_export = $obj->accountancy_code_sell_export; - $this->fk_default_warehouse = $obj->fk_default_warehouse; - $this->fk_default_workstation = $obj->fk_default_workstation; - $this->seuil_stock_alerte = $obj->seuil_stock_alerte; - $this->desiredstock = $obj->desiredstock; - $this->stock_reel = $obj->stock; + $this->fk_default_warehouse = $obj->fk_default_warehouse; + $this->fk_default_workstation = $obj->fk_default_workstation; + $this->seuil_stock_alerte = $obj->seuil_stock_alerte; + $this->desiredstock = $obj->desiredstock; + $this->stock_reel = $obj->stock; $this->pmp = $obj->pmp; - $this->date_creation = $obj->datec; - $this->date_modification = $obj->tms; - $this->import_key = $obj->import_key; - $this->entity = $obj->entity; + $this->date_creation = $obj->datec; + $this->date_modification = $obj->tms; + $this->import_key = $obj->import_key; + $this->entity = $obj->entity; - $this->ref_ext = $obj->ref_ext; - $this->fk_price_expression = $obj->fk_price_expression; - $this->fk_unit = $obj->fk_unit; + $this->ref_ext = $obj->ref_ext; + $this->fk_price_expression = $obj->fk_price_expression; + $this->fk_unit = $obj->fk_unit; $this->price_autogen = $obj->price_autogen; $this->model_pdf = $obj->model_pdf; @@ -5255,7 +5271,7 @@ class Product extends CommonObject * @param string $origin_element Origin element type * @param int $origin_id Origin id of element * @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (usefull only if product is a subproduct) - * @param array $extrafields Array of extrafields + * @param Extrafields $extrafields Array of extrafields * @return int <0 if KO, >0 if OK */ public function correct_stock($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0, $extrafields = null) @@ -5315,7 +5331,7 @@ class Product extends CommonObject * @param string $origin_element Origin element type * @param int $origin_id Origin id of element * @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (usefull only if product is a subproduct) - * @param array $extrafields Array of extrafields + * @param Extrafields $extrafields Array of extrafields * @return int <0 if KO, >0 if OK */ public function correct_stock_batch($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $dlc = '', $dluo = '', $lot = '', $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0, $extrafields = null) @@ -5921,10 +5937,11 @@ class Product extends CommonObject $this->description = 'This is description of this product specimen that was created the '.dol_print_date($now, 'dayhourlog').'.'; $this->specimen = 1; $this->country_id = 1; - $this->tosell = 1; - $this->tobuy = 1; + $this->status = 1; + $this->status_buy = 1; $this->tobatch = 0; - $this->note = 'This is a comment (private)'; + $this->note_private = 'This is a comment (private)'; + $this->note_public = 'This is a comment (public)'; $this->date_creation = $now; $this->date_modification = $now;