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;
// Retreive all extrafield for thirdparty
// Retreive all extrafield
// fetch optionals attributes and labels
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_optionals();
// Load other properties
$result=$this->fetch_subscriptions();

View File

@ -236,7 +236,9 @@ class Categorie extends CommonObject
$this->type = $res['type'];
$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);

View File

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

View File

@ -1434,12 +1434,9 @@ class Propal extends CommonObject
$this->brouillon = 1;
}
// Retreive all extrafield for invoice
// Retreive all extrafield
// fetch optionals attributes and labels
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_optionals();
$this->db->free($resql);

View File

@ -1668,12 +1668,9 @@ class Commande extends CommonOrder
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
// Retrieve all extrafields for invoice
// Retreive all extrafield
// fetch optionals attributes and labels
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_optionals();
$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_update = $this->db->jdate($obj->date_update);
// Retreive all extrafield for thirdparty
// Retreive all extrafield
// fetch optionals attributes and labels
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_optionals();
return 1;
}

View File

@ -381,12 +381,9 @@ class FactureRec extends CommonInvoice
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
// Retreive all extrafield for thirdparty
// Retreive all extrafield
// fetch optionals attributes and labels
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_optionals();
/*
* Lines

View File

@ -790,14 +790,17 @@ class Facture extends CommonInvoice
// Charge facture source
$facture=new Facture($this->db);
$this->fetch_optionals();
if(!empty($this->array_options)){
$facture->array_options = $this->array_options;
}
// Retreive all extrafield
// fetch optionals attributes and labels
$this->fetch_optionals();
foreach($this->lines as &$line){
if(!empty($this->array_options)){
$facture->array_options = $this->array_options;
}
foreach($this->lines as &$line){
$line->fetch_optionals();//fetch extrafields
}
}
$facture->fk_facture_source = $this->fk_facture_source;
$facture->type = $this->type;
@ -1328,16 +1331,13 @@ class Facture extends CommonInvoice
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
// Retrieve all extrafield for invoice
// Retreive all extrafield
// fetch optionals attributes and labels
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_optionals();
/*
* Lines
*/
*/
$this->lines = array();

View File

@ -801,12 +801,9 @@ class Contact extends CommonObject
}
}
// Retreive all extrafield for contact
// fetch optionals attributes and labels
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);
// Retreive all extrafield
// fetch optionals attributes and labels
$this->fetch_optionals();
return 1;
}

View File

@ -635,7 +635,9 @@ class Contrat extends CommonObject
$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
// fetch optionals attributes and labels
/*
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_optionals();
// $this->fetch_lines();

View File

@ -665,12 +665,9 @@ class Don extends CommonObject
$this->modelpdf = $obj->model_pdf;
$this->commentaire = $obj->note; // deprecated
// Retrieve all extrafield for thirdparty
// Retreive all extrafield
// fetch optionals attributes and labels
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_optionals();
}
return 1;
}

View File

@ -337,12 +337,8 @@ class EcmFiles //extends CommonObject
// Retrieve all extrafields for invoice
// fetch optionals attributes and labels
/*
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_optionals();
// $this->fetch_lines();
$this->db->free($resql);

View File

@ -547,12 +547,9 @@ class Expedition extends CommonObject
*/
$result=$this->fetch_thirdparty();
// Retrieve all extrafields for expedition
// Retreive all extrafield
// fetch optionals attributes and labels
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_optionals();
/*
* Lines

View File

@ -383,14 +383,13 @@ class Fichinter extends CommonObject
if ($this->statut == 0) $this->brouillon = 1;
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);
// Retreive all extrafield
// fetch optionals attributes and labels
$this->fetch_optionals();
/*
* Lines
*/
*/
$result=$this->fetch_lines();
if ($result < 0)
{

View File

@ -310,12 +310,9 @@ class CommandeFournisseur extends CommonOrder
$this->db->free($resql);
// Retrieve all extrafields
// Retreive all extrafield
// fetch optionals attributes and labels
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_optionals();
if ($this->statut == 0) $this->brouillon = 1;

View File

@ -643,10 +643,7 @@ class FactureFournisseur extends CommonInvoice
// Retreive all extrafield
// fetch optionals attributes and labels
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_optionals();
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;
// Retrieve all extrafields for delivery
// Retreive all extrafield
// fetch optionals attributes and labels
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_optionals();
/*
* Lignes

View File

@ -1951,13 +1951,9 @@ class Product extends CommonObject
$this->db->free($resql);
// Retreive all extrafield for current object
// Retreive all extrafield
// fetch optionals attributes and labels
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_optionals();
// multilangs
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);
}
// Retrieve all extrafields for invoice
// Retreive all extrafield
// fetch optionals attributes and labels
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_optionals();
// $this->fetch_lines();

View File

@ -233,12 +233,9 @@ class Productlot extends CommonObject
$this->fk_user_modif = $obj->fk_user_modif;
$this->import_key = $obj->import_key;
// Retrieve all extrafields for invoice
// Retreive all extrafield
// fetch optionals attributes and labels
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_optionals();
}
$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
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_optionals();
// $this->fetch_lines();

View File

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

View File

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

View File

@ -213,13 +213,9 @@ class Dolresource extends CommonObject
$this->note_private = $obj->note_private;
$this->type_label = $obj->type_label;
// Retreive all extrafield for thirdparty
// Retreive all extrafield
// fetch optionals attributes and labels
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_optionals();
}
$this->db->free($resql);

View File

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

View File

@ -1215,12 +1215,9 @@ class SupplierProposal extends CommonObject
$this->brouillon = 1;
}
// Retreive all extrafield for invoice
// Retreive all extrafield
// fetch optionals attributes and labels
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_optionals();
$this->db->free($resql);
@ -1311,12 +1308,9 @@ class SupplierProposal extends CommonObject
return -1;
}
// Retreive all extrafield for askprice
// Retreive all extrafield
// fetch optionals attributes and labels
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_optionals();
return 1;
}

View File

@ -324,12 +324,9 @@ class User extends CommonObject
// 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;
// Retreive all extrafield for thirdparty
// Retreive all extrafield
// fetch optionals attributes and labels
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_optionals();
$this->db->free($result);
}

View File

@ -116,12 +116,9 @@ class UserGroup extends CommonObject
$this->members=$this->listUsersForGroup();
// Retreive all extrafield for group
// Retreive all extrafield
// fetch optionals attributes and labels
dol_include_once('/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_optionals();
// Sav current LDAP Current DN