mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +01:00
ImportExport: Fix custom dates formatting to work for more than just the first row
This commit is contained in:
parent
372eadcff3
commit
edaf3abd4f
@ -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);
|
||||
if($date)
|
||||
// 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)
|
||||
{
|
||||
$val = $date->format(APi\DateTime::DATABASE);
|
||||
if (is_array($record))
|
||||
$date = Api\DateTime::createFromFormat($format, $val, Api\DateTime::$user_timezone);
|
||||
if($date)
|
||||
{
|
||||
$record[$name] = $val;
|
||||
return $date->format(APi\DateTime::DATABASE);
|
||||
}
|
||||
else
|
||||
{
|
||||
$record->$name = $val;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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