diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php
index 30020319813..580e1797d88 100644
--- a/htdocs/accountancy/bookkeeping/balance.php
+++ b/htdocs/accountancy/bookkeeping/balance.php
@@ -538,7 +538,7 @@ if ($action != 'export_csv') {
// Show first line of a break
print '
";
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 6a089f7a87d..a6fa25cfd13 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -1821,6 +1821,9 @@ if ($resql) {
$totalarray['val']['f.total_tva'] = 0;
$totalarray['val']['f.total_ht'] = 0;
$totalarray['val']['f.total_ttc'] = 0;
+ $totalarray['val']['totalam'] = 0;
+ $totalarray['val']['rtp'] = 0;
+
$with_margin_info = false;
if (isModEnabled('margin') && (
diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php
index 69a69891536..48e8b510877 100644
--- a/htdocs/compta/sociales/list.php
+++ b/htdocs/compta/sociales/list.php
@@ -102,7 +102,7 @@ $arrayfields = array(
'cs.fk_type' =>array('label'=>"Type", 'checked'=>1, 'position'=>30),
'cs.date_ech' =>array('label'=>"Date", 'checked'=>1, 'position'=>40),
'cs.periode' =>array('label'=>"PeriodEndDate", 'checked'=>1, 'position'=>50),
- 'p.ref' =>array('label'=>"ProjectRef", 'checked'=>1, 'position'=>60, 'enable'=>(isModEnabled('project'))),
+ 'p.ref' =>array('label'=>"ProjectRef", 'checked'=>1, 'position'=>60, 'enabled'=>(isModEnabled('project'))),
'cs.fk_user' =>array('label'=>"Employee", 'checked'=>1, 'position'=>70),
'cs.fk_mode_reglement' =>array('checked'=>-1, 'position'=>80, 'label'=>"DefaultPaymentMode"),
'cs.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>100),
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 0ee2c772ffc..f7e17f4072c 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -619,6 +619,19 @@ abstract class CommonObject
public $user_modification_id;
+ /**
+ * @var int ID
+ * @deprecated Use $user_creation_id
+ */
+ public $fk_user_creat;
+
+ /**
+ * @var int ID
+ * @deprecated Use $user_modification_id
+ */
+ public $fk_user_modif;
+
+
public $next_prev_filter;
/**
@@ -9058,9 +9071,9 @@ abstract class CommonObject
/**
- * Function to prepare a part of the query for insert by returning an array with all properties of object.
+ * Function to return the array of data key-value from the ->fields and all the ->properties of an object.
*
- * Note $this->${field} are set by the page that make the createCommon() or the updateCommon().
+ * Note: $this->${field} are set by the page that make the createCommon() or the updateCommon().
* $this->${field} should be a clean and string value (so date are formated for SQL insert).
*
* @return array Array with all values of each properties to update
@@ -9263,6 +9276,11 @@ abstract class CommonObject
}
if (array_key_exists('fk_user_creat', $fieldvalues) && !($fieldvalues['fk_user_creat'] > 0)) {
$fieldvalues['fk_user_creat'] = $user->id;
+ $this->fk_user_creat = $user->id;
+ }
+ if (array_key_exists('user_modification_id', $fieldvalues) && !($fieldvalues['user_modification_id'] > 0)) {
+ $fieldvalues['user_modification_id'] = $user->id;
+ $this->user_modification_id = $user->id;
}
unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert.
if (array_key_exists('ref', $fieldvalues)) {
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index cd9f44130b9..e262eb163c9 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -6348,7 +6348,7 @@ class Form
if (!empty($user) && $user->admin && preg_match('/\'(..)\'/', $country_code, $reg)) {
$langs->load("errors");
$new_country_code = $reg[1];
- $country_id = dol_getIdFromCode($this->db, $new_country_code, 'c_pays', 'code', 'rowid');
+ $country_id = dol_getIdFromCode($this->db, $new_country_code, 'c_country', 'code', 'rowid');
$this->error .= ' '.$langs->trans("ErrorFixThisHere", DOL_URL_ROOT.'/admin/dict.php?id=10'.($country_id > 0 ? '&countryidforinsert='.$country_id : ''));
}
$this->error .= '';
diff --git a/htdocs/core/lib/expensereport.lib.php b/htdocs/core/lib/expensereport.lib.php
index fd72aa16135..10f9d243031 100644
--- a/htdocs/core/lib/expensereport.lib.php
+++ b/htdocs/core/lib/expensereport.lib.php
@@ -81,7 +81,7 @@ function expensereport_prepare_head($object)
$head[$h][2] = 'info';
$h++;
- complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'add', 'external');
+ complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport', 'add', 'external');
complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport', 'remove');
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index cf8bb9b324e..181825a689e 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -9289,22 +9289,28 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1'
// We block use of php exec or php file functions
$forbiddenphpstrings = array('$$');
- $forbiddenphpstrings = array_merge($forbiddenphpstrings, array('_ENV', '_SESSION', '_COOKIE', '_GET', '_POST', '_REQUEST'));
+ $forbiddenphpstrings = array_merge($forbiddenphpstrings, array('_ENV', '_SESSION', '_COOKIE', '_GET', '_POST', '_REQUEST', 'ReflectionFunction'));
$forbiddenphpfunctions = array("exec", "passthru", "shell_exec", "system", "proc_open", "popen");
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("dol_eval", "executeCLI", "verifCond")); // native dolibarr functions
- $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("base64_decode", "rawurldecode", "urldecode")); // decode string functions
+ $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("base64_decode", "rawurldecode", "urldecode", "str_rot13", "hex2bin")); // decode string functions used to obfuscated function name
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "require", "include", "mkdir", "rmdir", "symlink", "touch", "unlink", "umask"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("get_defined_functions", "get_defined_vars", "get_defined_constants", "get_declared_classes"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("function", "call_user_func"));
+ $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("require", "include", "require_once", "include_once"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("eval", "create_function", "assert", "mb_ereg_replace")); // function with eval capabilities
+ $forbiddenphpmethods = array('invoke', 'invokeArgs'); // Method of ReflectionFunction to execute a function
+
$forbiddenphpregex = 'global\s+\$|\b('.implode('|', $forbiddenphpfunctions).')\b';
+ $forbiddenphpmethodsregex = '->('.implode('|', $forbiddenphpmethods).')';
+
do {
$oldstringtoclean = $s;
$s = str_ireplace($forbiddenphpstrings, '__forbiddenstring__', $s);
$s = preg_replace('/'.$forbiddenphpregex.'/i', '__forbiddenstring__', $s);
+ $s = preg_replace('/'.$forbiddenphpmethodsregex.'/i', '__forbiddenstring__', $s);
//$s = preg_replace('/\$[a-zA-Z0-9_\->\$]+\(/i', '', $s); // Remove $function( call and $mycall->mymethod(
} while ($oldstringtoclean != $s);
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index 2f4d4fe2f83..7cd07b3edcd 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -884,7 +884,10 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
$feature = 'agenda';
$dbtablename = 'actioncomm';
}
- if ($feature == 'payment_sc') {
+ if ($feature == 'payment_sc' && empty($parenttableforentity)) {
+ // If we check perm on payment page but $parenttableforentity not defined, we force value on parent table
+ $parenttableforentity = '';
+ $dbtablename = "chargesociales";
$feature = "chargesociales";
$objectid = $object->fk_charge;
}
@@ -892,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', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website', 'recruitment', 'chargesociales'); // 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'); // 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
diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php
index b3852a562fb..a53c92736ff 100644
--- a/htdocs/core/modules/DolibarrModules.class.php
+++ b/htdocs/core/modules/DolibarrModules.class.php
@@ -2,7 +2,7 @@
/* Copyright (C) 2003-2007 Rodolphe Quiedeville
* Copyright (C) 2004 Sebastien Di Cintio
* Copyright (C) 2004 Benoit Mortier
- * Copyright (C) 2004 Eric Seigne
+ * Copyright (C) 2004-2023 Eric Seigne
* Copyright (C) 2005-2013 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2014 Raphaƫl Doursenaud
@@ -1501,6 +1501,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$frequency = isset($this->cronjobs[$key]['frequency']) ? $this->cronjobs[$key]['frequency'] : '';
$unitfrequency = isset($this->cronjobs[$key]['unitfrequency']) ? $this->cronjobs[$key]['unitfrequency'] : '';
$priority = isset($this->cronjobs[$key]['priority']) ? $this->cronjobs[$key]['priority'] : '';
+ $datenextrun = isset($this->cronjobs[$key]['datenextrun']) ? $this->cronjobs[$key]['datenextrun'] : '';
$datestart = isset($this->cronjobs[$key]['datestart']) ? $this->cronjobs[$key]['datestart'] : '';
$dateend = isset($this->cronjobs[$key]['dateend']) ? $this->cronjobs[$key]['dateend'] : '';
$status = isset($this->cronjobs[$key]['status']) ? $this->cronjobs[$key]['status'] : '';
@@ -1536,7 +1537,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$this->db->begin();
if (!$err) {
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."cronjob (module_name, datec, datestart, dateend, label, jobtype, classesname, objectname, methodename, command, params, note,";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."cronjob (module_name, datec, datenextrun, datestart, dateend, label, jobtype, classesname, objectname, methodename, command, params, note,";
if (is_int($frequency)) {
$sql .= ' frequency,';
}
@@ -1553,6 +1554,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$sql .= " VALUES (";
$sql .= "'".$this->db->escape(empty($this->rights_class) ?strtolower($this->name) : $this->rights_class)."', ";
$sql .= "'".$this->db->idate($now)."', ";
+ $sql .= ($datenextrun ? "'".$this->db->idate($datenextrun)."'" : "'".$this->db->idate($now)."'").", ";
$sql .= ($datestart ? "'".$this->db->idate($datestart)."'" : "'".$this->db->idate($now)."'").", ";
$sql .= ($dateend ? "'".$this->db->idate($dateend)."'" : "NULL").", ";
$sql .= "'".$this->db->escape($label)."', ";
diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php
index 150b23666b5..58eeaf18dc3 100644
--- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php
+++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php
@@ -246,13 +246,15 @@ class InterfaceTicketEmail extends DolibarrTriggers
$linked_contacts = array_merge($linked_contacts, $object->listeContact(-1, 'internal'));
if (empty($linked_contacts) && !empty($conf->global->TICKET_NOTIFY_AT_CLOSING) && !empty($object->fk_soc)) {
$object->fetch_thirdparty();
- $linked_contacts[] = $object->thirdparty->email;
+ $linked_contacts[]['email'] = $object->thirdparty->email;
}
$contactid = GETPOST('contactid', 'int');
$res = 0;
if ($contactid > 0) {
+ // TODO This security test has no sens. We must check that $contactid is inside $linked_contacts[]['id'] when $linked_contacts[]['source'] = 'external' or 'thirdparty'
+ // Refuse email if not
$contact = new Contact($this->db);
$res = $contact->fetch($contactid);
if (! in_array($contact, $linked_contacts)) {
diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php
index cba47566c2b..9e1046d439f 100644
--- a/htdocs/filefunc.inc.php
+++ b/htdocs/filefunc.inc.php
@@ -34,7 +34,7 @@ if (!defined('DOL_APPLICATION_TITLE')) {
define('DOL_APPLICATION_TITLE', 'Dolibarr');
}
if (!defined('DOL_VERSION')) {
- define('DOL_VERSION', '18.0.5'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
+ define('DOL_VERSION', '18.0.6'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
}
if (!defined('EURO')) {
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index c9e5e8f4fee..2c1e723df00 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -1350,8 +1350,6 @@ if (empty($reshook)) {
$tva_tx = get_default_tva($soc, $mysoc, $lines[$i]->fk_product, $product_fourn_price_id);
}
- $object->special_code = $lines[$i]->special_code;
-
$result = $object->addline(
$desc,
$lines[$i]->subprice,
@@ -1374,7 +1372,9 @@ if (empty($reshook)) {
$lines[$i]->fk_unit,
0,
$element,
- !empty($lines[$i]->id) ? $lines[$i]->id : $lines[$i]->rowid
+ !empty($lines[$i]->id) ? $lines[$i]->id : $lines[$i]->rowid,
+ -1,
+ $lines[$i]->special_code
);
if ($result < 0) {
diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php
index 6a136f8ba2e..d65f48665a3 100644
--- a/htdocs/loan/payment/payment.php
+++ b/htdocs/loan/payment/payment.php
@@ -114,16 +114,16 @@ if ($action == 'add_payment') {
if (!$error) {
$paymentid = 0;
- $pay_amount_capital = price2num(GETPOST('amount_capital'));
- $pay_amount_insurance = price2num(GETPOST('amount_insurance'));
+ $pay_amount_capital = (float) price2num(GETPOST('amount_capital'));
+ $pay_amount_insurance = (float) price2num(GETPOST('amount_insurance'));
// User can't set interest him self if schedule is set (else value in schedule can be incoherent)
if (!empty($line)) {
$pay_amount_interest = $line->amount_interest;
} else {
- $pay_amount_interest = price2num(GETPOST('amount_interest'));
+ $pay_amount_interest = (float) price2num(GETPOST('amount_interest'));
}
- $remaindertopay = price2num(GETPOST('remaindertopay'));
- $amount = $pay_amount_capital + $pay_amount_insurance + $pay_amount_interest;
+ $remaindertopay = (float) price2num(GETPOST('remaindertopay'));
+ $amount = (float) price2num($pay_amount_capital + $pay_amount_insurance + $pay_amount_interest, 'MT');
// This term is allready paid
if (!empty($line) && !empty($line->fk_bank)) {
diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php
index 4ca3768fa11..b924b9c442c 100644
--- a/htdocs/product/inventory/inventory.php
+++ b/htdocs/product/inventory/inventory.php
@@ -1045,8 +1045,9 @@ if ($resql) {
// Expected quantity = Quantity in stock when we start inventory
print '
';
$valuetoshow = $obj->qty_stock;
+
// For inventory not yet close, we overwrite with the real value in stock now
- if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) {
+ if (($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) && !getDolGlobalString('DISABLE_QTY_OVERWRITE')) {
if (isModEnabled('productbatch') && $product_static->hasbatch()) {
$valuetoshow = $product_static->stock_warehouse[$obj->fk_warehouse]->detail_batch[$obj->batch]->qty;
} else {
diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php
index f2e58f98573..df498a5fec7 100644
--- a/htdocs/takepos/pay.php
+++ b/htdocs/takepos/pay.php
@@ -248,6 +248,7 @@ if ($resql) {
}
}
}
+
?>
+currency != $_SESSION["takeposcustomercurrency"]) {
+ //Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
+ $showothercurrency = 1;
+ include_once DOL_DOCUMENT_ROOT . '/multicurrency/class/multicurrency.class.php';
+ $multicurrency = new MultiCurrency($db);
+ $multicurrency->fetch(0, $_SESSION["takeposcustomercurrency"]);
+}
+?>
+