| ';
- print $langs->trans("SelectExportFields");
- print ' | ';
+ print '';
diff --git a/htdocs/html.formother.class.php b/htdocs/html.formother.class.php
index 57920ec39c5..3499d0fe58f 100644
--- a/htdocs/html.formother.class.php
+++ b/htdocs/html.formother.class.php
@@ -102,6 +102,53 @@ class FormOther
}
+ /**
+ * \brief Retourne la liste des modeles d'import
+ * \param selected Id modele pre-selectionne
+ * \param htmlname Nom de la zone select
+ * \param type Type des modeles recherches
+ * \param useempty Affiche valeur vide dans liste
+ */
+ function select_import_model($selected='',$htmlname='importmodelid',$type='',$useempty=0)
+ {
+ $sql = "SELECT rowid, label";
+ $sql.= " FROM ".MAIN_DB_PREFIX."import_model";
+ $sql.= " WHERE type = '".$type."'";
+ $sql.= " ORDER BY rowid";
+ $result = $this->db->query($sql);
+ if ($result)
+ {
+ print '";
+ }
+ else {
+ dol_print_error($this->db);
+ }
+ }
+
+
/**
* \brief Retourne la liste des ecotaxes avec tooltip sur le libelle
* \param selected code ecotaxes pre-selectionne
diff --git a/htdocs/imports/ajaximport.php b/htdocs/imports/ajaximport.php
index c5bb91d8707..ef75ffeb9ae 100644
--- a/htdocs/imports/ajaximport.php
+++ b/htdocs/imports/ajaximport.php
@@ -18,7 +18,7 @@
*/
/**
- * \file htdocs/ajaximport.php
+ * \file htdocs/imports/ajaximport.php
* \brief File to return Ajax response on Fields move in import page
* \version $Id$
*/
@@ -28,7 +28,6 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
-if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
// This is to make Dolibarr working with Plesk
set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs');
@@ -38,24 +37,55 @@ $entityCookieName = "DOLENTITYID_dolibarr";
if (isset($_COOKIE[$entityCookieName])) $_SESSION["dol_entity"] = $_COOKIE[$entityCookieName];
require('../master.inc.php');
+require_once(DOL_DOCUMENT_ROOT."/imports/import.class.php");
+require_once(DOL_DOCUMENT_ROOT.'/includes/modules/import/modules_import.php');
// Enregistrement de la position des champs
-
-//$_SESSION["dol_array_match_file_to_database"]
-dol_syslog("AjaxImport boxorder=".$_GET['boxorder']." userid=".$_GET['userid'], LOG_DEBUG);
-
-$part=split(':',$collist);
+dol_syslog("AjaxImport boxorder=".$_GET['boxorder']." userid=".$_GET['userid']." datatoimport=".$_GET["datatoimport"], LOG_DEBUG);
+$part=split(':',$_GET['boxorder']);
$colonne=$part[0];
$list=$part[1];
dol_syslog('AjaxImport column='.$colonne.' list='.$list);
+// Init object $objimport that describe the predefined import
+$fuser->id=$_GET['userid'];
+$fuser->fetch();
+$objimport=new Import($db);
+$datatoimport=isset($_GET["datatoimport"])? $_GET["datatoimport"] : (isset($_POST["datatoimport"])?$_POST["datatoimport"]:'');
+$objimport->load_arrays($fuser,$datatoimport);
-// We define array_match_file_to_database
+// Init targets fields array
+$fieldstarget=$objimport->array_import_fields[0];
+
+// We redefine array_match_file_to_database
$array_match_file_to_database=array();
+$listelem=split(',',$list);
+$pos=0;
+foreach($listelem as $fieldnb)
+{
+ //dol_syslog("Fieldnb in file=".$fieldnb." => keynb in targets=".$pos);
+ // Get name of database field at position $pos into $namefield
+ $posbis=0;$namefield='';
+ foreach($fieldstarget as $key => $val)
+ {
+ if ($posbis < $pos)
+ {
+ $posbis++;
+ continue;
+ }
+ // We found the key of targets that is at position pos
+ $namefield=$key;
+ break;
+ }
+ if (! empty($fieldnb)) $array_match_file_to_database[$fieldnb]=$namefield;
+
+ $pos++;
+}
// We save new matching in session
$_SESSION["dol_array_match_file_to_database"]=$array_match_file_to_database;
+dol_syslog('AjaxImport dol_array_match_file_to_database='.var_export($array_match_file_to_database,true));
?>
diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php
index 9c9d8a55887..504263ff5df 100644
--- a/htdocs/imports/import.php
+++ b/htdocs/imports/import.php
@@ -327,7 +327,7 @@ if ($step == 2 && $datatoimport)
$fullpathfiletoimport='';
$var=true;
- // Add help informations
+ // Add format informations and link to download example
print ' |
';
print '| '.img_picto_common($key,$objmodelimport->getPicto($key)).' | ';
- print ''.$objmodelimport->getDriverLabel($key).' | ';
+ print ''.$objmodelimport->getDriverLabel($key).' | ';
+ print ''.$langs->trans("DownloadEmptyExample").' | ';
//print ''.$objmodelimport->getLibLabel($key).' | '.$objmodelimport->getLibVersion($key).' | ';
print '
';
}
@@ -463,9 +464,13 @@ if ($step == 3 && $datatoimport)
$_SESSION["dol_array_match_file_to_database"]=$array_match_file_to_database;
}
+ // Now $array_match_file_to_database contains fieldnb(1,2,3...)=>fielddatabase(key in $array_match_file_to_database)
+
llxHeader('',$langs->trans("NewImport"),'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones');
+ $param='step=3&datatoimport='.$datatoimport.'&filetoimport='.urlencode($_GET["filetoimport"]);
+
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=1';
@@ -476,7 +481,7 @@ if ($step == 3 && $datatoimport)
$head[$h][1] = $langs->trans("Step")." 2";
$h++;
- $head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=3&datatoimport='.$datatoimport.'&filetoimport='.urlencode($_GET["filetoimport"]);
+ $head[$h][0] = DOL_URL_ROOT.'/imports/import.php?'.$param;
$head[$h][1] = $langs->trans("Step")." 3";
$hselected=$h;
$h++;
@@ -507,7 +512,18 @@ if ($step == 3 && $datatoimport)
print '