From 078da229c886bd89d34d1376d4fa18be392592d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 17 Sep 2025 14:11:32 +0200 Subject: [PATCH] clean code (#35352) * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * Clean code * Clean code * clean code * clean code * clean code * clean code * clean code --- dev/build/phpstan/phpstan-baseline.neon | 108 ------------------ dev/setup/git/hooks/pre-commit | 8 +- htdocs/bom/tpl/objectline_edit.tpl.php | 2 +- htdocs/comm/propal/card.php | 7 +- htdocs/commande/card.php | 2 +- htdocs/commande/class/commande.class.php | 2 +- htdocs/compta/bank/class/account.class.php | 2 +- .../bank/class/paymentvarious.class.php | 2 +- htdocs/compta/facture/card.php | 10 +- .../cheque/class/remisecheque.class.php | 16 +-- .../compta/paiement/class/paiement.class.php | 6 +- .../sociales/class/chargesociales.class.php | 2 +- .../core/class/commondocgenerator.class.php | 2 +- htdocs/core/class/commonobject.class.php | 6 +- .../modules/facture/doc/pdf_crabe.modules.php | 2 +- .../facture/doc/pdf_octopus.modules.php | 2 +- .../facture/doc/pdf_sponge.modules.php | 2 +- .../class/fournisseur.commande.class.php | 2 +- .../fourn/class/fournisseur.facture.class.php | 2 +- htdocs/fourn/facture/card.php | 3 +- htdocs/public/webportal/css/style.css.php | 3 +- htdocs/public/webportal/tpl/header.tpl.php | 1 + .../public/webportal/webportal.main.inc.php | 15 ++- htdocs/salaries/class/paymentsalary.class.php | 105 ++++++++--------- htdocs/salaries/payment_salary/card.php | 6 +- 25 files changed, 108 insertions(+), 210 deletions(-) diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index 93b0d72a79e..19eb4a4564b 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -17538,114 +17538,6 @@ parameters: count: 1 path: ../../../htdocs/salaries/card.php - - - message: '#^Call to function method_exists\(\) with \$this\(PaymentSalary\) and ''getNomUrl'' will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: ../../../htdocs/salaries/class/paymentsalary.class.php - - - - message: '#^Call to function property_exists\(\) with \$this\(PaymentSalary\) and ''amount'' will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: ../../../htdocs/salaries/class/paymentsalary.class.php - - - - message: '#^Call to function property_exists\(\) with \$this\(PaymentSalary\) and ''fk_bank'' will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: ../../../htdocs/salaries/class/paymentsalary.class.php - - - - message: '#^Call to function property_exists\(\) with \$this\(PaymentSalary\) and ''fk_typepayment'' will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: ../../../htdocs/salaries/class/paymentsalary.class.php - - - - message: '#^Call to function property_exists\(\) with \$this\(PaymentSalary\) and ''fk_user_author'' will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: ../../../htdocs/salaries/class/paymentsalary.class.php - - - - message: '#^Left side of && is always true\.$#' - identifier: booleanAnd.leftAlwaysTrue - count: 1 - path: ../../../htdocs/salaries/class/paymentsalary.class.php - - - - message: '#^Loose comparison using \=\= between '''' and ''nolink'' will always evaluate to false\.$#' - identifier: equal.alwaysFalse - count: 2 - path: ../../../htdocs/salaries/class/paymentsalary.class.php - - - - message: '#^Property PaymentSalary\:\:\$amount \(float\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 3 - path: ../../../htdocs/salaries/class/paymentsalary.class.php - - - - message: '#^Property PaymentSalary\:\:\$fk_bank \(int\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 3 - path: ../../../htdocs/salaries/class/paymentsalary.class.php - - - - message: '#^Property PaymentSalary\:\:\$fk_salary \(int\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 3 - path: ../../../htdocs/salaries/class/paymentsalary.class.php - - - - message: '#^Property PaymentSalary\:\:\$fk_typepayment \(int\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 3 - path: ../../../htdocs/salaries/class/paymentsalary.class.php - - - - message: '#^Property PaymentSalary\:\:\$fk_user_author \(int\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 3 - path: ../../../htdocs/salaries/class/paymentsalary.class.php - - - - message: '#^Property PaymentSalary\:\:\$fk_user_modif \(int\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 3 - path: ../../../htdocs/salaries/class/paymentsalary.class.php - - - - message: '#^Property PaymentSalary\:\:\$num_paiement \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 2 - path: ../../../htdocs/salaries/class/paymentsalary.class.php - - - - message: '#^Property PaymentSalary\:\:\$num_payment \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 3 - path: ../../../htdocs/salaries/class/paymentsalary.class.php - - - - message: '#^Result of \|\| is always false\.$#' - identifier: booleanOr.alwaysFalse - count: 2 - path: ../../../htdocs/salaries/class/paymentsalary.class.php - - - - message: '#^Strict comparison using \!\=\= between '''' and ''nolink'' will always evaluate to true\.$#' - identifier: notIdentical.alwaysTrue - count: 1 - path: ../../../htdocs/salaries/class/paymentsalary.class.php - - - - message: '#^Variable \$url in empty\(\) always exists and is not falsy\.$#' - identifier: empty.variable - count: 2 - path: ../../../htdocs/salaries/class/paymentsalary.class.php - - message: '#^Negated boolean expression is always false\.$#' identifier: booleanNot.alwaysFalse diff --git a/dev/setup/git/hooks/pre-commit b/dev/setup/git/hooks/pre-commit index c04e5a39609..25f6b4817b3 100755 --- a/dev/setup/git/hooks/pre-commit +++ b/dev/setup/git/hooks/pre-commit @@ -12,10 +12,10 @@ HERE="$(cd "$(dirname "$0")" && pwd)" ARGS+=(--hook-dir "$HERE" -- "$@") if [ -x "$INSTALL_PYTHON" ]; then - exec "$INSTALL_PYTHON" -mpre_commit "${ARGS[@]}" 1>&2 + exec "$INSTALL_PYTHON" -mpre_commit "${ARGS[@]}" 1>&2 elif command -v pre-commit > /dev/null; then - exec pre-commit "${ARGS[@]}" 1>&2 + exec pre-commit "${ARGS[@]}" 1>&2 else - echo 'pre-commit not found. Did you forget to activate your virtualenv?' 1>&2 - exit 1 + echo 'pre-commit not found. Did you forget to activate your virtualenv?' 1>&2 + exit 1 fi diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index d6744275031..80cbe9d3520 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -5,7 +5,7 @@ * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2013 Florian Henry - * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2018-2025 Frédéric France * Copyright (C) 2024 Vincent Maury * Copyright (C) 2024-2025 MDW * diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 367fe2f967d..5c2762df0ef 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2257,6 +2257,7 @@ if ($action == 'create') { $classname = ucfirst($subelement); $objectsrc = new $classname($db); '@phan-var-force Commande|Propal|Contrat|Expedition $objectsrc'; // Can be other class, but CommonObject is too generic + /** @var Commande|Propal|Contrat|Expedition $objectsrc */ $objectsrc->fetch($originid); if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) { $objectsrc->fetch_lines(); @@ -2268,8 +2269,8 @@ if ($action == 'create') { $soc = $objectsrc->thirdparty; - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); - $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0)); // Replicate extrafields @@ -2447,7 +2448,7 @@ if ($action == 'create') { // Bank Account if (getDolGlobalString('BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') && isModEnabled("bank")) { print '' . $langs->trans('BankAccount') . ''; - print img_picto('', 'bank_account', 'class="pictofixedwidth"') . $form->select_comptes($fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); + print img_picto('', 'bank_account', 'class="pictofixedwidth"') . $form->select_comptes((int) $fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); print ''; } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 93313068dec..c98e2362904 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2389,7 +2389,7 @@ if ($action == 'create' && $usercancreate) { // Bank Account if (getDolGlobalString('BANK_ASK_PAYMENT_BANK_DURING_ORDER') && isModEnabled("bank")) { print '' . $langs->trans('BankAccount') . ''; - print img_picto('', 'bank_account', 'class="pictofixedwidth"') . $form->select_comptes($fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); + print img_picto('', 'bank_account', 'class="pictofixedwidth"') . $form->select_comptes((int) $fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); print ''; } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 698fdcda7bc..37d551e2dc4 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -159,7 +159,7 @@ class Commande extends CommonOrder public $deposit_percent; /** - * @var int bank account ID + * @var ?int bank account ID */ public $fk_account; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index eaf1c0e3501..34036fce919 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -2147,7 +2147,7 @@ class AccountLine extends CommonObjectLine public $fk_bordereau; /** - * @var int ID of bank account + * @var ?int ID of bank account */ public $fk_account; diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index c114aef3c1f..b6e9889ed71 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -124,7 +124,7 @@ class PaymentVarious extends CommonObject public $fk_project; /** - * @var int Bank account ID + * @var ?int Bank account ID */ public $fk_account; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index d3f03ad3a10..fac611f7996 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3715,6 +3715,7 @@ if ($action == 'create') { $classname = ucfirst($subelement); $objectsrc = new $classname($db); '@phan-var-force Commande|Propal|Contrat|Expedition $objectsrc'; + /** @var Commande|Propal|Contrat|Expedition $objectsrc */ $objectsrc->fetch($originid); if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) { $objectsrc->fetch_lines(); @@ -3745,12 +3746,13 @@ if ($action == 'create') { $expesrc = new $classname($db); '@phan-var-force Expedition $expesrc'; + /** @var Expedition $expesrc */ dol_syslog("Is type Facture|Commande or Expedition: $element...expesrc($classname)=".get_class($expesrc)); $expesrc->fetch($expeoriginid); - $cond_reglement_id = (!empty($expesrc->cond_reglement_id) ? $expesrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 1)); - $mode_reglement_id = (!empty($expesrc->mode_reglement_id) ? $expesrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); - $fk_account = (!empty($expesrc->fk_account) ? $expesrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); + $cond_reglement_id = (!empty($expesrc->cond_reglement_id) ? $expesrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 1)); + $mode_reglement_id = (!empty($expesrc->mode_reglement_id) ? $expesrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); + $fk_account = (!empty($expesrc->fk_account) ? $expesrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); if (isModEnabled('multicurrency')) { $currency_code = (!empty($expesrc->multicurrency_code) ? $expesrc->multicurrency_code : (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : $objectsrc->multicurrency_code)); @@ -4502,7 +4504,7 @@ if ($action == 'create') { if (isModEnabled("bank")) { print ''.$langs->trans('BankAccount').''; print img_picto('', 'bank_account', 'class="pictofixedwidth"'); - print $form->select_comptes($fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth250 widthcentpercentminusx', 1); + print $form->select_comptes((int) $fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth250 widthcentpercentminusx', 1); //print ' id.($fac_rec ? '&fac_rec='.$fac_rec : '')).'">'; print ''; } diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index e8296d1adef..30086b85917 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -1,11 +1,11 @@ - * Copyright (C) 2007-2011 Laurent Destailleur - * 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 - * Copyright (C) 2024-2025 MDW +/* Copyright (C) 2006 Rodolphe Quiedeville + * Copyright (C) 2007-2011 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2011-2016 Juanjo Menent + * Copyright (C) 2015 Marcos García + * Copyright (C) 2024-2025 Frédéric France + * Copyright (C) 2024-2025 MDW * * 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 @@ -815,7 +815,7 @@ class RemiseCheque extends CommonObject $result = $rejectedPayment->create($user); if ($result > 0) { // We created a negative payment, we also add the line as bank transaction - $result = $rejectedPayment->addPaymentToBank($user, 'payment', '(CheckRejected)', $bankaccount, '', ''); + $result = $rejectedPayment->addPaymentToBank($user, 'payment', '(CheckRejected)', (int) $bankaccount, '', ''); if ($result > 0) { $result = $payment->reject(); if ($result > 0) { diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 324a0bd2c37..ed04237c4ed 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -198,7 +198,7 @@ class Paiement extends CommonObject public $bank_account; /** - * @var int bank account id of payment + * @var ?int bank account id of payment */ public $fk_account; @@ -404,11 +404,11 @@ class Paiement extends CommonObject $currencyofpayment = $conf->currency; } - if (!empty($currencyofpayment)) { + if (!empty($currencyofpayment && !empty($this->fk_account))) { // We must check that the currency of invoices is the same than the currency of the bank include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $bankaccount = new Account($this->db); - $bankaccount->fetch($this->fk_account); + $bankaccount->fetch((int) $this->fk_account); $bankcurrencycode = empty($bankaccount->currency_code) ? $conf->currency : $bankaccount->currency_code; if ($bankcurrencycode != $conf->currency) { diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index c122a11c644..71701a46d12 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -119,7 +119,7 @@ class ChargeSociales extends CommonObject public $lib; /** - * @var int account ID + * @var ?int account ID */ public $fk_account; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 6f569cbb27e..2d44bb28c17 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -758,7 +758,7 @@ abstract class CommonDocGenerator if (property_exists($object, 'fk_account') && $object->fk_account > 0) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $bank_account = new Account($this->db); - $bank_account->fetch($object->fk_account); + $bank_account->fetch((int) $object->fk_account); } $resarray[$array_key.'_bank_iban'] = (empty($bank_account) ? '' : $bank_account->iban); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index bca33a09703..956818e15a9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -558,14 +558,14 @@ abstract class CommonObject public $last_main_doc; /** - * @var int Bank account ID sometimes, ID of record into llx_bank sometimes + * @var ?int Bank account ID sometimes, ID of record into llx_bank sometimes * @deprecated * @see $fk_account */ public $fk_bank; /** - * @var int Bank account ID + * @var ?int Bank account ID * @see SetBankAccount() */ public $fk_account; @@ -754,7 +754,7 @@ abstract class CommonObject public $fk_user_creat; /** - * @var int ID + * @var ?int ID * @deprecated Use $user_modification_id */ public $fk_user_modif; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 19b35488472..5ef342975a7 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1483,7 +1483,7 @@ class pdf_crabe extends ModelePDFFactures $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank } $account = new Account($this->db); - $account->fetch($bankid); + $account->fetch((int) $bankid); $curx = $this->marge_gauche; $cury = $posy; diff --git a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php index 8a5bd24632e..7ec25f51722 100644 --- a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php @@ -1667,7 +1667,7 @@ class pdf_octopus extends ModelePDFFactures $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank } $account = new Account($this->db); - $account->fetch($bankid); + $account->fetch((int) $bankid); $curx = $this->marge_gauche; $cury = $posy; diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 0d1023eb761..c33005b7f56 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1643,7 +1643,7 @@ class pdf_sponge extends ModelePDFFactures // If payment mode not forced or forced to VIR, show payment with BAN if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') { if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) { - $bankid = ($object->fk_account <= 0 ? getDolGlobalInt('FACTURE_RIB_NUMBER') : $object->fk_account); + $bankid = ($object->fk_account <= 0 ? getDolGlobalInt('FACTURE_RIB_NUMBER') : (int) $object->fk_account); if ($object->fk_bank > 0) { $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index b11e046f0c0..bb43ad9216f 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -237,7 +237,7 @@ class CommandeFournisseur extends CommonOrder public $cond_reglement_doc; /** - * @var int Account ID + * @var ?int Account ID */ public $fk_account; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 65283c5c2b8..81f18a6b66a 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -229,7 +229,7 @@ class FactureFournisseur extends CommonInvoice public $propalid; /** - * @var int ID + * @var ?int ID */ public $fk_account; // default bank account diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 93abc63d0bc..fe8937585b5 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2203,6 +2203,7 @@ if ($action == 'create') { } $objectsrc = new $classname($db); '@phan-var-force Project|Commande|Propal|Facture|Contrat|CommandeFournisseur|CommonObject $objectsrc'; + /** @var CommandeFournisseur|CommonObject $objectsrc */ $objectsrc->fetch($originid); $objectsrc->fetch_thirdparty(); @@ -2768,7 +2769,7 @@ if ($action == 'create') { if (isModEnabled("bank")) { print ''.$langs->trans('BankAccount').''; // when bank account is empty (means not override by payment mode form a other object, like third-party), try to use default value - print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes($fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); + print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes((int) $fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); print ''; } diff --git a/htdocs/public/webportal/css/style.css.php b/htdocs/public/webportal/css/style.css.php index 7b9e95d82de..1eb7da00c54 100644 --- a/htdocs/public/webportal/css/style.css.php +++ b/htdocs/public/webportal/css/style.css.php @@ -1,5 +1,6 @@ + * Copyright (C) 2025 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 @@ -75,7 +76,7 @@ if (empty($dolibarr_nocache)) { @import "login.css"; /** -This file car overwrite default pico css +This file can overwrite default pico css */ diff --git a/htdocs/public/webportal/tpl/header.tpl.php b/htdocs/public/webportal/tpl/header.tpl.php index e3c1ce32037..279046affd5 100644 --- a/htdocs/public/webportal/tpl/header.tpl.php +++ b/htdocs/public/webportal/tpl/header.tpl.php @@ -1,5 +1,6 @@ + * Copyright (C) 2025 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 diff --git a/htdocs/public/webportal/webportal.main.inc.php b/htdocs/public/webportal/webportal.main.inc.php index 87143cc1234..bf7817d47eb 100644 --- a/htdocs/public/webportal/webportal.main.inc.php +++ b/htdocs/public/webportal/webportal.main.inc.php @@ -138,7 +138,10 @@ if (!defined('WEBPORTAL_NOLOGIN') && !empty($context->controllerInstance->access // Hooks for security access $hookmanager->initHooks(array('login')); - $parameters = array("webportal_sessionname" => $sessionname, "webportal_anti_spam_session_key" => $anti_spam_session_key); + $parameters = array( + "webportal_sessionname" => $sessionname, + "webportal_anti_spam_session_key" => $anti_spam_session_key, + ); $reshook = $hookmanager->executeHooks('beforeLoginAuthentication', $parameters, $context); if ($reshook < 0) { $error++; @@ -311,14 +314,20 @@ if (!defined('WEBPORTAL_NOLOGIN') && !empty($context->controllerInstance->access if ($error) { // Hooks on failed login - $parameters = array("webportal_sessionname" => $sessionname, "webportal_anti_spam_session_key" => $anti_spam_session_key); + $parameters = array( + "webportal_sessionname" => $sessionname, + "webportal_anti_spam_session_key" => $anti_spam_session_key, + ); $reshook = $hookmanager->executeHooks('afterLoginFailed', $parameters, $context); if ($reshook < 0) { $error++; } } else { // Hooks on after login - $parameters = array("webportal_sessionname" => $sessionname, "webportal_anti_spam_session_key" => $anti_spam_session_key); + $parameters = array( + "webportal_sessionname" => $sessionname, + "webportal_anti_spam_session_key" => $anti_spam_session_key, + ); $reshook = $hookmanager->executeHooks('afterLogin', $parameters, $context); if ($reshook < 0) { $error++; diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php index fe5c80dbfcb..fbfcf225e8e 100644 --- a/htdocs/salaries/class/paymentsalary.class.php +++ b/htdocs/salaries/class/paymentsalary.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2011-2024 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2021 Gauthier VERDOL - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024-2025 Frédéric France * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify @@ -58,7 +58,7 @@ class PaymentSalary extends CommonObject public $chid; /** - * @var int ID of the salary linked to the payment + * @var ?int ID of the salary linked to the payment */ public $fk_salary; @@ -87,7 +87,7 @@ class PaymentSalary extends CommonObject public $total; /** - * @var float Total amount of payment + * @var ?float Total amount of payment */ public $amount; @@ -97,40 +97,35 @@ class PaymentSalary extends CommonObject public $amounts = array(); /** - * @var int Payment type ID + * @var ?int Payment type ID */ public $fk_typepayment; /** - * @var string - * @deprecated Use $num_payment - */ - public $num_paiement; - - /** - * @var string Payment reference + * @var ?string Payment reference * (Cheque or bank transfer reference. Can be "ABC123") */ public $num_payment; /** * @inheritdoc - * @var int + * @var ?int + * @deprecated use $bank_line */ public $fk_bank; /** - * @var int ID of bank_line + * @var ?int ID of bank_line */ public $bank_line; /** - * @var int ID of the user who created the payment + * @var ?int ID of the user who created the payment */ public $fk_user_author; /** - * @var int ID of the user who modified the payment + * @var ?int ID of the user who modified the payment */ public $fk_user_modif; @@ -233,9 +228,6 @@ class PaymentSalary extends CommonObject if (isset($this->fk_typepayment)) { $this->fk_typepayment = (int) $this->fk_typepayment; } - if (isset($this->num_paiement)) { - $this->num_paiement = trim($this->num_paiement); - } // deprecated if (isset($this->num_payment)) { $this->num_payment = trim($this->num_payment); } @@ -344,7 +336,7 @@ class PaymentSalary extends CommonObject $sql .= " t.fk_typepayment,"; $sql .= " t.num_payment as num_payment,"; $sql .= " t.note,"; - $sql .= " t.fk_bank,"; + $sql .= " t.fk_bank as bank_line,"; $sql .= " t.fk_user_author,"; $sql .= " t.fk_user_modif,"; $sql .= " pt.code as type_code, pt.libelle as type_label,"; @@ -370,19 +362,21 @@ class PaymentSalary extends CommonObject $this->datep = $this->db->jdate($obj->datep); $this->amount = $obj->amount; $this->fk_typepayment = $obj->fk_typepayment; - $this->num_paiement = $obj->num_payment; $this->num_payment = $obj->num_payment; $this->note = $obj->note; $this->note_private = $obj->note; - $this->fk_bank = $obj->fk_bank; $this->fk_user_author = $obj->fk_user_author; $this->fk_user_modif = $obj->fk_user_modif; + $this->user_modification_id = $obj->fk_user_modif; $this->type_code = $obj->type_code; $this->type_label = $obj->type_label; - $this->bank_account = $obj->fk_account; - $this->bank_line = $obj->fk_bank; + $this->bank_account = $obj->fk_account; + $this->fk_account = $obj->fk_account; + + $this->fk_bank = $obj->bank_line; + $this->bank_line = $obj->bank_line; } $this->db->free($resql); @@ -417,9 +411,6 @@ class PaymentSalary extends CommonObject if (isset($this->fk_typepayment)) { $this->fk_typepayment = (int) $this->fk_typepayment; } - if (isset($this->num_paiement)) { - $this->num_paiement = trim($this->num_paiement); - } // deprecated if (isset($this->num_payment)) { $this->num_payment = trim($this->num_payment); } @@ -495,10 +486,10 @@ class PaymentSalary extends CommonObject if ($this->bank_line > 0) { $accline = new AccountLine($this->db); - $accline->fetch($this->bank_line); + $accline->fetch((int) $this->bank_line); $result = $accline->delete($user); if ($result < 0) { - $this->errors[] = $accline->error; + $this->setErrorsFromObject($accline); $error++; } } @@ -621,7 +612,7 @@ class PaymentSalary extends CommonObject global $langs; // Clean data - $this->num_payment = trim($this->num_payment ? $this->num_payment : $this->num_paiement); + $this->num_payment = trim((string) $this->num_payment); $error = 0; @@ -887,16 +878,16 @@ class PaymentSalary extends CommonObject $url = DOL_URL_ROOT.'/salaries/payment_salary/card.php?id='.$this->id; - if ($option !== 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { - $add_save_lastsearch_values = 1; - } - if ($url && $add_save_lastsearch_values) { - $url .= '&save_lastsearch_values=1'; - } - } + // if ($option !== 'nolink') { + // // Add param to save lastsearch_values or not + // $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + // if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + // $add_save_lastsearch_values = 1; + // } + // if ($url && $add_save_lastsearch_values) { + // $url .= '&save_lastsearch_values=1'; + // } + // } $linkclose = ''; if (empty($notooltip)) { @@ -910,17 +901,19 @@ class PaymentSalary extends CommonObject $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } - if ($option == 'nolink' || empty($url)) { - $linkstart = ''; - if ($option == 'nolink' || empty($url)) { - $linkend = ''; - } else { - $linkend = ''; - } + // if ($option == 'nolink') { + // $linkstart = ''; + // if ($option == 'nolink') { + // $linkend = ''; + // } else { + // $linkend = ''; + // } + $linkstart = 'picto); $return .= ''; $return .= '
'; - $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + $return .= '' . $this->getNomUrl(1) . ''; if ($selected >= 0) { $return .= ''; } - if (property_exists($this, 'fk_bank') && is_numeric($this->fk_bank)) { + if (!empty($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') && is_numeric($this->fk_user_author)) { + if (!empty($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')) { + if (!empty($this->fk_typepayment)) { $return .= '
'.$langs->trans("PaymentMode").' : '.$this->fk_typepayment.''; } - if (property_exists($this, 'amount')) { - $return .= '
'.$langs->trans("Amount").' : '.price($this->amount).''; - } + $return .= '
'.$langs->trans("Amount").' : '.price($this->amount).''; $return .= '
'; $return .= ''; $return .= ''; diff --git a/htdocs/salaries/payment_salary/card.php b/htdocs/salaries/payment_salary/card.php index d6559320b12..c6791a07796 100644 --- a/htdocs/salaries/payment_salary/card.php +++ b/htdocs/salaries/payment_salary/card.php @@ -6,7 +6,7 @@ * Copyright (C) 2021 Gauthier VERDOL * Copyright (C) 2024 MDW * Copyright (C) 2024 Alexandre SPANGARO - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024-2025 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 @@ -184,9 +184,9 @@ print ''.$langs->trans('Note').'bank_account) { + if ($object->bank_account && isset($object->bank_line)) { $bankline = new AccountLine($db); - $bankline->fetch($object->bank_line); + $bankline->fetch((int) $object->bank_line); print ''; print ''.$langs->trans('BankTransactionLine').'';