Improve code style
This commit is contained in:
parent
2248429eda
commit
751aa2a2aa
@ -13,6 +13,7 @@
|
|||||||
* Copyright (C) 2014-2016 Philippe Grand <philippe.grand@atoo-net.com>
|
* Copyright (C) 2014-2016 Philippe Grand <philippe.grand@atoo-net.com>
|
||||||
* Copyright (C) 2014 Ion agorria <ion@agorria.com>
|
* Copyright (C) 2014 Ion agorria <ion@agorria.com>
|
||||||
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
|
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
|
||||||
|
* Copyright (C) 2017 Gustavo Novaro
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -54,36 +55,61 @@ class Product extends CommonObject
|
|||||||
*/
|
*/
|
||||||
protected $table_ref_field = 'ref';
|
protected $table_ref_field = 'ref';
|
||||||
|
|
||||||
var $regeximgext='\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm'; // See also into images.lib.php
|
public $regeximgext='\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm'; // See also into images.lib.php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @deprecated
|
* @deprecated
|
||||||
* @see label
|
* @see label
|
||||||
*/
|
*/
|
||||||
var $libelle;
|
public $libelle;
|
||||||
/**
|
/**
|
||||||
* Product label
|
* Product label
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $label;
|
public $label;
|
||||||
/**
|
|
||||||
* Product descripion
|
/**
|
||||||
* @var string
|
* Product descripion
|
||||||
*/
|
* @var string
|
||||||
var $description;
|
*/
|
||||||
|
public $description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check TYPE constants
|
* Check TYPE constants
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
var $type = self::TYPE_PRODUCT;
|
public $type = self::TYPE_PRODUCT;
|
||||||
//! Selling price
|
|
||||||
var $price; // Price net
|
/**
|
||||||
var $price_ttc; // Price with tax
|
* Selling price
|
||||||
var $price_min; // Minimum price net
|
* @var float
|
||||||
var $price_min_ttc; // Minimum price with tax
|
*/
|
||||||
//! Base price ('TTC' for price including tax or 'HT' for net price)
|
public $price; // Price net
|
||||||
var $price_base_type;
|
|
||||||
|
/**
|
||||||
|
* Price with tax
|
||||||
|
* @var float
|
||||||
|
*/
|
||||||
|
public $price_ttc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimum price net
|
||||||
|
* @var float
|
||||||
|
*/
|
||||||
|
public $price_min;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimum price with tax
|
||||||
|
* @var float
|
||||||
|
*/
|
||||||
|
public $price_min_ttc;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Base price ('TTC' for price including tax or 'HT' for net price)
|
||||||
|
* @var float
|
||||||
|
*/
|
||||||
|
public $price_base_type;
|
||||||
|
|
||||||
//! Arrays for multiprices
|
//! Arrays for multiprices
|
||||||
public $multiprices=array();
|
public $multiprices=array();
|
||||||
public $multiprices_ttc=array();
|
public $multiprices_ttc=array();
|
||||||
@ -92,49 +118,99 @@ class Product extends CommonObject
|
|||||||
public $multiprices_min_ttc=array();
|
public $multiprices_min_ttc=array();
|
||||||
public $multiprices_tva_tx=array();
|
public $multiprices_tva_tx=array();
|
||||||
public $multiprices_recuperableonly=array();
|
public $multiprices_recuperableonly=array();
|
||||||
//! Price by quantity arrays
|
|
||||||
var $price_by_qty;
|
|
||||||
var $prices_by_qty=array();
|
|
||||||
var $prices_by_qty_id=array();
|
|
||||||
var $prices_by_qty_list=array();
|
|
||||||
//! Default VAT code for product (link to code into llx_c_tva but without foreign keys)
|
|
||||||
var $default_vat_code;
|
|
||||||
//! Default VAT rate of product
|
|
||||||
var $tva_tx;
|
|
||||||
//! French VAT NPR (0 or 1)
|
|
||||||
var $tva_npr=0;
|
|
||||||
//! Other local taxes
|
|
||||||
var $localtax1_tx;
|
|
||||||
var $localtax2_tx;
|
|
||||||
var $localtax1_type;
|
|
||||||
var $localtax2_type;
|
|
||||||
|
|
||||||
//! Stock real
|
//! Price by quantity arrays
|
||||||
var $stock_reel;
|
public $price_by_qty;
|
||||||
//! Stock virtual
|
public $prices_by_qty=array();
|
||||||
var $stock_theorique;
|
public $prices_by_qty_id=array();
|
||||||
//! Cost price
|
public $prices_by_qty_list=array();
|
||||||
var $cost_price;
|
|
||||||
|
//! Default VAT code for product (link to code into llx_c_tva but without foreign keys)
|
||||||
|
public $default_vat_code;
|
||||||
|
|
||||||
|
//! Default VAT rate of product
|
||||||
|
public $tva_tx;
|
||||||
|
|
||||||
|
//! French VAT NPR (0 or 1)
|
||||||
|
public $tva_npr=0;
|
||||||
|
|
||||||
|
//! Other local taxes
|
||||||
|
public $localtax1_tx;
|
||||||
|
public $localtax2_tx;
|
||||||
|
public $localtax1_type;
|
||||||
|
public $localtax2_type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stock real
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $stock_reel = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stock virtual
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $stock_theorique;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cost price
|
||||||
|
* @var float
|
||||||
|
*/
|
||||||
|
public $cost_price;
|
||||||
|
|
||||||
//! Average price value for product entry into stock (PMP)
|
//! Average price value for product entry into stock (PMP)
|
||||||
var $pmp;
|
public $pmp;
|
||||||
//! Stock alert
|
|
||||||
var $seuil_stock_alerte;
|
/**
|
||||||
//! Ask for replenishment when $desiredstock < $stock_reel
|
* Stock alert
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $seuil_stock_alerte;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ask for replenishment when $desiredstock < $stock_reel
|
||||||
|
*/
|
||||||
public $desiredstock;
|
public $desiredstock;
|
||||||
//! Duree de validite du service
|
|
||||||
var $duration_value;
|
/*
|
||||||
//! Unite de duree
|
* Service expiration
|
||||||
var $duration_unit;
|
*/
|
||||||
// Statut indique si le produit est en vente '1' ou non '0'
|
public $duration_value;
|
||||||
var $status;
|
|
||||||
// Status indicate whether the product is available for purchase '1' or not '0'
|
/**
|
||||||
var $status_buy;
|
* Exoiration unit
|
||||||
// Statut indique si le produit est un produit fini '1' ou une matiere premiere '0'
|
*/
|
||||||
var $finished;
|
public $duration_unit;
|
||||||
// We must manage lot/batch number, sell-by date and so on : '1':yes '0':no
|
|
||||||
var $status_batch;
|
/**
|
||||||
|
* Status indicates whether the product is on sale '1' or not '0'
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Status indicate whether the product is available for purchase '1' or not '0'
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $status_buy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Status indicates whether the product is a finished product '1' or a raw material '0'
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $finished;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We must manage lot/batch number, sell-by date and so on : '1':yes '0':no
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $status_batch;
|
||||||
|
|
||||||
var $customcode; // Customs code
|
/**
|
||||||
|
* Customs code
|
||||||
|
* @var
|
||||||
|
*/
|
||||||
|
public $customcode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Product URL
|
* Product URL
|
||||||
@ -143,56 +219,66 @@ class Product extends CommonObject
|
|||||||
public $url;
|
public $url;
|
||||||
|
|
||||||
//! Unites de mesure
|
//! Unites de mesure
|
||||||
var $weight;
|
public $weight;
|
||||||
var $weight_units;
|
public $weight_units;
|
||||||
var $length;
|
public $length;
|
||||||
var $length_units;
|
public $length_units;
|
||||||
var $surface;
|
public $surface;
|
||||||
var $surface_units;
|
public $surface_units;
|
||||||
var $volume;
|
public $volume;
|
||||||
var $volume_units;
|
public $volume_units;
|
||||||
|
|
||||||
var $accountancy_code_buy;
|
public $accountancy_code_buy;
|
||||||
var $accountancy_code_sell;
|
public $accountancy_code_sell;
|
||||||
|
|
||||||
//! barcode
|
/**
|
||||||
var $barcode; // value
|
* Main barcode
|
||||||
|
* barcode value
|
||||||
|
* @var
|
||||||
|
*/
|
||||||
|
public $barcode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Additional barcodes (Some products have different barcodes according to the country of origin of manufacture)
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $barcodes_extra=array();
|
||||||
|
|
||||||
var $stats_propale=array();
|
public $stats_propale=array();
|
||||||
var $stats_commande=array();
|
public $stats_commande=array();
|
||||||
var $stats_contrat=array();
|
public $stats_contrat=array();
|
||||||
var $stats_facture=array();
|
public $stats_facture=array();
|
||||||
var $stats_commande_fournisseur=array();
|
public $stats_commande_fournisseur=array();
|
||||||
|
|
||||||
var $multilangs=array();
|
public $multilangs=array();
|
||||||
|
|
||||||
//! Taille de l'image
|
//! Taille de l'image
|
||||||
var $imgWidth;
|
public $imgWidth;
|
||||||
var $imgHeight;
|
public $imgHeight;
|
||||||
|
|
||||||
var $date_creation;
|
public $date_creation;
|
||||||
var $date_modification;
|
public $date_modification;
|
||||||
|
|
||||||
//! Id du fournisseur
|
//! Id du fournisseur
|
||||||
var $product_fourn_id;
|
public $product_fourn_id;
|
||||||
|
|
||||||
//! Product ID already linked to a reference supplier
|
//! Product ID already linked to a reference supplier
|
||||||
var $product_id_already_linked;
|
public $product_id_already_linked;
|
||||||
|
|
||||||
var $nbphoto;
|
public $nbphoto;
|
||||||
|
|
||||||
//! Contains detail of stock of product into each warehouse
|
//! Contains detail of stock of product into each warehouse
|
||||||
var $stock_warehouse=array();
|
public $stock_warehouse=array();
|
||||||
|
|
||||||
var $oldcopy;
|
public $oldcopy;
|
||||||
|
|
||||||
var $fk_price_expression;
|
public $fk_price_expression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
* @see fourn_pu
|
* @see fourn_pu
|
||||||
*/
|
*/
|
||||||
var $buyprice;
|
public $buyprice;
|
||||||
public $fourn_pu;
|
public $fourn_pu;
|
||||||
|
|
||||||
public $fourn_price_base_type;
|
public $fourn_price_base_type;
|
||||||
@ -201,7 +287,7 @@ class Product extends CommonObject
|
|||||||
* @deprecated
|
* @deprecated
|
||||||
* @see ref_supplier
|
* @see ref_supplier
|
||||||
*/
|
*/
|
||||||
var $ref_fourn;
|
public $ref_fourn;
|
||||||
public $ref_supplier;
|
public $ref_supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -290,7 +376,7 @@ class Product extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
$this->ref = dol_string_nospecial(trim($this->ref));
|
$this->ref = dol_string_nospecial(trim($this->ref));
|
||||||
@ -320,39 +406,48 @@ class Product extends CommonObject
|
|||||||
$price_ttc=0;
|
$price_ttc=0;
|
||||||
$price_min_ht=0;
|
$price_min_ht=0;
|
||||||
$price_min_ttc=0;
|
$price_min_ttc=0;
|
||||||
|
|
||||||
|
//
|
||||||
if ($this->price_base_type == 'TTC' && $this->price_ttc > 0)
|
if ($this->price_base_type == 'TTC' && $this->price_ttc > 0)
|
||||||
{
|
{
|
||||||
$price_ttc = price2num($this->price_ttc,'MU');
|
$price_ttc = price2num($this->price_ttc,'MU');
|
||||||
$price_ht = price2num($this->price_ttc / (1 + ($this->tva_tx / 100)),'MU');
|
$price_ht = price2num($this->price_ttc / (1 + ($this->tva_tx / 100)),'MU');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
if ($this->price_base_type != 'TTC' && $this->price > 0)
|
if ($this->price_base_type != 'TTC' && $this->price > 0)
|
||||||
{
|
{
|
||||||
$price_ht = price2num($this->price,'MU');
|
$price_ht = price2num($this->price,'MU');
|
||||||
$price_ttc = price2num($this->price * (1 + ($this->tva_tx / 100)),'MU');
|
$price_ttc = price2num($this->price * (1 + ($this->tva_tx / 100)),'MU');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
if (($this->price_min_ttc > 0) && ($this->price_base_type == 'TTC'))
|
if (($this->price_min_ttc > 0) && ($this->price_base_type == 'TTC'))
|
||||||
{
|
{
|
||||||
$price_min_ttc = price2num($this->price_min_ttc,'MU');
|
$price_min_ttc = price2num($this->price_min_ttc,'MU');
|
||||||
$price_min_ht = price2num($this->price_min_ttc / (1 + ($this->tva_tx / 100)),'MU');
|
$price_min_ht = price2num($this->price_min_ttc / (1 + ($this->tva_tx / 100)),'MU');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
if (($this->price_min > 0) && ($this->price_base_type != 'TTC'))
|
if (($this->price_min > 0) && ($this->price_base_type != 'TTC'))
|
||||||
{
|
{
|
||||||
$price_min_ht = price2num($this->price_min,'MU');
|
$price_min_ht = price2num($this->price_min,'MU');
|
||||||
$price_min_ttc = price2num($this->price_min * (1 + ($this->tva_tx / 100)),'MU');
|
$price_min_ttc = price2num($this->price_min * (1 + ($this->tva_tx / 100)),'MU');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->accountancy_code_buy = trim($this->accountancy_code_buy);
|
$this->accountancy_code_buy = trim($this->accountancy_code_buy);
|
||||||
$this->accountancy_code_sell= trim($this->accountancy_code_sell);
|
$this->accountancy_code_sell= trim($this->accountancy_code_sell);
|
||||||
|
|
||||||
// Barcode value
|
// Barcode value
|
||||||
$this->barcode=trim($this->barcode);
|
$this->barcode=trim($this->barcode);
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if (empty($this->label))
|
if (empty($this->label))
|
||||||
{
|
{
|
||||||
$this->error='ErrorMandatoryParametersNotProvided';
|
$this->error='ErrorMandatoryParametersNotProvided';
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->ref))
|
if (empty($this->ref))
|
||||||
{
|
{
|
||||||
// Load object modCodeProduct
|
// Load object modCodeProduct
|
||||||
@ -371,6 +466,7 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
unset($modCodeProduct);
|
unset($modCodeProduct);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->ref))
|
if (empty($this->ref))
|
||||||
{
|
{
|
||||||
$this->error='ProductModuleNotSetupForAutoRef';
|
$this->error='ProductModuleNotSetupForAutoRef';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user