From 82010e7a60ef774792edb8116acbea6ba156ef0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 15 Oct 2025 18:56:13 +0200 Subject: [PATCH] fix CI payment_salary.php (#35767) * fix CI payment_salary.php * Update baseline.txt * Update phpstan-baseline.neon --- dev/build/phpstan/phpstan-baseline.neon | 4 +- dev/tools/phan/baseline.txt | 2 +- htdocs/salaries/payment_salary.php | 69 ++++++++++++------------- 3 files changed, 35 insertions(+), 40 deletions(-) diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index 18c0d0eeb6d..f459132b105 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -15850,13 +15850,13 @@ parameters: message: '#^Comparison operation "\>" between 1 and 1 is always false\.$#' identifier: greater.alwaysFalse count: 1 - path: ../../../htdocs/salaries/paiement_salary.php + path: ../../../htdocs/salaries/payment_salary.php - message: '#^Negated boolean expression is always true\.$#' identifier: booleanNot.alwaysTrue count: 2 - path: ../../../htdocs/salaries/paiement_salary.php + path: ../../../htdocs/salaries/payment_salary.php - message: '#^Negated boolean expression is always false\.$#' diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 08c4603f85e..8c6712b16bd 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -253,7 +253,7 @@ return [ 'htdocs/recruitment/recruitmentjobposition_card.php' => ['PhanUndeclaredProperty'], 'htdocs/recruitment/recruitmentjobposition_document.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/recruitment/recruitmentjobposition_note.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], - 'htdocs/salaries/paiement_salary.php' => ['PhanUndeclaredProperty'], + 'htdocs/salaries/payment_salary.php' => ['PhanUndeclaredProperty'], 'htdocs/salaries/virement_request.php' => ['PhanUndeclaredProperty'], 'htdocs/societe/ajax/company.php' => ['PhanUndeclaredProperty'], 'htdocs/societe/class/societe.class.php' => ['PhanTypeMismatchProperty'], diff --git a/htdocs/salaries/payment_salary.php b/htdocs/salaries/payment_salary.php index 06301af8a23..bcf7cd4768d 100644 --- a/htdocs/salaries/payment_salary.php +++ b/htdocs/salaries/payment_salary.php @@ -109,48 +109,43 @@ if (($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == ' if (!$error) { $paymentid = 0; + $db->begin(); + + // Create a line of payments + $paiement = new PaymentSalary($db); + $paiement->fk_salary = $id; + $paiement->chid = $id; // deprecated + $paiement->datep = $datepaye; + $paiement->amounts = $amounts; // Tableau de montant + $paiement->fk_typepayment = GETPOSTINT("paiementtype"); + $paiement->num_payment = GETPOST("num_payment", 'alphanohtml'); + $paiement->note = GETPOST("note", 'restricthtml'); + $paiement->note_private = GETPOST("note", 'restricthtml'); + + $paymentid = $paiement->create($user, (GETPOST('closepaidsalary') == 'on' ? 1 : 0)); + if ($paymentid < 0) { + $error++; + setEventMessages($paiement->error, null, 'errors'); + $action = 'create'; + } if (!$error) { - $db->begin(); + $result = $paiement->addPaymentToBank($user, 'payment_salary', '(SalaryPayment)', GETPOSTINT('accountid'), '', ''); - // Create a line of payments - $paiement = new PaymentSalary($db); - $paiement->fk_salary = $id; - $paiement->chid = $id; // deprecated - $paiement->datep = $datepaye; - $paiement->amounts = $amounts; // Tableau de montant - $paiement->fk_typepayment = GETPOSTINT("paiementtype"); - $paiement->num_payment = GETPOST("num_payment", 'alphanohtml'); - $paiement->note = GETPOST("note", 'restricthtml'); - $paiement->note_private = GETPOST("note", 'restricthtml'); - - if (!$error) { - $paymentid = $paiement->create($user, (GETPOST('closepaidsalary') == 'on' ? 1 : 0)); - if ($paymentid < 0) { - $error++; - setEventMessages($paiement->error, null, 'errors'); - $action = 'create'; - } + if (!($result > 0)) { + $error++; + setEventMessages($paiement->error, null, 'errors'); + $action = 'create'; } + } - if (!$error) { - $result = $paiement->addPaymentToBank($user, 'payment_salary', '(SalaryPayment)', GETPOSTINT('accountid'), '', ''); - - if (!($result > 0)) { - $error++; - setEventMessages($paiement->error, null, 'errors'); - $action = 'create'; - } - } - - if (!$error) { - $db->commit(); - $loc = DOL_URL_ROOT.'/salaries/card.php?id='.$id; - header('Location: '.$loc); - exit; - } else { - $db->rollback(); - } + if (!$error) { + $db->commit(); + $loc = DOL_URL_ROOT.'/salaries/card.php?id='.$id; + header('Location: '.$loc); + exit; + } else { + $db->rollback(); } } }