From f7f64651c9d9b2c6a1a8b7cd47662b3927c3352c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Mar 2024 21:52:45 +0100 Subject: [PATCH 01/17] Fix bad merge --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index d39fb128007..7609da636fe 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -895,7 +895,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl $checkonentitydone = 0; // Array to define rules of checks to do - $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'payment_sc', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website', 'recruitment', 'chargesociales', 'knowledgemanagement')); // Test on entity only (Objects with no link to company) + $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'payment_sc', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website', 'recruitment', 'chargesociales', 'knowledgemanagement'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for object Societe $checkparentsoc = array('agenda', 'contact', 'contrat'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet', 'project'); // Test for project object From aadd5376aa7c7a0dbc1c57f814e7d69edcaccb42 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Mar 2024 00:47:32 +0100 Subject: [PATCH 02/17] FIX Inline edition not implemented --- htdocs/accountancy/admin/fiscalyear_card.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index ee587a31f96..06dc52d3247 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -313,23 +313,23 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Label print ''; - print $form->editfieldkey("Label", 'label', $object->label, $object, 1, 'alpha:32'); + print $form->editfieldkey("Label", 'label', $object->label, $object, 0, 'alpha:32'); print ''; - print $form->editfieldval("Label", 'label', $object->label, $object, 1, 'alpha:32'); + print $form->editfieldval("Label", 'label', $object->label, $object, 0, 'alpha:32'); print ""; // Date start print ''; - print $form->editfieldkey("DateStart", 'date_start', $object->date_start, $object, 1, 'datepicker'); + print $form->editfieldkey("DateStart", 'date_start', $object->date_start, $object, 0, 'datepicker'); print ''; - print $form->editfieldval("DateStart", 'date_start', $object->date_start, $object, 1, 'datepicker'); + print $form->editfieldval("DateStart", 'date_start', $object->date_start, $object, 0, 'datepicker'); print ''; // Date end print ''; - print $form->editfieldkey("DateEnd", 'date_end', $object->date_end, $object, 1, 'datepicker'); + print $form->editfieldkey("DateEnd", 'date_end', $object->date_end, $object, 0, 'datepicker'); print ''; - print $form->editfieldval("DateEnd", 'date_end', $object->date_end, $object, 1, 'datepicker'); + print $form->editfieldval("DateEnd", 'date_end', $object->date_end, $object, 0, 'datepicker'); print ''; // Status From ae3847dc38c27c40b6267fe6a430a63bb895656d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Mar 2024 00:48:51 +0100 Subject: [PATCH 03/17] FIX Manual deletion of a bookkeeping line Conflicts: htdocs/accountancy/class/bookkeeping.class.php --- .../accountancy/class/bookkeeping.class.php | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 9075c241e3b..97387198fcd 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -758,11 +758,10 @@ class BookKeeping extends CommonObject /** * Load object in memory from the database * - * @param int $id Id object - * @param string $ref Ref - * @param string $mode Mode - * - * @return int Return integer <0 if KO, 0 if not found, >0 if OK + * @param int $id Id object + * @param string $ref Ref + * @param string $mode Mode ('' or 'tmp_') + * @return int Return integer <0 if KO, 0 if not found, >0 if OK */ public function fetch($id, $ref = null, $mode = '') { @@ -1491,17 +1490,18 @@ class BookKeeping extends CommonObject /** * Delete object in database * - * @param User $user User that deletes - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @param string $mode Mode - * @return int Return integer <0 if KO, >0 if OK + * @param User $user User that deletes + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @param string $mode Mode ('' or 'tmp_') + * @return int Return integer <0 if KO, >0 if OK */ - public function delete(User $user, $notrigger = false, $mode = '') + public function delete(User $user, $notrigger = 0, $mode = '') { global $langs; + dol_syslog(__METHOD__, LOG_DEBUG); - $result = $this->canModifyBookkeeping($this->id); + $result = $this->canModifyBookkeeping($this->id, $mode); if ($result < 0) { return -1; } elseif ($result == 0) { @@ -2303,9 +2303,10 @@ class BookKeeping extends CommonObject * Is the bookkeeping can be modified or deleted ? * * @param int $id Bookkeeping ID + * @param string $mode Mode ('' or 'tmp_') * @return int Return integer <0 if KO, == 0 if No, == 1 if Yes */ - public function canModifyBookkeeping($id) + public function canModifyBookkeeping($id, $mode = '') { global $conf; @@ -2317,7 +2318,7 @@ class BookKeeping extends CommonObject } $bookkeeping = new BookKeeping($this->db); - $result = $bookkeeping->fetch($id); + $result = $bookkeeping->fetch($id, null, $mode); if ($result <= 0) { return $result; } @@ -2338,7 +2339,7 @@ class BookKeeping extends CommonObject } $bookkeeping = new BookKeeping($this->db); - $result = $bookkeeping->fetch($id); + $result = $bookkeeping->fetch($id, null, $mode); if ($result <= 0) { return $result; } From 07d12c48e9286cc685215c90e75eea9e503a48a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Mar 2024 00:49:45 +0100 Subject: [PATCH 04/17] FIX Bad management on error creation of bookkeeping Conflicts: htdocs/accountancy/bookkeeping/card.php --- htdocs/accountancy/bookkeeping/card.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 7d42cb64a00..a2a617502bf 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -204,6 +204,8 @@ if ($action == "confirm_update") { $result = $object->createStd($user, false, $mode); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); + + $action = 'create'; } else { if ($mode != '_tmp') { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); @@ -404,6 +406,7 @@ if ($action == 'create') { print ''; } else { $object = new BookKeeping($db); + $result = $object->fetchPerMvt($piece_num, $mode); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); From 277f49aff62abe31bcb4899549741dc3256e37a5 Mon Sep 17 00:00:00 2001 From: xbloq Date: Mon, 18 Mar 2024 18:28:49 +0100 Subject: [PATCH 05/17] Update card.php #28938 Conflicts: htdocs/compta/prelevement/card.php --- htdocs/compta/prelevement/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 04b59c959ce..ed23a1b454d 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -460,7 +460,7 @@ if ($id > 0 || $ref) { if ($salaryBonPl) { $sql = "SELECT pl.rowid, pl.statut, pl.amount, pl.fk_user,"; $sql .= " u.rowid as socid, u.login as name"; - $sql .=" FROM llx_prelevement_lignes as pl"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as pb"; $sql .= ", ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $id); From db4fbdea716c430850ef6f9ab9daeb6538fa6c82 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Mar 2024 09:19:59 +0100 Subject: [PATCH 06/17] Fix dir for tmp files --- htdocs/core/class/CMailFile.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 3539c62b6cf..2b61913ca49 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1907,7 +1907,8 @@ class CMailFile $extensions = array_keys($this->image_types); if (empty($images_dir)) { - $images_dir = $conf->admin->dir_output.'/temp/'.uniqid('cmailfile'); + //$images_dir = $conf->admin->dir_output.'/temp/'.uniqid('cmailfile'); + $images_dir = $conf->admin->dir_output.'/temp/cmailfile'; } if ($images_dir && !dol_is_dir($images_dir)) { From 43b6d26dd8cf73316d1620a7248604796614348f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Mar 2024 10:31:39 +0100 Subject: [PATCH 07/17] Doc --- htdocs/core/class/CMailFile.class.php | 6 +++--- htdocs/public/payment/paymentok.php | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 2b61913ca49..229375894ae 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -466,7 +466,7 @@ class CMailFile $this->buildCSS(); } $msg = $this->html; - $msg = $this->checkIfHTML($msg); + $msg = $this->checkIfHTML($msg); // This add a header and a body including custom CSS to the HTML content } // Replace . alone on a new line with .. to avoid to have SMTP interpret this as end of message @@ -595,7 +595,7 @@ class CMailFile $this->buildCSS(); } $msg = $this->html; - $msg = $this->checkIfHTML($msg); + $msg = $this->checkIfHTML($msg); // This add a header and a body including custom CSS to the HTML content } if ($this->atleastoneimage) { @@ -1558,7 +1558,7 @@ class CMailFile $strContentAltText = trim(wordwrap($strContentAltText, 75, !getDolGlobalString('MAIN_FIX_FOR_BUGGED_MTA') ? "\r\n" : "\n")); // Check if html header already in message, if not complete the message - $strContent = $this->checkIfHTML($strContent); + $strContent = $this->checkIfHTML($strContent); // This add a header and a body including custom CSS to the HTML content } // Make RFC2045 Compliant, split lines diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 3c710691bdd..d909773d049 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -1286,9 +1286,10 @@ if ($ispaymentok) { } } + $attendeetovalidate = new ConferenceOrBoothAttendee($db); + if (!$error) { // Validating the attendee - $attendeetovalidate = new ConferenceOrBoothAttendee($db); $resultattendee = $attendeetovalidate->fetch((int) $tmptag['ATT']); if ($resultattendee < 0) { $error++; From 33cf4981ab11a32e4b60ea4e31809894beae238f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Mar 2024 10:36:56 +0100 Subject: [PATCH 08/17] Fix warning --- htdocs/paypal/lib/paypalfunctions.lib.php | 8 ++++---- htdocs/public/payment/paymentok.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/paypal/lib/paypalfunctions.lib.php b/htdocs/paypal/lib/paypalfunctions.lib.php index 0403f2c2735..db2ba280d3f 100644 --- a/htdocs/paypal/lib/paypalfunctions.lib.php +++ b/htdocs/paypal/lib/paypalfunctions.lib.php @@ -74,8 +74,8 @@ if (getDolGlobalString('PAYPAL_API_SANDBOX')) { } // Proxy -$PROXY_HOST = $conf->global->MAIN_PROXY_HOST; -$PROXY_PORT = $conf->global->MAIN_PROXY_PORT; -$PROXY_USER = $conf->global->MAIN_PROXY_USER; -$PROXY_PASS = $conf->global->MAIN_PROXY_PASS; +$PROXY_HOST = getDolGlobalString('MAIN_PROXY_HOST'); +$PROXY_PORT = getDolGlobalString('MAIN_PROXY_PORT'); +$PROXY_USER = getDolGlobalString('MAIN_PROXY_USER'); +$PROXY_PASS = getDolGlobalString('MAIN_PROXY_PASS'); $USE_PROXY = !getDolGlobalString('MAIN_PROXY_USE') ? false : true; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index d909773d049..a56d291644c 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -360,10 +360,10 @@ if ($reshook >= 0) { // If data not provided into callback url, search them into the session env if (empty($ipaddress)) { - $ipaddress = $_SESSION['ipaddress']; + $ipaddress = $_SESSION['ipaddress']; } if (empty($TRANSACTIONID)) { - $TRANSACTIONID = $_SESSION['TRANSACTIONID']; // pi_... or ch_... + $TRANSACTIONID = empty($_SESSION['TRANSACTIONID']) ? '' :$_SESSION['TRANSACTIONID']; // pi_... or ch_... if (empty($TRANSACTIONID) && GETPOST('payment_intent', 'alphanohtml')) { // For the case we use STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = 2 $TRANSACTIONID = GETPOST('payment_intent', 'alphanohtml'); @@ -377,7 +377,7 @@ if (empty($currencyCodeType)) { } // Seems used onyl by Paypal if (empty($paymentType)) { - $paymentType = $_SESSION["paymentType"]; + $paymentType = $_SESSION["paymentType"]; } $fulltag = $FULLTAG; From ddbec72c9ae8f758893c9eea0be4a1936f4b1899 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Mar 2024 10:38:49 +0100 Subject: [PATCH 09/17] Fix warning --- htdocs/public/payment/paymentok.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index a56d291644c..b84fe84cc3c 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -84,14 +84,14 @@ if (isModEnabled('paypal')) { if (getDolGlobalString('PAYPAL_API_SANDBOX')) { $PAYPAL_API_SANDBOX = $conf->global->PAYPAL_API_SANDBOX; } - $PAYPAL_API_OK = ""; + /*$PAYPAL_API_OK = ""; if ($urlok) { $PAYPAL_API_OK = $urlok; } $PAYPAL_API_KO = ""; if ($urlko) { $PAYPAL_API_KO = $urlko; - } + }*/ $PAYPALTOKEN = GETPOST('TOKEN'); if (empty($PAYPALTOKEN)) { From cc78decc0cb09fc26949c1750b1d80f9abbc0d7e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Mar 2024 10:43:59 +0100 Subject: [PATCH 10/17] Fix warning --- htdocs/public/payment/paymentok.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index b84fe84cc3c..0eb24d7b729 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -370,14 +370,14 @@ if (empty($TRANSACTIONID)) { } } if (empty($FinalPaymentAmt)) { - $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; + $FinalPaymentAmt = empty($_SESSION["FinalPaymentAmt"]) ? '' : $_SESSION["FinalPaymentAmt"]; } if (empty($currencyCodeType)) { - $currencyCodeType = $_SESSION['currencyCodeType']; + $currencyCodeType = empty($_SESSION['currencyCodeType']) ? '' : $_SESSION['currencyCodeType']; } -// Seems used onyl by Paypal +// Seems used only by Paypal if (empty($paymentType)) { - $paymentType = $_SESSION["paymentType"]; + $paymentType = empty($_SESSION["paymentType"]) ? '' : $_SESSION["paymentType"]; } $fulltag = $FULLTAG; From cd1b0abd91cfcc40b5a249cc1d799399a68de9a4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Mar 2024 10:46:45 +0100 Subject: [PATCH 11/17] Fix warnings --- htdocs/public/payment/paymentok.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 0eb24d7b729..a40974c2403 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -1749,9 +1749,9 @@ if ($ispaymentok) { $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION['onlinetoken'] : $PAYPALTOKEN; $payerID = empty($PAYPALPAYERID) ? $_SESSION['payerID'] : $PAYPALPAYERID; // Set by newpayment.php - $currencyCodeType = $_SESSION['currencyCodeType']; - $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; - $paymentType = $_SESSION['PaymentType']; // Seems used by paypal only + $currencyCodeType = empty($_SESSION['currencyCodeType']) ? '' : $_SESSION['currencyCodeType']; + $FinalPaymentAmt = empty($_SESSION["FinalPaymentAmt"]) ? '': $_SESSION["FinalPaymentAmt"]; + $paymentType = empty($_SESSION['PaymentType']) ? '' : $_SESSION['PaymentType']; // Seems used by paypal only if (is_object($object) && method_exists($object, 'call_trigger')) { // Call trigger From edbc4b37816da9132918bee53a44ac584f306cc6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Mar 2024 10:51:42 +0100 Subject: [PATCH 12/17] Fix fatal error --- htdocs/core/class/CMailFile.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 229375894ae..263ad6ebd3e 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -33,6 +33,7 @@ use OAuth\Common\Storage\DoliStorage; use OAuth\Common\Consumer\Credentials; + /** * Class to send emails (with attachments or not) * Usage: $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to,$css,$trackid,$moreinheader,$sendcontext,$replyto); @@ -1903,6 +1904,8 @@ class CMailFile { global $conf; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + // Build the array of image extensions $extensions = array_keys($this->image_types); From 07c84df3dcd5221295fae62829fba1f3712c9554 Mon Sep 17 00:00:00 2001 From: Kamel Khelifa Date: Tue, 19 Mar 2024 14:23:02 +0100 Subject: [PATCH 13/17] FIX: Move the trigger for delete order line before the SQL request --- htdocs/commande/class/commande.class.php | 88 ++++++++++++------------ 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 3ab9910376c..742ee65b42f 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -4398,20 +4398,20 @@ class OrderLine extends CommonOrderLine $error = 0; - if (empty($this->id) && !empty($this->rowid)) { // For backward compatibility + if (empty($this->id) && !empty($this->rowid)) { // For backward compatibility $this->id = $this->rowid; } // check if order line is not in a shipment line before deleting - $sqlCheckShipmentLine = "SELECT"; + $sqlCheckShipmentLine = "SELECT"; $sqlCheckShipmentLine .= " ed.rowid"; - $sqlCheckShipmentLine .= " FROM ".MAIN_DB_PREFIX."expeditiondet ed"; - $sqlCheckShipmentLine .= " WHERE ed.fk_origin_line = ".((int) $this->id); + $sqlCheckShipmentLine .= " FROM " . MAIN_DB_PREFIX . "expeditiondet ed"; + $sqlCheckShipmentLine .= " WHERE ed.fk_origin_line = " . ((int)$this->id); $resqlCheckShipmentLine = $this->db->query($sqlCheckShipmentLine); if (!$resqlCheckShipmentLine) { $error++; - $this->error = $this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->errors[] = $this->error; } else { $langs->load('errors'); @@ -4419,56 +4419,58 @@ class OrderLine extends CommonOrderLine if ($num > 0) { $error++; $objCheckShipmentLine = $this->db->fetch_object($resqlCheckShipmentLine); - $this->error = $langs->trans('ErrorRecordAlreadyExists').' : '.$langs->trans('ShipmentLine').' '.$objCheckShipmentLine->rowid; + $this->error = $langs->trans('ErrorRecordAlreadyExists') . ' : ' . $langs->trans('ShipmentLine') . ' ' . $objCheckShipmentLine->rowid; $this->errors[] = $this->error; } $this->db->free($resqlCheckShipmentLine); } if ($error) { - dol_syslog(__METHOD__.'Error ; '.$this->error, LOG_ERR); + dol_syslog(__METHOD__ . 'Error ; ' . $this->error, LOG_ERR); return -1; } $this->db->begin(); - $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid = ".((int) $this->id); - - dol_syslog("OrderLine::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('LINEORDER_DELETE', $user); - if ($result < 0) { - $error++; - } - // End call triggers + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('LINEORDER_DELETE', $user); + if ($result < 0) { + $error++; } - - // Remove extrafields - if (!$error) { - $result = $this->deleteExtraFields(); - if ($result < 0) { - $error++; - dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); - } - } - - if (!$error) { - $this->db->commit(); - return 1; - } - - foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); - } - $this->db->rollback(); - return -1 * $error; - } else { - $this->error = $this->db->lasterror(); - return -1; + // End call triggers } + + if (!$error) { + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . "commandedet WHERE rowid = " . ((int)$this->id); + + dol_syslog("OrderLine::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $this->error = $this->db->lasterror(); + $error++; + } + } + + // Remove extrafields + if (!$error) { + $result = $this->deleteExtraFields(); + if ($result < 0) { + $error++; + dol_syslog(get_class($this) . "::delete error -4 " . $this->error, LOG_ERR); + } + } + + if (!$error) { + $this->db->commit(); + return 1; + } + + foreach ($this->errors as $errmsg) { + dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); + $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; } /** From 426e18ea336b5c151cc4a4bbca40eed23c686bd5 Mon Sep 17 00:00:00 2001 From: Kamel Khelifa Date: Tue, 19 Mar 2024 14:31:15 +0100 Subject: [PATCH 14/17] Correction syntax --- htdocs/commande/class/commande.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 742ee65b42f..410713d7c12 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -4406,7 +4406,7 @@ class OrderLine extends CommonOrderLine $sqlCheckShipmentLine = "SELECT"; $sqlCheckShipmentLine .= " ed.rowid"; $sqlCheckShipmentLine .= " FROM " . MAIN_DB_PREFIX . "expeditiondet ed"; - $sqlCheckShipmentLine .= " WHERE ed.fk_origin_line = " . ((int)$this->id); + $sqlCheckShipmentLine .= " WHERE ed.fk_origin_line = " . ((int) $this->id); $resqlCheckShipmentLine = $this->db->query($sqlCheckShipmentLine); if (!$resqlCheckShipmentLine) { @@ -4441,7 +4441,7 @@ class OrderLine extends CommonOrderLine } if (!$error) { - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . "commandedet WHERE rowid = " . ((int)$this->id); + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . "commandedet WHERE rowid = " . ((int) $this->id); dol_syslog("OrderLine::delete", LOG_DEBUG); $resql = $this->db->query($sql); From 6f85a989f002b7983dea3a63d7b8e4f74e570808 Mon Sep 17 00:00:00 2001 From: ATM-Lucas Date: Tue, 19 Mar 2024 14:59:13 +0100 Subject: [PATCH 15/17] Condition on newDateLimReglement --- htdocs/compta/facture/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 4310d340844..b03f36dfbf0 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -456,7 +456,7 @@ if (empty($reshook)) { $object->date = $newdate; $new_date_lim_reglement = $object->calculate_date_lim_reglement(); - if ($new_date_lim_reglement > $old_date_lim_reglement) { + if ($new_date_lim_reglement) { $object->date_lim_reglement = $new_date_lim_reglement; } if ($object->date_lim_reglement < $object->date) { @@ -496,7 +496,7 @@ if (empty($reshook)) { if (!$error) { $old_date_lim_reglement = $object->date_lim_reglement; $new_date_lim_reglement = $object->calculate_date_lim_reglement(); - if ($new_date_lim_reglement > $old_date_lim_reglement) { + if ($new_date_lim_reglement) { $object->date_lim_reglement = $new_date_lim_reglement; } if ($object->date_lim_reglement < $object->date) { From b705dd80948d9a18c8973b769545157dd6302dd1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Mar 2024 19:39:08 +0100 Subject: [PATCH 16/17] NEW Support Reply-To tracking in emails sending (tickets only for the moment) Conflicts: htdocs/core/class/CMailFile.class.php htdocs/ticket/class/ticket.class.php --- htdocs/core/class/CMailFile.class.php | 30 ++++++++++++++++----------- htdocs/core/class/smtps.class.php | 14 +++++-------- htdocs/ticket/class/ticket.class.php | 4 +++- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 48b3690a92f..cc0edeb021d 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -80,19 +80,20 @@ class CMailFile */ public $errors = array(); - public $smtps; // Contains SMTPs object (if this method is used) - public $phpmailer; // Contains PHPMailer object (if this method is used) + + /** + * @var SMTPS (if this method is used) + */ + public $smtps; + /** + * @var Swift_Mailer (if the method is used) + */ + public $mailer; /** * @var Swift_SmtpTransport */ public $transport; - - /** - * @var Swift_Mailer - */ - public $mailer; - /** * @var Swift_Plugins_Loggers_ArrayLogger */ @@ -107,9 +108,13 @@ class CMailFile //! Defined background directly in body tag public $bodyCSS; + /** + * @var string Message-ID of the email to send (generated) + */ public $msgid; public $headers; public $message; + /** * @var array fullfilenames list (full path of filename on file system) */ @@ -513,13 +518,15 @@ class CMailFile //$this->message = new Swift_SignedMessage(); // Adding a trackid header to a message $headers = $this->message->getHeaders(); + $headers->addTextHeader('X-Dolibarr-TRACKID', $this->trackid.'@'.$host); $this->msgid = time().'.swiftmailer-dolibarr-'.$this->trackid.'@'.$host; $headerID = $this->msgid; $msgid = $headers->get('Message-ID'); $msgid->setId($headerID); - $headers->addIdHeader('References', $headerID); - // TODO if (!empty($moreinheader)) ... + + // Add 'References:' header + //$headers->addIdHeader('References', $headerID); // Give the message a subject try { @@ -652,7 +659,6 @@ class CMailFile } } - /** * Send mail that was prepared by constructor. * @@ -1451,7 +1457,7 @@ class CMailFile // References is kept in response and Message-ID is returned into In-Reply-To: $this->msgid = time().'.phpmail-dolibarr-'.$trackid.'@'.$host; $out .= 'Message-ID: <'.$this->msgid.">".$this->eol2; // Uppercase seems replaced by phpmail - $out .= 'References: <'.$this->msgid.">".$this->eol2; + //$out .= 'References: <'.$this->msgid.">".$this->eol2; $out .= 'X-Dolibarr-TRACKID: '.$trackid.'@'.$host.$this->eol2; } else { $this->msgid = time().'.phpmail@'.$host; diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index 0ab9bd3ef8d..cec01ddcac5 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -654,9 +654,8 @@ class SMTPs global $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; - /** - * Default return value - */ + + // Default return value $_retVal = false; // Connect to Server @@ -1450,10 +1449,10 @@ class SMTPs $trackid = $this->getTrackId(); if ($trackid) { - // References is kept in response and Message-ID is returned into In-Reply-To: $_header .= 'Message-ID: <'.time().'.SMTPs-dolibarr-'.$trackid.'@'.$host.">\r\n"; - $_header .= 'References: <'.time().'.SMTPs-dolibarr-'.$trackid.'@'.$host.">\r\n"; $_header .= 'X-Dolibarr-TRACKID: '.$trackid.'@'.$host."\r\n"; + // References and In-Reply-To: will be set by caller + //$_header .= 'References: <'.time().'.SMTPs-dolibarr-'.$trackid.'@'.$host.">\r\n"; } else { $_header .= 'Message-ID: <'.time().'.SMTPs@'.$host.">\r\n"; } @@ -1464,10 +1463,6 @@ class SMTPs $_header .= $this->getMoreInHeader(); // Value must include the "\r\n"; } - //$_header .= - // 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n" - // 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"; - if ($this->getSensitivity()) { $_header .= 'Sensitivity: '.$this->getSensitivity()."\r\n"; } @@ -1492,6 +1487,7 @@ class SMTPs $_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART ? 'MAIN_MAIL_USE_MULTI_PART' : 'No MAIN_MAIL_USE_MULTI_PART')."\r\n"; $_header .= 'Mime-Version: 1.0'."\r\n"; + // TODO Add also $this->references and In-Reply-To return $_header; } diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index e1b496b6929..eb261e85593 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -2885,10 +2885,12 @@ class Ticket extends CommonObject $moreinheader = 'X-Dolibarr-Info: sendTicketMessageByEmail'."\r\n"; if (!empty($this->email_msgid)) { - $moreinheader .= 'References <'.$this->email_msgid.'>'."\r\n"; + // We must also add 1 entry In-Reply-To: <$this->email_msgid> with Message-ID we respond from (See RFC5322). + $moreinheader .= 'In-Reply-To: <'.$this->email_msgid.'>'."\r\n"; } $mailfile = new CMailFile($subject, $receiver, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', $trackid, $moreinheader, 'ticket', '', $upload_dir_tmp); + if ($mailfile->error) { setEventMessages($mailfile->error, null, 'errors'); } else { From 0476ca9a47ac33a2d62a1706adb6335453b94387 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Mar 2024 17:00:59 +0100 Subject: [PATCH 17/17] Doc --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 846819f2433..46f462790a8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1635,7 +1635,7 @@ function dolPrintLabel($s) /** * Return a string ready to be output on HTML page - * To use text inside an attribute, you can simply use dol_escape_htmltag() + * To use text inside an attribute, you can simply use dolPrintHTMLForAttribute() or dol_escape_htmltag() * * @param string $s String to print * @param int $allowiframe Allow iframe tags