From 88a1eadfc7893084232dce9277e065fdcad5492e Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Wed, 20 Nov 2024 19:50:07 +0100 Subject: [PATCH 1/4] fix: php warning (#32020) * fix: php warning * fix php warning * fix php warning --- htdocs/admin/mails.php | 2 +- htdocs/comm/action/card.php | 4 ++-- htdocs/comm/action/peruser.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index ab8695e871b..7808ff615d3 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -511,7 +511,7 @@ if ($action == 'edit') { // SuperAdministrator access only if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) { - print $form->selectarray('MAIN_MAIL_SMTPS_OAUTH_SERVICE', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE); + print $form->selectarray('MAIN_MAIL_SMTPS_OAUTH_SERVICE', $oauthservices, getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE')); } else { $text = $oauthservices[getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE')]; if (empty($text)) { diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index d37b799493c..30c71c6e01a 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1963,8 +1963,8 @@ if ($id > 0) { 'type' => 'user', //'transparency'=>$object->userassigned[$user->id]['transparency'], 'transparency' => $object->transparency, // Force transparency on ownerfrom event - 'answer_status' => $object->userassigned[$object->userownerid]['answer_status'], - 'mandatory' => $object->userassigned[$object->userownerid]['mandatory'] + 'answer_status' => (isset($object->userassigned[$object->userownerid]['answer_status']) ? $object->userassigned[$object->userownerid]['answer_status']: null), + 'mandatory' => (isset($object->userassigned[$object->userownerid]['mandatory']) ? $object->userassigned[$object->userownerid]['mandatory']:null) ); } if (!empty($object->userassigned)) { // Now concat assigned users diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 6abe480da9c..56b758f64a6 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -1426,7 +1426,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $tmpcontact->fetch($event->contact_id); $cachecontacts[$event->contact_id] = $tmpcontact; } - $cases2[$h][$event->id]['string'] .= ', '.$cachecontacts[$event->contact_id]->getFullName($langs); + $cases3[$h][$event->id]['string'] .= ', '.$cachecontacts[$event->contact_id]->getFullName($langs); } } if ($event->date_start_in_calendar < $c && $dateendtouse > $b2) { From 0b81375f0077ff16ee9e45b527e02f458e834791 Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller <45882981+Hystepik@users.noreply.github.com> Date: Wed, 20 Nov 2024 20:58:11 +0100 Subject: [PATCH 2/4] fix missing require in various_payment card (#32015) Co-authored-by: Hystepik --- htdocs/compta/bank/various_payment/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 0eeab1735c3..bf05e2c9040 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -29,6 +29,7 @@ require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; From 9191c216f3c95a8349f2878507f5fe131228b4e2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 20 Nov 2024 22:49:59 +0100 Subject: [PATCH 3/4] Fix to make protection ok when no stock and STOCK_ALLOW_NEGATIVE_TRANSFER on --- htdocs/product/stock/class/mouvementstock.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index fd7ea010270..60cd678ba36 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -446,7 +446,7 @@ class MouvementStock extends CommonObject return -8; } } else { - if (isset($product->stock_warehouse[$entrepot_id]) && (empty($product->stock_warehouse[$entrepot_id]->real) || $product->stock_warehouse[$entrepot_id]->real < abs($qty))) { + if (empty($product->stock_warehouse[$entrepot_id]) || empty($product->stock_warehouse[$entrepot_id]->real) || $product->stock_warehouse[$entrepot_id]->real < abs($qty)) { $langs->load("stocks"); $this->error = $langs->trans('qtyToTranferIsNotEnough').' : '.$product->ref; $this->errors[] = $langs->trans('qtyToTranferIsNotEnough').' : '.$product->ref; From 4a3edf9294aec3daca8301169291b24049357346 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 20 Nov 2024 22:49:59 +0100 Subject: [PATCH 4/4] Fix to make protection ok when no stock and STOCK_ALLOW_NEGATIVE_TRANSFER on --- htdocs/comm/action/class/actioncomm.class.php | 133 +++++++++--------- 1 file changed, 69 insertions(+), 64 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 3ca29e1af4e..0b0e6d73db9 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -2702,82 +2702,87 @@ class ActionComm extends CommonObject // Load event $res = $this->fetch($actionCommReminder->fk_actioncomm); - if ($res > 0) $res = $this->fetch_thirdparty(); if ($res > 0) { - // PREPARE EMAIL - $errormesg = ''; + $res2 = $this->fetch_thirdparty(); + if ($res2 >= 0) { + // PREPARE EMAIL + $errormesg = ''; - // Make substitution in email content - $substitutionarray = getCommonSubstitutionArray($langs, 0, '', $this); + // Make substitution in email content + $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $this); - complete_substitutions_array($substitutionarray, $langs, $this); + complete_substitutions_array($substitutionarray, $langs, $this); - // Content - $sendContent = make_substitutions($langs->trans($arraymessage->content), $substitutionarray); + // Content + $sendContent = make_substitutions($langs->trans($arraymessage->content), $substitutionarray); - //Topic - $sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->transnoentities('EventReminder')); + //Topic + $sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->transnoentities('EventReminder')); - // Recipient - $recipient = new User($this->db); - $res = $recipient->fetch($actionCommReminder->fk_user); - if ($res > 0) { - if (!empty($recipient->email)) { - $to = $recipient->email; + // Recipient + $recipient = new User($this->db); + $res = $recipient->fetch($actionCommReminder->fk_user); + if ($res > 0) { + if (!empty($recipient->email)) { + $to = $recipient->email; + } else { + $errormesg = "Failed to send remind to user id=".$actionCommReminder->fk_user.". No email defined for user."; + $error++; + } } else { - $errormesg = "Failed to send remind to user id=".$actionCommReminder->fk_user.". No email defined for user."; + $errormesg = "Failed to load recipient with user id=".$actionCommReminder->fk_user; $error++; } + + // Sender + $from = getDolGlobalString('MAIN_MAIL_EMAIL_FROM'); + if (empty($from)) { + $errormesg = "Failed to get sender into global setup MAIN_MAIL_EMAIL_FROM"; + $error++; + } + + if (!$error) { + // Errors Recipient + $errors_to = getDolGlobalString('MAIN_MAIL_ERRORS_TO'); + + // Mail Creation + $cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', '', '', '', ''); + + // Sending Mail + if ($cMailFile->sendfile()) { + $nbMailSend++; + } else { + $errormesg = 'Failed to send email to: '.$to.' '.$cMailFile->error.implode(',', $cMailFile->errors); + $error++; + } + } + + if (!$error) { + $actionCommReminder->status = $actionCommReminder::STATUS_DONE; + + $res = $actionCommReminder->update($user); + if ($res < 0) { + $errorsMsg[] = "Failed to update status to done of ActionComm Reminder"; + $error++; + break; // This is to avoid to have this error on all the selected email. If we fails here for one record, it may fails for others. We must solve first. + } + } else { + $actionCommReminder->status = $actionCommReminder::STATUS_ERROR; + $actionCommReminder->lasterror = dol_trunc($errormesg, 128, 'right', 'UTF-8', 1); + + $res = $actionCommReminder->update($user); + if ($res < 0) { + $errorsMsg[] = "Failed to update status to error of ActionComm Reminder"; + $error++; + break; // This is to avoid to have this error on all the selected email. If we fails here for one record, it may fails for others. We must solve first. + } else { + $errorsMsg[] = $errormesg; + } + } } else { - $errormesg = "Failed to load recipient with user id=".$actionCommReminder->fk_user; + $errorsMsg[] = 'Failed to fetch record thirdparty on actioncomm with ID = '.$actionCommReminder->fk_actioncomm; $error++; } - - // Sender - $from = getDolGlobalString('MAIN_MAIL_EMAIL_FROM'); - if (empty($from)) { - $errormesg = "Failed to get sender into global setup MAIN_MAIL_EMAIL_FROM"; - $error++; - } - - if (!$error) { - // Errors Recipient - $errors_to = getDolGlobalString('MAIN_MAIL_ERRORS_TO'); - - // Mail Creation - $cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', '', '', '', ''); - - // Sending Mail - if ($cMailFile->sendfile()) { - $nbMailSend++; - } else { - $errormesg = 'Failed to send email to: '.$to.' '.$cMailFile->error.implode(',', $cMailFile->errors); - $error++; - } - } - - if (!$error) { - $actionCommReminder->status = $actionCommReminder::STATUS_DONE; - - $res = $actionCommReminder->update($user); - if ($res < 0) { - $errorsMsg[] = "Failed to update status to done of ActionComm Reminder"; - $error++; - break; // This is to avoid to have this error on all the selected email. If we fails here for one record, it may fails for others. We must solve first. - } - } else { - $actionCommReminder->status = $actionCommReminder::STATUS_ERROR; - $actionCommReminder->lasterror = dol_trunc($errormesg, 128, 'right', 'UTF-8', 1); - - $res = $actionCommReminder->update($user); - if ($res < 0) { - $errorsMsg[] = "Failed to update status to error of ActionComm Reminder"; - $error++; - break; // This is to avoid to have this error on all the selected email. If we fails here for one record, it may fails for others. We must solve first. - } else { - $errorsMsg[] = $errormesg; - } - } } else { $errorsMsg[] = 'Failed to fetch record actioncomm with ID = '.$actionCommReminder->fk_actioncomm; $error++;