diff --git a/ChangeLog b/ChangeLog
index 18f9fbe2dcb..a0aecd64a9a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -24,7 +24,10 @@ Following changes may create regressions for some external modules, but were nec
* All methods set_draft() were renamed into setDraft().
* Removed deprecated function function test_sql_and_script_inject that was replaced with testSqlAndScriptInject.
* Method load_measuring_units were renamed into selectMeasuringUnits and select_measuring_units was deprecated.
-* Hidden option CHANGE_ORDER_CONCAT_DESCRIPTION were renamed into MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION
+* Hidden option CHANGE_ORDER_CONCAT_DESCRIPTION were renamed into MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION.
+* Method dolEscapeXML was moved from functions.lib.php into function2.lib.php (not used enough to be loaded by default).
+* Removed deprecated use of string in dol_print_date(). Only date allowed.
+
***** ChangeLog for 9.0.1 compared to 9.0.0 *****
diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php
index 8cc396f3bc1..9dd7f6c405b 100644
--- a/htdocs/compta/bank/list.php
+++ b/htdocs/compta/bank/list.php
@@ -407,18 +407,17 @@ foreach ($accounts as $key=>$type)
$found++;
- $obj = new Account($db);
- $obj->fetch($key);
+ $result = $objecttmp->fetch($key);
- $solde = $obj->solde(1);
+ $solde = $objecttmp->solde(1);
- if (! empty($lastcurrencycode) && $lastcurrencycode != $obj->currency_code)
+ if (! empty($lastcurrencycode) && $lastcurrencycode != $objecttmp->currency_code)
{
$lastcurrencycode='various'; // We found several different currencies
}
if ($lastcurrencycode != 'various')
{
- $lastcurrencycode=$obj->currency_code;
+ $lastcurrencycode=$objecttmp->currency_code;
}
print '
';
@@ -426,14 +425,14 @@ foreach ($accounts as $key=>$type)
// Ref
if (! empty($arrayfields['b.ref']['checked']))
{
- print '
'.$obj->getNomUrl(1).'
';
+ print '
'.$objecttmp->getNomUrl(1).'
';
if (! $i) $totalarray['nbfield']++;
}
// Label
if (! empty($arrayfields['b.label']['checked']))
{
- print '
'.$obj->label.'
';
+ print '
'.$objecttmp->label.'
';
if (! $i) $totalarray['nbfield']++;
}
@@ -441,7 +440,7 @@ foreach ($accounts as $key=>$type)
if (! empty($arrayfields['accountype']['checked']))
{
print '
';
if (! $i) $totalarray['nbfield']++;
}
@@ -502,11 +501,11 @@ foreach ($accounts as $key=>$type)
if (! empty($arrayfields['toreconcile']['checked']))
{
print '
';
- if ($obj->rappro)
+ if ($objecttmp->rappro)
{
- $result=$obj->load_board($user, $obj->id);
+ $result=$objecttmp->load_board($user, $objecttmp->id);
if ($result<0) {
- setEventMessages($obj->error, $obj->errors, 'errors');
+ setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
} else {
print $result->nbtodo;
if ($result->nbtodolate) print ' ('.$result->nbtodolate.img_warning($langs->trans("Late")).')';
@@ -520,14 +519,14 @@ foreach ($accounts as $key=>$type)
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
- $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
- $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
+ $parameters=array('arrayfields'=>$arrayfields);
+ $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp); // Note that $action and $objecttmpect may have been modified by hook
print $hookmanager->resPrint;
// Date creation
if (! empty($arrayfields['b.datec']['checked']))
{
print '
';
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalbalancefield']=$totalarray['nbfield'];
@@ -563,15 +562,15 @@ foreach ($accounts as $key=>$type)
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected=0;
- if (in_array($obj->rowid, $arrayofselected)) $selected=1;
- print '';
+ if (in_array($objecttmp->id, $arrayofselected)) $selected=1;
+ print '';
}
print '';
if (! $i) $totalarray['nbfield']++;
print '
';
- $total[$obj->currency_code] += $solde;
+ $total[$objecttmp->currency_code] += $solde;
$i++;
}
diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index 142dd1b0e1e..b462095278d 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -1592,6 +1592,9 @@ class BonPrelevement extends CommonObject
{
// phpcs:enable
global $conf;
+
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+
$CrLf = "\n";
$Rowing = sprintf("%06d", $row_idfac);
diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php
index fa44c8dbcc9..87b32902684 100644
--- a/htdocs/core/class/html.formaccounting.class.php
+++ b/htdocs/core/class/html.formaccounting.class.php
@@ -224,9 +224,9 @@ class FormAccounting extends Form
/**
* Return select filter with date of transaction
*
- * @param string $htmlname Name of select field
- * @param string $selectedkey Value
- * @return string HTML edit field
+ * @param string $htmlname Name of select field
+ * @param string $selectedkey Value
+ * @return string HTML edit field
*/
public function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = '')
{
@@ -247,7 +247,7 @@ class FormAccounting extends Form
}
while ($obj = $this->db->fetch_object($resql)) {
- $options[$obj->import_key] = dol_print_date($obj->import_key, 'dayhourtext');
+ $options[$obj->import_key] = $obj->import_key;
}
return Form::selectarray($htmlname, $options, $selectedkey);
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 916e46c6ab5..1f6b029acc0 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -886,17 +886,6 @@ function dol_string_nospecial($str, $newstr = '_', $badcharstoreplace = '')
}
-/**
- * Encode string for xml usage
- *
- * @param string $string String to encode
- * @return string String encoded
- */
-function dolEscapeXML($string)
-{
- return strtr($string, array('\''=>''','"'=>'"','&'=>'&','<'=>'<','>'=>'>'));
-}
-
/**
* Returns text escaped for inclusion into javascript code
*
@@ -1785,8 +1774,8 @@ function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlang
if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg)
|| preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i', $time, $reg)) // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000
{
- // TODO Remove this. This part of code should not be used.
- dol_syslog("Functions.lib::dol_print_date function call with deprecated value of time in page ".$_SERVER["PHP_SELF"], LOG_WARNING);
+ // This part of code should not be used.
+ /*dol_syslog("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"], LOG_WARNING);
//if (function_exists('debug_print_backtrace')) debug_print_backtrace();
// Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' or 'YYYYMMDDHHMMSS'
$syear = (! empty($reg[1]) ? $reg[1] : '');
@@ -1797,7 +1786,9 @@ function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlang
$ssec = (! empty($reg[6]) ? $reg[6] : '');
$time=dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear, true);
- $ret=adodb_strftime($format, $time+$offsettz+$offsetdst, $to_gmt);
+ $ret=adodb_strftime($format, $time+$offsettz+$offsetdst, $to_gmt);*/
+ dol_print_error("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"]);
+ return '';
}
else
{
diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php
index 616f0bed7db..ffdf161fc7a 100644
--- a/htdocs/core/lib/functions2.lib.php
+++ b/htdocs/core/lib/functions2.lib.php
@@ -2414,28 +2414,39 @@ function getModuleDirForApiClass($module)
return $moduledirforclass;
}
-/*
+/**
* Return 2 hexa code randomly
*
- * @param $min int Between 0 and 255
- * @param $max int Between 0 and 255
- * @return String
+ * @param int $min Between 0 and 255
+ * @param int $max Between 0 and 255
+ * @return string A color string '12'
*/
-function random_color_part($min = 0, $max = 255)
+function randomColorPart($min = 0, $max = 255)
{
return str_pad(dechex(mt_rand($min, $max)), 2, '0', STR_PAD_LEFT);
}
-/*
+/**
* Return hexadecimal color randomly
*
- * @param $min int Between 0 and 255
- * @param $max int Between 0 and 255
- * @return String
+ * @param int $min Between 0 and 255
+ * @param int $max Between 0 and 255
+ * @return string A color string '123456'
*/
-function random_color($min = 0, $max = 255)
+function randomColor($min = 0, $max = 255)
{
- return random_color_part($min, $max) . random_color_part($min, $max) . random_color_part($min, $max);
+ return randomColorPart($min, $max) . randomColorPart($min, $max) . randomColorPart($min, $max);
+}
+
+/**
+ * Encode string for xml usage
+ *
+ * @param string $string String to encode
+ * @return string String encoded
+ */
+function dolEscapeXML($string)
+{
+ return strtr($string, array('\''=>''','"'=>'"','&'=>'&','<'=>'<','>'=>'>'));
}
/**
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index 1ba60bf9b41..b97b29ad47f 100644
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -117,7 +117,7 @@ class pdf_crabe extends ModelePDFFactures
/**
* Issuer
- * @var Company object that emits
+ * @var Societe object that emits
*/
public $emetteur;
@@ -856,7 +856,7 @@ class pdf_crabe extends ModelePDFFactures
$invoice->fetch($obj->fk_facture_source);
$pdf->SetXY($tab3_posx, $tab3_top+$y);
- $pdf->MultiCell(20, 3, dol_print_date($obj->datef, 'day', false, $outputlangs, true), 0, 'L', 0);
+ $pdf->MultiCell(20, 3, dol_print_date($db->jdate($obj->datef), 'day', false, $outputlangs, true), 0, 'L', 0);
$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
$pdf->MultiCell(20, 3, price(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
index da45babde4f..5e18b895c97 100644
--- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
@@ -928,7 +928,7 @@ class pdf_sponge extends ModelePDFFactures
$invoice->fetch($obj->fk_facture_source);
$pdf->SetXY($tab3_posx, $tab3_top+$y);
- $pdf->MultiCell(20, 3, dol_print_date($obj->datef, 'day', false, $outputlangs, true), 0, 'L', 0);
+ $pdf->MultiCell(20, 3, dol_print_date($db->jdate($obj->datef), 'day', false, $outputlangs, true), 0, 'L', 0);
$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
$pdf->MultiCell(20, 3, price(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
@@ -1829,7 +1829,7 @@ class pdf_sponge extends ModelePDFFactures
* Define Array Column Field
*
* @param object $object common object
- * @param outputlangs $outputlangs langs
+ * @param Translate $outputlangs langs
* @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref
diff --git a/htdocs/core/tpl/bloc_comment.tpl.php b/htdocs/core/tpl/bloc_comment.tpl.php
index acf1aad36ce..fba0810e7cd 100644
--- a/htdocs/core/tpl/bloc_comment.tpl.php
+++ b/htdocs/core/tpl/bloc_comment.tpl.php
@@ -64,9 +64,11 @@ if (!empty($object->comments))
$fk_user = $comment->fk_user_author;
$userstatic->fetch($fk_user);
- if(empty($TColors[$fk_user])) {
- $bgcolor = random_color(180, 240);
- if(!empty($userstatic->color)) {
+ if (empty($TColors[$fk_user]))
+ {
+ $bgcolor = randomColor(180, 240);
+ if (!empty($userstatic->color))
+ {
$bgcolor = $userstatic->color;
}
$color = (colorIsLight($bgcolor))?'555':'fff';
diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php
index 98db1318aa7..1823e5f0a93 100644
--- a/htdocs/holiday/month_report.php
+++ b/htdocs/holiday/month_report.php
@@ -173,10 +173,10 @@ else
print '';
print '