diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index a7d946f5ec7..f8b3215e083 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2014-2017 Olivier Geffroy * Copyright (C) 2015-2022 Alexandre Spangaro * Copyright (C) 2015-2020 Florian Henry - * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify @@ -1723,7 +1723,7 @@ class BookKeeping extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -1753,6 +1753,8 @@ class BookKeeping extends CommonObject $this->journal_label = 'Journal de vente'; $this->piece_num = 1234; $this->date_creation = $now; + + return 1; } /** diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index b0a9d88eaef..44f51ff9aca 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2016 Charlie Benke * Copyright (C) 2018-2019 Thibault Foucart * Copyright (C) 2021 Waël Almoman + * Copyright (C) 2024 Frédéric France * * 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 @@ -883,7 +884,7 @@ class AdherentType extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -907,6 +908,8 @@ class AdherentType extends CommonObject $this->members = array( $user->id => $user ); + + return 1; } /** diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 38da4658d25..4b468a5633c 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2018 Alexandre Spangaro + * Copyright (C) 2024 Frédéric France * * 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 @@ -1508,7 +1509,7 @@ class Asset extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -1516,7 +1517,7 @@ class Asset extends CommonObject // $this->property1 = ... // $this->property2 = ... - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/asset/class/assetmodel.class.php b/htdocs/asset/class/assetmodel.class.php index 0694ae75fd6..12132d4b65a 100644 --- a/htdocs/asset/class/assetmodel.class.php +++ b/htdocs/asset/class/assetmodel.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2021 Open-Dsi + * Copyright (C) 2024 Frédéric France * * 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 @@ -774,7 +775,7 @@ class AssetModel extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -782,7 +783,7 @@ class AssetModel extends CommonObject // $this->property1 = ... // $this->property2 = ... - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index 6f1e8b31ced..f551600797a 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -438,7 +438,7 @@ class Boms extends DolibarrApi * * @url DELETE {id}/lines/{lineid} * - * @return int + * @return array * * @throws RestException 403 Access denied * @throws RestException 404 BOM not found @@ -473,7 +473,12 @@ class Boms extends DolibarrApi $updateRes = $this->bom->deleteLine(DolibarrApiAccess::$user, $lineid); if ($updateRes > 0) { - return $this->get($id); + return array( + 'success' => array( + 'code' => 200, + 'message' => 'line ' .$lineid. ' deleted' + ) + ); } else { throw new RestException(500, $this->bom->error); } diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index e36415b4077..ba88dfff476 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2019 Laurent Destailleur * Copyright (C) 2023 Benjamin Falière * Copyright (C) 2023 Charlene Benke + * Copyright (C) 2024 Frédéric France * * 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 @@ -1368,13 +1369,15 @@ class BOM extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { $this->initAsSpecimenCommon(); $this->ref = 'BOM-123'; $this->date_creation = dol_now() - 20000; + + return 1; } @@ -2128,10 +2131,10 @@ class BOMLine extends CommonObjectLine * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } } diff --git a/htdocs/bookcal/class/availabilities.class.php b/htdocs/bookcal/class/availabilities.class.php index 5e9ffe56f5c..a839ae3e52c 100644 --- a/htdocs/bookcal/class/availabilities.class.php +++ b/htdocs/bookcal/class/availabilities.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2022 Alice Adminson + * Copyright (C) 2024 Frédéric France * * 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 @@ -926,7 +927,7 @@ class Availabilities extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -934,7 +935,7 @@ class Availabilities extends CommonObject // $this->property1 = ... // $this->property2 = ... - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/bookcal/class/calendar.class.php b/htdocs/bookcal/class/calendar.class.php index 5f7352bd493..eec383501db 100644 --- a/htdocs/bookcal/class/calendar.class.php +++ b/htdocs/bookcal/class/calendar.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2023 Frédéric France + * Copyright (C) 2023-2024 Frédéric France * Copyright (C) 2023 Alice Adminson * * This program is free software; you can redistribute it and/or modify @@ -915,7 +915,7 @@ class Calendar extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -923,7 +923,7 @@ class Calendar extends CommonObject // $this->property1 = ... // $this->property2 = ... - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index b16a0608680..1f901d7381e 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -2078,7 +2078,7 @@ class Categorie extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -2092,6 +2092,8 @@ class Categorie extends CommonObject $this->description = 'This is a description'; $this->socid = 1; $this->type = self::TYPE_PRODUCT; + + return 1; } /** diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php index 81d6249eaad..4880e42300d 100644 --- a/htdocs/comm/action/class/actioncommreminder.class.php +++ b/htdocs/comm/action/class/actioncommreminder.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -264,10 +265,10 @@ class ActionCommReminder extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index f7c25ae4545..39c01663d93 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -13,7 +13,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2022 ATM Consulting * Copyright (C) 2022 OpenDSI @@ -3598,7 +3598,7 @@ class Propal extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -3683,6 +3683,8 @@ class Propal extends CommonObject $xnbp++; } + + return 1; } /** diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index e7f81eb8af5..d89d3b39dfb 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -11,7 +11,7 @@ * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2016-2022 Ferran Marcet - * Copyright (C) 2021-2023 Frédéric France + * Copyright (C) 2021-2024 Frédéric France * Copyright (C) 2022 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify @@ -3972,7 +3972,7 @@ class Commande extends CommonOrder * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -4056,6 +4056,8 @@ class Commande extends CommonOrder $xnbp++; } + + return 1; } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index d6568fb9855..980139ac752 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2015-2017 Alexandre Spangaro * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2019 JC Prieto - * Copyright (C) 2022-2023 Frédéric France + * Copyright (C) 2022-2024 Frédéric France * * 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 @@ -1851,7 +1851,7 @@ class Account extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -1876,6 +1876,8 @@ class Account extends CommonObject $this->owner_town = 'Owner town'; $this->owner_country_id = 'Owner country_id'; $this->country_id = 1; + + return 1; } /** diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php index ad9d08b9fbc..ae96f872ce9 100644 --- a/htdocs/compta/bank/class/bankcateg.class.php +++ b/htdocs/compta/bank/class/bankcateg.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2008 Laurent Destailleur * Copyright (C) 2009 Regis Houssin * Copyright (C) 2016 Marcos García + * Copyright (C) 2024 Frédéric France * * 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 @@ -354,11 +355,13 @@ class BankCateg // extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { $this->id = 0; $this->label = ''; + + return 1; } } diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 81f5e8e6320..33ac0d8f817 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2018-2023 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * * 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 @@ -402,7 +402,7 @@ class PaymentVarious extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -419,6 +419,8 @@ class PaymentVarious extends CommonObject $this->fk_bank = 0; $this->fk_user_author = 0; $this->fk_user_modif = 0; + + return 1; } /** diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index af115c3aab2..ef52e74f6c8 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1494,9 +1494,9 @@ class Invoices extends DolibarrApi // Creation of payment line $paymentobj = new Paiement($this->db); - $paymentobj->datepaye = $datepaye; - $paymentobj->amounts = $amounts; - $paymentobj->multicurrency_amounts = $multicurrency_amounts; + $paymentobj->datepaye = dol_stringtotime($datepaye); + $paymentobj->amounts = $amounts; // Array with all payments dispatching with invoice id + $paymentobj->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paymentobj->paiementid = $paymentid; $paymentobj->paiementcode = (string) dol_getIdFromCode($this->db, $paymentid, 'c_paiement', 'id', 'code', 1); $paymentobj->num_payment = $num_payment; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 14e090339bb..50317b0ece3 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2013 Florian Henry * Copyright (C) 2015 Marcos García - * Copyright (C) 2017-2023 Frédéric France + * Copyright (C) 2017-2024 Frédéric France * Copyright (C) 2023 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify @@ -1710,7 +1710,7 @@ class FactureRec extends CommonInvoice * id must be 0 if object instance is a specimen. * * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines - * @return void + * @return int */ public function initAsSpecimen($option = '') { @@ -1830,6 +1830,8 @@ class FactureRec extends CommonInvoice } $this->usenewprice = 0; + + return 1; } /** diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index fc0ff165cd2..3f12e4e045f 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -21,6 +21,7 @@ * Copyright (C) 2023 Gauthier VERDOL * Copyright (C) 2023 Nick Fragoulis * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * 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 @@ -4996,7 +4997,7 @@ class Facture extends CommonInvoice * id must be 0 if object instance is a specimen. * * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines - * @return void + * @return int */ public function initAsSpecimen($option = '') { @@ -5145,6 +5146,8 @@ class Facture extends CommonInvoice $this->lines[$xnbp] = $line; $xnbp++; } + + return 1; } /** diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index 5d665921bc9..f23c8131d9f 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -432,7 +433,7 @@ class PaymentTerm // extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -446,5 +447,7 @@ class PaymentTerm // extends CommonObject $this->type_cdr = ''; $this->nbjour = ''; $this->decalage = ''; + + return 1; } } diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index ffc1c3314fb..579890f9b38 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -320,7 +321,7 @@ class Localtax extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -338,6 +339,8 @@ class Localtax extends CommonObject $this->fk_bank = 0; $this->fk_user_creat = $user->id; $this->fk_user_modif = $user->id; + + return 1; } diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index a659a0b460a..2be5b322d69 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2011-2016 Juanjo Menent * Copyright (C) 2015 Marcos García + * Copyright (C) 2024 Frédéric France * * 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 @@ -872,7 +873,7 @@ class RemiseCheque extends CommonObject * id must be 0 if object instance is a specimen. * * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines - * @return void + * @return int */ public function initAsSpecimen($option = '') { @@ -887,6 +888,8 @@ class RemiseCheque extends CommonObject $this->ref = 'SPECIMEN'; $this->specimen = 1; $this->date_bordereau = $nownotime; + + return 1; } /** diff --git a/htdocs/compta/paiement/class/cpaiement.class.php b/htdocs/compta/paiement/class/cpaiement.class.php index 8b77c745061..a8a49ca43d3 100644 --- a/htdocs/compta/paiement/class/cpaiement.class.php +++ b/htdocs/compta/paiement/class/cpaiement.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2023 Frédéric France + * Copyright (C) 2023-2024 Frédéric France * * 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 @@ -360,7 +360,7 @@ class Cpaiement extends CommonDict * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -372,5 +372,7 @@ class Cpaiement extends CommonDict $this->active = 1; $this->accountancy_code = ''; $this->module = ''; + + return 1; } } diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index b9fb85f148b..013c0fcebad 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -8,7 +8,7 @@ * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2018 Thibault FOUCART - * Copyright (C) 2018-2022 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2020 Andreu Bisquerra Gaya * Copyright (C) 2021 OpenDsi * Copyright (C) 2023 Joachim Kueter @@ -1258,7 +1258,7 @@ class Paiement extends CommonObject * id must be 0 if object instance is a specimen. * * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines - * @return void + * @return int */ public function initAsSpecimen($option = '') { @@ -1274,6 +1274,8 @@ class Paiement extends CommonObject $this->specimen = 1; $this->facid = 1; $this->datepaye = $nownotime; + + return 1; } diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index 287dda0dcb2..5141708f815 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2024 Frédéric France * * 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 @@ -514,7 +515,7 @@ class Cchargesociales * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -527,6 +528,8 @@ class Cchargesociales $this->fk_pays = 0; $this->module = ''; $this->accountancy_code = ''; + + return 1; } /** diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 066e007ad16..e81d5b80e5d 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur - * Copyright (C) 2016-2022 Frédéric France + * Copyright (C) 2016-2024 Frédéric France * Copyright (C) 2017 Alexandre Spangaro * Copyright (C) 2021 Gauthier VERDOL * @@ -737,7 +737,7 @@ class ChargeSociales extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -754,6 +754,8 @@ class ChargeSociales extends CommonObject $this->label = 'Social contribution label'; $this->type = 1; $this->type_label = 'Type of social contribution'; + + return 1; } /** diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 13844252901..2a724f56d42 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2002 Rodolphe Quiedeville * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2022 Alexandre Spangaro + * Copyright (C) 2024 Frédéric France * * 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 @@ -527,7 +528,7 @@ class PaymentSocialContribution extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -544,6 +545,8 @@ class PaymentSocialContribution extends CommonObject $this->fk_bank = 0; $this->fk_user_creat = 0; $this->fk_user_modif = 0; + + return 1; } diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index 0d2d82b0dd0..f45cc80e909 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2002 Rodolphe Quiedeville * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2024 Frédéric France * * 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 @@ -530,7 +531,7 @@ class PaymentVAT extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -547,6 +548,8 @@ class PaymentVAT extends CommonObject $this->fk_bank = 0; $this->fk_user_creat = 0; $this->fk_user_modif = 0; + + return 1; } diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 568fea68048..9b6081e6d7f 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2011-2017 Alexandre Spangaro * Copyright (C) 2018 Philippe Grand - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2021 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify @@ -413,7 +413,7 @@ class Tva extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -428,6 +428,8 @@ class Tva extends CommonObject $this->fk_bank = 0; $this->fk_user_creat = 0; $this->fk_user_modif = 0; + + return 1; } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 65cf34dcaeb..9b6752305a7 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -11,6 +11,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2020 Open-Dsi + * Copyright (C) 2024 Frédéric France * * 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 @@ -1683,6 +1684,7 @@ class Contact extends CommonObject $this->socid = $socid; $this->statut = 1; + return 1; } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 66f4aad8596..8139d7aa755 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018-2023 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2015-2018 Ferran Marcet * Copyright (C) 2024 William Mead * Copyright (C) 2024 MDW @@ -2442,7 +2442,7 @@ class Contrat extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -2507,6 +2507,8 @@ class Contrat extends CommonObject $this->lines[$xnbp] = $line; $xnbp++; } + + return 1; } /** diff --git a/htdocs/core/class/cgenericdic.class.php b/htdocs/core/class/cgenericdic.class.php index 7e163c56acb..9c617d9c78d 100644 --- a/htdocs/core/class/cgenericdic.class.php +++ b/htdocs/core/class/cgenericdic.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2014-2016 Juanjo Menent * Copyright (C) 2016 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2024 Frédéric France * * 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 @@ -471,7 +472,7 @@ class CGenericDic extends CommonDict * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -480,5 +481,7 @@ class CGenericDic extends CommonDict $this->code = 'CODE'; $this->label = 'Label'; $this->active = 1; + + return 1; } } diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index 717b7c43ec6..5d839fb0f26 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2014-2016 Juanjo Menent * Copyright (C) 2016 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2024 Frédéric France * * 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 @@ -425,7 +426,7 @@ class Ctyperesource extends CommonDict * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -434,6 +435,8 @@ class Ctyperesource extends CommonDict $this->code = ''; $this->label = ''; $this->active = 0; + + return 1; } } diff --git a/htdocs/core/class/defaultvalues.class.php b/htdocs/core/class/defaultvalues.class.php index acd56ec12a5..8389630123a 100644 --- a/htdocs/core/class/defaultvalues.class.php +++ b/htdocs/core/class/defaultvalues.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2021 Florian HENRY - * Copyright (C) 2021 Frédéric France + * Copyright (C) 2021-2024 Frédéric France * * 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 @@ -346,10 +346,10 @@ class DefaultValues extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } } diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 6f8157ca22c..bb597cb713b 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2024 Alexandre Janniaux + * Copyright (C) 2024 Frédéric France * * 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 @@ -731,7 +732,7 @@ class DiscountAbsolute extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -742,5 +743,7 @@ class DiscountAbsolute extends CommonObject $this->amount_ttc = 11.96; $this->tva_tx = 19.6; $this->description = 'Specimen discount'; + + return 1; } } diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index 2370ceaaad6..ec1eea0116c 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2024 Frédéric France * * 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 @@ -371,11 +372,11 @@ class EmailSenderProfile extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } } diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index 104a99d2f3d..a5dc47bb64c 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2019 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2023 William Mead + * Copyright (C) 2024 Frédéric France * * 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 @@ -305,7 +306,7 @@ class Events // extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -318,5 +319,7 @@ class Events // extends CommonObject $this->ip = '1.2.3.4'; $this->user_agent = 'Mozilla specimen User Agent X.Y'; $this->prefix_session = dol_getprefix(); + + return 1; } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 938333ef730..6c4a8bd4e55 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4904,7 +4904,7 @@ class Form * @param int $showcurrency Show currency in label * @param string $morecss More CSS * @param int $nooutput 1=Return string, do not send to output - * @return int Return integer <0 if error, Num of bank account found if OK (0, 1, 2, ...) + * @return int|string If noouput=0: Return integer <0 if error, Num of bank account found if OK (0, 1, 2, ...), If nooutput=1: Return a HTML select string. */ public function select_comptes($selected = '', $htmlname = 'accountid', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0, $morecss = '', $nooutput = 0) { diff --git a/htdocs/core/class/html.formintervention.class.php b/htdocs/core/class/html.formintervention.class.php index d6f7a8bf795..08587f3fad2 100644 --- a/htdocs/core/class/html.formintervention.class.php +++ b/htdocs/core/class/html.formintervention.class.php @@ -59,7 +59,7 @@ class FormIntervention * @param int $maxlength Maximum length of label * @param int $showempty Show empty line ('1' or string to show for empty line) * @param bool $draftonly Show only drafts intervention - * @return int Nbre of project if OK, <0 if KO + * @return string HTML code for the select list if OK, empty if KO */ public function select_interventions($socid = -1, $selected = 0, $htmlname = 'interventionid', $maxlength = 16, $showempty = 1, $draftonly = false) { diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index b86ee41f60f..ebda232e331 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2009-2012 Regis Houssin - * Copyright (C) 2018-2023 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * * 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 @@ -478,7 +478,7 @@ class Menubase * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -499,6 +499,8 @@ class Menubase $this->enabled = ''; $this->user = 0; $this->tms = dol_now(); + + return 1; } diff --git a/htdocs/core/class/timespent.class.php b/htdocs/core/class/timespent.class.php index 1c5868176c7..36cedd67896 100644 --- a/htdocs/core/class/timespent.class.php +++ b/htdocs/core/class/timespent.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2023 Frédéric France + * Copyright (C) 2023-2024 Frédéric France * Copyright (C) 2023 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify @@ -923,15 +923,15 @@ class TimeSpent extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - // Set here init that are not commonf fields + // Set here init that are not common fields // $this->property1 = ... // $this->property2 = ... - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d454e76bebd..ef6205953e4 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1685,7 +1685,7 @@ function dol_escape_json($stringtoescape) * Returns text escaped for inclusion into a php string, build with double quotes " or ' * * @param string $stringtoescape String to escape - * @param string $stringforquotes 2=String for doublequotes, 1=String for simple quotes + * @param int<1,2> $stringforquotes 2=String for doublequotes, 1=String for simple quotes * @return string Escaped string for json content. */ function dol_escape_php($stringtoescape, $stringforquotes = 2) @@ -1696,8 +1696,7 @@ function dol_escape_php($stringtoescape, $stringforquotes = 2) if ($stringforquotes == 2) { return str_replace('"', "'", $stringtoescape); - } - if ($stringforquotes == 1) { + } elseif ($stringforquotes == 1) { // We remove the \ char. // If we allow the \ char, we can have $stringtoescape = // abc\';phpcodedanger; so the escapement will become @@ -2905,10 +2904,10 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs /** * Format a string. * - * @param string $fmt Format of strftime function (http://php.net/manual/fr/function.strftime.php) - * @param int $ts Timestamp (If is_gmt is true, timestamp is already includes timezone and daylight saving offset, if is_gmt is false, timestamp is a GMT timestamp and we must compensate with server PHP TZ) - * @param bool $is_gmt See comment of timestamp parameter - * @return string A formatted string + * @param string $fmt Format of strftime function (http://php.net/manual/fr/function.strftime.php) + * @param int|false $ts Timestamp (If is_gmt is true, timestamp is already includes timezone and daylight saving offset, if is_gmt is false, timestamp is a GMT timestamp and we must compensate with server PHP TZ) + * @param bool $is_gmt See comment of timestamp parameter + * @return string A formatted string * @see dol_stringtotime() */ function dol_strftime($fmt, $ts = false, $is_gmt = false) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 47cfd7c081d..c8561fd1f11 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1547,6 +1547,7 @@ function get_left_menu_billing($mainmenu, &$newmenu, $usemenuhider = 1, $leftmen $newmenu->add("/don/card.php?leftmenu=donations&action=create", $langs->trans("NewDonation"), 1, $user->hasRight('don', 'creer')); $newmenu->add("/don/list.php?leftmenu=donations", $langs->trans("List"), 1, $user->hasRight('don', 'lire')); $newmenu->add("/don/paiement/list.php?leftmenu=donations", $langs->trans("Payments"), 1, $user->hasRight('don', 'lire')); + $newmenu->add("/don/stats/index.php", $langs->trans("Statistics"), 1, $user->hasRight('don', 'lire')); } // if ($leftmenu=="donations") $newmenu->add("/don/stats/index.php",$langs->trans("Statistics"), 1, $user->hasRight('don', 'lire')); } diff --git a/htdocs/core/modules/security/generate/modGeneratePassNone.class.php b/htdocs/core/modules/security/generate/modGeneratePassNone.class.php index d9688edfcd2..e5f1f77c00c 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassNone.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassNone.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -37,20 +38,6 @@ class modGeneratePassNone extends ModeleGenPassword public $picto = 'fa-keyboard'; - /** - * Minimum length (text visible by end user) - * - * @var int - */ - public $length; - - /** - * Minimum length in number of characters - * - * @var integer - */ - public $length2; - /** * Constructor * @@ -62,7 +49,7 @@ class modGeneratePassNone extends ModeleGenPassword public function __construct($db, $conf, $langs, $user) { $this->id = "none"; - $this->length = 0; + $this->length = '0'; $this->length2 = 0; $this->db = $db; diff --git a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php index e3769c66f78..a588e62eeef 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2006-2011 Laurent Destailleur * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> * Copyright (C) 2017 Regis Houssin + * Copyright (C) 2024 Frédéric France * * 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 @@ -39,20 +40,6 @@ class modGeneratePassPerso extends ModeleGenPassword public $picto = 'fa-shield-alt'; - /** - * Minimum length (text visible by end user) - * - * @var int - */ - public $length; - - /** - * Minimum length in number of characters - * - * @var integer - */ - public $length2; - public $NbMaj; public $NbNum; public $NbSpe; diff --git a/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php b/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php index 026ec34a852..53f40260dbc 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -37,20 +38,6 @@ class modGeneratePassStandard extends ModeleGenPassword public $picto = 'fa-shield-alt'; - /** - * Minimum length (text visible by end user) - * - * @var int - */ - public $length; - - /** - * Minimum length in number of characters - * - * @var integer - */ - public $length2; - /** * Constructor * @@ -62,7 +49,7 @@ class modGeneratePassStandard extends ModeleGenPassword public function __construct($db, $conf, $langs, $user) { $this->id = "standard"; - $this->length = 12; + $this->length = '12'; $this->length2 = 12; $this->db = $db; diff --git a/htdocs/core/modules/security/generate/modules_genpassword.php b/htdocs/core/modules/security/generate/modules_genpassword.php index ec17cac6e9b..a463f11b061 100644 --- a/htdocs/core/modules/security/generate/modules_genpassword.php +++ b/htdocs/core/modules/security/generate/modules_genpassword.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -63,6 +64,20 @@ abstract class ModeleGenPassword */ public $user; + /** + * Minimum length (text visible by end user) + * + * @var string + */ + public $length; + + /** + * Minimum length in number of characters + * + * @var integer + */ + public $length2; + /** * Return if a module can be used or not * diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 9644153c2e4..eea29c83601 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2022 Laurent Destailleur * Copyright (C) 2013 Florian Henry * Copyright (C) 2023-2024 William Mead + * Copyright (C) 2024 Frédéric France * * 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 @@ -934,7 +935,7 @@ class Cronjob extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -972,6 +973,8 @@ class Cronjob extends CommonObject $this->nbrun = 0; $this->maxrun = 100; $this->libname = ''; + + return 1; } diff --git a/htdocs/datapolicy/class/datapolicycron.class.php b/htdocs/datapolicy/class/datapolicycron.class.php index 3dc187455fb..d83e4534acd 100644 --- a/htdocs/datapolicy/class/datapolicycron.class.php +++ b/htdocs/datapolicy/class/datapolicycron.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2018-2023 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2024 William Mead * * This program is free software: you can redistribute it and/or modify @@ -486,7 +486,7 @@ class DataPolicyCron if ($object->isObjectUsed($obj->rowid) == 0) { // If object to clean is used foreach ($params['fields_anonym'] as $field => $val) { if ($val == 'MAKEANONYMOUS') { - $object->$field = $field.'-anonymous-'.$obj->rowid; + $object->$field = $field.'-anonymous-'.$obj->rowid; // @phpstan-ignore-line } else { $object->$field = $val; } diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index a5017547c34..6e634bfb669 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -965,7 +965,7 @@ class Delivery extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -1012,6 +1012,8 @@ class Delivery extends CommonObject $line->total_ht = 100; $this->lines[$i] = $line; + + return 1; } /** diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 19cc0ed8dee..dbdd5caf745 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2015-2017 Alexandre Spangaro * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2019 Thibault FOUCART - * Copyright (C) 2019-2020 Frédéric France + * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2021 Maxime DEMAREST * * This program is free software; you can redistribute it and/or modify @@ -234,7 +234,7 @@ class Don extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -283,7 +283,9 @@ class Don extends CommonObject $this->email = 'email@email.com'; $this->phone = '0123456789'; $this->phone_mobile = '0606060606'; - $this->statut = 1; + $this->status = 1; + + return 1; } diff --git a/htdocs/don/class/donstats.class.php b/htdocs/don/class/donstats.class.php index a4b8043f5ae..1e8f9f09d47 100644 --- a/htdocs/don/class/donstats.class.php +++ b/htdocs/don/class/donstats.class.php @@ -28,7 +28,6 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - /** * Class to manage donations statistics */ @@ -57,6 +56,10 @@ class DonationStats extends Stats */ public $where; + /** + * @var string JOIN + */ + public $join; /** * Constructor @@ -65,8 +68,10 @@ class DonationStats extends Stats * @param int $socid Id third party for filter * @param string $mode Option (not used) * @param int $userid Id user for filter (creation user) + * @param int $typentid Id of type of third party for filter + * @param int $status Status of donation for filter */ - public function __construct($db, $socid, $mode, $userid = 0) + public function __construct($db, $socid, $mode, $userid = 0, $typentid = 0, $status = 4) { global $conf; @@ -76,17 +81,31 @@ class DonationStats extends Stats $this->socid = ($socid > 0 ? $socid : 0); $this->userid = $userid; $this->cachefilesuffix = $mode; + $this->join = ''; + + if ($status == 0 || $status == 1 || $status == 2) { + $this->where = ' d.fk_statut IN ('.$this->db->sanitize($status).')'; + } elseif ($status == 3) { + $this->where = ' d.fk_statut IN (-1)'; + } elseif ($status == 4) { + $this->where = ' d.fk_statut >= 0'; + } $object = new Don($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as d"; - //$this->from.= ", ".MAIN_DB_PREFIX."societe as s"; - //$this->field='weight'; // Warning, unit of weight is NOT USED AND MUST BE - $this->where .= " d.fk_statut > 0"; // Not draft and not cancelled - //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; + if ($socid !== "-1" && $socid > 0) { + $this->where .= " AND d.fk_soc = ".((int) $socid); + } + $this->where .= " AND d.entity = ".$conf->entity; if ($this->userid > 0) { - $this->where .= ' WHERE c.fk_user_author = '.((int) $this->userid); + $this->where .= ' AND d.fk_user_author = '.((int) $this->userid); + } + + if ($typentid) { + $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = d.fk_soc'; + $this->where .= ' AND s.fk_typent = '.((int) $typentid); } } @@ -101,13 +120,13 @@ class DonationStats extends Stats { $sql = "SELECT date_format(d.datedon,'%m') as dm, COUNT(*) as nb"; $sql .= " FROM ".$this->from; + $sql .= $this->join; $sql .= " WHERE d.datedon BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); - $res = $this->_getNbByMonth($year, $sql, $format); - return $res; + return $this->_getNbByMonth($year, $sql, $format); } /** @@ -120,6 +139,7 @@ class DonationStats extends Stats { $sql = "SELECT date_format(d.datedon,'%Y') as dm, COUNT(*) as nb, SUM(d.".$this->field.")"; $sql .= " FROM ".$this->from; + $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); @@ -138,6 +158,7 @@ class DonationStats extends Stats { $sql = "SELECT date_format(d.datedon,'%m') as dm, sum(d.".$this->field.")"; $sql .= " FROM ".$this->from; + $sql .= $this->join; $sql .= " WHERE ".dolSqlDateFilter('d.datedon', 0, 0, (int) $year, 1); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; @@ -156,6 +177,7 @@ class DonationStats extends Stats { $sql = "SELECT date_format(d.datedon,'%m') as dm, avg(d.".$this->field.")"; $sql .= " FROM ".$this->from; + $sql .= $this->join; $sql .= " WHERE ".dolSqlDateFilter('d.datedon', 0, 0, (int) $year, 1); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; @@ -173,6 +195,7 @@ class DonationStats extends Stats { $sql = "SELECT date_format(d.datedon,'%Y') as year, COUNT(*) as nb, SUM(d.".$this->field.") as total, AVG(".$this->field.") as avg"; $sql .= " FROM ".$this->from; + $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY year"; $sql .= $this->db->order('year', 'DESC'); diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index 6720301d326..3d5a1e9071f 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -540,7 +541,7 @@ class PaymentDonation extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -558,6 +559,8 @@ class PaymentDonation extends CommonObject $this->fk_bank = 0; $this->fk_user_creat = dol_now(); $this->fk_user_modif = dol_now(); + + return 1; } diff --git a/htdocs/don/stats/index.php b/htdocs/don/stats/index.php index 1629ac2e984..1bb4458c37e 100644 --- a/htdocs/don/stats/index.php +++ b/htdocs/don/stats/index.php @@ -29,10 +29,16 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/donstats.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +if (isModEnabled('category')) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +} $WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); +// Load translation files required by the page +$langs->loadLangs("donations"); + $userid = GETPOSTINT('userid'); $socid = GETPOSTINT('socid'); // Security check @@ -41,44 +47,44 @@ if ($user->socid > 0) { $socid = $user->socid; } +$status = GETPOSTINT('status'); $nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); +$typent_id = GETPOSTINT('typent_id'); $year = GETPOST('year') > 0 ? GETPOST('year') : $nowyear; -$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS')))); +$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalInt('MAIN_STATS_GRAPHS_SHOW_N_YEARS')))); $endyear = $year; - -// Load translation files required by the page -$langs->loadLangs(array("companies", "other", "sendings")); +$mode = GETPOST("mode") ? GETPOST("mode") : 'customer'; +$custcats = GETPOST('custcats', 'array'); // Security check $result = restrictedArea($user, 'don'); - /* * View */ - $form = new Form($db); -$title = $langs->trans("DonationsStatistics"); -llxHeader('', $title, '', '', 0, 0, '', '', '', 'mod-donation page-stats'); +$formcompany = new FormCompany($db); -print load_fiche_titre($langs->trans("DonationsStatistics"), $mesg); +llxHeader(); +$dir = $conf->don->dir_temp; + +print load_fiche_titre($langs->trans("DonationsStatistics"), '', 'donation'); dol_mkdir($dir); -$stats = new DonationStats($db, $socid, '', ($userid > 0 ? $userid : 0)); +$stats = new DonationStats($db, $socid, '', ($userid > 0 ? $userid : 0), ($typent_id > 0 ? $typent_id : 0), ($status > 0 ? $status : 4)); + +if (is_array($custcats) && !empty($custcats)) { + $stats->from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cat ON (d.fk_soc = cat.fk_soc)'; + $stats->where .= ' AND cat.fk_categorie IN ('.$db->sanitize(implode(',', $custcats)).')'; +} // Build graphic number of object $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); -//var_dump($data);exit; -// $data = array(array('Lib',val1,val2,val3),...) - -if (!$user->hasRight('societe', 'client', 'voir')) { - $filenamenb = $dir.'/donationnbinyear-'.$user->id.'-'.$year.'.png'; -} else { - $filenamenb = $dir.'/donationnbinyear-'.$year.'.png'; -} +$filenamenb = $dir."/salariesnbinyear-".$year.".png"; +$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=donationStats&file=donationinyear-'.$year.'.png'; $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); @@ -99,11 +105,67 @@ if (!$mesg) { $px1->SetShading(3); $px1->SetHorizTickIncrement(1); $px1->mode = 'depth'; - $px1->SetTitle($langs->trans("NumberOfDonationsByMonth")); + $px1->SetTitle($langs->trans("NumberByMonth")); $px1->draw($filenamenb, $fileurlnb); } +$data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear); + +$filenameamount = $dir."/donationamount-".$year.".png"; +$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=donationStats&file=donationamoutinyear-'.$year.'.png'; + +$px2 = new DolGraph(); +$mesg = $px2->isGraphKo(); +if (!$mesg) { + $px2->SetData($data); + $i=$startyear;$legend=array(); + while ($i <= $endyear) { + $legend[]=$i; + $i++; + } + $px2->SetLegend($legend); + $px2->SetMaxValue($px2->GetCeilMaxValue()); + $px2->SetMinValue(min(0, $px2->GetFloorMinValue())); + $px2->SetWidth($WIDTH); + $px2->SetHeight($HEIGHT); + $px2->SetYLabel($langs->trans("Amount")); + $px2->SetShading(3); + $px2->SetHorizTickIncrement(1); + $px2->mode='depth'; + $px2->SetTitle($langs->trans("AmountTotal")); + + $px2->draw($filenameamount, $fileurlamount); +} + +$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); + +$filename_avg = $dir."/donationaverage-".$year.".png"; +$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=donationStats&file=donationaverageinyear-'.$year.'.png'; + +$px3 = new DolGraph(); +$mesg = $px3->isGraphKo(); +if (!$mesg) { + $px3->SetData($data); + $i = $startyear; + $legend = array(); + while ($i <= $endyear) { + $legend[] = $i; + $i++; + } + $px3->SetLegend($legend); + $px3->SetYLabel($langs->trans("AmountAverage")); + $px3->SetMaxValue($px3->GetCeilMaxValue()); + $px3->SetMinValue($px3->GetFloorMinValue()); + $px3->SetWidth($WIDTH); + $px3->SetHeight($HEIGHT); + $px3->SetShading(3); + $px3->SetHorizTickIncrement(1); + $px3->mode = 'depth'; + $px3->SetTitle($langs->trans("AmountAverage")); + + $px3->draw($filename_avg, $fileurl_avg); +} // Show array $data = $stats->getAllByYear(); @@ -133,33 +195,62 @@ print dol_get_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1); print '
'; - // Show filter box print '
'; print ''; -print ''; +print '
'; print ''; + // Company -print ''; +} + +// ThirdParty Type +print ''; + +// Category +if (isModEnabled('category')) { + $cat_type = Categorie::TYPE_CUSTOMER; + $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer")); + print ''; +} + // User -print ''; + +// Status +print ''; print ''; print '
'.$langs->trans("Filter").'
'.$langs->trans("ThirdParty").''; -print img_picto('', 'company', 'class="pictofixedwidth"'); -print $form->select_company($socid, 'socid', '', 1, 0, 0, array(), 0, 'widthcentpercentminusx maxwidth300', ''); +if (empty(!$conf->global->DONATION_USE_THIRDPARTIES)) { + print '
'.$langs->trans("ThirdParty").''; + print img_picto('', 'company', 'class="pictofixedwidth"'); + print $form->select_company($socid, 'socid', '', 1, 0, 0, array(), 0, 'widthcentpercentminusx maxwidth300', ''); + print '
'.$langs->trans("ThirdPartyType").''; +$sortparam_typent = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); +print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 1, 0, 0, '', 0, 0, 0, $sortparam_typent, '', 1); +if ($user->admin) { + print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); +} print '
'.$cat_label.''; + $cate_arbo = $form->select_all_categories($cat_type, null, 'parent', null, null, 1); + print img_picto('', 'category', 'class="pictofixedwidth"'); + print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), 0, 0, 'widthcentpercentminusx maxwidth300'); + print '
'.$langs->trans("CreatedBy").''; +print '
'.$langs->trans("CreatedBy").''; print img_picto('', 'user', 'class="pictofixedwidth"'); print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300'); print '
'.$langs->trans("Status").''; +$liststatus = array( + '2' => $langs->trans("DonationStatusPaid"), + '0' => $langs->trans("DonationStatusPromiseNotValidated"), + '1' => $langs->trans("DonationStatusPromiseValidated"), + '3' => $langs->trans("Canceled") +); +print $form->selectarray('status', $liststatus, 4, 1); + // Year -print '
'.$langs->trans("Year").''; -if (!in_array($year, $arrayyears)) { - $arrayyears[$year] = $year; -} -if (!in_array($nowyear, $arrayyears)) { - $arrayyears[$nowyear] = $nowyear; -} +print '
'.$langs->trans("Year").''; arsort($arrayyears); print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); + print '
'; @@ -167,33 +258,46 @@ print '
'; print '

'; print '
'; -print ''; -print ''; +print '
'; +print ''; print ''; print ''; -/*print ''; -print '';*/ +print ''; +print ''; +print ''; +print ''; +print ''; print ''; $oldyear = 0; foreach ($data as $val) { $year = $val['year']; - while (!empty($year) && $oldyear > $year + 1) { // If we have empty year + while (!empty($year) && $oldyear > $year + 1) { $oldyear--; - print ''; + print ''; print ''; print ''; - /*print ''; - print '';*/ + print ''; + print ''; + print ''; + print ''; + print ''; print ''; } - print ''; - print ''; + $greennb = (empty($val['nb_diff']) || $val['nb_diff'] >= 0); + $greentotal = (empty($val['total_diff']) || $val['total_diff'] >= 0); + $greenavg = (empty($val['avg_diff']) || $val['avg_diff'] >= 0); + + print ''; + print ''; print ''; - /*print ''; - print '';*/ + print ''; + print ''; + print ''; + print ''; + print ''; print ''; $oldyear = $year; } @@ -201,10 +305,8 @@ foreach ($data as $val) { print '
'.$langs->trans("Year").''.$langs->trans("NbOfDonations").''.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").'%'.$langs->trans("AmountTotal").'%'.$langs->trans("AmountAverage").'%
'.$oldyear.'00000
'.$year.'
0 ? '&userid='.$userid : '').'">'.$year.''.$val['nb'].''.price(price2num($val['total'],'MT'),1).''.price(price2num($val['avg'],'MT'),1).''.(!empty($val['nb_diff']) && $val['nb_diff'] < 0 ? '' : '+').round(!empty($val['nb_diff']) ? $val['nb_diff'] : 0).'%'.price(price2num($val['total'], 'MT'), 1).''.( !empty($val['total_diff']) && $val['total_diff'] < 0 ? '' : '+').round(!empty($val['total_diff']) ? $val['total_diff'] : 0).'%'.price(price2num($val['avg'], 'MT'), 1).''.(!empty($val['avg_diff']) && $val['avg_diff'] < 0 ? '' : '+').round(!empty($val['avg_diff']) ? $val['avg_diff'] : 0).'%
'; print '
'; - print '
'; - // Show graphs print '
'; if ($mesg) { @@ -212,55 +314,16 @@ if ($mesg) { } else { print $px1->show(); print "
\n"; - /*print $px2->show(); + print $px2->show(); print "
\n"; - print $px3->show();*/ + print $px3->show(); } print '
'; - print '
'; print '
'; print dol_get_fiche_end(); - - -// TODO USe code similar to commande/stats/index.php instead of this one. -/* -print ''; -print ''; -print ''; - -$sql = "SELECT count(*) as nb, date_format(date_expedition,'%Y') as dm"; -$sql.= " FROM ".MAIN_DB_PREFIX."expedition"; -$sql.= " WHERE fk_statut > 0"; -$sql.= " AND entity = ".$conf->entity; -$sql.= " GROUP BY dm DESC"; - -$resql=$db->query($sql); -if ($resql) -{ - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $row = $db->fetch_row($resql); - $nbproduct = $row[0]; - $year = $row[1]; - print ""; - print ''; - $i++; - } -} -$db->free($resql); - -print '
'.$langs->trans("Year").''.$langs->trans("NbOfSendings").'
'.$year.''.$nbproduct.'
'; -*/ - -print '
'; -print ''.$langs->trans("StatsOnDonationsOnlyValidated").''; - llxFooter(); - $db->close(); diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 6e73b229858..905eabdb5c1 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2008-2012 Regis Houssin + * Copyright (C) 2024 Frédéric France * * 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 @@ -450,7 +451,7 @@ class EcmDirectory extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -459,6 +460,8 @@ class EcmDirectory extends CommonObject $this->label = 'MyDirectory'; $this->fk_parent = 0; $this->description = 'This is a directory'; + + return 1; } diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 5e1c0107cfa..ce77414b31b 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2018 Francis Appels - * Copyright (C) 2019-2024 Frédéric France + * Copyright (C) 2019-2024 Frédéric France * * 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 @@ -957,7 +957,7 @@ class EcmFiles extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -983,6 +983,8 @@ class EcmFiles extends CommonObject $this->acl = ''; $this->src_object_type = 'product'; $this->src_object_id = 1; + + return 1; } } diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 86672a0f225..bffa405796e 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -698,14 +699,14 @@ class EmailCollector extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { $this->host = 'localhost'; $this->login = 'alogin'; - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/emailcollector/class/emailcollectoraction.class.php b/htdocs/emailcollector/class/emailcollectoraction.class.php index 6a49ee7fa87..bdefd8a1f87 100644 --- a/htdocs/emailcollector/class/emailcollectoraction.class.php +++ b/htdocs/emailcollector/class/emailcollectoraction.class.php @@ -1,6 +1,7 @@ * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2024 Frédéric France * * 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 @@ -449,10 +450,10 @@ class EmailCollectorAction extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } } diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php index 6618633a6b3..52acc3440d7 100644 --- a/htdocs/emailcollector/class/emailcollectorfilter.class.php +++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php @@ -1,6 +1,7 @@ * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2024 Frédéric France * * 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 @@ -463,10 +464,10 @@ class EmailCollectorFilter extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } } diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index d71fc6b2a9f..69cfcbf7b23 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -1,6 +1,7 @@ * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2024 Frédéric France * * 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 @@ -749,11 +750,11 @@ class ConferenceOrBooth extends ActionComm * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index eecb06e137c..6df9bad4a72 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -1,6 +1,7 @@ * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2024 Frédéric France * * 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 @@ -946,11 +947,11 @@ class ConferenceOrBoothAttendee extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 70a7b3a6a2d..4704baf9bb3 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -11,7 +11,7 @@ * Copyright (C) 2015 Claudio Aschieri * Copyright (C) 2016-2022 Ferran Marcet * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018-2022 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2020 Lenin Rivas * * This program is free software; you can redistribute it and/or modify @@ -2003,7 +2003,7 @@ class Expedition extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -2055,6 +2055,8 @@ class Expedition extends CommonObject $this->lines[] = $line; $xnbp++; } + + return 1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2133,7 +2135,7 @@ class Expedition extends CommonObject * @param int $id only this carrier, all if none * @return void */ - public function list_delivery_methods($id = '') + public function list_delivery_methods($id = 0) { // phpcs:enable global $langs; @@ -2143,7 +2145,7 @@ class Expedition extends CommonObject $sql = "SELECT em.rowid, em.code, em.libelle as label, em.description, em.tracking, em.active"; $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; - if ($id != '') { + if (!empty($id)) { $sql .= " WHERE em.rowid=".((int) $id); } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 46b7706d4f6..38d86dc15c7 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2015 Laurent Destailleur * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (c) 2018-2023 Frédéric France + * Copyright (c) 2018-2024 Frédéric France * Copyright (C) 2016-2020 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -876,7 +876,7 @@ class ExpenseReport extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -898,7 +898,6 @@ class ExpenseReport extends CommonObject $type_fees_id = 2; // TF_TRIP $this->status = 5; - $this->fk_statut = 5; $this->fk_user_author = $user->id; $this->fk_user_validator = $user->id; @@ -932,6 +931,8 @@ class ExpenseReport extends CommonObject $this->total_tva += $line->total_tva; $this->total_ttc += $line->total_ttc; } + + return 1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index ca7da95f824..09ea23d79c1 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2018 Nicolas ZABOURI + * Copyright (C) 2024 Frédéric France * * 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 @@ -495,7 +496,7 @@ class PaymentExpenseReport extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -512,6 +513,8 @@ class PaymentExpenseReport extends CommonObject $this->fk_bank = 0; $this->fk_user_creat = 0; $this->fk_user_modif = 0; + + return 1; } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 6e8195ac3d9..0b29b094202 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2015-2020 Charlene Benke * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2023-2024 William Mead * * This program is free software; you can redistribute it and/or modify @@ -1401,7 +1401,7 @@ class Fichinter extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -1433,6 +1433,8 @@ class Fichinter extends CommonObject $this->duration += $line->duration; } + + return 1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index f81c1812b1c..9e529651f8a 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -8,6 +8,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2016-2018 Charlie Benke * Copyright (C) 2024 William Mead + * Copyright (C) 2024 Frédéric France * * 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 @@ -304,7 +305,7 @@ class FichinterRec extends Fichinter $obj = $this->db->fetch_object($result); $this->id = $rowid; - $this->title = $obj->title; + $this->title = $obj->title; $this->ref = $obj->title; $this->description = $obj->description; $this->datec = $obj->datec; @@ -674,7 +675,7 @@ class FichinterRec extends Fichinter * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -685,6 +686,8 @@ class FichinterRec extends Fichinter parent::initAsSpecimen(); $this->usenewprice = 1; + + return 1; } /** diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 7a3ecf3dae6..2e128bcd7ec 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018-2023 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2018-2022 Ferran Marcet * Copyright (C) 2021 Josep Lluís Amador * Copyright (C) 2022 Gauthier VERDOL @@ -3079,7 +3079,7 @@ class CommandeFournisseur extends CommonOrder * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -3156,6 +3156,8 @@ class CommandeFournisseur extends CommonOrder $xnbp++; } + + return 1; } /** diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index b8bc60a463d..2b415cfc936 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2024 Frédéric France * * 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 @@ -619,7 +620,7 @@ class CommandeFournisseurDispatch extends CommonObjectLine * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -638,6 +639,8 @@ class CommandeFournisseurDispatch extends CommonObjectLine $this->batch = ''; $this->eatby = ''; $this->sellby = ''; + + return 1; } /** diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index 820c92baa11..f592f36ea9f 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2013 Florian Henry * Copyright (C) 2015 Marcos García - * Copyright (C) 2017-2020 Frédéric France + * Copyright (C) 2017-2024 Frédéric France * * 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 @@ -1651,7 +1651,7 @@ class FactureFournisseurRec extends CommonInvoice * id must be 0 if object instance is a specimen. * * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines - * @return void + * @return int */ public function initAsSpecimen($option = '') { @@ -1771,6 +1771,8 @@ class FactureFournisseurRec extends CommonInvoice } $this->usenewprice = 0; + + return 1; } /** diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 887b5ab425f..87af56e106c 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -12,7 +12,7 @@ * Copyright (C) 2015-2022 Ferran Marcet * Copyright (C) 2016-2023 Alexandre Spangaro * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018-2023 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2022 Gauthier VERDOL * Copyright (C) 2023 Nick Fragoulis * @@ -2989,7 +2989,7 @@ class FactureFournisseur extends CommonInvoice * id must be 0 if object instance is a specimen. * * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines - * @return void + * @return int */ public function initAsSpecimen($option = '') { @@ -3077,9 +3077,11 @@ class FactureFournisseur extends CommonInvoice } } - $this->total_ht = $xnbp * 100; - $this->total_tva = $xnbp * 19.6; - $this->total_ttc = $xnbp * 119.6; + $this->total_ht = $xnbp * 100; + $this->total_tva = $xnbp * 19.6; + $this->total_ttc = $xnbp * 119.6; + + return 1; } /** diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 7a33f41eb06..132af79c05f 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -9,6 +9,7 @@ * Copyright (C) 2018 Frédéric France * Copyright (C) 2023 Joachim Kueter * Copyright (C) 2023 Sylvain Legrand + * Copyright (C) 2024 Frédéric France * * 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 @@ -725,7 +726,7 @@ class PaiementFourn extends Paiement * id must be 0 if object instance is a specimen. * * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines - * @return void + * @return int */ public function initAsSpecimen($option = '') { @@ -740,6 +741,8 @@ class PaiementFourn extends Paiement $this->facid = 1; $this->socid = 1; $this->datepaye = $nownotime; + + return 1; } /** diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 6d22e0a915d..b778a22466d 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2012-2016 Regis Houssin * Copyright (C) 2013 Florian Henry * Copyright (C) 2016 Juanjo Menent - * Copyright (C) 2018-2023 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * * 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 @@ -2344,7 +2344,7 @@ class Holiday extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -2364,6 +2364,8 @@ class Holiday extends CommonObject $this->fk_type = 1; $this->statut = Holiday::STATUS_VALIDATED; $this->status = Holiday::STATUS_VALIDATED; + + return 1; } /** diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index 291546f253b..6825247be89 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * * 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 @@ -541,12 +541,14 @@ class Establishment extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { $this->id = 0; $this->ref = '0'; $this->label = 'Department AAA'; + + return 1; } } diff --git a/htdocs/hrm/class/evaluation.class.php b/htdocs/hrm/class/evaluation.class.php index c900f583cb4..be133e09c62 100644 --- a/htdocs/hrm/class/evaluation.class.php +++ b/htdocs/hrm/class/evaluation.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2021 Greg Rastklan * Copyright (C) 2021 Jean-Pascal BOUDET * Copyright (C) 2021 Grégory BLEMAND + * Copyright (C) 2024 Frédéric France * * 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 @@ -906,7 +907,7 @@ class Evaluation extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -914,7 +915,7 @@ class Evaluation extends CommonObject // $this->property1 = ... // $this->property2 = ... - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/hrm/class/evaluationdet.class.php b/htdocs/hrm/class/evaluationdet.class.php index 6e9099a2f73..216b5ff1704 100644 --- a/htdocs/hrm/class/evaluationdet.class.php +++ b/htdocs/hrm/class/evaluationdet.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2021 Greg Rastklan * Copyright (C) 2021 Jean-Pascal BOUDET * Copyright (C) 2021 Grégory BLEMAND + * Copyright (C) 2024 Frédéric France * * 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 @@ -874,7 +875,7 @@ class EvaluationLine extends CommonObjectLine * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -882,7 +883,7 @@ class EvaluationLine extends CommonObjectLine // $this->property1 = ... // $this->property2 = ... - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/hrm/class/job.class.php b/htdocs/hrm/class/job.class.php index 34f0960cb94..743a5f75e02 100644 --- a/htdocs/hrm/class/job.class.php +++ b/htdocs/hrm/class/job.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2021 Greg Rastklan * Copyright (C) 2021 Jean-Pascal BOUDET * Copyright (C) 2021 Grégory BLEMAND + * Copyright (C) 2024 Frédéric France * * 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 @@ -914,7 +915,7 @@ class Job extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -922,7 +923,7 @@ class Job extends CommonObject // $this->property1 = ... // $this->property2 = ... - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index 4577c13ba33..14fe2f18be4 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2021 Greg Rastklan * Copyright (C) 2021 Jean-Pascal BOUDET * Copyright (C) 2021 Grégory BLEMAND + * Copyright (C) 2024 Frédéric France * * 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 @@ -956,7 +957,7 @@ class Position extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -964,7 +965,7 @@ class Position extends CommonObject // $this->property1 = ... // $this->property2 = ... - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index 3eed59b8665..6d3be881130 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2021 Greg Rastklan * Copyright (C) 2021 Jean-Pascal BOUDET * Copyright (C) 2021 Grégory BLEMAND + * Copyright (C) 2024 Frédéric France * * 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 @@ -955,7 +956,7 @@ class Skill extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -963,7 +964,7 @@ class Skill extends CommonObject // $this->property1 = ... // $this->property2 = ... - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/hrm/class/skilldet.class.php b/htdocs/hrm/class/skilldet.class.php index 78318fc1514..8865aa94db8 100644 --- a/htdocs/hrm/class/skilldet.class.php +++ b/htdocs/hrm/class/skilldet.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2021 Greg Rastklan * Copyright (C) 2021 Jean-Pascal BOUDET * Copyright (C) 2021 Grégory BLEMAND + * Copyright (C) 2024 Frédéric France * * 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 @@ -864,7 +865,7 @@ class Skilldet extends CommonObjectLine * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -872,7 +873,7 @@ class Skilldet extends CommonObjectLine // $this->property1 = ... // $this->property2 = ... - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } diff --git a/htdocs/hrm/class/skillrank.class.php b/htdocs/hrm/class/skillrank.class.php index c66a86c5e0d..788cf2a1ded 100644 --- a/htdocs/hrm/class/skillrank.class.php +++ b/htdocs/hrm/class/skillrank.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2021 Greg Rastklan * Copyright (C) 2021 Jean-Pascal BOUDET * Copyright (C) 2021 Grégory BLEMAND + * Copyright (C) 2024 Frédéric France * * 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 @@ -912,7 +913,7 @@ class SkillRank extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -920,7 +921,7 @@ class SkillRank extends CommonObject // $this->property1 = ... // $this->property2 = ... - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/knowledgemanagement/class/knowledgerecord.class.php b/htdocs/knowledgemanagement/class/knowledgerecord.class.php index b8148c97f43..5e8011fd645 100644 --- a/htdocs/knowledgemanagement/class/knowledgerecord.class.php +++ b/htdocs/knowledgemanagement/class/knowledgerecord.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -958,12 +959,13 @@ class KnowledgeRecord extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { $this->question = "ABCD"; - $this->initAsSpecimenCommon(); + + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/langs/en_US/donations.lang b/htdocs/langs/en_US/donations.lang index e60a65efb46..eaebe7c2b03 100644 --- a/htdocs/langs/en_US/donations.lang +++ b/htdocs/langs/en_US/donations.lang @@ -35,3 +35,4 @@ DonationPayments=Donation payments DonationValidated=Donation %s validated DonationUseThirdparties=Use the address of an existing thirdparty as the address of the donor DonationsStatistics=Donation's statistics +NbOfDonations=Number of donations diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 89b7a974854..3eb5b1bdc45 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2015-2023 Frédéric France + * Copyright (C) 2015-2024 Frédéric France * * 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 @@ -609,7 +609,7 @@ class Loan extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -631,6 +631,8 @@ class Loan extends CommonObject $this->capital = 20000; $this->nbterm = 48; $this->rate = 4.3; + + return 1; } /** diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index cf83e9228d7..c0363bbc5b6 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2023 Frédéric France + * Copyright (C) 2023-2024 Frédéric France * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify @@ -1118,7 +1118,7 @@ class MyObject extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -1126,7 +1126,7 @@ class MyObject extends CommonObject // $this->property1 = ... // $this->property2 = ... - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index eb72e1cdaab..24595cab867 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1589,13 +1589,15 @@ class Mo extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + $ret = $this->initAsSpecimenCommon(); $this->lines = array(); + + return $ret; } /** diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 538b9df3268..e69330ceddd 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2014 Marcos García - * Copyright (C) 2020-2024 Frédéric France + * Copyright (C) 2020-2024 Frédéric France * * 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 @@ -615,7 +615,7 @@ class Opensurveysondage extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -630,6 +630,8 @@ class Opensurveysondage extends CommonObject $this->status = 1; $this->format = 'classic'; $this->mailsonde = 0; + + return 1; } /** diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 811697a1216..f3779321a51 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2021 NextGestion + * Copyright (C) 2024 Frédéric France * * 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 @@ -1161,11 +1162,11 @@ class Partnership extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/partnership/class/partnership_type.class.php b/htdocs/partnership/class/partnership_type.class.php index f02aa2c011c..06f7ab7b35c 100644 --- a/htdocs/partnership/class/partnership_type.class.php +++ b/htdocs/partnership/class/partnership_type.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2016 Charlie Benke * Copyright (C) 2018-2019 Thibault Foucart * Copyright (C) 2021 Waël Almoman + * Copyright (C) 2024 Frédéric France * * 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 @@ -415,7 +416,7 @@ class PartnershipType extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -423,6 +424,6 @@ class PartnershipType extends CommonObject // $this->property1 = ... // $this->property2 = ... - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } } diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 282917f2099..d272bc6e95a 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2015-2017 Francis Appels + * Copyright (C) 2024 Frédéric France * * 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 @@ -235,8 +236,8 @@ class FormProduct * Return full path to current warehouse in $tab (recursive function) * * @param array $tab warehouse data in $this->cache_warehouses line - * @param String $final_label full label with all parents, separated by ' >> ' (completed on each call) - * @return String full label with all parents, separated by ' >> ' + * @param string $final_label full label with all parents, separated by ' >> ' (completed on each call) + * @return string full label with all parents, separated by ' >> ' */ private function get_parent_path($tab, $final_label = '') { @@ -550,7 +551,7 @@ class FormProduct * @param int|string $adddefault 1=Add empty unit called "Default", ''=Add empty value * @param int $mode 1=Use short label as value, 0=Use rowid, 2=Use scale (power) * @param string $morecss More CSS - * @return string + * @return string|-1 */ public function selectMeasuringUnits($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0, $mode = 0, $morecss = 'maxwidth125') { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 1cfc859b2b9..262fbeaeb6c 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -14,7 +14,7 @@ * Copyright (C) 2014 Ion agorria * Copyright (C) 2016-2018 Ferran Marcet * Copyright (C) 2017 Gustavo Novaro - * Copyright (C) 2019-2023 Frédéric France + * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2023 Benjamin Falière * * This program is free software; you can redistribute it and/or modify @@ -6341,7 +6341,7 @@ class Product extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -6380,6 +6380,8 @@ class Product extends CommonObject $this->volume_units = 0; $this->barcode = -1; // Create barcode automatically + + return 1; } /** diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index 5f5987b439f..a447910fe5d 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2013-2014 Cedric GROSS + * Copyright (C) 2024 Frédéric France * * 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 @@ -335,7 +336,7 @@ class Productbatch extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -347,6 +348,8 @@ class Productbatch extends CommonObject $this->eatby = ''; $this->batch = ''; $this->import_key = ''; + + return 1; } /** diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 2c63a76b059..a32fea0c6b6 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2014 Florian Henry + * Copyright (C) 2024 Frédéric France * * 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 @@ -1000,7 +1001,7 @@ class ProductCustomerPrice extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -1024,6 +1025,8 @@ class ProductCustomerPrice extends CommonObject $this->localtax2_tx = ''; $this->fk_user = 0; $this->import_key = ''; + + return 1; } } diff --git a/htdocs/product/class/productfournisseurprice.class.php b/htdocs/product/class/productfournisseurprice.class.php index 6812ce9f498..e178fce18e3 100644 --- a/htdocs/product/class/productfournisseurprice.class.php +++ b/htdocs/product/class/productfournisseurprice.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2021 Alexis LAURIER + * Copyright (C) 2024 Frédéric France * * 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 @@ -779,11 +780,11 @@ class ProductFournisseurPrice extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/product/class/propalmergepdfproduct.class.php b/htdocs/product/class/propalmergepdfproduct.class.php index a16edd1f53f..965a251a1f0 100644 --- a/htdocs/product/class/propalmergepdfproduct.class.php +++ b/htdocs/product/class/propalmergepdfproduct.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2015 Florian HENRY + * Copyright (C) 2024 Frédéric France * * 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 @@ -547,7 +548,7 @@ class Propalmergepdfproduct extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -560,6 +561,8 @@ class Propalmergepdfproduct extends CommonObject $this->datec = ''; $this->tms = dol_now(); $this->import_key = ''; + + return 1; } } diff --git a/htdocs/product/dynamic_price/class/price_expression.class.php b/htdocs/product/dynamic_price/class/price_expression.class.php index 5a0fa5243ff..ef99ef8603c 100644 --- a/htdocs/product/dynamic_price/class/price_expression.class.php +++ b/htdocs/product/dynamic_price/class/price_expression.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2012 Laurent Destailleur * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ion Agorria + * Copyright (C) 2024 Frédéric France * * 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 @@ -325,11 +326,13 @@ class PriceExpression * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { $this->id = 0; $this->expression = ''; + + return 1; } } diff --git a/htdocs/product/dynamic_price/class/price_global_variable.class.php b/htdocs/product/dynamic_price/class/price_global_variable.class.php index 13cf5233342..6b81d780c49 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable.class.php @@ -281,7 +281,7 @@ class PriceGlobalVariable * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -289,6 +289,8 @@ class PriceGlobalVariable $this->code = ''; $this->description = ''; $this->value = ''; + + return 1; } /** diff --git a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php index d36c0477bf4..42030aa290e 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php @@ -306,7 +306,7 @@ class PriceGlobalVariableUpdater * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -318,6 +318,8 @@ class PriceGlobalVariableUpdater $this->update_interval = 0; $this->next_update = 0; $this->last_status = ''; + + return 1; } /** diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index ae477dafd8e..d20e7336110 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2014-2016 Juanjo Menent * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2024 Frédéric France * * 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 @@ -739,12 +740,14 @@ class Inventory extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + $ret = $this->initAsSpecimenCommon(); $this->title = ''; + + return $ret; } /** diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 010d657cb93..c3106759f8e 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2008 Regis Houssin * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2016 Francis Appels - * Copyright (C) 2019-2024 Frédéric France + * Copyright (C) 2019-2024 Frédéric France * * 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 @@ -841,7 +841,7 @@ class Entrepot extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -862,6 +862,8 @@ class Entrepot extends CommonObject $this->town = 'MyTown'; $this->country_id = 1; $this->country_code = 'FR'; + + return 1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 6b310bdac1a..80751ebbec7 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2011 Jean Heimburger * Copyright (C) 2014 Cedric GROSS * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * 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 @@ -1066,16 +1067,16 @@ class MouvementStock extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { - global $user, $langs, $conf, $mysoc; - // Initialize parameters $this->id = 0; // There is no specific properties. All data into insert are provided as method parameter. + + return 1; } /** diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index cd4dca967dc..28f8b53c88b 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2018-2022 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2023 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify @@ -1205,7 +1205,7 @@ class Productlot extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -1228,6 +1228,8 @@ class Productlot extends CommonObject $this->fk_user_creat = 0; $this->fk_user_modif = 0; $this->import_key = '123456'; + + return 1; } /** diff --git a/htdocs/product/stock/class/productstockentrepot.class.php b/htdocs/product/stock/class/productstockentrepot.class.php index 7d9e7c07d2b..f4dbdca4a75 100644 --- a/htdocs/product/stock/class/productstockentrepot.class.php +++ b/htdocs/product/stock/class/productstockentrepot.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2014-2016 Juanjo Menent * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * * 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 @@ -596,7 +596,7 @@ class ProductStockEntrepot extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -608,5 +608,7 @@ class ProductStockEntrepot extends CommonObject $this->seuil_stock_alerte = ''; $this->desiredstock = ''; $this->import_key = ''; + + return 1; } } diff --git a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php index ba3ab193089..ed7c6394d61 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransfer.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2021 Gauthier VERDOL - * Copyright (C) 2022 Frédéric France + * Copyright (C) 2022-2024 Frédéric France * * 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 @@ -929,11 +929,11 @@ class StockTransfer extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php index 4e6847287ca..bc0c56baa3f 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2021 Gauthier VERDOL * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2024 Frédéric France * * 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 @@ -911,11 +912,11 @@ class StockTransferLine extends CommonObjectLine * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 893ced6f27c..4f6e2b36480 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1477,7 +1477,7 @@ class Project extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -1520,6 +1520,8 @@ class Project extends CommonObject $xnbp++; } */ + + return 1; } /** diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 265f218fc53..df339ae9004 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -451,7 +451,7 @@ class Task extends CommonObjectLine // Clean parameters if (isset($this->fk_project)) { - $this->fk_project = trim($this->fk_project); + $this->fk_project = (int) $this->fk_project; } if (isset($this->ref)) { $this->ref = trim($this->ref); @@ -472,7 +472,7 @@ class Task extends CommonObjectLine $this->planned_workload = trim($this->planned_workload); } if (isset($this->budget_amount)) { - $this->budget_amount = trim($this->budget_amount); + $this->budget_amount = (float) $this->budget_amount; } if (!empty($this->date_start) && !empty($this->date_end) && $this->date_start > $this->date_end) { @@ -897,7 +897,7 @@ class Task extends CommonObjectLine * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -912,6 +912,8 @@ class Task extends CommonObjectLine $this->progress = '25'; $this->status = 0; $this->note = 'This is a specimen task not'; + + return 1; } /** diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 2ab50c297f4..0aeb300a666 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -11,7 +11,7 @@ * Copyright (C) 2015 Claudio Aschieri * Copyright (C) 2016-2022 Ferran Marcet * Copyright (C) 2018 Quentin Vial-Gouteyron - * Copyright (C) 2022-2023 Frédéric France + * Copyright (C) 2022-2024 Frédéric France * * 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 @@ -1414,7 +1414,7 @@ class Reception extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -1465,6 +1465,8 @@ class Reception extends CommonObject $this->lines[] = $line; $xnbp++; } + + return 1; } /** diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php index ae119deae92..0d02a59a573 100644 --- a/htdocs/recruitment/class/recruitmentcandidature.class.php +++ b/htdocs/recruitment/class/recruitmentcandidature.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -906,11 +907,11 @@ class RecruitmentCandidature extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index 049456248dd..3fa9c360610 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -1,6 +1,7 @@ /* Copyright (C) 2022 Alexandre Spangaro + * Copyright (C) 2024 Frédéric France * * 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 @@ -973,11 +974,11 @@ class RecruitmentJobPosition extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php index ef54b12b43a..18f3d1263e1 100644 --- a/htdocs/salaries/class/paymentsalary.class.php +++ b/htdocs/salaries/class/paymentsalary.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2011-2022 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2024 Frédéric France * * 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 @@ -555,7 +556,7 @@ class PaymentSalary extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -572,6 +573,8 @@ class PaymentSalary extends CommonObject $this->fk_bank = 0; $this->fk_user_author = 0; $this->fk_user_modif = 0; + + return 1; } @@ -983,11 +986,16 @@ class PaymentSalary extends CommonObject if ($selected >= 0) { $return .= ''; } - if (property_exists($this, 'fk_bank')) { - $return .= ' | '.$this->fk_bank.''; + if (property_exists($this, 'fk_bank') && is_numeric($this->fk_bank)) { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $account = new AccountLine($this->db); + $account->fetch($this->fk_bank); + $return .= ' | '.$account->getNomUrl(1).''; } - if (property_exists($this, 'fk_user_author')) { - $return .= '
'.$this->fk_user_author.''; + if (property_exists($this, 'fk_user_author') && is_numeric($this->fk_user_author)) { + $userstatic = new User($this->db); + $userstatic->fetch($this->fk_user_author); + $return .= '
'.$userstatic->getNomUrl(1).''; } if (property_exists($this, 'fk_typepayment')) { diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index c7cbc98ccb3..85b2b312f16 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2011-2022 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2024 Frédéric France * * 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 @@ -305,7 +306,7 @@ class Salary extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -323,6 +324,8 @@ class Salary extends CommonObject $this->fk_bank = 0; $this->fk_user_author = 0; $this->fk_user_modif = 0; + + return 1; } /** diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index b9f93125294..3921451d174 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -3,6 +3,7 @@ * Copyright (C) 2015-2016 Laurent Destailleur * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2024 Frédéric France * * 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 @@ -613,8 +614,8 @@ while ($i < $imaxinloop) { $accountlinestatic->id = $obj->fk_bank; $accountlinestatic->ref = $obj->fk_bank; - $paymentsalstatic->fk_bank = $accountlinestatic->getNomUrl(1); - $paymentsalstatic->fk_user_author = $userstatic->getNomUrl(1); + $paymentsalstatic->fk_bank = $accountlinestatic->id; + $paymentsalstatic->fk_user_author = $userstatic->id; if ($mode == 'kanban') { if ($i == 0) { diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index e67452d4347..6b95ec4ab79 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013 Peter Fontaine * Copyright (C) 2016 Marcos García + * Copyright (C) 2024 Frédéric France * * 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 @@ -673,7 +674,7 @@ class CompanyBankAccount extends Account * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -702,5 +703,7 @@ class CompanyBankAccount extends Account $this->frstrecur = 'FRST'; $this->socid = 1; + + return 1; } } diff --git a/htdocs/societe/class/companypaymentmode.class.php b/htdocs/societe/class/companypaymentmode.class.php index ce94ae75e38..99901fc00c8 100644 --- a/htdocs/societe/class/companypaymentmode.class.php +++ b/htdocs/societe/class/companypaymentmode.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 Frédéric France * * 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 @@ -552,10 +552,10 @@ class CompanyPaymentMode extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 2885555b01a..abdd447f9a1 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -15,7 +15,7 @@ * Copyright (C) 2017 Rui Strecht * Copyright (C) 2018 Philippe Grand * Copyright (C) 2019-2020 Josep Lluís Amador - * Copyright (C) 2019-2024 Frédéric France + * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2020 Open-Dsi * Copyright (C) 2022 ButterflyOfFire * Copyright (C) 2023 Alexandre Janniaux @@ -4514,6 +4514,7 @@ class Societe extends CommonObject $this->idprof4 = 'idprof4'; $this->idprof5 = 'idprof5'; $this->idprof6 = 'idprof6'; + return 1; } diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index 41bf4164981..c4a3f1fa824 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2014-2016 Juanjo Menent * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2024 Frédéric France * * 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 @@ -561,10 +562,10 @@ class SocieteAccount extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } } diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index b00c46b6dc6..70ed30c225f 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -48,6 +49,9 @@ class Stripe extends CommonObject */ public $id; + /** + * @var string + */ public $mode; /** @@ -55,11 +59,21 @@ class Stripe extends CommonObject */ public $entity; + /** + * @var string + */ public $statut; public $type; + /** + * @var string + */ public $code; + + /** + * @var string + */ public $declinecode; /** diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index b2a681606df..05f790292a4 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2289,7 +2289,7 @@ class SupplierProposal extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -2362,6 +2362,8 @@ class SupplierProposal extends CommonObject $xnbp++; } + + return 1; } /** diff --git a/htdocs/ticket/class/cticketcategory.class.php b/htdocs/ticket/class/cticketcategory.class.php index e783a40372a..923219858f7 100644 --- a/htdocs/ticket/class/cticketcategory.class.php +++ b/htdocs/ticket/class/cticketcategory.class.php @@ -1,6 +1,7 @@ * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2024 Frédéric France * * 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 @@ -637,10 +638,10 @@ class CTicketCategory extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } } diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index d2f8fd9bb31..beace9b3dbd 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2016 Christophe Battarel - * Copyright (C) 2019-2023 Frédéric France + * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2020 Laurent Destailleur * Copyright (C) 2023 Charlene Benke * Copyright (C) 2023 Benjamin Falière @@ -1291,6 +1291,7 @@ class Ticket extends CommonObject $this->date_last_msg_sent = dol_now(); $this->date_close = dol_now(); $this->tms = dol_now(); + return 1; } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 996fbee5611..0d442f9e121 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -12,7 +12,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2018 charlene Benke * Copyright (C) 2018-2021 Nicolas ZABOURI - * Copyright (C) 2019-2024 Frédéric France + * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2019 Abbes Bahfir * Copyright (C) 2024 MDW * @@ -3471,6 +3471,7 @@ class User extends CommonObject $this->status = 1; $this->entity = 1; + return 1; } diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index b3a60d92d90..48ec6758351 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2014 Alexis Algoud * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2019 Abbes Bahfir - * Copyright (C) 2023 Frédéric France + * Copyright (C) 2023-2024 Frédéric France * * 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 @@ -947,7 +947,7 @@ class UserGroup extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { @@ -967,6 +967,8 @@ class UserGroup extends CommonObject $this->members = array( $user->id => $user ); + + return 1; } /** diff --git a/htdocs/webhook/class/target.class.php b/htdocs/webhook/class/target.class.php index 1858d3791cb..6d538208dfa 100644 --- a/htdocs/webhook/class/target.class.php +++ b/htdocs/webhook/class/target.class.php @@ -1,6 +1,7 @@ * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2024 Frédéric France * * 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 @@ -858,13 +859,14 @@ class Target extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { $this->url = "https://thisisunurl"; $this->trigger_codes = "ThisIsATestCode"; - $this->initAsSpecimenCommon(); + + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index f22db99fd9c..a4b80193d02 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify @@ -909,7 +909,7 @@ class Website extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -929,6 +929,8 @@ class Website extends CommonObject $this->fk_user_modif = $user->id; $this->date_creation = dol_now(); $this->tms = dol_now(); + + return 1; } diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index 5e408330b4f..737e57ac3ec 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2020 Nicolas ZABOURI + * Copyright (C) 2024 Frédéric France * * 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 @@ -857,7 +858,7 @@ class WebsitePage extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { @@ -884,5 +885,7 @@ class WebsitePage extends CommonObject $this->date_modification = $now - (24 * 7 * 3600); $this->fk_user_creat = $user->id; $this->author_alias = 'mypublicpseudo'; + + return 1; } } diff --git a/htdocs/workstation/class/workstation.class.php b/htdocs/workstation/class/workstation.class.php index e38039e19c3..506071a26f2 100644 --- a/htdocs/workstation/class/workstation.class.php +++ b/htdocs/workstation/class/workstation.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2020 Gauthier VERDOL - * Copyright (C) 2023-2024 Frédéric France + * Copyright (C) 2023-2024 Frédéric France * * 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 @@ -855,11 +855,11 @@ class Workstation extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } /** diff --git a/htdocs/zapier/class/hook.class.php b/htdocs/zapier/class/hook.class.php index 17c8d0c2160..68bda9bedb8 100644 --- a/htdocs/zapier/class/hook.class.php +++ b/htdocs/zapier/class/hook.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-2024 Frédéric France * 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 * the Free Software Foundation; either version 3 of the License, or @@ -648,10 +648,10 @@ class Hook extends CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimen() { - $this->initAsSpecimenCommon(); + return $this->initAsSpecimenCommon(); } } diff --git a/test/phpunit/CommonClassTest.class.php b/test/phpunit/CommonClassTest.class.php index 0322cdd28bc..262dc2ad002 100644 --- a/test/phpunit/CommonClassTest.class.php +++ b/test/phpunit/CommonClassTest.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2018 Laurent Destailleur * Copyright (C) 2023 Alexandre Janniaux * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * 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 @@ -60,6 +61,16 @@ abstract class CommonClassTest extends TestCase */ public $nbLinesToShow = 100; + /** + * Log file from which to extract lines in case of failing test + */ + public $logfile = DOL_DATA_ROOT.'/dolibarr.log'; + + /** + * Log file size before a test started (=in setUp() call) + */ + public $logSizeAtSetup = 0; + /** * Constructor * We save global variables into local variables @@ -108,15 +119,25 @@ abstract class CommonClassTest extends TestCase */ protected function onNotSuccessfulTest(Throwable $t): void { - $logfile = DOL_DATA_ROOT.'/dolibarr.log'; - $lines = file($logfile); + // Get the lines that were added since the start of the test + + $filecontent = (string) @file_get_contents($this->logfile); + $currentSize = strlen($filecontent); + if ($currentSize >= $this->logSizeAtSetup) { + $filecontent = substr($filecontent, $this->logSizeAtSetup); + } + $lines = preg_split("/\r?\n/", $filecontent, -1, PREG_SPLIT_NO_EMPTY); + + + // Determine the number of lines to show $nbLinesToShow = $this->nbLinesToShow; if ($t instanceof PHPUnit\Framework\Error\Notice) { $nbLinesToShow = 3; } + // Determine test information to show $failedTestMethod = $this->getName(false); $className = get_called_class(); @@ -132,18 +153,26 @@ abstract class CommonClassTest extends TestCase // Get the last line of the log $last_lines = array_slice($lines, $first_line, $nbLinesToShow); + + // Show log information + print PHP_EOL; // Use GitHub Action compatible group output (:warning: arguments not encoded) print "##[group]$className::$failedTestMethod failed - $argsText.".PHP_EOL; - print "## Exception: {$t->getMessage()}".PHP_EOL; + print "## ".get_class($t).": {$t->getMessage()}".PHP_EOL; if ($nbLinesToShow) { - // Show partial log file contents when requested. - print "## Show last ".$nbLinesToShow." lines of dolibarr.log file -----".PHP_EOL; - foreach ($last_lines as $line) { - print $line.PHP_EOL; + $newLines = count($last_lines); + if ($newLines > 0) { + // Show partial log file contents when requested. + print "## Show last ".count($last_lines)." lines of dolibarr.log file -----".PHP_EOL; + foreach ($last_lines as $line) { + print $line.PHP_EOL; + } + print "## end of dolibarr.log for $className::$failedTestMethod".PHP_EOL; + } else { + print "## No new lines in 'dolibarr.log' since start of this test.".PHP_EOL; } - print "## end of dolibarr.log for $className::$failedTestMethod".PHP_EOL; } print "##[endgroup]".PHP_EOL; @@ -164,6 +193,9 @@ abstract class CommonClassTest extends TestCase $langs = $this->savlangs; $db = $this->savdb; + // Record the filesize to determine which part of the log to show on error + $this->logSizeAtSetup = (int) filesize($this->logfile); + if ((int) getenv('PHPUNIT_DEBUG') > 0) { print get_called_class().'::'.$this->getName(false)."::".__FUNCTION__.PHP_EOL; }