diff --git a/ChangeLog b/ChangeLog
index 470d4647b9e..c64c7f74931 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 b606076b25d..22ec0059b0c 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 '
| '.$langs->trans("DateEndSubscription").' | ';
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index 045d1bb33a1..57378b016a7 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 e4a979ac5b4..0030758f2c0 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 94b55fb6d0f..0f5e64cb7bb 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 '';
- // Show import id
- print $langs->trans("NowClickToTestTheImport",$langs->transnoentitiesnoconv("RunSimulateImportFile")).' ';
- print ' ';
+ if (GETPOST('action') != 'launchsimu')
+ {
+ // Show import id
+ print $langs->trans("NowClickToTestTheImport",$langs->transnoentitiesnoconv("RunSimulateImportFile")).' ';
+ print ' ';
+ // Actions
+ print '';
+ if ($user->rights->import->run)
+ {
+ print ''.$langs->trans("RunSimulateImportFile").'';
+ }
+ else
+ {
+ print ''.$langs->trans("RunSimulateImportFile").'';
+ }
+ print '';
+ }
+ else
+ {
- // Actions
- print '';
- if ($user->rights->import->run)
- {
- print ''.$langs->trans("RunSimulateImportFile").'';
- }
- else
- {
- print ''.$langs->trans("RunSimulateImportFile").'';
- }
- /*print '';*/
- print '';
+ // 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;
- if ($mesg) print $mesg;
+ $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().' '.$langs->trans("NoError").'
';
+ else print $langs->trans("NbOfLinesOK",$nbok).'
';
+
+ // Show Errors
+ //var_dump($arrayoferrors);
+ if (sizeof($arrayoferrors))
+ {
+ print img_error().' '.$langs->trans("ErrorsOnXLines",sizeof($arrayoferrors)).' ';
+ print '';
+ foreach ($arrayoferrors as $key => $val)
+ {
+ $nboferrors++;
+ if ($nboferrors > $maxnboferrors)
+ {
+ print $langs->trans("TooMuchErrors",(sizeof($arrayoferrors)-$nboferrors))." ";
+ break;
+ }
+ print '* '.$langs->trans("Line").' '.$key.' ';
+ foreach($val as $i => $err)
+ {
+ print ' > '.$err['lib'].' ';
+ }
+ }
+ print ' | ';
+ print ' ';
+ }
+
+ // Show Warnings
+ //var_dump($arrayoferrors);
+ if (sizeof($arrayofwarnings))
+ {
+ print img_warning().' '.$langs->trans("WarningsOnXLines",sizeof($arrayofwarnings)).' ';
+ print '';
+ foreach ($arrayofwarnings as $key => $val)
+ {
+ $nbofwarnings++;
+ if ($nbofwarnings > $maxnbofwarnings)
+ {
+ print $langs->trans("TooMuchWarnings",(sizeof($arrayofwarnings)-$nbofwarnings))." ";
+ break;
+ }
+ print ' * '.$langs->trans("Line").' '.$key.' ';
+ foreach($val as $i => $err)
+ {
+ print ' > '.$err['lib'].' ';
+ }
+ }
+ print ' | ';
+ print ' ';
+ }
+
+ // Show import id
+ $importid=dol_print_date(dol_now('tzserver'),'%Y%m%d%H%M%S');
+
+ print '';
+ print $langs->trans("NowClickToRunTheImport",$langs->transnoentitiesnoconv("RunImportFile")).' ';
+ print $langs->trans("DataLoadedWithId",$importid).' ';
+ print '';
+
+ print ' ';
+
+ // Actions
+ print '';
+ if ($user->rights->import->run)
+ {
+ if (empty($nboferrors))
+ {
+ print ''.$langs->trans("RunImportFile").'';
+ }
+ else
+ {
+ //print ''.$langs->trans("RunSimulateImportFile").'';
+
+ print ''.$langs->trans("RunImportFile").'';
+ }
+ }
+ else
+ {
+ print ''.$langs->trans("RunSimulateImportFile").'';
+
+ print ''.$langs->trans("RunImportFile").'';
+ }
+ print '';
+ }
+
+ 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ó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 '';
-
- // Module
- print '| '.$langs->trans("Module").' | ';
- print '';
- //print img_object($objimport->array_import_module[0]->getName(),$objimport->array_import_module[0]->picto).' ';
- print $objimport->array_import_module[0]->getName();
- print ' | ';
-
- // Lot de donnees a importer
- print '| '.$langs->trans("DatasetToImport").' | ';
- print '';
- print img_object($objimport->array_import_module[0]->getName(),$objimport->array_import_icon[0]).' ';
- print $objimport->array_import_label[0];
- print ' | ';
-
- print ' ';
- print ''.$langs->trans("InformationOnSourceFile").'';
- print '';
-
- print ' ';
-
- print ''.$langs->trans("InformationOnTargetTables").'';
- print '';
- //print '| '.$langs->trans("InformationOnTargetTables").' | ';
-
- // Tables imported
- print '| ';
- print $langs->trans("TablesTarget");
- print ' | ';
- $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.=' '.img_picto($langs->trans($mode == 'wiki' ? 'GoToWikiHelpPage': 'GoToHelpPage'),DOL_URL_ROOT.'/theme/common/helpdoc.png','',1).'';
- }*/
- print $newval;
- }
- }
- else print $langs->trans("Error");
- print ' | ';
-
- // Fields imported
- print '| ';
- print $langs->trans("FieldsTarget").' | ';
- $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 ' | ';
-
- print ' ';
-
- // 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 '';
-
- // Show OK
- if (! sizeof($arrayoferrors) && ! sizeof($arrayofwarnings)) print img_tick().' '.$langs->trans("NoError").'
';
- else print $langs->trans("NbOfLinesOK",$nbok).'
';
-
- // Show Errors
- //var_dump($arrayoferrors);
- if (sizeof($arrayoferrors))
- {
- print img_error().' '.$langs->trans("ErrorsOnXLines",sizeof($arrayoferrors)).' ';
- print '';
- foreach ($arrayoferrors as $key => $val)
- {
- $nboferrors++;
- if ($nboferrors > $maxnboferrors)
- {
- print $langs->trans("TooMuchErrors",(sizeof($arrayoferrors)-$nboferrors))." ";
- break;
- }
- print '* '.$langs->trans("Line").' '.$key.' ';
- foreach($val as $i => $err)
- {
- print ' > '.$err['lib'].' ';
- }
- }
- print ' | ';
- print ' ';
- }
-
-
- // Show Warnings
- //var_dump($arrayoferrors);
- if (sizeof($arrayofwarnings))
- {
- print img_warning().' '.$langs->trans("WarningsOnXLines",sizeof($arrayofwarnings)).' ';
- print '';
- foreach ($arrayofwarnings as $key => $val)
- {
- $nbofwarnings++;
- if ($nbofwarnings > $maxnbofwarnings)
- {
- print $langs->trans("TooMuchWarnings",(sizeof($arrayofwarnings)-$nbofwarnings))." ";
- break;
- }
- print ' * '.$langs->trans("Line").' '.$key.' ';
- foreach($val as $i => $err)
- {
- print ' > '.$err['lib'].' ';
- }
- }
- print ' | ';
- print ' ';
- }
-
- // Show import id
- $importid=dol_print_date(dol_now('tzserver'),'%Y%m%d%H%M%S');
-
- print '';
- print $langs->trans("NowClickToRunTheImport",$langs->transnoentitiesnoconv("RunImportFile")).' ';
- print $langs->trans("DataLoadedWithId",$importid).' ';
- print '';
-
- print ' ';
-
- // Actions
- print '';
- if ($user->rights->import->run)
- {
- if (empty($nboferrors))
- {
- print ''.$langs->trans("RunImportFile").'';
- }
- else
- {
- print ''.$langs->trans("RunImportFile").'';
- }
- }
- else
- {
- print ''.$langs->trans("RunImportFile").'';
- }
- /*print '';*/
- print '';
-
- 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 077ca9e21b8..7f78201f548 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 6e64499301b..0de813dd1fd 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 e54586e5cef..54017e54bab 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 7fff4961116..16ac7ba24cb 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 f49968d813d..43b85d8d5a4 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 0f02addd330..0c20dea193c 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 %s en provide the error code %s in your message, or even better by adding a screen copy of this page.
ErrorWrongValueForField=Wrong value for field number %s (value '%s' does not match regex rule %s)
+ErrorFieldValueNotIn=Wrong value for field number%s (value '%s' is not a value available into field %s of table %s)
ErrorsOnXLines=Errors on %s source lines
WarningsOnXLines=Warnings on %s 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 28fddf64932..32d07f6cda6 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 %s en lui indiquant le code erreur %s dans votre message ou mieux en fournissant une copie d'écran de cette page.
ErrorWrongValueForField=Mauvaise valeur pour le champ numéro %s (la valeur '%s' ne respecte pas la règle %s)
+ErrorFieldValueNotIn=Mauvaise valeur pour le champ numéro %s (la valeur '%s' n'est pas une valeure présente dans le champ %s de la table %s)
ErrorsOnXLines=Erreurs sur %s lignes sources
WarningsOnXLines=Alertes sur %s 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 f32a916b578..d2d702c6a68 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 f1a348e877a..a5b3cd7cf7b 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 ebf3ffe3ebb..ae30d75e387 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 ' ';
return ' ';
@@ -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 77ae8b18756..6fa4c4dfc8d 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.=' '.$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 ea4eb36a58c..385912b7af9 100644
--- a/scripts/members/sync_members_ldap2dolibarr.php
+++ b/scripts/members/sync_members_ldap2dolibarr.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2006-2009 Laurent Destailleur
+ * Copyright (C) 2006-2010 Laurent Destailleur
*
* 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");
|