Clean code around fetch_optionals()

This commit is contained in:
Laurent Destailleur 2018-02-20 19:38:18 +01:00
parent 8b54a80593
commit c4130730cb
29 changed files with 135 additions and 198 deletions

View File

@ -1156,12 +1156,9 @@ class Adherent extends CommonObject
$this->model_pdf = $obj->model_pdf; $this->model_pdf = $obj->model_pdf;
// Retreive all extrafield for thirdparty // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
// Load other properties // Load other properties
$result=$this->fetch_subscriptions(); $result=$this->fetch_subscriptions();

View File

@ -236,7 +236,9 @@ class Categorie extends CommonObject
$this->type = $res['type']; $this->type = $res['type'];
$this->entity = $res['entity']; $this->entity = $res['entity'];
$this->fetch_optionals($this->id,null); // Retreive all extrafield
// fetch optionals attributes and labels
$this->fetch_optionals();
$this->db->free($resql); $this->db->free($resql);

View File

@ -465,7 +465,10 @@ class ActionComm extends CommonObject
// Load source object // Load source object
$objFrom = clone $this; $objFrom = clone $this;
// Retreive all extrafield
// fetch optionals attributes and labels
$this->fetch_optionals(); $this->fetch_optionals();
// $this->fetch_userassigned(); // $this->fetch_userassigned();
$this->fetchResources(); $this->fetchResources();

View File

@ -1434,12 +1434,9 @@ class Propal extends CommonObject
$this->brouillon = 1; $this->brouillon = 1;
} }
// Retreive all extrafield for invoice // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
$this->db->free($resql); $this->db->free($resql);

View File

@ -1668,12 +1668,9 @@ class Commande extends CommonOrder
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
// Retrieve all extrafields for invoice // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
$this->db->free($result); $this->db->free($result);

View File

@ -913,12 +913,9 @@ class Account extends CommonObject
$this->date_creation = $this->db->jdate($obj->date_creation); $this->date_creation = $this->db->jdate($obj->date_creation);
$this->date_update = $this->db->jdate($obj->date_update); $this->date_update = $this->db->jdate($obj->date_update);
// Retreive all extrafield for thirdparty // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
return 1; return 1;
} }

View File

@ -381,12 +381,9 @@ class FactureRec extends CommonInvoice
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
// Retreive all extrafield for thirdparty // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
/* /*
* Lines * Lines

View File

@ -790,7 +790,10 @@ class Facture extends CommonInvoice
// Charge facture source // Charge facture source
$facture=new Facture($this->db); $facture=new Facture($this->db);
// Retreive all extrafield
// fetch optionals attributes and labels
$this->fetch_optionals(); $this->fetch_optionals();
if(!empty($this->array_options)){ if(!empty($this->array_options)){
$facture->array_options = $this->array_options; $facture->array_options = $this->array_options;
} }
@ -1328,12 +1331,9 @@ class Facture extends CommonInvoice
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
// Retrieve all extrafield for invoice // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
/* /*
* Lines * Lines

View File

@ -801,12 +801,9 @@ class Contact extends CommonObject
} }
} }
// Retreive all extrafield for contact // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
return 1; return 1;
} }

View File

@ -635,7 +635,9 @@ class Contrat extends CommonObject
$this->db->free($resql); $this->db->free($resql);
$this->fetch_optionals($this->id, null); // Retreive all extrafield
// fetch optionals attributes and labels
$this->fetch_optionals();
/* /*

View File

@ -194,12 +194,7 @@ class Ctyperesource
// Retrieve all extrafields for invoice // Retrieve all extrafields for invoice
// fetch optionals attributes and labels // fetch optionals attributes and labels
/* // $this->fetch_optionals();
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
*/
// $this->fetch_lines(); // $this->fetch_lines();

View File

@ -665,12 +665,9 @@ class Don extends CommonObject
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
$this->commentaire = $obj->note; // deprecated $this->commentaire = $obj->note; // deprecated
// Retrieve all extrafield for thirdparty // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
} }
return 1; return 1;
} }

View File

@ -337,12 +337,8 @@ class EcmFiles //extends CommonObject
// Retrieve all extrafields for invoice // Retrieve all extrafields for invoice
// fetch optionals attributes and labels // fetch optionals attributes and labels
/* // $this->fetch_optionals();
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
*/
// $this->fetch_lines(); // $this->fetch_lines();
$this->db->free($resql); $this->db->free($resql);

View File

@ -547,12 +547,9 @@ class Expedition extends CommonObject
*/ */
$result=$this->fetch_thirdparty(); $result=$this->fetch_thirdparty();
// Retrieve all extrafields for expedition // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
/* /*
* Lines * Lines

View File

@ -383,10 +383,9 @@ class Fichinter extends CommonObject
if ($this->statut == 0) $this->brouillon = 1; if ($this->statut == 0) $this->brouillon = 1;
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); // Retreive all extrafield
$extrafields=new ExtraFields($this->db); // fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); $this->fetch_optionals();
$this->fetch_optionals($this->id,$extralabels);
/* /*
* Lines * Lines

View File

@ -310,12 +310,9 @@ class CommandeFournisseur extends CommonOrder
$this->db->free($resql); $this->db->free($resql);
// Retrieve all extrafields // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
if ($this->statut == 0) $this->brouillon = 1; if ($this->statut == 0) $this->brouillon = 1;

View File

@ -643,10 +643,7 @@ class FactureFournisseur extends CommonInvoice
// Retreive all extrafield // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;

View File

@ -301,13 +301,9 @@ class Livraison extends CommonObject
if ($this->statut == 0) $this->brouillon = 1; if ($this->statut == 0) $this->brouillon = 1;
// Retreive all extrafield
// Retrieve all extrafields for delivery
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
/* /*
* Lignes * Lignes

View File

@ -1951,13 +1951,9 @@ class Product extends CommonObject
$this->db->free($resql); $this->db->free($resql);
// Retreive all extrafield
// Retreive all extrafield for current object
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
// multilangs // multilangs
if (! empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs(); if (! empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs();

View File

@ -576,12 +576,9 @@ class MouvementStock extends CommonObject
$this->sellby = $this->db->jdate($obj->sellby); $this->sellby = $this->db->jdate($obj->sellby);
} }
// Retrieve all extrafields for invoice // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
// $this->fetch_lines(); // $this->fetch_lines();

View File

@ -233,12 +233,9 @@ class Productlot extends CommonObject
$this->fk_user_modif = $obj->fk_user_modif; $this->fk_user_modif = $obj->fk_user_modif;
$this->import_key = $obj->import_key; $this->import_key = $obj->import_key;
// Retrieve all extrafields for invoice // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
} }
$this->db->free($resql); $this->db->free($resql);

View File

@ -202,12 +202,9 @@ class ProductStockEntrepot extends CommonObject
} }
// Retrieve all extrafields for invoice // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
// $this->fetch_lines(); // $this->fetch_lines();

View File

@ -444,7 +444,8 @@ class Project extends CommonObject
$this->db->free($resql); $this->db->free($resql);
// Retreive all extrafield for thirdparty // Retreive all extrafield
// fetch optionals attributes and labels
$this->fetch_optionals(); $this->fetch_optionals();
if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT)) if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT))

View File

@ -266,7 +266,8 @@ class Task extends CommonObject
$this->task_parent_position = $obj->task_parent_position; $this->task_parent_position = $obj->task_parent_position;
} }
// Retreive all extrafield data // Retreive all extrafield
// fetch optionals attributes and labels
$this->fetch_optionals(); $this->fetch_optionals();
} }

View File

@ -213,13 +213,9 @@ class Dolresource extends CommonObject
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;
$this->type_label = $obj->type_label; $this->type_label = $obj->type_label;
// Retreive all extrafield for thirdparty // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
} }
$this->db->free($resql); $this->db->free($resql);

View File

@ -1315,7 +1315,8 @@ class Societe extends CommonObject
$result = 1; $result = 1;
// Retreive all extrafield for thirdparty // Retreive all extrafield
// fetch optionals attributes and labels
$this->fetch_optionals(); $this->fetch_optionals();
} }
else else

View File

@ -1215,12 +1215,9 @@ class SupplierProposal extends CommonObject
$this->brouillon = 1; $this->brouillon = 1;
} }
// Retreive all extrafield for invoice // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
$this->db->free($resql); $this->db->free($resql);
@ -1311,12 +1308,9 @@ class SupplierProposal extends CommonObject
return -1; return -1;
} }
// Retreive all extrafield for askprice // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
return 1; return 1;
} }

View File

@ -324,12 +324,9 @@ class User extends CommonObject
// in such case, this admin user must be admin for ALL entities. // in such case, this admin user must be admin for ALL entities.
if (empty($conf->multicompany->enabled) && $this->admin && $this->entity == 1) $this->entity = 0; if (empty($conf->multicompany->enabled) && $this->admin && $this->entity == 1) $this->entity = 0;
// Retreive all extrafield for thirdparty // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
$this->db->free($result); $this->db->free($result);
} }

View File

@ -116,12 +116,9 @@ class UserGroup extends CommonObject
$this->members=$this->listUsersForGroup(); $this->members=$this->listUsersForGroup();
// Retreive all extrafield for group // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels
dol_include_once('/core/class/extrafields.class.php'); $this->fetch_optionals();
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
// Sav current LDAP Current DN // Sav current LDAP Current DN