Optimize constructors

This commit is contained in:
Laurent Destailleur 2018-04-21 15:08:46 +02:00
parent 394b988a4e
commit 411949a6bb
6 changed files with 132 additions and 138 deletions

View File

@ -218,18 +218,6 @@ class Propal extends CommonObject
$this->remise_absolue = 0; $this->remise_absolue = 0;
$this->duree_validite=$conf->global->PROPALE_VALIDITY_DURATION; $this->duree_validite=$conf->global->PROPALE_VALIDITY_DURATION;
$langs->load("propal");
$this->labelstatut[0]=(! empty($conf->global->PROPAL_STATUS_DRAFT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFT_LABEL : $langs->trans("PropalStatusDraft"));
$this->labelstatut[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATED_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATED_LABEL : $langs->trans("PropalStatusValidated"));
$this->labelstatut[2]=(! empty($conf->global->PROPAL_STATUS_SIGNED_LABEL) ? $conf->global->PROPAL_STATUS_SIGNED_LABEL : $langs->trans("PropalStatusSigned"));
$this->labelstatut[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNED_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNED_LABEL : $langs->trans("PropalStatusNotSigned"));
$this->labelstatut[4]=(! empty($conf->global->PROPAL_STATUS_BILLED_LABEL) ? $conf->global->PROPAL_STATUS_BILLED_LABEL : $langs->trans("PropalStatusBilled"));
$this->labelstatut_short[0]=(! empty($conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL : $langs->trans("PropalStatusDraftShort"));
$this->labelstatut_short[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL : $langs->trans("Opened"));
$this->labelstatut_short[2]=(! empty($conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL : $langs->trans("PropalStatusSignedShort"));
$this->labelstatut_short[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL : $langs->trans("PropalStatusNotSignedShort"));
$this->labelstatut_short[4]=(! empty($conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL : $langs->trans("PropalStatusBilledShort"));
} }
@ -3091,10 +3079,24 @@ class Propal extends CommonObject
* @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label * @return string Label
*/ */
function LibStatut($statut,$mode=1) function LibStatut($statut,$mode=1)
{ {
global $langs; // Init/load array of translation of status
$langs->load("propal"); if (empty($this->labelstatut) || empty($this->labelstatut_short))
{
global $langs;
$langs->load("propal");
$this->labelstatut[0]=(! empty($conf->global->PROPAL_STATUS_DRAFT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFT_LABEL : $langs->trans("PropalStatusDraft"));
$this->labelstatut[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATED_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATED_LABEL : $langs->trans("PropalStatusValidated"));
$this->labelstatut[2]=(! empty($conf->global->PROPAL_STATUS_SIGNED_LABEL) ? $conf->global->PROPAL_STATUS_SIGNED_LABEL : $langs->trans("PropalStatusSigned"));
$this->labelstatut[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNED_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNED_LABEL : $langs->trans("PropalStatusNotSigned"));
$this->labelstatut[4]=(! empty($conf->global->PROPAL_STATUS_BILLED_LABEL) ? $conf->global->PROPAL_STATUS_BILLED_LABEL : $langs->trans("PropalStatusBilled"));
$this->labelstatut_short[0]=(! empty($conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL : $langs->trans("PropalStatusDraftShort"));
$this->labelstatut_short[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL : $langs->trans("Opened"));
$this->labelstatut_short[2]=(! empty($conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL : $langs->trans("PropalStatusSignedShort"));
$this->labelstatut_short[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL : $langs->trans("PropalStatusNotSignedShort"));
$this->labelstatut_short[4]=(! empty($conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL : $langs->trans("PropalStatusBilledShort"));
}
$statuttrans=''; $statuttrans='';
if ($statut==self::STATUS_DRAFT) $statuttrans='statut0'; if ($statut==self::STATUS_DRAFT) $statuttrans='statut0';

View File

@ -34,8 +34,8 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
class Fournisseur extends Societe class Fournisseur extends Societe
{ {
var $next_prev_filter="te.fournisseur = 1"; // Used to add a filter in Form::showrefnav method var $next_prev_filter="te.fournisseur = 1"; // Used to add a filter in Form::showrefnav method
/** /**
* Constructor * Constructor
* *
@ -44,10 +44,9 @@ class Fournisseur extends Societe
function __construct($db) function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->client = 0; $this->client = 0;
$this->fournisseur = 0; $this->fournisseur = 1;
$this->effectif_id = 0;
$this->forme_juridique_code = 0;
} }

View File

@ -160,16 +160,16 @@ class Product extends CommonObject
//! Average price value for product entry into stock (PMP) //! Average price value for product entry into stock (PMP)
public $pmp; public $pmp;
/** /**
* Stock alert * Stock alert
* @var int * @var int
*/ */
public $seuil_stock_alerte; public $seuil_stock_alerte=0;
/** /**
* Ask for replenishment when $desiredstock < $stock_reel * Ask for replenishment when $desiredstock < $stock_reel
*/ */
public $desiredstock; public $desiredstock=0;
/* /*
* Service expiration * Service expiration
@ -185,13 +185,13 @@ class Product extends CommonObject
* Status indicates whether the product is on sale '1' or not '0' * Status indicates whether the product is on sale '1' or not '0'
* @var int * @var int
*/ */
public $status; public $status=0;
/** /**
* Status indicate whether the product is available for purchase '1' or not '0' * Status indicate whether the product is available for purchase '1' or not '0'
* @var int * @var int
*/ */
public $status_buy; public $status_buy=0;
/** /**
* Status indicates whether the product is a finished product '1' or a raw material '0' * Status indicates whether the product is a finished product '1' or a raw material '0'
@ -203,7 +203,7 @@ class Product extends CommonObject
* We must manage lot/batch number, sell-by date and so on : '1':yes '0':no * We must manage lot/batch number, sell-by date and so on : '1':yes '0':no
* @var int * @var int
*/ */
public $status_batch; public $status_batch=0;
/** /**
* Customs code * Customs code
@ -266,7 +266,7 @@ class Product extends CommonObject
//! Product ID already linked to a reference supplier //! Product ID already linked to a reference supplier
public $product_id_already_linked; public $product_id_already_linked;
public $nbphoto; public $nbphoto=0;
//! Contains detail of stock of product into each warehouse //! Contains detail of stock of product into each warehouse
public $stock_warehouse=array(); public $stock_warehouse=array();
@ -332,14 +332,7 @@ class Product extends CommonObject
global $langs; global $langs;
$this->db = $db; $this->db = $db;
$this->status = 0;
$this->status_buy = 0;
$this->nbphoto = 0;
$this->stock_reel = 0;
$this->seuil_stock_alerte = 0;
$this->desiredstock = 0;
$this->canvas = ''; $this->canvas = '';
$this->status_batch=0;
} }
/** /**

View File

@ -29,9 +29,9 @@ include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
*/ */
class Client extends Societe class Client extends Societe
{ {
var $next_prev_filter="te.client in (1,2,3)"; // Used to add a filter in Form::showrefnav method public $next_prev_filter="te.client in (1,2,3)"; // Used to add a filter in Form::showrefnav method
var $cacheprospectstatus=array(); public $cacheprospectstatus=array();
/** /**
@ -42,6 +42,9 @@ class Client extends Societe
function __construct($db) function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->client = 3;
$this->fournisseur = 0;
} }
/** /**

View File

@ -107,22 +107,22 @@ class Societe extends CommonObject
* Thirdparty status : 0=activity ceased, 1= in activity * Thirdparty status : 0=activity ceased, 1= in activity
* @var int * @var int
*/ */
var $status; public $status=1;
/** /**
* Id of department * Id of department
* @var int * @var int
*/ */
var $state_id; public $state_id;
var $state_code; public $state_code;
var $state; public $state;
/** /**
* Id of region * Id of region
* @var int * @var int
*/ */
var $region_code; public $region_code;
var $region; public $region;
/** /**
* State code * State code
@ -130,54 +130,54 @@ class Societe extends CommonObject
* @deprecated Use state_code instead * @deprecated Use state_code instead
* @see state_code * @see state_code
*/ */
var $departement_code; public $departement_code;
/** /**
* @var string * @var string
* @deprecated Use state instead * @deprecated Use state instead
* @see state * @see state
*/ */
var $departement; public $departement;
/** /**
* @var string * @var string
* @deprecated Use country instead * @deprecated Use country instead
* @see country * @see country
*/ */
var $pays; public $pays;
/** /**
* Phone number * Phone number
* @var string * @var string
*/ */
var $phone; public $phone;
/** /**
* Fax number * Fax number
* @var string * @var string
*/ */
var $fax; public $fax;
/** /**
* Email * Email
* @var string * @var string
*/ */
var $email; public $email;
/** /**
* Skype username * Skype username
* @var string * @var string
*/ */
var $skype; public $skype;
/** /**
* Webpage * Webpage
* @var string * @var string
*/ */
var $url; public $url;
//! barcode //! barcode
/** /**
* Barcode value * Barcode value
* @var string * @var string
*/ */
var $barcode; public $barcode;
// 6 professional id (usage depends on country) // 6 professional id (usage depends on country)
@ -185,68 +185,68 @@ class Societe extends CommonObject
* Professional ID 1 (Ex: Siren in France) * Professional ID 1 (Ex: Siren in France)
* @var string * @var string
*/ */
var $idprof1; public $idprof1;
/** /**
* Professional ID 2 (Ex: Siret in France) * Professional ID 2 (Ex: Siret in France)
* @var string * @var string
*/ */
var $idprof2; public $idprof2;
/** /**
* Professional ID 3 (Ex: Ape in France) * Professional ID 3 (Ex: Ape in France)
* @var string * @var string
*/ */
var $idprof3; public $idprof3;
/** /**
* Professional ID 4 (Ex: RCS in France) * Professional ID 4 (Ex: RCS in France)
* @var string * @var string
*/ */
var $idprof4; public $idprof4;
/** /**
* Professional ID 5 * Professional ID 5
* @var string * @var string
*/ */
var $idprof5; public $idprof5;
/** /**
* Professional ID 6 * Professional ID 6
* @var string * @var string
*/ */
var $idprof6; public $idprof6;
var $prefix_comm; public $prefix_comm;
var $tva_assuj; public $tva_assuj=1;
/** /**
* Intracommunitary VAT ID * Intracommunitary VAT ID
* @var string * @var string
*/ */
var $tva_intra; public $tva_intra;
// Local taxes // Local taxes
var $localtax1_assuj; public $localtax1_assuj;
var $localtax1_value; public $localtax1_value;
var $localtax2_assuj; public $localtax2_assuj;
var $localtax2_value; public $localtax2_value;
var $managers; public $managers;
var $capital; public $capital;
var $typent_id; public $typent_id=0;
var $typent_code; public $typent_code;
var $effectif; public $effectif;
var $effectif_id; public $effectif_id=0;
var $forme_juridique_code; public $forme_juridique_code;
var $forme_juridique; public $forme_juridique=0;
var $remise_percent; public $remise_percent;
var $remise_supplier_percent; public $remise_supplier_percent;
var $mode_reglement_supplier_id; public $mode_reglement_supplier_id;
var $cond_reglement_supplier_id; public $cond_reglement_supplier_id;
var $fk_prospectlevel; public $fk_prospectlevel;
var $name_bis; public $name_bis;
//Log data //Log data
@ -254,127 +254,127 @@ class Societe extends CommonObject
* Date of last update * Date of last update
* @var string * @var string
*/ */
var $date_modification; public $date_modification;
/** /**
* User that made last update * User that made last update
* @var string * @var string
*/ */
var $user_modification; public $user_modification;
/** /**
* Date of creation * Date of creation
* @var string * @var string
*/ */
var $date_creation; public $date_creation;
/** /**
* User that created the thirdparty * User that created the thirdparty
* @var User * @var User
*/ */
var $user_creation; public $user_creation;
var $specimen; public $specimen;
/** /**
* 0=no customer, 1=customer, 2=prospect, 3=customer and prospect * 0=no customer, 1=customer, 2=prospect, 3=customer and prospect
* @var int * @var int
*/ */
var $client; public $client=0;
/** /**
* 0=no prospect, 1=prospect * 0=no prospect, 1=prospect
* @var int * @var int
*/ */
var $prospect; public $prospect=0;
/** /**
* 0=no supplier, 1=supplier * 0=no supplier, 1=supplier
* @var int * @var int
*/ */
var $fournisseur; public $fournisseur;
/** /**
* Client code. E.g: CU2014-003 * Client code. E.g: CU2014-003
* @var string * @var string
*/ */
var $code_client; public $code_client;
/** /**
* Supplier code. E.g: SU2014-003 * Supplier code. E.g: SU2014-003
* @var string * @var string
*/ */
var $code_fournisseur; public $code_fournisseur;
/** /**
* Accounting code for client * Accounting code for client
* @var string * @var string
*/ */
var $code_compta; public $code_compta;
/** /**
* Accounting code for suppliers * Accounting code for suppliers
* @var string * @var string
*/ */
var $code_compta_fournisseur; public $code_compta_fournisseur;
/** /**
* @var string * @var string
* @deprecated Note is split in public and private notes * @deprecated Note is split in public and private notes
* @see note_public, note_private * @see note_public, note_private
*/ */
var $note; public $note;
/** /**
* Private note * Private note
* @var string * @var string
*/ */
var $note_private; public $note_private;
/** /**
* Public note * Public note
* @var string * @var string
*/ */
var $note_public; public $note_public;
//! code statut prospect //! code statut prospect
var $stcomm_id; public $stcomm_id;
var $statut_commercial; public $statut_commercial;
/** /**
* Assigned price level * Assigned price level
* @var int * @var int
*/ */
var $price_level; public $price_level;
var $outstanding_limit; public $outstanding_limit;
/** /**
* Min order amounts * Min order amounts
*/ */
var $order_min_amount; public $order_min_amount;
var $supplier_order_min_amount; public $supplier_order_min_amount;
/** /**
* Id of sales representative to link (used for thirdparty creation). Not filled by a fetch, because we can have several sales representatives. * Id of sales representative to link (used for thirdparty creation). Not filled by a fetch, because we can have several sales representatives.
* @var int * @var int
*/ */
var $commercial_id; public $commercial_id;
/** /**
* Id of parent thirdparty (if one) * Id of parent thirdparty (if one)
* @var int * @var int
*/ */
var $parent; public $parent;
/** /**
* Default language code of thirdparty (en_US, ...) * Default language code of thirdparty (en_US, ...)
* @var string * @var string
*/ */
var $default_lang; public $default_lang;
var $ref; public $ref;
var $ref_int; public $ref_int;
/** /**
* External user reference. * External user reference.
* This is to allow external systems to store their id and make self-developed synchronizing functions easier to * This is to allow external systems to store their id and make self-developed synchronizing functions easier to
* build. * build.
* @var string * @var string
*/ */
var $ref_ext; public $ref_ext;
/** /**
* Import key. * Import key.
@ -382,45 +382,39 @@ class Societe extends CommonObject
* to an import process * to an import process
* @var string * @var string
*/ */
var $import_key; public $import_key;
/** /**
* Supplier WebServices URL * Supplier WebServices URL
* @var string * @var string
*/ */
var $webservices_url; public $webservices_url;
/** /**
* Supplier WebServices Key * Supplier WebServices Key
* @var string * @var string
*/ */
var $webservices_key; public $webservices_key;
var $logo; public $logo;
var $logo_small; public $logo_small;
var $logo_mini; public $logo_mini;
var $array_options; public $array_options;
// Incoterms // Incoterms
var $fk_incoterms; public $fk_incoterms;
var $location_incoterms; public $location_incoterms;
var $libelle_incoterms; //Used into tooltip public $libelle_incoterms; //Used into tooltip
// Multicurrency // Multicurrency
var $fk_multicurrency; public $fk_multicurrency;
var $multicurrency_code; public $multicurrency_code;
// END MODULEBUILDER PROPERTIES // END MODULEBUILDER PROPERTIES
/**
* To contains a clone of this when we need to save old properties of object
* @var Societe
*/
var $oldcopy;
/** /**
* Constructor * Constructor
* *
@ -1972,7 +1966,7 @@ class Societe extends CommonObject
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
$name=$this->name?$this->name:$this->nom; $name=$this->name?$this->name:$this->nom;
if(!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)){ if(!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)){
if(empty($option) && $this->client > 0) $option = 'customer'; if(empty($option) && $this->client > 0) $option = 'customer';

View File

@ -191,18 +191,6 @@ class SupplierProposal extends CommonObject
$this->remise = 0; $this->remise = 0;
$this->remise_percent = 0; $this->remise_percent = 0;
$this->remise_absolue = 0; $this->remise_absolue = 0;
$langs->load("supplier_proposal");
$this->labelstatut[0]=$langs->trans("SupplierProposalStatusDraft");
$this->labelstatut[1]=$langs->trans("SupplierProposalStatusValidated");
$this->labelstatut[2]=$langs->trans("SupplierProposalStatusSigned");
$this->labelstatut[3]=$langs->trans("SupplierProposalStatusNotSigned");
$this->labelstatut[4]=$langs->trans("SupplierProposalStatusClosed");
$this->labelstatut_short[0]=$langs->trans("SupplierProposalStatusDraftShort");
$this->labelstatut_short[1]=$langs->trans("Opened");
$this->labelstatut_short[2]=$langs->trans("SupplierProposalStatusSignedShort");
$this->labelstatut_short[3]=$langs->trans("SupplierProposalStatusNotSignedShort");
$this->labelstatut_short[4]=$langs->trans("SupplierProposalStatusClosedShort");
} }
@ -2072,9 +2060,24 @@ class SupplierProposal extends CommonObject
*/ */
function LibStatut($statut,$mode=1) function LibStatut($statut,$mode=1)
{ {
global $langs; // Init/load array of translation of status
$langs->load("supplier_proposal"); if (empty($this->labelstatut) || empty($this->labelstatut_short))
{
global $langs;
$langs->load("supplier_proposal");
$this->labelstatut[0]=$langs->trans("SupplierProposalStatusDraft");
$this->labelstatut[1]=$langs->trans("SupplierProposalStatusValidated");
$this->labelstatut[2]=$langs->trans("SupplierProposalStatusSigned");
$this->labelstatut[3]=$langs->trans("SupplierProposalStatusNotSigned");
$this->labelstatut[4]=$langs->trans("SupplierProposalStatusClosed");
$this->labelstatut_short[0]=$langs->trans("SupplierProposalStatusDraftShort");
$this->labelstatut_short[1]=$langs->trans("Opened");
$this->labelstatut_short[2]=$langs->trans("SupplierProposalStatusSignedShort");
$this->labelstatut_short[3]=$langs->trans("SupplierProposalStatusNotSignedShort");
$this->labelstatut_short[4]=$langs->trans("SupplierProposalStatusClosedShort");
}
$statuttrans='';
if ($statut==0) $statuttrans='statut0'; if ($statut==0) $statuttrans='statut0';
if ($statut==1) $statuttrans='statut1'; if ($statut==1) $statuttrans='statut1';
if ($statut==2) $statuttrans='statut3'; if ($statut==2) $statuttrans='statut3';