Merge branch 'develop' into retrieving-extraparams-for-lines

This commit is contained in:
Laurent Destailleur
2025-03-04 21:35:01 +01:00
committed by GitHub
5 changed files with 37 additions and 11 deletions

View File

@@ -4227,7 +4227,12 @@ class Facture extends CommonInvoice
$special_code = 0;
}
if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '' || $situation_percent == null) {
$situation_percent = 100;
// INVOICE_USE_SITUATION = 2 - If there is no progress on a line, percent must not be 100% (No cumulative)
if ($this->type == Facture::TYPE_SITUATION && getDolGlobalInt('INVOICE_USE_SITUATION') == 2 && (int) $situation_percent < 100) {
$situation_percent = 0;
} else {
$situation_percent = 100;
}
}
if (empty($ref_ext)) {
$ref_ext = '';

View File

@@ -705,7 +705,7 @@ class FormSetupItem
{
global $conf;
if (isset($conf->global->{$this->confKey})) {
$this->fieldValue = getDolGlobalString($this->confKey, null);
$this->fieldValue = getDolGlobalString($this->confKey);
return true;
} else {
$this->fieldValue = null;

View File

@@ -11959,15 +11959,20 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
$value = preg_replace('/\s*\|\s*/', '|', $value);
// Split criteria on ' ' but not if we are inside quotes
$crits = dolExplodeKeepIfQuotes($value);
// Split criteria on ' ' but not if we are inside quotes.
// For mode 3, the split is done later on the , only and not on the ' '.
if ($mode != -3 && $mode != 3) {
$crits = dolExplodeKeepIfQuotes($value);
} else {
$crits = array($value);
}
$res = '';
if (!is_array($fields)) {
$fields = array($fields);
}
$i1 = 0; // count the nb of and criteria added (all fields / criteria)
$i1 = 0; // count the nb of "and" criteria added (all fields / criteria)
foreach ($crits as $crit) { // Loop on each AND criteria
$crit = trim($crit);
$i2 = 0; // count the nb of valid criteria added for this this first criteria
@@ -12022,7 +12027,7 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
$listofcodes .= "'".$db->escape($val)."'";
}
}
$newres .= ($i2 > 0 ? ' OR ' : '').$db->sanitize($field)." ".($mode == -3 ? 'NOT ' : '')."IN (".$db->sanitize($listofcodes, 1).")";
$newres .= ($i2 > 0 ? ' OR ' : '').$db->sanitize($field)." ".($mode == -3 ? 'NOT ' : '')."IN (".$db->sanitize($listofcodes, 1, 0, 1).")";
$i2++; // a criteria for 1 more field was added to string
}
if ($mode == -3) {

View File

@@ -132,10 +132,10 @@ $original_file = str_replace("../", "/", $original_file);
$cachestring = GETPOST("cache", 'aZ09'); // May be 1, or an int (delay in second of the cache if < 999999, or a timestamp), or a hash
if ($cachestring || image_format_supported($original_file) >= 0) {
// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
$delaycache = GETPOSTINT('cachedelay') ? GETPOSTINT('cachedelay') : ((is_numeric($cachestring) && (int) $cachestring > 1 && (int) $cachestring < 999999) ? $cachestring : '3600');
header('Cache-Control: max-age='.$delaycache.', public, must-revalidate');
$cachedelay = GETPOSTINT('cachedelay') ? GETPOSTINT('cachedelay') : ((is_numeric($cachestring) && (int) $cachestring > 1 && (int) $cachestring < 999999) ? $cachestring : '3600');
header('Cache-Control: max-age='.$cachedelay.', public, must-revalidate');
header('Pragma: cache'); // This is to avoid having Pragma: no-cache
header('Expires: '.gmdate('D, d M Y H:i:s', time() + (int) $delaycache).' GMT'); // This is to avoid to have Expires set by proxy or web server
header('Expires: '.gmdate('D, d M Y H:i:s', time() + (int) $cachedelay).' GMT'); // This is to avoid to have Expires set by proxy or web server
}
$refname = basename(dirname($original_file)."/");
@@ -175,7 +175,7 @@ if ($rss) {
require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
dol_syslog("build_exportfile Build export file format=".$format.", type=".$type.", cachedelay=".$cachedelay.", filename=".$filename.", filters size=".count($filters), LOG_DEBUG);
dol_syslog("build_exportfile Build export file format=".$format.", type=".$type.", cachestring=".$cachestring.", filename=".$filename.", filters size=".count($filters), LOG_DEBUG);
// Clean parameters
if (!$filename) {

View File

@@ -1894,7 +1894,6 @@ class FunctionsLibTest extends CommonClassTest
return true;
}
/**
* testRoundUpToNextMultiple
*
@@ -1918,4 +1917,21 @@ class FunctionsLibTest extends CommonClassTest
$this->assertEquals(roundUpToNextMultiple(40.5, 6), 42);
$this->assertEquals(roundUpToNextMultiple(44.5, 6), 48);
}
/**
* testNaturalSearch
*
* @return void;
*/
public function testNaturalSearch()
{
$s = natural_search("t.field", "abc def");
$this->assertEquals($s, " AND (t.field LIKE '%abc%' AND t.field LIKE '%def%')");
$s = natural_search("t.field", "'abc def' ghi");
$this->assertEquals($s, " AND (t.field LIKE '%abc def%' AND t.field LIKE '%ghi%')");
$s = natural_search("t.field", "abc def,ghi", 3);
$this->assertEquals($s, " AND (t.field IN ('abc def','ghi'))");
}
}