From 17dfec8ee46ee8941665285018c9556e520fc33b Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Tue, 1 Apr 2025 18:44:45 +0200 Subject: [PATCH 1/3] FIX Edit of payment mode from the bank transfer tab of salary --- htdocs/salaries/virement_request.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/htdocs/salaries/virement_request.php b/htdocs/salaries/virement_request.php index de001535e3f..a44cdc3914e 100644 --- a/htdocs/salaries/virement_request.php +++ b/htdocs/salaries/virement_request.php @@ -161,6 +161,23 @@ if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } +// payment mode +if ($action == 'setmode' && $permissiontoadd) { + $object->fetch($id); + $result = $object->setPaymentMethods(GETPOSTINT('mode_reglement_id')); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } +} + +// bank account +if ($action == 'setbankaccount' && $permissiontoadd) { + $object->fetch($id); + $result = $object->setBankAccount(GETPOSTINT('fk_account')); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } +} if ($action == "add" && $permissiontoadd) { //var_dump($object);exit; From 16c76a6505e18eedfccde1d778bea9feb03cf932 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Tue, 1 Apr 2025 18:50:12 +0200 Subject: [PATCH 2/3] FIX The payment mode for salary on credit transfer must be credit transfer --- htdocs/salaries/class/salary.class.php | 2 +- htdocs/salaries/virement_request.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index da4fed65b02..69b55a9406c 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -997,7 +997,7 @@ class Salary extends CommonObject if (!$error) { // Force payment mode of invoice to withdraw - $payment_mode_id = dol_getIdFromCode($this->db, ($type == 'bank-transfer' ? 'VIR' : 'PRE'), 'c_paiement', 'code', 'id', 1); + $payment_mode_id = dol_getIdFromCode($this->db, (($type == 'bank-transfer' || $type == 'salaire') ? 'VIR' : 'PRE'), 'c_paiement', 'code', 'id', 1); if ($payment_mode_id > 0) { $result = $this->setPaymentMethods($payment_mode_id); } diff --git a/htdocs/salaries/virement_request.php b/htdocs/salaries/virement_request.php index a44cdc3914e..d4077bf0937 100644 --- a/htdocs/salaries/virement_request.php +++ b/htdocs/salaries/virement_request.php @@ -186,7 +186,8 @@ if ($action == "add" && $permissiontoadd) { $sourcetype = 'salaire'; $newtype = 'salaire'; - $paymentservice = GETPOST('paymentservice'); + $paymentservice = GETPOST('paymentservice'); // value can be 'stripesepa'. not used yet. + $result = $object->demande_prelevement($user, price2num(GETPOST('request_transfer', 'alpha')), $newtype, $sourcetype); if ($result > 0) { From 62fba4f84d4c424c0000feb3c5a0341dd2d8c0ce Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Tue, 1 Apr 2025 19:23:47 +0200 Subject: [PATCH 3/3] Add missing try catch --- htdocs/core/class/translate.class.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 1151ec349cc..1e046425a2a 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -705,6 +705,7 @@ class Translate try { // @phan-suppress-next-line PhanPluginPrintfVariableFormatString $str = sprintf($str, $param1, $param2, $param3, $param4); // Replace %s and %d except for FormatXXX strings. + // Note: the catch ValueError is possible only when php min will be 8.1 } catch (Exception $e) { // No exception managed } @@ -790,9 +791,13 @@ class Translate } if (!preg_match('/^Format/', $key)) { - //print $str; - // @phan-suppress-next-line PhanPluginPrintfVariableFormatString - $str = sprintf($str, $param1, $param2, $param3, $param4, $param5); // Replace %s and %d except for FormatXXX strings. + try { + // @phan-suppress-next-line PhanPluginPrintfVariableFormatString + $str = sprintf($str, $param1, $param2, $param3, $param4, $param5); // Replace %s and %d except for FormatXXX strings. + // Note: the catch ValueError is possible only when php min will be 8.1 + } catch (Exception $e) { + // No exception managed. + } } // Remove dangerous sequence we should never have. Not needed into a translated response.