mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 00:13:35 +01:00
ImportExport: Fix custom dates formatting to work for more than just the first row
This commit is contained in:
parent
d9aa678ce3
commit
2491cf16c0
@ -246,24 +246,23 @@ class importexport_export_csv implements importexport_iface_export_record
|
||||
switch($c_field['type']) {
|
||||
case 'date':
|
||||
case 'date-time':
|
||||
$fields[$c_field['type']][] = $name;
|
||||
if ($c_field['values']['format'] && (is_array($record) ? $record[$name] : $record->$name))
|
||||
{
|
||||
// Date has custom format. Convert so it's standard.
|
||||
$val = is_array($record) ? $record[$name] : $record->$name;
|
||||
$date = Api\DateTime::createFromFormat($c_field['values']['format'], $val, Api\DateTime::$user_timezone);
|
||||
// Date has custom format. Convert so it's standard, don't do normal processing
|
||||
$format = $c_field['values']['format'];
|
||||
$methods[$name] = function($val) use ($format)
|
||||
{
|
||||
$date = Api\DateTime::createFromFormat($format, $val, Api\DateTime::$user_timezone);
|
||||
if($date)
|
||||
{
|
||||
$val = $date->format(APi\DateTime::DATABASE);
|
||||
if (is_array($record))
|
||||
{
|
||||
$record[$name] = $val;
|
||||
return $date->format(APi\DateTime::DATABASE);
|
||||
}
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
$record->$name = $val;
|
||||
}
|
||||
}
|
||||
// Process as normal
|
||||
$fields[$c_field['type']][] = $name;
|
||||
}
|
||||
break;
|
||||
case 'select-account':
|
||||
@ -442,7 +441,17 @@ class importexport_export_csv implements importexport_iface_export_record
|
||||
|
||||
// Some custom methods for conversion
|
||||
foreach((array)$methods as $name => $method) {
|
||||
if($record->$name) $record->$name = ExecMethod($method, $record->$name);
|
||||
if ($record->$name)
|
||||
{
|
||||
if(is_string($method))
|
||||
{
|
||||
$record->$name = ExecMethod($method, $record->$name);
|
||||
}
|
||||
else if (is_callable($method))
|
||||
{
|
||||
$record->$name = $method($record->$name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static $cat_object;
|
||||
|
Loading…
Reference in New Issue
Block a user