diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 3469e8e994c..828f48ad003 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -229,6 +229,8 @@ if (empty($reshook)) { if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); + + $action = 'create'; } else { $result = $object->delete($user, 0, $mode); if ($result < 0) { diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 2dc381808fc..54baad28c40 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1543,7 +1543,7 @@ class BookKeeping extends CommonObject * Delete object in database * * @param User $user User that deletes - * @param int $notrigger false=launch triggers after, true=disable triggers + * @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 */ diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 931fbbd94d6..26f583792f5 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -4381,20 +4381,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'); @@ -4402,56 +4402,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; } /** diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 86898548291..bf962b1575d 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -476,7 +476,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) { @@ -517,7 +517,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) { diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 78c04ba5e88..9d73998e151 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -34,6 +34,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); @@ -530,7 +531,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 @@ -671,7 +672,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) { @@ -1635,7 +1636,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 @@ -1980,11 +1981,14 @@ 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); 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)) { diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index f66f83bb61b..4e1c12dc196 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 = getDolGlobalString('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)) { @@ -360,24 +360,24 @@ 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'); } } 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 only by Paypal if (empty($paymentType)) { - $paymentType = $_SESSION["paymentType"]; + $paymentType = empty($_SESSION["paymentType"]) ? '' : $_SESSION["paymentType"]; } $fulltag = $FULLTAG; @@ -1342,9 +1342,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++; @@ -1826,9 +1827,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 diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index c53d732169a..29fbf4266ff 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -3029,9 +3029,11 @@ class Ticket extends CommonObject // According to RFC5322, we should add here all the References fields of the initial message concatenated with // the Message-ID of the message we respond from (but each ID must be once). $references = ''; - // @TODO - // Retrieve source References to do $references .= (empty($references) ? '' : ' ').Source References - // If No References is set, use the In-Reply-To for $references .= (empty($references) ? '' : ' ').Source In-reply-To + if (empty($this->origin_references)) { + // TODO If No References is set, use the In-Reply-To for $references .= (empty($references) ? '' : ' ').Source In-reply-To + } else { + $references .= (empty($references) ? '' : ' ').$this->origin_references; + } $references .= (empty($references) ? '' : ' ').'<'.$this->email_msgid.'>'; if ($references) { $moreinheader .= 'References: '.$references."\r\n";