diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
index 1bbd13d9022..e6bcc7ad12e 100644
--- a/.php-cs-fixer.dist.php
+++ b/.php-cs-fixer.dist.php
@@ -8,6 +8,8 @@ $finder = (new PhpCsFixer\Finder())
'custom',
'documents',
'doctemplates',
+ 'vendor',
+ 'install/doctemplates',
'htdocs/custom',
'htdocs/includes',
'htdocs/install/doctemplates',
diff --git a/COPYRIGHT b/COPYRIGHT
index 31b7f47434e..fb2d6159e06 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -26,7 +26,7 @@ PHP libraries:
EvalMath 1.0 BSD Yes Safe math expressions evaluation. Used by dynamic price only. TODO Replace with dol_eval ?
Escpos-php 3.0 MIT License Yes Thermal receipt printer library, for use with ESC/POS compatible printers
GeoIP2 0.2.0 Apache License 2.0 Yes Lib to make geoip convert
-MathPHP 2.8.1 MIT License Yes Modern math library for PHP
+MathPHP 2.8.1 MIT License Yes Modern math library for PHP (only few files)
Mobiledetect 2.8.41 MIT License Yes Detect mobile devices browsers
NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package)
PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency
diff --git a/dev/tools/apstats.php b/dev/tools/apstats.php
index e15c8b5ace2..80e026bb600 100755
--- a/dev/tools/apstats.php
+++ b/dev/tools/apstats.php
@@ -38,6 +38,8 @@ error_reporting(E_ALL & ~E_DEPRECATED);
define('PRODUCT', "apstats");
define('VERSION', "1.0");
+$phpstanlevel = 2;
+
print '***** '.constant('PRODUCT').' - '.constant('VERSION').' *****'."\n";
if (empty($argv[1])) {
@@ -71,6 +73,7 @@ while ($i < $argc) {
$i++;
}
+$timestart = time();
// Count lines of code of Dolibarr itself
/*
@@ -86,7 +89,7 @@ $resexec = (int) (empty($resexec) ? 0 : trim($resexec));
*/
// Count lines of code of application
-$commandcheck = ($dirscc ? $dirscc.'/' : '').'scc . --exclude-dir=includes,custom';
+$commandcheck = ($dirscc ? $dirscc.'/' : '').'scc . --exclude-dir=htdocs/includes,htdocs/custom,htdocs/theme/common/fontawesome-5,htdocs/theme/common/octicons';
print 'Execute SCC to count lines of code in project: '.$commandcheck."\n";
$output_arrproj = array();
$resexecproj = 0;
@@ -94,7 +97,7 @@ exec($commandcheck, $output_arrproj, $resexecproj);
// Count lines of code of dependencies
-$commandcheck = ($dirscc ? $dirscc.'/' : '').'scc htdocs/includes';
+$commandcheck = ($dirscc ? $dirscc.'/' : '').'scc htdocs/includes htdocs/theme/common/fontawesome-5 htdocs/theme/common/octicons';
print 'Execute SCC to count lines of code in dependencies: '.$commandcheck."\n";
$output_arrdep = array();
$resexecdep = 0;
@@ -102,7 +105,7 @@ exec($commandcheck, $output_arrdep, $resexecdep);
// Get technical debt
-$commandcheck = ($dirphpstan ? $dirphpstan.'/' : '').'phpstan -v analyze -a build/phpstan/bootstrap.php --memory-limit 5G --error-format=github';
+$commandcheck = ($dirphpstan ? $dirphpstan.'/' : '').'phpstan --level='.$phpstanlevel.' -v analyze -a build/phpstan/bootstrap.php --memory-limit 5G --error-format=github';
print 'Execute PHPStan to get the technical debt: '.$commandcheck."\n";
$output_arrtd = array();
$resexectd = 0;
@@ -169,6 +172,8 @@ foreach (array('proj', 'dep') as $source) {
}
}
+$timeend = time();
+
/*
* View
@@ -224,7 +229,7 @@ th,td {
.nowrap {
white-space: nowrap;
}
-.opacity {
+.opacitymedium {
opacity: 0.5;
}
.centpercent {
@@ -238,6 +243,7 @@ th,td {
}
.seedetail {
color: #000088;
+ cursor: pointer;
}
.box {
padding: 20px;
@@ -293,7 +299,7 @@ $html .= '
'."\n";
$html .= ''."\n";
@@ -314,9 +320,9 @@ $html .= '';
foreach (array('proj', 'dep') as $source) {
$html .= '';
if ($source == 'proj') {
- $html .= 'All files from project only';
+ $html .= ' All files without dependencies';
} elseif ($source == 'dep') {
- $html .= ' All files from dependencies';
+ $html .= ' All files of dependencies only';
}
$html .= ' (See detail per file type...) ';
$html .= ' '.formatNumber($arrayofmetrics[$source]['Bytes']).' ';
@@ -372,19 +378,24 @@ $html .= ''.formatNumber($arraycocomo['proj']['people'] * $arraycocomo['proj'
$html .= ' monthes people ';
$html .= ''."\n";
-$html .= ''."\n";
-$html .= 'Technical debt ('.count($output_arrtd).') '."\n";
-$html .= ''."\n";
-$html .= '
'."\n";
-$html .= 'File Line Type '."\n";
+$tmp = '';
+$nblines = 0;
foreach ($output_arrtd as $line) {
$reg = array();
//print $line."\n";
preg_match('/^::error file=(.*),line=(\d+),col=(\d+)::(.*)$/', $line, $reg);
if (!empty($reg[1])) {
- $html .= ''.$reg[1].' '.$reg[2].' '.$reg[4].' '."\n";
+ $tmp .= ''.$reg[1].' '.$reg[2].' '.$reg[4].' '."\n";
+ $nblines++;
}
}
+
+$html .= ''."\n";
+$html .= 'Technical debt (PHPStan level '.$phpstanlevel.' -> '.$nblines.' warnings) '."\n";
+$html .= ''."\n";
+$html .= '
'."\n";
+$html .= 'File Line Type '."\n";
+$html .= $tmp;
$html .= '
';
$html .= '
';
$html .= ' '."\n";
diff --git a/dev/tools/php-cs-fixer/run-php-cs-fixer.sh b/dev/tools/php-cs-fixer/run-php-cs-fixer.sh
index b62befcf011..d8c9d4ae6bb 100755
--- a/dev/tools/php-cs-fixer/run-php-cs-fixer.sh
+++ b/dev/tools/php-cs-fixer/run-php-cs-fixer.sh
@@ -36,7 +36,7 @@ MINPHPVERSION="7.0"
echo "***** run-php-cs-fixer.sh *****"
if [ "x$1" = "x" ]; then
- echo "Syntax: run-php-cs-fixer.sh check|fix [path]"
+ echo "Syntax: run-php-cs-fixer.sh check|fix [path_from_root_project]"
exit 1;
fi
diff --git a/dev/tools/rector/src/Renaming/GlobalToFunction.php b/dev/tools/rector/src/Renaming/GlobalToFunction.php
index d20c2867cdb..656a7d4ff59 100644
--- a/dev/tools/rector/src/Renaming/GlobalToFunction.php
+++ b/dev/tools/rector/src/Renaming/GlobalToFunction.php
@@ -21,10 +21,12 @@ use Rector\Php71\ValueObject\TwoNodeMatch;
use Symplify\RuleDocGenerator\Exception\PoorDocumentationException;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
+use PhpParser\Node\Expr\BinaryOp\NotEqual;
use PhpParser\Node\Expr\BinaryOp\Greater;
use PhpParser\Node\Expr\BinaryOp\GreaterOrEqual;
use PhpParser\Node\Expr\BinaryOp\Smaller;
use PhpParser\Node\Expr\BinaryOp\SmallerOrEqual;
+use PhpParser\Node\Expr\BinaryOp\NotIdentical;
/**
* Class with Rector custom rule to fix code
@@ -55,7 +57,7 @@ class GlobalToFunction extends AbstractRector
public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition(
- 'Change $conf->global to getDolGlobal',
+ 'Change $conf->global to getDolGlobal in context (1) conf->global Operator Value or (2) function(conf->global...)',
[new CodeSample(
'$conf->global->CONSTANT',
'getDolGlobalInt(\'CONSTANT\')'
@@ -70,14 +72,15 @@ class GlobalToFunction extends AbstractRector
*/
public function getNodeTypes(): array
{
- return [Equal::class, Greater::class, GreaterOrEqual::class, Smaller::class, SmallerOrEqual::class, BooleanAnd::class, Concat::class, ArrayDimFetch::class];
+ return [FuncCall::class, Equal::class, NotEqual::class, Greater::class, GreaterOrEqual::class, Smaller::class, SmallerOrEqual::class, NotIdentical::class, BooleanAnd::class, Concat::class, ArrayDimFetch::class];
}
/**
* refactor
*
* @param Node $node A node
- * @return Equal|Concat|ArrayDimFetch|void
+ * @return FuncCall|Equal|Concat|ArrayDimFetch|void
+ * return $node unchanged or void to do nothing
*/
public function refactor(Node $node)
{
@@ -97,6 +100,35 @@ class GlobalToFunction extends AbstractRector
}
return $node;
}
+
+ if ($node instanceof FuncCall) {
+ $tmpfunctionname = $this->getName($node);
+ if (in_array($tmpfunctionname, array('dol_escape_htmltag', 'make_substitutions', 'min', 'max', 'explode'))) {
+ $args = $node->getArgs();
+ $nbofparam = count($args);
+
+ if ($nbofparam >= 1) {
+ $tmpargs = $args;
+ foreach ($args as $key => $arg) { // only 1 element in this array
+ //var_dump($key);
+ //var_dump($arg->value);exit;
+ if ($this->isGlobalVar($arg->value)) {
+ $constName = $this->getConstName($arg->value);
+ if (empty($constName)) {
+ return;
+ }
+ $a = new FuncCall(new Name('getDolGlobalString'), [new Arg($constName)]);
+ $tmpargs[$key] = new Arg($a);
+
+ $r = new FuncCall(new Name($tmpfunctionname), $tmpargs);
+ return $r;
+ }
+ }
+ }
+ }
+ return $node;
+ }
+
if ($node instanceof Concat) {
if ($this->isGlobalVar($node->left)) {
$constName = $this->getConstName($node->left);
@@ -125,6 +157,7 @@ class GlobalToFunction extends AbstractRector
}
return new Concat($leftConcat, $rightConcat);
}
+
if ($node instanceof BooleanAnd) {
$nodes = $this->resolveTwoNodeMatch($node);
if (!isset($nodes)) {
@@ -135,10 +168,16 @@ class GlobalToFunction extends AbstractRector
$node = $nodes->getFirstExpr();
}
+ // Now process all comparison like:
+ // $conf->global->... Operator Value
+
$typeofcomparison = '';
if ($node instanceof Equal) {
$typeofcomparison = 'Equal';
}
+ if ($node instanceof NotEqual) {
+ $typeofcomparison = 'NotEqual';
+ }
if ($node instanceof Greater) {
$typeofcomparison = 'Greater';
}
@@ -151,6 +190,10 @@ class GlobalToFunction extends AbstractRector
if ($node instanceof SmallerOrEqual) {
$typeofcomparison = 'SmallerOrEqual';
}
+ if ($node instanceof NotIdentical) {
+ $typeofcomparison = 'NotIdentical';
+ //var_dump($node->left);
+ }
if (empty($typeofcomparison)) {
return;
}
@@ -160,7 +203,8 @@ class GlobalToFunction extends AbstractRector
}
// Test the type after the comparison conf->global->xxx to know the name of function
- switch ($node->right->getType()) {
+ $typeright = $node->right->getType();
+ switch ($typeright) {
case 'Scalar_LNumber':
$funcName = 'getDolGlobalInt';
break;
@@ -185,6 +229,15 @@ class GlobalToFunction extends AbstractRector
$node->right
);
}
+ if ($typeofcomparison == 'NotEqual') {
+ return new NotEqual(
+ new FuncCall(
+ new Name($funcName),
+ [new Arg($constName)]
+ ),
+ $node->right
+ );
+ }
if ($typeofcomparison == 'Greater') {
return new Greater(
new FuncCall(
@@ -221,6 +274,15 @@ class GlobalToFunction extends AbstractRector
$node->right
);
}
+ if ($typeofcomparison == 'NotIdentical') {
+ return new NotIdentical(
+ new FuncCall(
+ new Name($funcName),
+ [new Arg($constName)]
+ ),
+ $node->right
+ );
+ }
}
/**
@@ -233,7 +295,7 @@ class GlobalToFunction extends AbstractRector
{
return $this->binaryOpManipulator->matchFirstAndSecondConditionNode(
$booleanAnd,
- // $conf->global == $value
+ // Function to check if we are in the case $conf->global->... == $value
function (Node $node): bool {
if (!$node instanceof Equal) {
return \false;
@@ -257,7 +319,7 @@ class GlobalToFunction extends AbstractRector
* Check if node is a global access with format conf->global->XXX
*
* @param Node $node A node
- * @return bool Return true if noe is conf->global->XXX
+ * @return bool Return true if node is conf->global->XXX
*/
private function isGlobalVar($node)
{
diff --git a/scripts/invoices/facturex-pdfextractxml.py b/dev/tools/test/facturex-pdfextractxml.py
similarity index 100%
rename from scripts/invoices/facturex-pdfextractxml.py
rename to dev/tools/test/facturex-pdfextractxml.py
diff --git a/htdocs/accountancy/admin/closure.php b/htdocs/accountancy/admin/closure.php
index d1b0d10e262..faf5360c984 100644
--- a/htdocs/accountancy/admin/closure.php
+++ b/htdocs/accountancy/admin/closure.php
@@ -145,14 +145,14 @@ print '';
print '';
print ''.$langs->trans("ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT").' ';
print '';
-print ' ';
+print ' ';
print ' ';
// Accounting groups used for the income statement
print '';
print ''.$langs->trans("ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT").' ';
print '';
-print ' ';
+print ' ';
print ' ';
print "
\n";
diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php
index a1881cf212d..aaba332d2ef 100644
--- a/htdocs/accountancy/bookkeeping/balance.php
+++ b/htdocs/accountancy/bookkeeping/balance.php
@@ -100,7 +100,7 @@ if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) {
$search_date_start = strtotime($fiscalYear->date_start);
$search_date_end = strtotime($fiscalYear->date_end);
} else {
- $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
+ $month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
$year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) {
$year_start--; // If current month is lower that starting fiscal month, we start last year
diff --git a/htdocs/accountancy/bookkeeping/export.php b/htdocs/accountancy/bookkeeping/export.php
index 5323c3c9cce..b6f21694a4f 100644
--- a/htdocs/accountancy/bookkeeping/export.php
+++ b/htdocs/accountancy/bookkeeping/export.php
@@ -170,7 +170,7 @@ if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GE
$search_date_start = strtotime($fiscalYear->date_start);
$search_date_end = strtotime($fiscalYear->date_end);
} else {
- $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
+ $month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
$year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) {
$year_start--; // If current month is lower that starting fiscal month, we start last year
diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index f722e32df08..580ea4287d1 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -165,7 +165,7 @@ if (!in_array($action, array('delmouv', 'delmouvconfirm')) && !GETPOSTISSET('beg
$search_date_start = strtotime($fiscalYear->date_start);
$search_date_end = strtotime($fiscalYear->date_end);
} else {
- $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
+ $month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
$year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) {
$year_start--; // If current month is lower that starting fiscal month, we start last year
diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php
index 864508e99d8..a6999195470 100644
--- a/htdocs/accountancy/bookkeeping/listbyaccount.php
+++ b/htdocs/accountancy/bookkeeping/listbyaccount.php
@@ -141,7 +141,7 @@ if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('searc
$search_date_start = strtotime($fiscalYear->date_start);
$search_date_end = strtotime($fiscalYear->date_end);
} else {
- $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
+ $month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
$year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) {
$year_start--; // If current month is lower that starting fiscal month, we start last year
diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php
index 8759890a020..ffda82c2174 100644
--- a/htdocs/accountancy/class/bookkeeping.class.php
+++ b/htdocs/accountancy/class/bookkeeping.class.php
@@ -367,7 +367,7 @@ class BookKeeping extends CommonObject
$this->piece_num = $objnum->piece_num;
}
- dol_syslog(get_class($this).":: create this->piece_num=".$this->piece_num, LOG_DEBUG);
+ dol_syslog(get_class($this)."::create this->piece_num=".$this->piece_num, LOG_DEBUG);
if (empty($this->piece_num)) {
$sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum";
$sqlnum .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php
index aeb9dc2009f..085c8a65e80 100644
--- a/htdocs/accountancy/closure/index.php
+++ b/htdocs/accountancy/closure/index.php
@@ -87,8 +87,8 @@ if (is_array($fiscal_periods)) {
}
}
-$accounting_groups_used_for_balance_sheet_account = array_filter(array_map('trim', explode(',', $conf->global->ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT)), 'strlen');
-$accounting_groups_used_for_income_statement = array_filter(array_map('trim', explode(',', $conf->global->ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT)), 'strlen');
+$accounting_groups_used_for_balance_sheet_account = array_filter(array_map('trim', explode(',', getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT'))), 'strlen');
+$accounting_groups_used_for_income_statement = array_filter(array_map('trim', explode(',', getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT'))), 'strlen');
/*
diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php
index 14e69593c02..0551a3fe95a 100644
--- a/htdocs/accountancy/customer/index.php
+++ b/htdocs/accountancy/customer/index.php
@@ -53,7 +53,7 @@ if (!$user->hasRight('accounting', 'bind', 'write')) {
$accountingAccount = new AccountingAccount($db);
-$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
+$month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
if (GETPOST("year", 'int')) {
$year_start = GETPOST("year", 'int');
} else {
diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php
index 0f0b5ec146c..1382eaf5ac6 100644
--- a/htdocs/accountancy/expensereport/index.php
+++ b/htdocs/accountancy/expensereport/index.php
@@ -36,7 +36,7 @@ $langs->loadLangs(array("compta", "bills", "other", "accountancy"));
$validatemonth = GETPOST('validatemonth', 'int');
$validateyear = GETPOST('validateyear', 'int');
-$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
+$month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
if (GETPOST("year", 'int')) {
$year_start = GETPOST("year", 'int');
} else {
diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php
index e9cb8de0705..5d80232d51d 100644
--- a/htdocs/accountancy/journal/bankjournal.php
+++ b/htdocs/accountancy/journal/bankjournal.php
@@ -104,10 +104,16 @@ $error = 0;
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
-if (empty($date_startmonth) || empty($date_endmonth)) {
+if (empty($date_startmonth)) {
// Period by default on transfer
$dates = getDefaultDatesForTransfer();
$date_start = $dates['date_start'];
+ $pastmonthyear = $dates['pastmonthyear'];
+ $pastmonth = $dates['pastmonth'];
+}
+if (empty($date_endmonth)) {
+ // Period by default on transfer
+ $dates = getDefaultDatesForTransfer();
$date_end = $dates['date_end'];
$pastmonthyear = $dates['pastmonthyear'];
$pastmonth = $dates['pastmonth'];
@@ -306,16 +312,28 @@ if ($result) {
// get_url may return -1 which is not traversable
if (is_array($links) && count($links) > 0) {
+ // Test if entry is for a social contribution, salary or expense report.
+ // In such a case, we will ignore the bank url line for user
$is_sc = false;
+ $is_salary = false;
+ $is_expensereport = false;
foreach ($links as $v) {
if ($v['type'] == 'sc') {
$is_sc = true;
break;
}
+ if ($v['type'] == 'payment_salary') {
+ $is_salary = true;
+ break;
+ }
+ if ($v['type'] == 'payment_expensereport') {
+ $is_expensereport = true;
+ break;
+ }
}
// Now loop on each link of record in bank (code similar to bankentries_list.php)
foreach ($links as $key => $val) {
- if ($links[$key]['type'] == 'user' && !$is_sc) {
+ if ($links[$key]['type'] == 'user' && !$is_sc && !$is_salary && !$is_expensereport) {
continue;
}
if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'member', 'payment_loan', 'payment_salary', 'payment_various'))) {
@@ -365,6 +383,7 @@ if ($result) {
$userstatic->firstname = $tabuser[$obj->rowid]['firstname'];
$userstatic->lastname = $tabuser[$obj->rowid]['lastname'];
$userstatic->statut = $tabuser[$obj->rowid]['status'];
+ $userstatic->status = $tabuser[$obj->rowid]['status'];
$userstatic->accountancy_code = $tabuser[$obj->rowid]['accountancy_code'];
if ($userstatic->id > 0) {
$tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0);
diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php
index 39fa8d8e050..fb86cdc3505 100644
--- a/htdocs/accountancy/journal/expensereportsjournal.php
+++ b/htdocs/accountancy/journal/expensereportsjournal.php
@@ -90,10 +90,16 @@ $journal_label = $accountingjournalstatic->label;
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
-if (empty($date_startmonth) || empty($date_endmonth)) {
+if (empty($date_startmonth)) {
// Period by default on transfer
$dates = getDefaultDatesForTransfer();
$date_start = $dates['date_start'];
+ $pastmonthyear = $dates['pastmonthyear'];
+ $pastmonth = $dates['pastmonth'];
+}
+if (empty($date_endmonth)) {
+ // Period by default on transfer
+ $dates = getDefaultDatesForTransfer();
$date_end = $dates['date_end'];
$pastmonthyear = $dates['pastmonthyear'];
$pastmonth = $dates['pastmonth'];
diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php
index ed03d708b79..8439ff5ec99 100644
--- a/htdocs/accountancy/journal/purchasesjournal.php
+++ b/htdocs/accountancy/journal/purchasesjournal.php
@@ -92,10 +92,16 @@ $journal_label = $accountingjournalstatic->label;
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
-if (empty($date_startmonth) || empty($date_endmonth)) {
+if (empty($date_startmonth)) {
// Period by default on transfer
$dates = getDefaultDatesForTransfer();
$date_start = $dates['date_start'];
+ $pastmonthyear = $dates['pastmonthyear'];
+ $pastmonth = $dates['pastmonth'];
+}
+if (empty($date_endmonth)) {
+ // Period by default on transfer
+ $dates = getDefaultDatesForTransfer();
$date_end = $dates['date_end'];
$pastmonthyear = $dates['pastmonthyear'];
$pastmonth = $dates['pastmonth'];
diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php
index 5ca5c164007..b91a7393572 100644
--- a/htdocs/accountancy/journal/sellsjournal.php
+++ b/htdocs/accountancy/journal/sellsjournal.php
@@ -94,10 +94,16 @@ $journal_label = $accountingjournalstatic->label;
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
-if (empty($date_startmonth) || empty($date_endmonth)) {
+if (empty($date_startmonth)) {
// Period by default on transfer
$dates = getDefaultDatesForTransfer();
$date_start = $dates['date_start'];
+ $pastmonthyear = $dates['pastmonthyear'];
+ $pastmonth = $dates['pastmonth'];
+}
+if (empty($date_endmonth)) {
+ // Period by default on transfer
+ $dates = getDefaultDatesForTransfer();
$date_end = $dates['date_end'];
$pastmonthyear = $dates['pastmonthyear'];
$pastmonth = $dates['pastmonth'];
@@ -464,7 +470,7 @@ if ($action == 'writebookkeeping' && !$error) {
// Warranty
if (!$errorforline) {
- if (is_iterable($tabwarranty[$key])) {
+ if (is_array($tabwarranty[$key])) {
foreach ($tabwarranty[$key] as $k => $mt) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
@@ -706,7 +712,7 @@ if ($action == 'writebookkeeping' && !$error) {
// Revenue stamp
if (!$errorforline) {
- if (is_iterable($tabrevenuestamp[$key])) {
+ if (is_array($tabrevenuestamp[$key])) {
foreach ($tabrevenuestamp[$key] as $k => $mt) {
if ($mt) {
$accountingaccount->fetch(null, $k, true); // TODO Use a cache for label
@@ -1144,7 +1150,7 @@ if (empty($action) || $action == 'view') {
}
// Warranty
- if (is_iterable($tabwarranty[$key])) {
+ if (is_array($tabwarranty[$key])) {
foreach ($tabwarranty[$key] as $k => $mt) {
print '
';
print "";
@@ -1292,7 +1298,7 @@ if (empty($action) || $action == 'view') {
}
// Revenue stamp
- if (is_iterable($tabrevenuestamp[$key])) {
+ if (is_array($tabrevenuestamp[$key])) {
foreach ($tabrevenuestamp[$key] as $k => $mt) {
print ' ';
print "";
diff --git a/htdocs/accountancy/journal/variousjournal.php b/htdocs/accountancy/journal/variousjournal.php
index 7d496cee5a0..0906f7c4754 100644
--- a/htdocs/accountancy/journal/variousjournal.php
+++ b/htdocs/accountancy/journal/variousjournal.php
@@ -61,10 +61,16 @@ $parameters = array();
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
-if (empty($date_startmonth) || empty($date_endmonth)) {
+if (empty($date_startmonth)) {
// Period by default on transfer
$dates = getDefaultDatesForTransfer();
$date_start = $dates['date_start'];
+ $pastmonthyear = $dates['pastmonthyear'];
+ $pastmonth = $dates['pastmonth'];
+}
+if (empty($date_endmonth)) {
+ // Period by default on transfer
+ $dates = getDefaultDatesForTransfer();
$date_end = $dates['date_end'];
$pastmonthyear = $dates['pastmonthyear'];
$pastmonth = $dates['pastmonth'];
diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php
index fd07ac82704..a8181885c3a 100644
--- a/htdocs/accountancy/supplier/index.php
+++ b/htdocs/accountancy/supplier/index.php
@@ -51,7 +51,7 @@ if (!$user->hasRight('accounting', 'bind', 'write')) {
$accountingAccount = new AccountingAccount($db);
-$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
+$month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
if (GETPOST("year", 'int')) {
$year_start = GETPOST("year", 'int');
} else {
diff --git a/htdocs/accountancy/tpl/export_journal.tpl.php b/htdocs/accountancy/tpl/export_journal.tpl.php
index 0a87cf13b4a..9853dd08bf1 100644
--- a/htdocs/accountancy/tpl/export_journal.tpl.php
+++ b/htdocs/accountancy/tpl/export_journal.tpl.php
@@ -53,7 +53,7 @@ if (($accountancyexport->getFormatCode($formatexportset) == 'fec' || $accountanc
}
$datetouseforfilename = $search_date_end;
$tmparray = dol_getdate($datetouseforfilename);
- $fiscalmonth = !getDolGlobalString('SOCIETE_FISCAL_MONTH_START') ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START;
+ $fiscalmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
// Define end of month to use
if ($tmparray['mon'] < $fiscalmonth || $fiscalmonth == 1) {
$tmparray['mon'] = $fiscalmonth == 1 ? 12 : $fiscalmonth - 1;
diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php
index 06cd83397c4..b78cd367c9d 100644
--- a/htdocs/adherents/admin/member.php
+++ b/htdocs/adherents/admin/member.php
@@ -353,12 +353,12 @@ print " \n";
print '
';
print $langs->trans("MemberSubscriptionStartAfter");
print ' ';
-print ' ';
+print ' ';
print " \n";
// Mail required for members
print '
'.$langs->trans("AdherentMailRequired").' ';
-print $form->selectyesno('ADHERENT_MAIL_REQUIRED', (getDolGlobalString('ADHERENT_MAIL_REQUIRED') ? $conf->global->ADHERENT_MAIL_REQUIRED : 0), 1);
+print $form->selectyesno('ADHERENT_MAIL_REQUIRED', getDolGlobalInt('ADHERENT_MAIL_REQUIRED'), 1);
print " \n";
// Login/Pass required for members
@@ -370,24 +370,24 @@ print "
\n";
// Send mail information is on by default
print ''.$langs->trans("MemberSendInformationByMailByDefault").' ';
-print $form->selectyesno('ADHERENT_DEFAULT_SENDINFOBYMAIL', (getDolGlobalString('ADHERENT_DEFAULT_SENDINFOBYMAIL') ? $conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL : 0), 1);
+print $form->selectyesno('ADHERENT_DEFAULT_SENDINFOBYMAIL', getDolGlobalInt('ADHERENT_DEFAULT_SENDINFOBYMAIL', 0), 1);
print " \n";
// Create an external user login for each new member subscription validated
print ''.$langs->trans("MemberCreateAnExternalUserForSubscriptionValidated").' ';
-print $form->selectyesno('ADHERENT_CREATE_EXTERNAL_USER_LOGIN', (getDolGlobalString('ADHERENT_CREATE_EXTERNAL_USER_LOGIN') ? $conf->global->ADHERENT_CREATE_EXTERNAL_USER_LOGIN : 0), 1);
+print $form->selectyesno('ADHERENT_CREATE_EXTERNAL_USER_LOGIN', getDolGlobalInt('ADHERENT_CREATE_EXTERNAL_USER_LOGIN', 0), 1);
print " \n";
// Create an external user login for each new member subscription validated
-$linkofpubliclist = DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.((isModEnabled('multicompany')) ? '?entity='.$conf->entity : '');
+$linkofpubliclist = DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.((isModEnabled('multicompany')) ? '?entity='.((int) $conf->entity) : '');
print ''.$langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist).' ';
-print $form->selectyesno('MEMBER_PUBLIC_ENABLED', (getDolGlobalString('MEMBER_PUBLIC_ENABLED') ? $conf->global->MEMBER_PUBLIC_ENABLED : 0), 1);
+print $form->selectyesno('MEMBER_PUBLIC_ENABLED', getDolGlobalInt('MEMBER_PUBLIC_ENABLED', 0), 1);
print " \n";
// Allow members to change type on renewal forms
/* To test during next beta
print ''.$langs->trans("MemberAllowchangeOfType").' ';
-print $form->selectyesno('MEMBER_ALLOW_CHANGE_OF_TYPE', (!empty($conf->global->MEMBER_ALLOW_CHANGE_OF_TYPE) ? 0 : 1), 1);
+print $form->selectyesno('MEMBER_ALLOW_CHANGE_OF_TYPE', (getDolGlobalInt('MEMBER_ALLOW_CHANGE_OF_TYPE') ? 0 : 1), 1);
print " \n";
*/
@@ -416,7 +416,7 @@ if (isModEnabled('facture')) {
print ''.$langs->trans("VATToUseForSubscriptions").' ';
if (isModEnabled("banque")) {
print '';
- print $form->selectarray('ADHERENT_VAT_FOR_SUBSCRIPTIONS', array('0'=>$langs->trans("NoVatOnSubscription"), 'defaultforfoundationcountry'=>$langs->trans("Default")), (!getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') ? '0' : $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS), 0);
+ print $form->selectarray('ADHERENT_VAT_FOR_SUBSCRIPTIONS', array('0'=>$langs->trans("NoVatOnSubscription"), 'defaultforfoundationcountry'=>$langs->trans("Default")), getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS', '0'), 0);
print ' ';
} else {
print '';
@@ -428,7 +428,7 @@ if (isModEnabled('facture')) {
if (isModEnabled("product") || isModEnabled("service")) {
print ' '.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").' ';
print '';
- $selected = (!getDolGlobalString('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') ? '' : $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
+ $selected = getDolGlobalString('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS');
print img_picto('', 'product', 'class="pictofixedwidth"');
$form->select_produits($selected, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', '', 0);
print ' ';
diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php
index 4a9ba7ee1c7..8ac296f9449 100644
--- a/htdocs/adherents/admin/website.php
+++ b/htdocs/adherents/admin/website.php
@@ -215,7 +215,7 @@ if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
print '';
$listofval = array();
$listofval += $adht->liste_array(1);
- $forcetype = !getDolGlobalString('MEMBER_NEWFORM_FORCETYPE') ? -1 : $conf->global->MEMBER_NEWFORM_FORCETYPE;
+ $forcetype = getDolGlobalInt('MEMBER_NEWFORM_FORCETYPE', -1);
print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval) > 1 ? 1 : 0);
print " \n";
@@ -225,7 +225,7 @@ if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
print '';
print $langs->trans("ForceMemberNature");
print ' ';
- $forcenature = !getDolGlobalString('MEMBER_NEWFORM_FORCEMORPHY') ? 0 : $conf->global->MEMBER_NEWFORM_FORCEMORPHY;
+ $forcenature = getDolGlobalInt('MEMBER_NEWFORM_FORCEMORPHY', 0);
print $form->selectarray("MEMBER_NEWFORM_FORCEMORPHY", $morphys, $forcenature, 1);
print " \n";
@@ -233,25 +233,25 @@ if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
print '';
print $langs->trans("DefaultAmount");
print ' ';
- print ' ';
+ print ' ';
print " \n";
// Min amount
print '';
print $langs->trans("MinimumAmount");
print ' ';
- print ' ';
+ print ' ';
print " \n";
// SHow counter of validated members publicly
print '';
print $langs->trans("MemberCountersArePublic");
print ' ';
- print $form->selectyesno("MEMBER_COUNTERS_ARE_PUBLIC", (getDolGlobalString('MEMBER_COUNTERS_ARE_PUBLIC') ? $conf->global->MEMBER_COUNTERS_ARE_PUBLIC : 0), 1);
+ print $form->selectyesno("MEMBER_COUNTERS_ARE_PUBLIC", getDolGlobalInt('MEMBER_COUNTERS_ARE_PUBLIC'), 1);
print " \n";
// Show the table of all available membership types. If not, show a form (as the default was for Dolibarr <=16.0)
- $skiptable = (getDolGlobalString('MEMBER_SKIP_TABLE') ? $conf->global->MEMBER_SKIP_TABLE : 0);
+ $skiptable = getDolGlobalInt('MEMBER_SKIP_TABLE');
print '';
print $langs->trans("MembersShowMembershipTypesTable");
print ' ';
@@ -259,7 +259,7 @@ if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
print " \n";
// Show "vote allowed" setting for membership types
- $hidevoteallowed = (getDolGlobalString('MEMBER_HIDE_VOTE_ALLOWED') ? $conf->global->MEMBER_HIDE_VOTE_ALLOWED : 0);
+ $hidevoteallowed = getDolGlobalInt('MEMBER_HIDE_VOTE_ALLOWED');
print '';
print $langs->trans("MembersShowVotesAllowed");
print ' ';
@@ -282,7 +282,7 @@ if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
if (isModEnabled('stripe')) {
$listofval['stripe'] = 'Stripe';
}
- print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, (getDolGlobalString('MEMBER_NEWFORM_PAYONLINE') ? $conf->global->MEMBER_NEWFORM_PAYONLINE : ''), 0);
+ print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, getDolGlobalString('MEMBER_NEWFORM_PAYONLINE'), 0);
print " \n";
print '';
diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php
index fcfe87209c0..c47e745c8b8 100644
--- a/htdocs/adherents/cartes/carte.php
+++ b/htdocs/adherents/cartes/carte.php
@@ -150,10 +150,10 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
// For business cards
if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') {
- $textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray);
- $textheader = make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray);
- $textfooter = make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray);
- $textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray);
+ $textleft = make_substitutions(getDolGlobalString('ADHERENT_CARD_TEXT'), $substitutionarray);
+ $textheader = make_substitutions(getDolGlobalString('ADHERENT_CARD_HEADER_TEXT'), $substitutionarray);
+ $textfooter = make_substitutions(getDolGlobalString('ADHERENT_CARD_FOOTER_TEXT'), $substitutionarray);
+ $textright = make_substitutions(getDolGlobalString('ADHERENT_CARD_TEXT_RIGHT'), $substitutionarray);
if (is_numeric($foruserid) || $foruserlogin) {
$nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY']; // $_Avery_Labels is defined into an include
@@ -190,7 +190,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
if (!getDolGlobalString('ADHERENT_ETIQUETTE_TEXT')) {
$conf->global->ADHERENT_ETIQUETTE_TEXT = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__";
}
- $textleft = make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray);
+ $textleft = make_substitutions(getDolGlobalString('ADHERENT_ETIQUETTE_TEXT'), $substitutionarray);
$textheader = '';
$textfooter = '';
$textright = '';
@@ -275,7 +275,7 @@ dol_htmloutput_errors($mesg);
print ' ';
-print img_picto('', 'card').' '.$langs->trans("DocForAllMembersCards", (getDolGlobalString('ADHERENT_CARD_TYPE') ? $conf->global->ADHERENT_CARD_TYPE : $langs->transnoentitiesnoconv("None"))).' ';
+print img_picto('', 'card').' '.$langs->trans("DocForAllMembersCards", getDolGlobalString('ADHERENT_CARD_TYPE', $langs->transnoentitiesnoconv("None"))).' ';
print '';
print ' ';
-print img_picto('', 'card').' '.$langs->trans("DocForOneMemberCards", (getDolGlobalString('ADHERENT_CARD_TYPE') ? $conf->global->ADHERENT_CARD_TYPE : $langs->transnoentitiesnoconv("None"))).' ';
+print img_picto('', 'card').' '.$langs->trans("DocForOneMemberCards", getDolGlobalString('ADHERENT_CARD_TYPE', $langs->transnoentitiesnoconv("None"))).' ';
print '';
print ' ';
-print img_picto('', 'card').' '.$langs->trans("DocForLabels", (!getDolGlobalString('ADHERENT_ETIQUETTE_TYPE') ? '' : $conf->global->ADHERENT_ETIQUETTE_TYPE)).' ';
+print img_picto('', 'card').' '.$langs->trans("DocForLabels", getDolGlobalString('ADHERENT_ETIQUETTE_TYPE')).' ';
print '';
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index 294e0c4689d..51af75d9591 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -1151,7 +1151,6 @@ class Adherent extends CommonObject
// Mise a jour
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent";
$sql .= " SET pass_crypted = '".$this->db->escape($password_crypted)."'";
- //if (!empty($conf->global->DATABASE_PWD_ENCRYPTED))
if ($isencrypted) {
$sql .= ", pass = null";
} else {
@@ -1921,7 +1920,7 @@ class Adherent extends CommonObject
$outputlangs->setDefaultLang($newlang);
}
// Generate PDF (whatever is option MAIN_DISABLE_PDF_AUTOUPDATE) so we can include it into email
- //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
+ //if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE'))
$invoice->generateDocument($invoice->model_pdf, $outputlangs);
}
@@ -2727,7 +2726,7 @@ class Adherent extends CommonObject
$keymodified = false;
// Object classes
- $info["objectclass"] = explode(',', $conf->global->LDAP_MEMBER_OBJECT_CLASS);
+ $info["objectclass"] = explode(',', getDolGlobalString('LDAP_MEMBER_OBJECT_CLASS'));
$this->fullname = $this->getFullName($langs);
@@ -2752,7 +2751,7 @@ class Adherent extends CommonObject
$info[getDolGlobalString($constname)] = $this->$varname;
// Check if it is the LDAP key and if its value has been changed
- if (getDolGlobalString('LDAP_KEY_MEMBERS') && $conf->global->LDAP_KEY_MEMBERS == getDolGlobalString($constname)) {
+ if (getDolGlobalString('LDAP_KEY_MEMBERS') && getDolGlobalString('LDAP_KEY_MEMBERS') == getDolGlobalString($constname)) {
if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) {
$keymodified = true; // For check if LDAP key has been modified
}
@@ -2821,15 +2820,15 @@ class Adherent extends CommonObject
if (getDolGlobalString('LDAP_MEMBER_FIELD_PASSWORD_CRYPTED')) {
$info[getDolGlobalString('LDAP_MEMBER_FIELD_PASSWORD_CRYPTED')] = dol_hash($this->pass, 'openldap'); // Create OpenLDAP password (see LDAP_PASSWORD_HASH_TYPE)
}
- } elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !== '3') {
+ } elseif (getDolGlobalString('LDAP_SERVER_PROTOCOLVERSION') !== '3') {
// Set LDAP password if possible
// If ldap key is modified and LDAPv3 we use ldap_rename function for avoid lose encrypt password
- if (getDolGlobalString('DATABASE_PWD_ENCRYPTED')) {
- // Just for the default MD5 !
- if (!getDolGlobalString('MAIN_SECURITY_HASH_ALGO')) {
+ if (getDolGlobalString('DATABASE_PWD_ENCRYPTED')) { // This should be on on default installation
+ // Just for the case we use old md5 encryption (deprecated, no more used, kept for compatibility)
+ if (!getDolGlobalString('MAIN_SECURITY_HASH_ALGO') || getDolGlobalString('MAIN_SECURITY_HASH_ALGO') == 'md5') {
if ($this->pass_indatabase_crypted && getDolGlobalString('LDAP_MEMBER_FIELD_PASSWORD_CRYPTED')) {
// Create OpenLDAP MD5 password from Dolibarr MD5 password
- // Note: This suppose that "pass_indatabase_crypted" is a md5 (guaranted by the previous test if "(empty($conf->global->MAIN_SECURITY_HASH_ALGO))"
+ // Note: This suppose that "pass_indatabase_crypted" is a md5 (this should not happen anymore)"
$info[getDolGlobalString('LDAP_MEMBER_FIELD_PASSWORD_CRYPTED')] = dolGetLdapPasswordHash($this->pass_indatabase_crypted, 'md5frommd5');
}
}
diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php
index c75ec565b35..4832a4242e7 100644
--- a/htdocs/adherents/class/adherent_type.class.php
+++ b/htdocs/adherents/class/adherent_type.class.php
@@ -844,7 +844,7 @@ class AdherentType extends CommonObject
$dn = getDolGlobalString('LDAP_KEY_MEMBERS_TYPES') . "=".$info[getDolGlobalString('LDAP_KEY_MEMBERS_TYPES')]."," . getDolGlobalString('LDAP_MEMBER_TYPE_DN');
}
if ($mode == 1) {
- $dn = $conf->global->LDAP_MEMBER_TYPE_DN;
+ $dn = getDolGlobalString('LDAP_MEMBER_TYPE_DN');
}
if ($mode == 2) {
$dn = getDolGlobalString('LDAP_KEY_MEMBERS_TYPES') . "=".$info[getDolGlobalString('LDAP_KEY_MEMBERS_TYPES')];
@@ -868,7 +868,7 @@ class AdherentType extends CommonObject
$info = array();
// Object classes
- $info["objectclass"] = explode(',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS);
+ $info["objectclass"] = explode(',', getDolGlobalString('LDAP_MEMBER_TYPE_OBJECT_CLASS'));
if (empty($this->note_public) && !empty($this->note)) { // For backward compatibility
$this->note_public = $this->note;
diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php
index f430e59f68d..4de525281b1 100644
--- a/htdocs/adherents/class/api_members.class.php
+++ b/htdocs/adherents/class/api_members.class.php
@@ -294,6 +294,12 @@ class Members extends DolibarrApi
$member = new Adherent($this->db);
foreach ($request_data as $field => $value) {
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $member->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
$member->$field = $value;
}
if ($member->create(DolibarrApiAccess::$user) < 0) {
@@ -329,6 +335,12 @@ class Members extends DolibarrApi
if ($field == 'id') {
continue;
}
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $member->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
// Process the status separately because it must be updated using
// the validate(), resiliate() and exclude() methods of the class Adherent.
if ($field == 'statut') {
diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php
index 458af55a36b..5f1a1aec7b6 100644
--- a/htdocs/adherents/class/api_memberstypes.class.php
+++ b/htdocs/adherents/class/api_memberstypes.class.php
@@ -159,6 +159,12 @@ class MembersTypes extends DolibarrApi
$membertype = new AdherentType($this->db);
foreach ($request_data as $field => $value) {
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $membertype->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
$membertype->$field = $value;
}
if ($membertype->create(DolibarrApiAccess::$user) < 0) {
@@ -194,6 +200,12 @@ class MembersTypes extends DolibarrApi
if ($field == 'id') {
continue;
}
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $membertype->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
// Process the status separately because it must be updated using
// the validate(), resiliate() and exclude() methods of the class AdherentType.
$membertype->$field = $value;
diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php
index 174de6d5fe9..9c051ac6a41 100644
--- a/htdocs/adherents/class/api_subscriptions.class.php
+++ b/htdocs/adherents/class/api_subscriptions.class.php
@@ -156,6 +156,12 @@ class Subscriptions extends DolibarrApi
$subscription = new Subscription($this->db);
foreach ($request_data as $field => $value) {
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $subscription->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
$subscription->$field = $value;
}
if ($subscription->create(DolibarrApiAccess::$user) < 0) {
@@ -187,6 +193,12 @@ class Subscriptions extends DolibarrApi
if ($field == 'id') {
continue;
}
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $subscription->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
$subscription->$field = $value;
}
diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php
index 351b7092dd8..d2cd86f7de0 100644
--- a/htdocs/adherents/stats/byproperties.php
+++ b/htdocs/adherents/stats/byproperties.php
@@ -41,7 +41,7 @@ if ($user->socid > 0) {
$result = restrictedArea($user, 'adherent', '', '', 'cotisation');
$year = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
-$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
+$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS'))));
$endyear = $year;
// Load translation files required by the page
diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php
index 4dc2f756df1..fd64e315ff1 100644
--- a/htdocs/adherents/stats/geo.php
+++ b/htdocs/adherents/stats/geo.php
@@ -43,7 +43,7 @@ if ($user->socid > 0) {
$result = restrictedArea($user, 'adherent', '', '', 'cotisation');
$year = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
-$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
+$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS'))));
$endyear = $year;
// Load translation files required by the page
diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php
index 182957bc97d..511553b9e88 100644
--- a/htdocs/adherents/subscription.php
+++ b/htdocs/adherents/subscription.php
@@ -1056,7 +1056,7 @@ if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->h
print $langs->trans("CreateDolibarrThirdParty");
print ')';
}
- if (!getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') {
+ if (!getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') || getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') != 'defaultforfoundationcountry') {
print '. '.$langs->trans("NoVatOnSubscription", 0).' ';
}
if (getDolGlobalString('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && (isModEnabled('product') || isModEnabled('service'))) {
@@ -1086,7 +1086,7 @@ if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->h
print $langs->trans("CreateDolibarrThirdParty");
print ')';
}
- if (!getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') {
+ if (!getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') || getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') != 'defaultforfoundationcountry') {
print '. '.$langs->trans("NoVatOnSubscription", 0).' ';
}
if (getDolGlobalString('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && (isModEnabled('product')|| isModEnabled('service'))) {
diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php
index 2fac417ab8c..c92d0032176 100644
--- a/htdocs/admin/company.php
+++ b/htdocs/admin/company.php
@@ -460,7 +460,7 @@ print ''."\n";
print ''.$langs->trans("State").' ';
$state_id = 0;
if (getDolGlobalString('MAIN_INFO_SOCIETE_STATE')) {
- $tmp = explode(':', $conf->global->MAIN_INFO_SOCIETE_STATE);
+ $tmp = explode(':', getDolGlobalString('MAIN_INFO_SOCIETE_STATE'));
$state_id = $tmp[0];
}
print img_picto('', 'state', 'class="pictofixedwidth"');
@@ -768,7 +768,7 @@ print ' '.$langs->trans("FiscalYearInformation").'
print " \n";
print ''.$langs->trans("FiscalMonthStart").' ';
-print $formother->select_month(getDolGlobalString('SOCIETE_FISCAL_MONTH_START') ? $conf->global->SOCIETE_FISCAL_MONTH_START : '', 'SOCIETE_FISCAL_MONTH_START', 0, 1, 'maxwidth100').' ';
+print $formother->select_month(getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') ? $conf->global->SOCIETE_FISCAL_MONTH_START : '', 'SOCIETE_FISCAL_MONTH_START', 0, 1, 'maxwidth100').'';
print "";
diff --git a/htdocs/admin/company_socialnetworks.php b/htdocs/admin/company_socialnetworks.php
index 426b5a8eeb3..d4784351dba 100644
--- a/htdocs/admin/company_socialnetworks.php
+++ b/htdocs/admin/company_socialnetworks.php
@@ -128,11 +128,11 @@ foreach ($listofnetworks as $key => $value) {
$networkconstname = 'MAIN_INFO_SOCIETE_'.strtoupper($key).'_URL';
$networkconstid = 'MAIN_INFO_SOCIETE_'.strtoupper($key);
print ' ';
- print ' ';
+ print ' ';
print '';
- print ' ';
+ print ' ';
print ' ';
- print ''.dol_print_socialnetworks((!empty($conf->global->$networkconstid) ? dol_escape_htmltag($conf->global->$networkconstid) : ''), 0, 0, $key, $listofnetworks).' ';
+ print ''.dol_print_socialnetworks((!empty($conf->global->$networkconstid) ? dol_escape_htmltag(getDolGlobalString($networkconstid)) : ''), 0, 0, $key, $listofnetworks).' ';
print ''."\n";
}
}
diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php
index 804797237b8..8e4ae808f3e 100644
--- a/htdocs/admin/delais.php
+++ b/htdocs/admin/delais.php
@@ -286,7 +286,7 @@ if ($action == 'edit') {
print ' ';
-if (!getDolGlobalString('MAIN_DISABLE_METEO') || $conf->global->MAIN_DISABLE_METEO != 1) {
+if (!getDolGlobalString('MAIN_DISABLE_METEO') || getDolGlobalInt('MAIN_DISABLE_METEO') != 1) {
// Show logo for weather
print ''.$langs->trans("DescWeather").' ';
diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php
index dca0d5c02f7..e85f5aa51ea 100644
--- a/htdocs/admin/external_rss.php
+++ b/htdocs/admin/external_rss.php
@@ -262,13 +262,13 @@ if ($resql) {
print '';
print ''.$langs->trans("Title")." ";
- print ' ';
+ print ' ';
print ' '."\n";
print '';
print "".$langs->trans("URL")." ";
- print ' ';
+ print ' ';
print ' '."\n";
diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php
index 0f33e1506f5..5f8afdb7fe2 100644
--- a/htdocs/admin/mails.php
+++ b/htdocs/admin/mails.php
@@ -707,7 +707,7 @@ if ($action == 'edit') {
// SMTPS PW
if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') != "XOAUTH2") {
- print ''.$langs->trans("MAIN_MAIL_SMTPS_PW").' '.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW).' ';
+ print ''.$langs->trans("MAIN_MAIL_SMTPS_PW").' '.preg_replace('/./', '*', getDolGlobalString('MAIN_MAIL_SMTPS_PW')).' ';
}
// SMTPS oauth service
@@ -918,7 +918,7 @@ if ($action == 'edit') {
print ''.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").' ';
print '';
if (getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO')) {
- $listofemail = explode(',', $conf->global->MAIN_MAIL_AUTOCOPY_TO);
+ $listofemail = explode(',', getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO'));
$i = 0;
foreach ($listofemail as $key => $val) {
if ($i) {
diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php
index dbb6ad27d61..eee4b71f42b 100644
--- a/htdocs/admin/mails_emailing.php
+++ b/htdocs/admin/mails_emailing.php
@@ -533,7 +533,7 @@ if ($action == 'edit') {
}
print ' ';
- if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') {
+ if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') && getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') {
// Host server
if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') == 'mail')) {
//print ''.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").' '.$langs->trans("SeeLocalSendMailSetup").' ';
@@ -653,8 +653,8 @@ if ($action == 'edit') {
print ''.$langs->trans("Modify").' ';
- if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') {
- if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'mail' || !$linuxlike) {
+ if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') && getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') {
+ if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'mail' || !$linuxlike) {
if (function_exists('fsockopen') && $port && $server) {
print '' . $langs->trans("DoTestServerAvailability") . ' ';
}
diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php
index 104efa16c19..1fa1cd2bb33 100644
--- a/htdocs/admin/mails_ticket.php
+++ b/htdocs/admin/mails_ticket.php
@@ -510,7 +510,7 @@ if ($action == 'edit') {
}
print '';
- if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') && $conf->global->MAIN_MAIL_SENDMODE_TICKET != 'default') {
+ if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') && getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') != 'default') {
// Host server
if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'mail')) {
//print ''.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").' '.$langs->trans("SeeLocalSendMailSetup").' ';
@@ -615,8 +615,8 @@ if ($action == 'edit') {
print ''.$langs->trans("Modify").' ';
- if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') && $conf->global->MAIN_MAIL_SENDMODE_TICKET != 'default') {
- if ($conf->global->MAIN_MAIL_SENDMODE_TICKET != 'mail' || !$linuxlike) {
+ if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') && getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') != 'default') {
+ if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') != 'mail' || !$linuxlike) {
if (function_exists('fsockopen') && $port && $server) {
print ''.$langs->trans("DoTestServerAvailability").' ';
}
diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php
index 038a41c66bb..0c191d9ae7b 100644
--- a/htdocs/admin/security_file.php
+++ b/htdocs/admin/security_file.php
@@ -155,7 +155,7 @@ if (isset($max)) {
}
print '';
print '';
-print ' '.$langs->trans("Kb");
+print ' '.$langs->trans("Kb");
print ' ';
print '';
@@ -165,7 +165,7 @@ print '';
print $form->textwithpicto($langs->trans("UMask"), $langs->trans("UMaskExplanation"));
print ' ';
print '';
-print ' ';
+print ' ';
print ' ';
print '';
@@ -200,7 +200,7 @@ print ''.$langs->trans("AntiVirusParam").' ';
print ''.$langs->trans("AntiVirusParamExample").' ';
print ' ';
print '';
-print ' ';
+print ' ';
if (defined('MAIN_ANTIVIRUS_PARAM')) {
print ''.$langs->trans("ValueIsForcedBySystem").' ';
}
diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php
index e45d581c35f..7ad70c385b5 100644
--- a/htdocs/admin/system/security.php
+++ b/htdocs/admin/system/security.php
@@ -350,7 +350,7 @@ print ' -> PHP streams allowed = ';
$arrayofstreams = stream_get_wrappers();
if (!empty($arrayofstreams)) {
sort($arrayofstreams);
- print (join(',', $arrayofstreams)).' ('.$langs->trans("Recommended").': '.$langs->trans("TryToKeepOnly", 'file,http,https,php').') '."\n";
+ print(join(',', $arrayofstreams)).' ('.$langs->trans("Recommended").': '.$langs->trans("TryToKeepOnly", 'file,http,https,php').') '."\n";
}
print ' ';
@@ -627,13 +627,13 @@ print 'MAIN_SECURITY_HASH_ALGO = '.getDolGlobalString('MAIN_SEC
if (!getDolGlobalString('MAIN_SECURITY_HASH_ALGO')) {
print ' If unset: \'md5\' ';
}
-if ($conf->global->MAIN_SECURITY_HASH_ALGO != 'password_hash') {
+if (getDolGlobalString('MAIN_SECURITY_HASH_ALGO') != 'password_hash') {
print 'MAIN_SECURITY_SALT = '.getDolGlobalString('MAIN_SECURITY_SALT', ''.$langs->trans("Undefined").' ').' ';
} else {
print '('.$langs->trans("Recommended").': password_hash) ';
print ' ';
}
-if ($conf->global->MAIN_SECURITY_HASH_ALGO != 'password_hash') {
+if (getDolGlobalString('MAIN_SECURITY_HASH_ALGO') != 'password_hash') {
print 'The recommanded value for MAIN_SECURITY_HASH_ALGO is now \'password_hash\' but setting it now will make ALL existing passwords of all users not valid, so update is not possible. ';
print 'If you really want to switch, you must: ';
print '- Go on home - setup - other and add constant MAIN_SECURITY_HASH_ALGO to value \'password_hash\' ';
diff --git a/htdocs/api/admin/explorer_withredoc.php b/htdocs/api/admin/explorer_withredoc.php
index 387da2a06af..8c94e7a6f62 100644
--- a/htdocs/api/admin/explorer_withredoc.php
+++ b/htdocs/api/admin/explorer_withredoc.php
@@ -47,7 +47,7 @@ if (getDolGlobalString('API_EXPLORER_DISABLED')) {
// Restrict API to some IPs
if (getDolGlobalString('API_RESTRICT_ON_IP')) {
- $allowedip = explode(' ', $conf->global->API_RESTRICT_ON_IP);
+ $allowedip = explode(' ', getDolGlobalString('API_RESTRICT_ON_IP'));
$ipremote = getUserRemoteIP();
if (!in_array($ipremote, $allowedip)) {
dol_syslog('Remote ip is '.$ipremote.', not into list ' . getDolGlobalString('API_RESTRICT_ON_IP'));
diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php
index 868b03304e5..ffa57c6e3f8 100644
--- a/htdocs/api/class/api.class.php
+++ b/htdocs/api/class/api.class.php
@@ -78,18 +78,24 @@ class DolibarrApi
* Display a short message an return a http code 200
*
* @param string $field Field name
- * @param string $value Value to check/clean
+ * @param mixed $value Value to check/clean
* @param Object $object Object
* @return string Value cleaned
*/
protected function _checkValForAPI($field, $value, $object)
{
// phpcs:enable
- // TODO Use type detected in $object->fields
- if (in_array($field, array('note', 'note_private', 'note_public', 'desc', 'description'))) {
- return sanitizeVal($value, 'restricthtml');
+ if (!is_array($value)) {
+ // TODO Use type detected in $object->fields if $object known and we can
+ if (in_array($field, array('note', 'note_private', 'note_public', 'desc', 'description'))) {
+ return sanitizeVal($value, 'restricthtml');
+ } else {
+ return sanitizeVal($value, 'alphanohtml');
+ }
} else {
- return sanitizeVal($value, 'alphanohtml');
+ // TODO Recall _checkValForAPI for each element of array
+
+ return $value;
}
}
diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php
index 45b8be32763..292add085d2 100644
--- a/htdocs/api/class/api_setup.class.php
+++ b/htdocs/api/class/api_setup.class.php
@@ -2097,7 +2097,7 @@ class Setup extends DolibarrApi
$constvalue = (empty($constvalue) ? '0' : $constvalue);
// Value found
$value = '';
- if ($constname && $conf->global->$constname != '') {
+ if ($constname && getDolGlobalString($constname) != '') {
$value = $conf->global->$constname;
}
$valueforchecksum = (empty($value) ? '0' : $value);
diff --git a/htdocs/api/index.php b/htdocs/api/index.php
index da711f6f43b..b824c7b97dc 100644
--- a/htdocs/api/index.php
+++ b/htdocs/api/index.php
@@ -198,7 +198,7 @@ UploadFormat::$allowedMimeTypes = array('image/jpeg', 'image/png', 'text/plain',
// Restrict API to some IPs
if (getDolGlobalString('API_RESTRICT_ON_IP')) {
- $allowedip = explode(' ', $conf->global->API_RESTRICT_ON_IP);
+ $allowedip = explode(' ', getDolGlobalString('API_RESTRICT_ON_IP'));
$ipremote = getUserRemoteIP();
if (!in_array($ipremote, $allowedip)) {
dol_syslog('Remote ip is '.$ipremote.', not into list ' . getDolGlobalString('API_RESTRICT_ON_IP'));
@@ -343,7 +343,7 @@ if (!empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' &&
// Test rules on endpoints. For example:
// $conf->global->API_ENDPOINT_RULES = 'endpoint1:1,endpoint2:1,...'
if (getDolGlobalString('API_ENDPOINT_RULES')) {
- $listofendpoints = explode(',', $conf->global->API_ENDPOINT_RULES);
+ $listofendpoints = explode(',', getDolGlobalString('API_ENDPOINT_RULES'));
$endpointisallowed = false;
foreach ($listofendpoints as $endpointrule) {
diff --git a/htdocs/blockedlog/admin/blockedlog.php b/htdocs/blockedlog/admin/blockedlog.php
index e73f4cb1196..75acdf7b230 100644
--- a/htdocs/blockedlog/admin/blockedlog.php
+++ b/htdocs/blockedlog/admin/blockedlog.php
@@ -155,7 +155,7 @@ if ($resql) {
}
}
-$seledted = !getDolGlobalString('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY') ? array() : explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY);
+$seledted = !getDolGlobalString('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY') ? array() : explode(',', getDolGlobalString('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY'));
print $form->multiselectarray('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', $countryArray, $seledted);
print ' ';
diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php
index 70611f174e9..9874be8bebe 100644
--- a/htdocs/blockedlog/admin/blockedlog_list.php
+++ b/htdocs/blockedlog/admin/blockedlog_list.php
@@ -442,7 +442,6 @@ print '
';
// User
print '';
print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
-
print ' ';
// Actions code
@@ -570,7 +569,7 @@ if (is_array($blocks)) {
print ''.dol_print_date($block->date_creation, 'dayhour').' ';
// User
- print '';
+ print ' ';
//print $block->getUser()
print dol_escape_htmltag($block->user_fullname);
print ' ';
@@ -580,7 +579,7 @@ if (is_array($blocks)) {
// Ref
print '';
- print $block->ref_object;
+ print dol_escape_htmltag($block->ref_object);
print ' ';
// Link to source object
@@ -596,7 +595,7 @@ if (is_array($blocks)) {
print ''.img_info($langs->trans('ShowDetails')).' ';
// Fingerprint
- print '';
+ print ' ';
$texttoshow = $langs->trans("Fingerprint").' - '.$langs->trans("Saved").': '.$block->signature;
$texttoshow .= ' '.$langs->trans("Fingerprint").' - Recalculated sha256(previoushash * data): '.$checkdetail[$block->id]['calculatedsignature'];
$texttoshow .= ''.$langs->trans("PreviousHash").'='.$checkdetail[$block->id]['previoushash'].' ';
diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php
index 27a05d81e0e..a69c839f369 100644
--- a/htdocs/blockedlog/class/blockedlog.class.php
+++ b/htdocs/blockedlog/class/blockedlog.class.php
@@ -211,7 +211,7 @@ class BlockedLog
// Add more action to track from a conf variable
// For example: STOCK_MOVEMENT,...
if (getDolGlobalString('BLOCKEDLOG_ADD_ACTIONS_SUPPORTED')) {
- $tmparrayofmoresupportedevents = explode(',', $conf->global->BLOCKEDLOG_ADD_ACTIONS_SUPPORTED);
+ $tmparrayofmoresupportedevents = explode(',', getDolGlobalString('BLOCKEDLOG_ADD_ACTIONS_SUPPORTED'));
foreach ($tmparrayofmoresupportedevents as $val) {
$this->trackedevents[$val] = 'log'.$val;
}
diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php
index 5188e2d4758..4b9ccda6b09 100644
--- a/htdocs/bom/class/api_boms.class.php
+++ b/htdocs/bom/class/api_boms.class.php
@@ -203,6 +203,12 @@ class Boms extends DolibarrApi
$result = $this->_validate($request_data);
foreach ($request_data as $field => $value) {
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $this->bom->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
$this->bom->$field = $value;
}
@@ -241,6 +247,12 @@ class Boms extends DolibarrApi
if ($field == 'id') {
continue;
}
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $this->bom->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
$this->bom->$field = $value;
}
diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php
index f3a051ba703..5d2a9d0862a 100644
--- a/htdocs/categories/class/api_categories.class.php
+++ b/htdocs/categories/class/api_categories.class.php
@@ -204,6 +204,12 @@ class Categories extends DolibarrApi
$result = $this->_validate($request_data);
foreach ($request_data as $field => $value) {
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $this->category->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
$this->category->$field = $value;
}
if ($this->category->create(DolibarrApiAccess::$user) < 0) {
@@ -238,6 +244,12 @@ class Categories extends DolibarrApi
if ($field == 'id') {
continue;
}
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $this->category->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
$this->category->$field = $value;
}
diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index 766b440d9e9..f586cbca79a 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -69,7 +69,7 @@ $p2hour = GETPOST('p2hour', 'int');
$p2min = GETPOST('p2min', 'int');
$addreminder = GETPOST('addreminder', 'alpha');
-$offsetvalue = GETPOST('offsetvalue', 'int');
+$offsetvalue = GETPOSTINT('offsetvalue');
$offsetunit = GETPOST('offsetunittype_duration', 'aZ09');
$remindertype = GETPOST('selectremindertype', 'aZ09');
$modelmail = GETPOST('actioncommsendmodel_mail', 'int');
@@ -536,7 +536,7 @@ if (empty($reshook) && $action == 'add') {
if ($addreminder == 'on') {
$actionCommReminder = new ActionCommReminder($db);
- $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit);
+ $dateremind = dol_time_plus_duree($datep, -1 * $offsetvalue, $offsetunit);
$actionCommReminder->dateremind = $dateremind;
$actionCommReminder->typeremind = $remindertype;
@@ -653,7 +653,7 @@ if (empty($reshook) && $action == 'add') {
if ($addreminder == 'on') {
$actionCommReminder = new ActionCommReminder($db);
- $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit);
+ $dateremind = dol_time_plus_duree($datep, -1 * $offsetvalue, $offsetunit);
$actionCommReminder->dateremind = $dateremind;
$actionCommReminder->typeremind = $remindertype;
@@ -981,7 +981,7 @@ if (empty($reshook) && $action == 'update') {
if ($addreminder == 'on' && $object->datep > dol_now()) {
$actionCommReminder = new ActionCommReminder($db);
- $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit);
+ $dateremind = dol_time_plus_duree($datep, -1 * $offsetvalue, $offsetunit);
$actionCommReminder->dateremind = $dateremind;
$actionCommReminder->typeremind = $remindertype;
diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php
index 2e816865312..5c86aa9f6b5 100644
--- a/htdocs/comm/action/class/api_agendaevents.class.php
+++ b/htdocs/comm/action/class/api_agendaevents.class.php
@@ -217,6 +217,12 @@ class AgendaEvents extends DolibarrApi
$result = $this->_validate($request_data);
foreach ($request_data as $field => $value) {
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $this->actioncomm->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
$this->actioncomm->$field = $this->_checkValForAPI($field, $value, $this->actioncomm);
}
/*if (isset($request_data["lines"])) {
@@ -269,6 +275,11 @@ class AgendaEvents extends DolibarrApi
if ($field == 'id') {
continue;
}
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $this->actioncomm->context['caller'] = $request_data['caller'];
+ continue;
+ }
$this->actioncomm->$field = $this->_checkValForAPI($field, $value, $this->actioncomm);
}
diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index 9a5d6305301..f008b84dfad 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -1683,7 +1683,7 @@ if (empty($mode) || $mode == 'show_month') { // View by month
$maxnbofchar = 80;
- $tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS);
+ $tmp = explode('-', getDolGlobalString('MAIN_DEFAULT_WORKING_HOURS'));
$minhour = round($tmp[0], 0);
$maxhour = round($tmp[1], 0);
if ($minhour > 23) {
diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php
index 059db036436..05cb33a17df 100644
--- a/htdocs/comm/propal/class/api_proposals.class.php
+++ b/htdocs/comm/propal/class/api_proposals.class.php
@@ -266,6 +266,12 @@ class Proposals extends DolibarrApi
$result = $this->_validate($request_data);
foreach ($request_data as $field => $value) {
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $this->propal->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
$this->propal->$field = $value;
}
/*if (isset($request_data["lines"])) {
@@ -698,6 +704,12 @@ class Proposals extends DolibarrApi
if ($field == 'id') {
continue;
}
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $this->propal->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
$this->propal->$field = $value;
}
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 7ff7de223bf..d470fc8bc52 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -1512,7 +1512,7 @@ class Propal extends CommonObject
$error++;
}
- if (!$error) {
+ if (!$error && !getDolGlobalInt('MAIN_IGNORE_CONTACTS_ON_CLONING')) {
// copy internal contacts
if ($object->copy_linked_contact($this, 'internal') < 0) {
$error++;
@@ -2720,7 +2720,7 @@ class Propal extends CommonObject
}
}
- if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
+ if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE') && !getDolGlobalInt('PROPAL_DISABLE_AUTOUPDATE_ON_CLOSE')) {
// Define output language
$outputlangs = $langs;
if (getDolGlobalInt('MAIN_MULTILANGS')) {
diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php
index 3f6f8be39c3..7c4e197bdec 100644
--- a/htdocs/comm/propal/stats/index.php
+++ b/htdocs/comm/propal/stats/index.php
@@ -54,7 +54,7 @@ if ($user->socid > 0) {
$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear;
-$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
+$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS'))));
$endyear = $year;
// Load translation files required by the page
diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php
index 2bbcbe94104..c5119a51f6e 100644
--- a/htdocs/commande/class/api_orders.class.php
+++ b/htdocs/commande/class/api_orders.class.php
@@ -282,6 +282,12 @@ class Orders extends DolibarrApi
$result = $this->_validate($request_data);
foreach ($request_data as $field => $value) {
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $this->commande->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
$this->commande->$field = $value;
}
/*if (isset($request_data["lines"])) {
@@ -652,6 +658,12 @@ class Orders extends DolibarrApi
if ($field == 'id') {
continue;
}
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $this->commande->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
$this->commande->$field = $value;
}
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 99024dca83f..5ec0a3374d1 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -1191,7 +1191,7 @@ class Commande extends CommonOrder
return 0;
} else {
- dol_print_error($this->db);
+ $this->error = $this->db->lasterror();
$this->db->rollback();
return -1;
}
diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php
index a909820ae6e..702ee59d5e9 100644
--- a/htdocs/commande/stats/index.php
+++ b/htdocs/commande/stats/index.php
@@ -75,7 +75,7 @@ if ($user->socid > 0) {
$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$year = GETPOST('year') > 0 ? GETPOST('year') : $nowyear;
-$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
+$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS'))));
$endyear = $year;
// Load translation files required by the page
diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php
index 1d56ac2016d..84131a90fc3 100644
--- a/htdocs/compta/bank/bankentries_list.php
+++ b/htdocs/compta/bank/bankentries_list.php
@@ -342,7 +342,7 @@ if (GETPOST('save') && !$cancel && $user->hasRight('banque', 'modifier')) {
if (price2num(GETPOST("addcredit")) > 0) {
$amount = price2num(GETPOST("addcredit"));
} else {
- $amount = - price2num(GETPOST("adddebit"));
+ $amount = price2num(-1 * (float) price2num(GETPOST("adddebit")));
}
$operation = GETPOST("operation", 'alpha');
diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index eb82d04a190..5b10b742d87 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -590,7 +590,7 @@ class Account extends CommonObject
// Check parameters
if (!$oper) {
- $this->error = "oper not defined";
+ $this->error = "Operation code not defined";
return -1;
}
if (!$this->id) {
diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php
index a369b2f976e..4be3f7dee2d 100644
--- a/htdocs/compta/bank/class/api_bankaccounts.class.php
+++ b/htdocs/compta/bank/class/api_bankaccounts.class.php
@@ -158,6 +158,12 @@ class BankAccounts extends DolibarrApi
$account = new Account($this->db);
foreach ($request_data as $field => $value) {
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $account->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
$account->$field = $this->_checkValForAPI($field, $value, $account);
}
// Date of the initial balance (required to create an account).
@@ -333,6 +339,12 @@ class BankAccounts extends DolibarrApi
if ($field == 'id') {
continue;
}
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $account->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
$account->$field = $this->_checkValForAPI($field, $value, $account);
}
diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php
index cda42de38d3..449866b5e74 100644
--- a/htdocs/compta/bank/line.php
+++ b/htdocs/compta/bank/line.php
@@ -258,25 +258,38 @@ if ($user->hasRight('banque', 'consolidate') && ($action == 'num_releve' || $act
}
$sql .= " WHERE rowid = ".((int) $rowid);
- dol_syslog("line.php", LOG_DEBUG);
+ $updatePathFile = true;
+ $update_dir = true;
+
+ dol_syslog("line.php update bank line to set the new bank receipt nuber", LOG_DEBUG);
+
$result = $db->query($sql);
+
+ // We must not rename the directory of the bank receipt when we change 1 line of bank receipt. Other lines may share the same old ref.
+ // Renaming can be done when we rename globaly a bank receipt but not when changing 1 line from one receipt into another one.
+ /*
if ($result) {
- $oldfilepath = dol_sanitizePathName("bank/".((int) $id)."/statement/".$oldNum_rel);
- $filepath = dol_sanitizePathName("bank/".((int) $id)."/statement/".$num_rel);
+ if ($oldNum_rel) {
+ if ($num_rel) {
+ $oldfilepath = dol_sanitizePathName("bank/".((int) $id)."/statement/".$oldNum_rel);
+ $filepath = dol_sanitizePathName("bank/".((int) $id)."/statement/".$num_rel);
- $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_files";
- $sql .= " SET filepath = '".$db->escape($filepath)."'";
- $sql .= " WHERE filepath = '".$db->escape($oldfilepath)."'";
- $updatePathFile = $db->query($sql);
+ $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_files";
+ $sql .= " SET filepath = '".$db->escape($filepath)."'";
+ $sql .= " WHERE filepath = '".$db->escape($oldfilepath)."'";
+ $updatePathFile = $db->query($sql);
- $srcdir = dol_sanitizePathName(DOL_DATA_ROOT."/bank/".((int) $id)."/statement/".$oldNum_rel);
- $destdir = dol_sanitizePathName(DOL_DATA_ROOT."/bank/".((int) $id)."/statement/".$num_rel);
+ $srcdir = dol_sanitizePathName(DOL_DATA_ROOT."/bank/".((int) $id)."/statement/".$oldNum_rel);
+ $destdir = dol_sanitizePathName(DOL_DATA_ROOT."/bank/".((int) $id)."/statement/".$num_rel);
- $update_dir = true;
- if (dol_is_dir($srcdir)) {
- $update_dir = dol_move_dir($srcdir, $destdir, 1);
+ if (dol_is_dir($srcdir)) {
+ $update_dir = dol_move_dir($srcdir, $destdir, 1);
+ }
+ }
}
}
+ */
+
if ($result && $updatePathFile && $update_dir) {
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
$db->commit();
diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php
index c9f4809998c..479f09dabde 100644
--- a/htdocs/compta/cashcontrol/cashcontrol_card.php
+++ b/htdocs/compta/cashcontrol/cashcontrol_card.php
@@ -416,7 +416,7 @@ if ($action == "create" || $action == "start" || $action == 'close') {
print ' ';
$array = array();
- $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS);
+ $numterminals = max(1, getDolGlobalString('TAKEPOS_NUM_TERMINALS'));
for ($i = 1; $i <= $numterminals; $i++) {
$array[$i] = $i;
}
diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php
index 4e41cfb8a26..381baabadae 100644
--- a/htdocs/compta/deplacement/stats/index.php
+++ b/htdocs/compta/deplacement/stats/index.php
@@ -64,7 +64,7 @@ if ($userid > 0) {
$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$year = GETPOST('year') > 0 ? GETPOST('year') : $nowyear;
-$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
+$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS'))));
$endyear = $year;
$mode = GETPOST("mode") ? GETPOST("mode") : 'customer';
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index cdf811dd5c3..b819569d041 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -165,7 +165,7 @@ $permissiontoadd = $usercancreate; // Used by the include of actions_addupdatede
// retained warranty invoice available type
$retainedWarrantyInvoiceAvailableType = array();
if (getDolGlobalString('INVOICE_USE_RETAINED_WARRANTY')) {
- $retainedWarrantyInvoiceAvailableType = explode('+', $conf->global->INVOICE_USE_RETAINED_WARRANTY);
+ $retainedWarrantyInvoiceAvailableType = explode('+', getDolGlobalString('INVOICE_USE_RETAINED_WARRANTY'));
}
// Security check
@@ -1684,7 +1684,7 @@ if (empty($reshook)) {
if (!isset($conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE)) {
$conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE = '5';
}
- if ($srcobject->element == 'contrat' && in_array($lines[$i]->statut, explode(',', $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE))) {
+ if ($srcobject->element == 'contrat' && in_array($lines[$i]->statut, explode(',', getDolGlobalString('CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE')))) {
continue;
}
diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php
index 54ff8d6621e..94de562a3c2 100644
--- a/htdocs/compta/facture/class/api_invoices.class.php
+++ b/htdocs/compta/facture/class/api_invoices.class.php
@@ -302,6 +302,12 @@ class Invoices extends DolibarrApi
$result = $this->_validate($request_data);
foreach ($request_data as $field => $value) {
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $this->invoice->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
$this->invoice->$field = $value;
}
if (!array_key_exists('date', $request_data)) {
@@ -623,6 +629,12 @@ class Invoices extends DolibarrApi
if ($field == 'id') {
continue;
}
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $this->invoice->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
$this->invoice->$field = $value;
}
@@ -1422,10 +1434,10 @@ class Invoices extends DolibarrApi
// Clean parameters amount if payment is for a credit note
if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) {
$resteapayer = price2num($resteapayer, 'MT');
- $amounts[$id] = -$resteapayer;
+ $amounts[$id] = price2num(-1 * $resteapayer, 'MT');
// Multicurrency
$newvalue = price2num($this->invoice->multicurrency_total_ttc, 'MT');
- $multicurrency_amounts[$id] = -$newvalue;
+ $multicurrency_amounts[$id] = price2num(-1 * $newvalue, 'MT');
} else {
$resteapayer = price2num($resteapayer, 'MT');
$amounts[$id] = $resteapayer;
@@ -1568,7 +1580,7 @@ class Invoices extends DolibarrApi
}
if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) {
- $amount = -$amount;
+ $amount = price2num(-1 * $amount, 'MT');
}
if ($is_multicurrency) {
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 9bc9d68220f..b277db0da53 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -181,8 +181,6 @@ class Facture extends CommonInvoice
public $fk_facture_source;
public $linked_objects = array();
- public $date_lim_reglement;
-
/**
* @var int ID Field to store bank id to use when payment mode is withdraw
*/
@@ -5534,7 +5532,7 @@ class Facture extends CommonInvoice
}
if ($rounding < 0) {
- $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
+ $rounding = min(getDolGlobalString('MAIN_MAX_DECIMALS_UNIT'), $conf->global->MAIN_MAX_DECIMALS_TOT);
}
if ($rounding > 0) {
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index e3e7a952a6c..d58a1cf15d4 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -214,7 +214,7 @@ $arrayfields = array(
'f.subtype'=>array('label'=>"InvoiceSubtype", 'checked'=>0, 'position'=>17),
'f.date_lim_reglement'=>array('label'=>"DateDue", 'checked'=>1, 'position'=>25),
'f.date_closing'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>30),
- 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>40),
+ 'p.ref'=>array('label'=>"ProjectRef", 'langs'=>'projects', 'checked'=>1, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>40),
'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>41),
's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>50),
's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1, 'position'=>51),
@@ -910,38 +910,6 @@ $parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
-// We disable this. It create a bug when searching with sall and sorting on status. Also it create performance troubles.
-/*
-if (!$sall) {
- $sql .= ' GROUP BY f.rowid, f.ref, ref_client, f.fk_soc, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total_ht, f.total_tva, f.total_ttc,';
- $sql .= ' f.localtax1, f.localtax2,';
- $sql .= ' f.datef, f.date_valid, f.date_lim_reglement, f.module_source, f.pos_source,';
- $sql .= ' f.paye, f.fk_statut, f.close_code,';
- $sql .= ' f.datec, f.tms, f.date_closing,';
- $sql .= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,';
- $sql .= ' f.fk_user_author, f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht,';
- $sql .= ' f.multicurrency_total_tva, f.multicurrency_total_ttc,';
- $sql .= ' s.rowid, s.nom, s.name_alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,';
- $sql .= ' typent.code,';
- $sql .= ' state.code_departement, state.nom,';
- $sql .= ' country.code,';
- $sql .= " p.rowid, p.ref, p.title,";
- $sql .= " u.login, u.lastname, u.firstname, u.email, u.statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender";
- if ($search_categ_cus && $search_categ_cus != -1) {
- $sql .= ", cc.fk_categorie, cc.fk_soc";
- }
- // Add fields from extrafields
- if (!empty($extrafields->attributes[$object->table_element]['label'])) {
- foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
- $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : '');
- }
- }
- // Add GroupBy from hooks
- $parameters = array('all' => !empty($all) ? $all : 0, 'fieldstosearchall' => $fieldstosearchall);
- $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
- $sql .= $hookmanager->resPrint;
-} else {
-*/
if ($sall) {
$sql .= natural_search(array_keys($fieldstosearchall), $sall);
}
@@ -1708,6 +1676,7 @@ if (!empty($arrayfields['f.date_lim_reglement']['checked'])) {
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.ref']['checked'])) {
+ $langs->load("projects");
print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php
index a33215086a2..54042ae0ec8 100644
--- a/htdocs/compta/facture/stats/index.php
+++ b/htdocs/compta/facture/stats/index.php
@@ -66,7 +66,7 @@ if ($user->socid > 0) {
$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear;
-$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
+$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS'))));
$endyear = $year;
diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php
index 4a90dd52b66..49925556725 100644
--- a/htdocs/compta/journal/purchasesjournal.php
+++ b/htdocs/compta/journal/purchasesjournal.php
@@ -104,7 +104,7 @@ $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.
report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink);
-$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
+$p = explode(":", getDolGlobalString('MAIN_INFO_SOCIETE_COUNTRY'));
$idpays = $p[0];
@@ -137,7 +137,7 @@ $result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
// les variables
- $cptfour = (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"));
+ $cptfour = ((getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"));
$cpttva = (getDolGlobalString('ACCOUNTING_VAT_BUY_ACCOUNT') ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
$tabfac = array();
diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php
index 9ffa49798e0..6f76ebfcedb 100644
--- a/htdocs/compta/journal/sellsjournal.php
+++ b/htdocs/compta/journal/sellsjournal.php
@@ -107,7 +107,7 @@ if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) {
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink);
-$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
+$p = explode(":", getDolGlobalString('MAIN_INFO_SOCIETE_COUNTRY'));
$idpays = $p[0];
$sql = "SELECT f.rowid, f.ref, f.type, f.datef, f.ref_client,";
@@ -165,7 +165,7 @@ if ($result) {
while ($i < $num) {
$obj = $db->fetch_object($result);
// les variables
- $cptcli = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "") ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"));
+ $cptcli = ((getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') != "") ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"));
$compta_soc = (!empty($obj->code_compta) ? $obj->code_compta : $cptcli);
$compta_prod = $obj->accountancy_code_sell;
if (empty($compta_prod)) {
diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php
index d1fe6e7f2b5..fc1dbded732 100644
--- a/htdocs/compta/localtax/clients.php
+++ b/htdocs/compta/localtax/clients.php
@@ -55,7 +55,7 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e
$date_start = dol_get_first_day($year_start, GETPOST("month"), false);
$date_end = dol_get_last_day($year_start, GETPOST("month"), false);
} else {
- $date_start = dol_get_first_day($year_start, !getDolGlobalString('SOCIETE_FISCAL_MONTH_START') ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START, false);
+ $date_start = dol_get_first_day($year_start, !getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START, false);
if (!getDolGlobalString('MAIN_INFO_VAT_RETURN') || getDolGlobalInt('MAIN_INFO_VAT_RETURN') == 2) {
$date_end = dol_time_plus_duree($date_start, 3, 'm') - 1;
} elseif (getDolGlobalInt('MAIN_INFO_VAT_RETURN') == 3) {
diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php
index 49a448b2196..6a508abb5f8 100644
--- a/htdocs/compta/localtax/quadri_detail.php
+++ b/htdocs/compta/localtax/quadri_detail.php
@@ -65,7 +65,7 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e
$date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false);
$date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false);
} else {
- $date_start = dol_get_first_day($year_start, !getDolGlobalString('SOCIETE_FISCAL_MONTH_START') ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START, false);
+ $date_start = dol_get_first_day($year_start, !getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START, false);
if (!getDolGlobalString('MAIN_INFO_VAT_RETURN') || getDolGlobalInt('MAIN_INFO_VAT_RETURN') == 2) {
$date_end = dol_time_plus_duree($date_start, 3, 'm') - 1;
} elseif (getDolGlobalInt('MAIN_INFO_VAT_RETURN') == 3) {
diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php
index a5605f59873..32e05251fde 100644
--- a/htdocs/compta/paiement.php
+++ b/htdocs/compta/paiement.php
@@ -391,7 +391,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
}
if ($(\'#fieldchqemetteur\').val() == \'\')
{
- var emetteur = ('.$facture->type.' == '.Facture::TYPE_CREDIT_NOTE.') ? \''.dol_escape_js(dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_NOM)).'\' : jQuery(\'#thirdpartylabel\').val();
+ var emetteur = ('.$facture->type.' == '.Facture::TYPE_CREDIT_NOTE.') ? \''.dol_escape_js(dol_escape_htmltag(getDolGlobalString('MAIN_INFO_SOCIETE_NOM'))).'\' : jQuery(\'#thirdpartylabel\').val();
$(\'#fieldchqemetteur\').val(emetteur);
}
}
diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php
index a5e7c3fc17c..04b59c959ce 100644
--- a/htdocs/compta/prelevement/card.php
+++ b/htdocs/compta/prelevement/card.php
@@ -149,14 +149,14 @@ if (empty($reshook)) {
}
// Set direct debit order to credited, create payment and close invoices
- if ($action == 'infocredit' && $permissiontocreditdebit) {
+ if ($action == 'setinfocredit' && $permissiontocreditdebit) {
$dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
if (($object->type != 'bank-transfer' && $object->statut == BonPrelevement::STATUS_CREDITED) || ($object->type == 'bank-transfer' && $object->statut == BonPrelevement::STATUS_DEBITED)) {
$error = 1;
setEventMessages('WithdrawalCantBeCreditedTwice', array(), 'errors');
} else {
- $error = $object->set_infocredit($user, $dt);
+ $error = $object->set_infocredit($user, $dt, ($salaryBonPl ? 'salary' : ''));
}
if ($error) {
@@ -164,6 +164,14 @@ if (empty($reshook)) {
}
}
+ if ($action == 'reopen' && $permissiontocreditdebit) {
+ $savtype = $object->type;
+ $res = $object->setStatut(BonPrelevement::STATUS_TRANSFERED);
+ if ($res <= 0) {
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ }
+
if ($action == 'confirm_delete' && $permissiontodelete) {
$savtype = $object->type;
$res = $object->delete($user);
@@ -386,11 +394,11 @@ if ($id > 0 || $ref) {
print ' ';
}
- if (!empty($object->date_trans) && empty($object->date_credit) && (($user->hasRight('prelevement', 'bons', 'credit') && $object->type != 'bank-transfer') || ($user->hasRight('paymentbybanktransfer', 'debit') && $object->type == 'bank-transfer')) && $action == 'setcredited') {
+ if ($object->status == BonPrelevement::STATUS_TRANSFERED && (($user->hasRight('prelevement', 'bons', 'credit') && $object->type != 'bank-transfer') || ($user->hasRight('paymentbybanktransfer', 'debit') && $object->type == 'bank-transfer')) && $action == 'setcredited') {
$btnLabel = ($object->type == 'bank-transfer') ? $langs->trans("ClassDebited") : $langs->trans("ClassCredited");
print '