diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php
index da1617b6780..1396c43328a 100644
--- a/htdocs/accountancy/journal/sellsjournal.php
+++ b/htdocs/accountancy/journal/sellsjournal.php
@@ -226,6 +226,14 @@ if ($result) {
$vatdata = $vatdata_cache[$tax_id];
} else {
$vatdata = getTaxesFromId($tax_id, $mysoc, $mysoc, 0);
+ if (getDolGlobalString('SERVICE_ARE_ECOMMERCE_200238EC')) {
+ $buyer = new Societe($db);
+ $buyer->fetch($obj->socid);
+ } else {
+ $buyer = null; // We don't need the buyer in this case
+ }
+ $seller = $mysoc;
+ $vatdata = getTaxesFromId($tax_id, $buyer, $seller, 0);
$vatdata_cache[$tax_id] = $vatdata;
}
$compta_tva = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php
index d587ef016ff..ae2105ab846 100644
--- a/htdocs/admin/mails_templates.php
+++ b/htdocs/admin/mails_templates.php
@@ -1129,6 +1129,10 @@ if ($num) {
if (getDolGlobalString('MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES')) {
$fieldsforcontent[] = 'content_lines';
}
+
+ $parameters = array('fieldsforcontent' => &$fieldsforcontent, 'tabname' => $tabname[$id]);
+ $hookmanager->executeHooks('editEmailTemplateFieldsForContent', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
+
foreach ($fieldsforcontent as $tmpfieldlist) {
$showfield = 1;
$css = "left";
diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index ac96a98483c..d37b799493c 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -2047,6 +2047,7 @@ if ($id > 0) {
// Related contact
print '
| '.$langs->trans("ActionOnContact").' | ';
print ' ';
+
print img_picto('', 'contact', 'class="paddingrightonly"');
if (getDolGlobalString('CONTACT_USE_SEARCH_TO_SELECT') && $conf->use_javascript_ajax) {
// FIXME Use the select_contact supporting the "multiple"
diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index 5d3644cbd9a..781b766b136 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -870,9 +870,9 @@ if ($object->id > 0) {
$filedir = $conf->propal->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
$file_list = null;
if (!empty($filedir)) {
- $file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
+ $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
}
- if (is_array($file_list)) {
+ if (is_array($file_list) && !empty($file_list)) {
// Defined relative dir to DOL_DATA_ROOT
$relativedir = '';
if ($filedir) {
@@ -982,9 +982,9 @@ if ($object->id > 0) {
$filedir = $conf->commande->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
$file_list = null;
if (!empty($filedir)) {
- $file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
+ $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
}
- if (is_array($file_list)) {
+ if (is_array($file_list) && !empty($file_list)) {
// Defined relative dir to DOL_DATA_ROOT
$relativedir = '';
if ($filedir) {
@@ -1076,9 +1076,9 @@ if ($object->id > 0) {
$filedir = $conf->expedition->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
$file_list = null;
if (!empty($filedir)) {
- $file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
+ $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
}
- if (is_array($file_list)) {
+ if (is_array($file_list) && !empty($file_list)) {
// Defined relative dir to DOL_DATA_ROOT
$relativedir = '';
if ($filedir) {
@@ -1182,9 +1182,9 @@ if ($object->id > 0) {
$filedir = $conf->contrat->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
$file_list = null;
if (!empty($filedir)) {
- $file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
+ $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
}
- if (is_array($file_list)) {
+ if (is_array($file_list) && !empty($file_list)) {
// Defined relative dir to DOL_DATA_ROOT
$relativedir = '';
if ($filedir) {
@@ -1273,9 +1273,9 @@ if ($object->id > 0) {
$filedir = $conf->ficheinter->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
$file_list = null;
if (!empty($filedir)) {
- $file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
+ $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
}
- if (is_array($file_list)) {
+ if (is_array($file_list) && !empty($file_list)) {
// Defined relative dir to DOL_DATA_ROOT
$relativedir = '';
if ($filedir) {
@@ -1485,9 +1485,9 @@ if ($object->id > 0) {
$filedir = $conf->facture->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
$file_list = null;
if (!empty($filedir)) {
- $file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
+ $file_list = dol_dir_list($filedir, 'files', 0, dol_sanitizeFileName($objp->ref).'.pdf', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
}
- if (is_array($file_list)) {
+ if (is_array($file_list) && !empty($file_list)) {
// Defined relative dir to DOL_DATA_ROOT
$relativedir = '';
if ($filedir) {
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 2ad3869639b..7caa20868fa 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -911,17 +911,17 @@ if (empty($reshook)) {
// Set unit price to use
if (!empty($price_ht) || $price_ht === '0') {
- $pu_ht = price2num($price_ht, 'MU');
- $pu_ttc = price2num((float) $pu_ht * (1 + ($tmpvat / 100)), 'MU');
+ $pu_ht = (float) price2num($price_ht, 'MU');
+ $pu_ttc = (float) price2num((float) $pu_ht * (1 + ($tmpvat / 100)), 'MU');
} elseif (!empty($price_ttc) || $price_ttc === '0') {
- $pu_ttc = price2num($price_ttc, 'MU');
- $pu_ht = price2num((float) $pu_ttc / (1 + ($tmpvat / 100)), 'MU');
+ $pu_ttc = (float) price2num($price_ttc, 'MU');
+ $pu_ht = (float) price2num((float) $pu_ttc / (1 + ($tmpvat / 100)), 'MU');
} elseif ($tmpvat != $tmpprodvat) {
// Is this still used ?
if ($price_base_type != 'HT') {
- $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
+ $pu_ht = (float) price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
} else {
- $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
+ $pu_ttc = (float) price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
}
}
diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php
index 44e5276e914..f85ab0b477a 100644
--- a/htdocs/compta/bank/line.php
+++ b/htdocs/compta/bank/line.php
@@ -165,7 +165,8 @@ if ($user->hasRight('banque', 'modifier') && $action == "update") {
$sql .= " SET ";
// Always opened
if (GETPOSTISSET('value')) {
- $sql .= " fk_type='".$db->escape(GETPOST('value'))."',";
+ $type = GETPOST('value');
+ $sql .= " fk_type='".$db->escape(empty($type) && $object->fk_type == 'SOLD' ? 'SOLD' : $type)."',";
}
if (GETPOSTISSET('num_chq')) {
$sql .= " num_chq='".$db->escape(GETPOST("num_chq"))."',";
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index c78ecad1d5b..4eed51ebbbf 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -2114,7 +2114,9 @@ if ($num > 0) {
}
$filename = dol_sanitizeFileName($obj->ref);
- $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref);
+ $filepath = $conf->facture->multidir_output[$obj->entity] ?? $conf->facture->dir_output;
+ $filedir = $filepath . '/' . $filename;
+
$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->id;
print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
print ' | ';
diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index 2bd039d4fb3..747900f6fc9 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -480,6 +480,11 @@ if (!$error && $massaction == 'confirm_presend') {
$substitutionarray['__EMAIL__'] = $thirdparty->email;
$substitutionarray['__CHECK_READ__'] = '
';
+ if ($oneemailperrecipient) {
+ $substitutionarray['__ONLINE_PAYMENT_URL__'] = '';
+ $substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__'] = '';
+ }
+
$parameters = array('mode' => 'formemail');
if (!empty($listofobjectthirdparties)) {
diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php
index c72996481bb..1a66cea368a 100644
--- a/htdocs/core/actions_sendmails.inc.php
+++ b/htdocs/core/actions_sendmails.inc.php
@@ -324,7 +324,7 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO
//
$message = preg_replace('/()/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message);
- $sendtobcc = GETPOST('sendtoccc');
+ $sendtobcc = GETPOST('sendtoccc', 'alphawithlgt');
// Autocomplete the $sendtobcc
// $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO...
if (!empty($autocopy)) {
diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index a9df7140848..f9c20e48d1d 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -687,7 +687,7 @@ class CMailFile
if (!empty($this->errors_to)) {
try {
- $headers->addTextHeader('Errors-To', $this->getArrayAddress($this->errors_to));
+ $headers->addTextHeader('Errors-To', $this->getValidAddress($this->errors_to, 0));
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}
@@ -762,7 +762,6 @@ class CMailFile
$this->errors[] = $e->getMessage();
}
}
- //if (!empty($this->errors_to)) $this->message->setErrorsTo($this->getArrayAddress($this->errors_to));
if (isset($this->deliveryreceipt) && $this->deliveryreceipt == 1) {
try {
$this->message->setReadReceiptTo($this->getArrayAddress($this->addr_from));
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 89a691f0c74..b22672fde3d 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -1694,7 +1694,7 @@ abstract class CommonObject
$tab = array();
- $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle as type_label, tc.position, tc.element";
+ $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle as type_label, tc.position, tc.element, tc.module";
$sql .= " FROM ".$this->db->prefix()."c_type_contact as tc";
$sqlWhere = array();
@@ -1731,7 +1731,7 @@ abstract class CommonObject
$langs->loadLangs(array("propal", "orders", "bills", "suppliers", "contracts", "supplier_proposal"));
while ($obj = $this->db->fetch_object($resql)) {
- $modulename = $obj->element;
+ $modulename = $obj->module ?? $obj->element;
if (strpos($obj->element, 'project') !== false) {
$modulename = 'projet';
} elseif ($obj->element == 'contrat') {
@@ -9071,7 +9071,7 @@ abstract class CommonObject
}
}
$datekey = $keyprefix.'options_'.$key.$keysuffix;
- $value = (GETPOSTISSET($datekey)) ? dol_mktime(12, 0, 0, GETPOSTINT($datekey.'month', 3), GETPOSTINT($datekey.'day', 3), GETPOSTINT($datekey.'year', 3)) : $datenotinstring;
+ $value = (GETPOSTISSET($datekey) && $this->id == GETPOST('elrowid', 'int')) ? dol_mktime(12, 0, 0, GETPOSTINT($datekey.'month', 3), GETPOSTINT($datekey.'day', 3), GETPOSTINT($datekey.'year', 3)) : $datenotinstring;
}
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('datetime'))) {
$datenotinstring = null;
diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index cb191810031..3158b6d47fa 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -916,12 +916,14 @@ class FormMail extends Form
}
// Complete substitution array with the url to make online payment
- $validpaymentmethod = array();
+ $paymenturl = '';
+ // Set the online payment url link into __ONLINE_PAYMENT_URL__ key
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
+ $validpaymentmethod = getValidOnlinePaymentMethods('');
+
if (empty($this->substit['__REF__'])) {
$paymenturl = '';
} else {
- // Set the online payment url link into __ONLINE_PAYMENT_URL__ key
- require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
$langs->loadLangs(array('paypal', 'other'));
$typeforonlinepayment = 'free';
if ($this->param["models"] == 'order' || $this->param["models"] == 'order_send') {
@@ -935,14 +937,15 @@ class FormMail extends Form
}
$url = getOnlinePaymentUrl(0, $typeforonlinepayment, $this->substit['__REF__']);
$paymenturl = $url;
-
- $validpaymentmethod = getValidOnlinePaymentMethods('');
}
if (count($validpaymentmethod) > 0 && $paymenturl) {
$langs->load('other');
$this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__'] = str_replace('\n', "\n", $langs->transnoentities("PredefinedMailContentLink", $paymenturl));
$this->substit['__ONLINE_PAYMENT_URL__'] = $paymenturl;
+ } elseif (count($validpaymentmethod) > 0) {
+ $this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__'] = '__ONLINE_PAYMENT_TEXT_AND_URL__';
+ $this->substit['__ONLINE_PAYMENT_URL__'] = '__ONLINE_PAYMENT_URL__';
} else {
$this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__'] = '';
$this->substit['__ONLINE_PAYMENT_URL__'] = '';
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 6a696ab26de..dec861d258f 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -2436,7 +2436,7 @@ function show_subsidiaries($conf, $langs, $db, $object)
$i = -1;
- $sql = "SELECT s.rowid, s.client, s.fournisseur, s.nom as name, s.name_alias, s.email, s.address, s.zip, s.town, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.canvas";
+ $sql = "SELECT s.rowid, s.client, s.fournisseur, s.nom as name, s.name_alias, s.email, s.address, s.zip, s.town, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.canvas, s.status";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE s.parent = ".((int) $object->id);
$sql .= " AND s.entity IN (".getEntity('societe').")";
@@ -2476,6 +2476,7 @@ function show_subsidiaries($conf, $langs, $db, $object)
$socstatic->canvas = $obj->canvas;
$socstatic->client = $obj->client;
$socstatic->fournisseur = $obj->fournisseur;
+ $socstatic->status = $obj->status;
print '