Merge branch '20.0' of git@github.com:Dolibarr/dolibarr.git into 20.0

This commit is contained in:
Laurent Destailleur 2025-09-16 00:24:10 +02:00
commit 349930ff03
35 changed files with 376 additions and 87 deletions

View file

@ -623,6 +623,7 @@ FIX: when qty is not an integer, apply price() (#31138)
FIX: Wrong default PDF model when creating the second situation invoice (#30843)
FIX: wrong subprice if price base type is TTC (#30887)
***** ChangeLog for 19.0.3 compared to 19.0.2 *****
FIX: #29403 HRM - Unable to delete a skill in a job Profile (#29779)
FIX: #29439 incomplete API return (#29796)
@ -1187,7 +1188,39 @@ The following changes may create regressions for some external modules, but were
* The load of hook context productdao has been removed before calling loadvirtualstock. Modules must use the context of main parent page or 'all' for all cases.
***** ChangeLog for 18.0.8 compared to 18.0.7 *****
35 files changed, 647 insertions(+), 298 deletions(-)
FIX: #34746 - More complete fix for CVE-2024-40137
FIX: Correct the calculation of the amount of the current period between the period provided (#35083)
FIX: Add security test for show terminal selection if no terminal selected when invoice.php is call (#34717)
FIX: Add security test for show terminal selection if no terminal selected when invoice.php is call
FIX: missing quick edit for extrafields (baclport commit 4fc66c6) (#35160)
FIX: Missing sentence part (#35144)
FIX: set global mysoc and load langs in API access (#35041)
FIX: set global mysoc and load langs in API access
FIX: reset mysoc and langs only if entity of API has changed
FIX: accountancy general ledger: bad handling of hook return (#34029)
FIX: accountancy general ledger: bad handling of hook return
FIX: accountancy balance: bad handling of hook return
FIX: - Fix missing token for disable custom group category for compta report (page /htdocs/accountancy/admin/categories_list.php) (#35084)
FIX: The combo of custom groups has disappeared (backport v19) (#35016)
FIX: #34893 (#34897)
FIX: #34893
FIX: change error code to USERNOTALLOWEDTOCHANGEPASS
FIX: asset: could not select invoice in disposal pop-in (#34725)
FIX: 17.0 SQL syntax error and/or constraint error when calling Facture::update() after a clone (e.g. in a trigger) (#34778)
FIX: 17.0: when you clone an invoice that was created from a template invoice, the clone should not be linked to the template invoice (#34777)
FIX: pre-send mail mass action: keep __EMAIL__ substitution (#34522)
FIX: pre-send mail mass action: keep __EMAIL__ substitution
FIX: comment
FIX: massaction email tpl: keep preset
FIX: loop interrupt if an error occurs in sendEmailsRemindersOnInvoiceDueDate (#34657)
FIX: #34654
***** ChangeLog for 18.0.7 compared to 18.0.6 *****
138 files changed, 1622 insertions(+), 530 deletions(-)
FIX: 17.0 API endpoints "PUT": prevent overwriting all extrafields if only some are supplied in the request cf. PR #29237
FIX: 17.0 - collisions in cache for dol_getIdFromCode
FIX: 17.0 - missing error handling for FactureRec::fetch in card-rec.php

View file

@ -172,7 +172,7 @@ $files = new RegexIterator($iterator1, '#^(?:[A-Z]:)?(?:/(?!(?:'.($includecustom
*/
// Define qualified files (must be same than into generate_filelist_xml.php and in api_setup.class.php)
$regextoinclude = '\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|bak|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$';
$regextoexclude = '('.($includecustom ? '' : 'custom|').'documents|conf|install|dejavu-fonts-ttf-.*|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs
$regextoexclude = '('.($includecustom ? '' : 'custom|').'documents|escpos-php\/doc|conf|install|dejavu-fonts-ttf-.*|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs
$files = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude, 'fullname');
$dir = '';

View file

@ -901,6 +901,7 @@ if ($resql) {
print '<td class="center" class="nowrap">';
if ($canbedisabled) {
print '<a class="reposition" href="'.$url.'action='.urlencode($acts[$obj->active]).'&token='.newToken().'">'.$actl[$obj->active].'</a>';
print '<a class="reposition" href="'.$url.'action='.$acts[$obj->active].'&token='.newToken().'">'.$actl[$obj->active].'</a>';
} else {
print $langs->trans("AlwaysActive");
}

View file

@ -309,7 +309,7 @@ if ($action != 'export_csv') {
$newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint;
if (empty($reshook)) {
$newcardbutton = '<input type="button" id="exportcsvbutton" name="exportcsvbutton" class="butAction" value="'.$langs->trans("Export").' (' . getDolGlobalString('ACCOUNTING_EXPORT_FORMAT').')" />';
$newcardbutton .= '<input type="button" id="exportcsvbutton" name="exportcsvbutton" class="butAction" value="'.$langs->trans("Export").' (' . getDolGlobalString('ACCOUNTING_EXPORT_FORMAT').')" />';
print '<script type="text/javascript">
jQuery(document).ready(function() {

View file

@ -679,7 +679,7 @@ if ($reshook < 0) {
$newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint;
if (empty($reshook)) {
$newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param);
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param);
if ($type == 'sub') {
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly'));
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?type=sub&' . $url_param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));

View file

@ -92,7 +92,7 @@ class DolibarrApiAccess implements iAuthenticate
public function __isAllowed()
{
// phpcs:enable
global $conf, $db, $user;
global $conf, $db, $langs, $mysoc, $user;
$login = '';
$stored_key = '';
@ -146,6 +146,56 @@ class DolibarrApiAccess implements iAuthenticate
// We must also reload global conf to get params from the entity
dol_syslog("Entity was not set on http header with HTTP_DOLAPIENTITY (recommended for performance purpose), so we switch now on entity of user (".$conf->entity.") and we have to reload configuration.", LOG_WARNING);
$conf->setValues($this->db);
// set global mysoc after setting conf entity (the entity can be changed with the user logged)
// see master.inc.php
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$fmysoc = new Societe($db);
$fmysoc->setMysoc($conf);
// We set some specific default values according to country
if ($fmysoc->country_code == 'DE' && !isset($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
// For DE, we need to invert our address with customer address
$conf->global->MAIN_INVERT_SENDER_RECIPIENT = 1;
}
if ($fmysoc->country_code == 'FR' && !isset($conf->global->INVOICE_CATEGORY_OF_OPERATION)) {
// For FR, default value of option to show category of operations is on by default. Decret n°2099-1299 2022-10-07
$conf->global->INVOICE_CATEGORY_OF_OPERATION = 1;
}
if ($fmysoc->country_code == 'FR' && !isset($conf->global->INVOICE_DISABLE_REPLACEMENT)) {
// For FR, the replacement invoice type is not allowed.
// From an accounting point of view, this creates holes in the numbering of the invoice.
// This is very problematic during a fiscal control.
$conf->global->INVOICE_DISABLE_REPLACEMENT = 1;
}
if ($fmysoc->country_code == 'GR' && !isset($conf->global->INVOICE_DISABLE_REPLACEMENT)) {
// The replacement invoice type is not allowed in Greece.
$conf->global->INVOICE_DISABLE_REPLACEMENT = 1;
}
if ($fmysoc->country_code == 'GR' && !isset($conf->global->INVOICE_DISABLE_DEPOSIT)) {
// The deposit invoice type is not allowed in Greece.
$conf->global->INVOICE_DISABLE_DEPOSIT = 1;
}
if (($fmysoc->localtax1_assuj || $fmysoc->localtax2_assuj) && !isset($conf->global->MAIN_NO_INPUT_PRICE_WITH_TAX)) {
// For countries using the 2nd or 3rd tax, we disable input/edit of lines using the price including tax (because 2nb and 3rd tax not yet taken into account).
// Work In Progress to support all taxes into unit price entry when MAIN_UNIT_PRICE_WITH_TAX_IS_FOR_ALL_TAXES is set.
$conf->global->MAIN_NO_INPUT_PRICE_WITH_TAX = 1;
}
// Set also the global variable $mysoc
$mysoc = $fmysoc;
// Reload langs
$langcode = (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT);
if (!empty($user->conf->MAIN_LANG_DEFAULT)) {
$langcode = $user->conf->MAIN_LANG_DEFAULT;
}
if ($langs->getDefaultLang() != $langcode) {
$langs->setDefaultLang($langcode);
$langs->tab_translate = array();
$langs->loadLangs(array('main'));
}
}
} elseif ($nbrows > 1) {
throw new RestException(503, 'Error when fetching user api_key : More than 1 user with this apikey');

View file

@ -2471,7 +2471,7 @@ class Setup extends DolibarrApi
// Define qualified files (must be same than into generate_filelist_xml.php and in api_setup.class.php)
$regextoinclude = '\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|bak|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$';
$regextoexclude = '('.($includecustom ? '' : 'custom|').'documents|conf|install|dejavu-fonts-ttf-.*|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs
$regextoexclude = '('.($includecustom ? '' : 'custom|').'documents|escpos-php\/doc|conf|install|dejavu-fonts-ttf-.*|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs
$scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude);
// Fill file_list with files in signature, new files, modified files

View file

@ -277,9 +277,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$disposal_type_form = $object->showInputField(null, 'fk_disposal_type', $fk_disposal_type, '', '', '', 0);
$object->fields['fk_disposal_type']['visible'] = -2;
$object->fields['disposal_invoice_id'] = array('type' => 'integer:Facture:compta/facture/class/facture.class.php::entity IN (__SHARED_ENTITIES__)', 'enabled' => '1', 'notnull' => 1, 'visible' => 1, 'index' => 1, 'validate' => '1',);
$disposal_invoice_form = $object->showInputField(null, 'disposal_invoice_id', $disposal_invoice_id, '', '', '', 0);
unset($object->fields['disposal_invoice_id']);
$disposal_invoice_form = $form->selectForForms('Facture:compta/facture/class/facture.class.php::(entity:IN:__SHARED_ENTITIES__)', 'disposal_invoice_id', $disposal_invoice_id);
// Create an array for form
$formquestion = array(

View file

@ -523,33 +523,37 @@ if ($modecompta == 'CREANCES-DETTES') {
$yeartoprocess++;
}
//var_dump($monthtoprocess.'_'.$yeartoprocess);
if (isset($cpt['account_number'])) {
$return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, empty($cat['dc']) ? 0 : $cat['dc'], 'nofilter', $monthtoprocess, $yeartoprocess);
if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors');
$resultM = 0;
if (($yeartoprocess == $start_year && ($k + 1) >= $date_startmonth && $k < $date_endmonth) ||
($yeartoprocess == $start_year + 1 && ($k + 1) < $date_startmonth)
) {
//var_dump($monthtoprocess.'_'.$yeartoprocess);
if (isset($cpt['account_number'])) {
$return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, empty($cat['dc']) ? 0 : $cat['dc'], 'nofilter', $monthtoprocess, $yeartoprocess);
if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors');
$resultM = 0;
} else {
$resultM = $AccCat->sdc;
}
} else {
$resultM = $AccCat->sdc;
$resultM = 0;
}
if (empty($totCat['M'][$k])) {
$totCat['M'][$k] = $resultM;
} else {
$totCat['M'][$k] += $resultM;
}
if (empty($sommes[$code]['M'][$k])) {
$sommes[$code]['M'][$k] = $resultM;
} else {
$sommes[$code]['M'][$k] += $resultM;
}
if (isset($cpt['account_number'])) {
$totPerAccount[$cpt['account_number']]['M'][$k] = $resultM;
}
} else {
$resultM = 0;
}
if (empty($totCat['M'][$k])) {
$totCat['M'][$k] = $resultM;
} else {
$totCat['M'][$k] += $resultM;
}
if (empty($sommes[$code]['M'][$k])) {
$sommes[$code]['M'][$k] = $resultM;
} else {
$sommes[$code]['M'][$k] += $resultM;
}
if (isset($cpt['account_number'])) {
$totPerAccount[$cpt['account_number']]['M'][$k] = $resultM;
}
$resultN += $resultM;
$resultN += $resultM;
}
}
if (empty($totCat)) {

View file

@ -767,9 +767,6 @@ if (empty($reshook)) {
$price_ht = price2num(GETPOST('elprice'), 'MU');
$remise_percent = price2num(GETPOST('elremise_percent'), '', 2);
if ($remise_percent > 0) {
$remise = round(((float) $price_ht * (float) $remise_percent / 100), 2);
}
$objectline->fk_product = GETPOSTINT('idprod');
$objectline->description = GETPOST('product_desc', 'restricthtml');
@ -1991,7 +1988,9 @@ if ($action == 'create') {
if ($objp->fk_product > 0) {
$product = new Product($db);
$product->fetch($objp->fk_product);
$dateactend = dol_time_plus_duree(time(), $product->duration_value, $product->duration_unit);
if (!empty($product->duration_value) && !empty($product->duration_unit)) {
$dateactend = dol_time_plus_duree(time(), $product->duration_value, $product->duration_unit);
}
}
}

View file

@ -294,7 +294,11 @@ class CMailFile
// Note because media links are public, this should be useless, except avoid blocking images with email browser.
// This converts an embed file with src="/viewimage.php?modulepart... into a cid link
// TODO Exclude viewimage used for the read tracker ?
$findimg = $this->findHtmlImages($dolibarr_main_data_root.'/medias');
$dolibarr_main_data_root_images = $dolibarr_main_data_root;
if ((int) $conf->entity !== 1) {
$dolibarr_main_data_root_images.='/'.$conf->entity.'/';
}
$findimg = $this->findHtmlImages($dolibarr_main_data_root_images.'/medias');
if ($findimg < 0) {
dol_syslog("CMailFile::CMailfile: Error on findHtmlImages");
$this->error = 'ErrorInAddAttachmentsImageBaseOnMedia';

View file

@ -1074,7 +1074,9 @@ function num_open_day($timestampStart, $timestampEnd, $inhour = 0, $lastday = 0,
// Check if start/end days are working days just ONCE to optimize performance
// by avoiding redundant calls to the potentially slow num_public_holiday() function.
// @phan-suppress-next-line PhanPluginSuspiciousParamPosition
$isStartDayWorking = (num_public_holiday($timestampStart, $timestampStart, $country_code, 1) == 0);
// @phan-suppress-next-line PhanPluginSuspiciousParamPosition
$isEndDayWorking = (num_public_holiday($timestampEnd, $timestampEnd, $country_code, 1) == 0);
// Deduct 0.5 if the leave starts in the afternoon of a working day.

View file

@ -3362,6 +3362,10 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
// Wrapping for recruitment module
$accessallowed = $user->hasRight('recruitment', 'recruitmentjobposition', 'read');
$original_file = $conf->recruitment->dir_output.'/'.$original_file;
} elseif ($modulepart == 'hrm' && !empty($conf->hrm->dir_output)) {
// Wrapping for hrm module
$accessallowed = $user->hasRight('hrm', 'all', 'read');
$original_file = $conf->hrm->dir_output.'/'.$original_file;
} elseif ($modulepart == 'editor' && !empty($conf->fckeditor->dir_output)) {
// Wrapping for wysiwyg editor
$accessallowed = 1;

View file

@ -7715,7 +7715,6 @@ function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart = '
if (empty($level) && array_key_exists($modulepart, $arrayforoldpath)) {
$level = $arrayforoldpath[$modulepart];
}
if (!empty($level) && array_key_exists($modulepart, $arrayforoldpath)) {
// This part should be removed once all code is using "get_exdir" to forge path, with parameter $object and $modulepart provided.
if (empty($num) && is_object($object)) {
@ -7740,8 +7739,12 @@ function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart = '
// We will enhance here a common way of forging path for document storage.
// In a future, we may distribute directories on several levels depending on setup and object.
// Here, $object->id, $object->ref and $modulepart are required.
//var_dump($modulepart);
$path = dol_sanitizeFileName(empty($object->ref) ? (string) ((is_object($object) && property_exists($object, 'id')) ? $object->id : '') : $object->ref);
if (in_array($modulepart, array('societe', 'thirdparty')) && $object instanceOf Societe) {
// Special case for thirdparty, where the ref is a company name that is not unique so path on disk is using the ID instead of the ref
$path = dol_sanitizeFileName($object->id);
} else {
$path = dol_sanitizeFileName(empty($object->ref) ? (string) ((is_object($object) && property_exists($object, 'id')) ? $object->id : '') : $object->ref);
}
}
if (empty($withoutslash) && !empty($path)) {
@ -8019,14 +8022,21 @@ function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes
{
if (is_null($allowed_attributes)) {
$allowed_attributes = array(
"allow", "allowfullscreen", "alt", "class", "contenteditable", "data-html", "frameborder", "height", "href", "id", "name", "src", "style", "target", "title", "width",
"allow", "allowfullscreen", "alt", "async", "class", "contenteditable", "crossorigin", "data-html", "frameborder", "height", "href", "id", "name", "property", "rel", "src", "style", "target", "title", "type", "width",
// HTML5
"header", "footer", "nav", "section", "menu", "menuitem"
);
}
// Always add content and http-equiv for meta tags, required to force encoding and keep html content in utf8 by load/saveHTML functions.
if (!in_array("content", $allowed_attributes)) {
$allowed_attributes[] = "content";
}
if (!in_array("http-equiv", $allowed_attributes)) {
$allowed_attributes[] = "http-equiv";
}
if (class_exists('DOMDocument') && !empty($stringtoclean)) {
$stringtoclean = '<?xml encoding="UTF-8"><html><body>'.$stringtoclean.'</body></html>';
$stringtoclean = '<?xml encoding="UTF-8"><html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body>'.$stringtoclean.'</body></html>';
// Warning: loadHTML does not support HTML5 on old libxml versions.
$dom = new DOMDocument('', 'UTF-8');
@ -8077,12 +8087,15 @@ function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes
}
}
$dom->encoding = 'UTF-8';
$return = $dom->saveHTML(); // This may add a LF at end of lines, so we will trim later
//$return = '<html><body>aaaa</p>bb<p>ssdd</p>'."\n<p>aaa</p>aa<p>bb</p>";
$return = preg_replace('/^'.preg_quote('<?xml encoding="UTF-8">', '/').'/', '', $return);
$return = preg_replace('/^'.preg_quote('<html><body>', '/').'/', '', $return);
$return = preg_replace('/'.preg_quote('</body></html>', '/').'$/', '', $return);
$return = preg_replace('/^'.preg_quote('<html><head><', '/').'[^<>]*'.preg_quote('></head><body>', '/').'/', '', $return);
$return = preg_replace('/'.preg_quote('</body></html>', '/').'$/', '', trim($return));
return trim($return);
} else {
return $stringtoclean;
@ -8254,17 +8267,24 @@ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = '
// like 'abc' that wrongly ends up, without the trick, with '<p>abc</p>'
if (dol_textishtml($out)) {
$out = '<?xml encoding="UTF-8"><div class="tricktoremove">'.$out.'</div>';
$out = '<?xml encoding="UTF-8"><html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body><div class="tricktoremove">'.$out.'</div></body></html>';
} else {
$out = '<?xml encoding="UTF-8"><div class="tricktoremove">'.dol_nl2br($out).'</div>';
$out = '<?xml encoding="UTF-8"><html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body><div class="tricktoremove">'.dol_nl2br($out).'</div></body></html>';
}
$dom->loadHTML($out, LIBXML_HTML_NODEFDTD | LIBXML_ERR_NONE | LIBXML_HTML_NOIMPLIED | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_NOERROR | LIBXML_NOXMLDECL);
$dom->encoding = 'UTF-8';
$out = trim($dom->saveHTML());
// Remove the trick added to solve pb with text without parent tag
$out = preg_replace('/^<\?xml encoding="UTF-8"><div class="tricktoremove">/', '', $out);
$out = preg_replace('/<\/div>$/', '', $out);
// Remove the trick added to solve pb with text in utf8 and text without parent tag
$out = preg_replace('/^'.preg_quote('<?xml encoding="UTF-8">', '/').'/', '', $out);
$out = preg_replace('/^'.preg_quote('<html><head><', '/').'[^<>]+'.preg_quote('></head><body><div class="tricktoremove">', '/').'/', '', $out);
$out = preg_replace('/'.preg_quote('</div></body></html>', '/').'$/', '', trim($out));
// $out = preg_replace('/^<\?xml encoding="UTF-8"><div class="tricktoremove">/', '', $out);
// $out = preg_replace('/<\/div>$/', '', $out);
// var_dump('rrrrrrrrrrrrrrrrrrrrrrrrrrrrr'.$out);
} catch (Exception $e) {
// If error, invalid HTML string with no way to clean it
//print $e->getMessage();
@ -10313,7 +10333,7 @@ function verifCond($strToEvaluate, $onlysimplestring = '1')
/**
* Replace eval function to add more security.
* This function is called by verifCond() or trans() and transnoentitiesnoconv().
* This function is called by verifCond() for example.
*
* @param string $s String to evaluate
* @param int<0,1> $returnvalue 0=No return (deprecated, used to execute eval($a=something)). 1=Value of eval is returned (used to eval($something)).
@ -10446,18 +10466,33 @@ function dol_eval($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring = '1'
$forbiddenphpstrings = array('$$', '$_', '}[');
$forbiddenphpstrings = array_merge($forbiddenphpstrings, array('_ENV', '_SESSION', '_COOKIE', '_GET', '_POST', '_REQUEST', 'ReflectionFunction'));
// We list all forbidden function as keywords we don't want to see (we don't mind it if is "kewyord(" or just "keyword", we don't want "keyword" at all)
// We must exclude all functions that allow to execute another function. This includes all function that has a parameter with type "callable" to avoid things
// like we can do with array_map and its callable parameter: dol_eval('json_encode(array_map(implode("",["ex","ec"]), ["id"]))', 1, 1, '0')
$forbiddenphpfunctions = array();
// @phpcs:ignore
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("base64"."_"."decode", "rawurl"."decode", "url"."decode", "str"."_rot13", "hex"."2bin")); // name of forbidden functions are split to avoid false positive
$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("override_function", "session_id", "session_create_id", "session_regenerate_id"));
$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("function", "call_user_func", "call_user_func_array"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("array_all", "array_any", "array_diff_ukey", "array_filter", "array_find", "array_find_key", "array_map", "array_reduce", "array_intersect_uassoc", "array_intersect_ukey", "array_walk", "array_walk_recursive"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("usort", "uasort", "uksort", "preg_replace_callback", "preg_replace_callback_array", "header_register_callback"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("set_error_handler", "set_exception_handler", "libxml_set_external_entity_loader", "register_shutdown_function", "register_tick_function", "unregister_tick_function"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("spl_autoload_register", "spl_autoload_unregister", "iterator_apply", "session_set_save_handler"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("forward_static_call", "forward_static_call_array", "register_postsend_function"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("ob_start"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("require", "include", "require_once", "include_once"));
$forbiddenphpfunctions = array_merge($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("eval", "create_function", "assert", "mb_ereg_replace")); // function with eval capabilities
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("eval", "create_function", "assert", "mb_ereg_replace", "mb_ereg_replace_callback")); // function with eval capabilities
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("readline_completion_function", "readline_callback_handler_install"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("dol_compress_dir", "dol_decode", "dol_delete_file", "dol_delete_dir", "dol_delete_dir_recursive", "dol_copy", "archiveOrBackupFile")); // more dolibarr functions
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "mkdir", "rmdir", "symlink", "touch", "unlink", "umask"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("require", "include"));
$forbiddenphpmethods = array('invoke', 'invokeArgs'); // Method of ReflectionFunction to execute a function

View file

@ -30,7 +30,7 @@
* - common local lookup ips like 127.*.*.* are automatically added
*
* @param string $url URL to call.
* @param string $postorget 'POST', 'GET', 'HEAD', 'PUT', 'PUTALREADYFORMATED', 'POSTALREADYFORMATED', 'DELETE'
* @param string $postorget 'POST', 'GET', 'HEAD', 'PUT', 'PATCH', 'PUTALREADYFORMATED', 'POSTALREADYFORMATED', 'PATCHALREADYFORMATED', 'DELETE'
* @param string $param Parameters of URL (x=value1&y=value2) or may be a formatted content with $postorget='PUTALREADYFORMATED'
* @param integer $followlocation 0=Do not follow, 1=Follow location.
* @param string[] $addheaders Array of string to add into header. Example: ('Accept: application/xrds+xml', ....)
@ -135,7 +135,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation =
$array_param = null;
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT'
if (!is_array($param)) {
parse_str($param, $array_param);
parse_str($param, $array_param); // @phan-suppress-current-line PhanPluginConstantVariableNull
} else {
dol_syslog("parameter param must be a string", LOG_WARNING);
$array_param = $param;
@ -144,6 +144,19 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation =
} elseif ($postorget == 'PUTALREADYFORMATED') {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT'
curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // param = content of post, like a xml string
} elseif ($postorget == 'PATCH') {
$array_param = null;
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH'); // RFC 5789
if (!is_array($param)) {
parse_str($param, $array_param); // @phan-suppress-current-line PhanPluginConstantVariableNull
} else {
dol_syslog("parameter param must be a string", LOG_WARNING);
$array_param = $param;
}
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array_param));
} elseif ($postorget == 'PATCHALREADYFORMATED') {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH'); // RFC 5789
curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
} elseif ($postorget == 'HEAD') {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'HEAD'); // HTTP request is 'HEAD'
curl_setopt($ch, CURLOPT_NOBODY, true);

View file

@ -600,6 +600,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
{
global $user, $langs, $conf, $db, $hookmanager;
global $projectstatic, $taskstatic, $extrafields;
global $objectoffield;
$lastprojectid = 0;
@ -936,6 +937,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
$extrafieldsobjectkey = $taskstatic->table_element;
$extrafieldsobjectprefix = 'efpt.';
$obj = $lines[$i];
$object = $lines[$i];
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
$parameters = array('arrayfields' => $arrayfields, 'obj' => $lines[$i]);

View file

@ -3,7 +3,8 @@
* Copyright (C) 2010-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2025 Joachim Küter <git-jk@bloxera.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -804,7 +805,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1);
$resteapayer = 0;
}

View file

@ -1221,6 +1221,9 @@ class FactureFournisseur extends CommonInvoice
$this->fk_project = (int) $this->fk_project;
}
}
if (isset($this->mode_reglement_id)) {
$this->mode_reglement_id = (int) $this->mode_reglement_id;
}
if (isset($this->cond_reglement_id)) {
$this->cond_reglement_id = (int) $this->cond_reglement_id;
}
@ -1271,6 +1274,7 @@ class FactureFournisseur extends CommonInvoice
$sql .= " fk_facture_source=".($this->fk_facture_source ? ((int) $this->fk_facture_source) : "null").",";
$sql .= " vat_reverse_charge = ".($this->vat_reverse_charge != '' ? ((int) $this->db->escape($this->vat_reverse_charge)) : 0).",";
$sql .= " fk_projet=".(!empty($this->fk_project) ? ((int) $this->fk_project) : "null").",";
$sql .= " fk_mode_reglement=".(isset($this->mode_reglement_id) ? ((int) $this->mode_reglement_id) : "null").",";
$sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? ((int) $this->cond_reglement_id) : "null").",";
$sql .= " date_lim_reglement=".(dol_strlen($this->date_echeance) != 0 ? "'".$this->db->idate($this->date_echeance)."'" : 'null').",";
$sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").",";

View file

@ -39,6 +39,11 @@
define('ALLOWED_IF_UPGRADE_UNLOCK_FOUND', 1);
include_once 'inc.php';
/**
* @var string $conffile
*/
if (!file_exists($conffile)) {
print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").';
}
@ -47,6 +52,11 @@ require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
global $langs;
/**
* @var Conf $conf
* @var Translate $langs
*/
$grant_query = '';
$step = 2;
$ok = 0;

View file

@ -42,6 +42,11 @@
define('ALLOWED_IF_UPGRADE_UNLOCK_FOUND', 1);
include_once 'inc.php';
/**
* @var string $conffile
*/
if (!file_exists($conffile)) {
print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").';
}
@ -58,13 +63,17 @@ require_once $dolibarr_main_document_root.'/core/lib/files.lib.php';
global $langs;
/**
* @var Conf $conf
* @var Translate $langs
*/
$grant_query = '';
$step = 2;
$error = 0;
// Cette page peut etre longue. On augmente le delai autorise.
// Ne fonctionne que si on est pas en safe_mode.
// This page can be long. We increase the allowed delay, but this does not work when we are in safe_mode.
$err = error_reporting();
error_reporting(0);
if (getDolGlobalString('MAIN_OVERRIDE_TIME_LIMIT')) {
@ -226,8 +235,11 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$db->begin();
foreach ($listofentities as $entity) {
dol_syslog("Process upgrade2 for entity ".$entity);
// Set $conf context for entity
$conf->setEntityValues($db, $entity);
// Reset forced setup after the setValues
if (defined('SYSLOG_FILE')) {
$conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
@ -250,10 +262,11 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$versiontoarray = explode('.', $versionto);
$versionranarray = explode('.', DOL_VERSION);
$afterversionarray = explode('.', '2.0.0');
$beforeversionarray = explode('.', '2.7.9');
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
dol_syslog("Run migrate_... versionto is between ".json_encode($afterversionarray)." and ".json_encode($beforeversionarray));
// Script pour V2 -> V2.1
migrate_paiements($db, $langs, $conf);
@ -317,6 +330,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$beforeversionarray = explode('.', '2.8.9');
//print $versionto.' '.versioncompare($versiontoarray,$afterversionarray).' '.versioncompare($versiontoarray,$beforeversionarray);
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
dol_syslog("Run migrate_... versionto is between ".json_encode($afterversionarray)." and ".json_encode($beforeversionarray));
migrate_price_facture($db, $langs, $conf); // Code of this function works for 2.8+ because need a field tva_tx
migrate_relationship_tables($db, $langs, $conf, 'co_exp', 'fk_commande', 'commande', 'fk_expedition', 'shipping');
@ -342,6 +357,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$afterversionarray = explode('.', '2.8.9');
$beforeversionarray = explode('.', '2.9.9');
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
dol_syslog("Run migrate_... versionto is between ".json_encode($afterversionarray)." and ".json_encode($beforeversionarray));
migrate_element_time($db, $langs, $conf);
migrate_customerorder_shipping($db, $langs, $conf);
@ -362,6 +379,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$afterversionarray = explode('.', '3.0.9');
$beforeversionarray = explode('.', '3.1.9');
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
dol_syslog("Run migrate_... versionto is between ".json_encode($afterversionarray)." and ".json_encode($beforeversionarray));
migrate_rename_directories($db, $langs, $conf, '/rss', '/externalrss');
migrate_actioncomm_element($db, $langs, $conf);
@ -371,6 +390,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$afterversionarray = explode('.', '3.1.9');
$beforeversionarray = explode('.', '3.2.9');
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
dol_syslog("Run migrate_... versionto is between ".json_encode($afterversionarray)." and ".json_encode($beforeversionarray));
migrate_price_contrat($db, $langs, $conf);
migrate_mode_reglement($db, $langs, $conf);
@ -382,6 +403,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$afterversionarray = explode('.', '3.2.9');
$beforeversionarray = explode('.', '3.3.9');
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
dol_syslog("Run migrate_... versionto is between ".json_encode($afterversionarray)." and ".json_encode($beforeversionarray));
migrate_categorie_association($db, $langs, $conf);
}
@ -392,6 +415,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$afterversionarray = explode('.', '3.6.9'); // target is after this
$beforeversionarray = explode('.', '3.7.9'); // target is before this
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
dol_syslog("Run migrate_... versionto is between ".json_encode($afterversionarray)." and ".json_encode($beforeversionarray));
migrate_event_assignement($db, $langs, $conf);
}
@ -406,6 +431,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$afterversionarray = explode('.', '3.9.9');
$beforeversionarray = explode('.', '4.0.9');
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
dol_syslog("Run migrate_... versionto is between ".json_encode($afterversionarray)." and ".json_encode($beforeversionarray));
migrate_rename_directories($db, $langs, $conf, '/fckeditor', '/medias');
}
@ -413,6 +440,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$afterversionarray = explode('.', '4.0.9');
$beforeversionarray = explode('.', '5.0.9');
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
dol_syslog("Run migrate_... versionto is between ".json_encode($afterversionarray)." and ".json_encode($beforeversionarray));
// Migrate to add entity value into llx_societe_remise
migrate_remise_entity($db, $langs, $conf);
@ -429,6 +458,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
// Only if the transverse mode is not used
if (empty($multicompany_transverse_mode)) {
dol_syslog("Run migrate_... versionto is between ".json_encode($afterversionarray)." and ".json_encode($beforeversionarray));
// Migrate to add entity value into llx_user_rights
migrate_user_rights_entity($db, $langs, $conf);
@ -442,6 +473,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$afterversionarray = explode('.', '6.0.9');
$beforeversionarray = explode('.', '7.0.9');
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
dol_syslog("Run migrate_... versionto is between ".json_encode($afterversionarray)." and ".json_encode($beforeversionarray));
// Migrate contact association
migrate_event_assignement_contact($db, $langs, $conf);
@ -452,6 +485,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$afterversionarray = explode('.', '7.0.9');
$beforeversionarray = explode('.', '8.0.9');
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
dol_syslog("Run migrate_... versionto is between ".json_encode($afterversionarray)." and ".json_encode($beforeversionarray));
migrate_rename_directories($db, $langs, $conf, '/contracts', '/contract');
}
@ -466,6 +501,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$afterversionarray = explode('.', '10.0.9');
$beforeversionarray = explode('.', '11.0.9');
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
dol_syslog("Run migrate_... versionto is between ".json_encode($afterversionarray)." and ".json_encode($beforeversionarray));
migrate_users_socialnetworks();
migrate_members_socialnetworks();
migrate_contacts_socialnetworks();
@ -476,6 +513,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$afterversionarray = explode('.', '13.0.9');
$beforeversionarray = explode('.', '14.0.9');
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
dol_syslog("Run migrate_... versionto is between ".json_encode($afterversionarray)." and ".json_encode($beforeversionarray));
migrate_export_import_profiles('export');
migrate_export_import_profiles('import');
}
@ -484,6 +523,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$afterversionarray = explode('.', '15.0.9');
$beforeversionarray = explode('.', '16.0.9');
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
dol_syslog("Run migrate_... versionto is between ".json_encode($afterversionarray)." and ".json_encode($beforeversionarray));
migrate_user_photospath();
migrate_user_photospath2();
}
@ -492,6 +533,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$afterversionarray = explode('.', '16.0.9');
$beforeversionarray = explode('.', '17.0.9');
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
dol_syslog("Run migrate_... versionto is between ".json_encode($afterversionarray)." and ".json_encode($beforeversionarray));
migrate_contractdet_rank();
}
@ -499,6 +542,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$afterversionarray = explode('.', '17.0.9');
$beforeversionarray = explode('.', '18.0.9');
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
dol_syslog("Run migrate_... versionto is between ".json_encode($afterversionarray)." and ".json_encode($beforeversionarray));
migrate_contractdet_rank();
}
@ -519,9 +564,10 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
}
}
// Code executed only if migration is LAST ONE. Must always be done.
if (versioncompare($versiontoarray, $versionranarray) >= 0 || versioncompare($versiontoarray, $versionranarray) <= -3) {
dol_syslog("Run migrate_... if migration is LAST ONE");
// Reload modules (this must be always done and only into last targeted version, because code to reload module may need table structure of last version)
$listofmodule = array(
'MAIN_MODULE_ACCOUNTING' => 'newboxdefonly',
@ -566,6 +612,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
if ($result < 0) {
$error++;
}
// Reload menus (this must be always and only into last targeted version)
$result = migrate_reload_menu($db, $langs, $conf);
if ($result < 0) {

View file

@ -186,7 +186,7 @@ DONATION_ACCOUNTINGACCOUNT=Account (from the Chart Of Account) to be used to reg
ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT=Account (from the Chart Of Account) to be used to register memberships subscriptions (Membership module - if membership recorded without invoice)
ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT=Account (from the Chart Of Account) to be used as the default account to register customer deposit
UseAuxiliaryAccountOnCustomerDeposit=Store customer account as individual account in subsidiary ledger for lines of down payments (if disabled, individual account for down payment lines will remain empty)
ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT=Account (from the Chart Of Account) to be used as the default
ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT=Account (from the Chart Of Account) to be used as the default account to register supplier deposit
UseAuxiliaryAccountOnSupplierDeposit=Store supplier account as individual account in subsidiary ledger for lines of down payments (if disabled, individual account for down payment lines will remain empty)
ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY=Accounting account by default to register customer retained warranty
ACCOUNTING_PRODUCT_BUY_ACCOUNT=Account (from the Chart Of Account) to be used as the default account for the products purchased within same country (used if not defined in the product sheet)
@ -338,6 +338,7 @@ ACCOUNTING_LETTERING_NBLETTERS_DESC=Some accounting software only accepts a two-
OptionsAdvanced=Advanced options
ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE=Activate the management of VAT reverse charge on supplier purchases
ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE_DESC=When this option is enabled, you can define that a supplier or a given vendor invoice must be transferred into accountancy differently: A additional debit and a credit line will generated into the accounting on 2 given accounts from the chart of account defined into the "%s" setup page.
## Export
NotExportLettering=Do not export the lettering when generating the file
NotifiedExportDate=Flag not yet exported lines as Exported <span class="warning">(to modify a line flagged as exported, you will need to delete the whole transaction and re-transfert it into accounting)</span>

View file

@ -54,3 +54,4 @@ RestoreWithCurrentQtySaved=Fill quantities with latest saved values
ReceptionsRecorded=Receptions recorded
ReceptionUpdated=Reception successfully updated
ReceptionDistribution=Reception distribution
ReceptionMustBeInTheSameCurrencyThanOther=Reception have to be int the same currency than the other

View file

@ -56,3 +56,4 @@ RestoreWithCurrentQtySaved=Remplir les quantités avec les dernières valeurs en
ReceptionsRecorded=Réceptions enregistrées
ReceptionUpdated=Réception mise à jour avec succès
ReceptionDistribution=Distribution de réception
ReceptionMustBeInTheSameCurrencyThanOther=Cette Reception n'est pas dans la même devise que les autres

View file

@ -891,6 +891,7 @@ class Productlot extends CommonObject
}
$sql .= " WHERE cf.entity IN (".getEntity('expedition').")";
$sql .= " AND cfdi.batch = '".($this->db->escape($this->batch))."'";
$sql .= " AND cfdi.fk_product = " . (int) $this->fk_product;
if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}

View file

@ -358,7 +358,7 @@ if ($action == "correct_stock" && $permissiontoadd) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors');
$action = 'correction';
}
if (!is_numeric(GETPOST("nbpiece"))) {
if (!GETPOSTFLOAT("nbpiece")) {
$error++;
setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors');
$action = 'correction';
@ -384,7 +384,7 @@ if ($action == "correct_stock" && $permissiontoadd) {
$result = $product->correct_stock_batch(
$user,
$id,
GETPOSTINT("nbpiece"),
GETPOSTFLOAT("nbpiece"),
GETPOSTINT("mouvement"),
GETPOST("label", 'alphanohtml'),
price2num(GETPOST('unitprice'), 'MT'),
@ -401,7 +401,7 @@ if ($action == "correct_stock" && $permissiontoadd) {
$result = $product->correct_stock(
$user,
$id,
GETPOSTINT("nbpiece"),
GETPOSTFLOAT("nbpiece"),
GETPOSTINT("mouvement"),
GETPOST("label", 'alphanohtml'),
price2num(GETPOST('unitprice'), 'MT'),
@ -446,7 +446,7 @@ if ($action == "transfert_stock" && $permissiontoadd && !$cancel) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors');
$action = 'transfert';
}
if (!GETPOSTINT("nbpiece")) {
if (!GETPOSTFLOAT("nbpiece")) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors');
$error++;
$action = 'transfert';
@ -510,7 +510,7 @@ if ($action == "transfert_stock" && $permissiontoadd && !$cancel) {
$result1 = $product->correct_stock_batch(
$user,
$srcwarehouseid,
GETPOSTINT("nbpiece"),
GETPOSTFLOAT("nbpiece"),
1,
GETPOST("label", 'san_alpha'),
$pricesrc,
@ -527,7 +527,7 @@ if ($action == "transfert_stock" && $permissiontoadd && !$cancel) {
$result2 = $product->correct_stock_batch(
$user,
GETPOSTINT("id_entrepot_destination"),
GETPOSTINT("nbpiece"),
GETPOSTFLOAT("nbpiece"),
0,
GETPOST("label", 'san_alpha'),
$pricedest,
@ -546,9 +546,9 @@ if ($action == "transfert_stock" && $permissiontoadd && !$cancel) {
$result1 = $product->correct_stock(
$user,
$id,
GETPOST("nbpiece"),
GETPOSTFLOAT("nbpiece"),
1,
GETPOST("label", 'san_alpha'),
GETPOST("label", 'alphanohtml'),
$pricesrc,
GETPOST('inventorycode', 'alphanohtml'),
'',
@ -561,9 +561,9 @@ if ($action == "transfert_stock" && $permissiontoadd && !$cancel) {
$result2 = $product->correct_stock(
$user,
GETPOST("id_entrepot_destination"),
GETPOST("nbpiece"),
GETPOSTFLOAT("nbpiece"),
0,
GETPOST("label", 'san_alpha'),
GETPOST("label", 'alphanohtml'),
$pricedest,
GETPOST('inventorycode', 'alphanohtml'),
'',

View file

@ -230,6 +230,7 @@ if ($id > 0 || !empty($ref)) {
}
$sql .= " WHERE cf.entity IN (".getEntity('product').")";
$sql .= " AND cfdi.batch = '".($db->escape($object->batch))."'";
$sql .= " AND cfdi.fk_product = " . (int) $object->fk_product;
if (!empty($search_month)) {
$sql .= ' AND MONTH(cf.date_commande) IN ('.$db->sanitize($search_month).')';
}

View file

@ -113,12 +113,15 @@ if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $acti
$permissiontoadd = $user->hasRight('projet', 'creer');
$permissiontodelete = $user->hasRight('projet', 'supprimer');
$permissiondellink = $user->hasRight('projet', 'creer'); // Used by the include of actions_dellink.inc.php
$permissiontoeditextra = $permissiontoadd;
/*
* Actions
*/
$error = 0;
$parameters = array('id' => $socid, 'objcanvas' => $objcanvas);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
@ -552,18 +555,19 @@ if (empty($reshook)) {
}
// Quick edit for extrafields
if ($action == 'update_extras' && $permissiontoadd) {
$object->oldcopy = dol_clone($object, 2);
if ($action == 'update_extras' && $permissiontoeditextra) {
$object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty
$attribute_name = GETPOST('attribute', 'aZ09');
// Fill array 'array_options' with data from update form
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
$ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name);
if ($ret < 0) {
$error++;
}
if (!$error) {
// Actions on extra fields
$result = $object->insertExtraFields('PROJECT_MODIFY');
$result = $object->updateExtraField($attribute_name, 'PROJECT_MODIFY');
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;

View file

@ -1272,12 +1272,12 @@ foreach ($listofreferent as $key => $value) {
if (!empty($element->close_code) && $element->close_code == 'replaced') {
$qualifiedfortotal = false; // Replacement invoice, do not include into total
}
} elseif ($key == 'order_supplier' && $element->status == 7) {
} elseif ($key == 'order_supplier' && ($element->status == 6 || $element->status == 7)) {
$qualifiedfortotal = false; // It makes no sense to include canceled orders in the total
}
if ($key == "order_supplier" && $element->status == 7) {
print '<tr class="oddeven tr_canceled" style=display:none>';
if ($key == "order_supplier" && ($element->status == 6 || $element->status == 7)) {
print '<tr class="oddeven tr_canceled">';
} else {
print '<tr class="oddeven" >';
}

View file

@ -265,6 +265,8 @@ if (empty($reshook)) {
$mode_reglement_id = 0;
$fk_account = 0;
$transport_mode_id = 0;
$multicurrency_code = null;
if (!empty($rcp->cond_reglement_id)) {
$cond_reglement_id = $rcp->cond_reglement_id;
}
@ -277,11 +279,15 @@ if (empty($reshook)) {
if (!empty($rcp->transport_mode_id)) {
$transport_mode_id = $rcp->transport_mode_id;
}
if (!empty($rcp->multicurrency_code)) {
$multicurrency_code = $rcp->multicurrency_code;
}
if (empty($cond_reglement_id)
|| empty($mode_reglement_id)
|| empty($fk_account)
|| empty($transport_mode_id)
|| empty($multicurrency_code)
) {
if (!isset($rcp->supplier_order)) {
$rcp->fetch_origin();
@ -302,6 +308,9 @@ if (empty($reshook)) {
if (empty($transport_mode_id) && !empty($supplierOrder->transport_mode_id)) {
$transport_mode_id = $supplierOrder->transport_mode_id;
}
if (empty($multicurrency_code) && !empty($supplierOrder->multicurrency_code)) {
$multicurrency_code = $supplierOrder->multicurrency_code;
}
}
// try get from third-party of reception
@ -319,6 +328,9 @@ if (empty($reshook)) {
if (empty($transport_mode_id) && !empty($soc->transport_mode_id)) {
$transport_mode_id = $soc->transport_mode_id;
}
if (empty($multicurrency_code) && !empty($soc->multicurrency_code)) {
$multicurrency_code = $soc->multicurrency_code;
}
}
}
@ -329,6 +341,7 @@ if (empty($reshook)) {
$objecttmp->mode_reglement_id = $mode_reglement_id;
$objecttmp->fk_account = $fk_account;
$objecttmp->transport_mode_id = $transport_mode_id;
$objecttmp->multicurrency_code = $multicurrency_code;
// if the VAT reverse-charge is activated by default in supplier card to resume the information
$objecttmp->vat_reverse_charge = $soc->vat_reverse_charge;
@ -384,6 +397,13 @@ if (empty($reshook)) {
}
if ($objecttmp->id > 0) {
if (!isset($rcp->origin_object)) {
$rcp->fetch_origin();
}
if ($rcp->origin_object->multicurrency_code != $objecttmp->multicurrency_code) {
$errors[] = $rcp->ref." : ".$langs->trans("ReceptionMustBeInTheSameCurrencyThanOther");
}
$res = $objecttmp->add_object_linked($objecttmp->origin, $id_reception);
if ($res == 0) {
@ -492,7 +512,7 @@ if (empty($reshook)) {
array(),
null,
$lines[$i]->rowid,
0,
$lines[$i]->multicurrency_subprice,
$lines[$i]->ref_supplier
);

View file

@ -4875,10 +4875,12 @@ class Societe extends CommonObject
$alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT');
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
*/
$today = dol_get_first_hour(dol_now('tzuser')); // Returns today at 00:00 in the user's time zone
$sql = "SELECT rowid, ref, total_ht, total_ttc, paye, type, fk_statut as status, close_code FROM ".MAIN_DB_PREFIX.$table." as f";
$sql .= " WHERE fk_soc = ".((int) $this->id);
if (!empty($late)) {
$sql .= " AND date_lim_reglement < '".$this->db->idate(dol_now())."'";
$sql .= " AND date_lim_reglement < '".$this->db->idate($today)."'";
}
if ($mode == 'supplier') {
$sql .= " AND entity IN (".getEntity('facture_fourn').")";

View file

@ -183,10 +183,11 @@ print '</div>';
print dol_get_fiche_end();
$modulepart = 'societe';
$modulepart = 'company';
$permissiontoadd = $user->hasRight('societe', 'creer');
$permtoedit = $user->hasRight('societe', 'creer');
$param = '&id='.$object->id;
$relativepathwithnofile = $object->id . '/';
include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
// End of page

View file

@ -81,8 +81,30 @@ if ((getDolGlobalString('TAKEPOS_PHONE_BASIC_LAYOUT') == 1 && $conf->browser->la
}
}
$takeposterminal = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '';
// When session has expired (selected terminal has been lost from session), redirect to the terminal selection.
if (empty($takeposterminal)) {
if (getDolGlobalInt('TAKEPOS_NUM_TERMINALS') == 1) {
$_SESSION["takeposterminal"] = 1; // Use terminal 1 if there is only 1 terminal
$takeposterminal = 1;
} elseif (!empty($_COOKIE["takeposterminal"])) {
$_SESSION["takeposterminal"] = preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE["takeposterminal"]); // Restore takeposterminal from previous session
$takeposterminal = $_SESSION["takeposterminal"];
} else {
print <<<SCRIPT
<script language="javascript">
$( document ).ready(function() {
ModalBox('ModalTerminal');
});
</script>
SCRIPT;
exit;
}
}
/**
* Abort invoice creation with a given error message
*

View file

@ -133,6 +133,15 @@ if (empty($reshook)) {
$result = $edituser->fetch('', '', '', 1, $conf->entity, $username);
}
// If the user does not have the right to change his own password
if ($result > 0) {
$edituser->getrights('user');
if (!$edituser->hasRight('user', 'self', 'password')) {
$result = 0;
$edituser->error = 'USERNOTALLOWEDTOCHANGEPASS';
}
}
// Set the message to show (must be the same if login/email exists or not
// to avoid to guess them.
$messagewarning = '<div class="warning paddingtopbottom'.(!getDolGlobalString('MAIN_LOGIN_BACKGROUND') ? '' : ' backgroundsemitransparent boxshadow').'">';
@ -143,7 +152,7 @@ if (empty($reshook)) {
}
$messagewarning .= '</div>';
if ($result <= 0 && $edituser->error == 'USERNOTFOUND') {
if ($result <= 0 && ($edituser->error == 'USERNOTFOUND' || $edituser->error == 'USERNOTALLOWEDTOCHANGEPASS')) {
usleep(20000); // add delay to simulate setPassword() and send_password() actions delay (0.02s)
$message .= $messagewarning;
$username = '';

1
test/phpunit/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/DemoTest.php

View file

@ -545,8 +545,8 @@ class SecurityTest extends CommonClassTest
print __METHOD__." result for param0=".$result."\n";
$this->assertEquals($resultexpected, $result, 'Test on param0');
$result = GETPOST("param15b", 'restricthtml'); // param15b = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
print __METHOD__." result for param15b=".$result."\n";
$result=GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
print __METHOD__." result for param15=".$result."\n";
//$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b'); // With some PHP and libxml version, we got this result when parsing invalid HTML, but ...
//$this->assertEquals('<img onerror> src=&gt;0xbeefed', $result, 'Test 15b'); // ... on other PHP and libxml versions, we got a HTML that has been cleaned
@ -798,7 +798,9 @@ class SecurityTest extends CommonClassTest
{
$stringtotest = 'eée';
$decodedstring = dol_string_onlythesehtmlattributes($stringtotest);
$this->assertEquals('e&eacute;e', $decodedstring, 'Function did not sanitize correctly with test 1');
//$this->assertEquals('e&eacute;e', $decodedstring, 'Function did not sanitize correctly with test 1');
$this->assertEquals('eée', $decodedstring, 'Function did not sanitize correctly with test 1');
$stringtotest = '<div onload="ee"><a href="123"><span class="abc">abc</span></a></div>';
$decodedstring = dol_string_onlythesehtmlattributes($stringtotest);
@ -1071,6 +1073,22 @@ class SecurityTest extends CommonClassTest
print "result6 = ".$result."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', $result);
$result = dol_eval('json_encode(array_map(implode("",["ex","ec"]), ["id"]))', 1, 1, '1'); // result of dol_eval may be an object Closure
print "result4a = ".json_encode($result)."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', json_encode($result), 'The string was not detected as evil, it should due to the [ char and method "2"');
$result = dol_eval('json_encode(array_map(implode("",["ex","ec"]), ["id"]))', 1, 1, '2'); // result of dol_eval may be an object Closure
print "result4b = ".json_encode($result)."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', json_encode($result), 'The string was not detected as evil, it should due to the use of array_map');
$result = dol_eval('json_encode(array_map(implode("",array("ex","ec"), array("id")))', 1, 1, '1'); // result of dol_eval may be an object Closure
print "result4c = ".json_encode($result)."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', json_encode($result), 'The string was not detected as evil, it should due to the use of array_map');
$result = dol_eval('$a=function() { }; $a', 1, 1, '0'); // result of dol_eval may be an object Closure
print "result5 = ".json_encode($result)."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', json_encode($result), 'The string was not detected as evil');
$result = (string) dol_eval('$a=exec("ls");', 1, 1);
print "result7 = ".$result."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', $result);