A better transition with deprecation

This commit is contained in:
Laurent Destailleur 2019-04-01 22:09:24 +02:00
parent 7db443e8ab
commit 8a6e28860b
2 changed files with 22 additions and 19 deletions

View File

@ -1393,7 +1393,7 @@ class Contrat extends CommonObject
if (empty($txtva) || ! is_numeric($txtva)) $txtva=0; if (empty($txtva) || ! is_numeric($txtva)) $txtva=0;
if (empty($txlocaltax1) || ! is_numeric($txlocaltax1)) $txlocaltax1=0; if (empty($txlocaltax1) || ! is_numeric($txlocaltax1)) $txlocaltax1=0;
if (empty($txlocaltax2) || ! is_numeric($txlocaltax2)) $txlocaltax2=0; if (empty($txlocaltax2) || ! is_numeric($txlocaltax2)) $txlocaltax2=0;
if ($price_base_type=='HT') if ($price_base_type=='HT')
{ {
$pu=$pu_ht; $pu=$pu_ht;
@ -1405,13 +1405,13 @@ class Contrat extends CommonObject
// Check parameters // Check parameters
if (empty($remise_percent)) $remise_percent=0; if (empty($remise_percent)) $remise_percent=0;
if ($date_start && $date_end && $date_start > $date_end) { if ($date_start && $date_end && $date_start > $date_end) {
$langs->load("errors"); $langs->load("errors");
$this->error=$langs->trans('ErrorStartDateGreaterEnd'); $this->error=$langs->trans('ErrorStartDateGreaterEnd');
return -1; return -1;
} }
$this->db->begin(); $this->db->begin();
$localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc); $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc);
@ -1603,7 +1603,7 @@ class Contrat extends CommonObject
{ {
$remise_percent=0; $remise_percent=0;
} }
if ($date_start && $date_end && $date_start > $date_end) { if ($date_start && $date_end && $date_start > $date_end) {
$langs->load("errors"); $langs->load("errors");
$this->error=$langs->trans('ErrorStartDateGreaterEnd'); $this->error=$langs->trans('ErrorStartDateGreaterEnd');

View File

@ -1771,25 +1771,28 @@ function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlang
} }
// Analyze date // Analyze date
if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg) $reg=array();
|| 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 if (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
{ {
// 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] : '');
$smonth = (! empty($reg[2]) ? $reg[2] : '');
$sday = (! empty($reg[3]) ? $reg[3] : '');
$shour = (! empty($reg[4]) ? $reg[4] : '');
$smin = (! empty($reg[5]) ? $reg[5] : '');
$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);*/
dol_print_error("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"]); dol_print_error("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"]);
return ''; return '';
} }
elseif (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg)) // Still available to solve problems in extrafields of type date
{
// 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'
$syear = (! empty($reg[1]) ? $reg[1] : '');
$smonth = (! empty($reg[2]) ? $reg[2] : '');
$sday = (! empty($reg[3]) ? $reg[3] : '');
$shour = (! empty($reg[4]) ? $reg[4] : '');
$smin = (! empty($reg[5]) ? $reg[5] : '');
$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);
}
else else
{ {
// Date is a timestamps // Date is a timestamps