From a318031034c079fb21532767360be06eba02823b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Oct 2023 11:37:29 +0200 Subject: [PATCH] QUAL Standardize code. Renamed ID of user properties into ->user_xxx_id --- ChangeLog | 5 +++- .../class/accountingaccount.class.php | 1 + htdocs/adherents/class/adherent.class.php | 1 + htdocs/asset/class/assetmodel.class.php | 1 + htdocs/bom/class/bom.class.php | 3 ++ htdocs/bookcal/class/availabilities.class.php | 6 ---- htdocs/bookcal/class/calendar.class.php | 6 ---- htdocs/categories/class/categorie.class.php | 4 --- htdocs/comm/action/class/actioncomm.class.php | 2 ++ htdocs/comm/mailing/class/mailing.class.php | 7 +++-- htdocs/comm/propal/class/propal.class.php | 13 ++------- htdocs/commande/class/commande.class.php | 5 ++-- htdocs/compta/bank/class/account.class.php | 14 ++-------- .../bank/class/paymentvarious.class.php | 13 ++------- .../deplacement/class/deplacement.class.php | 1 + .../facture/class/facture-rec.class.php | 15 +++------- htdocs/compta/facture/class/facture.class.php | 28 +++++-------------- .../compta/paiement/class/paiement.class.php | 14 +++------- .../class/rejetprelevement.class.php | 1 - .../sociales/class/chargesociales.class.php | 19 ++----------- htdocs/compta/tva/class/tva.class.php | 14 ++-------- htdocs/contact/class/contact.class.php | 14 ++-------- htdocs/contrat/class/contrat.class.php | 10 ++----- htdocs/core/class/commonobject.class.php | 20 ++++++------- htdocs/core/class/fiscalyear.class.php | 2 ++ htdocs/core/class/timespent.class.php | 6 ---- htdocs/core/lib/functions2.lib.php | 4 +-- htdocs/cron/class/cronjob.class.php | 1 + .../class/emailcollector.class.php | 1 + .../class/emailcollectoraction.class.php | 1 + .../class/emailcollectorfilter.class.php | 1 + .../class/conferenceorbooth.class.php | 1 + .../class/conferenceorboothattendee.class.php | 1 + .../class/expensereport.class.php | 27 ++++-------------- .../class/paymentexpensereport.class.php | 14 +++------- htdocs/fichinter/class/fichinter.class.php | 23 ++++----------- .../class/fournisseur.commande.class.php | 22 +++++---------- .../fourn/class/fournisseur.facture.class.php | 17 +++-------- htdocs/fourn/class/paiementfourn.class.php | 16 +++-------- htdocs/holiday/class/holiday.class.php | 16 ++--------- htdocs/hrm/class/establishment.class.php | 1 + htdocs/hrm/class/evaluation.class.php | 1 + htdocs/hrm/class/evaluationdet.class.php | 1 + htdocs/hrm/class/job.class.php | 1 + htdocs/hrm/class/position.class.php | 1 + htdocs/hrm/class/skill.class.php | 1 + htdocs/hrm/class/skilldet.class.php | 1 + htdocs/hrm/class/skillrank.class.php | 1 + .../class/knowledgerecord.class.php | 1 + htdocs/loan/class/loan.class.php | 1 + .../template/class/myobject.class.php | 25 +++++++++++++---- htdocs/mrp/class/mo.class.php | 1 + .../partnership/class/partnership.class.php | 1 + .../class/partnership_type.class.php | 1 + htdocs/product/class/product.class.php | 17 +++-------- .../class/productfournisseurprice.class.php | 16 ++--------- .../inventory/class/inventory.class.php | 18 ++---------- htdocs/projet/class/project.class.php | 13 +++------ .../class/recruitmentcandidature.class.php | 1 + .../class/recruitmentjobposition.class.php | 1 + htdocs/salaries/class/salary.class.php | 1 + .../class/companypaymentmode.class.php | 1 + htdocs/societe/class/societe.class.php | 6 ++-- htdocs/societe/class/societeaccount.class.php | 1 - .../class/supplier_proposal.class.php | 14 ++-------- htdocs/ticket/class/cticketcategory.class.php | 2 +- htdocs/webhook/class/target.class.php | 2 +- htdocs/webservices/server_thirdparty.php | 6 ++-- .../workstation/class/workstation.class.php | 1 + htdocs/zapier/class/hook.class.php | 1 + 70 files changed, 171 insertions(+), 338 deletions(-) diff --git a/ChangeLog b/ChangeLog index c8821eb3d81..fae8969078c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,11 +24,14 @@ Following changes may create regressions for some external modules, but were nec * The duplicated and deprecated property ->date_livraison that was renamed into ->delivery_date has been completely removed. * The property ->user_close to store ID of closing user has been renamed into ->user_closing_id. * The property ->user_validation to store ID of user validating has been renamed into ->user_validation_id. +* The property ->user_creation to store ID of user of creation has been renamed into ->user_creation_id. +* The property ->user_modification to store ID of user of modification has been renamed into ->user_modification_id. +* The duplicate property ->user_creat, ->date_creat, ->date_valid has been removed * The method get_substitutionarray_shipment_lines() has been removed. Use the generic get_substitutionarray_lines() instead. * The method ProductcustomerPrice->fetch_all_log() has been renamed into camel case ->fetchAllLog() * Recheck setup of your module workflow to see if you need to enable the new setting to have shipment set to billed automatically when an invoice from a shipment is validated (and if your process is to make invoice on shipment and not on order), because this setup has changed. -* It was possible to use a variable $soc or $right inside a php code condition of some extrafields properties, this is no more true (this 2 variables are no more defined globaly). +* It was possible to use a variable $soc or $right inside a php code condition of some extrafields properties, this is no more true (this 2 variables are no more global variables). diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 36cb577d3c8..b8091164925 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -599,6 +599,7 @@ class AccountingAccount extends CommonObject if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_author; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 41ee03cf9a4..1038fbd051a 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2884,6 +2884,7 @@ class Adherent extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_author; diff --git a/htdocs/asset/class/assetmodel.class.php b/htdocs/asset/class/assetmodel.class.php index 458715f7123..05ffe7b9495 100644 --- a/htdocs/asset/class/assetmodel.class.php +++ b/htdocs/asset/class/assetmodel.class.php @@ -733,6 +733,7 @@ class AssetModel extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index b011e3ecb18..c16093ec851 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1280,6 +1280,7 @@ class BOM extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; @@ -2073,7 +2074,9 @@ class BOMLine extends CommonObjectLine if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + $this->user_creation_id = $obj->fk_user_creat; $this->user_modification_id = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->datec); diff --git a/htdocs/bookcal/class/availabilities.class.php b/htdocs/bookcal/class/availabilities.class.php index 1e1d4b5f82d..f61dd40e7df 100644 --- a/htdocs/bookcal/class/availabilities.class.php +++ b/htdocs/bookcal/class/availabilities.class.php @@ -932,14 +932,8 @@ class Availabilities extends CommonObject $this->user_creation_id = $obj->fk_user_creat; $this->user_modification_id = $obj->fk_user_modif; - if (!empty($obj->fk_user_valid)) { - $this->user_validation_id = $obj->fk_user_valid; - } $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem); - if (!empty($obj->datev)) { - $this->date_validation = empty($obj->datev) ? '' : $this->db->jdate($obj->datev); - } } $this->db->free($result); diff --git a/htdocs/bookcal/class/calendar.class.php b/htdocs/bookcal/class/calendar.class.php index 716ffa6bcf4..359dadf8214 100644 --- a/htdocs/bookcal/class/calendar.class.php +++ b/htdocs/bookcal/class/calendar.class.php @@ -958,14 +958,8 @@ class Calendar extends CommonObject $this->user_creation_id = $obj->fk_user_creat; $this->user_modification_id = $obj->fk_user_modif; - if (!empty($obj->fk_user_valid)) { - $this->user_validation_id = $obj->fk_user_valid; - } $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem); - if (!empty($obj->datev)) { - $this->date_validation = empty($obj->datev) ? '' : $this->db->jdate($obj->datev); - } } $this->db->free($result); diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index d956a757151..348334e77dc 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -343,8 +343,6 @@ class Categorie extends CommonObject */ public function fetch($id, $label = '', $type = null, $ref_ext = '') { - global $conf; - // Check parameters if (empty($id) && empty($label) && empty($ref_ext)) { $this->error = "No category to search for"; @@ -389,8 +387,6 @@ class Categorie extends CommonObject $this->date_modification = $this->db->jdate($res['tms']); $this->user_creation_id = (int) $res['fk_user_creat']; $this->user_modification_id = (int) $res['fk_user_modif']; - $this->user_creation = (int) $res['fk_user_creat']; - $this->user_modification = (int) $res['fk_user_modif']; // Retrieve all extrafield // fetch optionals attributes and labels diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index b9040f922bc..e3ed2deb7b8 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1496,7 +1496,9 @@ class ActionComm extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->id; + $this->user_creation_id = $obj->fk_user_author; $this->user_modification_id = $obj->fk_user_mod; $this->date_creation = $this->db->jdate($obj->datec); diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index f1831472a58..f8d51b74787 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -128,6 +128,7 @@ class Mailing extends CommonObject /** * @var int id of user create + * @deprecated */ public $user_creation; @@ -139,6 +140,7 @@ class Mailing extends CommonObject /** * @var int id of user validate + * @deprecated */ public $user_validation; @@ -413,9 +415,8 @@ class Mailing extends CommonObject $this->email_replyto = $obj->email_replyto; $this->email_errorsto = $obj->email_errorsto; - $this->user_creat = $obj->fk_user_creat; - $this->user_creation = $obj->fk_user_creat; - $this->user_validation = $obj->fk_user_valid; + $this->user_creation_id = $obj->fk_user_creat; + $this->user_validation_id = $obj->fk_user_valid; $this->date_creat = $this->db->jdate($obj->date_creat); $this->date_creation = $this->db->jdate($obj->date_creat); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 5092e53a6e9..b122114793c 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3350,13 +3350,8 @@ class Propal extends CommonObject $this->date_signature = $this->db->jdate($obj->date_signature); $this->date_cloture = $this->db->jdate($obj->date_cloture); - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - - if ($obj->fk_user_valid) { - $this->user_validation_id = $obj->fk_user_valid; - } + $this->user_creation_id = $obj->fk_user_author; + $this->user_validation_id = $obj->fk_user_valid; if ($obj->fk_user_signature) { $user_signature = new User($this->db); @@ -3364,9 +3359,7 @@ class Propal extends CommonObject $this->user_signature = $user_signature; } - if ($obj->fk_user_cloture) { - $this->user_closing_id = $obj->fk_user_cloture; - } + $this->user_closing_id = $obj->fk_user_cloture; } $this->db->free($result); } else { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 5decf2e70d5..f4b13e1a3b9 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1911,7 +1911,6 @@ class Commande extends CommonOrder $this->user_creation_id = $obj->fk_user_author; $this->user_validation_id = $obj->fk_user_valid; $this->user_modification_id = $obj->fk_user_modif; - $this->user_modification = $obj->fk_user_modif; // deprecated $this->total_ht = $obj->total_ht; $this->total_tva = $obj->total_tva; $this->total_localtax1 = $obj->total_localtax1; @@ -1920,8 +1919,8 @@ class Commande extends CommonOrder $this->date = $this->db->jdate($obj->date_commande); $this->date_commande = $this->db->jdate($obj->date_commande); $this->date_creation = $this->db->jdate($obj->date_creation); - $this->date_validation = $this->db->jdate($obj->date_valid); - $this->date_modification = $this->db->jdate($obj->tms); + $this->date_validation = $this->db->jdate($obj->date_valid); + $this->date_modification = $this->db->jdate($obj->tms); $this->source = $obj->source; $this->billed = $obj->billed; $this->note = $obj->note_private; // deprecated diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index f35c70890b5..5888499127a 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -2530,19 +2530,11 @@ class AccountLine extends CommonObjectLine if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; - if ($obj->fk_user_author) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } - if ($obj->fk_user_rappro) { - $ruser = new User($this->db); - $ruser->fetch($obj->fk_user_rappro); - $this->user_rappro = $ruser; - } - + $this->user_creation_id = $obj->fk_user_author; + $this->user_rappro = $obj->fk_user_rappro; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->datem); //$this->date_rappro = $obj->daterappro; // Not yet managed diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 14093ed2067..5eaf0d72e55 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -744,18 +744,11 @@ class PaymentVarious extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; - if ($obj->fk_user_author) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } + $this->user_creation = $obj->fk_user_author; + $this->user_modif = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->datec); - if ($obj->fk_user_modif) { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_modif); - $this->user_modif = $muser; - } $this->date_modif = $this->db->jdate($obj->tms); } $this->db->free($result); diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index d5d2cc191e2..d67458eceae 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -457,6 +457,7 @@ class Deplacement extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_author; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index ffbec6a7ad9..ce297c63f5f 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1673,18 +1673,11 @@ class FactureRec extends CommonInvoice if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; - if ($obj->fk_user_author) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } - if ($obj->fk_user_modif) { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_modif); - $this->user_modification = $muser; - } + $this->id = $obj->rowid; + + $this->user_creation_id = $obj->fk_user_author; + $this->user_modification_id = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->datem); } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 60139479720..0f7facb6e26 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -133,13 +133,6 @@ class Facture extends CommonInvoice */ public $fk_user_valid; - /** - * @var int ID - * @deprecated - * @see $fk_user_modif - */ - public $user_modification; - /** * @var int ID */ @@ -2203,9 +2196,9 @@ class Facture extends CommonInvoice $this->note = $obj->note_private; // deprecated $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; - $this->user_creation_id = $obj->fk_user_author; // deprecated - $this->user_validation_id = $obj->fk_user_valid; // deprecated - $this->user_modification = $obj->fk_user_modif; // deprecated + $this->user_creation_id = $obj->fk_user_author; + $this->user_validation_id = $obj->fk_user_valid; + $this->user_modification_id = $obj->fk_user_modif; $this->fk_user_author = $obj->fk_user_author; $this->fk_user_valid = $obj->fk_user_valid; $this->fk_user_modif = $obj->fk_user_modif; @@ -4655,18 +4648,11 @@ class Facture extends CommonInvoice if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; - if ($obj->fk_user_author) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } - if ($obj->fk_user_valid) { - $this->user_validation_id = $obj->fk_user_valid; - } - if ($obj->fk_user_closing) { - $this->user_closing_id = $obj->fk_user_closing; - } + $this->user_creation_id = $obj->fk_user_author; + $this->user_validation_id = $obj->fk_user_valid; + $this->user_closing_id = $obj->fk_user_closing; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->datem); diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 2c91a7e1774..6f95b6237bc 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -1016,17 +1016,11 @@ class Paiement extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; - if ($obj->fk_user_creat) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_creat); - $this->user_creation = $cuser; - } - if ($obj->fk_user_modif) { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_modif); - $this->user_modification = $muser; - } + + $this->user_creation_id = $obj->fk_user_creat; + $this->user_modification_id = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->tms); } diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index 37649da3171..0859f961c2b 100644 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -146,7 +146,6 @@ class RejetPrelevement $result = $this->db->query($sql); if (!$result) { - dol_syslog("RejetPrelevement::create Erreur 4"); dol_syslog("RejetPrelevement::create Erreur 4 $sql"); $error++; } diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 62707e329d2..fb43c8a526a 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -710,22 +710,9 @@ class ChargeSociales extends CommonObject $this->id = $obj->rowid; - if ($obj->fk_user_author) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } - - if ($obj->fk_user_modif) { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_modif); - $this->user_modification = $muser; - } - - if ($obj->fk_user_valid) { - $this->user_validation_id = $obj->fk_user_valid; - } - + $this->user_creation_id = $obj->fk_user_author; + $this->user_modification_id = $obj->fk_user_modif; + $this->user_validation_id = $obj->fk_user_valid; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->datem); $this->date_validation = $this->db->jdate($obj->datev); diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 7a78c565e92..c888f438f54 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -822,18 +822,8 @@ class Tva extends CommonObject $this->id = $obj->rowid; - if ($obj->fk_user_creat) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_creat); - $this->user_creation = $cuser; - } - - if ($obj->fk_user_modif) { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_modif); - $this->user_modification = $muser; - } - + $this->user_creation_id = $obj->fk_user_creat; + $this->user_modification_id = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->tms); $this->import_key = $obj->import_key; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 8d17dea8c94..d8807b9bca9 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1348,18 +1348,8 @@ class Contact extends CommonObject $this->id = $obj->rowid; - if ($obj->fk_user_creat) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_creat); - $this->user_creation = $cuser; - } - - if ($obj->fk_user_modif) { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_modif); - $this->user_modification = $muser; - } - + $this->user_creation_id = $obj->fk_user_creat; + $this->user_modification_id = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->tms); } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 79f774e94b7..bb01930b9e0 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -151,6 +151,7 @@ class Contrat extends CommonObject /** * @var User Object user that create the contract. Set by the info method. + * @deprecated */ public $user_creation; @@ -2157,14 +2158,9 @@ class Contrat extends CommonObject $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - - if ($obj->fk_user_author) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } - $this->ref = (!$obj->ref) ? $obj->rowid : $obj->ref; + + $this->user_creation_id = $obj->fk_user_author; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->date_modification); } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9c70bd72bd3..f96482038ee 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -587,14 +587,14 @@ abstract class CommonObject public $date_cloture; // Date closing (tms field) /** - * @var User|int User author/creation - * @TODO Merge with user_creation + * @var User User author/creation + * @deprecated Store only id in user_creation_id */ public $user_author; /** - * @var User|int User author/creation - * @TODO Remove type id + * @var User User author/creation + * @deprecated */ public $user_creation; @@ -604,14 +604,14 @@ abstract class CommonObject public $user_creation_id; /** - * @var User|int User of validation - * @TODO Merge with user_validation + * @var User User of validation + * @deprecated */ public $user_valid; /** - * @var User|int User of validation - * @TODO Remove type id + * @var User User of validation + * @deprecated */ public $user_validation; @@ -626,8 +626,8 @@ abstract class CommonObject public $user_closing_id; /** - * @var User|int User last modifier - * @TODO Remove type id + * @var User User last modifier + * @deprecated */ public $user_modification; diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index 1e4bd60e988..197c7e27693 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -446,7 +446,9 @@ class Fiscalyear extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + $this->user_creation_id = $obj->fk_user_author; $this->user_modification_id = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->datec); diff --git a/htdocs/core/class/timespent.class.php b/htdocs/core/class/timespent.class.php index aca6c3237f1..6455459ce24 100644 --- a/htdocs/core/class/timespent.class.php +++ b/htdocs/core/class/timespent.class.php @@ -902,14 +902,8 @@ class TimeSpent extends CommonObject $this->user_creation_id = $obj->fk_user_creat; $this->user_modification_id = $obj->fk_user_modif; - if (!empty($obj->fk_user_valid)) { - $this->user_validation_id = $obj->fk_user_valid; - } $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem); - if (!empty($obj->datev)) { - $this->date_validation = empty($obj->datev) ? '' : $this->db->jdate($obj->datev); - } } $this->db->free($result); diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 4d5f8d2d8fa..ab7ed7aa526 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -259,7 +259,7 @@ function dol_print_object_info($object, $usetable = 0) } } else { $userstatic = new User($db); - $userstatic->fetch($object->user_creation_id ? $object->user_creation_id : $object->user_creation); + $userstatic->fetch($object->user_creation_id); if ($userstatic->id) { print $userstatic->getNomUrl(-1, '', 0, 0, 0); } else { @@ -314,7 +314,7 @@ function dol_print_object_info($object, $usetable = 0) } } else { $userstatic = new User($db); - $userstatic->fetch($object->user_modification_id ? $object->user_modification_id : $object->user_modification); + $userstatic->fetch($object->user_modification_id); if ($userstatic->id) { print $userstatic->getNomUrl(-1, '', 0, 0, 0); } else { diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 80402a83d33..4b1c4b9c5f1 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1113,6 +1113,7 @@ class Cronjob extends CommonObject if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); + $this->id = $obj->rowid; $this->user_modification_id = $obj->fk_user_mod; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index f241a7ef5b5..a34f94a4a9c 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -681,6 +681,7 @@ class EmailCollector extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/emailcollector/class/emailcollectoraction.class.php b/htdocs/emailcollector/class/emailcollectoraction.class.php index 07aea7feda8..6257a35976c 100644 --- a/htdocs/emailcollector/class/emailcollectoraction.class.php +++ b/htdocs/emailcollector/class/emailcollectoraction.class.php @@ -432,6 +432,7 @@ class EmailCollectorAction extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php index 0bdb0294a27..32818cafe3f 100644 --- a/htdocs/emailcollector/class/emailcollectorfilter.class.php +++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php @@ -446,6 +446,7 @@ class EmailCollectorFilter extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index e80dbb2476d..4ec158bdaf8 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -720,6 +720,7 @@ class ConferenceOrBooth extends ActionComm if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index 1a143b5cfd7..25b471d6e92 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -950,6 +950,7 @@ class ConferenceOrBoothAttendee extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index bb89bdb0788..10dc3c10664 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -844,28 +844,11 @@ class ExpenseReport extends CommonObject $this->date_validation = $this->db->jdate($obj->datev); $this->date_approbation = $this->db->jdate($obj->datea); - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - - if ($obj->fk_user_creation) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_creation); - $this->user_creation = $cuser; - } - if ($obj->fk_user_valid) { - $this->user_validation_id = $obj->fk_user_valid; - } - if ($obj->fk_user_modification) { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_modification); - $this->user_modification = $muser; - } - if ($obj->fk_user_approve) { - $auser = new User($this->db); - $auser->fetch($obj->fk_user_approve); - $this->user_approve = $auser; - } + $this->user_creation_id = $obj->fk_user_author; + $this->user_creation_id = $obj->fk_user_creation; + $this->user_validation_id = $obj->fk_user_valid; + $this->user_modification_id = $obj->fk_user_modification; + $this->user_approve_id = $obj->fk_user_approve; } $this->db->free($resql); } else { diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index c0f2eb79355..cf1c20901bd 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -693,17 +693,11 @@ class PaymentExpenseReport extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; - if ($obj->fk_user_creat) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_creat); - $this->user_creation = $cuser; - } - if ($obj->fk_user_modif) { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_modif); - $this->user_modification = $muser; - } + + $this->user_creation_id = $obj->fk_user_creat; + $this->user_modification_id = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->tms); } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index f150aa5b6d8..83b2b5d0173 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -479,7 +479,7 @@ class Fichinter extends CommonObject $this->fk_contrat = $obj->fk_contrat; $this->entity = $obj->entity; - $this->user_creation = $obj->fk_user_author; + $this->user_creation_id = $obj->fk_user_author; $this->extraparams = (array) json_decode($obj->extraparams, true); @@ -726,12 +726,10 @@ class Fichinter extends CommonObject */ public function getAmount() { - global $db; - $amount = 0; - $this->author = new User($db); - $this->author->fetch($this->user_creation); + $this->author = new User($this->db); + $this->author->fetch($this->user_creation_id); $thm = $this->author->thm; @@ -1017,18 +1015,9 @@ class Fichinter extends CommonObject $this->date_modification = $this->db->jdate($obj->date_modification); $this->date_validation = $this->db->jdate($obj->datev); - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - - if ($obj->fk_user_valid) { - $this->user_validation_id = $obj->fk_user_valid; - } - if ($obj->fk_user_modification) { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_modification); - $this->user_modification = $muser; - } + $this->user_creation_id = $obj->fk_user_author; + $this->user_validation_id = $obj->fk_user_valid; + $this->user_modification_id = $obj->fk_user_modification; } $this->db->free($resql); } else { diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 421c2ba4b44..a5bbb991e9a 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3094,22 +3094,14 @@ class CommandeFournisseur extends CommonOrder if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; - if ($obj->fk_user_author) { - $this->user_creation_id = $obj->fk_user_author; - } - if ($obj->fk_user_valid) { - $this->user_validation_id = $obj->fk_user_valid; - } - if ($obj->fk_user_modif) { - $this->user_modification_id = $obj->fk_user_modif; - } - if ($obj->fk_user_approve) { - $this->user_approve_id = $obj->fk_user_approve; - } - if ($obj->fk_user_approve2) { - $this->user_approve_id2 = $obj->fk_user_approve2; - } + + $this->user_creation_id = $obj->fk_user_author; + $this->user_validation_id = $obj->fk_user_valid; + $this->user_modification_id = $obj->fk_user_modif; + $this->user_approve_id = $obj->fk_user_approve; + $this->user_approve_id2 = $obj->fk_user_approve2; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->datem); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 612cc440fd0..ec0cd58f01d 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2540,19 +2540,10 @@ class FactureFournisseur extends CommonInvoice $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } - if ($obj->fk_user_valid) { - $this->user_validation_id = $obj->fk_user_valid; - } - if ($obj->fk_user_modif) { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_modif); - $this->user_modification = $muser; - } + + $this->user_creation_id = $obj->fk_user_author; + $this->user_validation_id = $obj->fk_user_valid; + $this->user_modification_id = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->datem); //$this->date_validation = $obj->datev; // This field is not available. Should be store into log table and using this function should be replaced with showing content of log (like for supplier orders) diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index fb36ef6bb9d..f587bc6e8f2 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -519,7 +519,7 @@ class PaiementFourn extends Paiement */ public function info($id) { - $sql = 'SELECT c.rowid, datec, fk_user_author as fk_user_creat, tms'; + $sql = 'SELECT c.rowid, datec, fk_user_author as fk_user_creat, tms as fk_user_modif'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as c'; $sql .= ' WHERE c.rowid = '.((int) $id); @@ -528,18 +528,10 @@ class PaiementFourn extends Paiement $num = $this->db->num_rows($resql); if ($num) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - if ($obj->fk_user_creat) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_creat); - $this->user_creation = $cuser; - } - if ($obj->fk_user_modif) { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_modif); - $this->user_modification = $muser; - } + $this->id = $obj->rowid; + $this->user_creation_id = $obj->fk_user_creat; + $this->user_modification_id = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->tms); } diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index d9b14a6f0f5..0b4da0052b8 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -2299,19 +2299,9 @@ class Holiday extends CommonObject $this->date_validation = $this->db->jdate($obj->datev); $this->date_approval = $this->db->jdate($obj->datea); - if (!empty($obj->fk_user_creation)) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_creation); - $this->user_creation = $cuser; - } - if (!empty($obj->fk_user_valid)) { - $this->user_validation_id = $obj->fk_user_valid; - } - if (!empty($obj->fk_user_modification)) { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_modification); - $this->user_modification = $muser; - } + $this->user_creation_id = $obj->fk_user_creation; + $this->user_validation_id = $obj->fk_user_valid; + $this->user_modification_id = $obj->fk_user_modification; if ($obj->status == Holiday::STATUS_APPROVED || $obj->status == Holiday::STATUS_CANCELED) { if ($obj->fk_user_approval_done) { diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index 0c70b3b5014..474af220461 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -408,6 +408,7 @@ class Establishment extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_author; diff --git a/htdocs/hrm/class/evaluation.class.php b/htdocs/hrm/class/evaluation.class.php index fea6f43be08..f8dd2d0e0f7 100644 --- a/htdocs/hrm/class/evaluation.class.php +++ b/htdocs/hrm/class/evaluation.class.php @@ -875,6 +875,7 @@ class Evaluation extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/hrm/class/evaluationdet.class.php b/htdocs/hrm/class/evaluationdet.class.php index ebeab0af4f6..6adb8602f57 100644 --- a/htdocs/hrm/class/evaluationdet.class.php +++ b/htdocs/hrm/class/evaluationdet.class.php @@ -849,6 +849,7 @@ class EvaluationLine extends CommonObjectLine if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/hrm/class/job.class.php b/htdocs/hrm/class/job.class.php index 129daac3c8b..7a5417ee435 100644 --- a/htdocs/hrm/class/job.class.php +++ b/htdocs/hrm/class/job.class.php @@ -885,6 +885,7 @@ class Job extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index d6384e05bad..56715d4dde8 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -933,6 +933,7 @@ class Position extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index 4568aac5017..15ac783b6c0 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -929,6 +929,7 @@ class Skill extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/hrm/class/skilldet.class.php b/htdocs/hrm/class/skilldet.class.php index 9f19bbf7459..ec1a007bd07 100644 --- a/htdocs/hrm/class/skilldet.class.php +++ b/htdocs/hrm/class/skilldet.class.php @@ -837,6 +837,7 @@ class Skilldet extends CommonObjectLine if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/hrm/class/skillrank.class.php b/htdocs/hrm/class/skillrank.class.php index 384a95ac1a0..5e1f480ff95 100644 --- a/htdocs/hrm/class/skillrank.class.php +++ b/htdocs/hrm/class/skillrank.class.php @@ -876,6 +876,7 @@ class SkillRank extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/knowledgemanagement/class/knowledgerecord.class.php b/htdocs/knowledgemanagement/class/knowledgerecord.class.php index 8d12fa7fd50..5f25311f558 100644 --- a/htdocs/knowledgemanagement/class/knowledgerecord.class.php +++ b/htdocs/knowledgemanagement/class/knowledgerecord.class.php @@ -930,6 +930,7 @@ class KnowledgeRecord extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 92af439b823..a12d9a1b936 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -683,6 +683,7 @@ class Loan extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_author; diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 90ce81b991d..8201a34c5f7 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -1011,8 +1011,19 @@ class MyObject extends CommonObject public function info($id) { $sql = "SELECT rowid,"; - $sql .= " date_creation as datec, tms as datem,"; - $sql .= " fk_user_creat, fk_user_modif"; + $sql .= " date_creation as datec, tms as datem"; + if (!empty($this->fields['date_validation'])) { + $sql .= ", date_validation as datev"; + } + if (!empty($this->fields['fk_user_creat'])) { + $sql .= ", fk_user_creat"; + } + if (!empty($this->fields['fk_user_modif'])) { + $sql .= ", fk_user_modif"; + } + if (!empty($this->fields['fk_user_valid'])) { + $sql .= ", fk_user_valid"; + } $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; $sql .= " WHERE t.rowid = ".((int) $id); @@ -1023,9 +1034,13 @@ class MyObject extends CommonObject $this->id = $obj->rowid; - $this->user_creation_id = $obj->fk_user_creat; - $this->user_modification_id = $obj->fk_user_modif; - if (!empty($obj->fk_user_valid)) { + if (!empty($this->fields['fk_user_creat'])) { + $this->user_creation_id = $obj->fk_user_creat; + } + if (!empty($this->fields['fk_user_modif'])) { + $this->user_modification_id = $obj->fk_user_modif; + } + if (!empty($this->fields['fk_user_valid'])) { $this->user_validation_id = $obj->fk_user_valid; } $this->date_creation = $this->db->jdate($obj->datec); diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 9502e51edaf..e000b498589 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1524,6 +1524,7 @@ class Mo extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 080184b46f8..0ec7e97ad87 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -1111,6 +1111,7 @@ class Partnership extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/partnership/class/partnership_type.class.php b/htdocs/partnership/class/partnership_type.class.php index b6d0f3dec70..9cdae65786e 100644 --- a/htdocs/partnership/class/partnership_type.class.php +++ b/htdocs/partnership/class/partnership_type.class.php @@ -396,6 +396,7 @@ class PartnershipType extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index fb4ed5a2e45..c156b44bc08 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -6412,20 +6412,11 @@ class Product extends CommonObject $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - - if ($obj->fk_user_author) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } - - if ($obj->fk_user_modif) { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_modif); - $this->user_modification = $muser; - } - $this->ref = $obj->ref; + + $this->user_creation_id = $obj->fk_user_author; + $this->user_modification_id = $obj->fk_user_modif; + $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_modification = $this->db->jdate($obj->date_modification); } diff --git a/htdocs/product/class/productfournisseurprice.class.php b/htdocs/product/class/productfournisseurprice.class.php index 6dd911abe33..c27ad0ceb1c 100644 --- a/htdocs/product/class/productfournisseurprice.class.php +++ b/htdocs/product/class/productfournisseurprice.class.php @@ -711,24 +711,14 @@ class ProductFournisseurPrice extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; - if ($obj->fk_user_author) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } - if ($obj->fk_user_valid) { - $this->user_validation_id = $obj->fk_user_valid; - } - - if ($obj->fk_user_cloture) { - $this->user_closing_id = $obj->fk_user_cloture; - } + $this->user_creation_id = $obj->fk_user_author; + $this->user_validation_id = $obj->fk_user_valid; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->datem); - $this->date_validation = $this->db->jdate($obj->datev); } $this->db->free($result); diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index a8730651621..56c2e3bb0d7 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -721,21 +721,9 @@ class Inventory extends CommonObject $this->id = $obj->rowid; - if ($obj->fk_user_creat > 0) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_creat); - $this->user_creation = $cuser; - } - - if ($obj->fk_user_modif > 0) { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_modif); - $this->user_creation = $muser; - } - - if ($obj->fk_user_valid > 0) { - $this->user_validation_id = $obj->fk_user_valid; - } + $this->user_creation_id = $obj->fk_user_creat; + $this->user_modification_id = $obj->fk_user_modif; + $this->user_validation_id = $obj->fk_user_valid; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->datem); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 7a6cc794f02..1756289e2cd 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -2336,16 +2336,11 @@ class Project extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; - if ($obj->fk_user_author) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } - if (!empty($obj->fk_user_cloture)) { - $this->user_closing_id = $obj->fk_user_cloture; - } + $this->id = $obj->rowid; + + $this->user_creation_id = $obj->fk_user_author; + $this->user_closing_id = $obj->fk_user_cloture; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->datem); diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php index d172c5129ba..4e9e8f7007a 100644 --- a/htdocs/recruitment/class/recruitmentcandidature.class.php +++ b/htdocs/recruitment/class/recruitmentcandidature.class.php @@ -880,6 +880,7 @@ class RecruitmentCandidature extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index d81ba26973e..b828bf93255 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -947,6 +947,7 @@ class RecruitmentJobPosition extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index a521107310d..0d7c814dd1c 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -618,6 +618,7 @@ class Salary extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_author; diff --git a/htdocs/societe/class/companypaymentmode.class.php b/htdocs/societe/class/companypaymentmode.class.php index 6fc7f6d4e2e..691bd2c1270 100644 --- a/htdocs/societe/class/companypaymentmode.class.php +++ b/htdocs/societe/class/companypaymentmode.class.php @@ -540,6 +540,7 @@ class CompanyPaymentMode extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 0a415146b21..3bca12e7e31 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -553,6 +553,7 @@ class Societe extends CommonObject /** * User that made last update * @var User + * @deprecated */ public $user_modification; @@ -565,6 +566,7 @@ class Societe extends CommonObject /** * User that created the thirdparty * @var User + * @deprecated */ public $user_creation; @@ -1890,8 +1892,8 @@ class Societe extends CommonObject $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_modification = $this->db->jdate($obj->date_modification); - $this->user_creation = $obj->fk_user_creat; - $this->user_modification = $obj->fk_user_modif; + $this->user_creation_id = $obj->fk_user_creat; + $this->user_modification_id = $obj->fk_user_modif; $this->address = $obj->address; $this->zip = $obj->zip; diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index fc06383ea01..5d94c0c78c7 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -572,7 +572,6 @@ class SocieteAccount extends CommonObject $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - $this->user_creation_id = $obj->fk_user_creat; $this->user_modification_id = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->datec); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 8e85a0b7122..a817f992898 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2113,17 +2113,9 @@ class SupplierProposal extends CommonObject $this->date_validation = $this->db->jdate($obj->datev); $this->date_cloture = $this->db->jdate($obj->dateo); - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - - if ($obj->fk_user_valid) { - $this->user_validation_id = $obj->fk_user_valid; - } - - if ($obj->fk_user_cloture) { - $this->user_closing_id = $obj->fk_user_cloture; - } + $this->user_creation_id = $obj->fk_user_author; + $this->user_validation_id = $obj->fk_user_valid; + $this->user_closing_id = $obj->fk_user_cloture; } $this->db->free($result); } else { diff --git a/htdocs/ticket/class/cticketcategory.class.php b/htdocs/ticket/class/cticketcategory.class.php index 38a4214f2b6..9aefaa1950a 100644 --- a/htdocs/ticket/class/cticketcategory.class.php +++ b/htdocs/ticket/class/cticketcategory.class.php @@ -623,8 +623,8 @@ class CTicketCategory extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; $this->user_modification_id = $obj->fk_user_modif; diff --git a/htdocs/webhook/class/target.class.php b/htdocs/webhook/class/target.class.php index 1eeade02d17..2fc10140883 100644 --- a/htdocs/webhook/class/target.class.php +++ b/htdocs/webhook/class/target.class.php @@ -867,8 +867,8 @@ class Target extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; $this->user_modification_id = $obj->fk_user_modif; diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index 4167ad5c785..d9651daa720 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -352,11 +352,11 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '', $bar 'supplier' => $thirdparty->fournisseur, 'customer_code' => $thirdparty->code_client, 'supplier_code' => $thirdparty->code_fournisseur, - 'customer_code_accountancy' => $thirdparty->code_compta, + 'customer_code_accountancy' => $thirdparty->code_compta_client, 'supplier_code_accountancy' => $thirdparty->code_compta_fournisseur, - 'user_creation' => $thirdparty->user_creation, + 'user_creation_id' => $thirdparty->user_creation_id, 'date_creation' => dol_print_date($thirdparty->date_creation, 'dayhourrfc'), - 'user_modification' => $thirdparty->user_modification, + 'user_modification_id' => $thirdparty->user_modification_id, 'date_modification' => dol_print_date($thirdparty->date_modification, 'dayhourrfc'), 'address' => $thirdparty->address, 'zip' => $thirdparty->zip, diff --git a/htdocs/workstation/class/workstation.class.php b/htdocs/workstation/class/workstation.class.php index 5e1a9d6df1e..f02cbfae23b 100644 --- a/htdocs/workstation/class/workstation.class.php +++ b/htdocs/workstation/class/workstation.class.php @@ -752,6 +752,7 @@ class Workstation extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat; diff --git a/htdocs/zapier/class/hook.class.php b/htdocs/zapier/class/hook.class.php index d027cfb3710..f957d0acc0f 100644 --- a/htdocs/zapier/class/hook.class.php +++ b/htdocs/zapier/class/hook.class.php @@ -634,6 +634,7 @@ class Hook extends CommonObject if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; $this->user_creation_id = $obj->fk_user_creat;