From 4cf3857aa4cdae59450fa6cfdb644c3cc05ba96f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 3 May 2014 13:19:03 +0200 Subject: [PATCH 1/7] Improved documentation of Societe and started type hinting variables --- htdocs/societe/class/societe.class.php | 85 ++++++++++++++++++++------ 1 file changed, 65 insertions(+), 20 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index dc7488c733f..06f7e3799da 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -42,11 +42,20 @@ class Societe extends CommonObject public $table_element = 'societe'; public $fk_element='fk_soc'; protected $childtables=array("propal","commande","facture","contrat","facture_fourn","commande_fournisseur"); // To test if we can delete object - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + + /** + * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + * @var int + */ + protected $ismultientitymanaged = 1; var $id; var $name; - var $nom; // TODO obsolete + + /** + * @deprecated Use $name instead + */ + var $nom; var $firstname; var $lastname; var $particulier; @@ -54,15 +63,31 @@ class Societe extends CommonObject var $address; var $zip; var $town; - var $status; // 0=activity ceased, 1= in activity + /** + * 0=activity ceased, 1= in activity + * @var int + */ + var $status; - var $state_id; // Id of department + /** + * Id of department + */ + var $state_id; var $state_code; var $state; + /** + * @deprecated Use state_code instead + */ var $departement_code; // deprecated - var $departement; // deprecated + /** + * @deprecated Use state instead + */ + var $departement; - var $pays; // deprecated + /** + * @deprecated Use country instead + */ + var $pays; var $country_id; var $country_code; var $country; @@ -111,16 +136,31 @@ class Societe extends CommonObject var $mode_reglement_supplier_id; var $cond_reglement_supplier_id; - var $client; // 0=no customer, 1=customer, 2=prospect, 3=customer and prospect - var $prospect; // 0=no prospect, 1=prospect - var $fournisseur; // 0=no supplier, 1=supplier + /** + * 0=no customer, 1=customer, 2=prospect, 3=customer and prospect + * @var int + */ + var $client; + /** + * 0=no prospect, 1=prospect + * @var int + */ + var $prospect; + /** + * 0=no supplier, 1=supplier + * @var int + */ + var $fournisseur; var $code_client; var $code_fournisseur; var $code_compta; var $code_compta_fournisseur; - var $note; //TODO deprecated + /** + * @deprecated Note is split in public and private notes + */ + var $note; var $note_private; var $note_public; //! code statut prospect @@ -133,7 +173,10 @@ class Societe extends CommonObject var $datec; var $date_update; - var $commercial_id; // 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 $commercial_id; var $parent; var $default_lang; @@ -146,8 +189,10 @@ class Societe extends CommonObject var $array_options; - var $oldcopy; // To contains a clone of this when we need to save old properties of object - + /** + * To contains a clone of this when we need to save old properties of object + */ + var $oldcopy; /** * Constructor @@ -304,7 +349,7 @@ class Societe extends CommonObject * @param User $user Object user * @return int <0 if KO, >0 if OK */ - function create_individual($user) + function create_individual(User $user) { require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $contact=new Contact($this->db); @@ -1199,7 +1244,7 @@ class Societe extends CommonObject * @param User $user Utilisateur qui definie la remise * @return int <0 if KO, >0 if OK */ - function set_remise_client($remise, $note, $user) + function set_remise_client($remise, $note, User $user) { global $langs; @@ -1261,7 +1306,7 @@ class Societe extends CommonObject * @param float $tva_tx VAT rate * @return int <0 if KO, id of discount record if OK */ - function set_remise_except($remise, $user, $desc, $tva_tx=0) + function set_remise_except($remise, User $user, $desc, $tva_tx=0) { global $langs; @@ -1337,7 +1382,7 @@ class Societe extends CommonObject * @param User $user Object user * @return array Array of sales representatives of third party */ - function getSalesRepresentatives($user='') + function getSalesRepresentatives(User $user) { global $conf; @@ -1376,7 +1421,7 @@ class Societe extends CommonObject * @param User $user Use making change * @return int <0 if KO, >0 if OK */ - function set_price_level($price_level, $user) + function set_price_level($price_level, User $user) { if ($this->id) { @@ -1409,7 +1454,7 @@ class Societe extends CommonObject * @param int $commid Id of user * @return void */ - function add_commercial($user, $commid) + function add_commercial(User $user, $commid) { if ($this->id > 0 && $commid > 0) { @@ -1436,7 +1481,7 @@ class Societe extends CommonObject * @param int $commid Id of user * @return void */ - function del_commercial($user, $commid) + function del_commercial(User $user, $commid) { if ($this->id > 0 && $commid > 0) { From eb57d729a37237e3f7e426b71f1986c632afaa4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 3 May 2014 13:23:45 +0200 Subject: [PATCH 2/7] Typehinting $user variable --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 06f7e3799da..d395200da2a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2887,7 +2887,7 @@ class Societe extends CommonObject * @param User $user User making change * @return int <0 if KO, >0 if OK */ - function set_OutstandingBill ($user) + function set_OutstandingBill (User $user) { if ($this->id) { From 0d129617cb2d3ef401ec6ce51c3a8cb581642dc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 3 May 2014 13:24:42 +0200 Subject: [PATCH 3/7] Corrected Database.interface::fetch_object doc --- htdocs/core/db/Database.interface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php index 2a4fe0b57e8..233a7470a9f 100644 --- a/htdocs/core/db/Database.interface.php +++ b/htdocs/core/db/Database.interface.php @@ -451,7 +451,7 @@ interface Database /** * Renvoie la ligne courante (comme un objet) pour le curseur resultset * - * @param Resultset $resultset Curseur de la requete voulue + * @param resource $resultset Curseur de la requete voulue * @return Object Object result line or false if KO or end of cursor */ function fetch_object($resultset); From abfb8b23175dde58f6407a2d862cccee5eab45d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 3 May 2014 13:27:24 +0200 Subject: [PATCH 4/7] Corrected Database.interface doc --- htdocs/core/db/Database.interface.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php index 233a7470a9f..8b5f2c86810 100644 --- a/htdocs/core/db/Database.interface.php +++ b/htdocs/core/db/Database.interface.php @@ -38,7 +38,7 @@ interface Database /** * Return datas as an array * - * @param Resultset $resultset Resultset of request + * @param resource $resultset Resultset of request * @return array Array */ function fetch_row($resultset); @@ -98,7 +98,7 @@ interface Database /** * Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE * - * @param resultset $resultset Curseur de la requete voulue + * @param resource $resultset Curseur de la requete voulue * @return int Nombre de lignes * @see num_rows */ @@ -154,7 +154,7 @@ interface Database /** * Return datas as an array * - * @param Resultset $resultset Resultset of request + * @param resource $resultset Resultset of request * @return array Array */ function fetch_array($resultset); @@ -257,7 +257,7 @@ interface Database /** * Return number of lines for result of a SELECT * - * @param Resultset $resultset Resulset of requests + * @param resource $resultset Resulset of requests * @return int Nb of lines * @see affected_rows */ @@ -421,7 +421,7 @@ interface Database /** * Free last resultset used. * - * @param resultset $resultset Curseur de la requete voulue + * @param resource $resultset Curseur de la requete voulue * @return void */ function free($resultset = 0); From 105d892d2778204b886d1b23dccae08ed4e740e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 3 May 2014 13:42:34 +0200 Subject: [PATCH 5/7] Corrected Translate::getLabelFromKey doc --- htdocs/core/class/translate.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index c075a71e018..383f2c01cf4 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -643,7 +643,7 @@ class Translate * Search into translation array, then into cache, then if still not found, search into database. * Store key-label found into cache variable $this->cache_labels to save SQL requests to get labels. * - * @param DoliBD $db Database handler + * @param DoliDB $db Database handler * @param string $key Translation key to get label (key in language file) * @param string $tablename Table name without prefix * @param string $fieldkey Field for key From 85c605449ef317a722a77b9ea7bb74150c2c2799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 3 May 2014 13:45:20 +0200 Subject: [PATCH 6/7] Defined missing used variables of the class and removed unused local vars --- htdocs/societe/class/societe.class.php | 34 +++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index d395200da2a..13ab928be09 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -51,6 +51,7 @@ class Societe extends CommonObject var $id; var $name; + var $entity; /** * @deprecated Use $name instead @@ -126,6 +127,7 @@ class Societe extends CommonObject var $capital; var $typent_id; var $typent_code; + var $effectif; var $effectif_id; var $forme_juridique_code; var $forme_juridique; @@ -136,6 +138,14 @@ class Societe extends CommonObject var $mode_reglement_supplier_id; var $cond_reglement_supplier_id; + var $date_modification; + var $date_creation; + var $user_modification; + var $user_creation; + var $fk_prospectlevel; + var $specimen; + var $name_bis; + /** * 0=no customer, 1=customer, 2=prospect, 3=customer and prospect * @var int @@ -180,7 +190,9 @@ class Societe extends CommonObject var $parent; var $default_lang; + var $ref; var $ref_int; + var $ref_ext; var $import_key; var $logo; @@ -201,8 +213,6 @@ class Societe extends CommonObject */ public function __construct($db) { - global $conf; - $this->db = $db; $this->client = 0; @@ -1066,7 +1076,7 @@ class Societe extends CommonObject */ function delete($id) { - global $user, $langs, $conf, $hookmanager; + global $user, $langs, $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -2196,7 +2206,6 @@ class Societe extends CommonObject $resql = $this->db->query($sql); if ($resql) { - $nump = $this->db->num_rows($resql); $obj = $this->db->fetch_object($resql); $count = $obj->idprof; } @@ -2364,7 +2373,6 @@ class Societe extends CommonObject $resql = $this->db->query($sql); if ($resql) { - $nump = $this->db->num_rows($resql); $obj = $this->db->fetch_object($resql); $count = $obj->numproj; } @@ -2496,13 +2504,13 @@ class Societe extends CommonObject /** * Create a third party into database from a member object * - * @param Member $member Object member + * @param Adherent $member Object member * @param string $socname Name of third party to force * @return int <0 if KO, id of created account if OK */ - function create_from_member($member,$socname='') + function create_from_member(Adherent $member,$socname='') { - global $conf,$user,$langs; + global $user,$langs; $name = $socname?$socname:$member->societe; if (empty($name)) $name=$member->getFullName($langs); @@ -2639,8 +2647,6 @@ class Societe extends CommonObject */ function initAsSpecimen() { - global $user,$langs,$conf,$mysoc; - $now=dol_now(); // Initialize parameters @@ -2769,14 +2775,12 @@ class Societe extends CommonObject * @param User $user Utilisateur qui definie la remise * @return int <0 if KO, >0 if OK */ - function set_prospect_level($user) + function set_prospect_level(User $user) { if ($this->id) { $this->db->begin(); - $now=dol_now(); - // Positionne remise courante $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; $sql.= " fk_prospectlevel='".$this->fk_prospectlevel."'"; @@ -2859,8 +2863,6 @@ class Societe extends CommonObject { $this->db->begin(); - $now=dol_now(); - // Positionne remise courante $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; $sql.= " fk_stcomm='".$this->stcomm_id."'"; @@ -2893,8 +2895,6 @@ class Societe extends CommonObject { $this->db->begin(); - $now=dol_now(); - // Clean parameters $outstanding = price2num($this->outstanding_limit); From 862a8626f9adb5e55e927e9844824ac36f6d7a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 4 May 2014 11:31:05 +0200 Subject: [PATCH 7/7] Documenting variables --- htdocs/societe/class/societe.class.php | 125 ++++++++++++++++++++++--- 1 file changed, 113 insertions(+), 12 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 13ab928be09..aee5f3c8f01 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -10,6 +10,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Alexandre Spangaro * Copyright (C) 2013 Peter Fontaine + * Copyright (C) 2014 Marcos GarcĂ­a * * 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 @@ -100,23 +101,77 @@ class Societe extends CommonObject var $url; //! barcode - var $barcode; // value - var $barcode_type; // id - var $barcode_type_code; // code (loaded by fetch_barcode) - var $barcode_type_label; // label (loaded by fetch_barcode) - var $barcode_type_coder; // coder (loaded by fetch_barcode) + /** + * Barcode value + * @var string + */ + var $barcode; + /** + * ID of bardode type + * @var int + */ + var $barcode_type; + /** + * code (loaded by fetch_barcode) + * @var + */ + var $barcode_type_code; + /** + * label (loaded by fetch_barcode) + * @var + */ + var $barcode_type_label; + /** + * coder (loaded by fetch_barcode) + * @var + */ + var $barcode_type_coder; - // 4 professional id (usage depend on country) - var $idprof1; // IdProf1 (Ex: Siren in France) - var $idprof2; // IdProf2 (Ex: Siret in France) - var $idprof3; // IdProf3 (Ex: Ape in France) - var $idprof4; // IdProf4 (Ex: RCS in France) - var $idprof5; // IdProf5 - var $idprof6; // IdProf6 + // 6 professional id (usage depends on country) + + /** + * Professional ID 1 (Ex: Siren in France) + * @var string + */ + var $idprof1; + + /** + * Professional ID 2 (Ex: Siret in France) + * @var string + */ + var $idprof2; + + /** + * Professional ID 3 (Ex: Ape in France) + * @var string + */ + var $idprof3; + + /** + * Professional ID 4 (Ex: RCS in France) + * @var string + */ + var $idprof4; + + /** + * Professional ID 5 + * @var string + */ + var $idprof5; + + /** + * Professional ID 6 + * @var string + */ + var $idprof6; var $prefix_comm; var $tva_assuj; + /** + * Intracommunitary VAT ID + * @var string + */ var $tva_intra; // Local taxes @@ -162,21 +217,54 @@ class Societe extends CommonObject */ var $fournisseur; + /** + * Client code. E.g: CU2014-003 + * @var string + */ var $code_client; + + /** + * Supplier code. E.g: SU2014-003 + * @var string + */ var $code_fournisseur; + + /** + * Accounting code for client + * @var string + */ var $code_compta; + + /** + * Accounting code for suppliers + * @var string + */ var $code_compta_fournisseur; /** * @deprecated Note is split in public and private notes */ var $note; + + /** + * Private note + * @var string + */ var $note_private; + + /** + * Public note + * @var string + */ var $note_public; //! code statut prospect var $stcomm_id; var $statut_commercial; + /** + * Assigned price level + * @var int + */ var $price_level; var $outstanding_limit; @@ -192,7 +280,20 @@ class Societe extends CommonObject var $ref; var $ref_int; + /** + * External user reference. + * This is to allow external systems to store their id and make self-developed synchronizing functions easier to + * build. + * @var string + */ var $ref_ext; + + /** + * Import key. + * Set when the thirdparty has been created through an import process. This is to relate those created thirdparties + * to an import process + * @var string + */ var $import_key; var $logo;