diff --git a/ChangeLog b/ChangeLog
index 470d4647b9e624140c9843065028ad50dc3fab55..c64c7f74931834500b818fc9ee3b7a92fc629a73 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@ English Dolibarr ChangeLog
 ***** ChangeLog for 3.0 compared to 2.9 *****
 
 For users:
+- New: Can import members using assistant.
 - New: Can exclude deposit, replacement or credit notes in script rebuild_merge_pdf.
 - New: task #10473 : Option MAIN_PROFIDx_IN_ADDRESS must no more be hidden.
 - New: Can generate business card for on particular member.
diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php
index b606076b25d6330c0223673c2fd18aee217bd447..22ec0059b0c15a7e137cae545b5465486902f5f1 100644
--- a/htdocs/adherents/card_subscriptions.php
+++ b/htdocs/adherents/card_subscriptions.php
@@ -27,6 +27,7 @@
 
 require("../main.inc.php");
 require_once(DOL_DOCUMENT_ROOT."/lib/member.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
 require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
 require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php");
 require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_options.class.php");
@@ -755,7 +756,6 @@ if ($rowid)
         }
         if (! $dateto)
         {
-            //$dateto=dol_time_plus_duree(dol_time_plus_duree($datefrom,$defaultdelay,$defaultdelayunit),-1,'d');
             $dateto=-1;		// By default, no date is suggested
         }
         print '<tr><td>'.$langs->trans("DateEndSubscription").'</td><td>';
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index 045d1bb33a13e9aca01a4b5fa6bff5dcc767134b..57378b016a74e3bcd26205093ce877a09b1e697c 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -31,6 +31,7 @@
 require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
 require_once(DOL_DOCUMENT_ROOT."/adherents/class/cotisation.class.php");
 require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
 
 
 /**
diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php
index e4a979ac5b4a259af9b56d7bb850e9af70207bb1..0030758f2c0bce9b5badc00bbf0b81c31b56cb8d 100644
--- a/htdocs/contrat/fiche.php
+++ b/htdocs/contrat/fiche.php
@@ -28,6 +28,7 @@
  */
 
 require ("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
 require_once(DOL_DOCUMENT_ROOT.'/lib/contract.lib.php');
 if ($conf->projet->enabled)  require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
 if ($conf->propal->enabled)  require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php
index 94b55fb6d0fae7c20bb18b28c8061b1af17eab57..0f5e64cb7bb0bfe72a10b4a34b081812123a4057 100644
--- a/htdocs/imports/import.php
+++ b/htdocs/imports/import.php
@@ -1071,7 +1071,7 @@ if ($step == 4 && $datatoimport)
 }
 
 
-// STEP 5: Summary of choices
+// STEP 5: Summary of choices and launch simulation
 if ($step == 5 && $datatoimport)
 {
 	$model=$format;
@@ -1262,356 +1262,162 @@ if ($step == 5 && $datatoimport)
 	print '</div>';
 
 
-	// Show import id
-	print $langs->trans("NowClickToTestTheImport",$langs->transnoentitiesnoconv("RunSimulateImportFile")).'<br>';
-	print '<br>';
-
-
-	// Actions
-	print '<center>';
-	if ($user->rights->import->run)
-	{
-		print '<a class="butAction" href="'.DOL_URL_ROOT.'/imports/import.php?leftmenu=import&step=6'.$param.'">'.$langs->trans("RunSimulateImportFile").'</a>';
-	}
-	else
-	{
-		print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("RunSimulateImportFile").'</a>';
-	}
-	/*print '<form action="'.$_SERVER["PHP_SELF"].'?step=6&'.$param.'">';
-	print '<input class="button" type="submit" value="'.$langs->trans("RunSimulateImportFile").'">';
-	print '</form>';*/
-	print '</center>';
-
-	if ($mesg) print $mesg;
+    if (GETPOST('action') != 'launchsimu')
+    {
+        // Show import id
+        print $langs->trans("NowClickToTestTheImport",$langs->transnoentitiesnoconv("RunSimulateImportFile")).'<br>';
+        print '<br>';
+
+        // Actions
+        print '<center>';
+        if ($user->rights->import->run)
+        {
+            print '<a class="butAction" href="'.DOL_URL_ROOT.'/imports/import.php?leftmenu=import&step=5&action=launchsimu'.$param.'">'.$langs->trans("RunSimulateImportFile").'</a>';
+        }
+        else
+        {
+            print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("RunSimulateImportFile").'</a>';
+        }
+        print '</center>';
+    }
+    else
+    {
+
+        // Launch import
+        $arrayoferrors=array();
+        $arrayofwarnings=array();
+        $maxnboferrors=empty($conf->global->IMPORT_MAX_NB_OF_ERRORS)?50:$conf->global->IMPORT_MAX_NB_OF_ERRORS;
+        $maxnbofwarnings=empty($conf->global->IMPORT_MAX_NB_OF_WARNINGS)?50:$conf->global->IMPORT_MAX_NB_OF_WARNINGS;
+        $nboferrors=0;
+        $nbofwarnings=0;
+
+        $importid=dol_print_date(dol_now('tzserver'),'%Y%m%d%H%M%S');
+
+        //var_dump($array_match_file_to_database);
+
+        $db->begin();
+
+        // Open input file
+        $nbok=0;
+        $pathfile=$conf->import->dir_temp.'/'.$filetoimport;
+        $result=$obj->import_open_file($pathfile,$langs);
+        if ($result > 0)
+        {
+            $sourcelinenb=0;
+            // Loop on each input file record
+            while ($sourcelinenb < $nboflines)
+            {
+                $sourcelinenb++;
+                $arrayrecord=$obj->import_read_record();
+                if ($excludefirstline && $sourcelinenb == 1) continue;
+
+                $result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,sizeof($fieldssource),$importid);
+                if (sizeof($obj->errors))   $arrayoferrors[$sourcelinenb]=$obj->errors;
+                if (sizeof($obj->warnings)) $arrayofwarnings[$sourcelinenb]=$obj->warnings;
+                if (! sizeof($obj->errors) && ! sizeof($obj->warnings)) $nbok++;
+            }
+            // Close file
+            $obj->import_close_file();
+        }
+        else
+        {
+            print $langs->trans("ErrorFailedToOpenFile",$pathfile);
+        }
+
+        $db->rollback();    // We force rollback because this was just a simulation.
+
+        // Show OK
+        if (! sizeof($arrayoferrors) && ! sizeof($arrayofwarnings)) print img_tick().' <b>'.$langs->trans("NoError").'</b><br><br>';
+        else print $langs->trans("NbOfLinesOK",$nbok).'</b><br><br>';
+
+        // Show Errors
+        //var_dump($arrayoferrors);
+        if (sizeof($arrayoferrors))
+        {
+            print img_error().' <b>'.$langs->trans("ErrorsOnXLines",sizeof($arrayoferrors)).'</b><br>';
+            print '<table width="100%" class="border"><tr><td>';
+            foreach ($arrayoferrors as $key => $val)
+            {
+                $nboferrors++;
+                if ($nboferrors > $maxnboferrors)
+                {
+                    print $langs->trans("TooMuchErrors",(sizeof($arrayoferrors)-$nboferrors))."<br>";
+                    break;
+                }
+                print '* '.$langs->trans("Line").' '.$key.'<br>';
+                foreach($val as $i => $err)
+                {
+                    print ' &nbsp; &nbsp; > '.$err['lib'].'<br>';
+                }
+            }
+            print '</td></tr></table>';
+            print '<br>';
+        }
+
+        // Show Warnings
+        //var_dump($arrayoferrors);
+        if (sizeof($arrayofwarnings))
+        {
+            print img_warning().' <b>'.$langs->trans("WarningsOnXLines",sizeof($arrayofwarnings)).'</b><br>';
+            print '<table width="100%" class="border"><tr><td>';
+            foreach ($arrayofwarnings as $key => $val)
+            {
+                $nbofwarnings++;
+                if ($nbofwarnings > $maxnbofwarnings)
+                {
+                    print $langs->trans("TooMuchWarnings",(sizeof($arrayofwarnings)-$nbofwarnings))."<br>";
+                    break;
+                }
+                print ' * '.$langs->trans("Line").' '.$key.'<br>';
+                foreach($val as $i => $err)
+                {
+                    print ' &nbsp; &nbsp; > '.$err['lib'].'<br>';
+                }
+            }
+            print '</td></tr></table>';
+            print '<br>';
+        }
+
+        // Show import id
+        $importid=dol_print_date(dol_now('tzserver'),'%Y%m%d%H%M%S');
+
+        print '<center>';
+        print $langs->trans("NowClickToRunTheImport",$langs->transnoentitiesnoconv("RunImportFile")).'<br>';
+        print $langs->trans("DataLoadedWithId",$importid).'<br>';
+        print '</center>';
+
+        print '<br>';
+
+        // Actions
+        print '<center>';
+        if ($user->rights->import->run)
+        {
+            if (empty($nboferrors))
+            {
+                print '<a class="butAction" href="'.DOL_URL_ROOT.'/imports/import.php?leftmenu=import&step=6&importid='.$importid.$param.'">'.$langs->trans("RunImportFile").'</a>';
+            }
+            else
+            {
+                //print '<a class="butAction" href="'.DOL_URL_ROOT.'/imports/import.php?leftmenu=import&step=5&action=launchsimu'.$param.'">'.$langs->trans("RunSimulateImportFile").'</a>';
+
+                print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("CorrectErrorBeforeRunningImport")).'">'.$langs->trans("RunImportFile").'</a>';
+            }
+        }
+        else
+        {
+            print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("RunSimulateImportFile").'</a>';
+
+            print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("RunImportFile").'</a>';
+        }
+        print '</center>';
+    }
+
+    if ($mesg) print $mesg;
 }
 
 
-// STEP 6: Result of simulation
+// STEP 6: Real import
 if ($step == 6 && $datatoimport)
-{
-	$model=$format;
-	$liste=$objmodelimport->liste_modeles($db);
-
-	// Create classe to use for import
-	$dir = DOL_DOCUMENT_ROOT . "/includes/modules/import/";
-	$file = "import_".$model.".modules.php";
-	$classname = "Import".ucfirst($model);
-	require_once($dir.$file);
-	$obj = new $classname($db);
-
-	// Load source fields in input file
-	$fieldssource=array();
-	$result=$obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport,$langs);
-	if ($result >= 0)
-	{
-		// Read first line
-		$arrayrecord=$obj->import_read_record();
-		// Put into array fieldssource starting with 1.
-		$i=1;
-		foreach($arrayrecord as $key => $val)
-		{
-			$fieldssource[$i]['example1']=dol_trunc($val['val'],24);
-			$i++;
-		}
-		$obj->import_close_file();
-	}
-
-	$nboflines=(! empty($_GET["nboflines"])?$_GET["nboflines"]:dol_count_nb_of_line($conf->import->dir_temp.'/'.$filetoimport));
-
-	$param='&format='.$format.'&datatoimport='.$datatoimport.'&filetoimport='.urlencode($filetoimport).'&nboflines='.$nboflines;
-	if ($excludefirstline) $param.='&excludefirstline=1';
-
-	llxHeader('',$langs->trans("NewImport"),'EN:Module_Imports_En|FR:Module_Imports|ES:M&oacute;dulo_Importaciones');
-
-	$h = 0;
-
-	$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=1'.$param;
-	$head[$h][1] = $langs->trans("Step")." 1";
-	$h++;
-
-	$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=2'.$param;
-	$head[$h][1] = $langs->trans("Step")." 2";
-	$h++;
-
-	$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=3'.$param;
-	$head[$h][1] = $langs->trans("Step")." 3";
-	$h++;
-
-	$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=4'.$param;
-	$head[$h][1] = $langs->trans("Step")." 4";
-	$h++;
-
-	$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=5'.$param;
-	$head[$h][1] = $langs->trans("Step")." 5";
-	$h++;
-
-	$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=6'.$param;
-	$head[$h][1] = $langs->trans("Step")." 6";
-	$hselected=$h;
-	$h++;
-
-	dol_fiche_head($head, $hselected, $langs->trans("NewImport"));
-
-	print '<table width="100%" class="border">';
-
-	// Module
-	print '<tr><td width="25%">'.$langs->trans("Module").'</td>';
-	print '<td>';
-	//print img_object($objimport->array_import_module[0]->getName(),$objimport->array_import_module[0]->picto).' ';
-	print $objimport->array_import_module[0]->getName();
-	print '</td></tr>';
-
-	// Lot de donnees a importer
-	print '<tr><td>'.$langs->trans("DatasetToImport").'</td>';
-	print '<td>';
-	print img_object($objimport->array_import_module[0]->getName(),$objimport->array_import_icon[0]).' ';
-	print $objimport->array_import_label[0];
-	print '</td></tr>';
-
-	print '</table><br>';
-	print '<b>'.$langs->trans("InformationOnSourceFile").'</b>';
-	print '<table width="100%" class="border">';
-	//print '<tr><td colspan="2"><b>'.$langs->trans("InformationOnSourceFile").'</b></td></tr>';
-
-	// Source file format
-	print '<tr><td width="25%">'.$langs->trans("SourceFileFormat").'</td>';
-	print '<td>';
-    $text=$objmodelimport->getDriverDesc($format);
-    print $html->textwithpicto($objmodelimport->getDriverLabel($format),$text);
-	print '</td></tr>';
-
-	// File to import
-	print '<tr><td>'.$langs->trans("FileToImport").'</td>';
-	print '<td>';
-	$modulepart='import';
-	//$relativepath=$filetoimport;
-    print '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&file='.urlencode($filetoimport).'&step=4'.$param.'" target="_blank">';
-    print $filetoimport;
-    print '</a>';
-	print '</td></tr>';
-
-	// Nb of fields
-	print '<tr><td>';
-	print $langs->trans("NbOfSourceLines");
-	print '</td><td>';
-	print $nboflines;
-	print '</td></tr>';
-
-	// Checkbox do not import first line
-	print '<tr><td>';
-	print $langs->trans("Option");
-	print '</td><td>';
-	print '<input type="hidden" name="excludefirstline" value="'.$excludefirstline.'">';
-	print '<input type="checkbox" name="excludefirstlinebis" value="1" disabled="true"';
-	print ($excludefirstline?' checked="true"':'');
-	print '>';
-	print ' '.$langs->trans("DoNotImportFirstLine");
-	print '</td></tr>';
-
-	print '</table>';
-
-	print '<br>';
-
-	print '<b>'.$langs->trans("InformationOnTargetTables").'</b>';
-	print '<table width="100%" class="border">';
-	//print '<tr><td colspan="2"><b>'.$langs->trans("InformationOnTargetTables").'</b></td></tr>';
-
-	// Tables imported
-	print '<tr><td width="25%">';
-	print $langs->trans("TablesTarget");
-	print '</td><td>';
-	$listtables=array();
-	foreach($array_match_file_to_database as $code=>$label)
-	{
-		//var_dump($fieldssource);
-		if ($code > sizeof($fieldssource)) continue;
-		//print $code.'-'.$label;
-		$alias=preg_replace('/(\..*)$/i','',$label);
-		$listtables[$alias]=$objimport->array_import_tables[0][$alias];
-	}
-	if (sizeof($listtables))
-	{
-		$newval='';
-		foreach ($listtables as $val)
-		{
-			if ($newval) print ', ';
-			$newval=$val;
-			// Link to Dolibarr wiki pages
-			/*$helppagename='EN:Table_'.$newval;
-			if ($helppagename && empty($conf->global->MAIN_HELP_DISABLELINK))
-			{
-				// Get helpbaseurl, helppage and mode from helppagename and langs
-				$arrayres=getHelpParamFor($helppagename,$langs);
-				$helpbaseurl=$arrayres['helpbaseurl'];
-				$helppage=$arrayres['helppage'];
-				$mode=$arrayres['mode'];
-				$newval.=' <a href="'.sprintf($helpbaseurl,$helppage).'">'.img_picto($langs->trans($mode == 'wiki' ? 'GoToWikiHelpPage': 'GoToHelpPage'),DOL_URL_ROOT.'/theme/common/helpdoc.png','',1).'</a>';
-			}*/
-			print $newval;
-		}
-	}
-	else print $langs->trans("Error");
-	print '</td></tr>';
-
-	// Fields imported
-	print '<tr><td>';
-	print $langs->trans("FieldsTarget").'</td><td>';
-	$listfields=array();
-	$i=0;
-	$sort_array_match_file_to_database=$array_match_file_to_database;
-	ksort($sort_array_match_file_to_database);
-	//var_dump($sort_array_match_file_to_database);
-	foreach($sort_array_match_file_to_database as $code=>$label)
-	{
-		$i++;
-		//var_dump($fieldssource);
-		if ($code > sizeof($fieldssource)) continue;
-		//print $code.'-'.$label;
-		$alias=preg_replace('/(\..*)$/i','',$label);
-		$listfields[$i]=$langs->trans("Field").' '.$code.'->'.$label;
-	}
-	print sizeof($listfields)?(join(', ',$listfields)):$langs->trans("Error");
-	print '</td></tr>';
-
-	print '</table>';
-
-	// Launch import
-	$arrayoferrors=array();
-	$arrayofwarnings=array();
-	$maxnboferrors=empty($conf->global->IMPORT_MAX_NB_OF_ERRORS)?50:$conf->global->IMPORT_MAX_NB_OF_ERRORS;
-	$maxnbofwarnings=empty($conf->global->IMPORT_MAX_NB_OF_WARNINGS)?50:$conf->global->IMPORT_MAX_NB_OF_WARNINGS;
-	$nboferrors=0;
-	$nbofwarnings=0;
-
-	$importid=dol_print_date(dol_now('tzserver'),'%Y%m%d%H%M%S');
-
-	//var_dump($array_match_file_to_database);
-
-	$db->begin();
-
-	// Open input file
-	$nbok=0;
-	$pathfile=$conf->import->dir_temp.'/'.$filetoimport;
-	$result=$obj->import_open_file($pathfile,$langs);
-	if ($result > 0)
-	{
-		$sourcelinenb=0;
-		// Loop on each input file record
-		while ($sourcelinenb < $nboflines)
-		{
-			$sourcelinenb++;
-			$arrayrecord=$obj->import_read_record();
-			if ($excludefirstline && $sourcelinenb == 1) continue;
-
-			$result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,sizeof($fieldssource),$importid);
-			if (sizeof($obj->errors))   $arrayoferrors[$sourcelinenb]=$obj->errors;
-			if (sizeof($obj->warnings))	$arrayofwarnings[$sourcelinenb]=$obj->warnings;
-			if (! sizeof($obj->errors) && ! sizeof($obj->warnings)) $nbok++;
-		}
-		// Close file
-		$obj->import_close_file();
-	}
-	else
-	{
-		print $langs->trans("ErrorFailedToOpenFile",$pathfile);
-	}
-
-	$db->rollback();	// We force rollback because this was just a simulation.
-
-	print '</div>';
-
-	// Show OK
-	if (! sizeof($arrayoferrors) && ! sizeof($arrayofwarnings)) print img_tick().' <b>'.$langs->trans("NoError").'</b><br><br>';
-	else print $langs->trans("NbOfLinesOK",$nbok).'</b><br><br>';
-
-	// Show Errors
-	//var_dump($arrayoferrors);
-	if (sizeof($arrayoferrors))
-	{
-		print img_error().' <b>'.$langs->trans("ErrorsOnXLines",sizeof($arrayoferrors)).'</b><br>';
-		print '<table width="100%" class="border"><tr><td>';
-		foreach ($arrayoferrors as $key => $val)
-		{
-			$nboferrors++;
-			if ($nboferrors > $maxnboferrors)
-			{
-				print $langs->trans("TooMuchErrors",(sizeof($arrayoferrors)-$nboferrors))."<br>";
-				break;
-			}
-			print '* '.$langs->trans("Line").' '.$key.'<br>';
-			foreach($val as $i => $err)
-			{
-				print ' &nbsp; &nbsp; > '.$err['lib'].'<br>';
-			}
-		}
-		print '</td></tr></table>';
-		print '<br>';
-	}
-
-
-	// Show Warnings
-	//var_dump($arrayoferrors);
-	if (sizeof($arrayofwarnings))
-	{
-		print img_warning().' <b>'.$langs->trans("WarningsOnXLines",sizeof($arrayofwarnings)).'</b><br>';
-		print '<table width="100%" class="border"><tr><td>';
-		foreach ($arrayofwarnings as $key => $val)
-		{
-			$nbofwarnings++;
-			if ($nbofwarnings > $maxnbofwarnings)
-			{
-				print $langs->trans("TooMuchWarnings",(sizeof($arrayofwarnings)-$nbofwarnings))."<br>";
-				break;
-			}
-			print ' * '.$langs->trans("Line").' '.$key.'<br>';
-			foreach($val as $i => $err)
-			{
-				print ' &nbsp; &nbsp; > '.$err['lib'].'<br>';
-			}
-		}
-		print '</td></tr></table>';
-		print '<br>';
-	}
-
-	// Show import id
-	$importid=dol_print_date(dol_now('tzserver'),'%Y%m%d%H%M%S');
-
-	print '<center>';
-	print $langs->trans("NowClickToRunTheImport",$langs->transnoentitiesnoconv("RunImportFile")).'<br>';
-	print $langs->trans("DataLoadedWithId",$importid).'<br>';
-	print '</center>';
-
-	print '<br>';
-
-	// Actions
-	print '<center>';
-	if ($user->rights->import->run)
-	{
-		if (empty($nboferrors))
-		{
-			print '<a class="butAction" href="'.DOL_URL_ROOT.'/imports/import.php?leftmenu=import&step=7&importid='.$importid.$param.'">'.$langs->trans("RunImportFile").'</a>';
-		}
-		else
-		{
-			print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("CorrectErrorBeforeRunningImport")).'">'.$langs->trans("RunImportFile").'</a>';
-		}
-	}
-	else
-	{
-		print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("RunImportFile").'</a>';
-	}
-	/*print '<form action="'.$_SERVER["PHP_SELF"].'?step=6&'.$param.'">';
-	print '<input class="button" type="submit" value="'.$langs->trans("RunSimulateImportFile").'">';
-	print '</form>';*/
-	print '</center>';
-
-	if ($mesg) print $mesg;
-}
-
-
-
-// STEP 7: Real import
-if ($step == 7 && $datatoimport)
 {
 	$model=$format;
 	$liste=$objmodelimport->liste_modeles($db);
@@ -1673,10 +1479,6 @@ if ($step == 7 && $datatoimport)
 
 	$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=6'.$param;
 	$head[$h][1] = $langs->trans("Step")." 6";
-	$h++;
-
-	$head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=7'.$param;
-	$head[$h][1] = $langs->trans("Step")." 7";
 	$hselected=$h;
 	$h++;
 
diff --git a/htdocs/includes/modules/import/import_csv.modules.php b/htdocs/includes/modules/import/import_csv.modules.php
index 077ca9e21b81cbf23005dbadc94b0bc07c01bc3d..7f78201f548f79b9f9bdaaa26a815508f0f0c576 100644
--- a/htdocs/includes/modules/import/import_csv.modules.php
+++ b/htdocs/includes/modules/import/import_csv.modules.php
@@ -50,6 +50,8 @@ class ImportCsv extends ModeleImports
 
     var $handle;    // Handle fichier
 
+    var $cachefieldtable=array();   // Array to cache list of value into fields@tables
+
 
     /**
      *		\brief      Constructeur
@@ -330,7 +332,7 @@ class ImportCsv extends ModeleImports
 						else if ($arrayrecord[($key-1)]['type'] > 0)
 						{
 							$newval=$arrayrecord[($key-1)]['val'];
-							$listvalues.="'".addslashes($arrayrecord[($key-1)]['val'])."'";
+							$listvalues.="'".$this->db->escape($arrayrecord[($key-1)]['val'])."'";
 						}
 
 						// Make some tests
@@ -345,16 +347,55 @@ class ImportCsv extends ModeleImports
 						}
 						// Test format only if field is not a missing mandatory field
 						else {
-							if (! empty($objimport->array_import_regex[0][$val]) && ! preg_match('/'.$objimport->array_import_regex[0][$val].'/i',$newval))
+							if (! empty($objimport->array_import_regex[0][$val]))
 							{
-								$this->errors[$error]['lib']=$langs->trans('ErrorWrongValueForField',$key,$newval,$objimport->array_import_regex[0][$val]);
-								$this->errors[$error]['type']='REGEX';
-								$errorforthistable++;
-								$error++;
+							    // If test is "Must exist in a field@table"
+							    if (preg_match('/^(.*)@(.*)$/',$objimport->array_import_regex[0][$val],$reg))
+							    {
+							        $field=$reg[1];
+							        $table=$reg[2];
+
+							        if (! is_array($this->cachefieldtable[$field.'@'.$table])) // If content of field@table no already loaded into cache
+							        {
+                                        $sql="SELECT ".$field." as aliasfield FROM ".$table;
+                                        $resql=$this->db->query($sql);
+                                        if ($resql)
+                                        {
+                                            $num=$this->db->num_rows($resql);
+                                            $i=0;
+                                            while ($i < $num)
+                                            {
+                                                $obj=$this->db->fetch_object($resql);
+                                                if ($obj) $this->cachefieldtable[$field.'@'.$table][]=$obj->aliasfield;
+                                                $i++;
+                                            }
+                                        }
+                                        else
+                                        {
+                                            dol_print_error($this->db);
+                                        }
+							        }
+
+							        // Now we check in cache
+							        if (! in_array($newval,$this->cachefieldtable[$field.'@'.$table]))
+							        {
+                                        $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn',$key,$newval,$field,$table);
+                                        $this->errors[$error]['type']='FOREIGNKEY';
+							            $error++;
+							        }
+							    }
+							    // If test is just a static regex
+                                else if (! preg_match('/'.$objimport->array_import_regex[0][$val].'/i',$newval))
+                                {
+    							    $this->errors[$error]['lib']=$langs->trans('ErrorWrongValueForField',$key,$newval,$objimport->array_import_regex[0][$val]);
+    								$this->errors[$error]['type']='REGEX';
+    								$errorforthistable++;
+    								$error++;
+                                }
 							}
 
-							// Other tests
-							// ...
+                            // Other tests
+                            // ...
 						}
 					}
 					$i++;
diff --git a/htdocs/includes/modules/modAdherent.class.php b/htdocs/includes/modules/modAdherent.class.php
index 6e64499301bd5beb27a8e955349d4592195ab970..0de813dd1fd372c0781fe45ca0ff735fc24ff34e 100644
--- a/htdocs/includes/modules/modAdherent.class.php
+++ b/htdocs/includes/modules/modAdherent.class.php
@@ -209,16 +209,19 @@ class modAdherent extends DolibarrModules
         //--------
         $r=0;
 
+        $now=dol_now();
+        require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
+
         $r++;
         $this->import_code[$r]=$this->rights_class.'_'.$r;
         $this->import_label[$r]="Members"; // Translation key
         $this->import_icon[$r]=$this->picto;
         $this->import_tables_array[$r]=array('a'=>MAIN_DB_PREFIX.'adherent');
         $this->import_tables_creator_array[$r]=array('a'=>'fk_user_author');    // Fields to store import user id
-        $this->import_fields_array[$r]=array('a.civilite'=>"Civility",'a.nom'=>"Lastname*",'a.prenom'=>"Firstname",'a.login'=>"Login*","a.pass"=>"Password","a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'MorPhy*','a.societe'=>'Company','a.adresse'=>"Address",'a.cp'=>"Zip",'a.ville'=>"Town",'a.pays'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.naiss'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note'=>"Note",'a.datec'=>'DateCreation');
+        $this->import_fields_array[$r]=array('a.civilite'=>"Civility",'a.nom'=>"Lastname*",'a.prenom'=>"Firstname",'a.login'=>"Login*","a.pass"=>"Password","a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'MorPhy*','a.societe'=>'Company','a.adresse'=>"Address",'a.cp'=>"Zip",'a.ville'=>"Town",'a.pays'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.naiss'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note'=>"Note",'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription');
         $this->import_entities_array[$r]=array();   // We define here only fields that use another picto
-        $this->import_regex_array[$r]=array('a.civilite'=>'code@'.MAIN_DB_PREFIX.'c_civilite','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)','a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
-        $this->import_examplevalues_array[$r]=array('a.civilite'=>"MR",'a.nom'=>'Smith','a.prenom'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1','a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.adresse'=>'21 jump street','a.cp'=>'55000','a.ville'=>'New York','a.pays'=>'US','a.email'=>'jsmith@example.com','a.naiss'=>'1972-10-10','a.statut'=>"0 or 1",'a.note'=>"This is a comment on member",'a.datec'=>'2008-12-31');
+        $this->import_regex_array[$r]=array('a.civilite'=>'code@'.MAIN_DB_PREFIX.'c_civilite','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)','a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
+        $this->import_examplevalues_array[$r]=array('a.civilite'=>"MR",'a.nom'=>'Smith','a.prenom'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1','a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.adresse'=>'21 jump street','a.cp'=>'55000','a.ville'=>'New York','a.pays'=>'1','a.email'=>'jsmith@example.com','a.naiss'=>'1972-10-10','a.statut'=>"0 or 1",'a.note'=>"This is a comment on member",'a.datec'=>dol_print_date($now,'%Y-%m-%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'),'%Y-%m-%d'));
     }
 
 
diff --git a/htdocs/install/mysql/migration/2.9.0-3.0.0.sql b/htdocs/install/mysql/migration/2.9.0-3.0.0.sql
index e54586e5cef6402cd1aef58b713f9a6439f1f58b..54017e54babf936d8b45487185bfa967a6a7a509 100644
--- a/htdocs/install/mysql/migration/2.9.0-3.0.0.sql
+++ b/htdocs/install/mysql/migration/2.9.0-3.0.0.sql
@@ -65,3 +65,7 @@ UPDATE llx_c_tva SET taux = '18' WHERE rowid = 41;
 UPDATE llx_c_tva SET taux = '8' WHERE rowid = 42;
 DELETE FROM llx_c_tva WHERE rowid = 45;
 DELETE FROM llx_c_tva WHERE rowid = 46;
+
+
+ALTER TABLE llx_adherent  ADD COLUMN import_key varchar(14);
+ALTER TABLE llx_categorie ADD COLUMN import_key varchar(14);
diff --git a/htdocs/install/mysql/tables/llx_adherent.sql b/htdocs/install/mysql/tables/llx_adherent.sql
index 7fff4961116ae761eba49ea540312a1c3d453f9f..16ac7ba24cb78117a114af2eeebcabe4efcc223f 100644
--- a/htdocs/install/mysql/tables/llx_adherent.sql
+++ b/htdocs/install/mysql/tables/llx_adherent.sql
@@ -59,5 +59,6 @@ create table llx_adherent
   tms              timestamp, -- date de modification
   fk_user_author   integer,   -- can be null because member can be create by a guest
   fk_user_mod      integer,
-  fk_user_valid    integer 
+  fk_user_valid    integer,
+  import_key       varchar(14)                  -- Import key
 )type=innodb;
diff --git a/htdocs/install/mysql/tables/llx_categorie.sql b/htdocs/install/mysql/tables/llx_categorie.sql
index f49968d813da04805998a606ec5b5249469bb5bd..43b85d8d5a4f3632dc39bccb9c3439b6a7c4c62b 100644
--- a/htdocs/install/mysql/tables/llx_categorie.sql
+++ b/htdocs/install/mysql/tables/llx_categorie.sql
@@ -25,10 +25,11 @@ create table llx_categorie
 	rowid 		    integer AUTO_INCREMENT PRIMARY KEY,
 	label 		    varchar(255),                       -- category name
 	type	        tinyint DEFAULT 1 NOT NULL,         -- category type (product, supplier, customer)
-	entity        integer DEFAULT 1 NOT NULL,	        -- multi company id
+	entity          integer DEFAULT 1 NOT NULL,	        -- multi company id
 	description 	text,                               -- description of the category
-	fk_soc        integer DEFAULT NULL,						  	-- attribution of the category has a company (for product only)
-	visible       tinyint DEFAULT 1 NOT NULL          -- determine if the products are visible or not
+	fk_soc          integer DEFAULT NULL,					-- attribution of the category has a company (for product only)
+	visible         tinyint DEFAULT 1 NOT NULL,           -- determine if the products are visible or not
+    import_key      varchar(14)                  -- Import key
 )type=innodb;
 
 -- 
diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang
index 0f02addd3304cecc109e37f2159f5fa13338e437..0c20dea193c29146dbbfd7c47249cf5e363a0d33 100644
--- a/htdocs/langs/en_US/errors.lang
+++ b/htdocs/langs/en_US/errors.lang
@@ -64,6 +64,7 @@ ErrorModuleRequireJavascript=Javascript must not be disabled to have this featur
 ErrorPasswordsMustMatch=Both typed passwords must match each other
 ErrorContactEMail=A technical error occured. Please, contact administrator to folowwing email <b>%s</b> en provide the error code <b>%s</b> in your message, or even better by adding a screen copy of this page.
 ErrorWrongValueForField=Wrong value for field number <b>%s</b> (value '<b>%s</b>' does not match regex rule <b>%s</b>)
+ErrorFieldValueNotIn=Wrong value for field number<b>%s</b> (value '<b>%s</b>' is not a value available into field <b>%s</b> of table <b>%s</b>)
 ErrorsOnXLines=Errors on <b>%s</b> source lines
 WarningsOnXLines=Warnings on <b>%s</b> source lines
 ErrorFileIsInfectedWithAVirus=The antivirus program was not able to validate the file (file might be infected by a virus)
diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang
index 28fddf64932cae97516d9764f3126fe812c0ed6e..32d07f6cda6e3c9356ef1e5b3c4ed36e1d0a12e1 100644
--- a/htdocs/langs/fr_FR/errors.lang
+++ b/htdocs/langs/fr_FR/errors.lang
@@ -65,6 +65,7 @@ ErrorModuleRequireJavascript=Le javascript ne doit pas être désactivé pour qu
 ErrorPasswordsMustMatch=Les 2 mots de passe saisis doivent correspondre
 ErrorContactEMail=Une erreur technique est apparue. Merci de contacter l'administrateur à l'email suivant <b>%s</b> en lui indiquant le code erreur <b>%s</b> dans votre message ou mieux en fournissant une copie d'écran de cette page.
 ErrorWrongValueForField=Mauvaise valeur pour le champ numéro <b>%s</b> (la valeur '<b>%s</b>' ne respecte pas la règle <b>%s</b>)
+ErrorFieldValueNotIn=Mauvaise valeur pour le champ numéro <b>%s</b> (la valeur '<b>%s</b>' n'est pas une valeure présente dans le champ <b>%s</b> de la table <b>%s</b>)
 ErrorsOnXLines=Erreurs sur <b>%s</b> lignes sources
 WarningsOnXLines=Alertes sur <b>%s</b> lignes sources
 ErrorFileIsInfectedWithAVirus=L'antivirus n'a pas pu valider ce fichier (il est probablement infecté par un virus) !
diff --git a/htdocs/lib/date.lib.php b/htdocs/lib/date.lib.php
index f32a916b5782f7885828c4d688c16ed7e8dff1a3..d2d702c6a689e09d2a6c546e69118eaf9d4be952 100644
--- a/htdocs/lib/date.lib.php
+++ b/htdocs/lib/date.lib.php
@@ -21,15 +21,34 @@
 /**
  *  \file		htdocs/lib/date.lib.php
  *  \brief		Ensemble de fonctions de base de dolibarr sous forme d'include
- *  \version		$Id$
+ *  \version	$Id$
  */
 
 
-/**   \brief      Converti les heures et minutes en secondes
- *    \param      iHours      Heures
- *    \param      iMinutes    Minutes
- *    \param      iSeconds    Secondes
- *    \return     iResult	    Temps en secondes
+/**
+ *  Add a delay to a date
+ *  @param      time                Date timestamp ou au format YYYY-MM-DD
+ *  @param      duration_value      Value of delay to add
+ *  @param      duration_unit       Unit of added delay (d, m, y)
+ *  @return     int                 New timestamp
+ */
+function dol_time_plus_duree($time,$duration_value,$duration_unit)
+{
+    if ($duration_value == 0) return $time;
+    if ($duration_value > 0) $deltastring="+".abs($duration_value);
+    if ($duration_value < 0) $deltastring="-".abs($duration_value);
+    if ($duration_unit == 'd') { $deltastring.=" day"; }
+    if ($duration_unit == 'm') { $deltastring.=" month"; }
+    if ($duration_unit == 'y') { $deltastring.=" year"; }
+    return strtotime($deltastring,$time);
+}
+
+
+/**   Converti les heures et minutes en secondes
+ *    @param      iHours      Heures
+ *    @param      iMinutes    Minutes
+ *    @param      iSeconds    Secondes
+ *    @return     iResult	    Temps en secondes
  */
 function ConvertTime2Seconds($iHours=0,$iMinutes=0,$iSeconds=0)
 {
@@ -38,13 +57,12 @@ function ConvertTime2Seconds($iHours=0,$iMinutes=0,$iSeconds=0)
 }
 
 
-/**	  	\brief      Return, in clear text, value of a number of seconds in days, hours and minutes
- *    	\param      iSecond		Number of seconds
- *    	\param      format		Output format (all: complete display, hour: displays only hours, min: displays only minutes)
- *    	\param      lengthOfDay	Length of day (default 86400 seconds)
- *    	\return     sTime		Formated text of duration
- * 		\example	0 return 00:00, 3600 return 1:00, 86400 return 1d, 90000 return 1 Day 01:00
- *
+/**	  	Return, in clear text, value of a number of seconds in days, hours and minutes
+ *    	@param      iSecond		Number of seconds
+ *    	@param      format		Output format (all: complete display, hour: displays only hours, min: displays only minutes)
+ *    	@param      lengthOfDay	Length of day (default 86400 seconds)
+ *    	@return     sTime		Formated text of duration
+ * 		@example	0 return 00:00, 3600 return 1:00, 86400 return 1d, 90000 return 1 Day 01:00
  */
 function ConvertSecondToTime($iSecond,$format='all',$lengthOfDay=86400)
 {
@@ -86,10 +104,10 @@ function ConvertSecondToTime($iSecond,$format='all',$lengthOfDay=86400)
 }
 
 
-/**	\brief		Return previous month
- *	\param		month	Month
- *	\param		year	Year
- *	\return		array	Previous year,month
+/**	Return previous month
+ *	@param		month	Month
+ *	@param		year	Year
+ *	@return		array	Previous year,month
  */
 function dol_get_prev_month($month, $year)
 {
@@ -106,10 +124,10 @@ function dol_get_prev_month($month, $year)
 	return array('year' => $prev_year, 'month' => $prev_month);
 }
 
-/**	\brief		Return next month
- *	\param		month	Month
- *	\param		year	Year
- *	\return		array	Next year,month
+/**	Return next month
+ *	@param		month	Month
+ *	@param		year	Year
+ *	@return		array	Next year,month
  */
 function dol_get_next_month($month, $year)
 {
@@ -127,13 +145,13 @@ function dol_get_next_month($month, $year)
 }
 
 
-/**	\brief		Return GMT time for first day of a month or year
- *	\param		year		Year
- * 	\param		month		Month
- * 	\param		gm			False = Return date to compare with server TZ, True to compare with GM date.
+/**	Return GMT time for first day of a month or year
+ *	@param		year		Year
+ * 	@param		month		Month
+ * 	@param		gm			False = Return date to compare with server TZ, True to compare with GM date.
  *                          Exemple: dol_get_first_day(1970,1,false) will return -3600 with TZ+1, after a dol_print_date will return 1970-01-01 00:00:00
  *                          Exemple: dol_get_first_day(1970,1,true) will return 0 whatever is TZ, after a dol_print_date will return 1970-01-01 00:00:00
- *  \return		Timestamp	Date for first day
+ *  @return		Timestamp	Date for first day
  */
 function dol_get_first_day($year,$month=1,$gm=false)
 {
@@ -141,11 +159,11 @@ function dol_get_first_day($year,$month=1,$gm=false)
 }
 
 
-/**	\brief		Return GMT time for last day of a month or year
- *	\param		year		Year
- * 	\param		month		Month
- * 	\param		gm			False = Return date to compare with server TZ, True to compare with GM date.
- *	\return		Timestamp	Date for first day
+/**	Return GMT time for last day of a month or year
+ *	@param		year		Year
+ * 	@param		month		Month
+ * 	@param		gm			False = Return date to compare with server TZ, True to compare with GM date.
+ *	@return		Timestamp	Date for first day
  */
 function dol_get_last_day($year,$month=12,$gm=false)
 {
@@ -168,11 +186,11 @@ function dol_get_last_day($year,$month=12,$gm=false)
 
 
 /**
- *	\brief     	Fonction retournant le nombre de jour fieries samedis et dimanches entre 2 dates entrees en timestamp
- *	\remarks	Called by function num_open_day
- *	\param	    timestampStart      Timestamp de debut
- *	\param	    timestampEnd        Timestamp de fin
- *	\return   	nbFerie             Nombre de jours feries
+ *	Fonction retournant le nombre de jour fieries samedis et dimanches entre 2 dates entrees en timestamp
+ *	@remarks	Called by function num_open_day
+ *	@param	    timestampStart      Timestamp de debut
+ *	@param	    timestampEnd        Timestamp de fin
+ *	@return   	nbFerie             Nombre de jours feries
  */
 function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR')
 {
@@ -266,11 +284,11 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR')
 }
 
 /**
- *	\brief     Fonction retournant le nombre de jour entre deux dates
- *	\param	   timestampStart      Timestamp de debut
- *	\param	   timestampEnd        Timestamp de fin
- *	\param     lastday             On prend en compte le dernier jour, 0: non, 1:oui
- *	\return    nbjours             Nombre de jours
+ *	Fonction retournant le nombre de jour entre deux dates
+ *	@param	   timestampStart      Timestamp de debut
+ *	@param	   timestampEnd        Timestamp de fin
+ *	@param     lastday             On prend en compte le dernier jour, 0: non, 1:oui
+ *	@return    nbjours             Nombre de jours
  */
 function num_between_day($timestampStart, $timestampEnd, $lastday=0)
 {
@@ -290,12 +308,12 @@ function num_between_day($timestampStart, $timestampEnd, $lastday=0)
 }
 
 /**
- *	\brief     Fonction retournant le nombre de jour entre deux dates sans les jours feries (jours ouvres)
- *	\param	   timestampStart      Timestamp de debut
- *	\param	   timestampEnd        Timestamp de fin
- *	\param     inhour              0: sort le nombre de jour , 1: sort le nombre d'heure (72 max)
- *	\param     lastday             On prend en compte le dernier jour, 0: non, 1:oui
- *	\return    nbjours             Nombre de jours ou d'heures
+ *	Fonction retournant le nombre de jour entre deux dates sans les jours feries (jours ouvres)
+ *	@param	   timestampStart      Timestamp de debut
+ *	@param	   timestampEnd        Timestamp de fin
+ *	@param     inhour              0: sort le nombre de jour , 1: sort le nombre d'heure (72 max)
+ *	@param     lastday             On prend en compte le dernier jour, 0: non, 1:oui
+ *	@return    nbjours             Nombre de jours ou d'heures
  */
 function num_open_day($timestampStart, $timestampEnd,$inhour=0,$lastday=0)
 {
diff --git a/htdocs/lib/files.lib.php b/htdocs/lib/files.lib.php
index f1a348e877acb046ce98cb5d3997a240f651949e..a5b3cd7cf7b79343a662e3b9ae19a78852444e9a 100644
--- a/htdocs/lib/files.lib.php
+++ b/htdocs/lib/files.lib.php
@@ -24,16 +24,16 @@
  */
 
 /**
- *  \brief		Scan a directory and return a list of files/directories. Content for string is UTF8.
- *  \param		$path        	Starting path from which to search
- *  \param		$types        	Can be "directories", "files", or "all"
- *  \param		$recursive		Determines whether subdirectories are searched
- *  \param		$filter        	Regex for include filter
- *  \param		$exludefilter  	Regex for exclude filter (example: '\.meta$')
- *  \param		$sortcriteria	Sort criteria ("name","date","size")
- *  \param		$sortorder		Sort order (SORT_ASC, SORT_DESC)
- *	\param		$mode			0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower)
- *  \return		array			Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file')
+ *  Scan a directory and return a list of files/directories. Content for string is UTF8.
+ *  @param		$path        	Starting path from which to search
+ *  @param		$types        	Can be "directories", "files", or "all"
+ *  @param		$recursive		Determines whether subdirectories are searched
+ *  @param		$filter        	Regex for include filter
+ *  @param		$exludefilter  	Regex for exclude filter (example: '\.meta$')
+ *  @param		$sortcriteria	Sort criteria ("name","date","size")
+ *  @param		$sortorder		Sort order (SORT_ASC, SORT_DESC)
+ *	@param		$mode			0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower)
+ *  @return		array			Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file')
  */
 function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0)
 {
diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php
index ebf3ffe3ebb4c4082032d298b18b1e484101d492..ae30d75e387042282e78ac018aaec58d76b9a4f4 100644
--- a/htdocs/lib/functions.lib.php
+++ b/htdocs/lib/functions.lib.php
@@ -393,8 +393,8 @@ function dol_fiche_head($links, $active='0', $title='', $notab=0, $picto='')
 }
 
 /**
- *	\brief      Show tab footer of a card
- *	\param      notab		0=Add tab footer, 1=no tab footer
+ *	Show tab footer of a card
+ *	@param      notab		0=Add tab footer, 1=no tab footer
  */
 function dol_fiche_end($notab=0)
 {
@@ -402,25 +402,6 @@ function dol_fiche_end($notab=0)
 }
 
 
-/**
- *	\brief      Add a delay to a date
- *	\param	    time                Date timestamp ou au format YYYY-MM-DD
- *	\param	    duration_value      Value of delay to add
- *	\param	    duration_unit       Unit of added delay (d, m, y)
- *	\return     int                 New timestamp
- */
-function dol_time_plus_duree($time,$duration_value,$duration_unit)
-{
-	if ($duration_value == 0) return $time;
-	if ($duration_value > 0) $deltastring="+".abs($duration_value);
-	if ($duration_value < 0) $deltastring="-".abs($duration_value);
-	if ($duration_unit == 'd') { $deltastring.=" day"; }
-	if ($duration_unit == 'm') { $deltastring.=" month"; }
-	if ($duration_unit == 'y') { $deltastring.=" year"; }
-	return strtotime($deltastring,$time);
-}
-
-
 /* For backward compatibility */
 function dolibarr_print_date($time,$format='',$to_gmt=false,$outputlangs='',$encodetooutput=false)
 {
@@ -1101,15 +1082,15 @@ function img_object($alt, $object)
 function img_picto($alt, $picto, $options='', $pictoisfullpath=0)
 {
 	global $conf;
-	
+
 	$path =  'theme/'.$conf->theme;
-	
+
 	if (preg_match('/^([^@]+)@([^@]+)$/i',$picto,$regs))
 	{
 		$picto = $regs[1];
 		$path = $regs[2];
 	}
-	
+
 	if (! preg_match('/(\.png|\.gif)$/i',$picto)) $picto.='.png';
 	if ($pictoisfullpath) return '<img src="'.$picto.'" border="0" alt="'.dol_escape_htmltag($alt).'" title="'.dol_escape_htmltag($alt).'"'.($options?' '.$options:'').'>';
 	return '<img src="'.DOL_URL_ROOT.'/'.$path.'/img/'.$picto.'" border="0" alt="'.dol_escape_htmltag($alt).'" title="'.dol_escape_htmltag($alt).'"'.($options?' '.$options:'').'>';
@@ -2422,7 +2403,7 @@ function price($amount, $html=0, $outlangs='', $trunc=1, $rounding=-1, $forcerou
 			$end='...';
 		}
 	}
-	
+
 	// If force rounding
 	if ($forcerounding >= 0) $nbdecimal = $forcerounding;
 
diff --git a/htdocs/public/paybox/newpayment.php b/htdocs/public/paybox/newpayment.php
index 77ae8b18756d9f64550eb81c243c5278fa42f116..6fa4c4dfc8de956b142764af376fd150a37005c2 100644
--- a/htdocs/public/paybox/newpayment.php
+++ b/htdocs/public/paybox/newpayment.php
@@ -475,8 +475,6 @@ if ($_REQUEST["amount"] == 'contractline')
 	//}
 	if ($contractline->date_fin_validite)
 	{
-		//$dateactend = dol_time_plus_duree ($contractline->date_fin_validite, $product->duration_value, $product->duration_unit);
-		//print ', '.$langs->trans("DateEndPlanned").': '.dol_print_date($contractline->date_fin_validite);
 		$text.='<br>'.$langs->trans("ExpiredSince").': '.dol_print_date($contractline->date_fin_validite);
 	}
 
diff --git a/scripts/members/sync_members_ldap2dolibarr.php b/scripts/members/sync_members_ldap2dolibarr.php
index ea4eb36a58c29ecdf475b82df84a2382c29fccd8..385912b7af9a2e1a96f272d4a3d538e072b3a991 100644
--- a/scripts/members/sync_members_ldap2dolibarr.php
+++ b/scripts/members/sync_members_ldap2dolibarr.php
@@ -1,6 +1,6 @@
 <?PHP
 /* Copyright (C) 2005      Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2006-2009 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2006-2010 Laurent Destailleur  <eldy@users.sourceforge.net>
  *
  * 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
@@ -42,6 +42,7 @@ $forcecommit=0;
 
 
 require_once($path."../../htdocs/master.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
 require_once(DOL_DOCUMENT_ROOT."/lib/ldap.class.php");
 require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
 require_once(DOL_DOCUMENT_ROOT."/adherents/class/cotisation.class.php");