Fix: Import example file was wrong

This commit is contained in:
Laurent Destailleur 2011-06-07 10:36:30 +00:00
parent 8fe14361c3
commit 777c1ff575
2 changed files with 215 additions and 212 deletions

View File

@ -1,22 +1,22 @@
<?php <?php
/* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2009-2010 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see http://www.gnu.org/ * or see http://www.gnu.org/
*/ */
/** /**
* \file htdocs/includes/modules/import/import_csv.modules.php * \file htdocs/includes/modules/import/import_csv.modules.php
@ -62,7 +62,7 @@ class ImportCsv extends ModeleImports
global $conf,$langs; global $conf,$langs;
$this->db = $db; $this->db = $db;
$this->separator=','; $this->separator=','; // Change also function cleansep
if (! empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE)) $this->separator=$conf->global->IMPORT_CSV_SEPARATOR_TO_USE; if (! empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE)) $this->separator=$conf->global->IMPORT_CSV_SEPARATOR_TO_USE;
$this->enclosure='"'; $this->enclosure='"';
$this->escape='"'; $this->escape='"';
@ -131,10 +131,7 @@ class ImportCsv extends ModeleImports
*/ */
function write_title_example($outputlangs,$headerlinefields) function write_title_example($outputlangs,$headerlinefields)
{ {
$func = function($value) { $s.=join($this->separator,array_map('cleansep',$headerlinefields));
return str_replace($this->separator,'/',$value);
};
$s.=join($this->separator,array_map($headerlinefields));
return $s."\n"; return $s."\n";
} }
@ -144,10 +141,7 @@ class ImportCsv extends ModeleImports
*/ */
function write_record_example($outputlangs,$contentlinevalues) function write_record_example($outputlangs,$contentlinevalues)
{ {
$func = function($value) { $s=join($this->separator,array_map('cleansep',$contentlinevalues));
return str_replace($this->separator,'/',$value);
};
$s=join($this->separator,array_map($contentlinevalues));
return $s."\n"; return $s."\n";
} }
@ -466,4 +460,12 @@ class ImportCsv extends ModeleImports
} }
/**
* Clean a string from separator
*/
function cleansep($value)
{
return str_replace(',','/',$value);
};
?> ?>

View File

@ -289,8 +289,9 @@ ExportCardToFormat=Export card to format
ContactNotLinkedToCompany=Contact not linked to any third party ContactNotLinkedToCompany=Contact not linked to any third party
DolibarrLogin=Dolibarr login DolibarrLogin=Dolibarr login
NoDolibarrAccess=No Dolibarr access NoDolibarrAccess=No Dolibarr access
ExportDataset_company_1=Companies/foundations and properties ExportDataset_company_1=Third parties (Companies/foundations) and properties
ExportDataset_company_2=Contacts and properties ExportDataset_company_2=Contacts and properties
ImportDataset_company_1=Third parties (Companies/foundations) and properties
PriceLevel=Price level PriceLevel=Price level
DeliveriesAddress=Delivery addresses DeliveriesAddress=Delivery addresses
DeliveryAddress=Delivery address DeliveryAddress=Delivery address