mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 07:12:26 +02:00
(Retrofit from trunk) N.701 (continuation of [r4596] which introduced regressions on the handling of date fields)
SVN:2.3[4627]
This commit is contained in:
@@ -214,7 +214,7 @@ function ReadMandatoryParam($oP, $sParam, $sSanitizationFilter)
|
|||||||
return trim($sValue);
|
return trim($sValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ChangeDateFormat($sProposedDate, $sFormat)
|
function ChangeDateFormat($sProposedDate, $sFormat, $bDateOnly)
|
||||||
{
|
{
|
||||||
if ($sProposedDate == '')
|
if ($sProposedDate == '')
|
||||||
{
|
{
|
||||||
@@ -233,7 +233,8 @@ function ChangeDateFormat($sProposedDate, $sFormat)
|
|||||||
$oDate = $oFormat->Parse($sProposedDate);
|
$oDate = $oFormat->Parse($sProposedDate);
|
||||||
if ($oDate !== null)
|
if ($oDate !== null)
|
||||||
{
|
{
|
||||||
$sDate = $oDate->format(AttributeDateTime::GetInternalFormat());
|
$oTargetFormat = $bDateOnly ? AttributeDate::GetInternalFormat() : AttributeDateTime::GetInternalFormat();
|
||||||
|
$sDate = $oDate->format($oTargetFormat);
|
||||||
return $sDate;
|
return $sDate;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -444,7 +445,20 @@ try
|
|||||||
|
|
||||||
// Check columns
|
// Check columns
|
||||||
$aColumns = $oDataSource->GetSQLColumns();
|
$aColumns = $oDataSource->GetSQLColumns();
|
||||||
$aDateColumns = $oDataSource->GetDateSQLColumns();
|
|
||||||
|
$aDateColumns = array();
|
||||||
|
foreach(MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef)
|
||||||
|
{
|
||||||
|
if ($oAttDef instanceof AttributeDate)
|
||||||
|
{
|
||||||
|
$aDateColumns[$sAttCode] = 'DATE';
|
||||||
|
}
|
||||||
|
elseif ($oAttDef instanceof AttributeDateTime)
|
||||||
|
{
|
||||||
|
$aDateColumns[$sAttCode] = 'DATETIME';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$aIsDateToTransform = array();
|
$aIsDateToTransform = array();
|
||||||
$aDateToTransformReport = array();
|
$aDateToTransformReport = array();
|
||||||
foreach($aInputColumns as $iFieldId => $sInputColumn)
|
foreach($aInputColumns as $iFieldId => $sInputColumn)
|
||||||
@@ -530,12 +544,14 @@ try
|
|||||||
}
|
}
|
||||||
elseif ($aIsDateToTransform[$iCol] !== false)
|
elseif ($aIsDateToTransform[$iCol] !== false)
|
||||||
{
|
{
|
||||||
|
$bDateOnly = false;
|
||||||
$sFormat = $sDateTimeFormat;
|
$sFormat = $sDateTimeFormat;
|
||||||
if ($aIsDateToTransform[$iCol] == 'DATE')
|
if ($aIsDateToTransform[$iCol] == 'DATE')
|
||||||
{
|
{
|
||||||
|
$bDateOnly = true;
|
||||||
$sFormat = $sDateFormat;
|
$sFormat = $sDateFormat;
|
||||||
}
|
}
|
||||||
$sDate = ChangeDateFormat($value, $sFormat);
|
$sDate = ChangeDateFormat($value, $sFormat, $bDateOnly);
|
||||||
if ($sDate === false)
|
if ($sDate === false)
|
||||||
{
|
{
|
||||||
$aValues[] = CMDBSource::Quote('');
|
$aValues[] = CMDBSource::Quote('');
|
||||||
@@ -592,12 +608,14 @@ try
|
|||||||
$sCol = $aInputColumns[$iCol];
|
$sCol = $aInputColumns[$iCol];
|
||||||
if ($aIsDateToTransform[$iCol] !== false)
|
if ($aIsDateToTransform[$iCol] !== false)
|
||||||
{
|
{
|
||||||
|
$bDateOnly = false;
|
||||||
$sFormat = $sDateTimeFormat;
|
$sFormat = $sDateTimeFormat;
|
||||||
if ($aIsDateToTransform[$iCol] == 'DATE')
|
if ($aIsDateToTransform[$iCol] == 'DATE')
|
||||||
{
|
{
|
||||||
|
$bDateOnly = true;
|
||||||
$sFormat = $sDateFormat;
|
$sFormat = $sDateFormat;
|
||||||
}
|
}
|
||||||
$sDate = ChangeDateFormat($value, $sFormat);
|
$sDate = ChangeDateFormat($value, $sFormat, $bDateOnly);
|
||||||
if ($sDate === false)
|
if ($sDate === false)
|
||||||
{
|
{
|
||||||
if ($sOutput == 'details')
|
if ($sOutput == 'details')
|
||||||
@@ -661,12 +679,12 @@ try
|
|||||||
{
|
{
|
||||||
$aDateTimeColumns = array();
|
$aDateTimeColumns = array();
|
||||||
$aDateColumns = array();
|
$aDateColumns = array();
|
||||||
foreach($aIsDateToTransform as $iCol => $sSQLDef)
|
foreach($aIsDateToTransform as $iCol => $sType)
|
||||||
{
|
{
|
||||||
if ($sSQLDef !== false)
|
if ($sType !== false)
|
||||||
{
|
{
|
||||||
$sCol = $aInputColumns[$iCol];
|
$sCol = $aInputColumns[$iCol];
|
||||||
if ($sSQLDef == 'DATE')
|
if ($sType == 'DATE')
|
||||||
{
|
{
|
||||||
$aDateColumns[] = $sCol;
|
$aDateColumns[] = $sCol;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1165,7 +1165,7 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of Date and Datetime SQL columns
|
* DEPRECATED - Get the list of Date and Datetime SQL columns
|
||||||
*/
|
*/
|
||||||
public function GetDateSQLColumns()
|
public function GetDateSQLColumns()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user