Update import / export CSV plugins & default definitions

This commit is contained in:
Nathan Gray 2012-10-11 20:53:55 +00:00
parent 7e1053c8ec
commit 759b7b515a
7 changed files with 60 additions and 52 deletions

View File

@ -284,7 +284,7 @@ class importexport_import_csv implements importexport_iface_import_record { //,
if($fields) {
foreach((array)$fields['select'] as $name) {
if($record[$name] != null && is_array($selects) && $selects[$name]) {
$key = array_search($record[$name], $selects[$name]);
$key = array_search(strtolower($record[$name]), array_map('strtolower',$selects[$name]));
if($key !== false) $record[$name] = $key;
}
}

View File

@ -286,7 +286,7 @@
$data = translation::convert($data,$options['charset']);
$ok = true;
if(count($data) != count($options['field_mapping']) && max(array_keys($data)) != max(array_keys($options['csv_fields'])))
if(count($data) != count($options['field_mapping']) && max(array_keys($data)) != max(array_keys($options['field_mapping'])))
{
$message[] = lang("Column mismatch. Expected %1 columns, your file has %2.",
count($options['field_mapping']),

View File

@ -26,15 +26,15 @@ class infolog_export_csv implements importexport_iface_export_plugin {
$options = $_definition->plugin_options;
translation::add_app('infolog');
$bo = new infolog_bo();
$this->bo = new infolog_bo();
$selection = array();
$query = array();
$cf_links = array();
if(!$this->selects)
{
$this->selects['info_type'] = $bo->enums['type'];
$this->selects['info_priority'] = $bo->enums['priority'];
$this->selects['info_type'] = $this->bo->enums['type'];
$this->selects['info_priority'] = $this->bo->enums['priority'];
}
$export_object = new importexport_export_csv($_stream, (array)$options);
@ -45,9 +45,9 @@ class infolog_export_csv implements importexport_iface_export_plugin {
if($field[0] == '#') {
$query['custom_fields'][] = $field;
if($GLOBALS['egw_info']['user']['apps'][$bo->customfields[substr($field,1)]['type']])
if($GLOBALS['egw_info']['user']['apps'][$this->bo->customfields[substr($field,1)]['type']])
{
$cf_links[$field] = $bo->customfields[substr($field,1)]['type'];
$cf_links[$field] = $this->bo->customfields[substr($field,1)]['type'];
}
}
}
@ -62,7 +62,7 @@ class infolog_export_csv implements importexport_iface_export_plugin {
$query['num_rows'] = 500;
$query['start'] = 0;
do {
$selection = $bo->search($query);
$selection = $this->bo->search($query);
$ids = array_keys($selection);
// Pre-load any cfs that are links
@ -131,7 +131,7 @@ class infolog_export_csv implements importexport_iface_export_plugin {
}
// Some conversion
if($options['convert']) {
$this->selects['info_status'] = $bo->status[$record->info_type];
$this->selects['info_status'] = $this->bo->get_status($record->info_type);
importexport_export_csv::convert($record, infolog_egw_record::$types, 'infolog', $this->selects);
$this->convert($record);

View File

@ -152,7 +152,9 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
$_lookups = array(
'info_type' => $this->boinfolog->enums['type'],
'info_status' => $this->boinfolog->status['task']
'info_status' => $this->boinfolog->status['task'],
'info_priority' => $this->boinfolog->enums['priority'],
'info_confirm' => $this->boinfolog->enums['confirm']
);
// Start counting successes

View File

@ -2,7 +2,7 @@
<entry type="array" name="importExportDefinitions">
<entry type="array" name="metainfo">
<entry type="string" name="type">importexport definitions</entry>
<entry type="string" name="charset">user</entry>
<entry type="string" name="charset">utf-8</entry>
<entry type="integer" name="entries">2</entry>
</entry>
<entry type="array" name="definitions">
@ -32,11 +32,12 @@
<entry type="string" name="info_datecompleted">Date completed</entry>
<entry type="string" name="info_datemodified">Last changed</entry>
<entry type="string" name="info_location">Location</entry>
<entry type="string" name="info_startdate">Startdate</entry>
<entry type="string" name="info_enddate">Enddate</entry>
<entry type="string" name="info_startdate">Start date</entry>
<entry type="string" name="info_enddate">Due date</entry>
<entry type="string" name="info_responsible">Responsible</entry>
<entry type="string" name="info_cc">Cc</entry>
<entry type="string" name="info_planned_time">planned time</entry>
<entry type="string" name="info_replanned_time">re-planned time</entry>
<entry type="string" name="info_used_time">used time</entry>
<entry type="string" name="pl_id">pricelist</entry>
<entry type="string" name="info_price">price</entry>
@ -47,7 +48,7 @@
<entry type="string" name="begin_with_fieldnames">label</entry>
<entry type="string" name="convert">1</entry>
</entry>
<entry type="string" name="modified">2011-05-24 10:00:00</entry>
<entry type="string" name="modified">2012-10-10 10:00:00</entry>
</entry>
<entry type="array" name="import-infolog">
<entry type="string" name="name">import-infolog</entry>
@ -78,14 +79,15 @@
<entry type="string" name="13">Date completed</entry>
<entry type="string" name="14">Last changed</entry>
<entry type="string" name="15">Location</entry>
<entry type="string" name="16">Start Date</entry>
<entry type="string" name="16">Start date</entry>
<entry type="string" name="17">Due date</entry>
<entry type="string" name="18">responsible</entry>
<entry type="string" name="18">Responsible</entry>
<entry type="string" name="19">Cc</entry>
<entry type="string" name="20">planned time</entry>
<entry type="string" name="21">used time</entry>
<entry type="string" name="22">Pricelist</entry>
<entry type="string" name="23">Price</entry>
<entry type="string" name="21">re-planned time</entry>
<entry type="string" name="22">used time</entry>
<entry type="string" name="23">pricelist</entry>
<entry type="string" name="24">price</entry>
</entry>
<entry type="array" name="field_mapping">
<entry type="string" name="0">info_id</entry>
@ -104,14 +106,15 @@
<entry type="string" name="13">info_datecompleted</entry>
<entry type="string" name="14">info_datemodified</entry>
<entry type="string" name="15">info_location</entry>
<entry type="string" name="16">info_enddate</entry>
<entry type="string" name="17">info_responsible</entry>
<entry type="string" name="16">info_startdate</entry>
<entry type="string" name="17">info_enddate</entry>
<entry type="string" name="18">info_responsible</entry>
<entry type="string" name="19">info_cc</entry>
<entry type="string" name="20">info_planned_time</entry>
<entry type="string" name="21">info_used_time</entry>
<entry type="string" name="22">pl_id</entry>
<entry type="string" name="23">info_price</entry>
<entry type="string" name="21">info_replanned_time</entry>
<entry type="string" name="22">info_used_time</entry>
<entry type="string" name="23">pl_id</entry>
<entry type="string" name="24">info_price</entry>
</entry>
<entry type="string" name="field_conversion"/>
<entry type="array" name="conditions">
@ -126,8 +129,9 @@
</entry>
</entry>
</entry>
<entry type="string" name="convert">1</entry>
</entry>
<entry type="string" name="modified">2012-10-09 10:00:00</entry>
<entry type="string" name="modified">2012-10-10 10:00:00</entry>
</entry>
</entry>
</entry>

View File

@ -18,16 +18,17 @@
<entry type="array" name="mapping">
<entry type="string" name="res_id">Resource ID</entry>
<entry type="string" name="name">Name</entry>
<entry type="string" name="inventory_number">Inventory number</entry>
<entry type="string" name="short_description">Short description</entry>
<entry type="string" name="long_description">Long description</entry>
<entry type="string" name="cat_id">Category</entry>
<entry type="string" name="quantity">Quantity</entry>
<entry type="string" name="useable">useable</entry>
<entry type="string" name="useable">Usable</entry>
<entry type="string" name="location">Location</entry>
<entry type="string" name="storage_info">Storage</entry>
<entry type="string" name="bookable">Bookable</entry>
<entry type="string" name="buyable">Buyable</entry>
<entry type="string" name="prize">Prize</entry>
<entry type="string" name="long_description">Long description</entry>
<entry type="string" name="inventory_number">Inventory number</entry>
<entry type="string" name="all_custom_fields">resources</entry>
</entry>
<entry type="string" name="delimiter">;</entry>
@ -35,7 +36,7 @@
<entry type="string" name="begin_with_fieldnames">label</entry>
<entry type="string" name="convert">1</entry>
</entry>
<entry type="string" name="modified">2011-05-24 10:12:46</entry>
<entry type="string" name="modified">2012-10-10 12:43:09</entry>
</entry>
<entry type="array" name="import-resources">
<entry type="string" name="name">import-resources</entry>
@ -53,31 +54,32 @@
<entry type="array" name="csv_fields">
<entry type="string" name="0">Resource ID</entry>
<entry type="string" name="1">Name</entry>
<entry type="string" name="2">Short description</entry>
<entry type="string" name="3">Category</entry>
<entry type="string" name="4">Quantity</entry>
<entry type="string" name="5">useable</entry>
<entry type="string" name="6">Location</entry>
<entry type="string" name="7">Bookable</entry>
<entry type="string" name="8">Buyable</entry>
<entry type="string" name="9">Prize</entry>
<entry type="string" name="10">Long description</entry>
<entry type="string" name="11">Inventory number</entry>
<entry type="string" name="12">Test CF</entry>
<entry type="string" name="2">Inventory number</entry>
<entry type="string" name="3">Short description</entry>
<entry type="string" name="4">Long description</entry>
<entry type="string" name="5">Category</entry>
<entry type="string" name="6">Quantity</entry>
<entry type="string" name="7">Usable</entry>
<entry type="string" name="8">Location</entry>
<entry type="string" name="9">Storage</entry>
<entry type="string" name="10">Bookable</entry>
<entry type="string" name="11">Buyable</entry>
<entry type="string" name="12">Prize</entry>
</entry>
<entry type="array" name="field_mapping">
<entry type="string" name="0">res_id</entry>
<entry type="string" name="1">name</entry>
<entry type="string" name="2">short_description</entry>
<entry type="string" name="3">cat_id</entry>
<entry type="string" name="4">quantity</entry>
<entry type="string" name="5">useable</entry>
<entry type="string" name="6">location</entry>
<entry type="string" name="7">bookable</entry>
<entry type="string" name="8">buyable</entry>
<entry type="string" name="9">prize</entry>
<entry type="string" name="10">long_description</entry>
<entry type="string" name="11">inventory_number</entry>
<entry type="string" name="2">inventory_number</entry>
<entry type="string" name="3">short_description</entry>
<entry type="string" name="4">long_description</entry>
<entry type="string" name="5">cat_id</entry>
<entry type="string" name="6">quantity</entry>
<entry type="string" name="7">useable</entry>
<entry type="string" name="8">location</entry>
<entry type="string" name="9">storage_info</entry>
<entry type="string" name="10">bookable</entry>
<entry type="string" name="11">buyable</entry>
<entry type="string" name="12">prize</entry>
</entry>
<entry type="string" name="field_conversion"/>
<entry type="array" name="conditions">
@ -96,7 +98,7 @@
</entry>
<entry type="string" name="convert">1</entry>
</entry>
<entry type="string" name="modified">2012-10-09 11:00:00</entry>
<entry type="string" name="modified">2012-10-10 12:55:25</entry>
</entry>
</entry>
</entry>

View File

@ -174,7 +174,7 @@ class timesheet_import_csv implements importexport_iface_import_plugin {
// don't import empty records
if( count( array_unique( $record ) ) < 2 ) continue;
$result = importexport_import_csv::convert($record, timesheet_egw_record::$types, 'timesheet', $lookups);
$result = importexport_import_csv::convert($record, timesheet_egw_record::$types, 'timesheet', $lookups, $_definition->plugin_options['convert']);
if($result) $this->warnings[$import_csv->get_current_position()] = $result;
// Automatically handle text categories without explicit translation