diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php
index 5ac4c68c96e..1f650889f91 100644
--- a/htdocs/exports/export.php
+++ b/htdocs/exports/export.php
@@ -136,7 +136,7 @@ if ($action=='downfield' || $action=='upfield')
$pos=$array_selected[$_GET["field"]];
if ($action=='downfield') $newpos=$pos+1;
if ($action=='upfield') $newpos=$pos-1;
- // Recherche code avec qui switch�
+ // Recherche code avec qui switcher
$newcode="";
foreach($array_selected as $code=>$value)
{
@@ -147,7 +147,7 @@ if ($action=='downfield' || $action=='upfield')
}
}
//print("Switch pos=$pos (code=".$_GET["field"].") and newpos=$newpos (code=$newcode)");
- if ($newcode) // Si newcode trouv� (prtoection contre resoumission de page
+ if ($newcode) // Si newcode trouve (protection contre resoumission de page)
{
$array_selected[$_GET["field"]]=$newpos;
$array_selected[$newcode]=$pos;
diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php
index 46b326b9044..823d9a20e4d 100644
--- a/htdocs/imports/import.php
+++ b/htdocs/imports/import.php
@@ -63,7 +63,7 @@ $entitytolang=array( // Translation code
'other'=>'Other'
);
-$array_selected=isset($_SESSION["import_selected_fields"])?$_SESSION["import_selected_fields"]:array();
+$array_match_file_to_database=isset($_SESSION["dol_array_match_file_to_database"])?$_SESSION["dol_array_match_file_to_database"]:array();
$datatoimport=isset($_GET["datatoimport"])? $_GET["datatoimport"] : (isset($_POST["datatoimport"])?$_POST["datatoimport"]:'');
$action=isset($_GET["action"]) ? $_GET["action"] : (isset($_POST["action"])?$_POST["action"]:'');
$step=isset($_GET["step"])? $_GET["step"] : (isset($_POST["step"])?$_POST["step"]:1);
@@ -85,6 +85,7 @@ $sqlusedforimport='';
* Actions
*/
+/*
if ($action=='selectfield')
{
if ($_GET["field"]=='all')
@@ -92,17 +93,17 @@ if ($action=='selectfield')
$fieldsarray=$objimport->array_import_alias[0];
foreach($fieldsarray as $key=>$val)
{
- if (! empty($array_selected[$key])) continue; // If already selected, select next
- $array_selected[$key]=sizeof($array_selected)+1;
- //print_r($array_selected);
- $_SESSION["import_selected_fields"]=$array_selected;
+ if (! empty($array_match_file_to_database[$key])) continue; // If already selected, select next
+ $array_match_file_to_database[$key]=sizeof($array_match_file_to_database)+1;
+ //print_r($array_match_file_to_database);
+ $_SESSION["dol_array_match_file_to_database"]=$array_match_file_to_database;
}
}
else
{
- $array_selected[$_GET["field"]]=sizeof($array_selected)+1;
- //print_r($array_selected);
- $_SESSION["import_selected_fields"]=$array_selected;
+ $array_match_file_to_database[$_GET["field"]]=sizeof($array_match_file_to_database)+1;
+ //print_r($array_match_file_to_database);
+ $_SESSION["dol_array_match_file_to_database"]=$array_match_file_to_database;
}
}
@@ -110,33 +111,35 @@ if ($action=='unselectfield')
{
if ($_GET["field"]=='all')
{
- $array_selected=array();
- $_SESSION["import_selected_fields"]=$array_selected;
+ $array_match_file_to_database=array();
+ $_SESSION["dol_array_match_file_to_database"]=$array_match_file_to_database;
}
else
{
- unset($array_selected[$_GET["field"]]);
+ unset($array_match_file_to_database[$_GET["field"]]);
// Renumber fields of array_selected (from 1 to nb_elements)
- asort($array_selected);
+ asort($array_match_file_to_database);
$i=0;
- $array_selected_save=$array_selected;
- foreach($array_selected as $code=>$value)
+ $array_match_file_to_database_save=$array_match_file_to_database;
+ foreach($array_match_file_to_database as $code=>$value)
{
$i++;
- $array_selected[$code]=$i;
+ $array_match_file_to_database[$code]=$i;
//print "x $code x $i y
";
}
- $_SESSION["import_selected_fields"]=$array_selected;
+ $_SESSION["dol_array_match_file_to_database"]=$array_match_file_to_database;
}
}
+*/
+
if ($action=='downfield' || $action=='upfield')
{
- $pos=$array_selected[$_GET["field"]];
+ $pos=$array_match_file_to_database[$_GET["field"]];
if ($action=='downfield') $newpos=$pos+1;
if ($action=='upfield') $newpos=$pos-1;
- // Recherche code avec qui switch�
+ // Recherche code avec qui switcher
$newcode="";
- foreach($array_selected as $code=>$value)
+ foreach($array_match_file_to_database as $code=>$value)
{
if ($value == $newpos)
{
@@ -145,24 +148,18 @@ if ($action=='downfield' || $action=='upfield')
}
}
//print("Switch pos=$pos (code=".$_GET["field"].") and newpos=$newpos (code=$newcode)");
- if ($newcode) // Si newcode trouv� (prtoection contre resoumission de page
+ if ($newcode) // Si newcode trouve (protection contre resoumission de page)
{
- $array_selected[$_GET["field"]]=$newpos;
- $array_selected[$newcode]=$pos;
- $_SESSION["import_selected_fields"]=$array_selected;
+ $array_match_file_to_database[$_GET["field"]]=$newpos;
+ $array_match_file_to_database[$newcode]=$pos;
+ $_SESSION["dol_array_match_file_to_database"]=$array_match_file_to_database;
}
}
-if ($step == 1 || $action == 'cleanselect')
-{
- $_SESSION["import_selected_fields"]=array();
- $array_selected=array();
-}
-
if ($action == 'builddoc')
{
// Build import file
- $result=$objimport->build_file($user, $_POST['model'], $datatoimport, $array_selected);
+ $result=$objimport->build_file($user, $_POST['model'], $datatoimport, $array_match_file_to_database);
if ($result < 0)
{
$mesg='
| '.$langs->trans("FieldsInSourceFile").' | '; - print '  | '; print ''.$langs->trans("FieldsInTargetDatabase").' | '; print '||||||
| '; + print ' | ||||||||
';
// List of source fields
print '
| ';
- // Arrows
- print '
| '; + + print ' | ';
$i = 0;
$var=true;
@@ -614,7 +658,7 @@ if ($step == 3 && $datatoimport)
*/
print ' ';
- if (sizeof($array_selected))
+ if (sizeof($array_match_file_to_database))
{
print ''.$langs->trans("NextStep").'';
}
@@ -623,7 +667,7 @@ if ($step == 3 && $datatoimport)
// Area for profils import
- if (sizeof($array_selected))
+ if (sizeof($array_match_file_to_database))
{
print ' '; print $langs->trans("SaveImportModel"); @@ -683,7 +727,7 @@ if ($step == 3 && $datatoimport) if ($step == 4 && $datatoimport) { - asort($array_selected); + asort($array_match_file_to_database); llxHeader('',$langs->trans("NewImport")); @@ -730,7 +774,7 @@ if ($step == 4 && $datatoimport) // Nbre champs importes print ' '.$langs->trans("ImportedFields").' | ';
$list='';
- foreach($array_selected as $code=>$label)
+ foreach($array_match_file_to_database as $code=>$label)
{
$list.=($list?',':'');
$list.=$langs->trans($objimport->array_import_fields[0][$code]);
diff --git a/mysql/migration/2.6.0-2.7.0.sql b/mysql/migration/2.6.0-2.7.0.sql
index dd306c7aa74..9d595334426 100644
--- a/mysql/migration/2.6.0-2.7.0.sql
+++ b/mysql/migration/2.6.0-2.7.0.sql
@@ -6,6 +6,18 @@
-- when current version is 2.6.0 or higher.
--
+-- Create new table for import module
+create table llx_import_model
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ fk_user integer DEFAULT 0 NOT NULL,
+ label varchar(50) NOT NULL,
+ type varchar(20) NOT NULL,
+ field text NOT NULL
+)type=innodb;
+
+ALTER TABLE llx_import_model ADD UNIQUE INDEX uk_import_model (label,type);
+
delete from llx_const where name = 'FACTURE_ENABLE_RECUR';
alter table llx_facturedet_rec add column product_type integer DEFAULT 0 after fk_product;
diff --git a/mysql/tables/llx_import_model.key.sql b/mysql/tables/llx_import_model.key.sql
new file mode 100644
index 00000000000..68b6cd9a315
--- /dev/null
+++ b/mysql/tables/llx_import_model.key.sql
@@ -0,0 +1,22 @@
+-- ===================================================================
+-- Copyright (C) 2009 Laurent Destailleur |